EasyManua.ls Logo

Altera DE1-SoC - Page 30

Altera DE1-SoC
45 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
DE1-SOC COMPUTER SYSTEM WITH NIOS II For Quartus II 15.0
#include "key_codes.h" // defines values for KEY0, KEY1, . . .
extern volatile int key_pressed;
/********************************************************************************
* Pushbutton - Interrupt Service Routine
*
* This routine checks which KEY has been pressed. It writes this value to the global
* variable KEY_PRESSED.
********************************************************************************/
void pushbutton_ISR( void )
{
volatile int * KEY_ptr = (int *) 0xFF200050;
int press;
press = *(KEY_ptr + 3); // read the pushbutton interrupt register
*(KEY_ptr + 3) = press; // clear the interrupt
if (press & 0x1) // KEY0
key_pressed = KEY0;
else if (press & 0x2) // KEY1
key_pressed = KEY1;
else if (press & 0x4) // KEY2
key_pressed = KEY2;
else // press & 0x8, which is KEY3
key_pressed = KEY3;
return;
}
Figure 24. Interrupt service routine for the pushbutton keys.
30 Altera Corporation - University Program
2015

Other manuals for Altera DE1-SoC

Related product manuals