📄 9073ad219284001d124efccffff46f52
字号:
#include <stdio.h>
#include <string.h>
#include "system.h"
#include "sys/alt_dma.h"
int main(void)
{
alt_dma_rxchan rx;
//创建DMA接收信道
rx = alt_dma_rxchan_open("/dev/dma_0");
//当信道创建成功
if(rx != NULL)
{
printf("Dma transition start.");
while(1)
{
//设置DMA传输的数据位宽 本例中为8位
alt_dma_rxchan_ioctl(rx,ALT_DMA_SET_MODE_8,NULL);
//指定从uart接收数据
alt_dma_rxchan_ioctl(rx,ALT_DMA_RX_ONLY_ON,(void*)UART_0_BASE);
//提交DMA接收请求 指定接收数据的位置(sdram)以及传输数据量
if(alt_dma_rxchan_prepare (rx,
SDRAM_0_BASE,
1024,
NULL,
NULL) < 0)
{
printf ("Error: failed to post receive request\n");
}
//关闭DMA接收信道
alt_dma_rxchan_close (rx);
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -