Send SDC_Closed without plausibility delay

This commit is contained in:
Jasper Blanckenburg 2024-07-17 18:21:21 +02:00
parent a4fd5d26f5
commit b68d26decb
3 changed files with 8 additions and 5 deletions

View File

@ -42,6 +42,7 @@ extern "C" {
/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
extern int sdc_closed;
extern int sdc_closed_nodelay;
/* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/

View File

@ -23,7 +23,8 @@ void can_init(FDCAN_HandleTypeDef *handle) {
HAL_StatusTypeDef can_send_status() {
uint8_t data[8];
data[0] = ts_state.current_state | (sdc_closed << 7);
data[0] =
ts_state.current_state | (sdc_closed << 7) | (sdc_closed_nodelay << 6);
data[1] = roundf(current_soc);
ftcan_marshal_unsigned(&data[2], min_voltage, 2);
ftcan_marshal_signed(&data[4], max_temp, 2);

View File

@ -60,6 +60,7 @@ UART_HandleTypeDef huart1;
/* USER CODE BEGIN PV */
int sdc_closed = 0;
int sdc_closed_nodelay = 0;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
@ -91,12 +92,12 @@ static void loop_delay() {
static void update_sdc() {
static int last[2] = {0, 0};
int current = HAL_GPIO_ReadPin(SDC_VOLTAGE_GPIO_Port, SDC_VOLTAGE_Pin) == GPIO_PIN_SET;
if (last[0] == last[1] && last[0] == current) {
sdc_closed = current;
sdc_closed_nodelay = HAL_GPIO_ReadPin(SDC_VOLTAGE_GPIO_Port, SDC_VOLTAGE_Pin) == GPIO_PIN_SET;
if (last[0] == last[1] && last[0] == sdc_closed_nodelay) {
sdc_closed = sdc_closed_nodelay;
}
last[0] = last[1];
last[1] = current;
last[1] = sdc_closed_nodelay;
}
/* USER CODE END 0 */