forked from biomimetics/imageproc-test
-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.c
executable file
·92 lines (83 loc) · 2.58 KB
/
main.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*********************************************************************************************************
* Name: main.c
* Desc: A test suite for the ImageProc 2.2 system. These tests should not be
* considered rigorous, exhaustive tests of the hardware, but rather
* "smoke tests" - ie. turn on the functionality and make sure the
* hardware/software doesn't start "smoking."
*
* The architecture is based on a function pointer queue scheduling model. The
* meat of the testing logic resides in test.c. If the radio has received a
* command packet during the previous timer interval for Timer2, the appropriate
* function pointer is added to a queue in the interrupt service routine for
* Timer2 (interrupts.c). The main loop simply pops the function pointer off
* the top of the queue and executes it.
*
* Date: 2011-04-13
* Author: AMH, Ryan Julian
*********************************************************************************************************/
#include "p33Fxxxx.h"
#include "init.h"
#include "init_default.h"
#include "timer.h"
#include "utils.h"
#include "queue.h"
#include "radio.h"
#include "radio_settings.h"
#include "tests.h" // TODO (fgb) : define/includes need to live elsewhere
#include "dfmem.h"
#include "interrupts.h"
#include "mpu6000.h"
#include "sclock.h"
#include "spi_controller.h"
#include "interrupts.h"
#include <stdlib.h>
Payload rx_payload;
MacPacket rx_packet;
Test* test;
int main() {
fun_queue = queueInit(FUN_Q_LEN);
test_function tf;
/* Initialization */
SetupClock();
SwitchClocks();
SetupPorts();
SetupInterrupts();
//SetupI2C();
//SetupADC();
SetupTimer1();
//SetupPWM();
SetupTimer2();
sclockSetup();
//gyroSetup();
//xlSetup();
dfmemSetup(0);
mpuSetup(1);
// Radio setup
radioInit(RADIO_RXPQ_MAX_SIZE, RADIO_TXPQ_MAX_SIZE, 0);
radioSetChannel(RADIO_MY_CHAN);
radioSetSrcAddr(RADIO_SRC_ADDR);
radioSetSrcPanID(RADIO_PAN_ID);
setupTimer6(RADIO_FCY); // Radio and buffer loop timer
char j;
for(j=0; j<3; j++){
LED_2 = ON;
delay_ms(250);
LED_2 = OFF;
delay_ms(250);
}
LED_2 = ON;
EnableIntT2;
while(1){
while(!queueIsEmpty(fun_queue))
{
test = queuePop(fun_queue);
rx_payload = macGetPayload(test->packet);
tf = test->tf;
(*tf)(payGetType(rx_payload), payGetStatus(rx_payload), payGetDataLength(rx_payload), payGetData(rx_payload));
payDelete(rx_payload);
radioReturnPacket(test->packet);
free(test);
}
}
return 0;
}