feat: add seat firmware workbench and OTA delivery
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "bsp_seat_backrest_heater.h"
|
||||
#include "bsp_seat_fan.h"
|
||||
#include "seat_controller_thermal.h"
|
||||
#include "seat_feature_profile.h"
|
||||
|
||||
volatile uint32_t g_seatMoveResetReason = 0u;
|
||||
volatile uint32_t g_seatMoveInitResult = MOTOR_API_FAILURE;
|
||||
@@ -59,11 +60,13 @@ int main(void)
|
||||
}
|
||||
|
||||
Motor_SetWatchdogServiceEnabled(true);
|
||||
#if SEAT_FEATURE_THERMAL
|
||||
if(!SeatControllerThermal_Init())
|
||||
{
|
||||
SafetyManager_LatchFault(SAFETY_FAULT_DRIVER);
|
||||
SeatMove_HoldSafeOff();
|
||||
}
|
||||
#endif
|
||||
if(!SeatMoveApplication_Init())
|
||||
{
|
||||
SeatMove_HoldSafeOff();
|
||||
@@ -72,7 +75,9 @@ int main(void)
|
||||
for(;;)
|
||||
{
|
||||
SeatMoveApplication_Service();
|
||||
#if SEAT_FEATURE_THERMAL
|
||||
SeatControllerThermal_Service1ms();
|
||||
#endif
|
||||
if(SafetyManager_IsInhibited())
|
||||
{
|
||||
Motor_ForceSafeOff();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "seat_backrest_heater.h"
|
||||
#include "seat_backrest_heater_config.h"
|
||||
#include "seat_fan_config.h"
|
||||
#include "seat_feature_profile.h"
|
||||
|
||||
#define SEAT_CONTROLLER_THERMAL_CONTROL_ID (0x29Eu)
|
||||
#define SEAT_CONTROLLER_THERMAL_CONFIG_ID (0x2AAu)
|
||||
@@ -247,6 +248,7 @@ static void SeatControllerThermal_HandleControl29e(
|
||||
fanGear = (uint8_t)((frame->data0 >> 16u) & 0x0Fu);
|
||||
heaterGear = (uint8_t)((frame->data0 >> 20u) & 0x0Fu);
|
||||
|
||||
#if SEAT_FEATURE_VENTILATION
|
||||
if(fanOn == 2u)
|
||||
{
|
||||
SeatControllerThermal_StopFan(1u);
|
||||
@@ -266,7 +268,14 @@ static void SeatControllerThermal_HandleControl29e(
|
||||
g_seatControllerThermalInvalidCount++;
|
||||
SeatControllerThermal_StopFan(0u);
|
||||
}
|
||||
#else
|
||||
(void)fanOn;
|
||||
(void)fanMode;
|
||||
(void)fanGear;
|
||||
SeatControllerThermal_StopFan(1u);
|
||||
#endif
|
||||
|
||||
#if SEAT_FEATURE_HEATING
|
||||
if(heaterOn == 2u)
|
||||
{
|
||||
SeatControllerThermal_StopHeater(1u);
|
||||
@@ -286,6 +295,11 @@ static void SeatControllerThermal_HandleControl29e(
|
||||
g_seatControllerThermalInvalidCount++;
|
||||
SeatControllerThermal_StopHeater(0u);
|
||||
}
|
||||
#else
|
||||
(void)heaterOn;
|
||||
(void)heaterGear;
|
||||
SeatControllerThermal_StopHeater(1u);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void SeatControllerThermal_HandleConfig2aa(
|
||||
@@ -308,16 +322,23 @@ static void SeatControllerThermal_HandleConfig2aa(
|
||||
g_seatControllerThermalInvalidCount++;
|
||||
return;
|
||||
}
|
||||
#if SEAT_FEATURE_VENTILATION
|
||||
s_fanConfiguredMaxGear = (fanConfig == 1u) ? 1u :
|
||||
((fanConfig == 2u) ? 2u : 3u);
|
||||
#endif
|
||||
#if SEAT_FEATURE_HEATING
|
||||
s_heaterConfiguredMaxLevel = (heaterConfig == 1u) ? 1u :
|
||||
((heaterConfig == 2u) ? 2u : 3u);
|
||||
#endif
|
||||
#if SEAT_FEATURE_VENTILATION
|
||||
if(s_fanRunning &&
|
||||
!SeatControllerThermal_RequestFan(s_fanLastVehicleGear))
|
||||
{
|
||||
g_seatControllerThermalOutputFaultStage = 4u;
|
||||
SeatControllerThermal_LatchOutputFault();
|
||||
}
|
||||
#endif
|
||||
#if SEAT_FEATURE_HEATING
|
||||
if(g_seatBackrestHeaterAppliedLevel !=
|
||||
SEAT_BACKREST_HEATER_LEVEL_OFF)
|
||||
{
|
||||
@@ -327,11 +348,13 @@ static void SeatControllerThermal_HandleConfig2aa(
|
||||
SeatControllerThermal_LatchOutputFault();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void SeatControllerThermal_HandleMode3ce(
|
||||
const bsp_seat_move_can_frame_t *frame)
|
||||
{
|
||||
#if SEAT_FEATURE_HEATING
|
||||
uint8_t mode;
|
||||
if(frame->dlc != SEAT_FAN_CAN_DLC)
|
||||
{
|
||||
@@ -347,6 +370,10 @@ static void SeatControllerThermal_HandleMode3ce(
|
||||
g_seatControllerThermalInvalidCount++;
|
||||
SeatControllerThermal_StopHeater(0u);
|
||||
}
|
||||
#else
|
||||
(void)frame;
|
||||
SeatControllerThermal_StopHeater(1u);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void SeatControllerThermal_HandleSwitch42a(
|
||||
@@ -363,6 +390,7 @@ static void SeatControllerThermal_HandleSwitch42a(
|
||||
}
|
||||
fanSwitch = (uint8_t)(frame->data0 & 0x03u);
|
||||
heaterSwitch = (uint8_t)((frame->data0 >> 2u) & 0x03u);
|
||||
#if SEAT_FEATURE_VENTILATION
|
||||
if(fanSwitch == 1u)
|
||||
{
|
||||
if(!SeatControllerThermal_RequestFan(s_fanLastVehicleGear))
|
||||
@@ -375,6 +403,11 @@ static void SeatControllerThermal_HandleSwitch42a(
|
||||
{
|
||||
SeatControllerThermal_StopFan(1u);
|
||||
}
|
||||
#else
|
||||
(void)fanSwitch;
|
||||
SeatControllerThermal_StopFan(1u);
|
||||
#endif
|
||||
#if SEAT_FEATURE_HEATING
|
||||
if(heaterSwitch == 1u)
|
||||
{
|
||||
if(!SeatControllerThermal_RequestHeater(s_heaterLastVehicleGear))
|
||||
@@ -387,10 +420,15 @@ static void SeatControllerThermal_HandleSwitch42a(
|
||||
{
|
||||
SeatControllerThermal_StopHeater(1u);
|
||||
}
|
||||
#else
|
||||
(void)heaterSwitch;
|
||||
SeatControllerThermal_StopHeater(1u);
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool SeatControllerThermal_RequestFan(uint8_t vehicleGear)
|
||||
{
|
||||
#if SEAT_FEATURE_VENTILATION
|
||||
uint8_t physicalGear = (vehicleGear >= 3u) ? 3u : vehicleGear;
|
||||
if((vehicleGear == 0u) || (vehicleGear > 5u))
|
||||
{
|
||||
@@ -418,10 +456,15 @@ static bool SeatControllerThermal_RequestFan(uint8_t vehicleGear)
|
||||
return BspSeatFan_SetDutyPercent(s_fanTargetDutyPercent);
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
(void)vehicleGear;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool SeatControllerThermal_RequestHeater(uint8_t vehicleGear)
|
||||
{
|
||||
#if SEAT_FEATURE_HEATING
|
||||
uint8_t physicalLevel = (vehicleGear >= 3u) ? 3u : vehicleGear;
|
||||
if((vehicleGear == 0u) || (vehicleGear > 5u) || !s_heaterModeValid)
|
||||
{
|
||||
@@ -440,6 +483,10 @@ static bool SeatControllerThermal_RequestHeater(uint8_t vehicleGear)
|
||||
g_seatControllerHeaterFeedbackRaw = physicalLevel + 1u;
|
||||
s_feedbackPending = true;
|
||||
return true;
|
||||
#else
|
||||
(void)vehicleGear;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void SeatControllerThermal_StopFan(uint8_t feedbackRaw)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "safety_manager.h"
|
||||
#include "seat_controller_thermal.h"
|
||||
#include "seat_dynamic_mode.h"
|
||||
#include "seat_feature_profile.h"
|
||||
#include "seat_motor_manager.h"
|
||||
#include "seat_move_config.h"
|
||||
#include "seat_move_store.h"
|
||||
@@ -336,7 +337,9 @@ void SeatMoveApplication_Service(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if SEAT_FEATURE_THERMAL
|
||||
SeatControllerThermal_HandleFrame(&frame);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
SeatMove_ServiceDispatcher();
|
||||
@@ -363,7 +366,9 @@ void Motor_CalibrationServiceHook(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if SEAT_FEATURE_THERMAL
|
||||
SeatControllerThermal_HandleFrame(&frame);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if(g_bspSeatMoveCanBusOff != 0u)
|
||||
@@ -533,15 +538,28 @@ static bool SeatMove_ParseCommand(const bsp_seat_move_can_frame_t *frame,
|
||||
{
|
||||
case SEAT_MOVE_OPCODE_MOVE_ABSOLUTE:
|
||||
case SEAT_MOVE_OPCODE_MOVE_RELATIVE:
|
||||
#if SEAT_FEATURE_POSITION_CONTROL
|
||||
break;
|
||||
#else
|
||||
*reject = SEAT_MOVE_REJECT_BAD_OPCODE;
|
||||
return false;
|
||||
#endif
|
||||
case SEAT_MOVE_OPCODE_MOVE_TIMED:
|
||||
case SEAT_MOVE_OPCODE_STOP_MOTOR:
|
||||
case SEAT_MOVE_OPCODE_STOP_ALL:
|
||||
break;
|
||||
case SEAT_MOVE_OPCODE_CALIBRATE_RANGE:
|
||||
case SEAT_MOVE_OPCODE_HOME_KNOWN_RANGE:
|
||||
case SEAT_MOVE_OPCODE_QUERY_STATUS:
|
||||
case SEAT_MOVE_OPCODE_CLEAR_FAULT:
|
||||
case SEAT_MOVE_OPCODE_START_DYNAMIC_MODE:
|
||||
case SEAT_MOVE_OPCODE_STOP_DYNAMIC_MODE:
|
||||
#if SEAT_FEATURE_POSITION_CONTROL
|
||||
break;
|
||||
#else
|
||||
*reject = SEAT_MOVE_REJECT_BAD_OPCODE;
|
||||
return false;
|
||||
#endif
|
||||
case SEAT_MOVE_OPCODE_QUERY_STATUS:
|
||||
case SEAT_MOVE_OPCODE_CLEAR_FAULT:
|
||||
break;
|
||||
default:
|
||||
*reject = SEAT_MOVE_REJECT_BAD_OPCODE;
|
||||
|
||||
Reference in New Issue
Block a user