diff --git a/Core/Inc/cerberus_conf.h b/Core/Inc/cerberus_conf.h index 8ad289c..047a8d9 100644 --- a/Core/Inc/cerberus_conf.h +++ b/Core/Inc/cerberus_conf.h @@ -74,5 +74,7 @@ #define CANID_LV_MONITOR 0x503 #define CANID_PEDALS_ACCEL_MSG 0x504 #define CANID_PEDALS_BRAKE_MSG 0x505 +#define CANID_PDU_CURRENT 0x508 +#define CANID_PUMP_SENSORS 0x509 // Reserved for MPU debug message, see yaml for format #define CANID_EXTRA_MSG 0x701 \ No newline at end of file diff --git a/Core/Inc/fault.h b/Core/Inc/fault.h index 15129bc..c3bd93e 100644 --- a/Core/Inc/fault.h +++ b/Core/Inc/fault.h @@ -30,7 +30,9 @@ typedef enum { BSPD_PREFAULT = (1 << 14), LV_MONITOR_FAULT = (1 << 15), RTDS_FAULT = (1 << 16), - MAX_FAULTS = (1 << 17) + PDU_CURRENT_FAULT = (1 << 17), + PUMP_SENSORS_FAULT = (1 << 18), + MAX_FAULTS = (1 << 19) } fault_code_t; typedef struct { diff --git a/Core/Inc/pdu.h b/Core/Inc/pdu.h index fcaff1a..3ed2dcf 100644 --- a/Core/Inc/pdu.h +++ b/Core/Inc/pdu.h @@ -2,37 +2,51 @@ #define PDU_H #include - +#include "fault.h" #include "cmsis_os.h" #include "pca9539.h" - -#define SOUND_RTDS_FLAG 1U +#include "INA226.h" +#include +#include typedef struct { + I2C_HandleTypeDef *hi2c; osMutexId_t *mutex; pca9539_t *shutdown_expander; pca9539_t *ctrl_expander; + + ina226_t *motor_controller_current_sensor; + ina226_t *battbox_fans_current_sensor; + ina226_t *pumps_current_sensor; + ina226_t *lv_boards_current_sensor; + + ADC_HandleTypeDef *pump_sensors_adc; + uint32_t pump_sensors_dma_buf[2]; } pdu_t; /* Creates a new PDU interface */ -pdu_t *init_pdu(); +pdu_t *init_pdu(I2C_HandleTypeDef *hi2c, ADC_HandleTypeDef *pump_sensors_adc); /* Functions to Control PDU */ -int8_t write_pump(pdu_t *pdu, bool status); -int8_t write_brakelight(pdu_t *pdu, bool status); -int8_t write_fan_battbox(pdu_t *pdu, bool status); +int8_t write_pump_0(pdu_t *pdu, bool state); +int8_t write_pump_1(pdu_t *pdu, bool state); +int8_t write_24V_12V_buck(pdu_t *pdu, bool state); +int8_t write_brakelight(pdu_t *pdu, bool state); +int8_t write_fan_battbox(pdu_t *pdu, bool state); +int8_t write_rtds(pdu_t *pdu, bool state); /* Function to Read the Status of Fuses from PDU */ typedef enum { - FUSE_BATTBOX, - FUSE_LVBOX, - FUSE_FAN_RADIATOR, - FUSE_MC, - FUSE_FAN_BATTBOX, - FUSE_PUMP, - FUSE_DASHBOARD, - FUSE_BRAKELIGHT, - FUSE_BRB, + BATTBOX_FUSE_STAT, + LV_BOARDS_FUSE_STAT, + RADFAN_FUSE_STAT, + BUCK_FUSE_STAT, + FANBATTBOX_FUSE_STAT, + PUMP_FUSE_STAT0, + DASHBOARD_FUSE_STAT, + BRKLIGHT_FUSE_STAT, + SD_TO_BRB_FUSE_STAT, + PUMP_FUSE_STAT1, MAX_FUSES } fuse_t; @@ -57,14 +71,14 @@ int8_t read_tsms_sense(pdu_t *pdu, bool *status); /* Functions to Read Status of Various Stages of Shutdown Loop */ typedef enum { CKPT_BRB_CLR, /* Cockpit BRB */ - BMS_OK, /* Battery Management System (Shepherd) */ - INERTIA_SW_OK, /* Inertia Switch */ - SPARE_GPIO1_OK, - IMD_OK, /* Insulation Monitoring Device */ - BSPD_OK, /* Brake System Plausbility Device */ - BOTS_OK, /* Brake Over Travel Switch */ - HVD_INTLK_OK, /* HVD Interlock */ - HVC_INTLK_OK, /* HV C Interlock*/ + BMS_GOOD, /* Battery Management System (Shepherd) */ + INERTIA_SW_GOOD, /* Inertia Switch */ + SPARE_GPIO1, + IMD_GOOD, /* Insulation Monitoring Device */ + BSPD_GOOD, /* Brake System Plausbility Device */ + BOTS_GOOD, /* Brake Over Travel Switch */ + HVD_INTLK_GOOD, /* HVD Interlock */ + HVC_INTLK_GOOD, /* HV C Interlock*/ //SIDE_BRB_CLR, /* Side BRB */ //TSMS, /* Tractive System Main Switch */ MAX_SHUTDOWN_STAGES @@ -79,6 +93,19 @@ typedef enum { */ int8_t read_shutdown(pdu_t *pdu, bool status[MAX_SHUTDOWN_STAGES]); +/** + * @brief Read the status of the shutdown loop. + * + * @param pdu Pointer to struct representing the PDU + * @param status Buffer that the data from both sensors will be written to + */ +void read_pump_sensors(pdu_t *pdu, uint32_t pump_sensors_buf[2]); + +// Function for reading current +int8_t read_all_current(pdu_t *pdu, float *motor_controller_current, + float *battbox_fans_current, float *pumps_current, + float *lv_boards_current); + /** * @brief Taskf for sounding RTDS. * @@ -97,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/main.c b/Core/Src/main.c index a17fd52..e6bf780 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -58,8 +58,10 @@ /* Private variables ---------------------------------------------------------*/ ADC_HandleTypeDef hadc1; +ADC_HandleTypeDef hadc2; ADC_HandleTypeDef hadc3; DMA_HandleTypeDef hdma_adc1; +DMA_HandleTypeDef hdma_adc2; DMA_HandleTypeDef hdma_adc3; CAN_HandleTypeDef hcan1; @@ -95,6 +97,7 @@ static void MX_ADC1_Init(void); static void MX_USART3_UART_Init(void); static void MX_ADC3_Init(void); static void MX_IWDG_Init(void); +static void MX_ADC2_Init(void); void StartDefaultTask(void *argument); /* USER CODE BEGIN PFP */ @@ -164,12 +167,13 @@ int main(void) MX_USART3_UART_Init(); MX_ADC3_Init(); MX_IWDG_Init(); + MX_ADC2_Init(); /* USER CODE BEGIN 2 */ /* Create Interfaces to Represent Relevant Hardware */ mpu_t *mpu = init_mpu(&hadc3, &hadc1, GPIOC, GPIOB); assert(mpu); - pdu_t *pdu = init_pdu(&hi2c2); + pdu_t *pdu = init_pdu(&hi2c2, &hadc2); assert(pdu); dti_t *mc = dti_init(); assert(mc); @@ -364,6 +368,66 @@ static void MX_ADC1_Init(void) } +/** + * @brief ADC2 Initialization Function + * @param None + * @retval None + */ +static void MX_ADC2_Init(void) +{ + + /* USER CODE BEGIN ADC2_Init 0 */ + + /* USER CODE END ADC2_Init 0 */ + + ADC_ChannelConfTypeDef sConfig = {0}; + + /* USER CODE BEGIN ADC2_Init 1 */ + + /* USER CODE END ADC2_Init 1 */ + + /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) + */ + hadc2.Instance = ADC2; + hadc2.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV6; + hadc2.Init.Resolution = ADC_RESOLUTION_12B; + hadc2.Init.ScanConvMode = ENABLE; + hadc2.Init.ContinuousConvMode = ENABLE; + hadc2.Init.DiscontinuousConvMode = DISABLE; + hadc2.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; + hadc2.Init.ExternalTrigConv = ADC_SOFTWARE_START; + hadc2.Init.DataAlign = ADC_DATAALIGN_RIGHT; + hadc2.Init.NbrOfConversion = 2; + hadc2.Init.DMAContinuousRequests = ENABLE; + hadc2.Init.EOCSelection = ADC_EOC_SINGLE_CONV; + if (HAL_ADC_Init(&hadc2) != HAL_OK) + { + Error_Handler(); + } + + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_10; + sConfig.Rank = 1; + sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES; + if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK) + { + Error_Handler(); + } + + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Rank = 2; + if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN ADC2_Init 2 */ + + /* USER CODE END ADC2_Init 2 */ + +} + /** * @brief ADC3 Initialization Function * @param None diff --git a/Core/Src/monitor.c b/Core/Src/monitor.c index 12ffec3..3c97f71 100644 --- a/Core/Src/monitor.c +++ b/Core/Src/monitor.c @@ -15,6 +15,81 @@ static bool tsms = false; osMutexId_t tsms_mutex; +/** + * @brief Read voltage of Pump Sensors and send a CAN message with the result. + */ +void read_pump_sens(pdu_t *pdu) +{ + // put fault stuff tomorrow + fault_data_t fault_data = { .id = PUMP_SENSORS_FAULT, + .severity = DEFCON5 }; + can_msg_t msg = { .id = CANID_PUMP_SENSORS, .len = 8, .data = { 0 } }; + + uint32_t pump_volts_int[2]; + + read_pump_sensors(pdu, pump_volts_int); + + // convert to real voltage + float pump_sensor0_volts_real = (pump_volts_int[0] / 4095.0) * 3.3; + float pump_sensor1_volts_real = (pump_volts_int[1] / 4095.0) * 3.3; + + pump_volts_int[0] = (uint32_t)(pump_sensor0_volts_real * 10000); + pump_volts_int[1] = (uint32_t)(pump_sensor1_volts_real * 10000); + + memcpy(msg.data, pump_volts_int, msg.len); + if (queue_can_msg(msg)) { + fault_data.diag = "Failed to send pump sensor CAN message"; + queue_fault(&fault_data); + } +} + +/** + * @brief Read current of MC, battox fans, pumps, and LV boards and send a CAN message with the result. + */ +void read_current(pdu_t *pdu) +{ + fault_data_t fault_data = { .id = PDU_CURRENT_FAULT, + .severity = DEFCON5 }; + can_msg_t msg = { .id = CANID_PDU_CURRENT, .len = 8, .data = { 0 } }; + + float motor_controller_current; + float battbox_fans_current; + float pumps_current; + float lv_boards_current; + + if (read_all_current(pdu, &motor_controller_current, + &battbox_fans_current, &pumps_current, + &lv_boards_current)) { + fault_data.diag = "Failed to read current"; + queue_fault(&fault_data); + } + + uint16_t int_motor_controller_current = + (uint16_t)(motor_controller_current * 1000); + uint16_t int_battbox_fans_current = + (uint16_t)(battbox_fans_current * 1000); + uint16_t int_pumps_current = (uint16_t)(pumps_current * 1000); + uint16_t int_lv_boards_current = (uint16_t)(lv_boards_current * 1000); + + struct __attribute__((__packed__)) { + uint16_t motor_controller; + uint16_t battbox_fans; + uint16_t pumps_current; + uint16_t lv_boards; + } current_data; + + current_data.motor_controller = int_motor_controller_current; + current_data.battbox_fans = int_battbox_fans_current; + current_data.pumps_current = int_pumps_current; + current_data.lv_boards = int_lv_boards_current; + + memcpy(msg.data, ¤t_data, msg.len); + if (queue_can_msg(msg)) { + fault_data.diag = "Failed to send current CAN message"; + queue_fault(&fault_data); + } +} + /** * @brief Read the open cell voltage of the LV batteries and send a CAN message with the result. */ @@ -138,6 +213,7 @@ void vNonFunctionalDataCollection(void *pv_params) for (;;) { read_lv_sense(mpu); read_fuse_data(pdu); + read_current(pdu); /* delay for 1000 ms (1k ticks at 1000 Hz tickrate) */ osDelay(1000); diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index 1b5330d..9b3619f 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -1,41 +1,20 @@ #include "pdu.h" - +#include "fault.h" #include #include #include - -#include "fault.h" - -#define PUMP_CTRL 0 -#define RADFAN_CTRL 1 -#define BRKLIGHT_CTRL 2 -#define BATBOXFAN_CTRL 3 -#define RTDS_CTRL 7 // PORT 17 BANK 1 (so read with 1_REG) -// #define TSMS_CTRL 0x04 -// #define SMBALERT 0x05 -#define MUTEX_TIMEOUT osWaitForever /* ms */ - -#define SHUTDOWN_ADDR PCA_I2C_ADDR_3 -#define CTRL_ADDR PCA_I2C_ADDR_2 -#define RTDS_DURATION 1750 /* ms at 1kHz tick rate */ +#include static osMutexAttr_t pdu_mutex_attributes; - -//hi2c2 variable to pass to the function wrappers (defined in main.c) extern I2C_HandleTypeDef hi2c2; -//Function wrapper for the STM specific HAL write function -//Serves as function pointer for PCA PAL +/* 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) - { return HAL_I2C_Mem_Write(&hi2c2, dev_address, reg, I2C_MEMADD_SIZE_8BIT, data, length, HAL_MAX_DELAY); } - -//Function wrapper for the STM specific HAL read function -//Serves as function pointer for PCA PAL static inline uint8_t pca_i2c_read(uint16_t dev_address, uint8_t reg, uint8_t *data, uint8_t length) { @@ -43,44 +22,34 @@ static inline uint8_t pca_i2c_read(uint16_t dev_address, uint8_t reg, data, length, HAL_MAX_DELAY); } -static uint8_t sound_rtds(pdu_t *pdu) +/* Wrappers for Current Sensor Read & Write */ +static inline int ina_read_reg(uint16_t dev_addr, uint8_t reg, uint16_t *data) { - if (!pdu) - return -1; - - osStatus_t stat = osMutexAcquire(pdu->mutex, MUTEX_TIMEOUT); - if (stat) - return stat; + uint8_t buff[2]; + HAL_StatusTypeDef status; - /* write RTDS over i2c */ - HAL_StatusTypeDef error = pca9539_write_pin( - pdu->ctrl_expander, PCA_OUTPUT_1_REG, RTDS_CTRL, true); - if (error != HAL_OK) { - osMutexRelease(pdu->mutex); - return error; + status = HAL_I2C_Mem_Read(&hi2c2, dev_addr, reg, I2C_MEMADD_SIZE_16BIT, + buff, 2, HAL_MAX_DELAY); + if (status != HAL_OK) { + return -1; } - osMutexRelease(pdu->mutex); - + *data = (buff[0] << 8) | buff[1]; return 0; } - -static uint8_t rtds_shutoff(void *pv_params) +static inline int ina_write_reg(uint16_t dev_addr, uint8_t reg, uint16_t *data) { - pdu_t *pdu = (pdu_t *)pv_params; - osStatus_t stat = osMutexAcquire(pdu->mutex, MUTEX_TIMEOUT); - if (stat) - return stat; + uint8_t buff[2]; + buff[0] = (*data >> 8) & 0xFF; + buff[1] = *data & 0xFF; - /* write RTDS over i2c */ - HAL_StatusTypeDef error = pca9539_write_pin( - pdu->ctrl_expander, PCA_OUTPUT_1_REG, RTDS_CTRL, false); - if (error != HAL_OK) { - osMutexRelease(pdu->mutex); - return error; + HAL_StatusTypeDef status; + status = HAL_I2C_Mem_Write(&hi2c2, dev_addr, reg, I2C_MEMADD_SIZE_16BIT, + buff, 2, HAL_MAX_DELAY); + if (status != HAL_OK) { + return -1; } - osMutexRelease(pdu->mutex); return 0; } @@ -100,58 +69,113 @@ void vRTDS(void *arg) for (;;) { osThreadFlagsWait(SOUND_RTDS_FLAG, osFlagsWaitAny, osWaitForever); - if (sound_rtds(pdu)) { + if (write_rtds(pdu, true)) { rtds_fault.diag = "Unable to sound RTDS"; queue_fault(&rtds_fault); } osDelay(RTDS_DURATION); - if (rtds_shutoff(pdu)) { + if (write_rtds(pdu, false)) { rtds_fault.diag = "Unable to stop RTDS"; queue_fault(&rtds_fault); } } } -pdu_t *init_pdu() +pdu_t *init_pdu(I2C_HandleTypeDef *hi2c, ADC_HandleTypeDef *pump_sensors_adc) { - /* Create PDU struct */ pdu_t *pdu = malloc(sizeof(pdu_t)); assert(pdu); + pdu->hi2c = hi2c; + pdu->pump_sensors_adc = pump_sensors_adc; + assert(!HAL_ADC_Start_DMA( + pdu->pump_sensors_adc, pdu->pump_sensors_dma_buf, + sizeof(pdu->pump_sensors_dma_buf) / sizeof(uint32_t))); + + // FOR ALL 4 CURRENT SENSORS: Callibration constants taken from Altium on 11/6/24 + /* Initialize Motor Controller Current Sensor */ + pdu->motor_controller_current_sensor = malloc(sizeof(ina226_t)); + assert(pdu->motor_controller_current_sensor); + ina226_init(pdu->motor_controller_current_sensor, ina_write_reg, + ina_read_reg, MOTOR_CONTROLLER_CURRENT_SENSOR_ADDR); + int status_init = ina226_calibrate(pdu->motor_controller_current_sensor, + 0.01f, 3.0f); + if (status_init != 0) { + printf("\n\rmotor controller current sensor init fail\n\r"); + free(pdu->motor_controller_current_sensor); + free(pdu); + return NULL; + } + + /* Initialize Battbox Fans Current Sensor */ + pdu->battbox_fans_current_sensor = malloc(sizeof(ina226_t)); + assert(pdu->battbox_fans_current_sensor); + ina226_init(pdu->battbox_fans_current_sensor, ina_write_reg, + ina_read_reg, BATTBOX_FANS_CURRENT_SENSOR_ADDR); + status_init = + ina226_calibrate(pdu->battbox_fans_current_sensor, 0.01f, 5.0f); + if (status_init != 0) { + printf("\n\rbattbox fans current sensor init fail\n\r"); + free(pdu->battbox_fans_current_sensor); + free(pdu); + return NULL; + } + + /* Initialize Pumps Current Sensor */ + pdu->pumps_current_sensor = malloc(sizeof(ina226_t)); + assert(pdu->pumps_current_sensor); + ina226_init(pdu->pumps_current_sensor, ina_write_reg, ina_read_reg, + PUMPS_CURRENT_SENSOR_ADDR); + status_init = ina226_calibrate(pdu->pumps_current_sensor, 0.01f, 2.0f); + if (status_init != 0) { + printf("\n\rpumps current sensor init fail\n\r"); + free(pdu->pumps_current_sensor); + free(pdu); + return NULL; + } + + /* Initialize LV Boards Current Sensor */ + pdu->lv_boards_current_sensor = malloc(sizeof(ina226_t)); + assert(pdu->lv_boards_current_sensor); + ina226_init(pdu->lv_boards_current_sensor, ina_write_reg, ina_read_reg, + LV_BOARDS_CURRENT_SENSOR_ADDR); + status_init = + ina226_calibrate(pdu->lv_boards_current_sensor, 0.01f, 1.25f); + if (status_init != 0) { + printf("\n\rlv boards current sensor init fail\n\r"); + free(pdu->lv_boards_current_sensor); + free(pdu); + return NULL; + } /* Initialize Shutdown GPIO Expander */ pdu->shutdown_expander = malloc(sizeof(pca9539_t)); assert(pdu->shutdown_expander); - // pca9539_init(pdu->shutdown_expander, pdu->hi2c, SHUTDOWN_ADDR); - // if (status != HAL_OK) { - // printf("\n\rshutdown init fail\n\r"); - // free(pdu->shutdown_expander); - // free(pdu); - // return NULL; - // } + pca9539_init(pdu->shutdown_expander, pca_i2c_write, pca_i2c_read, + SHUTDOWN_ADDR); // all shutdown expander things are inputs - // uint8_t shutdown_config_directions = 0b00000000; - // HAL_StatusTypeDef status = pca9539_write_reg(pdu->shutdown_expander, PCA_DIRECTION_0_REG, - // shutdown_config_directions); - // if (status != HAL_OK) { - // printf("\n\rshutdown write fail\n\r"); - // free(pdu->shutdown_expander); - // free(pdu); - // return NULL; - // } - // status - // = pca9539_write_reg(pdu->shutdown_expander, PCA_DIRECTION_1_REG, - // shutdown_config_directions); if (status != HAL_OK) { printf("\n\rshutdown wrtie 2 fail\n\r"); - // free(pdu->shutdown_expander); - // free(pdu); - // return NULL; - // } + uint8_t shutdown_config_directions = 0b00000000; + HAL_StatusTypeDef status = + pca9539_write_reg(pdu->shutdown_expander, PCA_DIRECTION_0_REG, + shutdown_config_directions); + if (status != HAL_OK) { + printf("\n\rshutdown write fail\n\r"); + free(pdu->shutdown_expander); + free(pdu); + return NULL; + } + status = pca9539_write_reg(pdu->shutdown_expander, PCA_DIRECTION_1_REG, + shutdown_config_directions); + if (status != HAL_OK) { + printf("\n\rshutdown wrtie 2 fail\n\r"); + free(pdu->shutdown_expander); + free(pdu); + return NULL; + } /* Initialize Control GPIO Expander */ pdu->ctrl_expander = malloc(sizeof(pca9539_t)); assert(pdu->ctrl_expander); - - //NEED pca9539_init(pdu->ctrl_expander, pca_i2c_write, pca_i2c_read, CTRL_ADDR); @@ -162,7 +186,7 @@ pdu_t *init_pdu() // pin 0 to the right buf = 0b11110000; - HAL_StatusTypeDef status = + status = pca9539_write_reg(pdu->ctrl_expander, PCA_DIRECTION_0_REG, buf); if (status != HAL_OK) { printf("cntrl init fail\n"); @@ -188,20 +212,19 @@ pdu_t *init_pdu() return pdu; } -int8_t write_pump(pdu_t *pdu, bool status) +/* CTRL Line Functions */ +static int8_t write_ctrl(pdu_t *pdu, bool state, uint8_t pin, uint8_t reg) { if (!pdu) return -1; - osStatus_t stat = osMutexAcquire(pdu->mutex, osWaitForever); - if (stat) { - osMutexRelease(pdu->mutex); + osStatus_t stat = osMutexAcquire(pdu->mutex, MUTEX_TIMEOUT); + if (stat) return stat; - } - /* write pump over i2c */ - HAL_StatusTypeDef error = pca9539_write_pin( - pdu->ctrl_expander, PCA_OUTPUT_0_REG, PUMP_CTRL, status); + HAL_StatusTypeDef error = + pca9539_write_pin(pdu->ctrl_expander, reg, pin, state); + if (error != HAL_OK) { osMutexRelease(pdu->mutex); return error; @@ -211,46 +234,41 @@ int8_t write_pump(pdu_t *pdu, bool status) return 0; } -int8_t write_brakelight(pdu_t *pdu, bool status) +int8_t write_pump_0(pdu_t *pdu, bool state) { - if (!pdu) - return -1; - - osStatus_t stat = osMutexAcquire(pdu->mutex, MUTEX_TIMEOUT); - if (stat) - return stat; + return write_ctrl(pdu, state, PIN_PUMP_CTRL_0, PCA_OUTPUT_0_REG); +} - /* write brakelight over i2c */ - HAL_StatusTypeDef error = pca9539_write_pin( - pdu->ctrl_expander, PCA_OUTPUT_0_REG, BRKLIGHT_CTRL, status); - if (error != HAL_OK) { - osMutexRelease(pdu->mutex); - return error; - } +int8_t write_pump_1(pdu_t *pdu, bool state) +{ + return write_ctrl(pdu, state, PIN_PUMP_CTRL_1, PCA_OUTPUT_0_REG); +} - osMutexRelease(pdu->mutex); - return 0; +int8_t write_24V_12V_buck(pdu_t *pdu, bool state) +{ + return write_ctrl(pdu, state, PIN_24V_12V_BUCK_CTRL, PCA_OUTPUT_0_REG); } -int8_t write_fan_battbox(pdu_t *pdu, bool status) +int8_t write_brakelight(pdu_t *pdu, bool state) { - if (!pdu) - return -1; + return write_ctrl(pdu, state, PIN_BRKLIGHT_CTRL, PCA_OUTPUT_0_REG); +} - osStatus_t stat = osMutexAcquire(pdu->mutex, MUTEX_TIMEOUT); - if (stat) - return stat; +int8_t write_fan_battbox(pdu_t *pdu, bool state) +{ + return write_ctrl(pdu, state, PIN_FANBATTBOX_CTRL, PCA_OUTPUT_0_REG); +} - /* write fan over i2c */ - HAL_StatusTypeDef error = pca9539_write_pin( - pdu->ctrl_expander, PCA_OUTPUT_0_REG, 2, status); - if (error != HAL_OK) { - osMutexRelease(pdu->mutex); - return error; - } +int8_t write_rtds(pdu_t *pdu, bool state) +{ + return write_ctrl(pdu, state, PIN_RTDS_CTRL, PCA_OUTPUT_1_REG); +} - osMutexRelease(pdu->mutex); - return 0; +/* Read Pump Sensors ADC DMA */ +void read_pump_sensors(pdu_t *pdu, uint32_t pump_sensors_buf[2]) +{ + memcpy(pump_sensors_buf, &pdu->pump_sensors_dma_buf, + sizeof(pdu->pump_sensors_dma_buf)); } static void deconstruct_buf(uint8_t data, bool config[8]) @@ -290,15 +308,16 @@ int8_t read_fuses(pdu_t *pdu, bool status[MAX_FUSES]) bool bank1[8]; deconstruct_buf(bank1_d, bank1); - status[FUSE_BATTBOX] = bank0[4]; - status[FUSE_LVBOX] = bank0[5]; - status[FUSE_FAN_RADIATOR] = bank0[6]; - status[FUSE_MC] = bank0[7]; - status[FUSE_FAN_BATTBOX] = bank1[0]; - status[FUSE_PUMP] = bank1[1]; - status[FUSE_DASHBOARD] = bank1[2]; - status[FUSE_BRAKELIGHT] = bank1[3]; - status[FUSE_BRB] = bank1[4]; + status[BATTBOX_FUSE_STAT] = bank0[PIN_BATTBOX_FUSE_STAT]; + status[LV_BOARDS_FUSE_STAT] = bank0[PIN_LV_BOARDS_FUSE_STAT]; + status[RADFAN_FUSE_STAT] = bank0[PIN_RADFAN_FUSE_STAT]; + status[BUCK_FUSE_STAT] = bank1[PIN_BUCK_FUSE_STAT]; + status[FANBATTBOX_FUSE_STAT] = bank1[PIN_FANBATTBOX_FUSE_STAT]; + status[PUMP_FUSE_STAT0] = bank1[PIN_PUMP_FUSE_STAT0]; + status[DASHBOARD_FUSE_STAT] = bank1[PIN_DASHBOARD_FUSE_STAT]; + status[BRKLIGHT_FUSE_STAT] = bank1[PIN_BRKLIGHT_FUSE_STAT]; + status[SD_TO_BRB_FUSE_STAT] = bank1[PIN_SD_TO_BRB_FUSE_STAT]; + status[PUMP_FUSE_STAT1] = bank1[PIN_PUMP_FUSE_STAT1]; osMutexRelease(pdu->mutex); return 0; @@ -314,10 +333,10 @@ int8_t read_tsms_sense(pdu_t *pdu, bool *status) return stat; /* read pin over i2c */ - uint8_t tsms_pin = 6; uint8_t config = 0; - HAL_StatusTypeDef error = pca9539_read_pin( - pdu->ctrl_expander, PCA_INPUT_1_REG, tsms_pin, &config); + HAL_StatusTypeDef error = pca9539_read_pin(pdu->shutdown_expander, + PCA_INPUT_1_REG, + PIN_TSMS_SENSE, &config); if (error != HAL_OK) { osMutexRelease(pdu->mutex); return error; @@ -358,20 +377,62 @@ int8_t read_shutdown(pdu_t *pdu, bool status[MAX_SHUTDOWN_STAGES]) bool bank1[8]; deconstruct_buf(bank1_d, bank1); - status[CKPT_BRB_CLR] = bank0[0]; - status[BMS_OK] = bank0[2]; - status[INERTIA_SW_OK] = bank0[3]; - status[SPARE_GPIO1_OK] = bank0[4]; - status[IMD_OK] = bank0[5]; - status[BSPD_OK] = bank1[0]; - status[BOTS_OK] = bank1[5]; - status[HVD_INTLK_OK] = bank1[6]; - status[HVC_INTLK_OK] = bank1[7]; + status[CKPT_BRB_CLR] = bank0[PIN_CKPT_BRB_CLR]; + status[BMS_GOOD] = bank0[PIN_BMS_GOOD]; + status[INERTIA_SW_GOOD] = bank0[PIN_INERTIA_SW_GOOD]; + status[SPARE_GPIO1] = bank0[PIN_SPARE_GPIO1]; + status[IMD_GOOD] = bank0[PIN_IMD_GOOD]; + status[BSPD_GOOD] = bank0[PIN_BSPD_GOOD]; + status[BOTS_GOOD] = bank1[PIN_BOTS_GOOD]; + status[HVD_INTLK_GOOD] = bank1[PIN_HVD_INTLK_GOOD]; + status[HVC_INTLK_GOOD] = bank1[PIN_HVC_INTLK_GOOD]; + + osMutexRelease(pdu->mutex); + return 0; +} + +static int8_t read_current(pdu_t *pdu, ina226_t *ina, float *data) +{ + if (!pdu || !ina || !data) + return -1; + + float current; + + osStatus_t stat = osMutexAcquire(pdu->mutex, MUTEX_TIMEOUT); + if (stat) + return stat; + + int status = ina226_read_current(ina, ¤t); + if (status != 0) { + osMutexRelease(pdu->mutex); + return status; + } + + *data = current; osMutexRelease(pdu->mutex); return 0; } +int8_t read_all_current(pdu_t *pdu, float *motor_controller_current, + float *battbox_fans_current, float *pumps_current, + float *lv_boards_current) +{ + if (!read_current(pdu, pdu->motor_controller_current_sensor, + motor_controller_current)) + return -1; + if (!read_current(pdu, pdu->battbox_fans_current_sensor, + battbox_fans_current)) + return -1; + if (!read_current(pdu, pdu->pumps_current_sensor, + motor_controller_current)) + return -1; + if (!read_current(pdu, pdu->lv_boards_current_sensor, + battbox_fans_current)) + return -1; + return 0; +} + int8_t read_brake_state(pdu_t *pdu, bool *status) { if (!pdu) @@ -383,8 +444,9 @@ int8_t read_brake_state(pdu_t *pdu, bool *status) /* read pin over i2c */ uint8_t config = 0; - HAL_StatusTypeDef error = pca9539_read_pin( - pdu->ctrl_expander, PCA_INPUT_1_REG, BRKLIGHT_CTRL, &config); + HAL_StatusTypeDef error = pca9539_read_pin(pdu->ctrl_expander, + PCA_INPUT_1_REG, + PIN_BRKLIGHT_CTRL, &config); if (error != HAL_OK) { osMutexRelease(pdu->mutex); return error; diff --git a/Core/Src/state_machine.c b/Core/Src/state_machine.c index 1ee7c77..a065b17 100644 --- a/Core/Src/state_machine.c +++ b/Core/Src/state_machine.c @@ -96,7 +96,8 @@ static int transition_functional_state(func_state_t new_state, pdu_t *pdu, /* Turn off high power peripherals */ // write_fan_battbox(pdu, false); - write_pump(pdu, false); + write_pump_0(pdu, false); + write_pump_1(pdu, false); write_fault(mpu, false); printf("READY\r\n"); break; @@ -128,7 +129,8 @@ static int transition_functional_state(func_state_t new_state, pdu_t *pdu, /* Turn on high power peripherals */ // write_fan_battbox(pdu, true); - write_pump(pdu, true); + write_pump_0(pdu, true); + write_pump_1(pdu, true); write_fault(mpu, false); printf("ACTIVE STATE\r\n"); break; @@ -140,7 +142,8 @@ static int transition_functional_state(func_state_t new_state, pdu_t *pdu, case FAULTED: /* Turn off high power peripherals */ // write_fan_battbox(pdu, true); - write_pump(pdu, false); + write_pump_0(pdu, false); + write_pump_1(pdu, false); cerberus_state.nero = (nero_state_t){ .nero_index = OFF, .home_mode = false }; @@ -322,7 +325,8 @@ void vStateMachineDirector(void *pv_params) free(args); /* Write to GPIO expander to set initial state */ - write_pump(pdu, false); + write_pump_0(pdu, false); + write_pump_1(pdu, false); write_fault(mpu, false); for (;;) { diff --git a/Core/Src/stm32f4xx_hal_msp.c b/Core/Src/stm32f4xx_hal_msp.c index dc232b7..7804171 100644 --- a/Core/Src/stm32f4xx_hal_msp.c +++ b/Core/Src/stm32f4xx_hal_msp.c @@ -25,6 +25,8 @@ /* USER CODE END Includes */ extern DMA_HandleTypeDef hdma_adc1; +extern DMA_HandleTypeDef hdma_adc2; + extern DMA_HandleTypeDef hdma_adc3; extern DMA_HandleTypeDef hdma_usart3_tx; @@ -140,6 +142,47 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) /* USER CODE END ADC1_MspInit 1 */ } + else if(hadc->Instance==ADC2) + { + /* USER CODE BEGIN ADC2_MspInit 0 */ + + /* USER CODE END ADC2_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_ADC2_CLK_ENABLE(); + + __HAL_RCC_GPIOC_CLK_ENABLE(); + /**ADC2 GPIO Configuration + PC0 ------> ADC2_IN10 + PC1 ------> ADC2_IN11 + */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* ADC2 DMA Init */ + /* ADC2 Init */ + hdma_adc2.Instance = DMA2_Stream2; + hdma_adc2.Init.Channel = DMA_CHANNEL_1; + hdma_adc2.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_adc2.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_adc2.Init.MemInc = DMA_MINC_ENABLE; + hdma_adc2.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; + hdma_adc2.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; + hdma_adc2.Init.Mode = DMA_CIRCULAR; + hdma_adc2.Init.Priority = DMA_PRIORITY_LOW; + hdma_adc2.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_adc2) != HAL_OK) + { + Error_Handler(); + } + + __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc2); + + /* USER CODE BEGIN ADC2_MspInit 1 */ + + /* USER CODE END ADC2_MspInit 1 */ + } else if(hadc->Instance==ADC3) { /* USER CODE BEGIN ADC3_MspInit 0 */ @@ -216,6 +259,26 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) /* USER CODE END ADC1_MspDeInit 1 */ } + else if(hadc->Instance==ADC2) + { + /* USER CODE BEGIN ADC2_MspDeInit 0 */ + + /* USER CODE END ADC2_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_ADC2_CLK_DISABLE(); + + /**ADC2 GPIO Configuration + PC0 ------> ADC2_IN10 + PC1 ------> ADC2_IN11 + */ + HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0|GPIO_PIN_1); + + /* ADC2 DMA DeInit */ + HAL_DMA_DeInit(hadc->DMA_Handle); + /* USER CODE BEGIN ADC2_MspDeInit 1 */ + + /* USER CODE END ADC2_MspDeInit 1 */ + } else if(hadc->Instance==ADC3) { /* USER CODE BEGIN ADC3_MspDeInit 0 */ diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index e02f66b..e31e9ad 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit e02f66b5d6d92f0a04aae5957a11f973e6a018db +Subproject commit e31e9ad7efa8952131e436fc17a25935f055d3b4 diff --git a/Makefile b/Makefile index 7c0b05b..9e440de 100644 --- a/Makefile +++ b/Makefile @@ -101,7 +101,7 @@ Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c \ Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c \ Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c \ Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c \ -Drivers/Embedded-Base/general/src/max7314.c \ +Drivers/Embedded-Base/general/src/INA226.c \ Drivers/Embedded-Base/platforms/stm32f405/src/can.c \ Drivers/Embedded-Base/general/src/pi4ioe.c \ Drivers/Embedded-Base/general/src/pca9539.c \ diff --git a/cerberus.ioc b/cerberus.ioc index 24312ea..18a831a 100644 --- a/cerberus.ioc +++ b/cerberus.ioc @@ -9,6 +9,18 @@ ADC1.Rank-2\#ChannelRegularConversion=1 ADC1.SamplingTime-2\#ChannelRegularConversion=ADC_SAMPLETIME_3CYCLES ADC1.ScanConvMode=ENABLE ADC1.master=1 +ADC2.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_10 +ADC2.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_10 +ADC2.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV6 +ADC2.ContinuousConvMode=ENABLE +ADC2.DMAContinuousRequests=ENABLE +ADC2.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,ClockPrescaler,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,NbrOfConversion,DMAContinuousRequests,ContinuousConvMode +ADC2.NbrOfConversion=2 +ADC2.NbrOfConversionFlag=1 +ADC2.Rank-0\#ChannelRegularConversion=1 +ADC2.Rank-1\#ChannelRegularConversion=2 +ADC2.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_3CYCLES +ADC2.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_3CYCLES ADC3.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_2 ADC3.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_3 ADC3.Channel-2\#ChannelRegularConversion=ADC_CHANNEL_0 @@ -53,6 +65,16 @@ Dma.ADC1.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD Dma.ADC1.1.PeriphInc=DMA_PINC_DISABLE Dma.ADC1.1.Priority=DMA_PRIORITY_LOW Dma.ADC1.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.ADC2.3.Direction=DMA_PERIPH_TO_MEMORY +Dma.ADC2.3.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.ADC2.3.Instance=DMA2_Stream2 +Dma.ADC2.3.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.ADC2.3.MemInc=DMA_MINC_ENABLE +Dma.ADC2.3.Mode=DMA_CIRCULAR +Dma.ADC2.3.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.ADC2.3.PeriphInc=DMA_PINC_DISABLE +Dma.ADC2.3.Priority=DMA_PRIORITY_LOW +Dma.ADC2.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode Dma.ADC3.0.Direction=DMA_PERIPH_TO_MEMORY Dma.ADC3.0.FIFOMode=DMA_FIFOMODE_DISABLE Dma.ADC3.0.Instance=DMA2_Stream0 @@ -66,7 +88,8 @@ Dma.ADC3.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlign Dma.Request0=ADC3 Dma.Request1=ADC1 Dma.Request2=USART3_TX -Dma.RequestsNb=3 +Dma.Request3=ADC2 +Dma.RequestsNb=4 Dma.USART3_TX.2.Direction=DMA_MEMORY_TO_PERIPH Dma.USART3_TX.2.FIFOMode=DMA_FIFOMODE_DISABLE Dma.USART3_TX.2.Instance=DMA1_Stream3 @@ -91,18 +114,19 @@ KeepUserPlacement=false Mcu.CPN=STM32F405RGT6V Mcu.Family=STM32F4 Mcu.IP0=ADC1 -Mcu.IP1=ADC3 -Mcu.IP10=SYS -Mcu.IP11=USART3 -Mcu.IP2=CAN1 -Mcu.IP3=DMA -Mcu.IP4=FREERTOS -Mcu.IP5=I2C1 -Mcu.IP6=I2C2 -Mcu.IP7=IWDG -Mcu.IP8=NVIC -Mcu.IP9=RCC -Mcu.IPNb=12 +Mcu.IP1=ADC2 +Mcu.IP10=RCC +Mcu.IP11=SYS +Mcu.IP12=USART3 +Mcu.IP2=ADC3 +Mcu.IP3=CAN1 +Mcu.IP4=DMA +Mcu.IP5=FREERTOS +Mcu.IP6=I2C1 +Mcu.IP7=I2C2 +Mcu.IP8=IWDG +Mcu.IP9=NVIC +Mcu.IPNb=13 Mcu.Name=STM32F405RGTx Mcu.Package=LQFP64 Mcu.Pin0=PH0-OSC_IN @@ -223,6 +247,10 @@ PB8.Mode=CAN_Activate PB8.Signal=CAN1_RX PB9.Mode=CAN_Activate PB9.Signal=CAN1_TX +PC0.Locked=true +PC0.Signal=ADCx_IN10 +PC1.Locked=true +PC1.Signal=ADCx_IN11 PC10.Locked=true PC10.Mode=Asynchronous PC10.Signal=USART3_TX @@ -276,7 +304,7 @@ ProjectManager.ToolChainLocation= ProjectManager.UAScriptAfterPath= ProjectManager.UAScriptBeforePath= ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_CAN1_Init-CAN1-false-HAL-true,5-MX_I2C1_Init-I2C1-false-HAL-true,6-MX_I2C2_Init-I2C2-false-HAL-true,7-MX_ADC1_Init-ADC1-false-HAL-true,8-MX_USART3_UART_Init-USART3-false-HAL-true,9-MX_ADC3_Init-ADC3-false-HAL-true,10-MX_IWDG_Init-IWDG-false-HAL-true +ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_CAN1_Init-CAN1-false-HAL-true,5-MX_I2C1_Init-I2C1-false-HAL-true,6-MX_I2C2_Init-I2C2-false-HAL-true,7-MX_ADC1_Init-ADC1-false-HAL-true,8-MX_USART3_UART_Init-USART3-false-HAL-true,9-MX_ADC3_Init-ADC3-false-HAL-true,10-MX_IWDG_Init-IWDG-false-HAL-true,11-MX_ADC2_Init-ADC2-false-HAL-true RCC.AHBFreq_Value=16000000 RCC.APB1Freq_Value=16000000 RCC.APB2Freq_Value=16000000 @@ -301,6 +329,10 @@ SH.ADCx_IN0.0=ADC3_IN0,IN0 SH.ADCx_IN0.ConfNb=1 SH.ADCx_IN1.0=ADC3_IN1,IN1 SH.ADCx_IN1.ConfNb=1 +SH.ADCx_IN10.0=ADC2_IN10,IN10 +SH.ADCx_IN10.ConfNb=1 +SH.ADCx_IN11.0=ADC2_IN11,IN11 +SH.ADCx_IN11.ConfNb=1 SH.ADCx_IN15.0=ADC1_IN15 SH.ADCx_IN15.ConfNb=1 SH.ADCx_IN2.0=ADC3_IN2,IN2