|
| void | XDMAC_SetArbitrationWeights (uint8_t pw0, uint8_t pw1, uint8_t pw2, uint8_t pw3) |
| | Set the weighted round-robin arbitration weights for channel groups.
|
| |
| bool | XDMAC_ConfigureChannel (uint8_t channel, const XDMAC_CH_CONFIG *config) |
| | Configure an XDMAC channel for a specific transfer mode.
|
| |
| void | XDMAC_EnableChannel (uint8_t channel) |
| | Enable a specific XDMAC channel.
|
| |
| void | XDMAC_DisableChannel (uint8_t channel) |
| | Disable a specific XDMAC channel, ensuring pending transfers are completed or terminated.
|
| |
| void | XDMAC_SuspendChannel (uint8_t channel) |
| | Suspend a specific XDMAC channel, pausing its operation.
|
| |
| void | XDMAC_ResumeChannel (uint8_t channel) |
| | Resume a suspended XDMAC channel.
|
| |
| void | XDMAC_FlushChannel (uint8_t channel) |
| | Flush a specific XDMAC channel, terminating any pending transfers.
|
| |
| void | XDMAC_GenerateSoftwareTrigger (uint8_t channel) |
| | Trigger a software-initiated transfer for a channel configured for software requests.
|
| |
| void | XDMAC_EnableInterrupt (uint8_t channel, uint32_t interrupt_mask) |
| | Enable specified interrupt sources for a specific XDMAC channel.
|
| |
| void | XDMAC_EnableChannelInterrupt (uint8_t channel) |
| | Enable interrupts for a channel at the global level.
|
| |
| void | XDMAC_DisableInterrupt (uint8_t channel, uint32_t interrupt_mask) |
| | Disable specified interrupt sources for a specific XDMAC channel.
|
| |
| void | XDMAC_DisableChannelInterrupt (uint8_t channel) |
| | Disable all interrupts for a channel at the global level.
|
| |
| uint32_t | XDMAC_GetInterruptStatus (uint8_t channel) |
| | Returns the interrupt status flags for a specific XDMAC channel.
|
| |
| uint32_t | XDMAC_GetErrorStatus (uint8_t channel) |
| | Returns error status flags for a specific XDMAC channel.
|
| |
| void | XDMAC_SetCallbackHandler (uint8_t channel, XDMAC_CALLBACK callback) |
| | Register a callback function for a specific XDMAC channel interrupt source.
|
| |
| void | XDMAC_SoftwareResetChannel (uint8_t channel) |
| | Reset a specific XDMAC channel, clearing all configuration and status registers.
|
| |
| bool | XDMAC_StartTransfer (uint8_t channel, const void *src_addr, const void *dest_addr, size_t block_size) |
| | Perform a simple DMA transfer on a specific channel.
|
| |
| bool | XDMAC_ChannelIsBusy (uint8_t channel) |
| | Check if a specific XDMAC channel is currently busy with a transfer.
|
| |
| XDMAC_TRANSFER_EVENT | XDMAC_GetTransferStatus (uint8_t channel) |
| | Get the current transfer event status for a specific channel.
|
| |
| uint32_t | XDMAC_GetChannelSettings (uint8_t channel) |
| | Retrieve the current configuration register value for a specific channel.
|
| |
| void | XDMAC_SetChannelSettings (uint8_t channel, uint32_t setting) |
| | Update the configuration register for a specific channel.
|
| |
| void | XDMAC_SetBlockTransferCount (uint8_t channel, uint16_t length) |
| | Set the block length for a specific channel.
|
| |
| bool | XDMAC_StartLinkedListTransfer (uint8_t channel, uint32_t first_descriptor_address, const uint32_t *first_descriptor_control) |
| | Initiate a linked-list transfer on a specific channel.
|
| |
| void | XDMAC_SetSourceAddress (uint8_t channel, uint32_t src_addr) |
| | Set the source address for a specific channel.
|
| |
| void | XDMAC_SetDestinationAddress (uint8_t channel, uint32_t dst_addr) |
| | Set the destination address for a specific channel.
|
| |
| void | XDMAC_SetMicroblockLength (uint8_t channel, uint32_t length) |
| | Set the microblock length (number of data units per microblock) for a specific channel.
|
| |
| void | XDMAC_SetDataWidth (uint8_t channel, uint8_t data_width) |
| | Set the data width (beat size) for a specific channel.
|
| |
| void | XDMAC_SetBurstSize (uint8_t channel, uint8_t burst_size) |
| | Set the burst size for a specific channel.
|
| |
| void | XDMAC_EnableSrcAddrIncrement (uint8_t channel) |
| | Enable source address increment for a specific channel.
|
| |
| void | XDMAC_DisableSrcAddrIncrement (uint8_t channel) |
| | Disable source address increment for a specific channel (fixed address mode).
|
| |
| void | XDMAC_EnableDstAddrIncrement (uint8_t channel) |
| | Enable destination address increment for a specific channel.
|
| |
| void | XDMAC_DisableDstAddrIncrement (uint8_t channel) |
| | Disable destination address increment for a specific channel (fixed address mode).
|
| |
| void | XDMAC_SetTransferType (uint8_t channel, uint8_t transfer_type) |
| | Set the transfer type for a specific channel.
|
| |
| void | XDMAC_SetTriggerSource (uint8_t channel, uint8_t perid) |
| | Set the peripheral trigger source for a specific channel.
|
| |
| uint32_t | XDMAC_GetSourceAddress (uint8_t channel) |
| | Get the source address for a specific channel.
|
| |
| uint32_t | XDMAC_GetDestinationAddress (uint8_t channel) |
| | Get the destination address for a specific channel.
|
| |
| uint32_t | XDMAC_GetMicroblockLength (uint8_t channel) |
| | Get the microblock length for a specific channel.
|
| |
#include <stdint.h>
#include <string.h>
#define XDMAC_TRANSFER_SIZE 1024U
#define XDMAC_TEST_CHANNEL 0U
#define XDMAC_TIMEOUT_CYCLES 1000000U
#define DCACHE_CLEAN_BY_ADDR(addr, sz) SCB_CleanDCache_by_Addr((uint32_t *)(uintptr_t)(addr), (sz))
#define DCACHE_INVALIDATE_BY_ADDR(addr, sz) SCB_InvalidateDCache_by_Addr((uint32_t *)(uintptr_t)(addr), (sz))
static uint8_t src_buff[XDMAC_TRANSFER_SIZE];
static uint8_t dst_buff[XDMAC_TRANSFER_SIZE];
static volatile bool transfer_done = false;
static volatile bool transfer_error = false;
static volatile bool ch1_transfer_done = false;
static volatile bool ch1_transfer_error = false;
#define UART1_THR_ADDR ((uint32_t)(uintptr_t)&UART1_REGS->UART_THR)
#ifndef XDMAC_UART_CHANNEL
#define XDMAC_UART_CHANNEL 1U
#endif
#ifndef UART_DMA_BUFFER_SIZE
#define UART_DMA_BUFFER_SIZE 64U
#endif
static uint8_t _Alignas(32) uart_tx_buffer[UART_DMA_BUFFER_SIZE];
static void ch0_callback(uint32_t status)
{
if ((status & XDMAC_CIS_BIS_Msk) != 0U)
{
transfer_done = true;
}
else if ((status & (XDMAC_CIS_RBEIS_Msk | XDMAC_CIS_WBEIS_Msk | XDMAC_CIS_ROIS_Msk)) != 0U)
{
transfer_error = true;
}
else
{
}
}
static void ch1_callback(uint32_t status)
{
if ((status & XDMAC_CIS_BIS_Msk) != 0U)
{
ch1_transfer_done = true;
}
else if ((status & (XDMAC_CIS_RBEIS_Msk | XDMAC_CIS_WBEIS_Msk | XDMAC_CIS_ROIS_Msk)) != 0U)
{
ch1_transfer_error = true;
}
else
{
}
}
int32_t configure_xdmac(void)
{
uint32_t i;
uint32_t timeout;
int32_t ret_val = -1;
for (i = 0U; i < XDMAC_TRANSFER_SIZE; i++)
{
src_buff[i] = (uint8_t)i;
}
(void)memset(dst_buff, 0, (size_t)XDMAC_TRANSFER_SIZE);
transfer_done = false;
transfer_error = false;
DCACHE_CLEAN_BY_ADDR(src_buff, (int32_t)XDMAC_TRANSFER_SIZE);
DCACHE_INVALIDATE_BY_ADDR(dst_buff, (int32_t)XDMAC_TRANSFER_SIZE);
timeout = XDMAC_TIMEOUT_CYCLES;
while (timeout > 0U)
{
bool done = transfer_done;
bool error = transfer_error;
if (done || error) { break; }
timeout--;
}
if (transfer_done == true)
{
DCACHE_INVALIDATE_BY_ADDR(dst_buff, (int32_t)XDMAC_TRANSFER_SIZE);
if (0 == memcmp(src_buff, dst_buff, (size_t)XDMAC_TRANSFER_SIZE))
{
ret_val = 0;
}
}
return ret_val;
}
int32_t configure_xdmac_with_struct(void)
{
uint32_t i;
uint32_t timeout;
bool result;
int32_t ret_val = -1;
for (i = 0U; i < XDMAC_TRANSFER_SIZE; i++)
{
src_buff[i] = (uint8_t)i;
}
(void)memset(dst_buff, 0, (size_t)XDMAC_TRANSFER_SIZE);
transfer_done = false;
transfer_error = false;
config.
csa = (uint32_t)(uintptr_t)src_buff;
config.
cda = (uint32_t)(uintptr_t)dst_buff;
config.
cubc = XDMAC_TRANSFER_SIZE;
config.
cc = XDMAC_CC_TYPE_MEM_TRAN |
XDMAC_CC_DWIDTH_BYTE |
XDMAC_CC_SAM_INCREMENTED_AM |
XDMAC_CC_DAM_INCREMENTED_AM |
XDMAC_CC_MBSIZE_SINGLE;
if (result == true)
{
DCACHE_CLEAN_BY_ADDR(src_buff, (int32_t)XDMAC_TRANSFER_SIZE);
DCACHE_INVALIDATE_BY_ADDR(dst_buff, (int32_t)XDMAC_TRANSFER_SIZE);
timeout = XDMAC_TIMEOUT_CYCLES;
while (timeout > 0U)
{
bool done = transfer_done;
bool error = transfer_error;
if (done || error) { break; }
timeout--;
}
if (transfer_done == true)
{
DCACHE_INVALIDATE_BY_ADDR(dst_buff, (int32_t)XDMAC_TRANSFER_SIZE);
if (0 == memcmp(src_buff, dst_buff, (size_t)XDMAC_TRANSFER_SIZE))
{
ret_val = 0;
}
}
}
return ret_val;
}
int32_t configure_xdmac_simple(void)
{
uint32_t i;
uint32_t timeout;
bool result;
int32_t ret_val = -1;
for (i = 0U; i < XDMAC_TRANSFER_SIZE; i++)
{
src_buff[i] = (uint8_t)i;
}
(void)memset(dst_buff, 0, (size_t)XDMAC_TRANSFER_SIZE);
transfer_done = false;
transfer_error = false;
XDMAC_CC_TYPE_MEM_TRAN |
XDMAC_CC_DWIDTH_BYTE |
XDMAC_CC_SAM_INCREMENTED_AM |
XDMAC_CC_DAM_INCREMENTED_AM |
XDMAC_CC_MBSIZE_SINGLE);
DCACHE_CLEAN_BY_ADDR(src_buff, (int32_t)XDMAC_TRANSFER_SIZE);
DCACHE_INVALIDATE_BY_ADDR(dst_buff, (int32_t)XDMAC_TRANSFER_SIZE);
if (result == true)
{
timeout = XDMAC_TIMEOUT_CYCLES;
while (timeout > 0U)
{
bool done = transfer_done;
bool error = transfer_error;
if (done || error) { break; }
timeout--;
}
if (transfer_done == true)
{
DCACHE_INVALIDATE_BY_ADDR(dst_buff, (int32_t)XDMAC_TRANSFER_SIZE);
if (0 == memcmp(src_buff, dst_buff, (size_t)XDMAC_TRANSFER_SIZE))
{
ret_val = 0;
}
}
}
return ret_val;
}
int32_t configure_xdmac_linked_list(void)
{
uint32_t i;
uint32_t timeout;
uint32_t desc_control;
bool result;
int32_t ret_val = -1;
static uint32_t _Alignas(4) desc_address;
for (i = 0U; i < XDMAC_TRANSFER_SIZE; i++)
{
src_buff[i] = (uint8_t)i;
}
(void)memset(dst_buff, 0, (size_t)XDMAC_TRANSFER_SIZE);
transfer_done = false;
transfer_error = false;
XDMAC_CC_TYPE_MEM_TRAN |
XDMAC_CC_DWIDTH_BYTE |
XDMAC_CC_SAM_INCREMENTED_AM |
XDMAC_CC_DAM_INCREMENTED_AM |
XDMAC_CC_MBSIZE_SINGLE);
desc_address = 0U;
desc_control = XDMAC_CNDC_NDE(0U);
DCACHE_CLEAN_BY_ADDR(src_buff, (int32_t)XDMAC_TRANSFER_SIZE);
DCACHE_INVALIDATE_BY_ADDR(dst_buff, (int32_t)XDMAC_TRANSFER_SIZE);
desc_address,
&desc_control);
if (result == true)
{
timeout = XDMAC_TIMEOUT_CYCLES;
while (timeout > 0U)
{
bool done = transfer_done;
bool error = transfer_error;
if (done || error) { break; }
timeout--;
}
if (transfer_done == true)
{
DCACHE_INVALIDATE_BY_ADDR(dst_buff, (int32_t)XDMAC_TRANSFER_SIZE);
if (0 == memcmp(src_buff, dst_buff, (size_t)XDMAC_TRANSFER_SIZE))
{
ret_val = 0;
}
}
}
return ret_val;
}
int32_t configure_xdmac_uart1_tx(const uint8_t *data, uint32_t length)
{
uint32_t channel_config;
uint32_t timeout;
int32_t ret_val = -1;
if ((data == NULL) || (length == 0U) || (length > UART_DMA_BUFFER_SIZE))
{
}
{
}
else
{
ch1_transfer_done = false;
ch1_transfer_error = false;
(void)memcpy(uart_tx_buffer, data, (size_t)length);
channel_config = XDMAC_CC_TYPE_PER_TRAN |
XDMAC_CC_DSYNC_MEM2PER |
XDMAC_CC_SWREQ_HWR_CONNECTED |
XDMAC_CC_PERID_UART1_TX |
XDMAC_CC_DWIDTH_BYTE |
XDMAC_CC_SIF_AHB_IF0 |
XDMAC_CC_DIF_AHB_IF1 |
XDMAC_CC_CSIZE_CHK_1 |
XDMAC_CC_SAM_INCREMENTED_AM |
XDMAC_CC_DAM_FIXED_AM |
XDMAC_CC_MBSIZE_SINGLE;
DCACHE_CLEAN_BY_ADDR(uart_tx_buffer, (int32_t)length);
XDMAC_CIE_BIE_Msk |
XDMAC_CIE_RBIE_Msk |
XDMAC_CIE_WBIE_Msk |
XDMAC_CIE_ROIE_Msk);
timeout = XDMAC_TIMEOUT_CYCLES;
while (timeout > 0U)
{
bool done = ch1_transfer_done;
bool error = ch1_transfer_error;
if (done || error) { break; }
timeout--;
}
if (ch1_transfer_done == true)
{
ret_val = 0;
}
}
return ret_val;
}
void XDMAC_EnableSrcAddrIncrement(uint8_t channel)
Enable source address increment for a specific channel.
void XDMAC_SetChannelSettings(uint8_t channel, uint32_t setting)
Update the configuration register for a specific channel.
void XDMAC_EnableDstAddrIncrement(uint8_t channel)
Enable destination address increment for a specific channel.
void XDMAC_SetBlockTransferCount(uint8_t channel, uint16_t length)
Set the block length for a specific channel.
bool XDMAC_StartLinkedListTransfer(uint8_t channel, uint32_t first_descriptor_address, const uint32_t *first_descriptor_control)
Initiate a linked-list transfer on a specific channel.
bool XDMAC_StartTransfer(uint8_t channel, const void *src_addr, const void *dest_addr, size_t block_size)
Perform a simple DMA transfer on a specific channel.
bool XDMAC_ChannelIsBusy(uint8_t channel)
Check if a specific XDMAC channel is currently busy with a transfer.
void XDMAC_SetDataWidth(uint8_t channel, uint8_t data_width)
Set the data width (beat size) for a specific channel.
bool XDMAC_ConfigureChannel(uint8_t channel, const XDMAC_CH_CONFIG *config)
Configure an XDMAC channel for a specific transfer mode.
void XDMAC_EnableChannelInterrupt(uint8_t channel)
Enable interrupts for a channel at the global level.
void XDMAC_SetCallbackHandler(uint8_t channel, XDMAC_CALLBACK callback)
Register a callback function for a specific XDMAC channel interrupt source.
void XDMAC_EnableChannel(uint8_t channel)
Enable a specific XDMAC channel.
void XDMAC_EnableInterrupt(uint8_t channel, uint32_t interrupt_mask)
Enable specified interrupt sources for a specific XDMAC channel.
void XDMAC_SetMicroblockLength(uint8_t channel, uint32_t length)
Set the microblock length (number of data units per microblock) for a specific channel.
void XDMAC_SetBurstSize(uint8_t channel, uint8_t burst_size)
Set the burst size for a specific channel.
void XDMAC_SetTransferType(uint8_t channel, uint8_t transfer_type)
Set the transfer type for a specific channel.
void XDMAC_SetDestinationAddress(uint8_t channel, uint32_t dst_addr)
Set the destination address for a specific channel.
void XDMAC_SetSourceAddress(uint8_t channel, uint32_t src_addr)
Set the source address for a specific channel.
XDMAC Channel Configuration Structure.
Definition plib_xdmac.h:90
uint32_t cubc
Definition plib_xdmac.h:93
uint32_t csus
Definition plib_xdmac.h:97
uint32_t cds_msp
Definition plib_xdmac.h:96
uint32_t cc
Definition plib_xdmac.h:95
uint32_t cda
Definition plib_xdmac.h:92
uint32_t cbc
Definition plib_xdmac.h:94
uint32_t csa
Definition plib_xdmac.h:91
uint32_t cdus
Definition plib_xdmac.h:98