Revision 1e5f7648 modules/DiWheelDrive_1-1/module.h
| modules/DiWheelDrive_1-1/module.h | ||
|---|---|---|
| 36 | 36 |
/*===========================================================================*/ |
| 37 | 37 |
#include <hal.h> |
| 38 | 38 |
#include <hal_qei.h> |
| 39 |
#include <aos_interrupts.h> |
|
| 40 | 39 |
|
| 41 | 40 |
/** |
| 42 | 41 |
* @brief CAN driver to use. |
| ... | ... | |
| 49 | 48 |
extern CANConfig moduleHalCanConfig; |
| 50 | 49 |
|
| 51 | 50 |
/** |
| 52 |
* @brief Interrupt driver (PAL). |
|
| 53 |
*/ |
|
| 54 |
|
|
| 55 |
extern aos_interrupt_driver_t moduleIntDriver; |
|
| 56 |
|
|
| 57 |
/** |
|
| 58 |
* @brief Interrupt driver config. |
|
| 59 |
*/ |
|
| 60 |
extern aos_interrupt_cfg_t moduleIntConfig[10]; |
|
| 61 |
|
|
| 62 |
/** |
|
| 63 | 51 |
* @brief I2C driver to access the compass. |
| 64 | 52 |
*/ |
| 65 | 53 |
#define MODULE_HAL_I2C_COMPASS I2CD1 |
| ... | ... | |
| 92 | 80 |
/** |
| 93 | 81 |
* @brief Drive PWM channel for the left wheel forward direction. |
| 94 | 82 |
*/ |
| 95 |
#define MODULE_HAL_PWM_DRIVE_CHANNEL_LEFT_FORWARD 0
|
|
| 83 |
#define MODULE_HAL_PWM_DRIVE_CHANNEL_LEFT_FORWARD ((apalPWMchannel_t)0)
|
|
| 96 | 84 |
|
| 97 | 85 |
/** |
| 98 | 86 |
* @brief Drive PWM channel for the left wheel backward direction. |
| 99 | 87 |
*/ |
| 100 |
#define MODULE_HAL_PWM_DRIVE_CHANNEL_LEFT_BACKWARD 1
|
|
| 88 |
#define MODULE_HAL_PWM_DRIVE_CHANNEL_LEFT_BACKWARD ((apalPWMchannel_t)1)
|
|
| 101 | 89 |
|
| 102 | 90 |
/** |
| 103 | 91 |
* @brief Drive PWM channel for the right wheel forward direction. |
| 104 | 92 |
*/ |
| 105 |
#define MODULE_HAL_PWM_DRIVE_CHANNEL_RIGHT_FORWARD 2
|
|
| 93 |
#define MODULE_HAL_PWM_DRIVE_CHANNEL_RIGHT_FORWARD ((apalPWMchannel_t)2)
|
|
| 106 | 94 |
|
| 107 | 95 |
/** |
| 108 | 96 |
* @brief Drive PWM channel for the right wheel backward direction. |
| 109 | 97 |
*/ |
| 110 |
#define MODULE_HAL_PWM_DRIVE_CHANNEL_RIGHT_BACKWARD 3
|
|
| 98 |
#define MODULE_HAL_PWM_DRIVE_CHANNEL_RIGHT_BACKWARD ((apalPWMchannel_t)3)
|
|
| 111 | 99 |
|
| 112 | 100 |
/** |
| 113 | 101 |
* @brief Quadrature encooder for the left wheel. |
| ... | ... | |
| 171 | 159 |
#include <amiro-lld.h> |
| 172 | 160 |
|
| 173 | 161 |
/** |
| 174 |
* @brief Interrupt channel for the SYS_SYNC signal. |
|
| 175 |
*/ |
|
| 176 |
#define MODULE_GPIO_INT_SYSSYNC ((uint8_t)1) |
|
| 177 |
|
|
| 178 |
/** |
|
| 179 |
* @brief Interrupt channel for the SYS_WARMRST signal. |
|
| 180 |
*/ |
|
| 181 |
#define MODULE_GPIO_INT_SYSWARMRST ((uint8_t)2) |
|
| 182 |
|
|
| 183 |
/** |
|
| 184 |
* @brief Interrupt channel for the PATH_DCSTAT signal. |
|
| 185 |
*/ |
|
| 186 |
#define MODULE_GPIO_INT_PATHDCSTAT ((uint8_t)3) |
|
| 187 |
|
|
| 188 |
/** |
|
| 189 |
* @brief Interrupt channel for the COMPASS_DRDY signal. |
|
| 190 |
*/ |
|
| 191 |
#define MODULE_GPIO_INT_COMPASSDRDY ((uint8_t)4) |
|
| 192 |
|
|
| 193 |
/** |
|
| 194 |
* @brief Interrupt channel for the SYS_PD signal. |
|
| 195 |
*/ |
|
| 196 |
#define MODULE_GPIO_INT_SYSPD ((uint8_t)5) |
|
| 197 |
|
|
| 198 |
/** |
|
| 199 |
* @brief Interrupt channel for the SYS_REG_EN signal. |
|
| 200 |
*/ |
|
| 201 |
#define MODULE_GPIO_INT_SYSREGEN ((uint8_t)6) |
|
| 202 |
|
|
| 203 |
/** |
|
| 204 |
* @brief Interrupt channel for the IR_INT signal. |
|
| 205 |
*/ |
|
| 206 |
#define MODULE_GPIO_INT_IRINT ((uint8_t)7) |
|
| 207 |
|
|
| 208 |
/** |
|
| 209 |
* @brief Interrupt channel for the GYRO_DRDY signal. |
|
| 210 |
*/ |
|
| 211 |
#define MODULE_GPIO_INT_GYRODRDY ((uint8_t)8) |
|
| 212 |
|
|
| 213 |
/** |
|
| 214 |
* @brief Interrupt channel for the SYS_UART_UP signal. |
|
| 215 |
*/ |
|
| 216 |
#define MODULE_GPIO_INT_SYSUARTUP ((uint8_t)9) |
|
| 217 |
|
|
| 218 |
/** |
|
| 219 |
* @brief Interrupt channel for the ACCEL_INT signal. |
|
| 220 |
*/ |
|
| 221 |
#define MODULE_GPIO_INT_ACCELINT ((uint8_t)10) |
|
| 222 |
|
|
| 223 |
/** |
|
| 224 | 162 |
* @brief LED output signal GPIO. |
| 225 | 163 |
*/ |
| 226 |
extern apalGpio_t moduleGpioLed; |
|
| 164 |
extern apalControlGpio_t moduleGpioLed;
|
|
| 227 | 165 |
|
| 228 | 166 |
/** |
| 229 | 167 |
* @brief POWER_EN output signal GPIO. |
| 230 | 168 |
*/ |
| 231 |
extern apalGpio_t moduleGpioPowerEn; |
|
| 169 |
extern apalControlGpio_t moduleGpioPowerEn;
|
|
| 232 | 170 |
|
| 233 | 171 |
/** |
| 234 | 172 |
* @brief COMPASS_DRDY input signal GPIO. |
| 235 | 173 |
*/ |
| 236 |
extern apalGpio_t moduleGpioCompassDrdy; |
|
| 174 |
extern apalControlGpio_t moduleGpioCompassDrdy;
|
|
| 237 | 175 |
|
| 238 | 176 |
/** |
| 239 | 177 |
* @brief IR_INT input signal GPIO. |
| 240 | 178 |
*/ |
| 241 |
extern apalGpio_t moduleGpioIrInt; |
|
| 179 |
extern apalControlGpio_t moduleGpioIrInt;
|
|
| 242 | 180 |
|
| 243 | 181 |
/** |
| 244 | 182 |
* @brief GYRO_DRDY input signal GPIO. |
| 245 | 183 |
*/ |
| 246 |
extern apalGpio_t moduleGpioGyroDrdy; |
|
| 184 |
extern apalControlGpio_t moduleGpioGyroDrdy;
|
|
| 247 | 185 |
|
| 248 | 186 |
/** |
| 249 | 187 |
* @brief SYS_UART_UP bidirectional signal GPIO. |
| 250 | 188 |
*/ |
| 251 |
extern apalGpio_t moduleGpioSysUartUp; |
|
| 189 |
extern apalControlGpio_t moduleGpioSysUartUp;
|
|
| 252 | 190 |
|
| 253 | 191 |
/** |
| 254 | 192 |
* @brief ACCEL_INT input signal GPIO. |
| 255 | 193 |
*/ |
| 256 |
extern apalGpio_t moduleGpioAccelInt; |
|
| 194 |
extern apalControlGpio_t moduleGpioAccelInt;
|
|
| 257 | 195 |
|
| 258 | 196 |
/** |
| 259 | 197 |
* @brief SYS_SNYC bidirectional signal GPIO. |
| 260 | 198 |
*/ |
| 261 |
extern apalGpio_t moduleGpioSysSync; |
|
| 199 |
extern apalControlGpio_t moduleGpioSysSync;
|
|
| 262 | 200 |
|
| 263 | 201 |
/** |
| 264 | 202 |
* @brief PATH_DCSTAT input signal GPIO. |
| 265 | 203 |
*/ |
| 266 |
extern apalGpio_t moduleGpioPathDcStat; |
|
| 204 |
extern apalControlGpio_t moduleGpioPathDcStat;
|
|
| 267 | 205 |
|
| 268 | 206 |
/** |
| 269 | 207 |
* @brief PATH_DCEN output signal GPIO. |
| 270 | 208 |
*/ |
| 271 |
extern apalGpio_t moduleGpioPathDcEn; |
|
| 209 |
extern apalControlGpio_t moduleGpioPathDcEn;
|
|
| 272 | 210 |
|
| 273 | 211 |
/** |
| 274 | 212 |
* @brief SYS_PD bidirectional signal GPIO. |
| 275 | 213 |
*/ |
| 276 |
extern apalGpio_t moduleGpioSysPd; |
|
| 214 |
extern apalControlGpio_t moduleGpioSysPd;
|
|
| 277 | 215 |
|
| 278 | 216 |
/** |
| 279 | 217 |
* @brief SYS_REG_EN input signal GPIO. |
| 280 | 218 |
*/ |
| 281 |
extern apalGpio_t moduleGpioSysRegEn; |
|
| 219 |
extern apalControlGpio_t moduleGpioSysRegEn;
|
|
| 282 | 220 |
|
| 283 | 221 |
/** |
| 284 | 222 |
* @brief SYS_WARMRST bidirectional signal GPIO. |
| 285 | 223 |
*/ |
| 286 |
extern apalGpio_t moduleGpioSysWarmrst; |
|
| 224 |
extern apalControlGpio_t moduleGpioSysWarmrst;
|
|
| 287 | 225 |
|
| 288 | 226 |
/** @} */ |
| 289 | 227 |
|
| ... | ... | |
| 297 | 235 |
/** |
| 298 | 236 |
* @brief Event flag to be set on a SYS_SYNC interrupt. |
| 299 | 237 |
*/ |
| 300 |
#define MODULE_OS_IOEVENTFLAGS_SYSSYNC ((eventflags_t)(1 << MODULE_GPIO_INT_SYSSYNC))
|
|
| 238 |
#define MODULE_OS_IOEVENTFLAGS_SYSSYNC ((eventflags_t)1 << GPIOC_SYS_INT_N)
|
|
| 301 | 239 |
|
| 302 | 240 |
/** |
| 303 | 241 |
* @brief Event flag to be set on a SYS_WARMRST interrupt. |
| 304 | 242 |
*/ |
| 305 |
#define MODULE_OS_IOEVENTFLAGS_SYSWARMRST ((eventflags_t)(1 << MODULE_GPIO_INT_SYSWARMRST))
|
|
| 243 |
#define MODULE_OS_IOEVENTFLAGS_SYSWARMRST ((eventflags_t)1 << GPIOD_SYS_WARMRST_N)
|
|
| 306 | 244 |
|
| 307 | 245 |
/** |
| 308 | 246 |
* @brief Event flag to be set on a PATH_DCSTAT interrupt. |
| 309 | 247 |
*/ |
| 310 |
#define MODULE_OS_IOEVENTFLAGS_PATHDCSTAT ((eventflags_t)(1 << MODULE_GPIO_INT_PATHDCSTAT))
|
|
| 248 |
#define MODULE_OS_IOEVENTFLAGS_PATHDCSTAT ((eventflags_t)1 << GPIOC_PATH_DCEN)
|
|
| 311 | 249 |
|
| 312 | 250 |
/** |
| 313 | 251 |
* @brief Event flag to be set on a COMPASS_DRDY interrupt. |
| 314 | 252 |
*/ |
| 315 |
#define MODULE_OS_IOEVENTFLAGS_COMPASSDRDY ((eventflags_t)(1 << MODULE_GPIO_INT_COMPASSDRDY))
|
|
| 253 |
#define MODULE_OS_IOEVENTFLAGS_COMPASSDRDY ((eventflags_t)1 << GPIOB_COMPASS_DRDY)
|
|
| 316 | 254 |
|
| 317 | 255 |
/** |
| 318 | 256 |
* @brief Event flag to be set on a SYS_PD interrupt. |
| 319 | 257 |
*/ |
| 320 |
#define MODULE_OS_IOEVENTFLAGS_SYSPD ((eventflags_t)(1 << MODULE_GPIO_INT_SYSPD))
|
|
| 258 |
#define MODULE_OS_IOEVENTFLAGS_SYSPD ((eventflags_t)1 << GPIOC_SYS_PD_N)
|
|
| 321 | 259 |
|
| 322 | 260 |
/** |
| 323 | 261 |
* @brief Event flag to be set on a SYS_REG_EN interrupt. |
| 324 | 262 |
*/ |
| 325 |
#define MODULE_OS_IOEVENTFLAGS_SYSREGEN ((eventflags_t)(1 << MODULE_GPIO_INT_SYSREGEN))
|
|
| 263 |
#define MODULE_OS_IOEVENTFLAGS_SYSREGEN ((eventflags_t)1 << GPIOC_SYS_REG_EN)
|
|
| 326 | 264 |
|
| 327 | 265 |
/** |
| 328 | 266 |
* @brief Event flag to be set on a IR_INT interrupt. |
| 329 | 267 |
*/ |
| 330 |
#define MODULE_OS_IOEVENTFLAGS_IRINT ((eventflags_t)(1 << MODULE_GPIO_INT_IRINT))
|
|
| 268 |
#define MODULE_OS_IOEVENTFLAGS_IRINT ((eventflags_t)1 << GPIOB_IR_INT)
|
|
| 331 | 269 |
|
| 332 | 270 |
/** |
| 333 | 271 |
* @brief Event flag to be set on a GYRO_DRDY interrupt. |
| 334 | 272 |
*/ |
| 335 |
#define MODULE_OS_IOEVENTFLAGS_GYRODRDY ((eventflags_t)(1 << MODULE_GPIO_INT_GYRODRDY))
|
|
| 273 |
#define MODULE_OS_IOEVENTFLAGS_GYRODRDY ((eventflags_t)1 << GPIOB_GYRO_DRDY)
|
|
| 336 | 274 |
|
| 337 | 275 |
/** |
| 338 | 276 |
* @brief Event flag to be set on a SYS_UART_UP interrupt. |
| 339 | 277 |
*/ |
| 340 |
#define MODULE_OS_IOEVENTFLAGS_SYSUARTUP ((eventflags_t)(1 << MODULE_GPIO_INT_SYSUARTUP))
|
|
| 278 |
#define MODULE_OS_IOEVENTFLAGS_SYSUARTUP ((eventflags_t)1 << GPIOB_SYS_UART_UP)
|
|
| 341 | 279 |
|
| 342 | 280 |
/** |
| 343 | 281 |
* @brief Event flag to be set on a ACCEL_INT interrupt. |
| 344 | 282 |
*/ |
| 345 |
#define MODULE_OS_IOEVENTFLAGS_ACCELINT ((eventflags_t)(1 << MODULE_GPIO_INT_ACCELINT))
|
|
| 283 |
#define MODULE_OS_IOEVENTFLAGS_ACCELINT ((eventflags_t)1 << GPIOB_ACCEL_INT_N)
|
|
| 346 | 284 |
|
| 347 | 285 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
| 348 | 286 |
/** |
| ... | ... | |
| 359 | 297 |
} |
| 360 | 298 |
|
| 361 | 299 |
/** |
| 300 |
* @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 |
/** |
|
| 362 | 328 |
* @brief Unit test initialization hook. |
| 363 | 329 |
*/ |
| 364 | 330 |
#define MODULE_INIT_TESTS() { \
|
| ... | ... | |
| 431 | 397 |
/** |
| 432 | 398 |
* @brief PD signal GPIO. |
| 433 | 399 |
*/ |
| 434 |
extern apalControlGpio_t moduleSsspGpioPd;
|
|
| 400 |
#define moduleSsspGpioPd moduleGpioSysPd
|
|
| 435 | 401 |
|
| 436 | 402 |
/** |
| 437 | 403 |
* @brief SYNC signal GPIO. |
| 438 | 404 |
*/ |
| 439 |
extern apalControlGpio_t moduleSsspGpioSync;
|
|
| 405 |
#define moduleSsspGpioSync moduleGpioSysSync
|
|
| 440 | 406 |
|
| 441 | 407 |
/** |
| 442 | 408 |
* @brief UP signal GPIO. |
| 443 | 409 |
*/ |
| 444 |
extern apalControlGpio_t moduleSsspGpioUp;
|
|
| 410 |
#define moduleSsspGpioUp moduleGpioSysUartUp
|
|
| 445 | 411 |
|
| 446 | 412 |
/** |
| 447 | 413 |
* @brief Event flags for PD signal events. |
Also available in: Unified diff