From 4a7b54acd24d55eacc7747edd987a6d220ddc8b5 Mon Sep 17 00:00:00 2001 From: "Jasper v. Blanckenburg" Date: Thu, 11 Jul 2024 22:16:07 +0200 Subject: [PATCH] Mirror TSActive on RSD. Don't do anything else. --- Core/Inc/can.h | 3 +- Core/Src/can.c | 21 +++++- Core/Src/main.c | 8 +-- FT23_Charger.launch | 156 ++++++++++++++++++++++---------------------- 4 files changed, 103 insertions(+), 85 deletions(-) diff --git a/Core/Inc/can.h b/Core/Inc/can.h index 96895a3..a25a75e 100644 --- a/Core/Inc/can.h +++ b/Core/Inc/can.h @@ -10,7 +10,8 @@ #include "stm32h7xx_hal.h" - +#define CAN_ID_AMS_STATUS 0x00A +#define CAN_ID_AMS_IN 0x00B #define CAN_ID_SLAVE_STATUS_BASE 0x080 #define CAN_ID_CHARGER_ACTIVE 0x200 diff --git a/Core/Src/can.c b/Core/Src/can.c index e2cdcb0..fc39ac2 100644 --- a/Core/Src/can.c +++ b/Core/Src/can.c @@ -10,6 +10,8 @@ #include "can-halal.h" #include "slave_handler.h" #include "b_cccv_algo.h" +#include "charger_control.h" + void initCan(FDCAN_HandleTypeDef *hcan) { @@ -20,11 +22,11 @@ void initCan(FDCAN_HandleTypeDef *hcan) void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data) { if ((id & 0xFF0) == CAN_ID_SLAVE_STATUS_BASE) { - slaves_handle_status(data); +// slaves_handle_status(data); return; } - if (id == CAN_ID_CHARGER_ACTIVE) + /*if (id == CAN_ID_CHARGER_ACTIVE) { if(data[0] == 1) { @@ -36,5 +38,20 @@ void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data) stopcharging(); } return; + }*/ + switch (id) { + case CAN_ID_AMS_STATUS: { + int sdc_closed = data[0] >> 7; + if (sdc_closed == 0) { + charger_control_disable_remote(); + } + break; + } + case CAN_ID_AMS_IN: { + int active = data[0] & 0x01; + if (active) { + charger_control_enable_remote(); + } + } } } diff --git a/Core/Src/main.c b/Core/Src/main.c index 3dda993..f73f95f 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -155,12 +155,12 @@ int main(void) if((HAL_GetTick() - lasttick) > 1000) { - float maxvoltage = slaves_get_maximum_voltage(); - lasttick = HAL_GetTick(); - chargingloop(slaves_get_maximum_voltage()); +// float maxvoltage = slaves_get_maximum_voltage(); +// lasttick = HAL_GetTick(); +// chargingloop(slaves_get_maximum_voltage()); + HAL_GPIO_TogglePin(STATUS_LED_2_GPIO_Port, STATUS_LED_2_Pin); } - // HAL_GPIO_TogglePin(STATUS_LED_2_GPIO_Port, STATUS_LED_2_Pin); // HAL_Delay(500); } /* USER CODE END 3 */ diff --git a/FT23_Charger.launch b/FT23_Charger.launch index 0e46311..edb5e91 100644 --- a/FT23_Charger.launch +++ b/FT23_Charger.launch @@ -1,78 +1,78 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +