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

📄 30ceb2ada99a001d134cf61914a1f8a0

📁 基于ALTERA公司的NIOSII的GPS信息接收系统的设计
💻
字号:
#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()
{
    gps_string = malloc(1000);
    init_uart_keyboard();
    
    
    return 0;
}

⌨️ 快捷键说明

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