amiro-os / modules / NUCLEO-F103RB / module.h @ 651cb6e6
History | View | Annotate | Download (10.032 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(AMIROLLD_CFG_DW1000)
|
40 |
|
41 |
#if defined(__cplusplus)
|
42 |
extern "C" { |
43 |
#endif /* defined(__cplusplus) */ |
44 |
|
45 |
void dw1000_spi_init(void); |
46 |
|
47 |
#if defined(__cplusplus)
|
48 |
} |
49 |
#endif /* defined(__cplusplus) */ |
50 |
|
51 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
52 |
|
53 |
|
54 |
/** @} */
|
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 |
|
79 |
#if defined(AMIROLLD_CFG_DW1000)
|
80 |
|
81 |
/**
|
82 |
* @brief SPI interface driver for the motion sensors (gyroscope and accelerometer).
|
83 |
*/
|
84 |
#define MODULE_HAL_SPI_UWB SPID2
|
85 |
|
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 |
|
97 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
98 |
|
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 defined(AMIROLLD_CFG_DW1000)
|
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 |
|
133 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
134 |
|
135 |
/**
|
136 |
* @brief User button input signal.
|
137 |
*/
|
138 |
extern ROMCONST apalControlGpio_t moduleGpioUserButton;
|
139 |
|
140 |
/** @} */
|
141 |
|
142 |
/*===========================================================================*/
|
143 |
/**
|
144 |
* @name AMiRo-OS core configurations
|
145 |
* @{
|
146 |
*/
|
147 |
/*===========================================================================*/
|
148 |
|
149 |
/**
|
150 |
* @brief Event flag to be call dwt_isr() interrupt.
|
151 |
*/
|
152 |
#define MODULE_OS_IOEVENTFLAGS_DW1000_IRQn AOS_IOEVENT_FLAG(GPIOB_ARD_D6)
|
153 |
|
154 |
/**
|
155 |
* @brief Event flag to be set on a USER_BUTTON interrupt.
|
156 |
*/
|
157 |
#define MODULE_OS_IOEVENTFLAGS_USERBUTTON AOS_IOEVENT_FLAG(GPIOC_BUTTON)
|
158 |
|
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 |
/**
|
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 |
palSetPadCallback(moduleGpioUserButton.gpio->port, moduleGpioUserButton.gpio->pad, _intCallback, &moduleGpioUserButton.gpio->pad); \ |
175 |
palEnablePadEvent(moduleGpioUserButton.gpio->port, moduleGpioUserButton.gpio->pad, APAL2CH_EDGE(moduleGpioUserButton.meta.edge)); \ |
176 |
MODULE_INIT_INTERRUPTS_DW1000(); \ |
177 |
} |
178 |
#if defined(AMIROLLD_CFG_DW1000)
|
179 |
#define MODULE_INIT_INTERRUPTS_DW1000() { \
|
180 |
palSetPadCallback(moduleGpioDw1000Irqn.gpio->port, moduleGpioDw1000Irqn.gpio->pad, _intCallback, &moduleGpioDw1000Irqn.gpio->pad); \ |
181 |
palEnablePadEvent(moduleGpioDw1000Irqn.gpio->port, moduleGpioDw1000Irqn.gpio->pad, APAL2CH_EDGE(moduleGpioDw1000Irqn.meta.edge)); \ |
182 |
} |
183 |
#else /* defined(AMIROLLD_CFG_DW1000) */ |
184 |
#define MODULE_INIT_INTERRUPTS_DW1000() { \
|
185 |
} |
186 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
187 |
|
188 |
|
189 |
/**
|
190 |
* @brief Unit test initialization hook.
|
191 |
*/
|
192 |
#define MODULE_INIT_TESTS() { \
|
193 |
/* add unit-test shell commands */ \
|
194 |
MODULE_INIT_TESTS_DW1000(); \ |
195 |
} |
196 |
#if defined(AMIROLLD_CFG_DW1000)
|
197 |
#define MODULE_INIT_TESTS_DW1000() { \
|
198 |
aosShellAddCommand(&aos.shell, &moduleUtAlldDw1000.shellcmd); \ |
199 |
} |
200 |
#else /* defined(AMIROLLD_CFG_DW1000) */ |
201 |
#define MODULE_INIT_TESTS_DW1000() { \
|
202 |
} |
203 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
204 |
|
205 |
|
206 |
/**
|
207 |
* @brief Periphery communication interfaces initialization hook.
|
208 |
*/
|
209 |
#define MODULE_INIT_PERIPHERY_COMM() { \
|
210 |
/* serial driver */ \
|
211 |
sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig); \ |
212 |
MODULE_INIT_PERIPHERY_COMM_DW1000(); \ |
213 |
} |
214 |
#if defined(AMIROLLD_CFG_DW1000)
|
215 |
#define MODULE_INIT_PERIPHERY_COMM_DW1000() { \
|
216 |
/* SPI init */ \
|
217 |
dw1000_spi_init(); \ |
218 |
spiStart(&MODULE_HAL_SPI_UWB, &moduleHalSpiUwbLsConfig); \ |
219 |
} |
220 |
#else /* defined(AMIROLLD_CFG_DW1000) */ |
221 |
#define MODULE_INIT_PERIPHERY_COMM_DW1000() { \
|
222 |
} |
223 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
224 |
|
225 |
|
226 |
/**
|
227 |
* @brief Periphery communication interface deinitialization hook.
|
228 |
*/
|
229 |
#define MODULE_SHUTDOWN_PERIPHERY_COMM() { \
|
230 |
MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000(); \ |
231 |
} |
232 |
#if defined(AMIROLLD_CFG_DW1000)
|
233 |
#define MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000() { \
|
234 |
/* SPI */ \
|
235 |
spiStop(&MODULE_HAL_SPI_UWB); \ |
236 |
} |
237 |
#else /* defined(AMIROLLD_CFG_DW1000) */ |
238 |
#define MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000() { \
|
239 |
} |
240 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
241 |
|
242 |
/**
|
243 |
* @brief HOOK to call process_deca_irq() func when the dw1000 interrupt pin is activated.
|
244 |
*/
|
245 |
#define MODULE_MAIN_LOOP_IO_EVENT(eventflags) { \
|
246 |
if (eventflags & MODULE_OS_IOEVENTFLAGS_USERBUTTON) { \
|
247 |
apalControlGpioState_t buttonstate; \ |
248 |
apalControlGpioGet(&moduleGpioUserButton, &buttonstate); \ |
249 |
apalControlGpioSet(&moduleGpioLed, buttonstate); \ |
250 |
} \ |
251 |
MODULE_MAIN_LOOP_IO_EVENT_DW1000(); \ |
252 |
} |
253 |
#if defined(AMIROLLD_CFG_DW1000)
|
254 |
#define MODULE_MAIN_LOOP_IO_EVENT_DW1000() { \
|
255 |
if(eventflags & MODULE_OS_IOEVENTFLAGS_DW1000_IRQn) { \
|
256 |
/*apalGpioToggle(moduleGpioLedGreen.gpio); // just for debug */ \
|
257 |
process_deca_irq(); \ |
258 |
} \ |
259 |
} |
260 |
#else /* defined(AMIROLLD_CFG_DW1000) */ |
261 |
#define MODULE_MAIN_LOOP_IO_EVENT_DW1000() { \
|
262 |
} |
263 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
264 |
|
265 |
/** @} */
|
266 |
|
267 |
/*===========================================================================*/
|
268 |
/**
|
269 |
* @name Startup Shutdown Synchronization Protocol (SSSP)
|
270 |
* @{
|
271 |
*/
|
272 |
/*===========================================================================*/
|
273 |
|
274 |
/** @} */
|
275 |
|
276 |
/*===========================================================================*/
|
277 |
/**
|
278 |
* @name Low-level drivers
|
279 |
* @{
|
280 |
*/
|
281 |
/*===========================================================================*/
|
282 |
#if defined(AMIROLLD_CFG_DW1000)
|
283 |
#include <alld_DW1000.h> |
284 |
|
285 |
extern DW1000Driver moduleLldDw1000;
|
286 |
|
287 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
288 |
|
289 |
/** @} */
|
290 |
|
291 |
/*===========================================================================*/
|
292 |
/**
|
293 |
* @name Unit tests (UT)
|
294 |
* @{
|
295 |
*/
|
296 |
/*===========================================================================*/
|
297 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
298 |
|
299 |
#if defined(AMIROLLD_CFG_DW1000) && (AMIROLLD_CFG_DW1000 == 1) |
300 |
#include <ut_alld_dw1000_v1.h> |
301 |
|
302 |
/**
|
303 |
* @brief DW1000 unit test object.
|
304 |
*/
|
305 |
extern aos_unittest_t moduleUtAlldDw1000;
|
306 |
|
307 |
#endif /* defined(AMIROLLD_CFG_DW1000) && (AMIROLLD_CFG_DW1000 == 1) */ |
308 |
|
309 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
310 |
|
311 |
/** @} */
|
312 |
|
313 |
#endif /* AMIROOS_MODULE_H */ |
314 |
|
315 |
/** @} */
|