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