if (!(txchan = alt_dma_txchan_open("/dev/DMA"))) { printf ("Failed to open transmit channel\n"); exit (1); }
/* 打开接收通道 */
if (!(rxchan = alt_dma_rxchan_open("/dev/DMA"))) { printf ("Failed to open receive channel\n"); exit (1); }
/* 开始发送数据 */
if ((rc = alt_dma_txchan_send (txchan, //选用transport通道 tx_data, //a pointer to the start of the data to send. 128, //the length of the data to send in bytes. NULL, NULL)) < 0)
{ printf ("Failed to post transmit request, reason = %i\n", rc); exit (1); }
/* 开始接收数据*/
if ((rc = alt_dma_rxchan_prepare (rxchan, //选中recieve通道 rx_buffer,//目标地址 128, //the maximum length of the data to receive done_t, //done_t()是DMA完成后被调用的回调函数 NULL)) < 0)
{ printf ("Failed to post read request, reason = %i\n", rc); exit (1); }