-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
89 lines (59 loc) · 1.82 KB
/
main.cpp
File metadata and controls
89 lines (59 loc) · 1.82 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
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
#include <ch.h>
#include <hal.h>
#include "globalVar.h"
#include "stdutil.h"
#include "config.hpp"
#include "castle_link.hpp"
#include "ttyConsole.hpp"
#include "led_blink.hpp"
/*
° connecter PA08 et PA05 ensemble -> entrée PWM du controller castlelink
*/
/*
° architecture :
* un (mailBox + memory chunk manager) pour envoyer les 11 int16_t (contiennent des longueurs en µs ou .1µs)
* la cb de l'ICU recupère les valeurs et les envoie dans la mailbox
* un fichier castlelink_pwm
° conf ICU et PWM
° callback, etc
° fonction start
° fonction setDutyLen
* un fichier serialLink
° gestion I/O
* utilisation de simpleSerialMessage (ou une version c++ parametrisable)
° 115200 bauds 8 bits sans parité, 1 bit de stop
° sortie : payload -> 11 floats + 1 short + protocole :
(50 octets à 5Hz) 250 octets/seconde sur 11500 possible : 3%
° entree : 1 octet msgId, 2 octets valeur
+ msgId 1 à 4 : valeur longueur du creneau PWM en µs
*/
void _init_chibios() __attribute__ ((constructor(101)));
void _init_chibios() {
halInit();
chSysInit();
// no official chibios support for TIM15
// TIM15 init has to be explicitely done
icu_opt_lld_init();
initHeap();
}
int main(void) {
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
* and performs the board-specific initializations.
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
#ifdef TRACE
if (&CASTLELINK::SD_TELEMETRY == &SD_SHELL) {
chSysHalt("same serial link used for shell and telemetry");
}
consoleInit();
#endif
castleLinkStart();
#ifdef TRACE
consoleLaunch();
#endif
// main thread does nothing
chThdSleep (TIME_INFINITE);
}