amiro-os / modules / NUCLEO-F103RB / module.h @ 65ebff5f
History | View | Annotate | Download (11.1 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 | 7de0cc90 | Thomas Schöpping | #if defined(__cplusplus)
|
40 | deaaa47e | Cung Sang | extern "C" { |
41 | 7de0cc90 | Thomas Schöpping | #endif /* defined(__cplusplus) */ |
42 | deaaa47e | Cung Sang | |
43 | 8d4d058e | Cung Sang | #if (BOARD_DW1000_CONNECTED == true) |
44 | deaaa47e | Cung Sang | void dw1000_spi_init(void); |
45 | 8d4d058e | Cung Sang | void process_deca_irq(void); |
46 | apalGpioState_t port_CheckEXT_IRQ(void) ;
|
||
47 | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
||
48 | |||
49 | void set_SPI_chip_select(void); |
||
50 | void clear_SPI_chip_select(void); |
||
51 | deaaa47e | Cung Sang | |
52 | 7de0cc90 | Thomas Schöpping | #if defined(__cplusplus)
|
53 | deaaa47e | Cung Sang | } |
54 | 7de0cc90 | Thomas Schöpping | #endif /* defined(__cplusplus) */ |
55 | deaaa47e | Cung Sang | |
56 | 8d4d058e | Cung Sang | |
57 | deaaa47e | Cung Sang | |
58 | |||
59 | f4da707a | Thomas Schöpping | /** @} */
|
60 | |||
61 | /*===========================================================================*/
|
||
62 | /**
|
||
63 | * @name ChibiOS/HAL configuration
|
||
64 | * @{
|
||
65 | */
|
||
66 | /*===========================================================================*/
|
||
67 | |||
68 | /**
|
||
69 | * @brief Serial driver of the programmer interface.
|
||
70 | */
|
||
71 | #define MODULE_HAL_PROGIF SD2
|
||
72 | |||
73 | /**
|
||
74 | * @brief Configuration for the programmer serial interface driver.
|
||
75 | */
|
||
76 | extern SerialConfig moduleHalProgIfConfig;
|
||
77 | |||
78 | /**
|
||
79 | * @brief Real-Time Clock driver.
|
||
80 | */
|
||
81 | #define MODULE_HAL_RTC RTCD1
|
||
82 | |||
83 | 4c72a54c | Thomas Schöpping | #if (BOARD_DW1000_CONNECTED == true) |
84 | deaaa47e | Cung Sang | /**
|
85 | * @brief SPI interface driver for the motion sensors (gyroscope and accelerometer).
|
||
86 | */
|
||
87 | #define MODULE_HAL_SPI_UWB SPID2
|
||
88 | |||
89 | /**
|
||
90 | * @brief Configuration for the SPI interface driver to communicate with the LED driver.
|
||
91 | */
|
||
92 | extern SPIConfig moduleHalSpiUwbHsConfig;
|
||
93 | |||
94 | /**
|
||
95 | * @brief Configuration for the SPI interface driver to communicate with the wireless transceiver.
|
||
96 | */
|
||
97 | extern SPIConfig moduleHalSpiUwbLsConfig;
|
||
98 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
99 | deaaa47e | Cung Sang | |
100 | f4da707a | Thomas Schöpping | /** @} */
|
101 | |||
102 | /*===========================================================================*/
|
||
103 | /**
|
||
104 | * @name GPIO definitions
|
||
105 | * @{
|
||
106 | */
|
||
107 | /*===========================================================================*/
|
||
108 | |||
109 | /**
|
||
110 | * @brief LED output signal GPIO.
|
||
111 | */
|
||
112 | extern ROMCONST apalControlGpio_t moduleGpioLed;
|
||
113 | |||
114 | 8d4d058e | Cung Sang | //#if (BOARD_DW1000_CONNECTED == true)
|
115 | deaaa47e | Cung Sang | /**
|
116 | * @brief DW1000 reset output signal
|
||
117 | * @note the reset pin should be drived as low by MCU to activate.
|
||
118 | * Then, put back the reset pin as input to MCU (tri-state float on the air
|
||
119 | * is not supported in AMiRo)
|
||
120 | */
|
||
121 | extern ROMCONST apalControlGpio_t moduleGpioDw1000Reset;
|
||
122 | |||
123 | /**
|
||
124 | * @brief DW1000 interrupt IRQn input signal.
|
||
125 | */
|
||
126 | extern ROMCONST apalControlGpio_t moduleGpioDw1000Irqn;
|
||
127 | |||
128 | /**
|
||
129 | * @brief DW1000 SPI chip select output signal.
|
||
130 | */
|
||
131 | extern ROMCONST apalControlGpio_t moduleGpioSpiChipSelect ;
|
||
132 | 8d4d058e | Cung Sang | //#endif /* (BOARD_DW1000_CONNECTED == true) */
|
133 | deaaa47e | Cung Sang | |
134 | f4da707a | Thomas Schöpping | /**
|
135 | * @brief User button input signal.
|
||
136 | */
|
||
137 | extern ROMCONST apalControlGpio_t moduleGpioUserButton;
|
||
138 | |||
139 | /** @} */
|
||
140 | |||
141 | /*===========================================================================*/
|
||
142 | /**
|
||
143 | * @name AMiRo-OS core configurations
|
||
144 | * @{
|
||
145 | */
|
||
146 | /*===========================================================================*/
|
||
147 | |||
148 | 8d4d058e | Cung Sang | //#if (BOARD_DW1000_CONNECTED == true)
|
149 | f4da707a | Thomas Schöpping | /**
|
150 | deaaa47e | Cung Sang | * @brief Event flag to be call dwt_isr() interrupt.
|
151 | */
|
||
152 | 8d4d058e | Cung Sang | #define MODULE_OS_IOEVENTFLAGS_DW1000_IRQn AOS_IOEVENT_FLAG(PAL_PAD(LINE_ARD_D14))
|
153 | //#endif /* (BOARD_DW1000_CONNECTED == true) */
|
||
154 | 4c72a54c | Thomas Schöpping | |
155 | deaaa47e | Cung Sang | /**
|
156 | f4da707a | Thomas Schöpping | * @brief Event flag to be set on a USER_BUTTON interrupt.
|
157 | */
|
||
158 | 3106e8cc | Thomas Schöpping | #define MODULE_OS_IOEVENTFLAGS_USERBUTTON AOS_IOEVENT_FLAG(PAL_PAD(LINE_BUTTON))
|
159 | f4da707a | Thomas Schöpping | |
160 | #if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
161 | /**
|
||
162 | * @brief Shell prompt text.
|
||
163 | */
|
||
164 | extern ROMCONST char* moduleShellPrompt; |
||
165 | 7de0cc90 | Thomas Schöpping | #endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */ |
166 | f4da707a | Thomas Schöpping | |
167 | /**
|
||
168 | * @brief Interrupt initialization macro.
|
||
169 | * @note SSSP related interrupt signals are already initialized in 'aos_system.c'.
|
||
170 | */
|
||
171 | #define MODULE_INIT_INTERRUPTS() { \
|
||
172 | /* user button */ \
|
||
173 | 3106e8cc | Thomas Schöpping | palSetLineCallback(moduleGpioUserButton.gpio->line, aosSysGetStdIntCallback(), &moduleGpioUserButton.gpio->line); \ |
174 | palEnableLineEvent(moduleGpioUserButton.gpio->line, APAL2CH_EDGE(moduleGpioUserButton.meta.edge)); \ |
||
175 | deaaa47e | Cung Sang | MODULE_INIT_INTERRUPTS_DW1000(); \ |
176 | f4da707a | Thomas Schöpping | } |
177 | 4c72a54c | Thomas Schöpping | #if (BOARD_DW1000_CONNECTED == true) |
178 | deaaa47e | Cung Sang | #define MODULE_INIT_INTERRUPTS_DW1000() { \
|
179 | 3106e8cc | Thomas Schöpping | palSetLineCallback(moduleGpioDw1000Irqn.gpio->line, aosSysGetStdIntCallback(), &moduleGpioDw1000Irqn.gpio->line); \ |
180 | palEnableLineEvent(moduleGpioDw1000Irqn.gpio->line, APAL2CH_EDGE(moduleGpioDw1000Irqn.meta.edge)); \ |
||
181 | deaaa47e | Cung Sang | } |
182 | 4c72a54c | Thomas Schöpping | #else /* (BOARD_DW1000_CONNECTED == true) */ |
183 | 7de0cc90 | Thomas Schöpping | #define MODULE_INIT_INTERRUPTS_DW1000() { \
|
184 | deaaa47e | Cung Sang | } |
185 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
186 | deaaa47e | Cung Sang | |
187 | f4da707a | Thomas Schöpping | |
188 | /**
|
||
189 | 4c72a54c | Thomas Schöpping | * @brief Test initialization hook.
|
190 | f4da707a | Thomas Schöpping | */
|
191 | #define MODULE_INIT_TESTS() { \
|
||
192 | 4c72a54c | Thomas Schöpping | /* initialize tests and add to shell */ \
|
193 | aosShellAddCommand(&aos.shell, &moduleTestLedShellCmd); \ |
||
194 | aosShellAddCommand(&aos.shell, &moduleTestButtonShellCmd); \ |
||
195 | deaaa47e | Cung Sang | MODULE_INIT_TESTS_DW1000(); \ |
196 | 4c72a54c | Thomas Schöpping | aosShellAddCommand(&aos.shell, &moduleTestAllShellCmd); \ |
197 | f4da707a | Thomas Schöpping | } |
198 | 4c72a54c | Thomas Schöpping | #if (BOARD_DW1000_CONNECTED == true) |
199 | deaaa47e | Cung Sang | #define MODULE_INIT_TESTS_DW1000() { \
|
200 | 4c72a54c | Thomas Schöpping | aosShellAddCommand(&aos.shell, &moduleTestDw1000ShellCmd); \ |
201 | deaaa47e | Cung Sang | } |
202 | 4c72a54c | Thomas Schöpping | #else /* (BOARD_DW1000_CONNECTED == true) */ |
203 | 7de0cc90 | Thomas Schöpping | #define MODULE_INIT_TESTS_DW1000() { \
|
204 | deaaa47e | Cung Sang | } |
205 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
206 | deaaa47e | Cung Sang | |
207 | f4da707a | Thomas Schöpping | |
208 | /**
|
||
209 | * @brief Periphery communication interfaces initialization hook.
|
||
210 | */
|
||
211 | 4c72a54c | Thomas Schöpping | #define MODULE_INIT_PERIPHERY_IF() { \
|
212 | f4da707a | Thomas Schöpping | /* serial driver */ \
|
213 | sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig); \ |
||
214 | 4c72a54c | Thomas Schöpping | MODULE_INIT_PERIPHERY_IF_DW1000(); \ |
215 | f4da707a | Thomas Schöpping | } |
216 | 4c72a54c | Thomas Schöpping | #if (BOARD_DW1000_CONNECTED == true) |
217 | #define MODULE_INIT_PERIPHERY_IF_DW1000() { \
|
||
218 | deaaa47e | Cung Sang | /* SPI init */ \
|
219 | dw1000_spi_init(); \ |
||
220 | spiStart(&MODULE_HAL_SPI_UWB, &moduleHalSpiUwbLsConfig); \ |
||
221 | } |
||
222 | 4c72a54c | Thomas Schöpping | #else /* (BOARD_DW1000_CONNECTED == true) */ |
223 | #define MODULE_INIT_PERIPHERY_IF_DW1000() { \
|
||
224 | deaaa47e | Cung Sang | } |
225 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
226 | deaaa47e | Cung Sang | |
227 | f4da707a | Thomas Schöpping | |
228 | /**
|
||
229 | * @brief Periphery communication interface deinitialization hook.
|
||
230 | */
|
||
231 | 4c72a54c | Thomas Schöpping | #define MODULE_SHUTDOWN_PERIPHERY_IF() { \
|
232 | MODULE_SHUTDOWN_PERIPHERY_IF_DW1000(); \ |
||
233 | deaaa47e | Cung Sang | } |
234 | 4c72a54c | Thomas Schöpping | #if (BOARD_DW1000_CONNECTED == true) |
235 | #define MODULE_SHUTDOWN_PERIPHERY_IF_DW1000() { \
|
||
236 | deaaa47e | Cung Sang | /* SPI */ \
|
237 | spiStop(&MODULE_HAL_SPI_UWB); \ |
||
238 | f4da707a | Thomas Schöpping | } |
239 | 4c72a54c | Thomas Schöpping | #else /* (BOARD_DW1000_CONNECTED == true) */ |
240 | #define MODULE_SHUTDOWN_PERIPHERY_IF_DW1000() { \
|
||
241 | deaaa47e | Cung Sang | } |
242 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
243 | f4da707a | Thomas Schöpping | |
244 | /**
|
||
245 | 4c72a54c | Thomas Schöpping | * @brief HOOK to toggle the LEDs when the user button is pressed.
|
246 | f4da707a | Thomas Schöpping | */
|
247 | 732a4657 | Thomas Schöpping | #define MODULE_MAIN_LOOP_IO_EVENT(eventflags) { \
|
248 | f4da707a | Thomas Schöpping | if (eventflags & MODULE_OS_IOEVENTFLAGS_USERBUTTON) { \
|
249 | apalControlGpioState_t buttonstate; \ |
||
250 | apalControlGpioGet(&moduleGpioUserButton, &buttonstate); \ |
||
251 | apalControlGpioSet(&moduleGpioLed, buttonstate); \ |
||
252 | } \ |
||
253 | deaaa47e | Cung Sang | MODULE_MAIN_LOOP_IO_EVENT_DW1000(); \ |
254 | f4da707a | Thomas Schöpping | } |
255 | 4c72a54c | Thomas Schöpping | #if (BOARD_DW1000_CONNECTED == true) |
256 | /**
|
||
257 | * @brief HOOK to call process_deca_irq() func when the dw1000 interrupt pin is activated.
|
||
258 | */
|
||
259 | deaaa47e | Cung Sang | #define MODULE_MAIN_LOOP_IO_EVENT_DW1000() { \
|
260 | 7de0cc90 | Thomas Schöpping | if(eventflags & MODULE_OS_IOEVENTFLAGS_DW1000_IRQn) { \
|
261 | 8d4d058e | Cung Sang | /*apalGpioToggle(moduleGpioLed.gpio);*/ /* just for debug*/ \ |
262 | deaaa47e | Cung Sang | process_deca_irq(); \ |
263 | 7de0cc90 | Thomas Schöpping | } \ |
264 | deaaa47e | Cung Sang | } |
265 | 4c72a54c | Thomas Schöpping | #else /* (BOARD_DW1000_CONNECTED == true) */ |
266 | deaaa47e | Cung Sang | #define MODULE_MAIN_LOOP_IO_EVENT_DW1000() { \
|
267 | } |
||
268 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
269 | f4da707a | Thomas Schöpping | |
270 | /** @} */
|
||
271 | |||
272 | /*===========================================================================*/
|
||
273 | /**
|
||
274 | * @name Startup Shutdown Synchronization Protocol (SSSP)
|
||
275 | * @{
|
||
276 | */
|
||
277 | /*===========================================================================*/
|
||
278 | |||
279 | /** @} */
|
||
280 | |||
281 | /*===========================================================================*/
|
||
282 | /**
|
||
283 | * @name Low-level drivers
|
||
284 | * @{
|
||
285 | */
|
||
286 | /*===========================================================================*/
|
||
287 | 4c72a54c | Thomas Schöpping | #include <alld_LED.h> |
288 | #include <alld_button.h> |
||
289 | |||
290 | /**
|
||
291 | * @brief LED driver.
|
||
292 | */
|
||
293 | extern LEDDriver moduleLldLed;
|
||
294 | |||
295 | /**
|
||
296 | * @brief Button driver.
|
||
297 | */
|
||
298 | extern ButtonDriver moduleLldUserButton;
|
||
299 | |||
300 | |||
301 | 8d4d058e | Cung Sang | /**
|
302 | * @brief DW1000 driver.
|
||
303 | */
|
||
304 | deaaa47e | Cung Sang | #include <alld_DW1000.h> |
305 | 8d4d058e | Cung Sang | void setHighSpeed_SPI(bool speedValue, DW1000Driver* drv); |
306 | deaaa47e | Cung Sang | |
307 | 8d4d058e | Cung Sang | #if (BOARD_DW1000_CONNECTED == true) |
308 | deaaa47e | Cung Sang | extern DW1000Driver moduleLldDw1000;
|
309 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_DW1000_CONNECTED == true) */ |
310 | f4da707a | Thomas Schöpping | |
311 | /** @} */
|
||
312 | |||
313 | /*===========================================================================*/
|
||
314 | /**
|
||
315 | 4c72a54c | Thomas Schöpping | * @name Tests
|
316 | f4da707a | Thomas Schöpping | * @{
|
317 | */
|
||
318 | /*===========================================================================*/
|
||
319 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
320 | |||
321 | 4c72a54c | Thomas Schöpping | /**
|
322 | * @brief LED test command.
|
||
323 | */
|
||
324 | extern aos_shellcommand_t moduleTestLedShellCmd;
|
||
325 | |||
326 | /**
|
||
327 | * @brief User button test command.
|
||
328 | */
|
||
329 | extern aos_shellcommand_t moduleTestButtonShellCmd;
|
||
330 | |||
331 | #if (BOARD_DW1000_CONNECTED == true) |
||
332 | deaaa47e | Cung Sang | /**
|
333 | 4c72a54c | Thomas Schöpping | * @brief DW1000 (UWB transmitter) test command.
|
334 | deaaa47e | Cung Sang | */
|
335 | 4c72a54c | Thomas Schöpping | extern aos_shellcommand_t moduleTestDw1000ShellCmd;
|
336 | #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 | /** @} */ |