From ea1724af9e1de15a7d35b9b7f01777288f6d6139 Mon Sep 17 00:00:00 2001 From: cfif Date: Tue, 5 May 2026 15:36:29 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BB=D0=B0=D1=82=D1=8B=20=D0=BD?= =?UTF-8?q?=D0=B0=20V2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MainModesArbiter.c | 417 +---------------------------------- MainModesArbiter.h | 5 +- MainModesArbiter_InitStage.c | 8 +- 3 files changed, 16 insertions(+), 414 deletions(-) diff --git a/MainModesArbiter.c b/MainModesArbiter.c index 55eeda1..005c2af 100644 --- a/MainModesArbiter.c +++ b/MainModesArbiter.c @@ -37,236 +37,7 @@ void Mma_Init( env->thread.id = 0; } - -//uint8_t dataR[1024 * 2]; - -/* -void BTS5180_120(tMma *env, char *desc, uint16_t adc_value) { - float kILIS = 550.0f; - - float ERROR_THRESHOLD_V = 4.9f; - uint16_t ERROR_THRESHOLD_CODE = (uint16_t) (ERROR_THRESHOLD_V * 4095.0f / 5.0f); - - if (adc_value >= ERROR_THRESHOLD_CODE) { - LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "%s: Error !!!", desc) - } else { - // Преобразование в напряжение - float U = (float) adc_value * 5.0f / 4095.0f; - float I = U / 1200; // Ток диагностики R = 1200 - float Iout = I * kILIS; // Ток устройства - LoggerFormatInfo(LOGGER, LOG_TASK_ARB, - "%s: U = %f I = %f Iout = %f", - desc, U, I, Iout) - } - -} - -void VN7008AJ(tMma *env, char *desc, uint16_t adc_value) { - - float RSENSE = 2490.0f; // Сопротивление датчика, Ом (На схеме) - float K_TYPICAL = 5890.0f; // Типичный коэффициент из даташита на микросхему - - float ERROR_THRESHOLD_V = 4.9f; - uint16_t ERROR_THRESHOLD_CODE = (uint16_t) (ERROR_THRESHOLD_V * 4095.0f / 5.0f); - - // 1. Проверка на ошибку - if (adc_value >= ERROR_THRESHOLD_CODE) { - LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "%s: Error !!!", desc) - } else { - - // 2. Преобразование в напряжение - float vsense = (float) adc_value * 5.0f / 4095.0f; - - // 3. Вычисление тока - float Isense = vsense / RSENSE; - float Iout = Isense * K_TYPICAL; - - LoggerFormatInfo(LOGGER, LOG_TASK_ARB, - "%s: U = %f I = %f Iout = %f", - desc, vsense, Isense, Iout) - } - -} - -void ANALOG_SENSOR(tMma *env, char *desc, uint16_t adc_value) { - float ERROR_THRESHOLD_V = 4.9f; - uint16_t ERROR_THRESHOLD_CODE = (uint16_t) (ERROR_THRESHOLD_V * 4095.0f / 5.0f); - - // 1. Проверка на ошибку - if (adc_value >= ERROR_THRESHOLD_CODE) { - LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "%s: Error !!!", desc) - } else { - // Преобразование в напряжение - float U = (float) adc_value * 5.0f / 4095.0f; - - LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "%s: U = %f", desc, U) - } - -} -*/ void LoadDataInFromModel(tMma *env) { -// int16_t temp1 = 0; -// float temp2 = 0; -/* - if (osMutexAcquire(env->adcTask0.access, 5000) == osOK) { - - if (env->adcTask0.ADC_isUpdate) { - env->adcTask0.ADC_isUpdate = false; - - memcpy(&env->ADC_Data_Model_local, &env->adcTask0.ADC0_Data, sizeof(env->adcTask0.ADC0_Data)); - - - -// temp1 = get_temperature_fast(env->adcTask0.ADC0_Data.Sensor_Ambient_Temp); -// temp2 = get_temperature_from_adc(env->adcTask0.ADC0_Data.Sensor_Ambient_Temp, ALG_STEINHART); - //env->ADC_Data_Model_local.Sensor_Incar_Temp_FL = env->adcTask0.ADC0_Data.Sensor_Ambient_Temp; - - -// LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "Temp1 = %d; Temp2 = %d; ADC = %d", temp1, (int16_t) (temp2 * 10.0f), env->adcTask0.ADC0_Data.Sensor_Ambient_Temp) - - - // R1 = 91000 R2 = 20000 ((5 * (91000 + 20000)) / 20000 = 27.75 В) -// float U_IGN_CHECK = ((float) env->adcTask0.ADC0_Data.IGN_ANS * 27.75f) / 4095.0f; -// LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "U_IGN_CHECK = %f", U_IGN_CHECK) - -// BTS5180_120(env, "BTS5120_2EKA_ShutoffValvePowerTXV1", -// env->adcTask0.ADC0_Data.BTS5120_2EKA_ShutoffValvePowerTXV1); -// BTS5180_120(env, "BTS5120_2EKA_ShutoffValvePowerTXV2", -// env->adcTask0.ADC0_Data.BTS5120_2EKA_ShutoffValvePowerTXV2); - -// BTS5180_120(env, "BTS5180_2EKA_ShutOFFValveFront", env->adcTask0.ADC0_Data.BTS5180_2EKA_ShutOFFValveFront); -// BTS5180_120(env, "BTS5180_2EKA_ShutOFFValveRear", env->adcTask0.ADC0_Data.BTS5180_2EKA_ShutOFFValveRear); - -// BTS5180_120(env, "BTS5180_2EKA_TwoWayValve", env->adcTask0.ADC0_Data.BTS5180_2EKA_TwoWayValve); -// BTS5180_120(env, "BTS5180_2EKA_ReservePowerSupply", -// env->adcTask0.ADC0_Data.BTS5180_2EKA_ReservePowerSupply); - -// BTS5180_120(env, "BTS5180_2EKA_FrontIncarMotor", env->adcTask0.ADC0_Data.BTS5180_2EKA_FrontIncarMotor); -// BTS5180_120(env, "BTS5180_2EKA_RearIncarMotor", env->adcTask0.ADC0_Data.BTS5180_2EKA_RearIncarMotor); - -// BTS5180_120(env, "BTS5180_2EKA_ChannelPTCPower1", env->adcTask0.ADC0_Data.BTS5180_2EKA_ChannelPTCPower1); -// BTS5180_120(env, "BTS5180_2EKA_ChannelPTCPower2", env->adcTask0.ADC0_Data.BTS5180_2EKA_ChannelPTCPower2); - -// ANALOG_SENSOR(env, "Sensor_Ambient_Temp", env->adcTask0.ADC0_Data.Sensor_Ambient_Temp); -// ANALOG_SENSOR(env, "Sensor_AC_Pressure", env->adcTask0.ADC0_Data.Sensor_AC_Pressure); -// ANALOG_SENSOR(env, "Sensor_Incar_Temp_FL", env->adcTask0.ADC0_Data.Sensor_Incar_Temp_FL); -// ANALOG_SENSOR(env, "Sensor_Incar_Temp_RL", env->adcTask0.ADC0_Data.Sensor_Incar_Temp_RL); -// ANALOG_SENSOR(env, "Sensor_Rear_Evap_Temp", env->adcTask0.ADC0_Data.Sensor_Rear_Evap_Temp); -// ANALOG_SENSOR(env, "Sensor_Evap_Temp", env->adcTask0.ADC0_Data.Sensor_Evap_Temp); -// ANALOG_SENSOR(env, "Sensor_Rear_Duct1", env->adcTask0.ADC0_Data.Sensor_Rear_Duct1); -// ANALOG_SENSOR(env, "Sensor_Rear_Duct2", env->adcTask0.ADC0_Data.Sensor_Rear_Duct2); -// ANALOG_SENSOR(env, "Sensor_Front_Duct1", env->adcTask0.ADC0_Data.Sensor_Front_Duct1); -// ANALOG_SENSOR(env, "Sensor_Front_Duct2", env->adcTask0.ADC0_Data.Sensor_Front_Duct2); -// ANALOG_SENSOR(env, "Sensor_Front_Duct3", env->adcTask0.ADC0_Data.Sensor_Front_Duct3); -// ANALOG_SENSOR(env, "Sensor_Front_Duct4", env->adcTask0.ADC0_Data.Sensor_Front_Duct4); -// ANALOG_SENSOR(env, "Sensor_Rear_Duct3", env->adcTask0.ADC0_Data.Sensor_Rear_Duct3); -// ANALOG_SENSOR(env, "Sensor_Rear_Duct4", env->adcTask0.ADC0_Data.Sensor_Rear_Duct4); -// ANALOG_SENSOR(env, "Sensor_Incar_Temp_FR", env->adcTask0.ADC0_Data.Sensor_Incar_Temp_FR); -// ANALOG_SENSOR(env, "Sensor_Incar_Temp_RR", env->adcTask0.ADC0_Data.Sensor_Incar_Temp_RR); -// ANALOG_SENSOR(env, "Sensor_Rear_Duct5", env->adcTask0.ADC0_Data.Sensor_Rear_Duct5); -// ANALOG_SENSOR(env, "Sensor_Rear_Duct6", env->adcTask0.ADC0_Data.Sensor_Rear_Duct6); -// ANALOG_SENSOR(env, "Reserve_Sensor_Duct_Temp_1", env->adcTask0.ADC0_Data.Reserve_Sensor_Duct_Temp_1); -// ANALOG_SENSOR(env, "Sensor_Front_Duct5", env->adcTask0.ADC0_Data.Sensor_Front_Duct5); -// ANALOG_SENSOR(env, "Sensor_Front_Duct6", env->adcTask0.ADC0_Data.Sensor_Front_Duct6); - - // R1 = 10000 R2 = 47000 ((5 * (10000 + 47000)) / 47000 = 6.0638 В) -// float Pressure_DIAG = ((float) env->adcTask0.ADC0_Data.Pressure_DIAG * 6.0638f) / 4095.0f; -// LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "Pressure_DIAG = %f", Pressure_DIAG) - -// ANALOG_SENSOR(env, "Reserve_Sensor_Duct_Temp_2", env->adcTask0.ADC0_Data.Reserve_Sensor_Duct_Temp_2); - - } - - osMutexRelease(env->adcTask0.access); - - } - - if (osMutexAcquire(env->adcTask1.access, 5000) == osOK) { - - if (env->adcTask1.ADC_isUpdate) { - env->adcTask1.ADC_isUpdate = false; - - memcpy(&env->ADC_Data_Model_local.VN7008AJ_DIAG_FrontLINActuatorPowerDriverAB, &env->adcTask1.ADC1_Data, - sizeof(env->adcTask1.ADC1_Data)); - asm("nop"); - - // R1 = 91000 R2 = 16000 ((5 * (91000 + 16000)) / 16000 = 33.4375 В) -// float U_PBATT_CHECK = ((float) env->adcTask1.ADC1_Data.PBATT_CHECK * 33.4375f) / 4095.0f; -// LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "U_PBATT_CHECK = %f", U_PBATT_CHECK) - - // R1 = 30000 R2 = 12000 ((5 * (30000 + 12000)) / 12000 = 17.5 В) -// float U_VN7008AJ_DIAG_FrontLINActuatorPowerDriverAB = -// ((float) env->adcTask1.ADC1_Data.VN7008AJ_DIAG_FrontLINActuatorPowerDriverAB * 17.5f) / 4095.0f; -// LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "U_VN7008AJ_DIAG_FrontLINActuatorPowerDriverAB = %f", -// U_VN7008AJ_DIAG_FrontLINActuatorPowerDriverAB) - - // R1 = 30000 R2 = 12000 ((5 * (30000 + 12000)) / 12000 = 17.5 В) -// float U_VN7008AJ_DIAG_RearLINActuatorPowerDriverC = -// ((float) env->adcTask1.ADC1_Data.VN7008AJ_DIAG_RearLINActuatorPowerDriverC * 17.5f) / 4095.0f; -// LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "U_VN7008AJ_DIAG_RearLINActuatorPowerDriverC = %f", -// U_VN7008AJ_DIAG_RearLINActuatorPowerDriverC) - -// VN7008AJ(env, "VN7008AJ_FrontLINActuatorPowerDriverAB", env->adcTask1.ADC1_Data.VN7008AJ_FrontLINActuatorPowerDriverAB); -// VN7008AJ(env, "VN7008AJ_RearLINActuatorPowerDriverC", env->adcTask1.ADC1_Data.VN7008AJ_RearLINActuatorPowerDriverC); - - } - - //temp2 = get_temperature_fast(env->adcTask1.ADC_Data[0], fast_lookup_KST45, 512); - - //env->rtDW.controllerDataIncarInput.InIncarFR = env->adcTask1.ADC_Data[0]; - - osMutexRelease(env->adcTask1.access); - //LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "Temp2 = %d", temp2) - } -*/ -// if (osMutexAcquire(env->ModelTask.access, 5000) == osOK) { -/* - rtDW.ADC_Key_Data_Model.ST_ReservePower = GpioPinGet( - &env->gpios->power.BTS4175SGAXUMA1_ReservePowerOutput.ST_ReservePower); - rtDW.ADC_Key_Data_Model.ST_BATTChiller = GpioPinGet( - &env->gpios->power.BTS4175SGAXUMA1_ShutOFFValveBatteryChiller.ST_BATTChiller); - rtDW.ADC_Key_Data_Model.EmergencyAirCleanSwitch = GpioPinGet(&env->gpios->EmergencyAirCleanSwitch); - rtDW.ADC_Key_Data_Model.FireExtinguishSwitch = GpioPinGet(&env->gpios->FireExtinguishSwitch); - rtDW.ADC_Key_Data_Model.Ign_Wakeup = GpioPinGet(&env->gpios->Ign_Wakeup); -*/ - - -/* - PWM_Get.pwmPercentFront = env->pwms->pwmFrontCaptureIO.getPwm(env->pwms->pwmFrontCaptureIO.env); - PWM_Get.pwmPercentRear = env->pwms->pwmRearCaptureIO.getPwm(env->pwms->pwmRearCaptureIO.env); - PWM_Get.pwmPercentFrontReserved = env->pwms->pwmFrontCaptureIO.getPwm(env->pwms->pwmFrontReservedCaptureIO.env); - PWM_Get.pwmPercentRearReserved = env->pwms->pwmRearCaptureIO.getPwm(env->pwms->pwmRearReservedCaptureIO.env); - -// LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "PWM (Front) = %d", PWM_Get.pwmPercentFront ) -// LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "PWM (Rear) = %d", PWM_Get.pwmPercentRear) -// LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "PWM (Front Reserve) = %d", PWM_Get.pwmPercentFrontReserved) -// LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "PWM (Rear Reserve) = %d", PWM_Get.pwmPercentRearReserved) - - env->pwms->pwmFrontIo.setActivePercent(env->pwms->pwmFrontIo.env, rtDW.PWM_Set_Model.pwmPercentFront); - env->pwms->pwmRearIo.setActivePercent(env->pwms->pwmRearIo.env, rtDW.PWM_Set_Model.pwmPercentRear); - env->pwms->pwmFrontReservedIo.setActivePercent(env->pwms->pwmFrontReservedIo.env, rtDW.PWM_Set_Model.pwmPercentFrontReserved); - env->pwms->pwmRearReservedIo.setActivePercent(env->pwms->pwmRearReservedIo.env, rtDW.PWM_Set_Model.pwmPercentRearReserved); - - PWM_Get.pwmPercentFront = env->pwms->pwmFrontCaptureIO.getPwm(env->pwms->pwmFrontCaptureIO.env); - PWM_Get.pwmPercentRear = env->pwms->pwmRearCaptureIO.getPwm(env->pwms->pwmRearCaptureIO.env); - PWM_Get.pwmPercentFrontReserved = env->pwms->pwmFrontCaptureIO.getPwm( - env->pwms->pwmFrontReservedCaptureIO.env); - PWM_Get.pwmPercentRearReserved = env->pwms->pwmRearCaptureIO.getPwm( - env->pwms->pwmRearReservedCaptureIO.env); - - - env->pwms->pwmFrontIo.setActivePercent(env->pwms->pwmFrontIo.env, PWM_Get.pwmPercentFront); - env->pwms->pwmRearIo.setActivePercent(env->pwms->pwmRearIo.env, PWM_Get.pwmPercentRear); - env->pwms->pwmFrontReservedIo.setActivePercent(env->pwms->pwmFrontReservedIo.env, - PWM_Get.pwmPercentFrontReserved); - env->pwms->pwmRearReservedIo.setActivePercent(env->pwms->pwmRearReservedIo.env, PWM_Get.pwmPercentRearReserved); -*/ - -// set_Dtc_state_error(&env->Diagnostic); -// set_CCU_Errors(&env->canSpamTransmitter, (CCU_Errors_t *) &CCU_Errors_Model); - -// osMutexRelease(env->ModelTask.access); -// } if (osMutexAcquire(env->ModelTask.access, 5000) == osOK) { @@ -283,10 +54,13 @@ void LoadDataInFromModel(tMma *env) { PWM_Get.pwmPercentRearReserved = env->pwms->pwmRearCaptureIO.getPwm( env->pwms->pwmRearReservedCaptureIO.env); - set_Dtc_state_error(&env->Diagnostic); + set_Dtc_state(&env->Diagnostic); set_CanSpamTransmitter(&env->canSpamTransmitter); get_CanSpamReceiver(&env->canSpamReceiver); + set_CanDebugSpamTransmitter(&env->canSpamDebugTransmitter); + + osMutexRelease(env->ModelTask.access); } @@ -294,23 +68,9 @@ void LoadDataInFromModel(tMma *env) { static _Noreturn void Mma_Thread(tMma *env) { - uint8_t step = 0; - bool busy = false; - // Запуск устройства Mma_InitStage(env); - // Инициализируем обе таблицы одновременно с разными значениями R1 -// init_both_tables(20000.0f, // R1 для KST45 -// 20000.0f, // R1 для INCAR -// ALG_STEINHART); - - -// can_rx_message_type frame_data; - -// uint32_t step = 0; - - if (RGM_SRS_WAKEUP_MASK == (RGM->SRS & RGM_SRS_WAKEUP_MASK)) { LoggerInfoStatic(LOGGER, LOG_TASK_ARB, "Wake up from standby") } @@ -326,121 +86,11 @@ static _Noreturn void Mma_Thread(tMma *env) { } LoggerInfoStatic(LOGGER, LOG_TASK_ARB, "Model running...") -/* - for (;;) { - uint16_t len = SerialPortReceive(&env->serialPorts->SerialPortLog_IO, dataR, 1024, 1000); - - if (len != 0) { - SerialPortTransmit(&env->serialPorts->SerialPortLog_IO, dataR, len, 1000); - } - } -*/ - for (;;) { -// if (osMutexAcquire(env->adcTask0.access, 1000) == osOK) { -/* - uint16_t adc_value = env->adcTask0.ADC0_Data.Sensor_Front_Duct1; - int16_t temp_incar = get_temperature_log_fast_for_table(adc_value, TABLE_KST45); - float resistance = get_resistance_log_fast_for_table(temp_incar, TABLE_KST45); - float U = (float) adc_value * 5.0f / 4095.0f; - - LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "Sensor_Front_Duct1: ADC = %u, Temp = %.2f °C, Resistance = %.2f Ohm U = %.2f", - adc_value, temp_incar / 10.0f, resistance, U) - -*/ -/* - uint16_t adc_value = env->adcTask0.ADC0_Data.Sensor_Front_Duct2; - int16_t temp_incar = get_temperature_log_fast_for_table(adc_value, TABLE_KST45); - float resistance = get_resistance_log_fast_for_table(temp_incar, TABLE_KST45); - float U = (float) adc_value * 5.0f / 4095.0f; - - LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "Sensor_Front_Duct1: ADC = %u, Temp = %.2f °C, Resistance = %.2f Ohm U = %.2f", - adc_value, temp_incar / 10.0f, resistance, U) -*/ -/* - uint16_t adc_value = env->adcTask0.ADC0_Data.Sensor_Ambient_Temp; - int16_t Sensor_Ambient_Temp = get_temperature_log_fast_for_table(adc_value, TABLE_KST45); - float resistance = get_resistance_log_fast_for_table(Sensor_Ambient_Temp, TABLE_KST45); - float U = (float) adc_value * 5.0f / 4095.0f; - - LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "Sensor_Ambient_Temp: ADC = %u, Temp = %.2f °C, Resistance = %.2f Ohm U = %.2f", - adc_value, Sensor_Ambient_Temp / 10.0f, resistance, U) -*/ - //uint16_t adc_value = env->adcTask0.ADC0_Data.Sensor_Incar_Temp_FL; - //int16_t temp_incar = get_temperature_log_fast_for_table(adc_value, TABLE_INCAR); - //LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "Sensor_Incar_Temp_FL: ADC = %u, Temp = %.2f °C", adc_value, - // temp_incar / 10.0f) - - - -// osMutexRelease(env->adcTask0.access); -// } - -/* - if (osMutexAcquire(env->ModelTask.access, 5000) == osOK) { - - PWM_Get.pwmPercentFront = env->pwms->pwmFrontCaptureIO.getPwm(env->pwms->pwmFrontCaptureIO.env); - PWM_Get.pwmPercentRear = env->pwms->pwmRearCaptureIO.getPwm(env->pwms->pwmRearCaptureIO.env); - PWM_Get.pwmPercentFrontReserved = env->pwms->pwmFrontCaptureIO.getPwm( - env->pwms->pwmFrontReservedCaptureIO.env); - PWM_Get.pwmPercentRearReserved = env->pwms->pwmRearCaptureIO.getPwm( - env->pwms->pwmRearReservedCaptureIO.env); - - env->pwms->pwmFrontIo.setActivePercent(env->pwms->pwmFrontIo.env, 95); - env->pwms->pwmRearIo.setActivePercent(env->pwms->pwmRearIo.env, 95); - env->pwms->pwmFrontReservedIo.setActivePercent(env->pwms->pwmFrontReservedIo.env, 10); - env->pwms->pwmRearReservedIo.setActivePercent(env->pwms->pwmRearReservedIo.env, 20); - - set_Dtc_state_error(&env->Diagnostic); - set_CCU_Errors(&env->canSpamTransmitter, (CCU_Errors_t *) &CCU_Errors_Model); - - osMutexRelease(env->ModelTask.access); - } -*/ - -/* - SystemDelayMs(10); - uint8_t pwm1 = env->pwms->pwmFrontCaptureIO.getPwm(env->pwms->pwmFrontCaptureIO.env); - LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "PWM (Front) = %d", pwm1) - - SystemDelayMs(10); - uint8_t pwm2 = env->pwms->pwmRearCaptureIO.getPwm(env->pwms->pwmRearCaptureIO.env); - LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "PWM (Rear) = %d", pwm2) - - SystemDelayMs(10); - uint8_t pwm3 = env->pwms->pwmFrontReservedCaptureIO.getPwm(env->pwms->pwmFrontReservedCaptureIO.env); - LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "PWM (Front Reserve) = %d", pwm3) - - SystemDelayMs(10); - uint8_t pwm4 = env->pwms->pwmRearReservedCaptureIO.getPwm(env->pwms->pwmRearReservedCaptureIO.env); - LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "PWM (Rear Reserve) = %d", pwm4) -*/ - -// LoadDataInFromModel(env); -/* - LinActuatorWork(env, &env->linTaskActuator1, 1, - &env->actuator_Ch0_Command_Model_local_1, - &env->ModelTask.triggerActuatorCmdBus_1, - &env->actuator_Ch0_Input_Model_local_1, - &Actuator_Ch0_Status_Model, &env->ModelTask.triggerCommand1, "Ln1 "); - - - LinActuatorWork(env, &env->linTaskActuator2, 2, - &env->actuator_Ch1_Command_Model_local_2, - &env->ModelTask.triggerActuatorCmdBus_2, - &env->actuator_Ch1_Input_Model_local_2, - &Actuator_Ch1_Status_Model, &env->ModelTask.triggerCommand2, "Ln2 "); - - - LinActuatorWork(env, &env->linTaskActuator3, 3, - &env->actuator_Ch2_Command_Model_local_3, - &env->ModelTask.triggerActuatorCmdBus_3, - &env->actuator_Ch2_Input_Model_local_3, - &Actuator_Ch2_Status_Model, &env->ModelTask.triggerCommand3, "Ln3 "); - -*/ +// bool ST_PowerReserve = GpioPinGet(&env->gpios->power.BTS4175SGAXUMA1_PowerReserve.ST_PowerReserve); +// bool ST_ReservePower = GpioPinGet(&env->gpios->power.BTS4175SGAXUMA1_ReservePowerOutput.ST_ReservePower); LoadDataInFromModel(env); @@ -454,61 +104,6 @@ static _Noreturn void Mma_Thread(tMma *env) { } */ -/* - if (osMutexAcquire(env->adcTask0.access, 1000) == osOK) { - temp1 = get_temperature_fast(env->adcTask0.ADC_Data[0], fast_lookup_Incar, 512); - osMutexRelease(env->adcTask0.access); - LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "Temp1 = %d", temp1) - } - - - if (osMutexAcquire(env->adcTask1.access, 1000) == osOK) { - temp2 = get_temperature_fast(env->adcTask1.ADC_Data[0], fast_lookup_KST45, 512); - osMutexRelease(env->adcTask1.access); - LoggerFormatInfo(LOGGER, LOG_TASK_ARB, "Temp2 = %d", temp2) - } -*/ - -/* - frame_data.id_type = FLEXCAN_ID_STD; - frame_data.dlc = 1; - - env->canPorts->Can1_IO.transmit(env->canPorts->Can1_IO.env, frame_data.data, frame_data.dlc, 0x123, frame_data.id_type, 1000); -*/ -/* - uint16_t len = env->canPorts->Can1_IO.receive(env->canPorts->Can1_IO.env, 0, (uint8_t *)&frame_data, 1, 1000); - - if (len > 0) { - env->canPorts->Can1_IO.transmit(env->canPorts->Can1_IO.env, frame_data.data, frame_data.dlc, frame_data.standard_id, frame_data.id_type, 1000); - } -*/ - -/* - uint16_t len = env->canPorts->Can0_IO.receive(env->canPorts->Can0_IO.env, 0, (uint8_t *)&frame_data, 1, 1000); - - if (len > 0) { - env->canPorts->Can0_IO.transmit(env->canPorts->Can0_IO.env, frame_data.data, frame_data.dlc, 0x123, frame_data.id_type, 1000); - } -*/ -/* - uint16_t len = env->canPorts->Can0_IO.receive(env->canPorts->Can0_IO.env, 0, (uint8_t *)&frame_data, 1, 1000); - - if (len > 0) { - - if (frame_data.id_type == FLEXCAN_ID_STD) { - CanSerialPortFrameSetType(env->canPorts->Can0_IO.env, FLEXCAN_ID_STD); - CanSerialPortFrameSetId(env->canPorts->Can0_IO.env, frame_data.standard_id); - } else { - CanSerialPortFrameSetType(env->canPorts->Can0_IO.env, FLEXCAN_ID_EXT); - CanSerialPortFrameSetId(env->canPorts->Can0_IO.env, frame_data.extended_id); - } - - - env->canPorts->Can0_IO.transmit(env->canPorts->Can0_IO.env, frame_data.data, frame_data.dlc, 1000); - } -*/ - - } } diff --git a/MainModesArbiter.h b/MainModesArbiter.h index b1a7993..3269ff4 100644 --- a/MainModesArbiter.h +++ b/MainModesArbiter.h @@ -21,6 +21,7 @@ #include "CanSerialPortFrameXCP.h" #include "CanSpamReceiver.h" #include "CanSpamTransmitter.h" +#include "CanSpamDebugReceiver.h" #include "CanSpamDebugTransmitter.h" #include "Lins.h" #include "LinActuatorTasks.h" @@ -60,6 +61,8 @@ typedef struct { tCanSpamReceiver canSpamReceiver; tCanSpamTransmitter canSpamTransmitter; + + tCanSpamDebugReceiver canSpamDebugReceiver; tCanSpamDebugTransmitter canSpamDebugTransmitter; tLinTaskActuator linTaskActuator1; @@ -81,7 +84,7 @@ typedef struct { struct { osThreadId_t id; - uint32_t stack[1024 * 1]; + uint32_t stack[384]; StaticTask_t controlBlock; osThreadAttr_t attr; } thread; diff --git a/MainModesArbiter_InitStage.c b/MainModesArbiter_InitStage.c index db40112..a597208 100644 --- a/MainModesArbiter_InitStage.c +++ b/MainModesArbiter_InitStage.c @@ -125,7 +125,7 @@ static void Mma_InitSubSystems(tMma *env) { &env->slog.logger ); -// CanXcpProcessing_Listener_Start(&env->CanSerialPortFrameXCP); + CanXcpProcessing_Listener_Start(&env->CanSerialPortFrameXCP); CanSpamReceiver_Init(&env->canSpamReceiver, &env->canPorts->Can0_IO, &env->slog.logger); CanSpamReceiver_StartThread(&env->canSpamReceiver); @@ -133,7 +133,11 @@ static void Mma_InitSubSystems(tMma *env) { CanSpamTransmitter_Init(&env->canSpamTransmitter, &env->canPorts->Can0_IO, &env->slog.logger); CanSpamTransmitter_StartThread(&env->canSpamTransmitter); - CanSpamDebugTransmitter_Init(&env->canSpamDebugTransmitter, &env->canPorts->Can1_IO, &env->slog.logger); + CanSpamDebugReceiver_Init(&env->canSpamDebugReceiver, &env->canPorts->Can1_IO, &env->slog.logger); + CanSpamDebugReceiver_StartThread(&env->canSpamDebugReceiver); + + CanSpamDebugTransmitter_Init(&env->canSpamDebugTransmitter, &env->canPorts->Can1_IO, &env->canSpamDebugReceiver, + &env->slog.logger); CanSpamDebugTransmitter_StartThread(&env->canSpamDebugTransmitter);