amiro-os / modules / LightRing_1-0 / module.h @ db6bd9f8
History | View | Annotate | Download (10.653 KB)
1 | e545e620 | Thomas Schöpping | /*
|
---|---|---|---|
2 | AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
||
3 | 96621a83 | Thomas Schöpping | Copyright (C) 2016..2020 Thomas Schöpping et al.
|
4 | e545e620 | Thomas Schöpping | |
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 | 7da800ab | Thomas Schöpping | /**
|
20 | * @file
|
||
21 | * @brief Structures and constant for the LightRing module.
|
||
22 | *
|
||
23 | * @addtogroup lightring_module
|
||
24 | * @{
|
||
25 | */
|
||
26 | |||
27 | 6ff06bbf | Thomas Schöpping | #ifndef AMIROOS_MODULE_H
|
28 | #define AMIROOS_MODULE_H
|
||
29 | e545e620 | Thomas Schöpping | |
30 | e2d7143f | Thomas Schöpping | #include <amiroos.h> |
31 | |||
32 | e545e620 | Thomas Schöpping | /*===========================================================================*/
|
33 | /**
|
||
34 | * @name Module specific functions
|
||
35 | * @{
|
||
36 | */
|
||
37 | /*===========================================================================*/
|
||
38 | |||
39 | /** @} */
|
||
40 | |||
41 | /*===========================================================================*/
|
||
42 | /**
|
||
43 | * @name ChibiOS/HAL configuration
|
||
44 | * @{
|
||
45 | */
|
||
46 | /*===========================================================================*/
|
||
47 | |||
48 | /**
|
||
49 | * @brief CAN driver to use.
|
||
50 | */
|
||
51 | #define MODULE_HAL_CAN CAND1
|
||
52 | |||
53 | /**
|
||
54 | * @brief Configuration for the CAN driver.
|
||
55 | */
|
||
56 | extern CANConfig moduleHalCanConfig;
|
||
57 | |||
58 | /**
|
||
59 | * @brief I2C driver to access the EEPROM.
|
||
60 | */
|
||
61 | #define MODULE_HAL_I2C_EEPROM I2CD2
|
||
62 | |||
63 | /**
|
||
64 | * @brief Configuration for the EEPROM I2C driver.
|
||
65 | */
|
||
66 | extern I2CConfig moduleHalI2cEepromConfig;
|
||
67 | |||
68 | /**
|
||
69 | * @brief Serial driver of the programmer interface.
|
||
70 | */
|
||
71 | #define MODULE_HAL_PROGIF SD1
|
||
72 | |||
73 | /**
|
||
74 | * @brief Configuration for the programmer serial interface driver.
|
||
75 | */
|
||
76 | extern SerialConfig moduleHalProgIfConfig;
|
||
77 | |||
78 | /**
|
||
79 | * @brief SPI interface driver for the motion sensors (gyroscope and accelerometer).
|
||
80 | */
|
||
81 | #define MODULE_HAL_SPI_LIGHT SPID1
|
||
82 | |||
83 | /**
|
||
84 | 02c29a8f | Thomas Schöpping | * @brief SPI interface driver for the wireless transceiver.
|
85 | e545e620 | Thomas Schöpping | */
|
86 | 02c29a8f | Thomas Schöpping | #define MODULE_HAL_SPI_WL SPID2
|
87 | e545e620 | Thomas Schöpping | |
88 | 8399aeae | Thomas Schöpping | /**
|
89 | e05848a6 | Robin Ewers | * @brief Configuration for the SPI interface driver to communicate with the LED driver.
|
90 | 22be62dc | Thomas Schöpping | */
|
91 | e05848a6 | Robin Ewers | extern SPIConfig moduleHalSpiLightConfig;
|
92 | 22be62dc | Thomas Schöpping | |
93 | /**
|
||
94 | 02c29a8f | Thomas Schöpping | * @brief Configuration for the SPI interface driver to communicate with the wireless transceiver.
|
95 | 22be62dc | Thomas Schöpping | */
|
96 | 02c29a8f | Thomas Schöpping | extern SPIConfig moduleHalSpiWlConfig;
|
97 | 22be62dc | Thomas Schöpping | |
98 | /**
|
||
99 | 8399aeae | Thomas Schöpping | * @brief Real-Time Clock driver.
|
100 | */
|
||
101 | #define MODULE_HAL_RTC RTCD1
|
||
102 | |||
103 | e545e620 | Thomas Schöpping | /** @} */
|
104 | |||
105 | /*===========================================================================*/
|
||
106 | /**
|
||
107 | * @name GPIO definitions
|
||
108 | * @{
|
||
109 | */
|
||
110 | /*===========================================================================*/
|
||
111 | |||
112 | /**
|
||
113 | * @brief LIGHT_BANK output signal GPIO.
|
||
114 | */
|
||
115 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioLightBlank;
|
116 | e545e620 | Thomas Schöpping | |
117 | /**
|
||
118 | * @brief LASER_EN output signal GPIO.
|
||
119 | */
|
||
120 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioLaserEn;
|
121 | e545e620 | Thomas Schöpping | |
122 | /**
|
||
123 | * @brief LASER_OC input signal GPIO.
|
||
124 | */
|
||
125 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioLaserOc;
|
126 | e545e620 | Thomas Schöpping | |
127 | /**
|
||
128 | * @brief SYS_UART_DN bidirectional signal GPIO.
|
||
129 | */
|
||
130 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioSysUartDn;
|
131 | e545e620 | Thomas Schöpping | |
132 | /**
|
||
133 | * @brief WL_GDO2 input signal GPIO.
|
||
134 | */
|
||
135 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioWlGdo2;
|
136 | e545e620 | Thomas Schöpping | |
137 | /**
|
||
138 | * @brief WL_GDO0 input signal GPIO.
|
||
139 | */
|
||
140 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioWlGdo0;
|
141 | e545e620 | Thomas Schöpping | |
142 | /**
|
||
143 | c930aa01 | Thomas Schöpping | * @brief LIGHT_XLAT output signal.
|
144 | */
|
||
145 | extern ROMCONST apalControlGpio_t moduleGpioLightXlat;
|
||
146 | |||
147 | /**
|
||
148 | e545e620 | Thomas Schöpping | * @brief SYS_PD bidirectional signal GPIO.
|
149 | */
|
||
150 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioSysPd;
|
151 | e545e620 | Thomas Schöpping | |
152 | /**
|
||
153 | * @brief SYS_SYNC bidirectional signal GPIO.
|
||
154 | */
|
||
155 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioSysSync;
|
156 | e545e620 | Thomas Schöpping | |
157 | /** @} */
|
||
158 | |||
159 | /*===========================================================================*/
|
||
160 | /**
|
||
161 | * @name AMiRo-OS core configurations
|
||
162 | * @{
|
||
163 | */
|
||
164 | /*===========================================================================*/
|
||
165 | |||
166 | /**
|
||
167 | * @brief Event flag to be set on a LASER_OC interrupt.
|
||
168 | */
|
||
169 | cda14729 | Thomas Schöpping | #define MODULE_OS_GPIOEVENTFLAG_LASEROC AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_LASER_OC_N))
|
170 | e545e620 | Thomas Schöpping | |
171 | /**
|
||
172 | * @brief Event flag to be set on a SYS_UART_DN interrupt.
|
||
173 | */
|
||
174 | cda14729 | Thomas Schöpping | #define MODULE_OS_GPIOEVENTFLAG_SYSUARTDN AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_SYS_UART_DN))
|
175 | e545e620 | Thomas Schöpping | |
176 | /**
|
||
177 | * @brief Event flag to be set on a WL_GDO2 interrupt.
|
||
178 | */
|
||
179 | cda14729 | Thomas Schöpping | #define MODULE_OS_GPIOEVENTFLAG_WLGDO2 AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_WL_GDO2))
|
180 | e545e620 | Thomas Schöpping | |
181 | /**
|
||
182 | * @brief Event flag to be set on a WL_GDO0 interrupt.
|
||
183 | */
|
||
184 | cda14729 | Thomas Schöpping | #define MODULE_OS_GPIOEVENTFLAG_WLGDO0 AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_WL_GDO0))
|
185 | e545e620 | Thomas Schöpping | |
186 | /**
|
||
187 | * @brief Event flag to be set on a SYS_PD interrupt.
|
||
188 | */
|
||
189 | cda14729 | Thomas Schöpping | #define MODULE_OS_GPIOEVENTFLAG_SYSPD AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_SYS_PD_N))
|
190 | e545e620 | Thomas Schöpping | |
191 | /**
|
||
192 | * @brief Event flag to be set on a SYS_SYNC interrupt.
|
||
193 | */
|
||
194 | cda14729 | Thomas Schöpping | #define MODULE_OS_GPIOEVENTFLAG_SYSSYNC AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_SYS_INT_N))
|
195 | e545e620 | Thomas Schöpping | |
196 | cda14729 | Thomas Schöpping | #if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
197 | e545e620 | Thomas Schöpping | /**
|
198 | * @brief Shell prompt text.
|
||
199 | */
|
||
200 | acc97cbf | Thomas Schöpping | extern ROMCONST char* moduleShellPrompt; |
201 | cda14729 | Thomas Schöpping | #endif /* (AMIROOS_CFG_SHELL_ENABLE == true) */ |
202 | e545e620 | Thomas Schöpping | |
203 | /**
|
||
204 | 1e5f7648 | Thomas Schöpping | * @brief Interrupt initialization macro.
|
205 | */
|
||
206 | #define MODULE_INIT_INTERRUPTS() { \
|
||
207 | /* LASER_OC */ \
|
||
208 | cda14729 | Thomas Schöpping | palSetLineCallback(moduleGpioLaserOc.gpio->line, aosSysGetStdGpioCallback(), &moduleGpioLaserOc.gpio->line); \ |
209 | 56dc4779 | Thomas Schöpping | palEnableLineEvent(moduleGpioLaserOc.gpio->line, APAL2CH_EDGE(moduleGpioLaserOc.meta.edge)); \ |
210 | 1e5f7648 | Thomas Schöpping | /* WL_GDO2 */ \
|
211 | cda14729 | Thomas Schöpping | palSetLineCallback(moduleGpioWlGdo2.gpio->line, aosSysGetStdGpioCallback(), &moduleGpioWlGdo2.gpio->line); \ |
212 | 56dc4779 | Thomas Schöpping | palEnableLineEvent(moduleGpioWlGdo2.gpio->line, APAL2CH_EDGE(moduleGpioWlGdo2.meta.edge)); \ |
213 | 1e5f7648 | Thomas Schöpping | /* WL_GDO0 */ \
|
214 | cda14729 | Thomas Schöpping | palSetLineCallback(moduleGpioWlGdo0.gpio->line, aosSysGetStdGpioCallback(), &moduleGpioWlGdo0.gpio->line); \ |
215 | c930aa01 | Thomas Schöpping | /*palEnableLineEvent(moduleGpioWlGdo0.gpio->line, APAL2CH_EDGE(moduleGpioWlGdo0.meta.edge)); // this is broken for some reason*/ \
|
216 | 1e5f7648 | Thomas Schöpping | } |
217 | |||
218 | /**
|
||
219 | 4c72a54c | Thomas Schöpping | * @brief Test initialization hook.
|
220 | e545e620 | Thomas Schöpping | */
|
221 | #define MODULE_INIT_TESTS() { \
|
||
222 | cda14729 | Thomas Schöpping | /* add test commands to shell */ \
|
223 | 4c72a54c | Thomas Schöpping | aosShellAddCommand(&aos.shell, &moduleTestAt24c01bShellCmd); \ |
224 | aosShellAddCommand(&aos.shell, &moduleTestTlc5947ShellCmd); \ |
||
225 | aosShellAddCommand(&aos.shell, &moduleTestTps2051bdbvShellCmd); \ |
||
226 | aosShellAddCommand(&aos.shell, &moduleTestAllShellCmd); \ |
||
227 | e545e620 | Thomas Schöpping | } |
228 | |||
229 | /**
|
||
230 | * @brief Periphery communication interfaces initialization hook.
|
||
231 | */
|
||
232 | 4c72a54c | Thomas Schöpping | #define MODULE_INIT_PERIPHERY_IF() { \
|
233 | e545e620 | Thomas Schöpping | /* serial driver */ \
|
234 | sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig); \ |
||
235 | /* I2C */ \
|
||
236 | ddf34c3d | Thomas Schöpping | moduleHalI2cEepromConfig.clock_speed = (AT24C01B_LLD_I2C_MAXFREQUENCY < moduleHalI2cEepromConfig.clock_speed) ? AT24C01B_LLD_I2C_MAXFREQUENCY : moduleHalI2cEepromConfig.clock_speed; \ |
237 | e545e620 | Thomas Schöpping | moduleHalI2cEepromConfig.duty_cycle = (moduleHalI2cEepromConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2; \
|
238 | i2cStart(&MODULE_HAL_I2C_EEPROM, &moduleHalI2cEepromConfig); \ |
||
239 | /* SPI */ \
|
||
240 | spiStart(&MODULE_HAL_SPI_LIGHT, &moduleHalSpiLightConfig); \ |
||
241 | 02c29a8f | Thomas Schöpping | spiStart(&MODULE_HAL_SPI_WL, &moduleHalSpiWlConfig); \ |
242 | cda14729 | Thomas Schöpping | /* CAN */ \
|
243 | canStart(&MODULE_HAL_CAN, &moduleHalCanConfig); \ |
||
244 | e545e620 | Thomas Schöpping | } |
245 | |||
246 | /**
|
||
247 | * @brief Periphery communication interface deinitialization hook.
|
||
248 | */
|
||
249 | 4c72a54c | Thomas Schöpping | #define MODULE_SHUTDOWN_PERIPHERY_IF() { \
|
250 | cda14729 | Thomas Schöpping | /* CAN */ \
|
251 | canStop(&MODULE_HAL_CAN); \ |
||
252 | e545e620 | Thomas Schöpping | /* SPI */ \
|
253 | spiStop(&MODULE_HAL_SPI_LIGHT); \ |
||
254 | 02c29a8f | Thomas Schöpping | spiStop(&MODULE_HAL_SPI_WL); \ |
255 | e545e620 | Thomas Schöpping | /* I2C */ \
|
256 | i2cStop(&MODULE_HAL_I2C_EEPROM); \ |
||
257 | /* don't stop the serial driver so messages can still be printed */ \
|
||
258 | } |
||
259 | |||
260 | /** @} */
|
||
261 | |||
262 | /*===========================================================================*/
|
||
263 | /**
|
||
264 | 6b53f6bf | Thomas Schöpping | * @name Startup Shutdown Synchronization Protocol (SSSP)
|
265 | * @{
|
||
266 | */
|
||
267 | /*===========================================================================*/
|
||
268 | |||
269 | c53ef0b1 | Thomas Schöpping | #define moduleSsspSignalPD() (&moduleGpioSysPd)
|
270 | #define moduleSsspEventflagPD() MODULE_OS_GPIOEVENTFLAG_SYSPD
|
||
271 | 6b53f6bf | Thomas Schöpping | |
272 | c53ef0b1 | Thomas Schöpping | #define moduleSsspSignalS() (&moduleGpioSysSync)
|
273 | #define moduleSsspEventflagS() MODULE_OS_GPIOEVENTFLAG_SYSSYNC
|
||
274 | 933df08e | Thomas Schöpping | |
275 | c53ef0b1 | Thomas Schöpping | #define moduleSsspSignalDN() (&moduleGpioSysUartDn)
|
276 | #define moduleSsspEventflagDN() MODULE_OS_GPIOEVENTFLAG_SYSUARTDN
|
||
277 | cda14729 | Thomas Schöpping | |
278 | 6b53f6bf | Thomas Schöpping | /** @} */
|
279 | |||
280 | /*===========================================================================*/
|
||
281 | /**
|
||
282 | e545e620 | Thomas Schöpping | * @name Low-level drivers
|
283 | * @{
|
||
284 | */
|
||
285 | /*===========================================================================*/
|
||
286 | ddf34c3d | Thomas Schöpping | #include <alld_AT24C01B.h> |
287 | #include <alld_TLC5947.h> |
||
288 | #include <alld_TPS20xxB.h> |
||
289 | e545e620 | Thomas Schöpping | |
290 | /**
|
||
291 | * @brief EEPROM driver.
|
||
292 | */
|
||
293 | ddf34c3d | Thomas Schöpping | extern AT24C01BDriver moduleLldEeprom;
|
294 | e545e620 | Thomas Schöpping | |
295 | /**
|
||
296 | 4c72a54c | Thomas Schöpping | * @brief 24 channel PWM LED driver.
|
297 | e545e620 | Thomas Schöpping | */
|
298 | extern TLC5947Driver moduleLldLedPwm;
|
||
299 | |||
300 | /**
|
||
301 | * @brief Power switch driver for the laser supply power.
|
||
302 | */
|
||
303 | ddf34c3d | Thomas Schöpping | extern TPS20xxBDriver moduleLldPowerSwitchLaser;
|
304 | e545e620 | Thomas Schöpping | |
305 | /** @} */
|
||
306 | |||
307 | /*===========================================================================*/
|
||
308 | /**
|
||
309 | 4c72a54c | Thomas Schöpping | * @name Tests
|
310 | e545e620 | Thomas Schöpping | * @{
|
311 | */
|
||
312 | /*===========================================================================*/
|
||
313 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
314 | |||
315 | /**
|
||
316 | 4c72a54c | Thomas Schöpping | * @brief AT24C01BN-SH-B (EEPROM) test command.
|
317 | e545e620 | Thomas Schöpping | */
|
318 | 4c72a54c | Thomas Schöpping | extern aos_shellcommand_t moduleTestAt24c01bShellCmd;
|
319 | e545e620 | Thomas Schöpping | |
320 | /**
|
||
321 | 4c72a54c | Thomas Schöpping | * @brief TLC5947 (24 channel PWM LED driver) test command
|
322 | e545e620 | Thomas Schöpping | */
|
323 | 4c72a54c | Thomas Schöpping | extern aos_shellcommand_t moduleTestTlc5947ShellCmd;
|
324 | e545e620 | Thomas Schöpping | |
325 | /**
|
||
326 | 4c72a54c | Thomas Schöpping | * @brief TPS2051BDBV (Current-limited power switch) test command
|
327 | e545e620 | Thomas Schöpping | */
|
328 | 4c72a54c | Thomas Schöpping | extern aos_shellcommand_t moduleTestTps2051bdbvShellCmd;
|
329 | e545e620 | Thomas Schöpping | |
330 | 4c72a54c | Thomas Schöpping | /**
|
331 | * @brief Entire module test command.
|
||
332 | */
|
||
333 | extern aos_shellcommand_t moduleTestAllShellCmd;
|
||
334 | e05848a6 | Robin Ewers | |
335 | 7de0cc90 | Thomas Schöpping | #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
336 | e545e620 | Thomas Schöpping | |
337 | /** @} */
|
||
338 | |||
339 | 6ff06bbf | Thomas Schöpping | #endif /* AMIROOS_MODULE_H */ |
340 | 7da800ab | Thomas Schöpping | |
341 | /** @} */ |