amiro-os / modules / NUCLEO-F103RB / module.h @ 7e674331
History | View | Annotate | Download (11.08 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 |
|
52 |
#if defined(__cplusplus)
|
53 |
} |
54 |
#endif /* defined(__cplusplus) */ |
55 |
|
56 |
|
57 |
|
58 |
|
59 |
/** @} */
|
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 |
#if (BOARD_DW1000_CONNECTED == true) |
84 |
/**
|
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 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
99 |
|
100 |
/** @} */
|
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 |
//#if (BOARD_DW1000_CONNECTED == true)
|
115 |
/**
|
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 |
//#endif /* (BOARD_DW1000_CONNECTED == true) */
|
133 |
|
134 |
/**
|
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 |
//#if (BOARD_DW1000_CONNECTED == true)
|
149 |
/**
|
150 |
* @brief Event flag to be call dwt_isr() interrupt.
|
151 |
*/
|
152 |
#define MODULE_OS_IOEVENTFLAGS_DW1000_IRQn AOS_IOEVENT_FLAG(PAL_PAD(LINE_ARD_D14))
|
153 |
//#endif /* (BOARD_DW1000_CONNECTED == true) */
|
154 |
|
155 |
/**
|
156 |
* @brief Event flag to be set on a USER_BUTTON interrupt.
|
157 |
*/
|
158 |
#define MODULE_OS_IOEVENTFLAGS_USERBUTTON AOS_IOEVENT_FLAG(PAL_PAD(LINE_BUTTON))
|
159 |
|
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 |
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */ |
166 |
|
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 |
palSetLineCallback(moduleGpioUserButton.gpio->line, aosSysGetStdIntCallback(), &moduleGpioUserButton.gpio->line); \ |
174 |
palEnableLineEvent(moduleGpioUserButton.gpio->line, APAL2CH_EDGE(moduleGpioUserButton.meta.edge)); \ |
175 |
MODULE_INIT_INTERRUPTS_DW1000(); \ |
176 |
} |
177 |
#if (BOARD_DW1000_CONNECTED == true) |
178 |
#define MODULE_INIT_INTERRUPTS_DW1000() { \
|
179 |
palSetLineCallback(moduleGpioDw1000Irqn.gpio->line, aosSysGetStdIntCallback(), &moduleGpioDw1000Irqn.gpio->line); \ |
180 |
palEnableLineEvent(moduleGpioDw1000Irqn.gpio->line, APAL2CH_EDGE(moduleGpioDw1000Irqn.meta.edge)); \ |
181 |
} |
182 |
#else /* (BOARD_DW1000_CONNECTED == true) */ |
183 |
#define MODULE_INIT_INTERRUPTS_DW1000() { \
|
184 |
} |
185 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
186 |
|
187 |
|
188 |
/**
|
189 |
* @brief Test initialization hook.
|
190 |
*/
|
191 |
#define MODULE_INIT_TESTS() { \
|
192 |
/* initialize tests and add to shell */ \
|
193 |
aosShellAddCommand(&aos.shell, &moduleTestLedShellCmd); \ |
194 |
aosShellAddCommand(&aos.shell, &moduleTestButtonShellCmd); \ |
195 |
MODULE_INIT_TESTS_DW1000(); \ |
196 |
aosShellAddCommand(&aos.shell, &moduleTestAllShellCmd); \ |
197 |
} |
198 |
#if (BOARD_DW1000_CONNECTED == true) |
199 |
#define MODULE_INIT_TESTS_DW1000() { \
|
200 |
aosShellAddCommand(&aos.shell, &moduleTestDw1000ShellCmd); \ |
201 |
} |
202 |
#else /* (BOARD_DW1000_CONNECTED == true) */ |
203 |
#define MODULE_INIT_TESTS_DW1000() { \
|
204 |
} |
205 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
206 |
|
207 |
|
208 |
/**
|
209 |
* @brief Periphery communication interfaces initialization hook.
|
210 |
*/
|
211 |
#define MODULE_INIT_PERIPHERY_IF() { \
|
212 |
/* serial driver */ \
|
213 |
sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig); \ |
214 |
MODULE_INIT_PERIPHERY_IF_DW1000(); \ |
215 |
} |
216 |
#if (BOARD_DW1000_CONNECTED == true) |
217 |
#define MODULE_INIT_PERIPHERY_IF_DW1000() { \
|
218 |
/* SPI init */ \
|
219 |
dw1000_spi_init(); \ |
220 |
spiStart(&MODULE_HAL_SPI_UWB, &moduleHalSpiUwbLsConfig); \ |
221 |
} |
222 |
#else /* (BOARD_DW1000_CONNECTED == true) */ |
223 |
#define MODULE_INIT_PERIPHERY_IF_DW1000() { \
|
224 |
} |
225 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
226 |
|
227 |
|
228 |
/**
|
229 |
* @brief Periphery communication interface deinitialization hook.
|
230 |
*/
|
231 |
#define MODULE_SHUTDOWN_PERIPHERY_IF() { \
|
232 |
MODULE_SHUTDOWN_PERIPHERY_IF_DW1000(); \ |
233 |
} |
234 |
#if (BOARD_DW1000_CONNECTED == true) |
235 |
#define MODULE_SHUTDOWN_PERIPHERY_IF_DW1000() { \
|
236 |
/* SPI */ \
|
237 |
spiStop(&MODULE_HAL_SPI_UWB); \ |
238 |
} |
239 |
#else /* (BOARD_DW1000_CONNECTED == true) */ |
240 |
#define MODULE_SHUTDOWN_PERIPHERY_IF_DW1000() { \
|
241 |
} |
242 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
243 |
|
244 |
/**
|
245 |
* @brief HOOK to toggle the LEDs when the user button is pressed.
|
246 |
*/
|
247 |
#define MODULE_MAIN_LOOP_IO_EVENT(eventflags) { \
|
248 |
if (eventflags & MODULE_OS_IOEVENTFLAGS_USERBUTTON) { \
|
249 |
apalControlGpioState_t buttonstate; \ |
250 |
apalControlGpioGet(&moduleGpioUserButton, &buttonstate); \ |
251 |
apalControlGpioSet(&moduleGpioLed, buttonstate); \ |
252 |
} \ |
253 |
MODULE_MAIN_LOOP_IO_EVENT_DW1000(); \ |
254 |
} |
255 |
#if (BOARD_DW1000_CONNECTED == true) |
256 |
/**
|
257 |
* @brief HOOK to call process_deca_irq() func when the dw1000 interrupt pin is activated.
|
258 |
*/
|
259 |
#define MODULE_MAIN_LOOP_IO_EVENT_DW1000() { \
|
260 |
if(eventflags & MODULE_OS_IOEVENTFLAGS_DW1000_IRQn) { \
|
261 |
/*apalGpioToggle(moduleGpioLed.gpio);*/ /* just for debug*/ \ |
262 |
process_deca_irq(); \ |
263 |
} \ |
264 |
} |
265 |
#else /* (BOARD_DW1000_CONNECTED == true) */ |
266 |
#define MODULE_MAIN_LOOP_IO_EVENT_DW1000() { \
|
267 |
} |
268 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
269 |
|
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 |
#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 |
/**
|
302 |
* @brief DW1000 driver.
|
303 |
*/
|
304 |
#include <alld_DW1000.h> |
305 |
void setHighSpeed_SPI(bool speedValue, DW1000Driver* drv); |
306 |
|
307 |
#if (BOARD_DW1000_CONNECTED == true) |
308 |
extern DW1000Driver moduleLldDw1000;
|
309 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
310 |
|
311 |
/** @} */
|
312 |
|
313 |
/*===========================================================================*/
|
314 |
/**
|
315 |
* @name Tests
|
316 |
* @{
|
317 |
*/
|
318 |
/*===========================================================================*/
|
319 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
320 |
|
321 |
/**
|
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 |
/**
|
333 |
* @brief DW1000 (UWB transmitter) test command.
|
334 |
*/
|
335 |
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 |
|
343 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
344 |
|
345 |
/** @} */
|
346 |
|
347 |
#endif /* AMIROOS_MODULE_H */ |
348 |
|
349 |
/** @} */
|