amiro-os / modules / PowerManagement_1-1 / module.h @ 0128be0f
History | View | Annotate | Download (22.533 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 | * @brief Makro to store data in the core coupled memory (ccm).
|
||
| 31 | * Example:
|
||
| 32 | * int compute_buffer[128] CCM_RAM;
|
||
| 33 | *
|
||
| 34 | * @note The ccm is not connected to any bus system.
|
||
| 35 | */
|
||
| 36 | #define CCM_RAM __attribute__((section(".ram4"), aligned(4))) |
||
| 37 | |||
| 38 | /*
|
||
| 39 | * @brief Makro to store data in the ethernet memory (eth).
|
||
| 40 | * Example:
|
||
| 41 | * int dma_buffer[128] ETH_RAM;
|
||
| 42 | *
|
||
| 43 | * @note The eth is a dedicated memory block with its own DMA controller.
|
||
| 44 | */
|
||
| 45 | #define ETH_RAM __attribute__((section(".ram2"), aligned(4))) |
||
| 46 | |||
| 47 | /*
|
||
| 48 | * @brief Makro to store data in the backup memory (bckp).
|
||
| 49 | * Example:
|
||
| 50 | * int backup_buffer[128] BCKP_RAM;
|
||
| 51 | *
|
||
| 52 | * @note The eth is a dedicated memory block with its own DMA controller.
|
||
| 53 | */
|
||
| 54 | #define BCKP_RAM __attribute__((section(".ram5"), aligned(4))) |
||
| 55 | |||
| 56 | /** @} */
|
||
| 57 | |||
| 58 | /*===========================================================================*/
|
||
| 59 | /**
|
||
| 60 | * @name ChibiOS/HAL configuration
|
||
| 61 | * @{
|
||
| 62 | */
|
||
| 63 | /*===========================================================================*/
|
||
| 64 | #include <hal.h> |
||
| 65 | 0128be0f | Marc Rothmann | #include <aos_interrupts.h> |
| 66 | e545e620 | Thomas Schöpping | |
| 67 | /**
|
||
| 68 | * @brief ADC driver for reading the system voltage.
|
||
| 69 | */
|
||
| 70 | #define MODULE_HAL_ADC_VSYS ADCD1
|
||
| 71 | |||
| 72 | /**
|
||
| 73 | * @brief Configuration for the ADC.
|
||
| 74 | */
|
||
| 75 | extern ADCConversionGroup moduleHalAdcVsysConversionGroup;
|
||
| 76 | |||
| 77 | /**
|
||
| 78 | * @brief CAN driver to use.
|
||
| 79 | */
|
||
| 80 | #define MODULE_HAL_CAN CAND1
|
||
| 81 | |||
| 82 | /**
|
||
| 83 | * @brief Configuration for the CAN driver.
|
||
| 84 | */
|
||
| 85 | extern CANConfig moduleHalCanConfig;
|
||
| 86 | |||
| 87 | /**
|
||
| 88 | 0128be0f | Marc Rothmann | * @brief Interrupt driver (PAL).
|
| 89 | e545e620 | Thomas Schöpping | */
|
| 90 | 0128be0f | Marc Rothmann | |
| 91 | extern aos_interrupt_driver_t moduleIntDriver;
|
||
| 92 | e545e620 | Thomas Schöpping | |
| 93 | /**
|
||
| 94 | 0128be0f | Marc Rothmann | * @brief Interrupt driver config.
|
| 95 | e545e620 | Thomas Schöpping | */
|
| 96 | 0128be0f | Marc Rothmann | extern aos_interrupt_cfg_t moduleIntConfig[14]; |
| 97 | e545e620 | Thomas Schöpping | |
| 98 | /**
|
||
| 99 | * @brief I2C driver to access multiplexer, proximity sensors 1 to 4, power monitors for VIO1.8 and VIO 3.3, and fuel gauge (rear battery).
|
||
| 100 | */
|
||
| 101 | #define MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR I2CD1
|
||
| 102 | |||
| 103 | /**
|
||
| 104 | * @brief Configuration for the multiplexer, proximity sensors 1 to 4, power monitors for VIO1.8 and VIO 3.3, and fuel gauge (rear battery) I2C driver.
|
||
| 105 | */
|
||
| 106 | extern I2CConfig moduleHalI2cProxPm18Pm33GaugeRearConfig;
|
||
| 107 | |||
| 108 | /**
|
||
| 109 | * @brief I2C driver to access multiplexer, proximity sensors 5 to 8, power monitors for VSYS4.2, VIO 5.0 and VDD, EEPROM, touch sensor, and fuel gauge (front battery).
|
||
| 110 | */
|
||
| 111 | #define MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT I2CD2
|
||
| 112 | |||
| 113 | /**
|
||
| 114 | * @brief Configuration for the multiplexer, proximity sensors 1 to 4, power monitors for VIO1.8 and VIO 3.3, and fuel gauge (rear battery) I2C driver.
|
||
| 115 | */
|
||
| 116 | extern I2CConfig moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig;
|
||
| 117 | |||
| 118 | /**
|
||
| 119 | * @brief PWM driver for the buzzer.
|
||
| 120 | */
|
||
| 121 | #define MODULE_HAL_PWM_BUZZER PWMD3
|
||
| 122 | |||
| 123 | /**
|
||
| 124 | * @brief Configuration of the PWM driver.
|
||
| 125 | */
|
||
| 126 | extern PWMConfig moduleHalPwmBuzzerConfig;
|
||
| 127 | |||
| 128 | /**
|
||
| 129 | * @brief PWM channeö for the buzzer.
|
||
| 130 | */
|
||
| 131 | #define MODULE_HAL_PWM_BUZZER_CHANNEL 1 |
||
| 132 | |||
| 133 | /**
|
||
| 134 | * @brief Serial driver of the programmer interface.
|
||
| 135 | */
|
||
| 136 | #define MODULE_HAL_PROGIF SD1
|
||
| 137 | |||
| 138 | /**
|
||
| 139 | * @brief Configuration for the programmer serial interface driver.
|
||
| 140 | */
|
||
| 141 | extern SerialConfig moduleHalProgIfConfig;
|
||
| 142 | |||
| 143 | 8399aeae | Thomas Schöpping | /**
|
| 144 | * @brief Real-Time Clock driver.
|
||
| 145 | */
|
||
| 146 | #define MODULE_HAL_RTC RTCD1
|
||
| 147 | |||
| 148 | e545e620 | Thomas Schöpping | /** @} */
|
| 149 | |||
| 150 | /*===========================================================================*/
|
||
| 151 | /**
|
||
| 152 | * @name GPIO definitions
|
||
| 153 | * @{
|
||
| 154 | */
|
||
| 155 | /*===========================================================================*/
|
||
| 156 | #include <amiro-lld.h> |
||
| 157 | |||
| 158 | /**
|
||
| 159 | * @brief Interrupt channel for the IR_INT1 and CHARGE_STAT1A signals.
|
||
| 160 | */
|
||
| 161 | 0128be0f | Marc Rothmann | #define MODULE_GPIO_INT_IRINT1 ((uint8_t)1) |
| 162 | e545e620 | Thomas Schöpping | |
| 163 | /**
|
||
| 164 | * @brief Interrupt channel for the GAUGE_BATLOW1 signal.
|
||
| 165 | */
|
||
| 166 | 0128be0f | Marc Rothmann | #define MODULE_GPIO_INT_GAUGEBATLOW1 ((uint8_t)2) |
| 167 | e545e620 | Thomas Schöpping | |
| 168 | /**
|
||
| 169 | * @brief Interrupt channel for the GAUGE_BATGD1 signal.
|
||
| 170 | */
|
||
| 171 | 0128be0f | Marc Rothmann | #define MODULE_GPIO_INT_GAUGEBATGD1 ((uint8_t)3) |
| 172 | e545e620 | Thomas Schöpping | |
| 173 | /**
|
||
| 174 | * @brief Interrupt channel for the SYS_UART_DN signal.
|
||
| 175 | */
|
||
| 176 | 0128be0f | Marc Rothmann | #define MODULE_GPIO_INT_SYSUARTDN ((uint8_t)4) |
| 177 | e545e620 | Thomas Schöpping | |
| 178 | /**
|
||
| 179 | * @brief Interrupt channel for the IR_INT2 and CHARGE_STAT2A signals.
|
||
| 180 | */
|
||
| 181 | 0128be0f | Marc Rothmann | #define MODULE_GPIO_INT_IRINT2 ((uint8_t)5) |
| 182 | e545e620 | Thomas Schöpping | |
| 183 | /**
|
||
| 184 | * @brief Interrupt channel for the TOUCH_INT signal.
|
||
| 185 | */
|
||
| 186 | 0128be0f | Marc Rothmann | #define MODULE_GPIO_INT_TOUCHINT ((uint8_t)6) |
| 187 | e545e620 | Thomas Schöpping | |
| 188 | /**
|
||
| 189 | * @brief Interrupt channel for the GAUGE_BATLOW2 signal.
|
||
| 190 | */
|
||
| 191 | 0128be0f | Marc Rothmann | #define MODULE_GPIO_INT_GAUGEBATLOW2 ((uint8_t)7) |
| 192 | e545e620 | Thomas Schöpping | |
| 193 | /**
|
||
| 194 | * @brief Interrupt channel for the GAUGE_BATGD2 signal.
|
||
| 195 | */
|
||
| 196 | 0128be0f | Marc Rothmann | #define MODULE_GPIO_INT_GAUGEBATGD2 ((uint8_t)8) |
| 197 | e545e620 | Thomas Schöpping | |
| 198 | /**
|
||
| 199 | * @brief Interrupt channel for the PATH_DC signal.
|
||
| 200 | */
|
||
| 201 | 0128be0f | Marc Rothmann | #define MODULE_GPIO_INT_PATHDC ((uint8_t)9) |
| 202 | e545e620 | Thomas Schöpping | |
| 203 | /**
|
||
| 204 | * @brief Interrupt channel for the SYS_SPI_DIR signal.
|
||
| 205 | */
|
||
| 206 | 0128be0f | Marc Rothmann | #define MODULE_GPIO_INT_SYSSPIDIR ((uint8_t)10) |
| 207 | e545e620 | Thomas Schöpping | |
| 208 | /**
|
||
| 209 | * @brief Interrupt channel for the SYS_SYNC signal.
|
||
| 210 | */
|
||
| 211 | 0128be0f | Marc Rothmann | #define MODULE_GPIO_INT_SYSSYNC ((uint8_t)11) |
| 212 | e545e620 | Thomas Schöpping | |
| 213 | /**
|
||
| 214 | * @brief Interrupt channel for the SYS_PD signal.
|
||
| 215 | */
|
||
| 216 | 0128be0f | Marc Rothmann | #define MODULE_GPIO_INT_SYSPD ((uint8_t)12) |
| 217 | e545e620 | Thomas Schöpping | |
| 218 | /**
|
||
| 219 | * @brief Interrupt channel for the SYS_WARMRST signal.
|
||
| 220 | */
|
||
| 221 | 0128be0f | Marc Rothmann | #define MODULE_GPIO_INT_SYSWARMRST ((uint8_t)13) |
| 222 | e545e620 | Thomas Schöpping | |
| 223 | /**
|
||
| 224 | * @brief Interrupt channel for the SYS_UART_UP signal.
|
||
| 225 | */
|
||
| 226 | 0128be0f | Marc Rothmann | #define MODULE_GPIO_INT_SYSUARTUP ((uint8_t)14) |
| 227 | e545e620 | Thomas Schöpping | |
| 228 | /**
|
||
| 229 | * @brief SYS_REG_EN output signal GPIO.
|
||
| 230 | */
|
||
| 231 | extern apalGpio_t moduleGpioSysRegEn;
|
||
| 232 | |||
| 233 | /**
|
||
| 234 | * @brief IR_INT1 input signal GPIO.
|
||
| 235 | */
|
||
| 236 | extern apalGpio_t moduleGpioIrInt1;
|
||
| 237 | |||
| 238 | /**
|
||
| 239 | * @brief POWER_EN output signal GPIO.
|
||
| 240 | */
|
||
| 241 | extern apalGpio_t moduleGpioPowerEn;
|
||
| 242 | |||
| 243 | /**
|
||
| 244 | * @brief SYS_UART_DN bidirectional signal GPIO.
|
||
| 245 | */
|
||
| 246 | extern apalGpio_t moduleGpioSysUartDn;
|
||
| 247 | |||
| 248 | /**
|
||
| 249 | * @brief CHARGE_STAT2A input signal GPIO.
|
||
| 250 | */
|
||
| 251 | extern apalGpio_t moduleGpioChargeStat2A;
|
||
| 252 | |||
| 253 | /**
|
||
| 254 | * @brief GAUGE_BATLOW2 input signal GPIO.
|
||
| 255 | */
|
||
| 256 | extern apalGpio_t moduleGpioGaugeBatLow2;
|
||
| 257 | |||
| 258 | /**
|
||
| 259 | * @brief GAUGE_BATGD2 input signal GPIO.
|
||
| 260 | */
|
||
| 261 | extern apalGpio_t moduleGpioGaugeBatGd2;
|
||
| 262 | |||
| 263 | /**
|
||
| 264 | * @brief LED output signal GPIO.
|
||
| 265 | */
|
||
| 266 | extern apalGpio_t moduleGpioLed;
|
||
| 267 | |||
| 268 | /**
|
||
| 269 | * @brief SYS_UART_UP bidirectional signal GPIO.
|
||
| 270 | */
|
||
| 271 | extern apalGpio_t moduleGpioSysUartUp;
|
||
| 272 | |||
| 273 | /**
|
||
| 274 | * @brief CHARGE_STAT1A input signal GPIO.
|
||
| 275 | */
|
||
| 276 | extern apalGpio_t moduleGpioChargeStat1A;
|
||
| 277 | |||
| 278 | /**
|
||
| 279 | * @brief GAUGE_BATLOW1 input signal GPIO.
|
||
| 280 | */
|
||
| 281 | extern apalGpio_t moduleGpioGaugeBatLow1;
|
||
| 282 | |||
| 283 | /**
|
||
| 284 | * @brief GAUGE_BATGD1 input signal GPIO.
|
||
| 285 | */
|
||
| 286 | extern apalGpio_t moduleGpioGaugeBatGd1;
|
||
| 287 | |||
| 288 | /**
|
||
| 289 | * @brief CHARG_EN1 output signal GPIO.
|
||
| 290 | */
|
||
| 291 | extern apalGpio_t moduleGpioChargeEn1;
|
||
| 292 | |||
| 293 | /**
|
||
| 294 | * @brief IR_INT2 input signal GPIO.
|
||
| 295 | */
|
||
| 296 | extern apalGpio_t moduleGpioIrInt2;
|
||
| 297 | |||
| 298 | /**
|
||
| 299 | * @brief TOUCH_INT input signal GPIO.
|
||
| 300 | */
|
||
| 301 | extern apalGpio_t moduleGpioTouchInt;
|
||
| 302 | |||
| 303 | /**
|
||
| 304 | * @brief SYS_DONE input signal GPIO.
|
||
| 305 | */
|
||
| 306 | extern apalGpio_t moduleGpioSysDone;
|
||
| 307 | |||
| 308 | /**
|
||
| 309 | * @brief SYS_PROG output signal GPIO.
|
||
| 310 | */
|
||
| 311 | extern apalGpio_t moduleGpioSysProg;
|
||
| 312 | |||
| 313 | /**
|
||
| 314 | * @brief PATH_DC input signal GPIO.
|
||
| 315 | */
|
||
| 316 | extern apalGpio_t moduleGpioPathDc;
|
||
| 317 | |||
| 318 | /**
|
||
| 319 | * @brief SYS_SPI_DIR bidirectional signal GPIO.
|
||
| 320 | */
|
||
| 321 | extern apalGpio_t moduleGpioSysSpiDir;
|
||
| 322 | |||
| 323 | /**
|
||
| 324 | * @brief SYS_SYNC bidirectional signal GPIO.
|
||
| 325 | */
|
||
| 326 | extern apalGpio_t moduleGpioSysSync;
|
||
| 327 | |||
| 328 | /**
|
||
| 329 | * @brief SYS_PD bidirectional signal GPIO.
|
||
| 330 | */
|
||
| 331 | extern apalGpio_t moduleGpioSysPd;
|
||
| 332 | |||
| 333 | /**
|
||
| 334 | * @brief SYS_WARMRST bidirectional signal GPIO.
|
||
| 335 | */
|
||
| 336 | extern apalGpio_t moduleGpioSysWarmrst;
|
||
| 337 | |||
| 338 | /**
|
||
| 339 | * @brief BT_RST output signal GPIO.
|
||
| 340 | */
|
||
| 341 | extern apalGpio_t moduleGpioBtRst;
|
||
| 342 | |||
| 343 | /**
|
||
| 344 | * @brief CHARGE_EN2 output signal GPIO.
|
||
| 345 | */
|
||
| 346 | extern apalGpio_t moduleGpioChargeEn2;
|
||
| 347 | |||
| 348 | /** @} */
|
||
| 349 | |||
| 350 | /*===========================================================================*/
|
||
| 351 | /**
|
||
| 352 | * @name AMiRo-OS core configurations
|
||
| 353 | * @{
|
||
| 354 | */
|
||
| 355 | /*===========================================================================*/
|
||
| 356 | |||
| 357 | /**
|
||
| 358 | * @brief Event flag to be set on a IR_INT1 / CHARGE_STAT1A interrupt.
|
||
| 359 | */
|
||
| 360 | 0128be0f | Marc Rothmann | #define MODULE_OS_IOEVENTFLAGS_IRINT1 ((eventflags_t)1 << MODULE_GPIO_INT_IRINT1) |
| 361 | e545e620 | Thomas Schöpping | |
| 362 | /**
|
||
| 363 | * @brief Event flag to be set on a GAUGE_BATLOW1 interrupt.
|
||
| 364 | */
|
||
| 365 | 0128be0f | Marc Rothmann | #define MODULE_OS_IOEVENTFLAGS_GAUGEBATLOW1 ((eventflags_t)1 << MODULE_GPIO_INT_GAUGEBATLOW1) |
| 366 | e545e620 | Thomas Schöpping | |
| 367 | /**
|
||
| 368 | * @brief Event flag to be set on a GAUGE_BATGD1 interrupt.
|
||
| 369 | */
|
||
| 370 | 0128be0f | Marc Rothmann | #define MODULE_OS_IOEVENTFLAGS_GAUGEBATGD1 ((eventflags_t)1 << MODULE_GPIO_INT_GAUGEBATGD1) |
| 371 | e545e620 | Thomas Schöpping | |
| 372 | /**
|
||
| 373 | * @brief Event flag to be set on a SYS_UART_DN interrupt.
|
||
| 374 | */
|
||
| 375 | 0128be0f | Marc Rothmann | #define MODULE_OS_IOEVENTFLAGS_SYSUARTDN ((eventflags_t)1 << MODULE_GPIO_INT_SYSUARTDN) |
| 376 | e545e620 | Thomas Schöpping | |
| 377 | /**
|
||
| 378 | * @brief Event flag to be set on a IR_INT2 / CHARGE_STAT2A interrupt.
|
||
| 379 | */
|
||
| 380 | 0128be0f | Marc Rothmann | #define MODULE_OS_IOEVENTFLAGS_IRINT2 ((eventflags_t)1 << MODULE_GPIO_INT_IRINT2) |
| 381 | e545e620 | Thomas Schöpping | |
| 382 | /**
|
||
| 383 | * @brief Event flag to be set on a TOUCH_INT interrupt.
|
||
| 384 | */
|
||
| 385 | 0128be0f | Marc Rothmann | #define MODULE_OS_IOEVENTFLAGS_TOUCHINT ((eventflags_t)1 << MODULE_GPIO_INT_TOUCHINT) |
| 386 | e545e620 | Thomas Schöpping | |
| 387 | /**
|
||
| 388 | * @brief Event flag to be set on a GAUGE_BATLOW2 interrupt.
|
||
| 389 | */
|
||
| 390 | 0128be0f | Marc Rothmann | #define MODULE_OS_IOEVENTFLAGS_GAUGEBATLOW2 ((eventflags_t)1 << MODULE_GPIO_INT_GAUGEBATLOW2) |
| 391 | e545e620 | Thomas Schöpping | |
| 392 | /**
|
||
| 393 | * @brief Event flag to be set on a GAUGE_BATGD2 interrupt.
|
||
| 394 | */
|
||
| 395 | 0128be0f | Marc Rothmann | #define MODULE_OS_IOEVENTFLAGS_GAUGEBATGD2 ((eventflags_t)1 << MODULE_GPIO_INT_GAUGEBATGD2) |
| 396 | e545e620 | Thomas Schöpping | |
| 397 | /**
|
||
| 398 | * @brief Event flag to be set on a PATH_DC interrupt.
|
||
| 399 | */
|
||
| 400 | 0128be0f | Marc Rothmann | #define MODULE_OS_IOEVENTFLAGS_PATHDC ((eventflags_t)1 << MODULE_GPIO_INT_PATHDC) |
| 401 | e545e620 | Thomas Schöpping | |
| 402 | /**
|
||
| 403 | * @brief Event flag to be set on a SYS_SPI_DIR interrupt.
|
||
| 404 | */
|
||
| 405 | 0128be0f | Marc Rothmann | #define MODULE_OS_IOEVENTFLAGS_SYSSPIDIR ((eventflags_t)1 << MODULE_GPIO_INT_SYSSPIDIR) |
| 406 | e545e620 | Thomas Schöpping | |
| 407 | /**
|
||
| 408 | * @brief Event flag to be set on a SYS_SYNC interrupt.
|
||
| 409 | */
|
||
| 410 | 0128be0f | Marc Rothmann | #define MODULE_OS_IOEVENTFLAGS_SYSSYNC ((eventflags_t)1 << MODULE_GPIO_INT_SYSSYNC) |
| 411 | e545e620 | Thomas Schöpping | |
| 412 | /**
|
||
| 413 | * @brief Event flag to be set on a SYS_PD interrupt.
|
||
| 414 | */
|
||
| 415 | 0128be0f | Marc Rothmann | #define MODULE_OS_IOEVENTFLAGS_SYSPD ((eventflags_t)1 << MODULE_GPIO_INT_SYSPD) |
| 416 | e545e620 | Thomas Schöpping | |
| 417 | /**
|
||
| 418 | * @brief Event flag to be set on a SYS_WARMRST interrupt.
|
||
| 419 | */
|
||
| 420 | 0128be0f | Marc Rothmann | #define MODULE_OS_IOEVENTFLAGS_SYSWARMRST ((eventflags_t)1 << MODULE_GPIO_INT_SYSWARMRST) |
| 421 | e545e620 | Thomas Schöpping | |
| 422 | /**
|
||
| 423 | * @brief Event flag to be set on a SYS_UART_UP interrupt.
|
||
| 424 | */
|
||
| 425 | 0128be0f | Marc Rothmann | #define MODULE_OS_IOEVENTFLAGS_SYSUARTUP ((eventflags_t)1 << MODULE_GPIO_INT_SYSUARTUP) |
| 426 | e545e620 | Thomas Schöpping | |
| 427 | 6b53f6bf | Thomas Schöpping | #if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
| 428 | e545e620 | Thomas Schöpping | /**
|
| 429 | * @brief Shell prompt text.
|
||
| 430 | */
|
||
| 431 | extern const char* moduleShellPrompt; |
||
| 432 | 6b53f6bf | Thomas Schöpping | #endif
|
| 433 | e545e620 | Thomas Schöpping | |
| 434 | /**
|
||
| 435 | * @brief Unit test initialization hook.
|
||
| 436 | */
|
||
| 437 | #define MODULE_INIT_TESTS() { \
|
||
| 438 | /* add unit-test shell commands */ \
|
||
| 439 | 6b53f6bf | Thomas Schöpping | aosShellAddCommand(&aos.shell, &moduleUtAdcVsys.shellcmd); \ |
| 440 | aosShellAddCommand(&aos.shell, &moduleUtAlldAt24c01bn.shellcmd); \ |
||
| 441 | aosShellAddCommand(&aos.shell, &moduleUtAlldBq24103a.shellcmd); \ |
||
| 442 | aosShellAddCommand(&aos.shell, &moduleUtAlldBq27500.shellcmd); \ |
||
| 443 | aosShellAddCommand(&aos.shell, &moduleUtAlldBq27500Bq24103a.shellcmd); \ |
||
| 444 | aosShellAddCommand(&aos.shell, &moduleUtAlldIna219.shellcmd); \ |
||
| 445 | aosShellAddCommand(&aos.shell, &moduleUtAlldMpr121.shellcmd); \ |
||
| 446 | aosShellAddCommand(&aos.shell, &moduleUtAlldPca9544a.shellcmd); \ |
||
| 447 | aosShellAddCommand(&aos.shell, &moduleUtAlldPklcs1212e4001.shellcmd); \ |
||
| 448 | aosShellAddCommand(&aos.shell, &moduleUtAlldLed.shellcmd); \ |
||
| 449 | aosShellAddCommand(&aos.shell, &moduleUtAlldTps62113.shellcmd); \ |
||
| 450 | aosShellAddCommand(&aos.shell, &moduleUtAlldTps62113Ina219.shellcmd); \ |
||
| 451 | aosShellAddCommand(&aos.shell, &moduleUtAlldVcnl4020.shellcmd); \ |
||
| 452 | e545e620 | Thomas Schöpping | } |
| 453 | |||
| 454 | /**
|
||
| 455 | * @brief Periphery communication interfaces initialization hook.
|
||
| 456 | */
|
||
| 457 | #define MODULE_INIT_PERIPHERY_COMM() { \
|
||
| 458 | /* serial driver */ \
|
||
| 459 | sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig); \ |
||
| 460 | /* I2C */ \
|
||
| 461 | moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (PCA9544A_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? PCA9544A_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed; \ |
||
| 462 | moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (VCNL4020_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? VCNL4020_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed; \ |
||
| 463 | moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (INA219_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? INA219_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed; \ |
||
| 464 | moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (BQ27500_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? BQ27500_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed; \ |
||
| 465 | moduleHalI2cProxPm18Pm33GaugeRearConfig.duty_cycle = (moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2; \
|
||
| 466 | i2cStart(&MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR, &moduleHalI2cProxPm18Pm33GaugeRearConfig); \ |
||
| 467 | moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (PCA9544A_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? PCA9544A_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
||
| 468 | moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (VCNL4020_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? VCNL4020_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
||
| 469 | moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (INA219_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? INA219_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
||
| 470 | moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (AT24C01BN_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? AT24C01BN_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
||
| 471 | moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (MPR121_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? MPR121_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
||
| 472 | moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (BQ27500_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? BQ27500_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
||
| 473 | moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.duty_cycle = (moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2; \
|
||
| 474 | i2cStart(&MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT, &moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig); \ |
||
| 475 | /* ADC */ \
|
||
| 476 | adcStart(&MODULE_HAL_ADC_VSYS, NULL); \
|
||
| 477 | /* PWM */ \
|
||
| 478 | pwmStart(&MODULE_HAL_PWM_BUZZER, &moduleHalPwmBuzzerConfig); \ |
||
| 479 | moduleHalPwmBuzzerConfig.frequency = MODULE_HAL_PWM_BUZZER.clock; \ |
||
| 480 | pwmStop(&MODULE_HAL_PWM_BUZZER); \ |
||
| 481 | moduleHalPwmBuzzerConfig.period = moduleHalPwmBuzzerConfig.frequency / PKLCS1212E4001_LLD_FREQUENCY_SPEC; \ |
||
| 482 | pwmStart(&MODULE_HAL_PWM_BUZZER, &moduleHalPwmBuzzerConfig); \ |
||
| 483 | } |
||
| 484 | |||
| 485 | /**
|
||
| 486 | * @brief Periphery communication interface deinitialization hook.
|
||
| 487 | */
|
||
| 488 | #define MODULE_SHUTDOWN_PERIPHERY_COMM() { \
|
||
| 489 | /* PWM */ \
|
||
| 490 | pwmStop(&MODULE_HAL_PWM_BUZZER); \ |
||
| 491 | /* ADC */ \
|
||
| 492 | adcStop(&MODULE_HAL_ADC_VSYS); \ |
||
| 493 | /* I2C */ \
|
||
| 494 | i2cStop(&MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR); \ |
||
| 495 | i2cStop(&MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT); \ |
||
| 496 | /* don't stop the serial driver so messages can still be printed */ \
|
||
| 497 | } |
||
| 498 | |||
| 499 | /** @} */
|
||
| 500 | |||
| 501 | /*===========================================================================*/
|
||
| 502 | /**
|
||
| 503 | 6b53f6bf | Thomas Schöpping | * @name Startup Shutdown Synchronization Protocol (SSSP)
|
| 504 | * @{
|
||
| 505 | */
|
||
| 506 | /*===========================================================================*/
|
||
| 507 | |||
| 508 | /**
|
||
| 509 | * @brief PD signal GPIO.
|
||
| 510 | */
|
||
| 511 | extern apalControlGpio_t moduleSsspGpioPd;
|
||
| 512 | |||
| 513 | /**
|
||
| 514 | * @brief SYNC signal GPIO.
|
||
| 515 | */
|
||
| 516 | extern apalControlGpio_t moduleSsspGpioSync;
|
||
| 517 | |||
| 518 | /**
|
||
| 519 | 933df08e | Thomas Schöpping | * @brief DN signal GPIO.
|
| 520 | */
|
||
| 521 | extern apalControlGpio_t moduleSsspGpioDn;
|
||
| 522 | |||
| 523 | /**
|
||
| 524 | * @brief UP signal GPIO.
|
||
| 525 | */
|
||
| 526 | extern apalControlGpio_t moduleSsspGpioUp;
|
||
| 527 | |||
| 528 | /**
|
||
| 529 | 6b53f6bf | Thomas Schöpping | * @brief Event flags for PD signal events.
|
| 530 | */
|
||
| 531 | #define MODULE_SSSP_EVENTFLAGS_PD MODULE_OS_IOEVENTFLAGS_SYSPD
|
||
| 532 | |||
| 533 | /**
|
||
| 534 | 933df08e | Thomas Schöpping | * @brief Event flags for SYNC signal events.
|
| 535 | 6b53f6bf | Thomas Schöpping | */
|
| 536 | #define MODULE_SSSP_EVENTFLAGS_SYNC MODULE_OS_IOEVENTFLAGS_SYSSYNC
|
||
| 537 | |||
| 538 | /**
|
||
| 539 | 933df08e | Thomas Schöpping | * @brief Event flags for UP signal events.
|
| 540 | */
|
||
| 541 | #define MODULE_SSSP_EVENTFLAGS_UP MODULE_OS_IOEVENTFLAGS_SYSUARTUP
|
||
| 542 | |||
| 543 | /**
|
||
| 544 | * @brief Event flags for DN signal events.
|
||
| 545 | */
|
||
| 546 | #define MODULE_SSSP_EVENTFLAGS_DN MODULE_OS_IOEVENTFLAGS_SYSUARTDN
|
||
| 547 | |||
| 548 | 6b53f6bf | Thomas Schöpping | /** @} */
|
| 549 | |||
| 550 | /*===========================================================================*/
|
||
| 551 | /**
|
||
| 552 | e545e620 | Thomas Schöpping | * @name Low-level drivers
|
| 553 | * @{
|
||
| 554 | */
|
||
| 555 | /*===========================================================================*/
|
||
| 556 | #include <alld_at24c01bn-sh-b.h> |
||
| 557 | #include <alld_bq24103a.h> |
||
| 558 | #include <alld_bq27500.h> |
||
| 559 | #include <alld_ina219.h> |
||
| 560 | #include <alld_led.h> |
||
| 561 | #include <alld_mpr121.h> |
||
| 562 | #include <alld_pca9544a.h> |
||
| 563 | #include <alld_pklcs1212e4001.h> |
||
| 564 | #include <alld_tps62113.h> |
||
| 565 | #include <alld_vcnl4020.h> |
||
| 566 | |||
| 567 | /**
|
||
| 568 | * @brief EEPROM driver.
|
||
| 569 | */
|
||
| 570 | extern AT24C01BNDriver moduleLldEeprom;
|
||
| 571 | |||
| 572 | /**
|
||
| 573 | * @brief Battery charger (front battery) driver.
|
||
| 574 | */
|
||
| 575 | extern BQ24103ADriver moduleLldBatteryChargerFront;
|
||
| 576 | |||
| 577 | /**
|
||
| 578 | * @brief Battery charger (rear battery) driver.
|
||
| 579 | */
|
||
| 580 | extern BQ24103ADriver moduleLldBatteryChargerRear;
|
||
| 581 | |||
| 582 | /**
|
||
| 583 | * @brief Fuel gauge (front battery) driver.
|
||
| 584 | */
|
||
| 585 | extern BQ27500Driver moduleLldFuelGaugeFront;
|
||
| 586 | |||
| 587 | /**
|
||
| 588 | * @brief Fuel gauge (rear battery) driver.
|
||
| 589 | */
|
||
| 590 | extern BQ27500Driver moduleLldFuelGaugeRear;
|
||
| 591 | |||
| 592 | /**
|
||
| 593 | * @brief Power monitor (VDD) driver.
|
||
| 594 | */
|
||
| 595 | extern INA219Driver moduleLldPowerMonitorVdd;
|
||
| 596 | |||
| 597 | /**
|
||
| 598 | * @brief Power monitor (VIO 1.8) driver.
|
||
| 599 | */
|
||
| 600 | extern INA219Driver moduleLldPowerMonitorVio18;
|
||
| 601 | |||
| 602 | /**
|
||
| 603 | * @brief Power monitor (VIO 3.3) driver.
|
||
| 604 | */
|
||
| 605 | extern INA219Driver moduleLldPowerMonitorVio33;
|
||
| 606 | |||
| 607 | /**
|
||
| 608 | * @brief Power monitor (VSYS 4.2) driver.
|
||
| 609 | */
|
||
| 610 | extern INA219Driver moduleLldPowerMonitorVsys42;
|
||
| 611 | |||
| 612 | /**
|
||
| 613 | * @brief Power monitor (VIO 5.0) driver.
|
||
| 614 | */
|
||
| 615 | extern INA219Driver moduleLldPowerMonitorVio50;
|
||
| 616 | |||
| 617 | /**
|
||
| 618 | * @brief Status LED driver.
|
||
| 619 | */
|
||
| 620 | extern LEDDriver moduleLldStatusLed;
|
||
| 621 | |||
| 622 | /**
|
||
| 623 | * @brief Touch sensor driver.
|
||
| 624 | */
|
||
| 625 | extern MPR121Driver moduleLldTouch;
|
||
| 626 | |||
| 627 | /**
|
||
| 628 | * @brief I2C multiplexer (I2C 1) driver.
|
||
| 629 | */
|
||
| 630 | extern PCA9544ADriver moduleLldI2cMultiplexer1;
|
||
| 631 | |||
| 632 | /**
|
||
| 633 | * @brief I2C multiplexer (I2C 2) driver.
|
||
| 634 | */
|
||
| 635 | extern PCA9544ADriver moduleLldI2cMultiplexer2;
|
||
| 636 | |||
| 637 | /**
|
||
| 638 | * @brief Step down converter driver.
|
||
| 639 | * @note Although there multiple TPS62113, those are completely identical from driver few (share the same signals).
|
||
| 640 | */
|
||
| 641 | extern TPS62113Driver moduleLldStepDownConverter;
|
||
| 642 | |||
| 643 | /**
|
||
| 644 | * @brief Proximity sensor (I2C 1) driver.
|
||
| 645 | */
|
||
| 646 | extern VCNL4020Driver moduleLldProximity1;
|
||
| 647 | |||
| 648 | /**
|
||
| 649 | * @brief Proximity sensor (I2C 2) driver.
|
||
| 650 | */
|
||
| 651 | extern VCNL4020Driver moduleLldProximity2;
|
||
| 652 | |||
| 653 | /** @} */
|
||
| 654 | |||
| 655 | /*===========================================================================*/
|
||
| 656 | /**
|
||
| 657 | * @name Unit tests (UT)
|
||
| 658 | * @{
|
||
| 659 | */
|
||
| 660 | /*===========================================================================*/
|
||
| 661 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
| 662 | #include <ut_lld_adc.h> |
||
| 663 | #include <ut_alld_at24c01bn-sh-b.h> |
||
| 664 | #include <ut_alld_bq24103a.h> |
||
| 665 | #include <ut_alld_bq27500.h> |
||
| 666 | #include <ut_alld_bq27500_bq24103a.h> |
||
| 667 | #include <ut_alld_ina219.h> |
||
| 668 | #include <ut_alld_led.h> |
||
| 669 | #include <ut_alld_mpr121.h> |
||
| 670 | #include <ut_alld_pca9544a.h> |
||
| 671 | #include <ut_alld_pklcs1212e4001.h> |
||
| 672 | #include <ut_alld_tps62113.h> |
||
| 673 | #include <ut_alld_tps62113_ina219.h> |
||
| 674 | #include <ut_alld_vcnl4020.h> |
||
| 675 | |||
| 676 | /**
|
||
| 677 | * @brief ADC unit test object.
|
||
| 678 | */
|
||
| 679 | extern aos_unittest_t moduleUtAdcVsys;
|
||
| 680 | |||
| 681 | /**
|
||
| 682 | * @brief AT24C01BN-SH-B (EEPROM) unit test object.
|
||
| 683 | */
|
||
| 684 | extern aos_unittest_t moduleUtAlldAt24c01bn;
|
||
| 685 | |||
| 686 | /**
|
||
| 687 | * @brief BQ24103A (battery charger) unit test object.
|
||
| 688 | */
|
||
| 689 | extern aos_unittest_t moduleUtAlldBq24103a;
|
||
| 690 | |||
| 691 | /**
|
||
| 692 | * @brief BQ27500 (fuel gauge) unit test object.
|
||
| 693 | */
|
||
| 694 | extern aos_unittest_t moduleUtAlldBq27500;
|
||
| 695 | |||
| 696 | /**
|
||
| 697 | * @brief BQ27500 (fuela gauge) in combination with BQ24103A (battery charger) unit test object.
|
||
| 698 | */
|
||
| 699 | extern aos_unittest_t moduleUtAlldBq27500Bq24103a;
|
||
| 700 | |||
| 701 | /**
|
||
| 702 | * @brief INA219 (power monitor) unit test object.
|
||
| 703 | */
|
||
| 704 | extern aos_unittest_t moduleUtAlldIna219;
|
||
| 705 | |||
| 706 | /**
|
||
| 707 | * @brief Status LED unit test object.
|
||
| 708 | */
|
||
| 709 | extern aos_unittest_t moduleUtAlldLed;
|
||
| 710 | |||
| 711 | /**
|
||
| 712 | * @brief MPR121 (touch sensor) unit test object.
|
||
| 713 | */
|
||
| 714 | extern aos_unittest_t moduleUtAlldMpr121;
|
||
| 715 | |||
| 716 | /**
|
||
| 717 | * @brief PCA9544A (I2C multiplexer) unit test object.
|
||
| 718 | */
|
||
| 719 | extern aos_unittest_t moduleUtAlldPca9544a;
|
||
| 720 | |||
| 721 | /**
|
||
| 722 | * @brief PKLCS1212E4001 (buzzer) unit test object.
|
||
| 723 | */
|
||
| 724 | extern aos_unittest_t moduleUtAlldPklcs1212e4001;
|
||
| 725 | |||
| 726 | /**
|
||
| 727 | * @brief TPS62113 (step-down converter) unit test object.
|
||
| 728 | */
|
||
| 729 | extern aos_unittest_t moduleUtAlldTps62113;
|
||
| 730 | |||
| 731 | /**
|
||
| 732 | * @brief TPS62113 (step-sown converter) in combination with INA219 (power monitor) unit test object.
|
||
| 733 | */
|
||
| 734 | extern aos_unittest_t moduleUtAlldTps62113Ina219;
|
||
| 735 | |||
| 736 | /**
|
||
| 737 | * @brief VCNL4020 (proximity sensor) unit test object.
|
||
| 738 | */
|
||
| 739 | extern aos_unittest_t moduleUtAlldVcnl4020;
|
||
| 740 | |||
| 741 | #endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
||
| 742 | |||
| 743 | /** @} */
|
||
| 744 | |||
| 745 | #endif /* _AMIROOS_MODULE_H_ */ |