/* * File: sdma.h * * SDMA module provides interface to sdma channels handling. It provides functions * - for selecting sdma channel, configuring it and coping data via selected channel. * * (c) multicore.ru */ #ifndef _SDMA_H_ #define _SDMA_H_ #ifdef __cplusplus extern "C" { #endif #define SDMA_BASE 0x37220000 typedef struct { volatile unsigned csr; volatile unsigned cpc; } Chan_CTRL; typedef struct { volatile unsigned sar; volatile unsigned dar; volatile unsigned ccr; volatile unsigned lc0; volatile unsigned lc1; volatile unsigned char RES[12]; } Chan; typedef struct { volatile unsigned dsr; volatile unsigned dpc; unsigned reserved1[6]; volatile unsigned inten; volatile unsigned int_event_ris; volatile unsigned intmis; volatile unsigned intclr; volatile unsigned fsrd; volatile unsigned fsrc; volatile unsigned ftrd; unsigned reserved2; volatile unsigned ftr[8]; unsigned reserved3[40]; Chan_CTRL chCtrl[8]; unsigned reserved4[176]; Chan ch[8]; unsigned reseved13[512]; unsigned dbgstatus; unsigned dbgcmd; unsigned dbginst0; unsigned dbginst1; unsigned reserved14[60]; volatile unsigned cr0; volatile unsigned cr1; volatile unsigned cr2; volatile unsigned cr3; volatile unsigned cr4; volatile unsigned crd; unsigned reserved15[26]; volatile unsigned wd; unsigned reserved16[87]; volatile unsigned periph_id_n[4]; volatile unsigned pcell_id_n[4]; } SDMA_CB; typedef SDMA_CB* PSDMA_CB; unsigned run_channel(unsigned int channel, unsigned int inst0, unsigned int pc); // Function: sdma_copy // // Blocking copy of buffer via sdma memory channel. The execution thread is blocked until the dma channel stops its work. // // Parameters: // dma_id - number of requested memory dma channel // dst - physical or virtual address of destination buffer // src - physical or virtual address of source buffer // size - size of transmitted buffer in bytes // // > #include "sdma.h" // > #define BUF_SIZE 0x400 // > // > int src_data[BUF_SIZE]; // > int dst_data[BUF_SIZE]; // > // > int main() { // > for (int i=0; i sdma_copy(0, dst_data, src_data, BUF_SIZE * sizeof(int)); // > return 0 ; // > } void sdma_copy(int dma_id, unsigned int *dst, unsigned int *src, int size); // Function: sdma_copy2d // // Blocking copy of 2d array via dma memory channel. The execution thread is blocked until the sdma channel stops its work. // // Parameters: // dma_id - number of requested memory dma channel // dst - physical or virtual address of destination buffer // stride_dst - destination stride in bytes // src - physical or virtual address of source buffer // stride_src - source stride in bytes // width - size of line in bytes // height - number of lines // // Return: // ERL_NO_ERROR - configuration procedure is successful // ERL_SYSTEM_ERROR - dma channel id wrong // ERL_PROGRAM_ERROR - size or line number is wrong // void sdma_copy2d(int dma_id, unsigned int *dst, unsigned int stride_dst, unsigned int *src, unsigned int stride_src, int width, int height); #ifdef __cplusplus } #endif #endif