amiro-os / modules / NUCLEO-F103RB / module.h @ 651cb6e6
History | View | Annotate | Download (10.032 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(AMIROLLD_CFG_DW1000)
|
40 | deaaa47e | Cung Sang | |
41 | 7de0cc90 | Thomas Schöpping | #if defined(__cplusplus)
|
42 | deaaa47e | Cung Sang | extern "C" { |
43 | 7de0cc90 | Thomas Schöpping | #endif /* defined(__cplusplus) */ |
44 | deaaa47e | Cung Sang | |
45 | void dw1000_spi_init(void); |
||
46 | |||
47 | 7de0cc90 | Thomas Schöpping | #if defined(__cplusplus)
|
48 | deaaa47e | Cung Sang | } |
49 | 7de0cc90 | Thomas Schöpping | #endif /* defined(__cplusplus) */ |
50 | deaaa47e | Cung Sang | |
51 | 7de0cc90 | Thomas Schöpping | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
52 | deaaa47e | Cung Sang | |
53 | |||
54 | f4da707a | Thomas Schöpping | /** @} */
|
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 | deaaa47e | Cung Sang | |
79 | 7de0cc90 | Thomas Schöpping | #if defined(AMIROLLD_CFG_DW1000)
|
80 | deaaa47e | Cung Sang | |
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 | 7de0cc90 | Thomas Schöpping | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
98 | deaaa47e | Cung Sang | |
99 | f4da707a | Thomas Schöpping | /** @} */
|
100 | |||
101 | deaaa47e | Cung Sang | |
102 | f4da707a | Thomas Schöpping | /*===========================================================================*/
|
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 | 7de0cc90 | Thomas Schöpping | #if defined(AMIROLLD_CFG_DW1000)
|
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 | |||
133 | 7de0cc90 | Thomas Schöpping | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
134 | deaaa47e | Cung Sang | |
135 | f4da707a | Thomas Schöpping | /**
|
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 | deaaa47e | Cung Sang | * @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 | f4da707a | Thomas Schöpping | * @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 | deaaa47e | Cung Sang | |
160 | f4da707a | Thomas Schöpping | #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 | deaaa47e | Cung Sang | |
168 | f4da707a | Thomas Schöpping | /**
|
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 | deaaa47e | Cung Sang | MODULE_INIT_INTERRUPTS_DW1000(); \ |
177 | f4da707a | Thomas Schöpping | } |
178 | 7de0cc90 | Thomas Schöpping | #if defined(AMIROLLD_CFG_DW1000)
|
179 | deaaa47e | Cung Sang | #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 | 7de0cc90 | Thomas Schöpping | #else /* defined(AMIROLLD_CFG_DW1000) */ |
184 | #define MODULE_INIT_INTERRUPTS_DW1000() { \
|
||
185 | deaaa47e | Cung Sang | } |
186 | 7de0cc90 | Thomas Schöpping | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
187 | deaaa47e | Cung Sang | |
188 | f4da707a | Thomas Schöpping | |
189 | /**
|
||
190 | * @brief Unit test initialization hook.
|
||
191 | */
|
||
192 | #define MODULE_INIT_TESTS() { \
|
||
193 | /* add unit-test shell commands */ \
|
||
194 | deaaa47e | Cung Sang | MODULE_INIT_TESTS_DW1000(); \ |
195 | f4da707a | Thomas Schöpping | } |
196 | 7de0cc90 | Thomas Schöpping | #if defined(AMIROLLD_CFG_DW1000)
|
197 | deaaa47e | Cung Sang | #define MODULE_INIT_TESTS_DW1000() { \
|
198 | aosShellAddCommand(&aos.shell, &moduleUtAlldDw1000.shellcmd); \ |
||
199 | } |
||
200 | 7de0cc90 | Thomas Schöpping | #else /* defined(AMIROLLD_CFG_DW1000) */ |
201 | #define MODULE_INIT_TESTS_DW1000() { \
|
||
202 | deaaa47e | Cung Sang | } |
203 | 7de0cc90 | Thomas Schöpping | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
204 | deaaa47e | Cung Sang | |
205 | f4da707a | Thomas Schöpping | |
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 | deaaa47e | Cung Sang | MODULE_INIT_PERIPHERY_COMM_DW1000(); \ |
213 | f4da707a | Thomas Schöpping | } |
214 | 7de0cc90 | Thomas Schöpping | #if defined(AMIROLLD_CFG_DW1000)
|
215 | deaaa47e | Cung Sang | #define MODULE_INIT_PERIPHERY_COMM_DW1000() { \
|
216 | /* SPI init */ \
|
||
217 | dw1000_spi_init(); \ |
||
218 | spiStart(&MODULE_HAL_SPI_UWB, &moduleHalSpiUwbLsConfig); \ |
||
219 | } |
||
220 | 7de0cc90 | Thomas Schöpping | #else /* defined(AMIROLLD_CFG_DW1000) */ |
221 | deaaa47e | Cung Sang | #define MODULE_INIT_PERIPHERY_COMM_DW1000() { \
|
222 | } |
||
223 | 7de0cc90 | Thomas Schöpping | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
224 | deaaa47e | Cung Sang | |
225 | f4da707a | Thomas Schöpping | |
226 | /**
|
||
227 | * @brief Periphery communication interface deinitialization hook.
|
||
228 | */
|
||
229 | #define MODULE_SHUTDOWN_PERIPHERY_COMM() { \
|
||
230 | deaaa47e | Cung Sang | MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000(); \ |
231 | } |
||
232 | 7de0cc90 | Thomas Schöpping | #if defined(AMIROLLD_CFG_DW1000)
|
233 | deaaa47e | Cung Sang | #define MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000() { \
|
234 | /* SPI */ \
|
||
235 | spiStop(&MODULE_HAL_SPI_UWB); \ |
||
236 | f4da707a | Thomas Schöpping | } |
237 | 7de0cc90 | Thomas Schöpping | #else /* defined(AMIROLLD_CFG_DW1000) */ |
238 | deaaa47e | Cung Sang | #define MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000() { \
|
239 | } |
||
240 | 7de0cc90 | Thomas Schöpping | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
241 | f4da707a | Thomas Schöpping | |
242 | /**
|
||
243 | deaaa47e | Cung Sang | * @brief HOOK to call process_deca_irq() func when the dw1000 interrupt pin is activated.
|
244 | f4da707a | Thomas Schöpping | */
|
245 | 732a4657 | Thomas Schöpping | #define MODULE_MAIN_LOOP_IO_EVENT(eventflags) { \
|
246 | f4da707a | Thomas Schöpping | if (eventflags & MODULE_OS_IOEVENTFLAGS_USERBUTTON) { \
|
247 | apalControlGpioState_t buttonstate; \ |
||
248 | apalControlGpioGet(&moduleGpioUserButton, &buttonstate); \ |
||
249 | apalControlGpioSet(&moduleGpioLed, buttonstate); \ |
||
250 | } \ |
||
251 | deaaa47e | Cung Sang | MODULE_MAIN_LOOP_IO_EVENT_DW1000(); \ |
252 | f4da707a | Thomas Schöpping | } |
253 | 7de0cc90 | Thomas Schöpping | #if defined(AMIROLLD_CFG_DW1000)
|
254 | deaaa47e | Cung Sang | #define MODULE_MAIN_LOOP_IO_EVENT_DW1000() { \
|
255 | 7de0cc90 | Thomas Schöpping | if(eventflags & MODULE_OS_IOEVENTFLAGS_DW1000_IRQn) { \
|
256 | deaaa47e | Cung Sang | /*apalGpioToggle(moduleGpioLedGreen.gpio); // just for debug */ \
|
257 | process_deca_irq(); \ |
||
258 | 7de0cc90 | Thomas Schöpping | } \ |
259 | deaaa47e | Cung Sang | } |
260 | 7de0cc90 | Thomas Schöpping | #else /* defined(AMIROLLD_CFG_DW1000) */ |
261 | deaaa47e | Cung Sang | #define MODULE_MAIN_LOOP_IO_EVENT_DW1000() { \
|
262 | } |
||
263 | 7de0cc90 | Thomas Schöpping | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
264 | f4da707a | Thomas Schöpping | |
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 | 7de0cc90 | Thomas Schöpping | #if defined(AMIROLLD_CFG_DW1000)
|
283 | deaaa47e | Cung Sang | #include <alld_DW1000.h> |
284 | |||
285 | extern DW1000Driver moduleLldDw1000;
|
||
286 | |||
287 | 7de0cc90 | Thomas Schöpping | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
288 | f4da707a | Thomas Schöpping | |
289 | /** @} */
|
||
290 | |||
291 | /*===========================================================================*/
|
||
292 | /**
|
||
293 | * @name Unit tests (UT)
|
||
294 | * @{
|
||
295 | */
|
||
296 | /*===========================================================================*/
|
||
297 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
298 | |||
299 | deaaa47e | Cung Sang | #if defined(AMIROLLD_CFG_DW1000) && (AMIROLLD_CFG_DW1000 == 1) |
300 | 7de0cc90 | Thomas Schöpping | #include <ut_alld_dw1000_v1.h> |
301 | deaaa47e | Cung Sang | |
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 | 7de0cc90 | Thomas Schöpping | #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
310 | f4da707a | Thomas Schöpping | |
311 | /** @} */
|
||
312 | |||
313 | 6ff06bbf | Thomas Schöpping | #endif /* AMIROOS_MODULE_H */ |
314 | f4da707a | Thomas Schöpping | |
315 | /** @} */ |