amiro-os / modules / NUCLEO-F103RB / module.h @ 4d8d8663
History | View | Annotate | Download (10.854 KB)
1 | f4da707a | Thomas Schöpping | /*
|
---|---|---|---|
2 | AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
||
3 | Copyright (C) 2016..2019 Thomas Schöpping et al.
|
||
4 | |||
5 | This program is free software: you can redistribute it and/or modify
|
||
6 | it under the terms of the GNU General Public License as published by
|
||
7 | the Free Software Foundation, either version 3 of the License, or
|
||
8 | (at your option) any later version.
|
||
9 | |||
10 | This program is distributed in the hope that it will be useful,
|
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | GNU General Public License for more details.
|
||
14 | |||
15 | You should have received a copy of the GNU General Public License
|
||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
17 | */
|
||
18 | |||
19 | /**
|
||
20 | * @file
|
||
21 | * @brief Structures and constant for the NUCLEO-F103RB module.
|
||
22 | *
|
||
23 | * @addtogroup NUCLEO-F103RB_module
|
||
24 | * @{
|
||
25 | */
|
||
26 | |||
27 | 6ff06bbf | Thomas Schöpping | #ifndef AMIROOS_MODULE_H
|
28 | #define AMIROOS_MODULE_H
|
||
29 | f4da707a | Thomas Schöpping | |
30 | #include <amiroos.h> |
||
31 | |||
32 | /*===========================================================================*/
|
||
33 | /**
|
||
34 | * @name Module specific functions
|
||
35 | * @{
|
||
36 | */
|
||
37 | /*===========================================================================*/
|
||
38 | |||
39 | 4c72a54c | Thomas Schöpping | #if (BOARD_DW1000_CONNECTED == true) |
40 | deaaa47e | Cung Sang | |
41 | 7de0cc90 | Thomas Schöpping | #if defined(__cplusplus)
|
42 | deaaa47e | Cung Sang | extern "C" { |
43 | 7de0cc90 | Thomas Schöpping | #endif /* defined(__cplusplus) */ |
44 | deaaa47e | Cung Sang | |
45 | void dw1000_spi_init(void); |
||
46 | |||
47 | 7de0cc90 | Thomas Schöpping | #if defined(__cplusplus)
|
48 | deaaa47e | Cung Sang | } |
49 | 7de0cc90 | Thomas Schöpping | #endif /* defined(__cplusplus) */ |
50 | deaaa47e | Cung Sang | |
51 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
52 | deaaa47e | Cung Sang | |
53 | |||
54 | f4da707a | Thomas Schöpping | /** @} */
|
55 | |||
56 | /*===========================================================================*/
|
||
57 | /**
|
||
58 | * @name ChibiOS/HAL configuration
|
||
59 | * @{
|
||
60 | */
|
||
61 | /*===========================================================================*/
|
||
62 | |||
63 | /**
|
||
64 | * @brief Serial driver of the programmer interface.
|
||
65 | */
|
||
66 | #define MODULE_HAL_PROGIF SD2
|
||
67 | |||
68 | /**
|
||
69 | * @brief Configuration for the programmer serial interface driver.
|
||
70 | */
|
||
71 | extern SerialConfig moduleHalProgIfConfig;
|
||
72 | |||
73 | /**
|
||
74 | * @brief Real-Time Clock driver.
|
||
75 | */
|
||
76 | #define MODULE_HAL_RTC RTCD1
|
||
77 | |||
78 | 4c72a54c | Thomas Schöpping | #if (BOARD_DW1000_CONNECTED == true) |
79 | deaaa47e | Cung Sang | |
80 | /**
|
||
81 | * @brief SPI interface driver for the motion sensors (gyroscope and accelerometer).
|
||
82 | */
|
||
83 | #define MODULE_HAL_SPI_UWB SPID2
|
||
84 | |||
85 | /**
|
||
86 | * @brief Configuration for the SPI interface driver to communicate with the LED driver.
|
||
87 | */
|
||
88 | extern SPIConfig moduleHalSpiUwbHsConfig;
|
||
89 | |||
90 | /**
|
||
91 | * @brief Configuration for the SPI interface driver to communicate with the wireless transceiver.
|
||
92 | */
|
||
93 | extern SPIConfig moduleHalSpiUwbLsConfig;
|
||
94 | |||
95 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
96 | deaaa47e | Cung Sang | |
97 | f4da707a | Thomas Schöpping | /** @} */
|
98 | |||
99 | /*===========================================================================*/
|
||
100 | /**
|
||
101 | * @name GPIO definitions
|
||
102 | * @{
|
||
103 | */
|
||
104 | /*===========================================================================*/
|
||
105 | |||
106 | /**
|
||
107 | * @brief LED output signal GPIO.
|
||
108 | */
|
||
109 | extern ROMCONST apalControlGpio_t moduleGpioLed;
|
||
110 | |||
111 | 4c72a54c | Thomas Schöpping | #if (BOARD_DW1000_CONNECTED == true) |
112 | |||
113 | deaaa47e | Cung Sang | /**
|
114 | * @brief DW1000 reset output signal
|
||
115 | * @note the reset pin should be drived as low by MCU to activate.
|
||
116 | * Then, put back the reset pin as input to MCU (tri-state float on the air
|
||
117 | * is not supported in AMiRo)
|
||
118 | */
|
||
119 | extern ROMCONST apalControlGpio_t moduleGpioDw1000Reset;
|
||
120 | |||
121 | /**
|
||
122 | * @brief DW1000 interrupt IRQn input signal.
|
||
123 | */
|
||
124 | extern ROMCONST apalControlGpio_t moduleGpioDw1000Irqn;
|
||
125 | |||
126 | /**
|
||
127 | * @brief DW1000 SPI chip select output signal.
|
||
128 | */
|
||
129 | extern ROMCONST apalControlGpio_t moduleGpioSpiChipSelect ;
|
||
130 | |||
131 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
132 | deaaa47e | Cung Sang | |
133 | f4da707a | Thomas Schöpping | /**
|
134 | * @brief User button input signal.
|
||
135 | */
|
||
136 | extern ROMCONST apalControlGpio_t moduleGpioUserButton;
|
||
137 | |||
138 | /** @} */
|
||
139 | |||
140 | /*===========================================================================*/
|
||
141 | /**
|
||
142 | * @name AMiRo-OS core configurations
|
||
143 | * @{
|
||
144 | */
|
||
145 | /*===========================================================================*/
|
||
146 | |||
147 | 4c72a54c | Thomas Schöpping | #if (BOARD_DW1000_CONNECTED == true) |
148 | |||
149 | f4da707a | Thomas Schöpping | /**
|
150 | deaaa47e | Cung Sang | * @brief Event flag to be call dwt_isr() interrupt.
|
151 | */
|
||
152 | 3106e8cc | Thomas Schöpping | #define MODULE_OS_IOEVENTFLAGS_DW1000_IRQn AOS_IOEVENT_FLAG(PAL_PAD(LINE_ARD_D6))
|
153 | deaaa47e | Cung Sang | |
154 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
155 | |||
156 | deaaa47e | Cung Sang | /**
|
157 | f4da707a | Thomas Schöpping | * @brief Event flag to be set on a USER_BUTTON interrupt.
|
158 | */
|
||
159 | 3106e8cc | Thomas Schöpping | #define MODULE_OS_IOEVENTFLAGS_USERBUTTON AOS_IOEVENT_FLAG(PAL_PAD(LINE_BUTTON))
|
160 | f4da707a | Thomas Schöpping | |
161 | #if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
162 | /**
|
||
163 | * @brief Shell prompt text.
|
||
164 | */
|
||
165 | extern ROMCONST char* moduleShellPrompt; |
||
166 | 7de0cc90 | Thomas Schöpping | #endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */ |
167 | f4da707a | Thomas Schöpping | |
168 | /**
|
||
169 | * @brief Interrupt initialization macro.
|
||
170 | * @note SSSP related interrupt signals are already initialized in 'aos_system.c'.
|
||
171 | */
|
||
172 | #define MODULE_INIT_INTERRUPTS() { \
|
||
173 | /* user button */ \
|
||
174 | 3106e8cc | Thomas Schöpping | palSetLineCallback(moduleGpioUserButton.gpio->line, aosSysGetStdIntCallback(), &moduleGpioUserButton.gpio->line); \ |
175 | palEnableLineEvent(moduleGpioUserButton.gpio->line, APAL2CH_EDGE(moduleGpioUserButton.meta.edge)); \ |
||
176 | deaaa47e | Cung Sang | MODULE_INIT_INTERRUPTS_DW1000(); \ |
177 | f4da707a | Thomas Schöpping | } |
178 | 4c72a54c | Thomas Schöpping | #if (BOARD_DW1000_CONNECTED == true) |
179 | deaaa47e | Cung Sang | #define MODULE_INIT_INTERRUPTS_DW1000() { \
|
180 | 3106e8cc | Thomas Schöpping | palSetLineCallback(moduleGpioDw1000Irqn.gpio->line, aosSysGetStdIntCallback(), &moduleGpioDw1000Irqn.gpio->line); \ |
181 | palEnableLineEvent(moduleGpioDw1000Irqn.gpio->line, APAL2CH_EDGE(moduleGpioDw1000Irqn.meta.edge)); \ |
||
182 | deaaa47e | Cung Sang | } |
183 | 4c72a54c | Thomas Schöpping | #else /* (BOARD_DW1000_CONNECTED == true) */ |
184 | 7de0cc90 | Thomas Schöpping | #define MODULE_INIT_INTERRUPTS_DW1000() { \
|
185 | deaaa47e | Cung Sang | } |
186 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
187 | deaaa47e | Cung Sang | |
188 | f4da707a | Thomas Schöpping | |
189 | /**
|
||
190 | 4c72a54c | Thomas Schöpping | * @brief Test initialization hook.
|
191 | f4da707a | Thomas Schöpping | */
|
192 | #define MODULE_INIT_TESTS() { \
|
||
193 | 4c72a54c | Thomas Schöpping | /* initialize tests and add to shell */ \
|
194 | aosShellAddCommand(&aos.shell, &moduleTestLedShellCmd); \ |
||
195 | aosShellAddCommand(&aos.shell, &moduleTestButtonShellCmd); \ |
||
196 | deaaa47e | Cung Sang | MODULE_INIT_TESTS_DW1000(); \ |
197 | 4c72a54c | Thomas Schöpping | aosShellAddCommand(&aos.shell, &moduleTestAllShellCmd); \ |
198 | f4da707a | Thomas Schöpping | } |
199 | 4c72a54c | Thomas Schöpping | #if (BOARD_DW1000_CONNECTED == true) |
200 | deaaa47e | Cung Sang | #define MODULE_INIT_TESTS_DW1000() { \
|
201 | 4c72a54c | Thomas Schöpping | aosShellAddCommand(&aos.shell, &moduleTestDw1000ShellCmd); \ |
202 | deaaa47e | Cung Sang | } |
203 | 4c72a54c | Thomas Schöpping | #else /* (BOARD_DW1000_CONNECTED == true) */ |
204 | 7de0cc90 | Thomas Schöpping | #define MODULE_INIT_TESTS_DW1000() { \
|
205 | deaaa47e | Cung Sang | } |
206 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
207 | deaaa47e | Cung Sang | |
208 | f4da707a | Thomas Schöpping | |
209 | /**
|
||
210 | * @brief Periphery communication interfaces initialization hook.
|
||
211 | */
|
||
212 | 4c72a54c | Thomas Schöpping | #define MODULE_INIT_PERIPHERY_IF() { \
|
213 | f4da707a | Thomas Schöpping | /* serial driver */ \
|
214 | sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig); \ |
||
215 | 4c72a54c | Thomas Schöpping | MODULE_INIT_PERIPHERY_IF_DW1000(); \ |
216 | f4da707a | Thomas Schöpping | } |
217 | 4c72a54c | Thomas Schöpping | #if (BOARD_DW1000_CONNECTED == true) |
218 | #define MODULE_INIT_PERIPHERY_IF_DW1000() { \
|
||
219 | deaaa47e | Cung Sang | /* SPI init */ \
|
220 | dw1000_spi_init(); \ |
||
221 | spiStart(&MODULE_HAL_SPI_UWB, &moduleHalSpiUwbLsConfig); \ |
||
222 | } |
||
223 | 4c72a54c | Thomas Schöpping | #else /* (BOARD_DW1000_CONNECTED == true) */ |
224 | #define MODULE_INIT_PERIPHERY_IF_DW1000() { \
|
||
225 | deaaa47e | Cung Sang | } |
226 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
227 | deaaa47e | Cung Sang | |
228 | f4da707a | Thomas Schöpping | |
229 | /**
|
||
230 | * @brief Periphery communication interface deinitialization hook.
|
||
231 | */
|
||
232 | 4c72a54c | Thomas Schöpping | #define MODULE_SHUTDOWN_PERIPHERY_IF() { \
|
233 | MODULE_SHUTDOWN_PERIPHERY_IF_DW1000(); \ |
||
234 | deaaa47e | Cung Sang | } |
235 | 4c72a54c | Thomas Schöpping | #if (BOARD_DW1000_CONNECTED == true) |
236 | #define MODULE_SHUTDOWN_PERIPHERY_IF_DW1000() { \
|
||
237 | deaaa47e | Cung Sang | /* SPI */ \
|
238 | spiStop(&MODULE_HAL_SPI_UWB); \ |
||
239 | f4da707a | Thomas Schöpping | } |
240 | 4c72a54c | Thomas Schöpping | #else /* (BOARD_DW1000_CONNECTED == true) */ |
241 | #define MODULE_SHUTDOWN_PERIPHERY_IF_DW1000() { \
|
||
242 | deaaa47e | Cung Sang | } |
243 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
244 | f4da707a | Thomas Schöpping | |
245 | /**
|
||
246 | 4c72a54c | Thomas Schöpping | * @brief HOOK to toggle the LEDs when the user button is pressed.
|
247 | f4da707a | Thomas Schöpping | */
|
248 | 732a4657 | Thomas Schöpping | #define MODULE_MAIN_LOOP_IO_EVENT(eventflags) { \
|
249 | f4da707a | Thomas Schöpping | if (eventflags & MODULE_OS_IOEVENTFLAGS_USERBUTTON) { \
|
250 | apalControlGpioState_t buttonstate; \ |
||
251 | apalControlGpioGet(&moduleGpioUserButton, &buttonstate); \ |
||
252 | apalControlGpioSet(&moduleGpioLed, buttonstate); \ |
||
253 | } \ |
||
254 | deaaa47e | Cung Sang | MODULE_MAIN_LOOP_IO_EVENT_DW1000(); \ |
255 | f4da707a | Thomas Schöpping | } |
256 | 4c72a54c | Thomas Schöpping | #if (BOARD_DW1000_CONNECTED == true) |
257 | /**
|
||
258 | * @brief HOOK to call process_deca_irq() func when the dw1000 interrupt pin is activated.
|
||
259 | */
|
||
260 | deaaa47e | Cung Sang | #define MODULE_MAIN_LOOP_IO_EVENT_DW1000() { \
|
261 | 7de0cc90 | Thomas Schöpping | if(eventflags & MODULE_OS_IOEVENTFLAGS_DW1000_IRQn) { \
|
262 | deaaa47e | Cung Sang | /*apalGpioToggle(moduleGpioLedGreen.gpio); // just for debug */ \
|
263 | process_deca_irq(); \ |
||
264 | 7de0cc90 | Thomas Schöpping | } \ |
265 | deaaa47e | Cung Sang | } |
266 | 4c72a54c | Thomas Schöpping | #else /* (BOARD_DW1000_CONNECTED == true) */ |
267 | deaaa47e | Cung Sang | #define MODULE_MAIN_LOOP_IO_EVENT_DW1000() { \
|
268 | } |
||
269 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
270 | f4da707a | Thomas Schöpping | |
271 | /** @} */
|
||
272 | |||
273 | /*===========================================================================*/
|
||
274 | /**
|
||
275 | * @name Startup Shutdown Synchronization Protocol (SSSP)
|
||
276 | * @{
|
||
277 | */
|
||
278 | /*===========================================================================*/
|
||
279 | |||
280 | /** @} */
|
||
281 | |||
282 | /*===========================================================================*/
|
||
283 | /**
|
||
284 | * @name Low-level drivers
|
||
285 | * @{
|
||
286 | */
|
||
287 | /*===========================================================================*/
|
||
288 | 4c72a54c | Thomas Schöpping | #include <alld_LED.h> |
289 | #include <alld_button.h> |
||
290 | |||
291 | /**
|
||
292 | * @brief LED driver.
|
||
293 | */
|
||
294 | extern LEDDriver moduleLldLed;
|
||
295 | |||
296 | /**
|
||
297 | * @brief Button driver.
|
||
298 | */
|
||
299 | extern ButtonDriver moduleLldUserButton;
|
||
300 | |||
301 | #if (BOARD_DW1000_CONNECTED == true) |
||
302 | |||
303 | deaaa47e | Cung Sang | #include <alld_DW1000.h> |
304 | |||
305 | extern DW1000Driver moduleLldDw1000;
|
||
306 | |||
307 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
308 | f4da707a | Thomas Schöpping | |
309 | /** @} */
|
||
310 | |||
311 | /*===========================================================================*/
|
||
312 | /**
|
||
313 | 4c72a54c | Thomas Schöpping | * @name Tests
|
314 | f4da707a | Thomas Schöpping | * @{
|
315 | */
|
||
316 | /*===========================================================================*/
|
||
317 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
318 | |||
319 | 4c72a54c | Thomas Schöpping | /**
|
320 | * @brief LED test command.
|
||
321 | */
|
||
322 | extern aos_shellcommand_t moduleTestLedShellCmd;
|
||
323 | |||
324 | /**
|
||
325 | * @brief User button test command.
|
||
326 | */
|
||
327 | extern aos_shellcommand_t moduleTestButtonShellCmd;
|
||
328 | |||
329 | #if (BOARD_DW1000_CONNECTED == true) |
||
330 | deaaa47e | Cung Sang | |
331 | /**
|
||
332 | 4c72a54c | Thomas Schöpping | * @brief DW1000 (UWB transmitter) test command.
|
333 | deaaa47e | Cung Sang | */
|
334 | 4c72a54c | Thomas Schöpping | extern aos_shellcommand_t moduleTestDw1000ShellCmd;
|
335 | deaaa47e | Cung Sang | |
336 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
337 | |||
338 | /**
|
||
339 | * @brief Entire module test command.
|
||
340 | */
|
||
341 | extern aos_shellcommand_t moduleTestAllShellCmd;
|
||
342 | deaaa47e | Cung Sang | |
343 | 7de0cc90 | Thomas Schöpping | #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
344 | f4da707a | Thomas Schöpping | |
345 | /** @} */
|
||
346 | |||
347 | 6ff06bbf | Thomas Schöpping | #endif /* AMIROOS_MODULE_H */ |
348 | f4da707a | Thomas Schöpping | |
349 | /** @} */ |