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