forked from Hustra03/Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterrupt.c
More file actions
54 lines (44 loc) · 1.24 KB
/
Interrupt.c
File metadata and controls
54 lines (44 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdint.h> /* Declarations of uint_32 and the like */
#include <pic32mx.h> /* Declarations of system-specific addresses etc */
#include "flappybird.h"
int timecount = 0;
// needed for buttons intterupt
#define DEBOUNCE_TIME 10000 // debounce time in ms
int LastButtonTime =0;
int startgame =0;
/* Interrupt Service Routine */
void user_isr(void)
{
// Mohammed
if (((IFS(0)>> 12) & 0x1) == 0x1)
{ //
int TimeSinceLastEvent = TMR3 - LastButtonTime;
if(TimeSinceLastEvent > DEBOUNCE_TIME){ // debounce time to make sure when the button debounce will not be counted
if (startgame == 1){ // the game started means use just one button to controll the bird
if ((getbtns() & 0x1) == 0x1){
PORTE += 1;
}
}
else {
if ((getbtns() & 0x1) == 0x1){ //btn2
menuChoice = 3; PORTE += 1;
}
else if (((getbtns() >> 1) & 0x1) == 0x1)//btn3
{
menuChoice = 2; PORTE += 1;
}
else if (((getbtns() >> 2) & 0x1) == 0x1)//btn4
{
menuChoice = 4; PORTE += 1;
}
else if (((PORTF >> 1) & 0x1) == 0x1) //btn1
{
menuChoice = 1;PORTE += 1;
}
}
LastButtonTime = TMR3;
} // btns for menu and game in an tm3 intterupt
IFSCLR(0) = 0x00001000;
}
return;
}