FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
5986 Discussions

msgdma st to MM nios code implementation

Altera_Forum
Honored Contributor II
1,325 Views

Problems solved- needed some code clean up... 

 

// Modular Scatter-Gather DMA ST-to-MM with callback function  

# include <stdio.h> 

 

// DMA transfer# include <altera_msgdma_descriptor_regs.h># include <altera_msgdma_csr_regs.h># include <altera_msgdma.h> 

 

// Parallel I/O# include <altera_avalon_pio_regs.h># include <sys/alt_irq.h> 

# define DMA_LEN_BYTES 1600000 // Size of each DMA transfer in bytes# define BUFFER_A 0x40000000 // SDRAM Buffer A address 

 

// Modular Scatter-Gather DMA Globals 

alt_msgdma_dev *DATA_DMA_A; 

alt_msgdma_standard_descriptor DATA_DMA_A_desc; 

 

// DMA variables 

alt_u32 *DMA_write_addr_ptr_A; // Pointer for DMA A transfer write address 

alt_u32 DMA_write_addr_A; // DMA A transfer write address 

 

// Declare callback function 

void DATA_DMA_A_callback_function(void* context); 

 

void DATA_DMA_A_callback_function(void* context) { 

alt_msgdma_standard_descriptor_async_transfer(DATA_DMA_A, &DATA_DMA_A_desc); 

 

// Toggle PIO  

IOWR_ALTERA_AVALON_PIO_DATA(NIOS_DATA1_READY_BASE, 1); 

IOWR_ALTERA_AVALON_PIO_DATA(NIOS_DATA1_READY_BASE, 0); 

 

int main() { 

// Open the streaming modular scatter-gather DMA controllers 

DATA_DMA_A = alt_msgdma_open("/dev/data1_msgdma_csr"); 

if(DATA_DMA_A == NULL) 

printf("Could not open the mSG-DMA1\n"); 

 

// Configure DMA callback functions 

alt_msgdma_register_callback(DATA_DMA_A, DATA_DMA_A_callback_function, 0, NULL); 

 

// Configure the DMA write address 

DMA_write_addr_A = (alt_u32) BUFFER_A ; 

DMA_write_addr_ptr_A = (alt_u32*)(DMA_write_addr_A); 

 

dma_len_bytes = (alt_u32) DMA_LEN_BYTES;  

 

// Construct the DMA descriptors 

alt_msgdma_construct_standard_st_to_mm_descriptor ( DATA_DMA_A, 

&DATA_DMA_A_desc, DMA_write_addr_ptr_A, dma_len_bytes, 

ALTERA_MSGDMA_DESCRIPTOR_CONTROL_TRANSFER_COMPLETE_IRQ_MASK ); 

 

// Start DMA transfers 

alt_msgdma_standard_descriptor_async_transfer(DATA_DMA_A, &DATA_DMA_A_desc); 

 

return 0; 

}
0 Kudos
0 Replies
Reply