2025-05-30 14:10:31 +08:00
|
|
|
/*!
|
|
|
|
* @文件名 logic_mode_eol.c
|
2025-05-21 11:31:07 +08:00
|
|
|
*
|
2025-05-30 14:10:31 +08:00
|
|
|
* @功能描述
|
|
|
|
* 开机一定时间内,如果检测到上位机发来的命令,则进入EOL模式,方便进行下线配置
|
2025-05-21 11:31:07 +08:00
|
|
|
*/
|
2025-05-30 14:10:31 +08:00
|
|
|
#include "logic_public.h"
|
2025-05-21 11:31:07 +08:00
|
|
|
|
|
|
|
#define READ_COMD 0x22
|
|
|
|
#define WRITE_COMD 0x2E
|
|
|
|
|
|
|
|
|
|
|
|
void fml_test_mode(uint8_t *pBuf);
|
|
|
|
|
|
|
|
uint8_t test_slaveRxBuffer[8];
|
|
|
|
uint8_t test_slaveTxBuffer[6];
|
|
|
|
bool test_mode_flag = true;
|
|
|
|
|
|
|
|
extern ST_VENDOR_DATA gst_vendor_data;
|
|
|
|
|
|
|
|
void (*p_test_commod)(uint8_t*) = fml_test_mode;
|
|
|
|
static task_t s_test_task;
|
|
|
|
static task_t s_vendor_task;
|
|
|
|
|
|
|
|
extern void fml_ds90ub948_read_commod(uint8_t *pBuf);
|
|
|
|
extern uint8_t pub_slaveRxBuffer[2];
|
|
|
|
extern uint8_t pub_slaveTxBuffer[1];
|
|
|
|
extern uint8_t result1,result2;
|
|
|
|
|
|
|
|
|
|
|
|
void (*p_turn_read)(uint8_t*) = fml_ds90ub948_read_commod;
|
|
|
|
//extern static task_t s_test_task;
|
|
|
|
|
|
|
|
void logic_vendor_task(void *arg, uint32_t event)
|
|
|
|
{
|
2025-05-30 14:10:31 +08:00
|
|
|
(void)arg;
|
2025-05-21 11:31:07 +08:00
|
|
|
if(event == 1)
|
|
|
|
{
|
|
|
|
printf("vendor_data_load");
|
|
|
|
vendor_data_load();
|
|
|
|
}
|
|
|
|
else if(event == 2)
|
|
|
|
{
|
|
|
|
printf("vendor_data_save");
|
|
|
|
vendor_data_save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void check_one_second(void)
|
|
|
|
{
|
|
|
|
if(test_slaveRxBuffer[0] == 0 && jiffies>100)
|
|
|
|
{
|
|
|
|
test_mode_flag = false;
|
|
|
|
int sRx_length = sizeof(test_slaveRxBuffer);
|
|
|
|
int sTx_length = sizeof(test_slaveTxBuffer);
|
|
|
|
fml_ds90ub948_close();
|
|
|
|
i2c_pal_lpi2c0_SlaveConfig0.slaveAddress = 0x6B;
|
|
|
|
fml_ds90ub948_open();
|
|
|
|
fml_ds90ub948_init(pub_slaveRxBuffer,&sRx_length,pub_slaveTxBuffer,&sTx_length,p_turn_read,NULL);
|
|
|
|
cola_timer_stop(&s_test_task);
|
|
|
|
}
|
|
|
|
}
|
2025-05-30 14:10:31 +08:00
|
|
|
|
2025-05-21 11:31:07 +08:00
|
|
|
void test_mode_open(void)
|
|
|
|
{
|
|
|
|
int test_Rx_length = sizeof(test_slaveRxBuffer);
|
|
|
|
int test_Tx_length = sizeof(test_slaveTxBuffer);
|
|
|
|
fml_ds90ub948_init(test_slaveRxBuffer,test_Rx_length,test_slaveTxBuffer,test_Tx_length,p_test_commod,NULL);
|
|
|
|
cola_timer_create(&s_test_task, check_one_second, NULL);
|
|
|
|
cola_timer_start(&s_test_task, EN_COLA_TIMER_ALWAYS, 10);
|
|
|
|
cola_task_create(&s_vendor_task, logic_vendor_task, NULL);
|
|
|
|
//vendor_factory_set();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void fml_test_mode(uint8_t *pBuf)
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (pBuf[1])
|
|
|
|
{
|
|
|
|
case APP_VERSION:
|
|
|
|
if(pBuf[0] == READ_COMD)
|
|
|
|
{
|
|
|
|
test_slaveTxBuffer[0] = gst_vendor_data.SOFTWARE_VERSION0;
|
|
|
|
test_slaveTxBuffer[1] = gst_vendor_data.SOFTWARE_VERSION1;
|
|
|
|
test_slaveTxBuffer[2] = gst_vendor_data.SOFTWARE_VERSION2;
|
|
|
|
test_slaveTxBuffer[3] = gst_vendor_data.SOFTWARE_VERSION3;
|
|
|
|
test_slaveTxBuffer[4] = gst_vendor_data.SOFTWARE_VERSION4;
|
|
|
|
test_slaveTxBuffer[5] = gst_vendor_data.SOFTWARE_VERSION5;
|
|
|
|
}
|
|
|
|
else if (pBuf[0] == WRITE_COMD)
|
|
|
|
{
|
|
|
|
gst_vendor_data.SOFTWARE_VERSION0 = pBuf[2];
|
|
|
|
gst_vendor_data.SOFTWARE_VERSION1 = pBuf[3];
|
|
|
|
gst_vendor_data.SOFTWARE_VERSION2 = pBuf[4];
|
|
|
|
gst_vendor_data.SOFTWARE_VERSION3 = pBuf[5];
|
|
|
|
gst_vendor_data.SOFTWARE_VERSION4 = pBuf[6];
|
|
|
|
gst_vendor_data.SOFTWARE_VERSION5 = pBuf[7];
|
|
|
|
}
|
|
|
|
/* code */
|
|
|
|
break;
|
|
|
|
case PN_VERSION:
|
|
|
|
if(pBuf[0] == READ_COMD)
|
|
|
|
{
|
|
|
|
test_slaveTxBuffer[0] = gst_vendor_data.PN_VERSION0;
|
|
|
|
test_slaveTxBuffer[1] = gst_vendor_data.PN_VERSION1;
|
|
|
|
test_slaveTxBuffer[2] = gst_vendor_data.PN_VERSION2;
|
|
|
|
test_slaveTxBuffer[3] = gst_vendor_data.PN_VERSION3;
|
|
|
|
test_slaveTxBuffer[4] = gst_vendor_data.PN_VERSION4;
|
|
|
|
test_slaveTxBuffer[5] = gst_vendor_data.PN_VERSION5;
|
|
|
|
}
|
|
|
|
else if (pBuf[0] == WRITE_COMD)
|
|
|
|
{
|
|
|
|
gst_vendor_data.PN_VERSION0 = pBuf[2];
|
|
|
|
gst_vendor_data.PN_VERSION1 = pBuf[3];
|
|
|
|
gst_vendor_data.PN_VERSION2 = pBuf[4];
|
|
|
|
gst_vendor_data.PN_VERSION3 = pBuf[5];
|
|
|
|
gst_vendor_data.PN_VERSION4 = pBuf[6];
|
|
|
|
gst_vendor_data.PN_VERSION5 = pBuf[7];
|
|
|
|
}
|
|
|
|
/* code */
|
|
|
|
break;
|
|
|
|
case HARDWARE_VERSION:
|
|
|
|
if(pBuf[0] == READ_COMD)
|
|
|
|
{
|
|
|
|
test_slaveTxBuffer[0] = gst_vendor_data.HARDWARE_VERSION0;
|
|
|
|
test_slaveTxBuffer[1] = gst_vendor_data.HARDWARE_VERSION1;
|
|
|
|
test_slaveTxBuffer[2] = gst_vendor_data.HARDWARE_VERSION2;
|
|
|
|
test_slaveTxBuffer[3] = gst_vendor_data.HARDWARE_VERSION3;
|
|
|
|
test_slaveTxBuffer[4] = gst_vendor_data.HARDWARE_VERSION4;
|
|
|
|
test_slaveTxBuffer[5] = gst_vendor_data.HARDWARE_VERSION5;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (pBuf[0] == WRITE_COMD)
|
|
|
|
{
|
|
|
|
gst_vendor_data.HARDWARE_VERSION0 = pBuf[2];
|
|
|
|
gst_vendor_data.HARDWARE_VERSION1 = pBuf[3];
|
|
|
|
gst_vendor_data.HARDWARE_VERSION2 = pBuf[4];
|
|
|
|
gst_vendor_data.HARDWARE_VERSION3 = pBuf[5];
|
|
|
|
gst_vendor_data.HARDWARE_VERSION4 = pBuf[6];
|
|
|
|
gst_vendor_data.HARDWARE_VERSION5 = pBuf[7];
|
|
|
|
}
|
|
|
|
/* code */
|
|
|
|
break;
|
|
|
|
case PANNL_HARDWARE:
|
|
|
|
|
|
|
|
/* code */
|
|
|
|
break;
|
|
|
|
case PANNL_SOFTWAER:
|
|
|
|
/* code */
|
|
|
|
break;
|
|
|
|
case BLACKLIGHT_EN:
|
|
|
|
if (pBuf[0] == WRITE_COMD)
|
|
|
|
{
|
2025-05-30 14:10:31 +08:00
|
|
|
fml_max25512_set_bklight_on(pBuf[2]);
|
2025-05-21 11:31:07 +08:00
|
|
|
}
|
|
|
|
/* code */
|
|
|
|
break;
|
|
|
|
case BLACKLIGHT_DUTY:
|
|
|
|
if(pBuf[0] == READ_COMD)
|
|
|
|
{
|
|
|
|
test_slaveTxBuffer[0] = pwm_pal_1_configs.pwmChannels[0].duty;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (pBuf[0] == WRITE_COMD)
|
|
|
|
{
|
|
|
|
fml_pwm_change_duty(pBuf[2]);
|
|
|
|
}
|
|
|
|
/* code */
|
|
|
|
break;
|
|
|
|
case DIAGNOSTIC_1:
|
|
|
|
test_slaveTxBuffer[0] = result1;
|
|
|
|
/* code */
|
|
|
|
break;
|
|
|
|
case DIAGNOSTIC_2:
|
|
|
|
test_slaveTxBuffer[0] = result2;
|
|
|
|
/* code */
|
|
|
|
break;
|
|
|
|
case TEMP_AD_VALUE:
|
2025-05-30 14:10:31 +08:00
|
|
|
test_slaveTxBuffer[0] = fml_convert_ntc_ad_to_temp();
|
2025-05-21 11:31:07 +08:00
|
|
|
/* code */
|
|
|
|
break;
|
|
|
|
case TP_POSITION:
|
|
|
|
/* code */
|
|
|
|
break;
|
|
|
|
case TP_TYPE:
|
|
|
|
/* code */
|
|
|
|
break;
|
|
|
|
case DISPLAY_COLAL:
|
|
|
|
fml_gpio_write(OUT_TFT_BIST,true);
|
|
|
|
switch(pBuf[2])
|
|
|
|
{
|
|
|
|
case 0x01:
|
|
|
|
fml_tft_write_BIST_mode(PTGN_RED);
|
|
|
|
break;
|
|
|
|
case 0x02:
|
|
|
|
fml_tft_write_BIST_mode(PTGN_GREEN);
|
|
|
|
break;
|
|
|
|
case 0x03:
|
|
|
|
fml_tft_write_BIST_mode(PTGN_BLUE);
|
|
|
|
break;
|
|
|
|
case 0x04:
|
|
|
|
fml_tft_write_BIST_mode(PTGN_WHITE);
|
|
|
|
break;
|
|
|
|
case 0x05:
|
|
|
|
fml_tft_write_BIST_mode(PTGN_BLACK);
|
|
|
|
break;
|
|
|
|
case 0x06:
|
|
|
|
fml_tft_write_BIST_mode(PTGN_CHESS_B);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
/* code */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|