forked from OlinRoboticsAndBioinspiration/imageproc-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interrupts.c
71 lines (60 loc) · 1.72 KB
/
interrupts.c
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Interrupt handlers. All tests are handled through timer 2 interrupt.
* Timer 2 runs at 100Hz and checks to see if a command packet has
* been received. If so, it pushes the appropriate test routine onto
* a function queue to be popped and executed in the main loop.
*
* Created: 2011-04-16
* Author: AMH
*/
#include "interrupts.h"
#include "utils.h"
#include "consts.h"
#include "tests.h"
#include "init.h"
#include "timer.h"
#include "fpqueue.h"
#include "payload.h"
#include "radio.h"
unsigned char* rxPacketData;
unsigned char type, status, length;
volatile unsigned int t2_ticks;
volatile PayQueue rx_pay_queue;
void __attribute__((interrupt, no_auto_psv)) _INT0Interrupt(void) {
_INT0IF = 0; // Clear the interrupt flag
}
void __attribute__((interrupt, no_auto_psv)) _T1Interrupt(void) {
_T1IF = 0;
}
void __attribute__((interrupt, no_auto_psv)) _T2Interrupt(void) {
Payload rx_payload;
if (!radioIsRxQueueEmpty())
{
rx_payload = radioReceivePayload();
pqPush(rx_pay_queue, rx_payload);
switch(payGetType(rx_payload))
{
case RADIO_TEST:
queuePush(fun_queue, &test_radio);
break;
case GYRO_TEST:
queuePush(fun_queue, &test_gyro);
break;
case ACCEL_TEST:
queuePush(fun_queue, &test_accel);
break;
case DFLASH_TEST:
queuePush(fun_queue, &test_dflash);
break;
case MOTOR_TEST:
queuePush(fun_queue, &test_motor);
break;
case SMA_TEST:
queuePush(fun_queue, &test_sma);
break;
default:
break;
}
}
_T2IF = 0;
}