amiro-os / modules / NUCLEO-F103RB / module.h @ c7dcc892
History | View | Annotate | Download (9.977 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(PAL_PAD(LINE_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(PAL_PAD(LINE_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 |
* @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 defined(AMIROLLD_CFG_DW1000)
|
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 /* defined(AMIROLLD_CFG_DW1000) */ |
183 |
#define MODULE_INIT_INTERRUPTS_DW1000() { \
|
184 |
} |
185 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
186 |
|
187 |
|
188 |
/**
|
189 |
* @brief Unit test initialization hook.
|
190 |
*/
|
191 |
#define MODULE_INIT_TESTS() { \
|
192 |
/* add unit-test shell commands */ \
|
193 |
MODULE_INIT_TESTS_DW1000(); \ |
194 |
} |
195 |
#if defined(AMIROLLD_CFG_DW1000)
|
196 |
#define MODULE_INIT_TESTS_DW1000() { \
|
197 |
aosShellAddCommand(&aos.shell, &moduleUtAlldDw1000.shellcmd); \ |
198 |
} |
199 |
#else /* defined(AMIROLLD_CFG_DW1000) */ |
200 |
#define MODULE_INIT_TESTS_DW1000() { \
|
201 |
} |
202 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
203 |
|
204 |
|
205 |
/**
|
206 |
* @brief Periphery communication interfaces initialization hook.
|
207 |
*/
|
208 |
#define MODULE_INIT_PERIPHERY_COMM() { \
|
209 |
/* serial driver */ \
|
210 |
sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig); \ |
211 |
MODULE_INIT_PERIPHERY_COMM_DW1000(); \ |
212 |
} |
213 |
#if defined(AMIROLLD_CFG_DW1000)
|
214 |
#define MODULE_INIT_PERIPHERY_COMM_DW1000() { \
|
215 |
/* SPI init */ \
|
216 |
dw1000_spi_init(); \ |
217 |
spiStart(&MODULE_HAL_SPI_UWB, &moduleHalSpiUwbLsConfig); \ |
218 |
} |
219 |
#else /* defined(AMIROLLD_CFG_DW1000) */ |
220 |
#define MODULE_INIT_PERIPHERY_COMM_DW1000() { \
|
221 |
} |
222 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
223 |
|
224 |
|
225 |
/**
|
226 |
* @brief Periphery communication interface deinitialization hook.
|
227 |
*/
|
228 |
#define MODULE_SHUTDOWN_PERIPHERY_COMM() { \
|
229 |
MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000(); \ |
230 |
} |
231 |
#if defined(AMIROLLD_CFG_DW1000)
|
232 |
#define MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000() { \
|
233 |
/* SPI */ \
|
234 |
spiStop(&MODULE_HAL_SPI_UWB); \ |
235 |
} |
236 |
#else /* defined(AMIROLLD_CFG_DW1000) */ |
237 |
#define MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000() { \
|
238 |
} |
239 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
240 |
|
241 |
/**
|
242 |
* @brief HOOK to call process_deca_irq() func when the dw1000 interrupt pin is activated.
|
243 |
*/
|
244 |
#define MODULE_MAIN_LOOP_IO_EVENT(eventflags) { \
|
245 |
if (eventflags & MODULE_OS_IOEVENTFLAGS_USERBUTTON) { \
|
246 |
apalControlGpioState_t buttonstate; \ |
247 |
apalControlGpioGet(&moduleGpioUserButton, &buttonstate); \ |
248 |
apalControlGpioSet(&moduleGpioLed, buttonstate); \ |
249 |
} \ |
250 |
MODULE_MAIN_LOOP_IO_EVENT_DW1000(); \ |
251 |
} |
252 |
#if defined(AMIROLLD_CFG_DW1000)
|
253 |
#define MODULE_MAIN_LOOP_IO_EVENT_DW1000() { \
|
254 |
if(eventflags & MODULE_OS_IOEVENTFLAGS_DW1000_IRQn) { \
|
255 |
/*apalGpioToggle(moduleGpioLedGreen.gpio); // just for debug */ \
|
256 |
process_deca_irq(); \ |
257 |
} \ |
258 |
} |
259 |
#else /* defined(AMIROLLD_CFG_DW1000) */ |
260 |
#define MODULE_MAIN_LOOP_IO_EVENT_DW1000() { \
|
261 |
} |
262 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
263 |
|
264 |
/** @} */
|
265 |
|
266 |
/*===========================================================================*/
|
267 |
/**
|
268 |
* @name Startup Shutdown Synchronization Protocol (SSSP)
|
269 |
* @{
|
270 |
*/
|
271 |
/*===========================================================================*/
|
272 |
|
273 |
/** @} */
|
274 |
|
275 |
/*===========================================================================*/
|
276 |
/**
|
277 |
* @name Low-level drivers
|
278 |
* @{
|
279 |
*/
|
280 |
/*===========================================================================*/
|
281 |
#if defined(AMIROLLD_CFG_DW1000)
|
282 |
#include <alld_DW1000.h> |
283 |
|
284 |
extern DW1000Driver moduleLldDw1000;
|
285 |
|
286 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
287 |
|
288 |
/** @} */
|
289 |
|
290 |
/*===========================================================================*/
|
291 |
/**
|
292 |
* @name Unit tests (UT)
|
293 |
* @{
|
294 |
*/
|
295 |
/*===========================================================================*/
|
296 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
297 |
|
298 |
#if defined(AMIROLLD_CFG_DW1000) && (AMIROLLD_CFG_DW1000 == 1) |
299 |
#include <ut_alld_DW1000_v1.h> |
300 |
|
301 |
/**
|
302 |
* @brief DW1000 unit test object.
|
303 |
*/
|
304 |
extern aos_unittest_t moduleUtAlldDw1000;
|
305 |
|
306 |
#endif /* defined(AMIROLLD_CFG_DW1000) && (AMIROLLD_CFG_DW1000 == 1) */ |
307 |
|
308 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
309 |
|
310 |
/** @} */
|
311 |
|
312 |
#endif /* AMIROOS_MODULE_H */ |
313 |
|
314 |
/** @} */
|