📄 305baafe8f84001d124efccffff46f52
字号:
#include <stdio.h>
#include <string.h>
#include "system.h"
#include "sys/alt_dma.h"
volatile int curve_data[10000];
int main(void)
{
/* char* msg = "Hello from Nios II!";
FILE* fp;
fp = fopen("/dev/uart_0","r+");
if(fp){
fprintf(fp,"%s",msg);
fclose(fp);
}*/
alt_dma_rxchan rx;
/* Obtain a handle for the device */
if((rx = alt_dma_rxchan_open ("/dev/dma_0")) != NULL){
printf("start\n");
while(1){
alt_dma_rxchan_ioctl(rx,ALT_DMA_SET_MODE_8,NULL);
alt_dma_rxchan_ioctl(rx,ALT_DMA_RX_ONLY_ON,(void*)UART_0_BASE);
if(alt_dma_rxchan_prepare (rx, SDRAM_0_BASE, 1024, NULL, NULL) < 0){
printf ("Error: failed to post receive request\n");
}
//while (!dma_complete);
int i;
for(i=0; i<=10; i++){
printf("i%d = %x\n", i, curve_data[i]);
}
alt_dma_rxchan_close (rx);
usleep(1000000);
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -