90c1c28ba99a001d134cf61914a1f8a0

来自「基于ALTERA公司的NIOSII的GPS信息接收系统的设计」· 代码 · 共 54 行

TXT
54
字号
#include <stdio.h>
#include "system.h"
#include "alt_types.h"
#include "altera_avalon_uart_regs.h"
#include "sys/alt_irq.h"
#include <string.h>

char* gps_string;
int string_index = 0;

void receive_gps_string(char gps_code)
{
    int i;
    if(gps_code != 13){
        gps_string[string_index] = gps_code;
        
        string_index++;
    }
    else{
        gps_string[string_index] = '\0';
        
        for(i = 0;i < string_index;i++){
            printf("%c",gps_string[i]);
        }
        string_index = 0;
    }   
}
    
static void handle_uart_keyboard_interrups(void* context, alt_u32 id)
{
    char code;
    if((IORD_ALTERA_AVALON_UART_STATUS(GPS_UART_0_BASE)&(0x80)) == 0x80){
        code = IORD_ALTERA_AVALON_UART_RXDATA(GPS_UART_0_BASE);
        receive_gps_string(code);
    }
    IOWR_ALTERA_AVALON_UART_STATUS(GPS_UART_0_BASE, 0x0);
}

void init_uart_keyboard()
{
    IOWR_ALTERA_AVALON_UART_CONTROL(GPS_UART_0_BASE, 0x80);
    IOWR_ALTERA_AVALON_UART_STATUS(GPS_UART_0_BASE, 0x0);
    alt_irq_register(GPS_UART_0_IRQ,NULL,handle_uart_keyboard_interrups);
}


int main()
{
    init_uart_keyboard();
    
    
    return 0;
}

⌨️ 快捷键说明

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