⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 70279c7a7f84001d1a01f088cc7cc1e3

📁 基于ALTERA公司的NIOSII的串口通信DMA传输设计
💻
字号:
#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");
        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, (void*)curve_data, 10, NULL, NULL) < 0){
            printf ("Error: failed to post receive request\n");
        }
        int i;
        for(i=0; i<=1023; i++){  
            printf("i%d = %x\n", i, curve_data[i]);
        }
        alt_dma_rxchan_close (rx);
    }
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -