I need to enable GDMA in esp32c3 but I get descriptor error, did I fill descriptor correctly?
Posted: Thu Feb 23, 2023 8:15 pm
- #include "gdma_struct.h"
- typedef struct dma_link {
- struct {
- uint32_t size : 12; //the size of buf, must be able to be divisible by 4
- uint32_t length: 12; //in link,
- uint32_t reversed: 6; //reversed
- uint32_t eof: 1; //if this dma link is the last one, you shoule set this bit 1.
- uint32_t owner: 1; //the owner of buf, bit 1 : DMA, bit 0 : CPU.
- } des;
- uint8_t *buf; //the pointer of buf
- struct dma_link *pnext; //point to the next dma linke, if this link is the last one, set it NULL.
- } dma_link_t;
- dma_link_t dma_trans;
- dma_link_t dma_receive;
- uint8_t transmit[5]="hello";
- uint8_t receive[5]={0};
- void app_main()
- {
- //load outlink
- dma_trans.des.size = 0;
- dma_trans.des.length = 5;
- dma_trans.des.eof = 1;
- dma_trans.des.owner = 1;
- dma_trans.buf = transmit;
- dma_trans.pnext = NULL;
- //load inlink
- dma_receive.des.size = 5;
- dma_receive.des.length = 0;
- dma_receive.des.eof = 1;
- dma_receive.des.owner = 1;
- dma_receive.buf = receive;
- dma_receive.pnext = NULL;
- //reset GDMA's transmit channel
- GDMA.channel[0].out.out_conf0.out_rst = 1;
- GDMA.channel[0].out.out_conf0.out_rst = 0;
- //reset GDMA's receive channel
- GDMA.channel[0].in.in_conf0.in_rst = 1;
- GDMA.channel[0].in.in_conf0.in_rst = 0;
- //address of the transmit descriptor
- GDMA.channel[0].out.out_link.addr = (((uint32_t)&(dma_trans)) & (0xfffff << 0));
- //address of the receive descriptor
- GDMA.channel[0].in.in_link.addr = (((uint32_t)&(dma_receive)) & (0xfffff << 0));
- //enable memory to memory transfer
- GDMA.channel[0].in.in_conf0.mem_trans_en = 1;
- //enable transmit channel
- GDMA.channel[0].out.out_link.start = 1;
- //enable receive channel
- GDMA.channel[0].in.in_link.start = 1;
- }