-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.cpp
63 lines (49 loc) · 1.19 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
53
54
55
56
57
58
59
60
61
62
#include "Pins.h"
#include "Debug.h"
#include "timer.h"
#include "cdcacm.h"
#include "canhacker.h"
#include "CanHackerBinary.h"
#include "stm32.h"
#include "LedBlink.h"
#include "Lin/LinBus.h"
extern "C" int main();
int main()
{
DBG("\n\nCore started!\n");
initRemap();
Timer::init();
Usb::init();
LedBlink::init();
// LIN tests
// PinLin1Slp::Mode(OUTPUT_2MHZ); PinLin1Slp::On();
// PinLin2Slp::Mode(OUTPUT_2MHZ); PinLin2Slp::On();
// PinLinBreak::Mode(OUTPUT_2MHZ); PinLinBreak::On();
while (1)
{
Usb::checkConnect();
if (! canHacker.processPackets() &&
! canHacker.processCmd())
{
#if ! defined DEBUG
// go to sleep
__WFI();
#endif
}
linBus1.checkTimeout();
linBus2.checkTimeout();
/*
auto checkPort = [](uint16_t &oldVal, uint16_t newVal, const char* label) {
if (oldVal != newVal) {
DBG("%s: %X -> %X\n", label, oldVal, newVal);
oldVal = newVal;
}
};
static uint16_t port[4] = {};
const uint16_t maskA = (1<<13) | (1<<14) | (1<<11) | (1<<12); // USB, SWD
checkPort(port[0], GPIOA->IDR & (~maskA), "portA");
checkPort(port[1], GPIOB->IDR, "portB");
checkPort(port[2], GPIOC->IDR, "portC");
checkPort(port[3], GPIOD->IDR, "portD");*/
}
}