amiro-os / modules / NUCLEO-F103RB / module.h @ a2cdc4ae
History | View | Annotate | Download (9.977 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 | 3106e8cc | Thomas Schöpping | #define MODULE_OS_IOEVENTFLAGS_DW1000_IRQn AOS_IOEVENT_FLAG(PAL_PAD(LINE_ARD_D6))
|
153 | deaaa47e | Cung Sang | |
154 | /**
|
||
155 | f4da707a | Thomas Schöpping | * @brief Event flag to be set on a USER_BUTTON interrupt.
|
156 | */
|
||
157 | 3106e8cc | Thomas Schöpping | #define MODULE_OS_IOEVENTFLAGS_USERBUTTON AOS_IOEVENT_FLAG(PAL_PAD(LINE_BUTTON))
|
158 | f4da707a | Thomas Schöpping | |
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 | /**
|
||
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 | 3106e8cc | Thomas Schöpping | palSetLineCallback(moduleGpioUserButton.gpio->line, aosSysGetStdIntCallback(), &moduleGpioUserButton.gpio->line); \ |
174 | palEnableLineEvent(moduleGpioUserButton.gpio->line, APAL2CH_EDGE(moduleGpioUserButton.meta.edge)); \ |
||
175 | deaaa47e | Cung Sang | MODULE_INIT_INTERRUPTS_DW1000(); \ |
176 | f4da707a | Thomas Schöpping | } |
177 | 7de0cc90 | Thomas Schöpping | #if defined(AMIROLLD_CFG_DW1000)
|
178 | deaaa47e | Cung Sang | #define MODULE_INIT_INTERRUPTS_DW1000() { \
|
179 | 3106e8cc | Thomas Schöpping | palSetLineCallback(moduleGpioDw1000Irqn.gpio->line, aosSysGetStdIntCallback(), &moduleGpioDw1000Irqn.gpio->line); \ |
180 | palEnableLineEvent(moduleGpioDw1000Irqn.gpio->line, APAL2CH_EDGE(moduleGpioDw1000Irqn.meta.edge)); \ |
||
181 | deaaa47e | Cung Sang | } |
182 | 7de0cc90 | Thomas Schöpping | #else /* defined(AMIROLLD_CFG_DW1000) */ |
183 | #define MODULE_INIT_INTERRUPTS_DW1000() { \
|
||
184 | deaaa47e | Cung Sang | } |
185 | 7de0cc90 | Thomas Schöpping | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
186 | deaaa47e | Cung Sang | |
187 | f4da707a | Thomas Schöpping | |
188 | /**
|
||
189 | * @brief Unit test initialization hook.
|
||
190 | */
|
||
191 | #define MODULE_INIT_TESTS() { \
|
||
192 | /* add unit-test shell commands */ \
|
||
193 | deaaa47e | Cung Sang | MODULE_INIT_TESTS_DW1000(); \ |
194 | f4da707a | Thomas Schöpping | } |
195 | 7de0cc90 | Thomas Schöpping | #if defined(AMIROLLD_CFG_DW1000)
|
196 | deaaa47e | Cung Sang | #define MODULE_INIT_TESTS_DW1000() { \
|
197 | aosShellAddCommand(&aos.shell, &moduleUtAlldDw1000.shellcmd); \ |
||
198 | } |
||
199 | 7de0cc90 | Thomas Schöpping | #else /* defined(AMIROLLD_CFG_DW1000) */ |
200 | #define MODULE_INIT_TESTS_DW1000() { \
|
||
201 | deaaa47e | Cung Sang | } |
202 | 7de0cc90 | Thomas Schöpping | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
203 | deaaa47e | Cung Sang | |
204 | f4da707a | Thomas Schöpping | |
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 | deaaa47e | Cung Sang | MODULE_INIT_PERIPHERY_COMM_DW1000(); \ |
212 | f4da707a | Thomas Schöpping | } |
213 | 7de0cc90 | Thomas Schöpping | #if defined(AMIROLLD_CFG_DW1000)
|
214 | deaaa47e | Cung Sang | #define MODULE_INIT_PERIPHERY_COMM_DW1000() { \
|
215 | /* SPI init */ \
|
||
216 | dw1000_spi_init(); \ |
||
217 | spiStart(&MODULE_HAL_SPI_UWB, &moduleHalSpiUwbLsConfig); \ |
||
218 | } |
||
219 | 7de0cc90 | Thomas Schöpping | #else /* defined(AMIROLLD_CFG_DW1000) */ |
220 | deaaa47e | Cung Sang | #define MODULE_INIT_PERIPHERY_COMM_DW1000() { \
|
221 | } |
||
222 | 7de0cc90 | Thomas Schöpping | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
223 | deaaa47e | Cung Sang | |
224 | f4da707a | Thomas Schöpping | |
225 | /**
|
||
226 | * @brief Periphery communication interface deinitialization hook.
|
||
227 | */
|
||
228 | #define MODULE_SHUTDOWN_PERIPHERY_COMM() { \
|
||
229 | deaaa47e | Cung Sang | MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000(); \ |
230 | } |
||
231 | 7de0cc90 | Thomas Schöpping | #if defined(AMIROLLD_CFG_DW1000)
|
232 | deaaa47e | Cung Sang | #define MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000() { \
|
233 | /* SPI */ \
|
||
234 | spiStop(&MODULE_HAL_SPI_UWB); \ |
||
235 | f4da707a | Thomas Schöpping | } |
236 | 7de0cc90 | Thomas Schöpping | #else /* defined(AMIROLLD_CFG_DW1000) */ |
237 | deaaa47e | Cung Sang | #define MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000() { \
|
238 | } |
||
239 | 7de0cc90 | Thomas Schöpping | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
240 | f4da707a | Thomas Schöpping | |
241 | /**
|
||
242 | deaaa47e | Cung Sang | * @brief HOOK to call process_deca_irq() func when the dw1000 interrupt pin is activated.
|
243 | f4da707a | Thomas Schöpping | */
|
244 | 732a4657 | Thomas Schöpping | #define MODULE_MAIN_LOOP_IO_EVENT(eventflags) { \
|
245 | f4da707a | Thomas Schöpping | if (eventflags & MODULE_OS_IOEVENTFLAGS_USERBUTTON) { \
|
246 | apalControlGpioState_t buttonstate; \ |
||
247 | apalControlGpioGet(&moduleGpioUserButton, &buttonstate); \ |
||
248 | apalControlGpioSet(&moduleGpioLed, buttonstate); \ |
||
249 | } \ |
||
250 | deaaa47e | Cung Sang | MODULE_MAIN_LOOP_IO_EVENT_DW1000(); \ |
251 | f4da707a | Thomas Schöpping | } |
252 | 7de0cc90 | Thomas Schöpping | #if defined(AMIROLLD_CFG_DW1000)
|
253 | deaaa47e | Cung Sang | #define MODULE_MAIN_LOOP_IO_EVENT_DW1000() { \
|
254 | 7de0cc90 | Thomas Schöpping | if(eventflags & MODULE_OS_IOEVENTFLAGS_DW1000_IRQn) { \
|
255 | deaaa47e | Cung Sang | /*apalGpioToggle(moduleGpioLedGreen.gpio); // just for debug */ \
|
256 | process_deca_irq(); \ |
||
257 | 7de0cc90 | Thomas Schöpping | } \ |
258 | deaaa47e | Cung Sang | } |
259 | 7de0cc90 | Thomas Schöpping | #else /* defined(AMIROLLD_CFG_DW1000) */ |
260 | deaaa47e | Cung Sang | #define MODULE_MAIN_LOOP_IO_EVENT_DW1000() { \
|
261 | } |
||
262 | 7de0cc90 | Thomas Schöpping | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
263 | f4da707a | Thomas Schöpping | |
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 | 7de0cc90 | Thomas Schöpping | #if defined(AMIROLLD_CFG_DW1000)
|
282 | deaaa47e | Cung Sang | #include <alld_DW1000.h> |
283 | |||
284 | extern DW1000Driver moduleLldDw1000;
|
||
285 | |||
286 | 7de0cc90 | Thomas Schöpping | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
287 | f4da707a | Thomas Schöpping | |
288 | /** @} */
|
||
289 | |||
290 | /*===========================================================================*/
|
||
291 | /**
|
||
292 | * @name Unit tests (UT)
|
||
293 | * @{
|
||
294 | */
|
||
295 | /*===========================================================================*/
|
||
296 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
297 | |||
298 | deaaa47e | Cung Sang | #if defined(AMIROLLD_CFG_DW1000) && (AMIROLLD_CFG_DW1000 == 1) |
299 | ad02f035 | Thomas Schöpping | #include <ut_alld_DW1000_v1.h> |
300 | deaaa47e | Cung Sang | |
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 | 7de0cc90 | Thomas Schöpping | #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
309 | f4da707a | Thomas Schöpping | |
310 | /** @} */
|
||
311 | |||
312 | 6ff06bbf | Thomas Schöpping | #endif /* AMIROOS_MODULE_H */ |
313 | f4da707a | Thomas Schöpping | |
314 | /** @} */ |