From fe5981589a77f47721138b1d1e07c93e5a750132 Mon Sep 17 00:00:00 2001 From: bjackson312006 Date: Fri, 24 Jan 2025 17:06:51 -0500 Subject: [PATCH] Moved pdu #defines to pdu.h since there were a lot --- Core/Inc/pdu.h | 51 +++++++++++++++++++++++++++++++++++++++++++++-- Core/Src/pdu.c | 54 +------------------------------------------------- 2 files changed, 50 insertions(+), 55 deletions(-) diff --git a/Core/Inc/pdu.h b/Core/Inc/pdu.h index 4796191..3ed2dcf 100644 --- a/Core/Inc/pdu.h +++ b/Core/Inc/pdu.h @@ -9,8 +9,6 @@ #include #include -#define SOUND_RTDS_FLAG 1U - typedef struct { I2C_HandleTypeDef *hi2c; osMutexId_t *mutex; @@ -126,4 +124,53 @@ extern const osThreadAttr_t rtds_attributes; */ int8_t read_brake_state(pdu_t *pdu, bool *status); +/* CTRL GPIO Expander */ +#define CTRL_ADDR PCA_I2C_ADDR_0 +#define PIN_PUMP_CTRL_0 0 // P00 +#define PIN_PUMP_CTRL_1 1 // P01 +#define PIN_24V_12V_BUCK_CTRL 2 // P02 +#define PIN_BRKLIGHT_CTRL 3 // P03 +#define PIN_FANBATTBOX_CTRL 4 // P04 +#define PIN_BATTBOX_FUSE_STAT 5 // P05 +#define PIN_LV_BOARDS_FUSE_STAT 6 // P06 +#define PIN_RADFAN_FUSE_STAT 7 // P07 +#define PIN_BUCK_FUSE_STAT 0 // P10 +#define PIN_FANBATTBOX_FUSE_STAT 1 // P11 +#define PIN_PUMP_FUSE_STAT0 2 // P12 +#define PIN_DASHBOARD_FUSE_STAT 3 // P13 +#define PIN_BRKLIGHT_FUSE_STAT 4 // P14 +#define PIN_SD_TO_BRB_FUSE_STAT 5 // P15 +#define PIN_PUMP_FUSE_STAT1 6 // P16 +#define PIN_RTDS_CTRL 7 // P17 + +/* Shutdown GPIO Expander */ +#define SHUTDOWN_ADDR PCA_I2C_ADDR_1 +#define PIN_CKPT_BRB_CLR 0 // P00 +#define PIN_BMS_GOOD 1 // P01 +#define PIN_INERTIA_SW_GOOD 2 // P02 +#define PIN_SPARE_GPIO1 3 // P03 +#define PIN_IMD_GOOD 4 // P04 +#define PIN_BSPD_GOOD 5 // P05 +#define PIN_SHUTDOWN_06 6 // P06 (X) +#define PIN_SHUTDOWN_07 7 // P07 (X) +#define PIN_SHUTDOWN_10 0 // P10 (X) +#define PIN_MC_STAT 1 // P11 +#define PIN_SPARE_MON 2 // P12 +#define PIN_SPARE_FAULT 3 // P13 +#define PIN_TSMS_SENSE 4 // P14 +#define PIN_BOTS_GOOD 5 // P15 +#define PIN_HVD_INTLK_GOOD 6 // P16 +#define PIN_HVC_INTLK_GOOD 7 // P17 + +/* Current Sensors */ +#define MOTOR_CONTROLLER_CURRENT_SENSOR_ADDR 0x40 +#define BATTBOX_FANS_CURRENT_SENSOR_ADDR 0x42 +#define PUMPS_CURRENT_SENSOR_ADDR 0x44 +#define LV_BOARDS_CURRENT_SENSOR_ADDR 0x45 + +/* Misc */ +#define MUTEX_TIMEOUT osWaitForever /* ms */ +#define RTDS_DURATION 1750 /* ms at 1kHz tick rate */ +#define SOUND_RTDS_FLAG 1U + #endif /* PDU_H */ diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index 7b1a7b3..9b3619f 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -5,62 +5,10 @@ #include #include -/* CTRL GPIO Expander */ -#define CTRL_ADDR PCA_I2C_ADDR_0 -// BANK 0 (Read with PCA_OUTPUT_0_REG or PCA_INPUT_0_REG): -#define PIN_PUMP_CTRL_0 0 // P00 -#define PIN_PUMP_CTRL_1 1 // P01 -#define PIN_24V_12V_BUCK_CTRL 2 // P02 -#define PIN_BRKLIGHT_CTRL 3 // P03 -#define PIN_FANBATTBOX_CTRL 4 // P04 -#define PIN_BATTBOX_FUSE_STAT 5 // P05 -#define PIN_LV_BOARDS_FUSE_STAT 6 // P06 -#define PIN_RADFAN_FUSE_STAT 7 // P07 -// BANK 1 (Read with PCA_OUTPUT_1_REG or PCA_INPUT_1_REG): -#define PIN_BUCK_FUSE_STAT 0 // P10 -#define PIN_FANBATTBOX_FUSE_STAT 1 // P11 -#define PIN_PUMP_FUSE_STAT0 2 // P12 -#define PIN_DASHBOARD_FUSE_STAT 3 // P13 -#define PIN_BRKLIGHT_FUSE_STAT 4 // P14 -#define PIN_SD_TO_BRB_FUSE_STAT 5 // P15 -#define PIN_PUMP_FUSE_STAT1 6 // P16 -#define PIN_RTDS_CTRL 7 // P17 - -/* Shutdown GPIO Expander */ -#define SHUTDOWN_ADDR PCA_I2C_ADDR_1 -// BANK 0 (Read with PCA_OUTPUT_0_REG or PCA_INPUT_0_REG): -#define PIN_CKPT_BRB_CLR 0 // P00 -#define PIN_BMS_GOOD 1 // P01 -#define PIN_INERTIA_SW_GOOD 2 // P02 -#define PIN_SPARE_GPIO1 3 // P03 -#define PIN_IMD_GOOD 4 // P04 -#define PIN_BSPD_GOOD 5 // P05 -#define PIN_SHUTDOWN_06 6 // P06 (X) -#define PIN_SHUTDOWN_07 7 // P07 (X) -// BANK 1 (Read with PCA_OUTPUT_1_REG or PCA_INPUT_1_REG): -#define PIN_SHUTDOWN_10 0 // P10 (X) -#define PIN_MC_STAT 1 // P11 -#define PIN_SPARE_MON 2 // P12 -#define PIN_SPARE_FAULT 3 // P13 -#define PIN_TSMS_SENSE 4 // P14 -#define PIN_BOTS_GOOD 5 // P15 -#define PIN_HVD_INTLK_GOOD 6 // P16 -#define PIN_HVC_INTLK_GOOD 7 // P17 - -/* Current Sensors */ -#define MOTOR_CONTROLLER_CURRENT_SENSOR_ADDR 0x40 -#define BATTBOX_FANS_CURRENT_SENSOR_ADDR 0x42 -#define PUMPS_CURRENT_SENSOR_ADDR 0x44 -#define LV_BOARDS_CURRENT_SENSOR_ADDR 0x45 - -/* Misc */ -#define MUTEX_TIMEOUT osWaitForever /* ms */ -#define RTDS_DURATION 1750 /* ms at 1kHz tick rate */ - static osMutexAttr_t pdu_mutex_attributes; extern I2C_HandleTypeDef hi2c2; -/* Wrappers for GPIO Expander I2C */ +/* Wrappers for PCA9539 (GPIO Expander) */ static inline uint8_t pca_i2c_write(uint16_t dev_address, uint8_t reg, uint8_t *data, uint8_t length) {