amiro-os / modules / DiWheelDrive_1-1 / module.h @ 1e5f7648
History | View | Annotate | Download (19 KB)
1 | e545e620 | Thomas Schöpping | /*
|
---|---|---|---|
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 <hal_qei.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 I2C driver to access the compass.
|
||
52 | */
|
||
53 | #define MODULE_HAL_I2C_COMPASS I2CD1
|
||
54 | |||
55 | /**
|
||
56 | * @brief Configuration for the compass I2C driver.
|
||
57 | */
|
||
58 | extern I2CConfig moduleHalI2cCompassConfig;
|
||
59 | |||
60 | /**
|
||
61 | * @brief I2C driver to access multiplexer, proximity sensors, EEPROM and power monitor.
|
||
62 | */
|
||
63 | #define MODULE_HAL_I2C_PROX_EEPROM_PWRMTR I2CD2
|
||
64 | |||
65 | /**
|
||
66 | * @brief Configuration for the multiplexer, proximity, EEPROM and power monitor I2C driver.
|
||
67 | */
|
||
68 | extern I2CConfig moduleHalI2cProxEepromPwrmtrConfig;
|
||
69 | |||
70 | /**
|
||
71 | * @brief PWM driver to use.
|
||
72 | */
|
||
73 | #define MODULE_HAL_PWM_DRIVE PWMD2
|
||
74 | |||
75 | /**
|
||
76 | * @brief Configuration for the PWM driver.
|
||
77 | */
|
||
78 | extern PWMConfig moduleHalPwmDriveConfig;
|
||
79 | |||
80 | /**
|
||
81 | * @brief Drive PWM channel for the left wheel forward direction.
|
||
82 | */
|
||
83 | 1e5f7648 | Thomas Schöpping | #define MODULE_HAL_PWM_DRIVE_CHANNEL_LEFT_FORWARD ((apalPWMchannel_t)0) |
84 | e545e620 | Thomas Schöpping | |
85 | /**
|
||
86 | * @brief Drive PWM channel for the left wheel backward direction.
|
||
87 | */
|
||
88 | 1e5f7648 | Thomas Schöpping | #define MODULE_HAL_PWM_DRIVE_CHANNEL_LEFT_BACKWARD ((apalPWMchannel_t)1) |
89 | e545e620 | Thomas Schöpping | |
90 | /**
|
||
91 | * @brief Drive PWM channel for the right wheel forward direction.
|
||
92 | */
|
||
93 | 1e5f7648 | Thomas Schöpping | #define MODULE_HAL_PWM_DRIVE_CHANNEL_RIGHT_FORWARD ((apalPWMchannel_t)2) |
94 | e545e620 | Thomas Schöpping | |
95 | /**
|
||
96 | * @brief Drive PWM channel for the right wheel backward direction.
|
||
97 | */
|
||
98 | 1e5f7648 | Thomas Schöpping | #define MODULE_HAL_PWM_DRIVE_CHANNEL_RIGHT_BACKWARD ((apalPWMchannel_t)3) |
99 | e545e620 | Thomas Schöpping | |
100 | /**
|
||
101 | * @brief Quadrature encooder for the left wheel.
|
||
102 | */
|
||
103 | #define MODULE_HAL_QEI_LEFT_WHEEL QEID3
|
||
104 | |||
105 | /**
|
||
106 | * @brief Quadrature encooder for the right wheel.
|
||
107 | */
|
||
108 | #define MODULE_HAL_QEI_RIGHT_WHEEL QEID4
|
||
109 | |||
110 | /**
|
||
111 | * @brief Configuration for both quadrature encoders.
|
||
112 | */
|
||
113 | extern QEIConfig moduleHalQeiConfig;
|
||
114 | |||
115 | /**
|
||
116 | * @brief QEI increments per wheel revolution.
|
||
117 | * @details 2 signal edges per pulse * 2 signals * 16 pulses per motor revolution * 22:1 gearbox
|
||
118 | */
|
||
119 | #define MODULE_HAL_QEI_INCREMENTS_PER_REVOLUTION (apalQEICount_t)(2 * 2 * 16 * 22) |
||
120 | |||
121 | /**
|
||
122 | * @brief Serial driver of the programmer interface.
|
||
123 | */
|
||
124 | #define MODULE_HAL_PROGIF SD1
|
||
125 | |||
126 | /**
|
||
127 | * @brief Configuration for the programmer serial interface driver.
|
||
128 | */
|
||
129 | extern SerialConfig moduleHalProgIfConfig;
|
||
130 | |||
131 | /**
|
||
132 | * @brief SPI interface driver for the motion sensors (gyroscope and accelerometer).
|
||
133 | */
|
||
134 | #define MODULE_HAL_SPI_MOTION SPID1
|
||
135 | |||
136 | /**
|
||
137 | * @brief Configuration for the motion sensor SPI interface driver to communicate with the accelerometer.
|
||
138 | */
|
||
139 | extern SPIConfig moduleHalSpiAccelerometerConfig;
|
||
140 | |||
141 | /**
|
||
142 | * @brief Configuration for the motion sensor SPI interface driver to communicate with the gyroscope.
|
||
143 | */
|
||
144 | extern SPIConfig moduleHalSpiGyroscopeConfig;
|
||
145 | |||
146 | 8399aeae | Thomas Schöpping | /**
|
147 | * @brief Real-Time Clock driver.
|
||
148 | */
|
||
149 | #define MODULE_HAL_RTC RTCD1
|
||
150 | |||
151 | e545e620 | Thomas Schöpping | /** @} */
|
152 | |||
153 | /*===========================================================================*/
|
||
154 | /**
|
||
155 | * @name GPIO definitions
|
||
156 | * @{
|
||
157 | */
|
||
158 | /*===========================================================================*/
|
||
159 | #include <amiro-lld.h> |
||
160 | |||
161 | /**
|
||
162 | * @brief LED output signal GPIO.
|
||
163 | */
|
||
164 | 1e5f7648 | Thomas Schöpping | extern apalControlGpio_t moduleGpioLed;
|
165 | e545e620 | Thomas Schöpping | |
166 | /**
|
||
167 | * @brief POWER_EN output signal GPIO.
|
||
168 | */
|
||
169 | 1e5f7648 | Thomas Schöpping | extern apalControlGpio_t moduleGpioPowerEn;
|
170 | e545e620 | Thomas Schöpping | |
171 | /**
|
||
172 | * @brief COMPASS_DRDY input signal GPIO.
|
||
173 | */
|
||
174 | 1e5f7648 | Thomas Schöpping | extern apalControlGpio_t moduleGpioCompassDrdy;
|
175 | e545e620 | Thomas Schöpping | |
176 | /**
|
||
177 | * @brief IR_INT input signal GPIO.
|
||
178 | */
|
||
179 | 1e5f7648 | Thomas Schöpping | extern apalControlGpio_t moduleGpioIrInt;
|
180 | e545e620 | Thomas Schöpping | |
181 | /**
|
||
182 | * @brief GYRO_DRDY input signal GPIO.
|
||
183 | */
|
||
184 | 1e5f7648 | Thomas Schöpping | extern apalControlGpio_t moduleGpioGyroDrdy;
|
185 | e545e620 | Thomas Schöpping | |
186 | /**
|
||
187 | * @brief SYS_UART_UP bidirectional signal GPIO.
|
||
188 | */
|
||
189 | 1e5f7648 | Thomas Schöpping | extern apalControlGpio_t moduleGpioSysUartUp;
|
190 | e545e620 | Thomas Schöpping | |
191 | /**
|
||
192 | * @brief ACCEL_INT input signal GPIO.
|
||
193 | */
|
||
194 | 1e5f7648 | Thomas Schöpping | extern apalControlGpio_t moduleGpioAccelInt;
|
195 | e545e620 | Thomas Schöpping | |
196 | /**
|
||
197 | * @brief SYS_SNYC bidirectional signal GPIO.
|
||
198 | */
|
||
199 | 1e5f7648 | Thomas Schöpping | extern apalControlGpio_t moduleGpioSysSync;
|
200 | e545e620 | Thomas Schöpping | |
201 | /**
|
||
202 | * @brief PATH_DCSTAT input signal GPIO.
|
||
203 | */
|
||
204 | 1e5f7648 | Thomas Schöpping | extern apalControlGpio_t moduleGpioPathDcStat;
|
205 | e545e620 | Thomas Schöpping | |
206 | /**
|
||
207 | * @brief PATH_DCEN output signal GPIO.
|
||
208 | */
|
||
209 | 1e5f7648 | Thomas Schöpping | extern apalControlGpio_t moduleGpioPathDcEn;
|
210 | e545e620 | Thomas Schöpping | |
211 | /**
|
||
212 | * @brief SYS_PD bidirectional signal GPIO.
|
||
213 | */
|
||
214 | 1e5f7648 | Thomas Schöpping | extern apalControlGpio_t moduleGpioSysPd;
|
215 | e545e620 | Thomas Schöpping | |
216 | /**
|
||
217 | * @brief SYS_REG_EN input signal GPIO.
|
||
218 | */
|
||
219 | 1e5f7648 | Thomas Schöpping | extern apalControlGpio_t moduleGpioSysRegEn;
|
220 | e545e620 | Thomas Schöpping | |
221 | /**
|
||
222 | * @brief SYS_WARMRST bidirectional signal GPIO.
|
||
223 | */
|
||
224 | 1e5f7648 | Thomas Schöpping | extern apalControlGpio_t moduleGpioSysWarmrst;
|
225 | e545e620 | Thomas Schöpping | |
226 | /** @} */
|
||
227 | |||
228 | /*===========================================================================*/
|
||
229 | /**
|
||
230 | * @name AMiRo-OS core configurations
|
||
231 | * @{
|
||
232 | */
|
||
233 | /*===========================================================================*/
|
||
234 | |||
235 | /**
|
||
236 | * @brief Event flag to be set on a SYS_SYNC interrupt.
|
||
237 | */
|
||
238 | 1e5f7648 | Thomas Schöpping | #define MODULE_OS_IOEVENTFLAGS_SYSSYNC ((eventflags_t)1 << GPIOC_SYS_INT_N) |
239 | e545e620 | Thomas Schöpping | |
240 | /**
|
||
241 | * @brief Event flag to be set on a SYS_WARMRST interrupt.
|
||
242 | */
|
||
243 | 1e5f7648 | Thomas Schöpping | #define MODULE_OS_IOEVENTFLAGS_SYSWARMRST ((eventflags_t)1 << GPIOD_SYS_WARMRST_N) |
244 | e545e620 | Thomas Schöpping | |
245 | /**
|
||
246 | * @brief Event flag to be set on a PATH_DCSTAT interrupt.
|
||
247 | */
|
||
248 | 1e5f7648 | Thomas Schöpping | #define MODULE_OS_IOEVENTFLAGS_PATHDCSTAT ((eventflags_t)1 << GPIOC_PATH_DCEN) |
249 | e545e620 | Thomas Schöpping | |
250 | /**
|
||
251 | * @brief Event flag to be set on a COMPASS_DRDY interrupt.
|
||
252 | */
|
||
253 | 1e5f7648 | Thomas Schöpping | #define MODULE_OS_IOEVENTFLAGS_COMPASSDRDY ((eventflags_t)1 << GPIOB_COMPASS_DRDY) |
254 | e545e620 | Thomas Schöpping | |
255 | /**
|
||
256 | * @brief Event flag to be set on a SYS_PD interrupt.
|
||
257 | */
|
||
258 | 1e5f7648 | Thomas Schöpping | #define MODULE_OS_IOEVENTFLAGS_SYSPD ((eventflags_t)1 << GPIOC_SYS_PD_N) |
259 | e545e620 | Thomas Schöpping | |
260 | /**
|
||
261 | * @brief Event flag to be set on a SYS_REG_EN interrupt.
|
||
262 | */
|
||
263 | 1e5f7648 | Thomas Schöpping | #define MODULE_OS_IOEVENTFLAGS_SYSREGEN ((eventflags_t)1 << GPIOC_SYS_REG_EN) |
264 | e545e620 | Thomas Schöpping | |
265 | /**
|
||
266 | * @brief Event flag to be set on a IR_INT interrupt.
|
||
267 | */
|
||
268 | 1e5f7648 | Thomas Schöpping | #define MODULE_OS_IOEVENTFLAGS_IRINT ((eventflags_t)1 << GPIOB_IR_INT) |
269 | e545e620 | Thomas Schöpping | |
270 | /**
|
||
271 | * @brief Event flag to be set on a GYRO_DRDY interrupt.
|
||
272 | */
|
||
273 | 1e5f7648 | Thomas Schöpping | #define MODULE_OS_IOEVENTFLAGS_GYRODRDY ((eventflags_t)1 << GPIOB_GYRO_DRDY) |
274 | e545e620 | Thomas Schöpping | |
275 | /**
|
||
276 | * @brief Event flag to be set on a SYS_UART_UP interrupt.
|
||
277 | */
|
||
278 | 1e5f7648 | Thomas Schöpping | #define MODULE_OS_IOEVENTFLAGS_SYSUARTUP ((eventflags_t)1 << GPIOB_SYS_UART_UP) |
279 | e545e620 | Thomas Schöpping | |
280 | /**
|
||
281 | * @brief Event flag to be set on a ACCEL_INT interrupt.
|
||
282 | */
|
||
283 | 1e5f7648 | Thomas Schöpping | #define MODULE_OS_IOEVENTFLAGS_ACCELINT ((eventflags_t)1 << GPIOB_ACCEL_INT_N) |
284 | e545e620 | Thomas Schöpping | |
285 | 6b53f6bf | Thomas Schöpping | #if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
286 | e545e620 | Thomas Schöpping | /**
|
287 | * @brief Shell prompt text.
|
||
288 | */
|
||
289 | extern const char* moduleShellPrompt; |
||
290 | 6b53f6bf | Thomas Schöpping | #endif
|
291 | e545e620 | Thomas Schöpping | |
292 | /**
|
||
293 | * @brief Additional HAL initialization hook.
|
||
294 | */
|
||
295 | #define MODULE_INIT_HAL_EXTRA() { \
|
||
296 | qeiInit(); \ |
||
297 | } |
||
298 | |||
299 | /**
|
||
300 | 1e5f7648 | Thomas Schöpping | * @brief Interrupt initialization macro.
|
301 | * @note SSSP related interrupt signals are already initialized in 'aos_system.c'.
|
||
302 | */
|
||
303 | #define MODULE_INIT_INTERRUPTS() { \
|
||
304 | /* COMPASS_DRDY */ \
|
||
305 | palSetPadCallback(moduleGpioCompassDrdy.gpio->port, moduleGpioCompassDrdy.gpio->pad, _intCallback, &moduleGpioCompassDrdy.gpio->pad); \ |
||
306 | palEnablePadEvent(moduleGpioCompassDrdy.gpio->port, moduleGpioCompassDrdy.gpio->pad, APAL2CH_EDGE(moduleGpioCompassDrdy.meta.edge)); \ |
||
307 | /* IR_INT */ \
|
||
308 | palSetPadCallback(moduleGpioIrInt.gpio->port, moduleGpioIrInt.gpio->pad, _intCallback, &moduleGpioIrInt.gpio->pad); \ |
||
309 | palEnablePadEvent(moduleGpioIrInt.gpio->port, moduleGpioIrInt.gpio->pad, APAL2CH_EDGE(moduleGpioIrInt.meta.edge)); \ |
||
310 | /* GYRO_DRDY */ \
|
||
311 | palSetPadCallback(moduleGpioGyroDrdy.gpio->port, moduleGpioGyroDrdy.gpio->pad, _intCallback, &moduleGpioGyroDrdy.gpio->pad); \ |
||
312 | palEnablePadEvent(moduleGpioGyroDrdy.gpio->port, moduleGpioGyroDrdy.gpio->pad, APAL2CH_EDGE(moduleGpioGyroDrdy.meta.edge)); \ |
||
313 | /* ACCEL_INT */ \
|
||
314 | palSetPadCallback(moduleGpioAccelInt.gpio->port, moduleGpioAccelInt.gpio->pad, _intCallback, &moduleGpioAccelInt.gpio->pad); \ |
||
315 | palEnablePadEvent(moduleGpioAccelInt.gpio->port, moduleGpioAccelInt.gpio->pad, APAL2CH_EDGE(moduleGpioAccelInt.meta.edge)); \ |
||
316 | /* PATH_DCSTAT */ \
|
||
317 | palSetPadCallback(moduleGpioPathDcStat.gpio->port, moduleGpioPathDcStat.gpio->pad, _intCallback, &moduleGpioPathDcStat.gpio->pad); \ |
||
318 | palEnablePadEvent(moduleGpioPathDcStat.gpio->port, moduleGpioPathDcStat.gpio->pad, APAL2CH_EDGE(moduleGpioPathDcStat.meta.edge)); \ |
||
319 | /* SYS_REG_EN */ \
|
||
320 | palSetPadCallback(moduleGpioSysRegEn.gpio->port, moduleGpioSysRegEn.gpio->pad, _intCallback, &moduleGpioSysRegEn.gpio->pad); \ |
||
321 | palEnablePadEvent(moduleGpioSysRegEn.gpio->port, moduleGpioSysRegEn.gpio->pad, APAL2CH_EDGE(moduleGpioSysRegEn.meta.edge)); \ |
||
322 | /* SYS_WARMRST */ \
|
||
323 | palSetPadCallback(moduleGpioSysWarmrst.gpio->port, moduleGpioSysWarmrst.gpio->pad, _intCallback, &moduleGpioSysWarmrst.gpio->pad); \ |
||
324 | palEnablePadEvent(moduleGpioSysWarmrst.gpio->port, moduleGpioSysWarmrst.gpio->pad, APAL2CH_EDGE(moduleGpioSysWarmrst.meta.edge)); \ |
||
325 | } |
||
326 | |||
327 | /**
|
||
328 | e545e620 | Thomas Schöpping | * @brief Unit test initialization hook.
|
329 | */
|
||
330 | #define MODULE_INIT_TESTS() { \
|
||
331 | /* add unit-test shell commands */ \
|
||
332 | 6b53f6bf | Thomas Schöpping | aosShellAddCommand(&aos.shell, &moduleUtAlldA3906.shellcmd); \ |
333 | aosShellAddCommand(&aos.shell, &moduleUtAlldAt24c01bn.shellcmd); \ |
||
334 | aosShellAddCommand(&aos.shell, &moduleUtAlldHmc5883l.shellcmd); \ |
||
335 | aosShellAddCommand(&aos.shell, &moduleUtAlldIna219.shellcmd); \ |
||
336 | aosShellAddCommand(&aos.shell, &moduleUtAlldL3g4200d.shellcmd); \ |
||
337 | aosShellAddCommand(&aos.shell, &moduleUtAlldLed.shellcmd); \ |
||
338 | aosShellAddCommand(&aos.shell, &moduleUtAlldLis331dlh.shellcmd); \ |
||
339 | aosShellAddCommand(&aos.shell, &moduleUtAlldLtc4412.shellcmd); \ |
||
340 | aosShellAddCommand(&aos.shell, &moduleUtAlldPca9544a.shellcmd); \ |
||
341 | aosShellAddCommand(&aos.shell, &moduleUtAlldTps62113.shellcmd); \ |
||
342 | aosShellAddCommand(&aos.shell, &moduleUtAlldVcnl4020.shellcmd); \ |
||
343 | e545e620 | Thomas Schöpping | } |
344 | |||
345 | /**
|
||
346 | * @brief Periphery communication interfaces initialization hook.
|
||
347 | */
|
||
348 | #define MODULE_INIT_PERIPHERY_COMM() { \
|
||
349 | /* serial driver */ \
|
||
350 | sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig); \ |
||
351 | /* I2C */ \
|
||
352 | moduleHalI2cCompassConfig.clock_speed = (HMC5883L_LLD_I2C_MAXFREQUENCY < moduleHalI2cCompassConfig.clock_speed) ? HMC5883L_LLD_I2C_MAXFREQUENCY : moduleHalI2cCompassConfig.clock_speed; \ |
||
353 | moduleHalI2cCompassConfig.duty_cycle = (moduleHalI2cCompassConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2; \
|
||
354 | i2cStart(&MODULE_HAL_I2C_COMPASS, &moduleHalI2cCompassConfig); \ |
||
355 | moduleHalI2cProxEepromPwrmtrConfig.clock_speed = (PCA9544A_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxEepromPwrmtrConfig.clock_speed) ? PCA9544A_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxEepromPwrmtrConfig.clock_speed; \ |
||
356 | moduleHalI2cProxEepromPwrmtrConfig.clock_speed = (VCNL4020_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxEepromPwrmtrConfig.clock_speed) ? VCNL4020_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxEepromPwrmtrConfig.clock_speed; \ |
||
357 | moduleHalI2cProxEepromPwrmtrConfig.clock_speed = (AT24C01BN_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxEepromPwrmtrConfig.clock_speed) ? AT24C01BN_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxEepromPwrmtrConfig.clock_speed; \ |
||
358 | moduleHalI2cProxEepromPwrmtrConfig.clock_speed = (INA219_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxEepromPwrmtrConfig.clock_speed) ? INA219_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxEepromPwrmtrConfig.clock_speed; \ |
||
359 | moduleHalI2cProxEepromPwrmtrConfig.duty_cycle = (moduleHalI2cProxEepromPwrmtrConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2; \
|
||
360 | i2cStart(&MODULE_HAL_I2C_PROX_EEPROM_PWRMTR, &moduleHalI2cProxEepromPwrmtrConfig); \ |
||
361 | /* SPI is shared between accelerometer and gyroscope and needs to be restarted for each transmission */ \
|
||
362 | /* PWM */ \
|
||
363 | pwmStart(&MODULE_HAL_PWM_DRIVE, &moduleHalPwmDriveConfig); \ |
||
364 | /* QEI */ \
|
||
365 | qeiStart(&MODULE_HAL_QEI_LEFT_WHEEL, &moduleHalQeiConfig); \ |
||
366 | qeiStart(&MODULE_HAL_QEI_RIGHT_WHEEL, &moduleHalQeiConfig); \ |
||
367 | qeiEnable(&MODULE_HAL_QEI_LEFT_WHEEL); \ |
||
368 | qeiEnable(&MODULE_HAL_QEI_RIGHT_WHEEL); \ |
||
369 | } |
||
370 | |||
371 | /**
|
||
372 | * @brief Periphery communication interface deinitialization hook.
|
||
373 | */
|
||
374 | #define MODULE_SHUTDOWN_PERIPHERY_COMM() { \
|
||
375 | /* PWM */ \
|
||
376 | pwmStop(&MODULE_HAL_PWM_DRIVE); \ |
||
377 | /* QEI */ \
|
||
378 | qeiDisable(&MODULE_HAL_QEI_LEFT_WHEEL); \ |
||
379 | qeiDisable(&MODULE_HAL_QEI_RIGHT_WHEEL); \ |
||
380 | qeiStop(&MODULE_HAL_QEI_LEFT_WHEEL); \ |
||
381 | qeiStop(&MODULE_HAL_QEI_RIGHT_WHEEL); \ |
||
382 | /* I2C */ \
|
||
383 | i2cStop(&MODULE_HAL_I2C_COMPASS); \ |
||
384 | i2cStop(&MODULE_HAL_I2C_PROX_EEPROM_PWRMTR); \ |
||
385 | /* don't stop the serial driver so messages can still be printed */ \
|
||
386 | } |
||
387 | |||
388 | /** @} */
|
||
389 | |||
390 | /*===========================================================================*/
|
||
391 | /**
|
||
392 | 6b53f6bf | Thomas Schöpping | * @name Startup Shutdown Synchronization Protocol (SSSP)
|
393 | * @{
|
||
394 | */
|
||
395 | /*===========================================================================*/
|
||
396 | |||
397 | /**
|
||
398 | * @brief PD signal GPIO.
|
||
399 | */
|
||
400 | 1e5f7648 | Thomas Schöpping | #define moduleSsspGpioPd moduleGpioSysPd
|
401 | 6b53f6bf | Thomas Schöpping | |
402 | /**
|
||
403 | * @brief SYNC signal GPIO.
|
||
404 | */
|
||
405 | 1e5f7648 | Thomas Schöpping | #define moduleSsspGpioSync moduleGpioSysSync
|
406 | 6b53f6bf | Thomas Schöpping | |
407 | /**
|
||
408 | 933df08e | Thomas Schöpping | * @brief UP signal GPIO.
|
409 | */
|
||
410 | 1e5f7648 | Thomas Schöpping | #define moduleSsspGpioUp moduleGpioSysUartUp
|
411 | 933df08e | Thomas Schöpping | |
412 | /**
|
||
413 | 6b53f6bf | Thomas Schöpping | * @brief Event flags for PD signal events.
|
414 | */
|
||
415 | #define MODULE_SSSP_EVENTFLAGS_PD MODULE_OS_IOEVENTFLAGS_SYSPD
|
||
416 | |||
417 | /**
|
||
418 | 933df08e | Thomas Schöpping | * @brief Event flags for SYNC signal events.
|
419 | 6b53f6bf | Thomas Schöpping | */
|
420 | #define MODULE_SSSP_EVENTFLAGS_SYNC MODULE_OS_IOEVENTFLAGS_SYSSYNC
|
||
421 | |||
422 | /**
|
||
423 | 933df08e | Thomas Schöpping | * @brief Event flags for UP signal events.
|
424 | */
|
||
425 | #define MODULE_SSSP_EVENTFLAGS_UP MODULE_OS_IOEVENTFLAGS_SYSUARTUP
|
||
426 | |||
427 | 6b53f6bf | Thomas Schöpping | /** @} */
|
428 | |||
429 | /*===========================================================================*/
|
||
430 | /**
|
||
431 | e545e620 | Thomas Schöpping | * @name Low-level drivers
|
432 | * @{
|
||
433 | */
|
||
434 | /*===========================================================================*/
|
||
435 | #include <alld_a3906.h> |
||
436 | #include <alld_at24c01bn-sh-b.h> |
||
437 | #include <alld_hmc5883l.h> |
||
438 | #include <alld_ina219.h> |
||
439 | #include <alld_l3g4200d.h> |
||
440 | #include <alld_led.h> |
||
441 | #include <alld_lis331dlh.h> |
||
442 | #include <alld_ltc4412.h> |
||
443 | #include <alld_pca9544a.h> |
||
444 | #include <alld_tps62113.h> |
||
445 | #include <alld_vcnl4020.h> |
||
446 | |||
447 | /**
|
||
448 | * @brief Motor driver.
|
||
449 | */
|
||
450 | extern A3906Driver moduleLldMotors;
|
||
451 | |||
452 | /**
|
||
453 | * @brief EEPROM driver.
|
||
454 | */
|
||
455 | extern AT24C01BNDriver moduleLldEeprom;
|
||
456 | |||
457 | /**
|
||
458 | * @brief Compass driver.
|
||
459 | */
|
||
460 | extern HMC5883LDriver moduleLldCompass;
|
||
461 | |||
462 | /**
|
||
463 | * @brief Power monitor (VDD) driver.
|
||
464 | */
|
||
465 | extern INA219Driver moduleLldPowerMonitorVdd;
|
||
466 | |||
467 | /**
|
||
468 | * @brief Gyroscope driver.
|
||
469 | */
|
||
470 | extern L3G4200DDriver moduleLldGyroscope;
|
||
471 | |||
472 | /**
|
||
473 | * @brief Status LED driver.
|
||
474 | */
|
||
475 | extern LEDDriver moduleLldStatusLed;
|
||
476 | |||
477 | /**
|
||
478 | * @brief Accelerometer driver.
|
||
479 | */
|
||
480 | extern LIS331DLHDriver moduleLldAccelerometer;
|
||
481 | |||
482 | /**
|
||
483 | * @brief Power path controler (charging pins) driver.
|
||
484 | */
|
||
485 | extern LTC4412Driver moduleLldPowerPathController;
|
||
486 | |||
487 | /**
|
||
488 | * @brief I2C multiplexer driver.
|
||
489 | */
|
||
490 | extern PCA9544ADriver moduleLldI2cMultiplexer;
|
||
491 | |||
492 | /**
|
||
493 | * @brief Step down converter (VDRIVE) driver.
|
||
494 | */
|
||
495 | extern TPS62113Driver moduleLldStepDownConverterVdrive;
|
||
496 | |||
497 | /**
|
||
498 | * @brief Proximity sensor driver.
|
||
499 | */
|
||
500 | extern VCNL4020Driver moduleLldProximity;
|
||
501 | |||
502 | /** @} */
|
||
503 | |||
504 | /*===========================================================================*/
|
||
505 | /**
|
||
506 | * @name Unit tests (UT)
|
||
507 | * @{
|
||
508 | */
|
||
509 | /*===========================================================================*/
|
||
510 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
511 | #include <ut_alld_a3906.h> |
||
512 | #include <ut_alld_at24c01bn-sh-b.h> |
||
513 | #include <ut_alld_hmc5883l.h> |
||
514 | #include <ut_alld_ina219.h> |
||
515 | #include <ut_alld_l3g4200d.h> |
||
516 | #include <ut_alld_led.h> |
||
517 | #include <ut_alld_lis331dlh.h> |
||
518 | #include <ut_alld_ltc4412.h> |
||
519 | #include <ut_alld_pca9544a.h> |
||
520 | #include <ut_alld_tps62113.h> |
||
521 | #include <ut_alld_vcnl4020.h> |
||
522 | |||
523 | /**
|
||
524 | * @brief A3906 (motor driver) unit test object.
|
||
525 | */
|
||
526 | extern aos_unittest_t moduleUtAlldA3906;
|
||
527 | |||
528 | /**
|
||
529 | * @brief AT24C01BN-SH-B (EEPROM) unit test object.
|
||
530 | */
|
||
531 | extern aos_unittest_t moduleUtAlldAt24c01bn;
|
||
532 | |||
533 | /**
|
||
534 | * @brief HMC5883L (compass) unit test object.
|
||
535 | */
|
||
536 | extern aos_unittest_t moduleUtAlldHmc5883l;
|
||
537 | |||
538 | /**
|
||
539 | * @brief INA219 (power monitor) unit test object.
|
||
540 | */
|
||
541 | extern aos_unittest_t moduleUtAlldIna219;
|
||
542 | |||
543 | /**
|
||
544 | * @brief L3G4200D (gyroscope) unit test object.
|
||
545 | */
|
||
546 | extern aos_unittest_t moduleUtAlldL3g4200d;
|
||
547 | |||
548 | /**
|
||
549 | * @brief Status LED unit test object.
|
||
550 | */
|
||
551 | extern aos_unittest_t moduleUtAlldLed;
|
||
552 | |||
553 | /**
|
||
554 | * @brief LIS331DLH (accelerometer) unit test object.
|
||
555 | */
|
||
556 | extern aos_unittest_t moduleUtAlldLis331dlh;
|
||
557 | |||
558 | /**
|
||
559 | * @brief LTC4412 (power path controller) unit test object.
|
||
560 | */
|
||
561 | extern aos_unittest_t moduleUtAlldLtc4412;
|
||
562 | |||
563 | /**
|
||
564 | * @brief PCA9544A (I2C multiplexer) unit test object.
|
||
565 | */
|
||
566 | extern aos_unittest_t moduleUtAlldPca9544a;
|
||
567 | |||
568 | /**
|
||
569 | * @brief TPS62113 (step-down converter) unit test object.
|
||
570 | */
|
||
571 | extern aos_unittest_t moduleUtAlldTps62113;
|
||
572 | |||
573 | /**
|
||
574 | * @brief VCNL4020 (proximity sensor) unit test object.
|
||
575 | */
|
||
576 | extern aos_unittest_t moduleUtAlldVcnl4020;
|
||
577 | |||
578 | #endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
||
579 | |||
580 | /** @} */
|
||
581 | |||
582 | #endif /* _AMIROOS_MODULE_H_ */ |