Skip to content

Commit

Permalink
add dma_sdk addr mode functions (#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
davideschiavone authored Oct 25, 2024
1 parent 2c6d7d8 commit 8ded718
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sw/device/lib/sdk/dma/dma_sdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ extern "C"
return;
}

void dma_copy_to_addr(uint32_t addr_ptr, uint32_t src_ptr, uint32_t size, uint8_t channel)
{
volatile dma *the_dma = dma_peri(channel);
DMA_COPY_ADDR(addr_ptr, src_ptr, size, the_dma);
dma_start(the_dma, size, DMA_DATA_TYPE_WORD);
DMA_WAIT(channel);
return;
}

void dma_fill(uint32_t dst_ptr, uint32_t value_ptr, uint32_t size, uint8_t channel, dma_data_type_t src_type, dma_data_type_t dst_type, uint8_t signed_data)
{
volatile dma *the_dma = dma_peri(channel);
Expand Down
19 changes: 19 additions & 0 deletions sw/device/lib/sdk/dma/dma_sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ extern "C"
DMA_PERI->DST_DATA_TYPE = (uint32_t)(DST_TYPE & DMA_DST_DATA_TYPE_DATA_TYPE_MASK); \
DMA_PERI->SIGN_EXT = (uint32_t)SIGNED;

#define DMA_COPY_ADDR(ADDR, SRC, SIZE, DMA_PERI) \
DMA_PERI->INTERRUPT_EN = (uint32_t)0x1; \
DMA_PERI->SRC_PTR = (uint32_t)SRC; \
DMA_PERI->SRC_PTR_INC_D1 = (uint32_t)(INCREMENT(DMA_DATA_TYPE_WORD) & DMA_SRC_PTR_INC_D1_INC_MASK); \
DMA_PERI->ADDR_PTR = (uint32_t)ADDR; \
DMA_PERI->MODE = (uint32_t)(DMA_TRANS_MODE_ADDRESS & DMA_MODE_MODE_MASK); \
DMA_PERI->SRC_DATA_TYPE = (uint32_t)(DMA_DATA_TYPE_WORD & DMA_SRC_DATA_TYPE_DATA_TYPE_MASK);


#define DMA_WAIT(CH) \
while (!dma_is_ready(CH)) \
{ \
Expand Down Expand Up @@ -95,6 +104,16 @@ extern "C"
*/
void __attribute__((noinline)) dma_fill(uint32_t dst_ptr, uint32_t value_ptr, uint32_t size, uint8_t channel, dma_data_type_t src_type, dma_data_type_t dst_type, uint8_t signed_data);

/**
* @brief Copies 32-bit data from source to *addr_ptr using DMA.
*
* @param addr_ptr Pointer to the memory location that contains destinations.
* @param src_ptr Pointer to the source memory location.
* @param size Size of the data to be copied in bytes.
* @param channel DMA channel to be used for the transfer.
*/
void dma_copy_to_addr(uint32_t addr_ptr, uint32_t src_ptr, uint32_t size, uint8_t channel);

void __attribute__((noinline)) dma_copy_async(uint32_t dst_ptr, uint32_t src_ptr, uint32_t size, uint8_t channel, dma_data_type_t src_type, dma_data_type_t dst_type, uint8_t signed_data);

void __attribute__((noinline)) dma_fill_async(uint32_t dst_ptr, uint32_t value_ptr, uint32_t size, uint8_t channel, dma_data_type_t src_type, dma_data_type_t dst_type, uint8_t signed_data);
Expand Down

0 comments on commit 8ded718

Please sign in to comment.