amiro-os / modules / LightRing_1-0 / module.h @ 0128be0f
History | View | Annotate | Download (9.56 KB)
1 |
/*
|
---|---|
2 |
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
3 |
Copyright (C) 2016..2018 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 |
#ifndef _AMIROOS_MODULE_H_
|
20 |
#define _AMIROOS_MODULE_H_
|
21 |
|
22 |
/*===========================================================================*/
|
23 |
/**
|
24 |
* @name Module specific functions
|
25 |
* @{
|
26 |
*/
|
27 |
/*===========================================================================*/
|
28 |
|
29 |
/** @} */
|
30 |
|
31 |
/*===========================================================================*/
|
32 |
/**
|
33 |
* @name ChibiOS/HAL configuration
|
34 |
* @{
|
35 |
*/
|
36 |
/*===========================================================================*/
|
37 |
#include <hal.h> |
38 |
#include <aos_interrupts.h> |
39 |
|
40 |
/**
|
41 |
* @brief CAN driver to use.
|
42 |
*/
|
43 |
#define MODULE_HAL_CAN CAND1
|
44 |
|
45 |
/**
|
46 |
* @brief Configuration for the CAN driver.
|
47 |
*/
|
48 |
extern CANConfig moduleHalCanConfig;
|
49 |
|
50 |
/**
|
51 |
* @brief Interrupt driver (PAL).
|
52 |
*/
|
53 |
|
54 |
extern aos_interrupt_driver_t moduleIntDriver;
|
55 |
|
56 |
/**
|
57 |
* @brief Interrupt driver config.
|
58 |
*/
|
59 |
extern aos_interrupt_cfg_t moduleIntConfig[6]; |
60 |
|
61 |
/**
|
62 |
* @brief I2C driver to access the EEPROM.
|
63 |
*/
|
64 |
#define MODULE_HAL_I2C_EEPROM I2CD2
|
65 |
|
66 |
/**
|
67 |
* @brief Configuration for the EEPROM I2C driver.
|
68 |
*/
|
69 |
extern I2CConfig moduleHalI2cEepromConfig;
|
70 |
|
71 |
/**
|
72 |
* @brief Serial driver of the programmer interface.
|
73 |
*/
|
74 |
#define MODULE_HAL_PROGIF SD1
|
75 |
|
76 |
/**
|
77 |
* @brief Configuration for the programmer serial interface driver.
|
78 |
*/
|
79 |
extern SerialConfig moduleHalProgIfConfig;
|
80 |
|
81 |
/**
|
82 |
* @brief SPI interface driver for the motion sensors (gyroscope and accelerometer).
|
83 |
*/
|
84 |
#define MODULE_HAL_SPI_LIGHT SPID1
|
85 |
|
86 |
/**
|
87 |
* @brief Configuration for the SPI interface driver to communicate with the LED driver.
|
88 |
*/
|
89 |
extern SPIConfig moduleHalSpiLightConfig;
|
90 |
|
91 |
/**
|
92 |
* @brief Real-Time Clock driver.
|
93 |
*/
|
94 |
#define MODULE_HAL_RTC RTCD1
|
95 |
|
96 |
/** @} */
|
97 |
|
98 |
/*===========================================================================*/
|
99 |
/**
|
100 |
* @name GPIO definitions
|
101 |
* @{
|
102 |
*/
|
103 |
/*===========================================================================*/
|
104 |
#include <amiro-lld.h> |
105 |
|
106 |
/**
|
107 |
* @brief Interrupt channel for the SYS_SYNC signal.
|
108 |
*/
|
109 |
#define MODULE_GPIO_INT_SYSSYNC ((uint8_t)1) |
110 |
|
111 |
/**
|
112 |
* @brief Interrupt channel for the LASER_OC signal.
|
113 |
*/
|
114 |
#define MODULE_GPIO_INT_LASEROC ((uint8_t)2) |
115 |
|
116 |
/**
|
117 |
* @brief Interrupt channel for the SYS_UART_DN signal.
|
118 |
*/
|
119 |
#define MODULE_GPIO_INT_SYSUARTDN ((uint8_t)3) |
120 |
|
121 |
/**
|
122 |
* @brief Interrupt channel for the WL_GDO2 signal.
|
123 |
*/
|
124 |
#define MODULE_GPIO_INT_WLGDO2 ((uint8_t)4) |
125 |
|
126 |
/**
|
127 |
* @brief Interrupt channel for the WL_GDO0 signal.
|
128 |
*/
|
129 |
#define MODULE_GPIO_INT_WLGDO0 ((uint8_t)5) |
130 |
|
131 |
/**
|
132 |
* @brief Interrupt channel for the SYS_PD signal.
|
133 |
*/
|
134 |
#define MODULE_GPIO_INT_SYSPD ((uint8_t)6) |
135 |
|
136 |
/**
|
137 |
* @brief LIGHT_BANK output signal GPIO.
|
138 |
*/
|
139 |
extern apalGpio_t moduleGpioLightBlank;
|
140 |
|
141 |
/**
|
142 |
* @brief LASER_EN output signal GPIO.
|
143 |
*/
|
144 |
extern apalGpio_t moduleGpioLaserEn;
|
145 |
|
146 |
/**
|
147 |
* @brief LASER_OC input signal GPIO.
|
148 |
*/
|
149 |
extern apalGpio_t moduleGpioLaserOc;
|
150 |
|
151 |
/**
|
152 |
* @brief SYS_UART_DN bidirectional signal GPIO.
|
153 |
*/
|
154 |
extern apalGpio_t moduleGpioSysUartDn;
|
155 |
|
156 |
/**
|
157 |
* @brief WL_GDO2 input signal GPIO.
|
158 |
*/
|
159 |
extern apalGpio_t moduleGpioWlGdo2;
|
160 |
|
161 |
/**
|
162 |
* @brief WL_GDO0 input signal GPIO.
|
163 |
*/
|
164 |
extern apalGpio_t moduleGpioWlGdo0;
|
165 |
|
166 |
/**
|
167 |
* @brief LIGHT_XLAT output signal GPIO.
|
168 |
*/
|
169 |
extern apalGpio_t moduleGpioLightXlat;
|
170 |
|
171 |
/**
|
172 |
* @brief SYS_PD bidirectional signal GPIO.
|
173 |
*/
|
174 |
extern apalGpio_t moduleGpioSysPd;
|
175 |
|
176 |
/**
|
177 |
* @brief SYS_SYNC bidirectional signal GPIO.
|
178 |
*/
|
179 |
extern apalGpio_t moduleGpioSysSync;
|
180 |
|
181 |
/** @} */
|
182 |
|
183 |
/*===========================================================================*/
|
184 |
/**
|
185 |
* @name AMiRo-OS core configurations
|
186 |
* @{
|
187 |
*/
|
188 |
/*===========================================================================*/
|
189 |
|
190 |
/**
|
191 |
* @brief Event flag to be set on a LASER_OC interrupt.
|
192 |
*/
|
193 |
#define MODULE_OS_IOEVENTFLAGS_LASEROC ((eventflags_t)(1 << MODULE_GPIO_INT_LASEROC)) |
194 |
|
195 |
/**
|
196 |
* @brief Event flag to be set on a SYS_UART_DN interrupt.
|
197 |
*/
|
198 |
#define MODULE_OS_IOEVENTFLAGS_SYSUARTDN ((eventflags_t)(1 << MODULE_GPIO_INT_SYSUARTDN)) |
199 |
|
200 |
/**
|
201 |
* @brief Event flag to be set on a WL_GDO2 interrupt.
|
202 |
*/
|
203 |
#define MODULE_OS_IOEVENTFLAGS_WLGDO2 ((eventflags_t)(1 << MODULE_GPIO_INT_WLGDO2)) |
204 |
|
205 |
/**
|
206 |
* @brief Event flag to be set on a WL_GDO0 interrupt.
|
207 |
*/
|
208 |
#define MODULE_OS_IOEVENTFLAGS_WLGDO0 ((eventflags_t)(1 << MODULE_GPIO_INT_WLGDO0)) |
209 |
|
210 |
/**
|
211 |
* @brief Event flag to be set on a SYS_PD interrupt.
|
212 |
*/
|
213 |
#define MODULE_OS_IOEVENTFLAGS_SYSPD ((eventflags_t)(1 << MODULE_GPIO_INT_SYSPD)) |
214 |
|
215 |
/**
|
216 |
* @brief Event flag to be set on a SYS_SYNC interrupt.
|
217 |
*/
|
218 |
#define MODULE_OS_IOEVENTFLAGS_SYSSYNC ((eventflags_t)(1 << MODULE_GPIO_INT_SYSSYNC)) |
219 |
|
220 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
221 |
/**
|
222 |
* @brief Shell prompt text.
|
223 |
*/
|
224 |
extern const char* moduleShellPrompt; |
225 |
#endif
|
226 |
|
227 |
/**
|
228 |
* @brief Unit test initialization hook.
|
229 |
*/
|
230 |
#define MODULE_INIT_TESTS() { \
|
231 |
/* add unit-test shell commands */ \
|
232 |
aosShellAddCommand(&aos.shell, &moduleUtAlldAt24c01bn.shellcmd); \ |
233 |
aosShellAddCommand(&aos.shell, &moduleUtAlldTlc5947.shellcmd); \ |
234 |
aosShellAddCommand(&aos.shell, &moduleUtAlldTps2051bdbv.shellcmd); \ |
235 |
} |
236 |
|
237 |
/**
|
238 |
* @brief Periphery communication interfaces initialization hook.
|
239 |
*/
|
240 |
#define MODULE_INIT_PERIPHERY_COMM() { \
|
241 |
/* serial driver */ \
|
242 |
sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig); \ |
243 |
/* I2C */ \
|
244 |
moduleHalI2cEepromConfig.clock_speed = (AT24C01BN_LLD_I2C_MAXFREQUENCY < moduleHalI2cEepromConfig.clock_speed) ? AT24C01BN_LLD_I2C_MAXFREQUENCY : moduleHalI2cEepromConfig.clock_speed; \ |
245 |
moduleHalI2cEepromConfig.duty_cycle = (moduleHalI2cEepromConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2; \
|
246 |
i2cStart(&MODULE_HAL_I2C_EEPROM, &moduleHalI2cEepromConfig); \ |
247 |
/* SPI */ \
|
248 |
spiStart(&MODULE_HAL_SPI_LIGHT, &moduleHalSpiLightConfig); \ |
249 |
} |
250 |
|
251 |
/**
|
252 |
* @brief Periphery communication interface deinitialization hook.
|
253 |
*/
|
254 |
#define MODULE_SHUTDOWN_PERIPHERY_COMM() { \
|
255 |
/* SPI */ \
|
256 |
spiStop(&MODULE_HAL_SPI_LIGHT); \ |
257 |
/* I2C */ \
|
258 |
i2cStop(&MODULE_HAL_I2C_EEPROM); \ |
259 |
/* don't stop the serial driver so messages can still be printed */ \
|
260 |
} |
261 |
|
262 |
/** @} */
|
263 |
|
264 |
/*===========================================================================*/
|
265 |
/**
|
266 |
* @name Startup Shutdown Synchronization Protocol (SSSP)
|
267 |
* @{
|
268 |
*/
|
269 |
/*===========================================================================*/
|
270 |
|
271 |
/**
|
272 |
* @brief PD signal GPIO.
|
273 |
*/
|
274 |
extern apalControlGpio_t moduleSsspGpioPd;
|
275 |
|
276 |
/**
|
277 |
* @brief SYNC signal GPIO.
|
278 |
*/
|
279 |
extern apalControlGpio_t moduleSsspGpioSync;
|
280 |
|
281 |
/**
|
282 |
* @brief DN signal GPIO.
|
283 |
*/
|
284 |
extern apalControlGpio_t moduleSsspGpioDn;
|
285 |
|
286 |
/**
|
287 |
* @brief Event flags for PD signal events.
|
288 |
*/
|
289 |
#define MODULE_SSSP_EVENTFLAGS_PD MODULE_OS_IOEVENTFLAGS_SYSPD
|
290 |
|
291 |
/**
|
292 |
* @brief Event flags for SYNC signal events.
|
293 |
*/
|
294 |
#define MODULE_SSSP_EVENTFLAGS_SYNC MODULE_OS_IOEVENTFLAGS_SYSSYNC
|
295 |
|
296 |
/**
|
297 |
* @brief Event flags for DN signal events.
|
298 |
*/
|
299 |
#define MODULE_SSSP_EVENTFLAGS_DN MODULE_OS_IOEVENTFLAGS_SYSUARTDN
|
300 |
|
301 |
/** @} */
|
302 |
|
303 |
/*===========================================================================*/
|
304 |
/**
|
305 |
* @name Low-level drivers
|
306 |
* @{
|
307 |
*/
|
308 |
/*===========================================================================*/
|
309 |
#include <alld_at24c01bn-sh-b.h> |
310 |
#include <alld_tlc5947.h> |
311 |
#include <alld_tps2051bdbv.h> |
312 |
|
313 |
/**
|
314 |
* @brief EEPROM driver.
|
315 |
*/
|
316 |
extern AT24C01BNDriver moduleLldEeprom;
|
317 |
|
318 |
/**
|
319 |
* @brief LED PWM driver.
|
320 |
*/
|
321 |
extern TLC5947Driver moduleLldLedPwm;
|
322 |
|
323 |
/**
|
324 |
* @brief Power switch driver for the laser supply power.
|
325 |
*/
|
326 |
extern TPS2051BDriver moduleLldPowerSwitchLaser;
|
327 |
|
328 |
/** @} */
|
329 |
|
330 |
/*===========================================================================*/
|
331 |
/**
|
332 |
* @name Unit tests (UT)
|
333 |
* @{
|
334 |
*/
|
335 |
/*===========================================================================*/
|
336 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
337 |
#include <ut_alld_at24c01bn-sh-b.h> |
338 |
#include <ut_alld_tlc5947.h> |
339 |
#include <ut_alld_tps2051bdbv.h> |
340 |
|
341 |
/**
|
342 |
* @brief EEPROM unit test object.
|
343 |
*/
|
344 |
extern aos_unittest_t moduleUtAlldAt24c01bn;
|
345 |
|
346 |
/**
|
347 |
* @brief LED PWM driver unit test object.
|
348 |
*/
|
349 |
extern aos_unittest_t moduleUtAlldTlc5947;
|
350 |
|
351 |
/**
|
352 |
* @brief Current-limited power switch (Laser output)
|
353 |
*/
|
354 |
extern aos_unittest_t moduleUtAlldTps2051bdbv;
|
355 |
|
356 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
357 |
|
358 |
/** @} */
|
359 |
|
360 |
#endif /* _AMIROOS_MODULE_H_ */ |