Mirror TSActive on RSD. Don't do anything else.

This commit is contained in:
2024-07-11 22:16:07 +02:00
parent 1cbfd28288
commit 4a7b54acd2
4 changed files with 103 additions and 85 deletions

View File

@ -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

View File

@ -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();
}
}
}
}

View File

@ -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 */