amiro-os / modules / NUCLEO-F103RB / module.h @ 83e58975
History | View | Annotate | Download (11.117 KB)
1 |
/*
|
---|---|
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 |
#ifndef AMIROOS_MODULE_H
|
28 |
#define AMIROOS_MODULE_H
|
29 |
|
30 |
#include <amiroos.h> |
31 |
|
32 |
/*===========================================================================*/
|
33 |
/**
|
34 |
* @name Module specific functions
|
35 |
* @{
|
36 |
*/
|
37 |
/*===========================================================================*/
|
38 |
|
39 |
#if defined(__cplusplus)
|
40 |
extern "C" { |
41 |
#endif /* defined(__cplusplus) */ |
42 |
|
43 |
#if (BOARD_DW1000_CONNECTED == true) |
44 |
void dw1000_spi_init(void); |
45 |
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 |
void reset_DW1000(void); |
52 |
|
53 |
#if defined(__cplusplus)
|
54 |
} |
55 |
#endif /* defined(__cplusplus) */ |
56 |
|
57 |
/** @} */
|
58 |
|
59 |
/*===========================================================================*/
|
60 |
/**
|
61 |
* @name ChibiOS/HAL configuration
|
62 |
* @{
|
63 |
*/
|
64 |
/*===========================================================================*/
|
65 |
|
66 |
/**
|
67 |
* @brief Serial driver of the programmer interface.
|
68 |
*/
|
69 |
#define MODULE_HAL_PROGIF SD2
|
70 |
|
71 |
/**
|
72 |
* @brief Configuration for the programmer serial interface driver.
|
73 |
*/
|
74 |
extern SerialConfig moduleHalProgIfConfig;
|
75 |
|
76 |
/**
|
77 |
* @brief Real-Time Clock driver.
|
78 |
*/
|
79 |
#define MODULE_HAL_RTC RTCD1
|
80 |
|
81 |
#if (BOARD_DW1000_CONNECTED == true) |
82 |
/**
|
83 |
* @brief SPI interface driver for the motion sensors (gyroscope and accelerometer).
|
84 |
*/
|
85 |
#define MODULE_HAL_SPI_UWB SPID2
|
86 |
|
87 |
/**
|
88 |
* @brief Configuration for the SPI interface driver to communicate with the LED driver.
|
89 |
*/
|
90 |
extern SPIConfig moduleHalSpiUwbHsConfig;
|
91 |
|
92 |
/**
|
93 |
* @brief Configuration for the SPI interface driver to communicate with the wireless transceiver.
|
94 |
*/
|
95 |
extern SPIConfig moduleHalSpiUwbLsConfig;
|
96 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
97 |
|
98 |
/** @} */
|
99 |
|
100 |
/*===========================================================================*/
|
101 |
/**
|
102 |
* @name GPIO definitions
|
103 |
* @{
|
104 |
*/
|
105 |
/*===========================================================================*/
|
106 |
|
107 |
/**
|
108 |
* @brief LED output signal GPIO.
|
109 |
*/
|
110 |
extern ROMCONST apalControlGpio_t moduleGpioLed;
|
111 |
|
112 |
//#if (BOARD_DW1000_CONNECTED == true)
|
113 |
/**
|
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 |
//#endif /* (BOARD_DW1000_CONNECTED == true) */
|
131 |
|
132 |
/**
|
133 |
* @brief User button input signal.
|
134 |
*/
|
135 |
extern ROMCONST apalControlGpio_t moduleGpioUserButton;
|
136 |
|
137 |
/** @} */
|
138 |
|
139 |
/*===========================================================================*/
|
140 |
/**
|
141 |
* @name AMiRo-OS core configurations
|
142 |
* @{
|
143 |
*/
|
144 |
/*===========================================================================*/
|
145 |
|
146 |
//#if (BOARD_DW1000_CONNECTED == true)
|
147 |
/**
|
148 |
* @brief Event flag to be call dwt_isr() interrupt.
|
149 |
*/
|
150 |
#define MODULE_OS_GPIOEVENTFLAG_DW1000_IRQn AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_ARD_D14))
|
151 |
//#endif /* (BOARD_DW1000_CONNECTED == true) */
|
152 |
|
153 |
/**
|
154 |
* @brief Event flag to be set on a USER_BUTTON interrupt.
|
155 |
*/
|
156 |
#define MODULE_OS_GPIOEVENTFLAG_USERBUTTON AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_BUTTON))
|
157 |
|
158 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
159 |
/**
|
160 |
* @brief Shell prompt text.
|
161 |
*/
|
162 |
extern ROMCONST char* moduleShellPrompt; |
163 |
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) */ |
164 |
|
165 |
/**
|
166 |
* @brief Interrupt initialization macro.
|
167 |
* @note SSSP related interrupt signals are already initialized in 'aos_system.c'.
|
168 |
*/
|
169 |
#define MODULE_INIT_INTERRUPTS() { \
|
170 |
/* user button */ \
|
171 |
palSetLineCallback(moduleGpioUserButton.gpio->line, aosSysGetStdGpioCallback(), &moduleGpioUserButton.gpio->line); \ |
172 |
palEnableLineEvent(moduleGpioUserButton.gpio->line, APAL2CH_EDGE(moduleGpioUserButton.meta.edge)); \ |
173 |
MODULE_INIT_INTERRUPTS_DW1000(); \ |
174 |
} |
175 |
#if (BOARD_DW1000_CONNECTED == true) |
176 |
#define MODULE_INIT_INTERRUPTS_DW1000() { \
|
177 |
palSetLineCallback(moduleGpioDw1000Irqn.gpio->line, aosSysGetStdGpioCallback(), &moduleGpioDw1000Irqn.gpio->line); \ |
178 |
palEnableLineEvent(moduleGpioDw1000Irqn.gpio->line, APAL2CH_EDGE(moduleGpioDw1000Irqn.meta.edge)); \ |
179 |
} |
180 |
#else /* (BOARD_DW1000_CONNECTED == true) */ |
181 |
#define MODULE_INIT_INTERRUPTS_DW1000() { \
|
182 |
} |
183 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
184 |
|
185 |
|
186 |
/**
|
187 |
* @brief Test initialization hook.
|
188 |
*/
|
189 |
#define MODULE_INIT_TESTS() { \
|
190 |
/* add test commands to shell */ \
|
191 |
aosShellAddCommand(&aos.shell, &moduleTestLedShellCmd); \ |
192 |
aosShellAddCommand(&aos.shell, &moduleTestButtonShellCmd); \ |
193 |
MODULE_INIT_TESTS_DW1000(); \ |
194 |
aosShellAddCommand(&aos.shell, &moduleTestAllShellCmd); \ |
195 |
} |
196 |
#if (BOARD_DW1000_CONNECTED == true) |
197 |
#define MODULE_INIT_TESTS_DW1000() { \
|
198 |
aosShellAddCommand(&aos.shell, &moduleTestDw1000ShellCmd); \ |
199 |
} |
200 |
#else /* (BOARD_DW1000_CONNECTED == true) */ |
201 |
#define MODULE_INIT_TESTS_DW1000() { \
|
202 |
} |
203 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
204 |
|
205 |
|
206 |
/**
|
207 |
* @brief Periphery communication interfaces initialization hook.
|
208 |
*/
|
209 |
#define MODULE_INIT_PERIPHERY_IF() { \
|
210 |
/* serial driver */ \
|
211 |
sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig); \ |
212 |
MODULE_INIT_PERIPHERY_IF_DW1000(); \ |
213 |
} |
214 |
#if (BOARD_DW1000_CONNECTED == true) |
215 |
#define MODULE_INIT_PERIPHERY_IF_DW1000() { \
|
216 |
/* SPI init */ \
|
217 |
dw1000_spi_init(); \ |
218 |
spiStart(&MODULE_HAL_SPI_UWB, &moduleHalSpiUwbLsConfig); \ |
219 |
} |
220 |
#else /* (BOARD_DW1000_CONNECTED == true) */ |
221 |
#define MODULE_INIT_PERIPHERY_IF_DW1000() { \
|
222 |
} |
223 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
224 |
|
225 |
|
226 |
/**
|
227 |
* @brief Periphery communication interface deinitialization hook.
|
228 |
*/
|
229 |
#define MODULE_SHUTDOWN_PERIPHERY_IF() { \
|
230 |
MODULE_SHUTDOWN_PERIPHERY_IF_DW1000(); \ |
231 |
/* don't stop the serial driver so messages can still be printed */ \
|
232 |
} |
233 |
#if (BOARD_DW1000_CONNECTED == true) |
234 |
#define MODULE_SHUTDOWN_PERIPHERY_IF_DW1000() { \
|
235 |
/* SPI */ \
|
236 |
spiStop(&MODULE_HAL_SPI_UWB); \ |
237 |
} |
238 |
#else /* (BOARD_DW1000_CONNECTED == true) */ |
239 |
#define MODULE_SHUTDOWN_PERIPHERY_IF_DW1000() { \
|
240 |
} |
241 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
242 |
|
243 |
/**
|
244 |
* @brief HOOK to toggle the LEDs when the user button is pressed.
|
245 |
*/
|
246 |
#define MODULE_MAIN_LOOP_GPIOEVENT(eventflags) { \
|
247 |
if (eventflags & MODULE_OS_GPIOEVENTFLAG_USERBUTTON) { \
|
248 |
apalControlGpioState_t buttonstate; \ |
249 |
apalControlGpioGet(&moduleGpioUserButton, &buttonstate); \ |
250 |
apalControlGpioSet(&moduleGpioLed, buttonstate); \ |
251 |
} \ |
252 |
MODULE_MAIN_LOOP_GPIOEVENT_DW1000(); \ |
253 |
} |
254 |
#if (BOARD_DW1000_CONNECTED == true) |
255 |
/**
|
256 |
* @brief HOOK to call process_deca_irq() func when the dw1000 interrupt pin is activated.
|
257 |
*/
|
258 |
#define MODULE_MAIN_LOOP_GPIOEVENT_DW1000() { \
|
259 |
if(eventflags & MODULE_GPOS_IOEVENTFLAG_DW1000_IRQn) { \
|
260 |
/*apalGpioToggle(moduleGpioLed.gpio);*/ /* just for debug*/ \ |
261 |
process_deca_irq(); \ |
262 |
} \ |
263 |
} |
264 |
#else /* (BOARD_DW1000_CONNECTED == true) */ |
265 |
#define MODULE_MAIN_LOOP_GPIOEVENT_DW1000() { \
|
266 |
} |
267 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
268 |
|
269 |
/** @} */
|
270 |
|
271 |
/*===========================================================================*/
|
272 |
/**
|
273 |
* @name Startup Shutdown Synchronization Protocol (SSSP)
|
274 |
* @{
|
275 |
*/
|
276 |
/*===========================================================================*/
|
277 |
|
278 |
/** @} */
|
279 |
|
280 |
/*===========================================================================*/
|
281 |
/**
|
282 |
* @name Low-level drivers
|
283 |
* @{
|
284 |
*/
|
285 |
/*===========================================================================*/
|
286 |
#include <alld_LED.h> |
287 |
#include <alld_button.h> |
288 |
|
289 |
/**
|
290 |
* @brief LED driver.
|
291 |
*/
|
292 |
extern LEDDriver moduleLldLed;
|
293 |
|
294 |
/**
|
295 |
* @brief Button driver.
|
296 |
*/
|
297 |
extern ButtonDriver moduleLldUserButton;
|
298 |
|
299 |
|
300 |
/**
|
301 |
* @brief DW1000 driver.
|
302 |
*/
|
303 |
#include <alld_DW1000.h> |
304 |
void setHighSpeed_SPI(bool speedValue, DW1000Driver* drv); |
305 |
|
306 |
#if (BOARD_DW1000_CONNECTED == true) |
307 |
extern DW1000Driver moduleLldDw1000;
|
308 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
309 |
|
310 |
/** @} */
|
311 |
|
312 |
/*===========================================================================*/
|
313 |
/**
|
314 |
* @name Tests
|
315 |
* @{
|
316 |
*/
|
317 |
/*===========================================================================*/
|
318 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
319 |
|
320 |
/**
|
321 |
* @brief LED test command.
|
322 |
*/
|
323 |
extern aos_shellcommand_t moduleTestLedShellCmd;
|
324 |
|
325 |
/**
|
326 |
* @brief User button test command.
|
327 |
*/
|
328 |
extern aos_shellcommand_t moduleTestButtonShellCmd;
|
329 |
|
330 |
#if (BOARD_DW1000_CONNECTED == true) |
331 |
/**
|
332 |
* @brief DW1000 (UWB transmitter) test command.
|
333 |
*/
|
334 |
extern aos_shellcommand_t moduleTestDw1000ShellCmd;
|
335 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
336 |
|
337 |
/**
|
338 |
* @brief Entire module test command.
|
339 |
*/
|
340 |
extern aos_shellcommand_t moduleTestAllShellCmd;
|
341 |
|
342 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
343 |
|
344 |
/** @} */
|
345 |
|
346 |
#endif /* AMIROOS_MODULE_H */ |
347 |
|
348 |
/** @} */
|