60a5ed00185b001d12ebad93121f84ab

来自「altera DE1 SD_CARD带写入一个扇区功能的程序」· 代码 · 共 35 行

TXT
35
字号
#include "alt_types.h"
#include "sys/alt_irq.h"
#include "system.h"
#include <stdio.h>
#include <unistd.h>

#define pio *(unsigned int*)PIO_BASE
#define pio1 *(unsigned int*)PIO_1_BASE

void handle_button_interrupts(void* context, alt_u32 id)
{
    (&pio1)[3]=0;
    printf("The key u pressed is %c\n",pio);
}

void init_button_pio()
{
    alt_irq_register( PIO_1_IRQ, 0,handle_button_interrupts );
    (&pio1)[2]=0xf;
    (&pio1)[3]=0;
}

int main()
{
    init_button_pio();
    
    printf("Hello from Nios II!\n");
    while(1)
    {
        printf("asc=%x,release=%x\n",pio,pio1);
        usleep(100000);
    }
  return 0;
}

⌨️ 快捷键说明

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