Обновление
This commit is contained in:
parent
3268bbd153
commit
aedd2c0e23
|
|
@ -457,7 +457,7 @@ typedef struct {
|
|||
|
||||
struct {
|
||||
osThreadId_t id;
|
||||
uint32_t stack[256];
|
||||
uint32_t stack[384];
|
||||
StaticTask_t controlBlock;
|
||||
osThreadAttr_t attr;
|
||||
} threadLin;
|
||||
|
|
|
|||
287
LinSensorTasks.c
287
LinSensorTasks.c
|
|
@ -14,6 +14,9 @@
|
|||
#define LOG_SIGN5 "Lin5"
|
||||
#define LOGGER env->logger
|
||||
|
||||
const uint8_t DRS_SENSON_ADR_Stat[LIN5_SENSOR_COUNT] = {DRS_DL_Stat, DRS_DR_Stat, DRS_FCL_Stat, DRS_FCR_Stat,
|
||||
DRS_FPL_Stat, DRS_FPR_Stat, DRS_RLB_Stat, DRS_RRB_Stat};
|
||||
|
||||
static lin_event_id_t SEND_SENSOR_COM_x(tLinIO *linIo, uint8_t COM_ADR) {
|
||||
lin_event_id_t res = linIo->runCommand(linIo->env, COM_ADR, 40);
|
||||
SystemDelayMs(30);
|
||||
|
|
@ -249,214 +252,116 @@ static lin_event_id_t Get_DRS_Stat(tLinIO *linIo, tLinData *linData, tDRS_Stat *
|
|||
return res;
|
||||
}
|
||||
|
||||
// Вспомогательная функция: устанавливает три бита для группы led_group
|
||||
// в соответствии со значением count (0, 1, 2, 3)
|
||||
static void set_led_group(tCCU_DRS_Req *req, uint8_t led_group, uint8_t count) {
|
||||
// Определяем, какой из трёх битов должен быть установлен
|
||||
uint8_t b1 = (count == 1) ? 1 : 0;
|
||||
uint8_t b2 = (count == 2) ? 1 : 0;
|
||||
uint8_t b3 = (count == 3) ? 1 : 0;
|
||||
|
||||
switch (led_group) {
|
||||
case 0:
|
||||
req->CCU_DLLed1_Req = b1;
|
||||
req->CCU_DLLed2_Req = b2;
|
||||
req->CCU_DLLed3_Req = b3;
|
||||
break;
|
||||
case 1:
|
||||
req->CCU_DRLed1_Req = b1;
|
||||
req->CCU_DRLed2_Req = b2;
|
||||
req->CCU_DRLed3_Req = b3;
|
||||
break;
|
||||
case 2:
|
||||
req->CCU_FPLLed1_Req = b1;
|
||||
req->CCU_FPLLed2_Req = b2;
|
||||
req->CCU_FPLLed3_Req = b3;
|
||||
break;
|
||||
case 3:
|
||||
req->CCU_FPRLed1_Req = b1;
|
||||
req->CCU_FPRLed2_Req = b2;
|
||||
req->CCU_FPRLed3_Req = b3;
|
||||
break;
|
||||
case 4:
|
||||
req->CCU_RLBLed1_Req = b1;
|
||||
req->CCU_RLBLed2_Req = b2;
|
||||
req->CCU_RLBLed3_Req = b3;
|
||||
break;
|
||||
case 5:
|
||||
req->CCU_RRBLed1_Req = b1;
|
||||
req->CCU_RRBLed2_Req = b2;
|
||||
req->CCU_RRBLed3_Req = b3;
|
||||
break;
|
||||
case 6:
|
||||
req->CCU_FCLLed1_Req = b1;
|
||||
req->CCU_FCLLed2_Req = b2;
|
||||
req->CCU_FCLLed3_Req = b3;
|
||||
break;
|
||||
case 7:
|
||||
req->CCU_FCRLed1_Req = b1;
|
||||
req->CCU_FCRLed2_Req = b2;
|
||||
req->CCU_FCRLed3_Req = b3;
|
||||
break;
|
||||
default:
|
||||
// Недопустимый индекс – можно ничего не делать или добавить assert
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static lin_event_id_t Lin5_Scheduler(tLin5TaskSensor *env) {
|
||||
lin_event_id_t ret = LIN_NO_EVENT;
|
||||
|
||||
static uint32_t step = 0;
|
||||
for (uint8_t i = 0; i < LIN5_SENSOR_COUNT; ++i) {
|
||||
|
||||
/*
|
||||
// ---------------------------------------- d_DRS_DL_Stat ----------------------------------------------------------
|
||||
ret = Get_DRS_Stat(env->linIo, env->linData, &env->d_DRS_DL_Stat, DRS_DL_Stat);
|
||||
#if (LOG_LIN5_ACTUATOR == 1)
|
||||
ret = Get_DRS_Stat(env->linIo, env->linData, &env->d_DRS_Stat[i], DRS_SENSON_ADR_Stat[i]);
|
||||
|
||||
if (ret == LIN_RX_COMPLETED) {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5,
|
||||
"DRS_DL_Btn_Stat = %d DRS_DL_LinRespErr_Stat = %d DRS_DL_Err_Stat = %d",
|
||||
env->d_DRS_DL_Stat.DRS_Btn_Stat,
|
||||
env->d_DRS_DL_Stat.DRS_LinRespErr_Stat,
|
||||
env->d_DRS_DL_Stat.DRS_Err_Stat
|
||||
)
|
||||
} else {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5, "ERROR Get_DRS_DL_Stat = %d", ret)
|
||||
}
|
||||
if (env->d_DRS_Stat[i].DRS_Btn_Stat) {
|
||||
++env->LED_COUNT[i];
|
||||
|
||||
#endif
|
||||
|
||||
// ---------------------------------------- d_DRS_DR_Stat ----------------------------------------------------------
|
||||
ret = Get_DRS_Stat(env->linIo, env->linData, &env->d_DRS_DR_Stat, DRS_DR_Stat);
|
||||
#if (LOG_LIN5_ACTUATOR == 1)
|
||||
|
||||
if (ret == LIN_RX_COMPLETED) {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5,
|
||||
"DRS_DR_Btn_Stat = %d DRS_DR_LinRespErr_Stat = %d DRS_DR_Err_Stat = %d",
|
||||
env->d_DRS_DR_Stat.DRS_Btn_Stat,
|
||||
env->d_DRS_DR_Stat.DRS_LinRespErr_Stat,
|
||||
env->d_DRS_DR_Stat.DRS_Err_Stat
|
||||
)
|
||||
} else {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5, "ERROR Get_DRS_DR_Stat = %d", ret)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ---------------------------------------- d_DRS_FCL_Stat ----------------------------------------------------------
|
||||
ret = Get_DRS_Stat(env->linIo, env->linData, &env->d_DRS_FCL_Stat, DRS_FCL_Stat);
|
||||
#if (LOG_LIN5_ACTUATOR == 1)
|
||||
|
||||
if (ret == LIN_RX_COMPLETED) {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5,
|
||||
"DRS_FCL_Btn_Stat = %d DRS_FCL_LinRespErr_Stat = %d DRS_FCL_Err_Stat = %d",
|
||||
env->d_DRS_FCL_Stat.DRS_Btn_Stat,
|
||||
env->d_DRS_FCL_Stat.DRS_LinRespErr_Stat,
|
||||
env->d_DRS_FCL_Stat.DRS_Err_Stat
|
||||
)
|
||||
} else {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5, "ERROR Get_DRS_FCL_Stat = %d", ret)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ---------------------------------------- d_DRS_FCR_Stat ----------------------------------------------------------
|
||||
ret = Get_DRS_Stat(env->linIo, env->linData, &env->d_DRS_FCR_Stat, DRS_FCR_Stat);
|
||||
|
||||
#if (LOG_LIN5_ACTUATOR == 1)
|
||||
|
||||
if (ret == LIN_RX_COMPLETED) {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5,
|
||||
"DRS_FCR_Btn_Stat = %d DRS_FCR_LinRespErr_Stat = %d DRS_FCR_Err_Stat = %d",
|
||||
env->d_DRS_FCR_Stat.DRS_Btn_Stat,
|
||||
env->d_DRS_FCR_Stat.DRS_LinRespErr_Stat,
|
||||
env->d_DRS_FCR_Stat.DRS_Err_Stat
|
||||
)
|
||||
} else {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5, "ERROR Get_DRS_FCR_Stat = %d", ret)
|
||||
}
|
||||
|
||||
#endif
|
||||
*/
|
||||
|
||||
// ---------------------------------------- d_DRS_FPL_Stat ----------------------------------------------------------
|
||||
ret = Get_DRS_Stat(env->linIo, env->linData, &env->d_DRS_FPL_Stat, DRS_FPL_Stat);
|
||||
|
||||
if (env->d_DRS_FPL_Stat.DRS_Btn_Stat) {
|
||||
step = 0;
|
||||
}
|
||||
#if (LOG_LIN5_ACTUATOR == 1)
|
||||
|
||||
if (ret == LIN_RX_COMPLETED) {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5,
|
||||
"DRS_FPL_Btn_Stat = %d DRS_FPL_LinRespErr_Stat = %d DRS_FPL_Err_Stat = %d",
|
||||
env->d_DRS_FPL_Stat.DRS_Btn_Stat,
|
||||
env->d_DRS_FPL_Stat.DRS_LinRespErr_Stat,
|
||||
env->d_DRS_FPL_Stat.DRS_Err_Stat
|
||||
)
|
||||
|
||||
} else {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5, "ERROR Get_DRS_FPL_Stat = %d", ret)
|
||||
}
|
||||
|
||||
#endif
|
||||
/*
|
||||
// ---------------------------------------- d_DRS_FPR_Stat ----------------------------------------------------------
|
||||
ret = Get_DRS_Stat(env->linIo, env->linData, &env->d_DRS_FPR_Stat, DRS_FPR_Stat);
|
||||
#if (LOG_LIN5_ACTUATOR == 1)
|
||||
|
||||
if (ret == LIN_RX_COMPLETED) {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5,
|
||||
"DRS_FPR_Btn_Stat = %d DRS_FPR_LinRespErr_Stat = %d DRS_FPR_Err_Stat = %d",
|
||||
env->d_DRS_FPR_Stat.DRS_Btn_Stat,
|
||||
env->d_DRS_FPR_Stat.DRS_LinRespErr_Stat,
|
||||
env->d_DRS_FPR_Stat.DRS_Err_Stat
|
||||
)
|
||||
} else {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5, "ERROR Get_DRS_FPR_Stat = %d", ret)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ---------------------------------------- d_DRS_RLB_Stat ----------------------------------------------------------
|
||||
ret = Get_DRS_Stat(env->linIo, env->linData, &env->d_DRS_RLB_Stat, DRS_RLB_Stat);
|
||||
#if (LOG_LIN5_ACTUATOR == 1)
|
||||
|
||||
if (ret == LIN_RX_COMPLETED) {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5,
|
||||
"DRS_RLB_Btn_Stat = %d DRS_RLB_LinRespErr_Stat = %d DRS_RLB_Err_Stat = %d",
|
||||
env->d_DRS_RLB_Stat.DRS_Btn_Stat,
|
||||
env->d_DRS_RLB_Stat.DRS_LinRespErr_Stat,
|
||||
env->d_DRS_RLB_Stat.DRS_Err_Stat
|
||||
)
|
||||
} else {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5, "ERROR Get_DRS_RLB_Stat = %d", ret)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ---------------------------------------- d_DRS_RRB_Stat ----------------------------------------------------------
|
||||
ret = Get_DRS_Stat(env->linIo, env->linData, &env->d_DRS_RRB_Stat, DRS_RRB_Stat);
|
||||
#if (LOG_LIN5_ACTUATOR == 1)
|
||||
|
||||
if (ret == LIN_RX_COMPLETED) {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5,
|
||||
"DRS_RRB_Btn_Stat = %d DRS_RRB_LinRespErr_Stat = %d DRS_RRB_Err_Stat = %d",
|
||||
env->d_DRS_RRB_Stat.DRS_Btn_Stat,
|
||||
env->d_DRS_RRB_Stat.DRS_LinRespErr_Stat,
|
||||
env->d_DRS_RRB_Stat.DRS_Err_Stat
|
||||
)
|
||||
} else {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5, "ERROR Get_DRS_RRB_Stat = %d", ret)
|
||||
}
|
||||
|
||||
#endif
|
||||
*/
|
||||
|
||||
|
||||
if (step <= 3) {
|
||||
|
||||
uint8_t led1 = 0;
|
||||
uint8_t led2 = 0;
|
||||
uint8_t led3 = 0;
|
||||
|
||||
++step;
|
||||
|
||||
if (step == 1) {
|
||||
led1 = 1;
|
||||
led2 = 0;
|
||||
led3 = 0;
|
||||
if (env->LED_COUNT[i] > 3) {
|
||||
env->LED_COUNT[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (step == 2) {
|
||||
led1 = 0;
|
||||
led2 = 1;
|
||||
led3 = 0;
|
||||
}
|
||||
#if (LOG_LIN5_SENSOR == 1)
|
||||
|
||||
if (step == 3) {
|
||||
led1 = 0;
|
||||
led2 = 0;
|
||||
led3 = 1;
|
||||
}
|
||||
if (ret == LIN_RX_COMPLETED) {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5,
|
||||
"Sensor number %d: DRS_Btn_Stat = %d DRS_LinRespErr_Stat = %d DRS_Err_Stat = %d",
|
||||
i,
|
||||
env->d_DRS_Stat[i].DRS_Btn_Stat,
|
||||
env->d_DRS_Stat[i].DRS_LinRespErr_Stat,
|
||||
env->d_DRS_Stat[i].DRS_Err_Stat
|
||||
)
|
||||
|
||||
if (step == 4) {
|
||||
led1 = 0;
|
||||
led2 = 0;
|
||||
led3 = 0;
|
||||
}
|
||||
|
||||
|
||||
env->d_CCU_DRS_Req.CCU_FPLLed1_Req = led1;
|
||||
env->d_CCU_DRS_Req.CCU_FPLLed2_Req = led2;
|
||||
env->d_CCU_DRS_Req.CCU_FPLLed3_Req = led3;
|
||||
|
||||
env->d_CCU_DRS_Req.BCM_SwIndIntens_Stat = 0;
|
||||
|
||||
env->d_CCU_DRS_Req.BCM_IndFadingTime_Req = 2;
|
||||
|
||||
ret = Set_CCU_DRS_Req(env->linIo, env->linData, &env->d_CCU_DRS_Req);
|
||||
|
||||
|
||||
#if (LOG_LIN5_ACTUATOR == 1)
|
||||
if (ret == LIN_TX_COMPLETED) {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5, "OK Set_CCU_DRS_Req = %d", ret)
|
||||
} else {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5, "ERROR Set_CCU_DRS_Req = %d", ret)
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5, "Sensor number %d: ERROR Get_FPL_Stat = %d", i, ret)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
SystemDelayMs(50);
|
||||
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < LIN5_SENSOR_COUNT; ++i) {
|
||||
set_led_group(&env->d_CCU_DRS_Req, i, env->LED_COUNT[i]);
|
||||
}
|
||||
env->d_CCU_DRS_Req.BCM_SwIndIntens_Stat = 0;
|
||||
env->d_CCU_DRS_Req.BCM_IndFadingTime_Req = 2;
|
||||
|
||||
ret = Set_CCU_DRS_Req(env->linIo, env->linData, &env->d_CCU_DRS_Req);
|
||||
|
||||
|
||||
#if (LOG_LIN5_SENSOR == 1)
|
||||
if (ret == LIN_TX_COMPLETED) {
|
||||
// LoggerFormatInfo(LOGGER, LOG_SIGN5, "OK Set_CCU_DRS_Req = %d", ret)
|
||||
} else {
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN5, "Sensor Set_CCU_DRS_Req (ERROR %d)", ret)
|
||||
}
|
||||
#endif
|
||||
|
||||
SystemDelayMs(50);
|
||||
|
||||
|
||||
return LIN_NO_EVENT;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@
|
|||
#include "LinIO.h"
|
||||
#include "LoggerInterface.h"
|
||||
|
||||
#define LOG_LIN4_ACTUATOR 1
|
||||
#define LOG_LIN5_ACTUATOR 0
|
||||
#define LOG_LIN4_SENSOR 1
|
||||
#define LOG_LIN5_SENSOR 1
|
||||
|
||||
#define LIN5_SENSOR_COUNT 8
|
||||
|
||||
#define AirQS_Stat 0x14
|
||||
#define Aroma_Stat 0x5
|
||||
|
|
@ -99,11 +101,11 @@ typedef struct __attribute__ ((packed)) {
|
|||
} teTXV_rHVAC_Stat;
|
||||
|
||||
typedef struct __attribute__ ((packed)) {
|
||||
uint8_t eTXV_batChiller_Pos_Stat : 7; // 0
|
||||
uint8_t eTXV_batChiller_LinRespErr_Stat : 1; // 7
|
||||
uint8_t eTXV_batChiller_Err_Stat : 2; // 8
|
||||
uint8_t eTXV_batChiller_Pressure_Val : 6; // 10
|
||||
uint8_t eTXV_batChiller_Temp_Val : 7; // 16
|
||||
uint8_t eTXV_batChiller_Pos_Stat: 7; // 0
|
||||
uint8_t eTXV_batChiller_LinRespErr_Stat: 1; // 7
|
||||
uint8_t eTXV_batChiller_Err_Stat: 2; // 8
|
||||
uint8_t eTXV_batChiller_Pressure_Val: 6; // 10
|
||||
uint8_t eTXV_batChiller_Temp_Val: 7; // 16
|
||||
} teTXV_batChiller_Stat;
|
||||
|
||||
typedef struct __attribute__ ((packed)) {
|
||||
|
|
@ -221,7 +223,7 @@ typedef struct {
|
|||
|
||||
struct {
|
||||
osThreadId_t id;
|
||||
uint32_t stack[256];
|
||||
uint32_t stack[384];
|
||||
StaticTask_t controlBlock;
|
||||
osThreadAttr_t attr;
|
||||
} threadLin;
|
||||
|
|
@ -239,6 +241,7 @@ typedef struct {
|
|||
|
||||
tLoggerInterface *logger;
|
||||
|
||||
/*
|
||||
tDRS_Stat d_DRS_DL_Stat;
|
||||
tDRS_Stat d_DRS_DR_Stat;
|
||||
tDRS_Stat d_DRS_FCL_Stat;
|
||||
|
|
@ -247,12 +250,19 @@ typedef struct {
|
|||
tDRS_Stat d_DRS_FPR_Stat;
|
||||
tDRS_Stat d_DRS_RLB_Stat;
|
||||
tDRS_Stat d_DRS_RRB_Stat;
|
||||
*/
|
||||
tDRS_Stat d_DRS_Stat[LIN5_SENSOR_COUNT];
|
||||
|
||||
uint8_t LED_COUNT[LIN5_SENSOR_COUNT];
|
||||
uint8_t LED_STATE_1[LIN5_SENSOR_COUNT];
|
||||
uint8_t LED_STATE_2[LIN5_SENSOR_COUNT];
|
||||
uint8_t LED_STATE_3[LIN5_SENSOR_COUNT];
|
||||
|
||||
tCCU_DRS_Req d_CCU_DRS_Req;
|
||||
|
||||
struct {
|
||||
osThreadId_t id;
|
||||
uint32_t stack[256];
|
||||
uint32_t stack[384];
|
||||
StaticTask_t controlBlock;
|
||||
osThreadAttr_t attr;
|
||||
} threadLin;
|
||||
|
|
|
|||
Loading…
Reference in New Issue