amiro-os / modules / DiWheelDrive_1-1 / module.h @ ad8a2568
History | View | Annotate | Download (18.762 KB)
1 | e545e620 | Thomas Schöpping | /*
|
---|---|---|---|
2 | AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
||
3 | 84f0ce9e | Thomas Schöpping | Copyright (C) 2016..2019 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 | 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 | 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 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 | |||
168 | /**
|
||
169 | * @brief LED output signal GPIO.
|
||
170 | */
|
||
171 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioLed;
|
172 | e545e620 | Thomas Schöpping | |
173 | /**
|
||
174 | * @brief POWER_EN output signal GPIO.
|
||
175 | */
|
||
176 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioPowerEn;
|
177 | e545e620 | Thomas Schöpping | |
178 | /**
|
||
179 | * @brief COMPASS_DRDY input signal GPIO.
|
||
180 | */
|
||
181 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioCompassDrdy;
|
182 | e545e620 | Thomas Schöpping | |
183 | /**
|
||
184 | * @brief IR_INT input signal GPIO.
|
||
185 | */
|
||
186 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioIrInt;
|
187 | e545e620 | Thomas Schöpping | |
188 | /**
|
||
189 | * @brief GYRO_DRDY input signal GPIO.
|
||
190 | */
|
||
191 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioGyroDrdy;
|
192 | e545e620 | Thomas Schöpping | |
193 | /**
|
||
194 | * @brief SYS_UART_UP bidirectional signal GPIO.
|
||
195 | */
|
||
196 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioSysUartUp;
|
197 | e545e620 | Thomas Schöpping | |
198 | /**
|
||
199 | * @brief ACCEL_INT input signal GPIO.
|
||
200 | */
|
||
201 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioAccelInt;
|
202 | e545e620 | Thomas Schöpping | |
203 | /**
|
||
204 | * @brief SYS_SNYC bidirectional signal GPIO.
|
||
205 | */
|
||
206 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioSysSync;
|
207 | e545e620 | Thomas Schöpping | |
208 | /**
|
||
209 | * @brief PATH_DCSTAT input signal GPIO.
|
||
210 | */
|
||
211 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioPathDcStat;
|
212 | e545e620 | Thomas Schöpping | |
213 | /**
|
||
214 | * @brief PATH_DCEN output signal GPIO.
|
||
215 | */
|
||
216 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioPathDcEn;
|
217 | e545e620 | Thomas Schöpping | |
218 | /**
|
||
219 | * @brief SYS_PD bidirectional signal GPIO.
|
||
220 | */
|
||
221 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioSysPd;
|
222 | e545e620 | Thomas Schöpping | |
223 | /**
|
||
224 | * @brief SYS_REG_EN input signal GPIO.
|
||
225 | */
|
||
226 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioSysRegEn;
|
227 | e545e620 | Thomas Schöpping | |
228 | /**
|
||
229 | * @brief SYS_WARMRST bidirectional signal GPIO.
|
||
230 | */
|
||
231 | acc97cbf | Thomas Schöpping | extern ROMCONST apalControlGpio_t moduleGpioSysWarmrst;
|
232 | e545e620 | Thomas Schöpping | |
233 | /** @} */
|
||
234 | |||
235 | /*===========================================================================*/
|
||
236 | /**
|
||
237 | * @name AMiRo-OS core configurations
|
||
238 | * @{
|
||
239 | */
|
||
240 | /*===========================================================================*/
|
||
241 | |||
242 | /**
|
||
243 | * @brief Event flag to be set on a SYS_SYNC interrupt.
|
||
244 | */
|
||
245 | cda14729 | Thomas Schöpping | #define MODULE_OS_GPIOEVENTFLAG_SYSSYNC AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_SYS_INT_N))
|
246 | e545e620 | Thomas Schöpping | |
247 | /**
|
||
248 | * @brief Event flag to be set on a SYS_WARMRST interrupt.
|
||
249 | */
|
||
250 | cda14729 | Thomas Schöpping | #define MODULE_OS_GPIOEVENTFLAG_SYSWARMRST AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_SYS_WARMRST_N))
|
251 | e545e620 | Thomas Schöpping | |
252 | /**
|
||
253 | * @brief Event flag to be set on a PATH_DCSTAT interrupt.
|
||
254 | */
|
||
255 | cda14729 | Thomas Schöpping | #define MODULE_OS_GPIOEVENTFLAG_PATHDCSTAT AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_PATH_DCEN))
|
256 | e545e620 | Thomas Schöpping | |
257 | /**
|
||
258 | * @brief Event flag to be set on a COMPASS_DRDY interrupt.
|
||
259 | */
|
||
260 | cda14729 | Thomas Schöpping | #define MODULE_OS_GPIOEVENTFLAG_COMPASSDRDY AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_COMPASS_DRDY))
|
261 | e545e620 | Thomas Schöpping | |
262 | /**
|
||
263 | * @brief Event flag to be set on a SYS_PD interrupt.
|
||
264 | */
|
||
265 | cda14729 | Thomas Schöpping | #define MODULE_OS_GPIOEVENTFLAG_SYSPD AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_SYS_PD_N))
|
266 | e545e620 | Thomas Schöpping | |
267 | /**
|
||
268 | * @brief Event flag to be set on a SYS_REG_EN interrupt.
|
||
269 | */
|
||
270 | cda14729 | Thomas Schöpping | #define MODULE_OS_GPIOEVENTFLAG_SYSREGEN AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_SYS_REG_EN))
|
271 | e545e620 | Thomas Schöpping | |
272 | /**
|
||
273 | * @brief Event flag to be set on a IR_INT interrupt.
|
||
274 | */
|
||
275 | cda14729 | Thomas Schöpping | #define MODULE_OS_GPIOEVENTFLAG_IRINT AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_IR_INT))
|
276 | e545e620 | Thomas Schöpping | |
277 | /**
|
||
278 | * @brief Event flag to be set on a GYRO_DRDY interrupt.
|
||
279 | */
|
||
280 | cda14729 | Thomas Schöpping | #define MODULE_OS_GPIOEVENTFLAG_GYRODRDY AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_GYRO_DRDY))
|
281 | e545e620 | Thomas Schöpping | |
282 | /**
|
||
283 | * @brief Event flag to be set on a SYS_UART_UP interrupt.
|
||
284 | */
|
||
285 | cda14729 | Thomas Schöpping | #define MODULE_OS_GPIOEVENTFLAG_SYSUARTUP AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_SYS_UART_UP))
|
286 | e545e620 | Thomas Schöpping | |
287 | /**
|
||
288 | * @brief Event flag to be set on a ACCEL_INT interrupt.
|
||
289 | */
|
||
290 | cda14729 | Thomas Schöpping | #define MODULE_OS_GPIOEVENTFLAG_ACCELINT AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_ACCEL_INT_N))
|
291 | e545e620 | Thomas Schöpping | |
292 | cda14729 | Thomas Schöpping | #if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
293 | e545e620 | Thomas Schöpping | /**
|
294 | * @brief Shell prompt text.
|
||
295 | */
|
||
296 | acc97cbf | Thomas Schöpping | extern ROMCONST char* moduleShellPrompt; |
297 | cda14729 | Thomas Schöpping | #endif /* (AMIROOS_CFG_SHELL_ENABLE == true) */ |
298 | e545e620 | Thomas Schöpping | |
299 | /**
|
||
300 | 1e5f7648 | Thomas Schöpping | * @brief Interrupt initialization macro.
|
301 | */
|
||
302 | #define MODULE_INIT_INTERRUPTS() { \
|
||
303 | /* COMPASS_DRDY */ \
|
||
304 | cda14729 | Thomas Schöpping | palSetLineCallback(moduleGpioCompassDrdy.gpio->line, aosSysGetStdGpioCallback(), &moduleGpioCompassDrdy.gpio->line); \ |
305 | 56dc4779 | Thomas Schöpping | palEnableLineEvent(moduleGpioCompassDrdy.gpio->line, APAL2CH_EDGE(moduleGpioCompassDrdy.meta.edge)); \ |
306 | 1e5f7648 | Thomas Schöpping | /* IR_INT */ \
|
307 | cda14729 | Thomas Schöpping | palSetLineCallback(moduleGpioIrInt.gpio->line, aosSysGetStdGpioCallback(), &moduleGpioIrInt.gpio->line); \ |
308 | 56dc4779 | Thomas Schöpping | palEnableLineEvent(moduleGpioIrInt.gpio->line, APAL2CH_EDGE(moduleGpioIrInt.meta.edge)); \ |
309 | 1e5f7648 | Thomas Schöpping | /* GYRO_DRDY */ \
|
310 | cda14729 | Thomas Schöpping | palSetLineCallback(moduleGpioGyroDrdy.gpio->line, aosSysGetStdGpioCallback(), &moduleGpioGyroDrdy.gpio->line); \ |
311 | 56dc4779 | Thomas Schöpping | palEnableLineEvent(moduleGpioGyroDrdy.gpio->line, APAL2CH_EDGE(moduleGpioGyroDrdy.meta.edge)); \ |
312 | 1e5f7648 | Thomas Schöpping | /* ACCEL_INT */ \
|
313 | cda14729 | Thomas Schöpping | palSetLineCallback(moduleGpioAccelInt.gpio->line, aosSysGetStdGpioCallback(), &moduleGpioAccelInt.gpio->line); \ |
314 | 56dc4779 | Thomas Schöpping | palEnableLineEvent(moduleGpioAccelInt.gpio->line, APAL2CH_EDGE(moduleGpioAccelInt.meta.edge)); \ |
315 | 1e5f7648 | Thomas Schöpping | /* PATH_DCSTAT */ \
|
316 | cda14729 | Thomas Schöpping | palSetLineCallback(moduleGpioPathDcStat.gpio->line, aosSysGetStdGpioCallback(), &moduleGpioPathDcStat.gpio->line); \ |
317 | 56dc4779 | Thomas Schöpping | palEnableLineEvent(moduleGpioPathDcStat.gpio->line, APAL2CH_EDGE(moduleGpioPathDcStat.meta.edge)); \ |
318 | 1e5f7648 | Thomas Schöpping | /* SYS_REG_EN */ \
|
319 | cda14729 | Thomas Schöpping | palSetLineCallback(moduleGpioSysRegEn.gpio->line, aosSysGetStdGpioCallback(), &moduleGpioSysRegEn.gpio->line); \ |
320 | 56dc4779 | Thomas Schöpping | palEnableLineEvent(moduleGpioSysRegEn.gpio->line, APAL2CH_EDGE(moduleGpioSysRegEn.meta.edge)); \ |
321 | 1e5f7648 | Thomas Schöpping | /* SYS_WARMRST */ \
|
322 | cda14729 | Thomas Schöpping | palSetLineCallback(moduleGpioSysWarmrst.gpio->line, aosSysGetStdGpioCallback(), &moduleGpioSysWarmrst.gpio->line); \ |
323 | 56dc4779 | Thomas Schöpping | palEnableLineEvent(moduleGpioSysWarmrst.gpio->line, APAL2CH_EDGE(moduleGpioSysWarmrst.meta.edge)); \ |
324 | 1e5f7648 | Thomas Schöpping | } |
325 | |||
326 | /**
|
||
327 | 4c72a54c | Thomas Schöpping | * @brief Test initialization hook.
|
328 | e545e620 | Thomas Schöpping | */
|
329 | #define MODULE_INIT_TESTS() { \
|
||
330 | cda14729 | Thomas Schöpping | /* add test commands to shell */ \
|
331 | 4c72a54c | Thomas Schöpping | aosShellAddCommand(&aos.shell, &moduleTestA3906ShellCmd); \ |
332 | aosShellAddCommand(&aos.shell, &moduleTestAt24c01bShellCmd); \ |
||
333 | aosShellAddCommand(&aos.shell, &moduleTestHmc5883lShellCmd); \ |
||
334 | aosShellAddCommand(&aos.shell, &moduleTestIna219ShellCmd); \ |
||
335 | aosShellAddCommand(&aos.shell, &moduleTestL3g4200dShellCmd); \ |
||
336 | aosShellAddCommand(&aos.shell, &moduleTestLedShellCmd); \ |
||
337 | aosShellAddCommand(&aos.shell, &moduleTestLis331dlhShellCmd); \ |
||
338 | aosShellAddCommand(&aos.shell, &moduleTestLtc4412ShellCmd); \ |
||
339 | aosShellAddCommand(&aos.shell, &moduleTestPca9544aShellCmd); \ |
||
340 | aosShellAddCommand(&aos.shell, &moduleTestTps62113ShellCmd); \ |
||
341 | aosShellAddCommand(&aos.shell, &moduleTestVcnl4020ShellCmd); \ |
||
342 | aosShellAddCommand(&aos.shell, &moduleTestAllShellCmd); \ |
||
343 | e545e620 | Thomas Schöpping | } |
344 | |||
345 | /**
|
||
346 | * @brief Periphery communication interfaces initialization hook.
|
||
347 | */
|
||
348 | 4c72a54c | Thomas Schöpping | #define MODULE_INIT_PERIPHERY_IF() { \
|
349 | e545e620 | Thomas Schöpping | /* 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 | ddf34c3d | Thomas Schöpping | moduleHalI2cProxEepromPwrmtrConfig.clock_speed = (AT24C01B_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxEepromPwrmtrConfig.clock_speed) ? AT24C01B_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxEepromPwrmtrConfig.clock_speed; \ |
358 | e545e620 | Thomas Schöpping | 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 | cda14729 | Thomas Schöpping | /* CAN */ \
|
370 | canStart(&MODULE_HAL_CAN, &moduleHalCanConfig); \ |
||
371 | e545e620 | Thomas Schöpping | } |
372 | |||
373 | /**
|
||
374 | * @brief Periphery communication interface deinitialization hook.
|
||
375 | */
|
||
376 | 4c72a54c | Thomas Schöpping | #define MODULE_SHUTDOWN_PERIPHERY_IF() { \
|
377 | cda14729 | Thomas Schöpping | /* CAN */ \
|
378 | canStop(&MODULE_HAL_CAN); \ |
||
379 | e545e620 | Thomas Schöpping | /* PWM */ \
|
380 | pwmStop(&MODULE_HAL_PWM_DRIVE); \ |
||
381 | /* QEI */ \
|
||
382 | qeiDisable(&MODULE_HAL_QEI_LEFT_WHEEL); \ |
||
383 | qeiDisable(&MODULE_HAL_QEI_RIGHT_WHEEL); \ |
||
384 | qeiStop(&MODULE_HAL_QEI_LEFT_WHEEL); \ |
||
385 | qeiStop(&MODULE_HAL_QEI_RIGHT_WHEEL); \ |
||
386 | /* I2C */ \
|
||
387 | i2cStop(&MODULE_HAL_I2C_COMPASS); \ |
||
388 | i2cStop(&MODULE_HAL_I2C_PROX_EEPROM_PWRMTR); \ |
||
389 | /* don't stop the serial driver so messages can still be printed */ \
|
||
390 | } |
||
391 | |||
392 | /** @} */
|
||
393 | |||
394 | /*===========================================================================*/
|
||
395 | /**
|
||
396 | 6b53f6bf | Thomas Schöpping | * @name Startup Shutdown Synchronization Protocol (SSSP)
|
397 | * @{
|
||
398 | */
|
||
399 | /*===========================================================================*/
|
||
400 | |||
401 | c53ef0b1 | Thomas Schöpping | #define moduleSsspSignalPD() (&moduleGpioSysPd)
|
402 | #define moduleSsspEventflagPD() MODULE_OS_GPIOEVENTFLAG_SYSPD
|
||
403 | 6b53f6bf | Thomas Schöpping | |
404 | c53ef0b1 | Thomas Schöpping | #define moduleSsspSignalS() (&moduleGpioSysSync)
|
405 | #define moduleSsspEventflagS() MODULE_OS_GPIOEVENTFLAG_SYSSYNC
|
||
406 | 933df08e | Thomas Schöpping | |
407 | c53ef0b1 | Thomas Schöpping | #define moduleSsspSignalUP() (&moduleGpioSysUartUp)
|
408 | #define moduleSsspEventflagUP() MODULE_OS_GPIOEVENTFLAG_SYSUARTUP
|
||
409 | cda14729 | Thomas Schöpping | |
410 | 6b53f6bf | Thomas Schöpping | /** @} */
|
411 | |||
412 | /*===========================================================================*/
|
||
413 | /**
|
||
414 | e545e620 | Thomas Schöpping | * @name Low-level drivers
|
415 | * @{
|
||
416 | */
|
||
417 | /*===========================================================================*/
|
||
418 | ddf34c3d | Thomas Schöpping | #include <alld_A3906.h> |
419 | #include <alld_AT24C01B.h> |
||
420 | #include <alld_HMC5883L.h> |
||
421 | #include <alld_INA219.h> |
||
422 | #include <alld_L3G4200D.h> |
||
423 | #include <alld_LED.h> |
||
424 | #include <alld_LIS331DLH.h> |
||
425 | #include <alld_LTC4412.h> |
||
426 | #include <alld_PCA9544A.h> |
||
427 | #include <alld_TPS6211x.h> |
||
428 | #include <alld_VCNL4020.h> |
||
429 | e545e620 | Thomas Schöpping | |
430 | /**
|
||
431 | * @brief Motor driver.
|
||
432 | */
|
||
433 | extern A3906Driver moduleLldMotors;
|
||
434 | |||
435 | /**
|
||
436 | * @brief EEPROM driver.
|
||
437 | */
|
||
438 | ddf34c3d | Thomas Schöpping | extern AT24C01BDriver moduleLldEeprom;
|
439 | e545e620 | Thomas Schöpping | |
440 | /**
|
||
441 | * @brief Compass driver.
|
||
442 | */
|
||
443 | extern HMC5883LDriver moduleLldCompass;
|
||
444 | |||
445 | /**
|
||
446 | * @brief Power monitor (VDD) driver.
|
||
447 | */
|
||
448 | extern INA219Driver moduleLldPowerMonitorVdd;
|
||
449 | |||
450 | /**
|
||
451 | * @brief Gyroscope driver.
|
||
452 | */
|
||
453 | extern L3G4200DDriver moduleLldGyroscope;
|
||
454 | |||
455 | /**
|
||
456 | * @brief Status LED driver.
|
||
457 | */
|
||
458 | extern LEDDriver moduleLldStatusLed;
|
||
459 | |||
460 | /**
|
||
461 | * @brief Accelerometer driver.
|
||
462 | */
|
||
463 | extern LIS331DLHDriver moduleLldAccelerometer;
|
||
464 | |||
465 | /**
|
||
466 | * @brief Power path controler (charging pins) driver.
|
||
467 | */
|
||
468 | extern LTC4412Driver moduleLldPowerPathController;
|
||
469 | |||
470 | /**
|
||
471 | * @brief I2C multiplexer driver.
|
||
472 | */
|
||
473 | extern PCA9544ADriver moduleLldI2cMultiplexer;
|
||
474 | |||
475 | /**
|
||
476 | * @brief Step down converter (VDRIVE) driver.
|
||
477 | */
|
||
478 | ddf34c3d | Thomas Schöpping | extern TPS6211xDriver moduleLldStepDownConverterVdrive;
|
479 | e545e620 | Thomas Schöpping | |
480 | /**
|
||
481 | * @brief Proximity sensor driver.
|
||
482 | */
|
||
483 | extern VCNL4020Driver moduleLldProximity;
|
||
484 | |||
485 | /** @} */
|
||
486 | |||
487 | /*===========================================================================*/
|
||
488 | /**
|
||
489 | 4c72a54c | Thomas Schöpping | * @name Tests
|
490 | e545e620 | Thomas Schöpping | * @{
|
491 | */
|
||
492 | /*===========================================================================*/
|
||
493 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
494 | |||
495 | /**
|
||
496 | 4c72a54c | Thomas Schöpping | * @brief A3906 (motor driver) test command.
|
497 | e545e620 | Thomas Schöpping | */
|
498 | 4c72a54c | Thomas Schöpping | extern aos_shellcommand_t moduleTestA3906ShellCmd;
|
499 | e545e620 | Thomas Schöpping | |
500 | /**
|
||
501 | 4c72a54c | Thomas Schöpping | * @brief AT24C01BN-SH-B (EEPROM) test command.
|
502 | e545e620 | Thomas Schöpping | */
|
503 | 4c72a54c | Thomas Schöpping | extern aos_shellcommand_t moduleTestAt24c01bShellCmd;
|
504 | e545e620 | Thomas Schöpping | |
505 | /**
|
||
506 | 4c72a54c | Thomas Schöpping | * @brief HMC5883L (compass) test command.
|
507 | e545e620 | Thomas Schöpping | */
|
508 | 4c72a54c | Thomas Schöpping | extern aos_shellcommand_t moduleTestHmc5883lShellCmd;
|
509 | e545e620 | Thomas Schöpping | |
510 | /**
|
||
511 | 4c72a54c | Thomas Schöpping | * @brief INA219 (power monitor) test command.
|
512 | e545e620 | Thomas Schöpping | */
|
513 | 4c72a54c | Thomas Schöpping | extern aos_shellcommand_t moduleTestIna219ShellCmd;
|
514 | e545e620 | Thomas Schöpping | |
515 | /**
|
||
516 | 4c72a54c | Thomas Schöpping | * @brief L3G4200D (gyroscope) test command.
|
517 | e545e620 | Thomas Schöpping | */
|
518 | 4c72a54c | Thomas Schöpping | extern aos_shellcommand_t moduleTestL3g4200dShellCmd;
|
519 | e545e620 | Thomas Schöpping | |
520 | /**
|
||
521 | 4c72a54c | Thomas Schöpping | * @brief Status LED test command.
|
522 | e545e620 | Thomas Schöpping | */
|
523 | 4c72a54c | Thomas Schöpping | extern aos_shellcommand_t moduleTestLedShellCmd;
|
524 | e545e620 | Thomas Schöpping | |
525 | /**
|
||
526 | 4c72a54c | Thomas Schöpping | * @brief LIS331DLH (accelerometer) test command.
|
527 | e545e620 | Thomas Schöpping | */
|
528 | 4c72a54c | Thomas Schöpping | extern aos_shellcommand_t moduleTestLis331dlhShellCmd;
|
529 | e545e620 | Thomas Schöpping | |
530 | /**
|
||
531 | 4c72a54c | Thomas Schöpping | * @brief LTC4412 (power path controller) test command.
|
532 | e545e620 | Thomas Schöpping | */
|
533 | 4c72a54c | Thomas Schöpping | extern aos_shellcommand_t moduleTestLtc4412ShellCmd;
|
534 | e545e620 | Thomas Schöpping | |
535 | /**
|
||
536 | 4c72a54c | Thomas Schöpping | * @brief PCA9544A (I2C multiplexer) test command.
|
537 | e545e620 | Thomas Schöpping | */
|
538 | 4c72a54c | Thomas Schöpping | extern aos_shellcommand_t moduleTestPca9544aShellCmd;
|
539 | e545e620 | Thomas Schöpping | |
540 | /**
|
||
541 | 4c72a54c | Thomas Schöpping | * @brief TPS62113 (step-down converter) test command.
|
542 | e545e620 | Thomas Schöpping | */
|
543 | 4c72a54c | Thomas Schöpping | extern aos_shellcommand_t moduleTestTps62113ShellCmd;
|
544 | e545e620 | Thomas Schöpping | |
545 | /**
|
||
546 | 4c72a54c | Thomas Schöpping | * @brief VCNL4020 (proximity sensor) test command.
|
547 | e545e620 | Thomas Schöpping | */
|
548 | 4c72a54c | Thomas Schöpping | extern aos_shellcommand_t moduleTestVcnl4020ShellCmd;
|
549 | |||
550 | /**
|
||
551 | * @brief Entire module test command.
|
||
552 | */
|
||
553 | extern aos_shellcommand_t moduleTestAllShellCmd;
|
||
554 | e545e620 | Thomas Schöpping | |
555 | 7de0cc90 | Thomas Schöpping | #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
556 | e545e620 | Thomas Schöpping | |
557 | /** @} */
|
||
558 | |||
559 | 6ff06bbf | Thomas Schöpping | #endif /* AMIROOS_MODULE_H */ |
560 | 53710ca3 | Marc Rothmann | |
561 | /** @} */ |