Example of creating link list in code
and setting GPDMA_CxLBAR and GPDMA_CxLLR registers.
//Create GPDMA link list in code. Example:
//1. Link list item:
typedef struct {
volatile uint32_t CTR1_register;
volatile uint32_t CTR2_register;
volatile uint32_t CBR1_register;
volatile uint32_t CSAR_register; //Source address for the transfer.
volatile uint32_t CDAR_register; //Destination address for the transfer.
volatile uint32_t CTR3_register;
volatile uint32_t CBR2_register;
volatile uint32_t CLLR_register;
} LinkListItem_t;
//2. List object with 2 linked list items and their memory address:
typedef struct {
LinkListItem_t node1; //node1 address: 0x200bffa8 (same as base address)
LinkListItem_t node2; //node2 address: 0x200bffc8
} LinkList_t; //base address: 0x200bffa8
GPDMA channel x linked-list base address register (GPDMA_CxLBAR):
In this example, the address of the link list structure object is 0x200bffa8
GPDMA_CxLBAR->LBA = 0x200b
GPDMA_CxLBAR = 0x200b0000
GPDMA channel x linked-list address register (GPDMA_CxLLR):
The address of node1 is 0x200bffa8. Node 0 (staring value of LLR) points to node 1.
f |f |a |8
1111|1111|1010|1000
11|1111|1110|1010|00 Bits LA[15:2]Bits 1:0 Reserved
3 |f |e |a
//Bits 15:2 LA[15:2]: pointer (16-bit low-significant address) to the next linked-list data structure
pNode0->CLLR_register.LA = 0x3fea;
pNode0->CLLR_register = 0xfe01ffa8; //the last 4 hex values aggree to the last 4 hex of the address
The address of node2 is 0x200bffc8. The node 1 points to node 2.
f |f |c |8
1111|1111|1100|1000
11|1111|1111|0010|00 Bits LA[15:2]Bits 1:0 Reserved
3 |f |f |2
//Bits 15:2 LA[15:2]: pointer (16-bit low-significant address) to the next linked-list data structure
pNode1->CLLR_register.LA = 0x3ff2;
pNode1->CLLR_register = 0xfe01ffc8; //the last 4 hex values aggree to the last 4 hex of the address
The node 2 points back to node 1. (The address of node1 is 0x200bffa8.)
//Bits 15:2 LA[15:2]: pointer (16-bit low-significant address) to the next linked-list data structure
pNode2->CLLR_register.LA = 0x3fea;
pNode2->CLLR_register = 0xfe01ffa8; //the last 4 hex values aggree to the last 4 hex of the address
cc @Amel NASRI