Skip to content

Commit

Permalink
Add async copy
Browse files Browse the repository at this point in the history
  • Loading branch information
LuigiGiuffrida98 committed Jul 31, 2024
1 parent bf00be5 commit 95452f6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
22 changes: 22 additions & 0 deletions sw/device/lib/sdk/dma/dma_sdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ extern "C"
return;
}

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)
{
volatile dma *the_dma = dma_peri(channel);
DMA_COPY(dst_ptr, src_ptr, size, src_type, dst_type, signed_data, the_dma);
dma_start(the_dma, size, src_type);
return;
}

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)
{
volatile dma *the_dma = dma_peri(channel);
DMA_FILL(dst_ptr, value_ptr, size, src_type, dst_type, signed_data, the_dma);
dma_start(the_dma, size, src_type);
return;
}

void __attribute__ ((noinline)) dma_wait(uint8_t channel)
{
DMA_WAIT(channel);
return;
}

#ifdef __cplusplus
}
#endif
8 changes: 6 additions & 2 deletions sw/device/lib/sdk/dma/dma_sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ extern "C"
#define DMA_WAIT(CH) \
while (!dma_is_ready(CH)) \
{ \
CSR_CLEAR_BITS(CSR_REG_MSTATUS, 0x8); \
if (dma_is_ready(CH) == 0) \
{ \
wait_for_interrupt(); \
} \
CSR_SET_BITS(CSR_REG_MSTATUS, 0x8); \
}

/********************************/
Expand Down Expand Up @@ -95,6 +93,12 @@ extern "C"
*/
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);

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);

void __attribute__ ((noinline)) dma_wait(uint8_t channel);

#ifdef __cplusplus
}
#endif // __cplusplus
Expand Down

0 comments on commit 95452f6

Please sign in to comment.