-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
52 lines (44 loc) · 1.33 KB
/
main.cpp
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
#include "main.h"
#include "libCANCubesat.h"
Ticker ticker;
/**
* Main loop
*
* Empty because we use interruption mecanisms
*/
int main()
{
classobc_init();
while (1)
{
wait(10);
}
}
/**
* OBC initialization function
*/
void classobc_init()
{
pc.printf("classobc_init()\t");
/* CAN INIT */
//1 - CAN filters : can be used to ignore frames with id ranges
/*int filter1 = can1.filter(0x100, 0x7FF, CANStandard);
if (filter1 == 0) {
pc.printf("ERROR setting filter1\n");
return 0;
}*/
//2 - CAN callbacks : interruption handling
// when we use the attach function, deep sleep can't be enabled because the CAN device must be able to generate an interruption
can1.attach(&read_callback, CAN::RxIrq); // message received
can1.attach(&transmitted_callback, CAN::TxIrq); // message transmitted or aborted
can1.attach(&errorwarning_callback, CAN::EwIrq); // error warning
can1.attach(&do_callback, CAN::DoIrq); // data overrun
can1.attach(&wakeup_callback, CAN::WuIrq); // wake-up
can1.attach(&errorpassive_callback, CAN::EpIrq); // error passive
can1.attach(&al_callback, CAN::AlIrq); // arbitration lost
can1.attach(&be_callback, CAN::BeIrq); // bus error
/* BEHAVIOUR INIT */
//send messages periodically on the can bus
//ticker.attach(&send_adcsstable, 2);
//ticker.attach(&send_adcsstable_rtr, 2);
}