发布于 2019-09-26 作者 风铃 32次 浏览 版块 后端
代码设计具体看源工程
/* * "Hello World" example. * * This example prints 'Hello from Nios II' to the STDOUT stream. It runs on * the Nios II 'standard', 'full_featured', 'fast', and 'low_cost' example * designs. It runs with or without the MicroC/OS-II RTOS and requires a STDOUT * device in your system's hardware. * The memory footprint of this hosted application is ~69 kbytes by default * using the standard reference design. * * For a reduced footprint version of this template, and an explanation of how * to reduce the memory footprint for a given application, see the * "small_hello_world" template. * / #include <stdio.h> #include <unistd.h> #include <io.h> #include <string.h> #include "system.h" #include "alt_types.h" #include "altera_avalon_uart_regs.h" #include "sys\alt_irq.h"
static alt_u8 txdata = static alt_u8 rxdata = //UART中断服务函数 static { rxdata = IORD_ALTERA_AVALON_UART_RXDATA(UART_BASE); txdata = rxdata;
IOWR_ALTERA_AVALON_UART_TXDATA(UART_BASE,txdata); } void uart_init() {
IOWR_ALTERA_AVALON_UART_STATUS(UART_BASE,0);
IOWR_ALTERA_AVALON_UART_CONTROL(UART_BASE,0X80); } int main() { printf("Please Start!\n");
alt_ic_isr_register(UART_IRQ_INTERRUPT_CONTROLLER_ID, UART_IRQ,uart_isr,NULL,0x00); uart_init();
} |