|
| fsp_err_t | R_EXDMAC_Open (transfer_ctrl_t *const p_api_ctrl, transfer_cfg_t const *const p_cfg) |
| |
| fsp_err_t | R_EXDMAC_Reconfigure (transfer_ctrl_t *const p_api_ctrl, transfer_info_t *p_info) |
| |
| fsp_err_t | R_EXDMAC_Reset (transfer_ctrl_t *const p_api_ctrl, void const *volatile p_src, void *volatile p_dest, uint16_t const num_transfers) |
| |
| fsp_err_t | R_EXDMAC_SoftwareStart (transfer_ctrl_t *const p_api_ctrl, transfer_start_mode_t mode) |
| |
| fsp_err_t | R_EXDMAC_SoftwareStop (transfer_ctrl_t *const p_api_ctrl) |
| |
| fsp_err_t | R_EXDMAC_Enable (transfer_ctrl_t *const p_api_ctrl) |
| |
| fsp_err_t | R_EXDMAC_Disable (transfer_ctrl_t *const p_api_ctrl) |
| |
| fsp_err_t | R_EXDMAC_InfoGet (transfer_ctrl_t *const p_api_ctrl, transfer_properties_t *const p_info) |
| |
| fsp_err_t | R_EXDMAC_Reload (transfer_ctrl_t *const p_api_ctrl, void const *p_src, void *p_dest, uint32_t const num_transfers) |
| |
| fsp_err_t | R_EXDMAC_Close (transfer_ctrl_t *const p_api_ctrl) |
| |
| fsp_err_t | R_EXDMAC_CallbackSet (transfer_ctrl_t *const p_api_ctrl, void(*p_callback)(exdmac_callback_args_t *), void *const p_context, exdmac_callback_args_t *const p_callback_memory) |
| |
Driver for the EXDMAC peripheral on RX MCUs. This module implements the Transfer Interface.
Overview
The Direct Memory Access Controller (EXDMAC) designed exclusively for external bus. It can transfers data from one memory location to another without using the CPU.
Features
- Supports multiple transfer modes
- Normal transfer
- Repeat transfer
- Block transfer
- Repeat-Block transfer (Not available on all MCUs)
- Address increment, decrement, fixed, or offset modes
- Triggered by interrupt source of software configurable interrupts and external pins interrupts
- Refer to the Interrupt Controller Unit Chapter of the hardware manual for the interrupt source numbers and the interrupt vector table for external pin interrupts.
- Supports 1, 2, and 4 byte data units
Configuration
Build Time Configurations for r_exdmac
The following build time configurations are defined in fsp_cfg/r_exdmac_cfg.h:
| Configuration | Options | Default | Description |
| Parameter Checking |
-
Default (BSP)
-
Enabled
-
Disabled
| Default (BSP) | If selected code for parameter checking is included in the build. |
Configurations for Transfer > Transfer (r_exdmac)
This module can be added to the Stacks tab via New Stack > Transfer > Transfer (r_exdmac).
| Configuration | Options | Default | Description |
| Name | Name must be a valid C symbol | g_transfer0 | Module name. |
| Channel | Value must be a non-negative integer | 0 | Specify the hardware channel. |
| Mode | MCU Specific Options | | Select the transfer mode. Normal: One transfer per activation, transfer ends after Number of Transfers; Repeat: One transfer per activation, Repeat Area address reset after Number of Transfers, transfer ends after Number of Blocks; Block: Number of Blocks per activation, Repeat Area address reset after Number of Transfers, transfer ends after Number of Blocks; Repeat-Block: Number of Blocks per activation, Repeat Area address reset after each Block transfer, transfer ends after Number of Blocks. |
| Transfer Size |
| 2 Bytes | Select the transfer size. |
| Destination Address Mode |
-
Fixed
-
Offset addition
-
Incremented
-
Decremented
| Fixed | Select the address mode for the destination. |
| Source Address Mode |
-
Fixed
-
Offset addition
-
Incremented
-
Decremented
| Fixed | Select the address mode for the source. |
| Repeat Area (Unused in Normal Mode) |
| Source | Select the repeat area. Either the source or destination address resets to its initial value after completing Number of Transfers in Repeat or Block mode. |
| Number of Transfers | Value must be a non-negative integer | 1 | Specify the number of transfers for repeat and normal mode or block size for repeat-block transfer mode. |
| Number of Blocks (Valid only in Repeat,Block or Repeat-Block Mode) | Value must be a non-negative integer | 0 | Specify the number of blocks to transfer in Repeat,Block or Repeat-Block mode. |
| Activation Source | MCU Specific Options | | Select the EXDMAC transfer start event. |
| Callback | Name must be a valid C symbol | NULL | A user callback that is called at the end of the transfer. |
| Transfer End Interrupt Priority | MCU Specific Options | | Select the transfer end interrupt priority. |
| Interrupt Frequency |
-
Interrupt after all transfers have completed
-
Interrupt after each block, or repeat size is transferred
| Interrupt after all transfers have completed | Select to have interrupt after each transfer or after last transfer. |
| Offset value (Valid only when address mode is \'Offset\') | Value must be a 24 bit signed integer. | 1 | Offset value is added to the address after each transfer. |
| Source Buffer Size | Value must be a non-negative integer with a maximum configurable value of 65535. | 1 | Specify the size of whole source buffer (valid only for Repeat-Block transfer mode with source address update mode other than offset addition). |
Clock Configuration
The EXDMAC peripheral module uses ICLK as the clock source. The ICLK frequency is set by using the Clocks tab of the RX Configuration editor prior to a build, or by using the CGC module at run-time.
Pin Configuration
This module does not use I/O pins.
Usage Notes
Source and Destination Configuration
R_EXDMAC_Reset() API function should be called to set the source and destination before starting transfer operation.
Transfer Modes
The EXDMAC Module supports four modes of operation.
- Normal Mode - In normal mode, a single data unit is transferred every time the configured interrupt source is received by the EXDMAC channel. A data unit can be 1-byte, 2-bytes, or 4-bytes. The source and destination addresses can be fixed, increment, decrement, or add an offset to the next data unit after each transfer. A 16-bit counter decrements after each transfer. When the counter reaches 0, transfers will no longer be triggered by the interrupt source and the CPU can be interrupted to signal that all transfers have finished.
- Repeat Mode - Repeat mode works the same way as normal mode, however the length is limited to an integer in the range[1,1024]. When the transfer counter reaches 0, the counter is reset to its configured value, the repeat area (source or destination address) resets to its starting address and the block count remaining will decrement by 1. When the block count reaches 0, transfers will no longer be triggered by the interrupt source and the CPU may be interrupted to signal that all transfers have finished.
- Block Mode - In block mode, the amount of data units transferred by each interrupt can be set to an integer in the range [1,1024]. The number of blocks to transfer can also be configured to a 16-bit number. After each block transfer the repeat area (source or destination address) will reset to the original address and the other address will be incremented or decremented to the next block.
- Repeat-Block Mode - In repeat-block mode, the amount of data units transferred by each interrupt can be set to an integer in the range [1,1024]. The number of blocks to transfer can be configured to a 16 bit number. If the destination address mode is offset mode, maximum configurable number of blocks is 0xFFFF for block size(length) of one with data transfer size as byte,0x7FFF for block size of one with data transfer size as half word and 0x3FFF for block size of one with data size as word. After each block transfer the source address and the destination address will be incremented or decremented to the next block address. In case of offset address mode for source address, the source address size is the total size of source buffer after which the source area is rolled over, block size can be smaller than the source buffer size.For source address mode as offset mode, the maximum configurable source buffer size is 0xFFFF for transfer data size of a byte,0x7FFF for transfer data size of half word and 0x3FFF for transfer data size of word. Repeat-block mode can be used to implement single ring buffer to multiple ring buffer transfer type design.
Selecting the DTC or DMAC or EXDMAC
The Transfer API is implemented by DTC, DMAC and EXDMAC so that applications can switch between the DTC, DMAC and the EXDMAC. When selecting between them, consider these factors:
| DTC | DMAC | EXDMAC |
| Repeat Mode |
-
Repeats forever
-
Max repeat size is 256 x 4 bytes
|
-
Configurable number of repeats
-
Max repeat size is 1024 x 4 bytes
|
-
Configurable number of repeats
-
Max repeat size is 1024 x 4 bytes
|
| Block Mode |
-
Max block size is 256 x 4 bytes
|
-
Max block size is 1024 x 4 bytes
|
-
Max block size is 1024 x 4 bytes
|
| Channels |
-
One instance per interrupt
|
-
MCU specific (8 channels or less)
|
-
MCU specific (2 channels)
|
| Chained Transfers |
|
|
|
| Software Trigger |
-
Must use the ICU Software Interrupt
|
-
Has support for software trigger by selecting the software trigger activation source
-
Supports TRANSFER_START_MODE_SINGLE and TRANSFER_START_MODE_REPEAT
|
-
Has support for software trigger by selecting the software trigger activation source
-
Supports TRANSFER_START_MODE_SINGLE and TRANSFER_START_MODE_REPEAT
|
| Offset Address Mode |
|
|
|
| Transfer Space |
-
0000 0000h to FFFF FFFFh excluding reserved areas
|
-
0000 0000h to FFFF FFFFh excluding reserved areas
| Exclusively for external bus transfer
-
SRAM0/SRAM1 (0200 0000h to 0217 FFFFh)
-
CS0–CS7 / SDRAM (7000 0000h to 7FFF FFFFh)
-
xSPI0/xSPI1 (2000 0000h to 5FFF FFFFh)
|
Interrupts
The DTC, DMAC and EXDMAC interrupts behave differently. The DTC uses the activating peripheral's IRQ as the interrupt source whereas each DMAC and EXDMAC channel has its own IRQ.
The transfer_info_t::irq setting also behaves a little differently depending on which mode is selected.
Normal Mode
| DTC | DMAC | EXDMAC |
| TRANSFER_IRQ_EACH | Interrupt after each transfer | N/A | N/A |
| TRANSFER_IRQ_END | Interrupt after last transfer | Interrupt after last transfer | Interrupt after last transfer |
Repeat Mode
| DTC | DMAC | EXDMAC |
| TRANSFER_IRQ_EACH | Interrupt after each transfer | Interrupt after each repeat | Interrupt after each repeat |
| TRANSFER_IRQ_END | Interrupt after each repeat | Interrupt after last transfer | Interrupt after last transfer |
Block Mode
| DTC | DMAC | EXDMAC |
| TRANSFER_IRQ_EACH | Interrupt after each block | Interrupt after each block | Interrupt after each block |
| TRANSFER_IRQ_END | Interrupt after last block | Interrupt after last block | Interrupt after last block |
Repeat-block Mode
| DTC | DMAC | EXDMAC |
| TRANSFER_IRQ_EACH | N/A | N/A | N/A |
| TRANSFER_IRQ_END | N/A | Interrupt after last block | Interrupt after last block |
Additional Considerations
- The DTC requires a moderate amount of RAM (one transfer_info_t struct per open instance + DTC_VECTOR_TABLE_SIZE).
- The DTC stores transfer information in RAM and writes back to RAM after each transfer whereas the DMAC and EXDMAC store all transfer information in registers.
- When transfers are configured for more than one activation source, the DTC must fetch the transfer info from RAM on each interrupt. This can cause a higher latency between transfers.
Offset Address Mode
When the source or destination mode is configured to offset mode, a configurable offset is added to the source or destination pointer after each transfer. The offset is a signed 24 bit number.
Examples
Basic Example
This is a basic example of minimal use of the EXDMAC in an application. In this case, software configurable interrupts or external pins interrupt have been routed to the EXDMAC for handling so it only needs to be enabled to start accepting transfers.
Since EXDMAC is an exclusive peripheral used for external bus transfers, when transferring from or to an external address, the external memory must be initialized properly before starting the transfer.
void exdmac_minimal_example (void)
{
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
}
SDRAM Transfer Example
In this example the EXDMAC is used to copy data between two regions in external SDRAM. Both the source and destination addresses are located in the SDRAM transfer space, and SDRAM must be initialized by the user before starting the transfer.
volatile bool g_transfer_complete = false;
{
g_transfer_complete = true;
}
void exdmac_sdram_example (void)
{
#define EXDMAC_SDRAM_SRC_ADDR ((uint8_t *) 0x70000000)
#define EXDMAC_SDRAM_DEST_ADDR ((uint8_t *) 0x70001000)
uint8_t * p_src = EXDMAC_SDRAM_SRC_ADDR;
uint8_t * p_dest = EXDMAC_SDRAM_DEST_ADDR;
for (uint32_t i = 0; i < TRANSFER_LENGTH; i++)
{
p_src[i] = (uint8_t) ('A' + (i % 26));
p_dest[i] = 0x00;
}
g_transfer_cfg.p_info->p_src = (void *) p_src;
g_transfer_cfg.p_info->p_dest = (void *) p_dest;
assert(FSP_SUCCESS == err);
g_transfer_complete = false;
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
while (!g_transfer_complete)
{
}
for (uint32_t i = 0; i < TRANSFER_LENGTH; i++)
{
if (p_src[i] != p_dest[i])
{
__BKPT(0);
}
}
}
◆ exdmac_instance_ctrl_t
| struct exdmac_instance_ctrl_t |
Control block used by driver. DO NOT INITIALIZE - this structure will be initialized in transfer_api_t::open.
◆ exdmac_extended_cfg_t
| struct exdmac_extended_cfg_t |
EXDMAC transfer configuration extension. This extension is required.
◆ src_buffer_size
| uint16_t exdmac_extended_cfg_t::src_buffer_size |
◆ irq_activation_source
| IRQn_Type exdmac_extended_cfg_t::irq_activation_source |
Select which interrupt source will trigger the transfer.
◆ p_callback
Callback for transfer end interrupt.
◆ p_context
| void* exdmac_extended_cfg_t::p_context |
◆ EXDMAC_MAX_NORMAL_TRANSFER_LENGTH
| #define EXDMAC_MAX_NORMAL_TRANSFER_LENGTH |
Max configurable number of transfers in TRANSFER_MODE_NORMAL.
◆ EXDMAC_MAX_REPEAT_TRANSFER_LENGTH
| #define EXDMAC_MAX_REPEAT_TRANSFER_LENGTH |
Max number of transfers per repeat for TRANSFER_MODE_REPEAT.
◆ EXDMAC_MAX_BLOCK_TRANSFER_LENGTH
| #define EXDMAC_MAX_BLOCK_TRANSFER_LENGTH |
Max number of transfers per block in TRANSFER_MODE_BLOCK
◆ EXDMAC_MAX_REPEAT_COUNT
| #define EXDMAC_MAX_REPEAT_COUNT |
Max configurable number of repeats to transfer in TRANSFER_MODE_REPEAT
◆ EXDMAC_MAX_BLOCK_COUNT
| #define EXDMAC_MAX_BLOCK_COUNT |
Max configurable number of blocks to transfer in TRANSFER_MODE_BLOCK
◆ R_EXDMAC_Open()
Configure an EXDMAC channel.
- Return values
-
| FSP_SUCCESS | Successful open. |
| FSP_ERR_ASSERTION | An input parameter is invalid. |
| FSP_ERR_IP_CHANNEL_NOT_PRESENT | The configured channel is invalid. |
| FSP_ERR_IRQ_BSP_DISABLED | The IRQ associated with the activation source is not enabled in the BSP. |
| FSP_ERR_ALREADY_OPEN | The control structure is already opened. |
◆ R_EXDMAC_Reconfigure()
Reconfigure the transfer with new transfer info.
- Return values
-
| FSP_SUCCESS | Transfer is configured and will start when trigger occurs. |
| FSP_ERR_ASSERTION | An input parameter is invalid. |
| FSP_ERR_NOT_ENABLED | EXDMAC is not enabled. The current configuration must not be valid. |
| FSP_ERR_NOT_OPEN | Handle is not initialized. Call R_EXDMAC_Open to initialize the control block. |
◆ R_EXDMAC_Reset()
| fsp_err_t R_EXDMAC_Reset |
( |
transfer_ctrl_t *const |
p_api_ctrl, |
|
|
void const *volatile |
p_src, |
|
|
void *volatile |
p_dest, |
|
|
uint16_t const |
num_transfers |
|
) |
| |
Reset transfer source, destination, and number of transfers.
- Return values
-
| FSP_SUCCESS | Transfer reset successfully. |
| FSP_ERR_ASSERTION | An input parameter is invalid. |
| FSP_ERR_NOT_ENABLED | EXDMAC is not enabled. The current configuration must not be valid. |
| FSP_ERR_NOT_OPEN | Handle is not initialized. Call R_EXDMAC_Open to initialize the control block. |
◆ R_EXDMAC_SoftwareStart()
If the mode is TRANSFER_START_MODE_SINGLE initiate a single transfer with software. If the mode is TRANSFER_START_MODE_REPEAT continue triggering transfers until all of the transfers are completed.
- Return values
-
| FSP_SUCCESS | Transfer started written successfully. |
| FSP_ERR_ASSERTION | An input parameter is invalid. |
| FSP_ERR_NOT_OPEN | Handle is not initialized. Call R_EXDMAC_Open to initialize the control block. |
| FSP_ERR_UNSUPPORTED | Handle was not configured for software activation. |
◆ R_EXDMAC_SoftwareStop()
Stop software transfers if they were started with TRANSFER_START_MODE_REPEAT.
- Return values
-
| FSP_SUCCESS | Transfer stopped written successfully. |
| FSP_ERR_ASSERTION | An input parameter is invalid. |
| FSP_ERR_NOT_OPEN | Handle is not initialized. Call R_EXDMAC_Open to initialize the control block. |
◆ R_EXDMAC_Enable()
Enable transfers for the configured activation source.
- Return values
-
| FSP_SUCCESS | Counter value written successfully. |
| FSP_ERR_ASSERTION | An input parameter is invalid. |
| FSP_ERR_NOT_OPEN | Handle is not initialized. Call R_EXDMAC_Open to initialize the control block. |
◆ R_EXDMAC_Disable()
Disable transfers so that they are no longer triggered by the activation source.
- Return values
-
| FSP_SUCCESS | Counter value written successfully. |
| FSP_ERR_ASSERTION | An input parameter is invalid. |
| FSP_ERR_NOT_OPEN | Handle is not initialized. Call R_EXDMAC_Open to initialize the control block. |
◆ R_EXDMAC_InfoGet()
Set driver specific information in provided pointer.
- Return values
-
| FSP_SUCCESS | Information has been written to p_info. |
| FSP_ERR_NOT_OPEN | Handle is not initialized. Call R_EXDMAC_Open to initialize the control block. |
| FSP_ERR_ASSERTION | An input parameter is invalid. |
◆ R_EXDMAC_Reload()
| fsp_err_t R_EXDMAC_Reload |
( |
transfer_ctrl_t *const |
p_api_ctrl, |
|
|
void const * |
p_src, |
|
|
void * |
p_dest, |
|
|
uint32_t const |
num_transfers |
|
) |
| |
To update next transfer information without interruption during transfer.
- Return values
-
| FSP_ERR_UNSUPPORTED | This feature is not supported. |
◆ R_EXDMAC_Close()
Disable transfer and clean up internal data. Implements transfer_api_t::close.
- Return values
-
| FSP_SUCCESS | Successful close. |
| FSP_ERR_ASSERTION | An input parameter is invalid. |
| FSP_ERR_NOT_OPEN | Handle is not initialized. Call R_EXDMAC_Open to initialize the control block. |
◆ R_EXDMAC_CallbackSet()
Updates the user callback with the option to provide memory for the callback argument structure.
- Return values
-
| FSP_SUCCESS | Callback updated successfully. |
| FSP_ERR_ASSERTION | A required pointer is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened. |