diff --git a/.vscode/settings.json b/.vscode/settings.json index 5716d4d..05cd8ca 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,7 @@ { "files.associations": { "rte.h": "c", - "sysdiagdetect.h": "c" + "sysdiagdetect.h": "c", + "touch_example.h": "c" } } \ No newline at end of file diff --git a/firmware/p417_SWTL.X/nbproject/Makefile-genesis.properties b/firmware/p417_SWTL.X/nbproject/Makefile-genesis.properties index f2b6ffb..449cad3 100644 --- a/firmware/p417_SWTL.X/nbproject/Makefile-genesis.properties +++ b/firmware/p417_SWTL.X/nbproject/Makefile-genesis.properties @@ -1,5 +1,5 @@ # -#Sat Aug 24 10:49:00 CST 2024 +#Sat Sep 14 09:55:05 CST 2024 mcal.com-microchip-mplab-nbide-toolchain-xc32-XC32LanguageToolchain.md5=1eaf555a844840d91945cb14109201c3 conf.ids=mcal mcal.languagetoolchain.version=4.10 diff --git a/firmware/p417_SWTL.X/nbproject/private/private.xml b/firmware/p417_SWTL.X/nbproject/private/private.xml index 6807a2b..3d88403 100644 --- a/firmware/p417_SWTL.X/nbproject/private/private.xml +++ b/firmware/p417_SWTL.X/nbproject/private/private.xml @@ -2,6 +2,8 @@ - + + file:/F:/FCB_project/P417/CODE/20240727HW06/P417_SWTL/firmware/src/TouchPanel/TouchPanel.c + diff --git a/firmware/src/DiagnosticL/UDS/UDS_CoreServices_CB.h b/firmware/src/DiagnosticL/UDS/UDS_CoreServices_CB.h index 69c3588..ce4097c 100644 --- a/firmware/src/DiagnosticL/UDS/UDS_CoreServices_CB.h +++ b/firmware/src/DiagnosticL/UDS/UDS_CoreServices_CB.h @@ -223,6 +223,8 @@ typedef unsigned char UI_8; #define DID_PRESEE_SEN_SIGNAL ((UI_16)0x7021) #define DID_PRESEE_SEN_PRE_VAL ((UI_16)0x7022) +#define DID_RESET_SOURCE ((UI_16)0x7030) + /*--------------------------- Global variables ---------------------------- */ //#pragma push diff --git a/firmware/src/DiagnosticL/UDS/UDS_DIDNvm.c b/firmware/src/DiagnosticL/UDS/UDS_DIDNvm.c index 34ff0ee..7921bad 100644 --- a/firmware/src/DiagnosticL/UDS/UDS_DIDNvm.c +++ b/firmware/src/DiagnosticL/UDS/UDS_DIDNvm.c @@ -78,8 +78,8 @@ typedef struct{ * Private variables */ const UI_8 NVM_DID_CD_VIN[DLC_DID_CD_VIN] = GAC_VIN_DEFAULT_VALUE; -const UI_8 NVM_Reprogramming_Date_App[DLC_DID_REPROGRAMMING_DATE] = {0x20,0x24,0x08,0x19}; -const UI_8 NVM_DID_CD_SUPPLIER_ID[DLC_SYSTEM_SUPPLIER_ID] = {'2','4','0','8','1','9'}; +const UI_8 NVM_Reprogramming_Date_App[DLC_DID_REPROGRAMMING_DATE] = {0x20,0x24,0x09,0x14}; +const UI_8 NVM_DID_CD_SUPPLIER_ID[DLC_SYSTEM_SUPPLIER_ID] = {'2','4','0','9','1','4'}; const UI_8 NVM_Repair_Shop_Code[DLC_REPAIR_SHOP_CODE] = GAC_ECU_REPAIR_SHOP_CODE; const UI_8 NVM_DID_CD_HW_VERSION[DLC_GAC_HW_VERSION] = {'H','W','0','6',0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20}; static uint8 RAM_DID_CD_VIN[DLC_DID_CD_VIN]; @@ -570,6 +570,16 @@ t_UDS_ERR Get_DID_Pre_Value(uint8 *data) return ISO15765_3_POSITIVE_RESPONSE; } +t_UDS_ERR Get_DID_ResetSource(uint8 *data) +{ + uint8_t reset_source_buf[20]; + SmartEE_Read(0x400,reset_source_buf,20); + + memcpy(data,reset_source_buf,20); + + return ISO15765_3_POSITIVE_RESPONSE; +} + t_UDS_ERR Get_DID_Reprogramming_Date(uint8 *data) { //memcpy(data, RAM_DID_CD_REPROGRAMMING_DATE, sizeof(RAM_DID_CD_REPROGRAMMING_DATE)); diff --git a/firmware/src/DiagnosticL/UDS/UDS_DiDRead_CB.c b/firmware/src/DiagnosticL/UDS/UDS_DiDRead_CB.c index 3c03561..9b73ba1 100644 --- a/firmware/src/DiagnosticL/UDS/UDS_DiDRead_CB.c +++ b/firmware/src/DiagnosticL/UDS/UDS_DiDRead_CB.c @@ -218,6 +218,7 @@ t_UDSReadDidSubCommands uds_did_read_commands[] = { DID_PRESEE_SEN_BASELINE , 2, UDS_DEFAULT_SESSION, Get_DID_PressSen_Baseline }, { DID_PRESEE_SEN_SIGNAL , 2, UDS_DEFAULT_SESSION, Get_DID_PressSen_Signal }, { DID_PRESEE_SEN_PRE_VAL , 2, UDS_DEFAULT_SESSION, Get_DID_Pre_Value }, + {DID_RESET_SOURCE , 20, UDS_DEFAULT_SESSION , Get_DID_ResetSource }, {DID_FUN1, 2, UDS_DEFAULT_SESSION, Get_DID_Fun1}, diff --git a/firmware/src/DiagnosticL/UDS/UDS_Services_Common.h b/firmware/src/DiagnosticL/UDS/UDS_Services_Common.h index 9b89eb7..981d6be 100644 --- a/firmware/src/DiagnosticL/UDS/UDS_Services_Common.h +++ b/firmware/src/DiagnosticL/UDS/UDS_Services_Common.h @@ -159,6 +159,7 @@ t_UDS_ERR Get_DID_TouchSen13_Signal(uint8 *data); t_UDS_ERR Get_DID_PressSen_Baseline(uint8 *data); t_UDS_ERR Get_DID_PressSen_Signal(uint8 *data); t_UDS_ERR Get_DID_Pre_Value(uint8 *data); +t_UDS_ERR Get_DID_ResetSource(uint8 *data); t_UDS_ERR Get_DID_CD_SYSID_CALIRATION_DATE(uint8 *data); t_UDS_ERR Set_DID_CD_CALIRATION_DATE(uint8 *data); diff --git a/firmware/src/OsekCom/OsekCom.c b/firmware/src/OsekCom/OsekCom.c index 3d29fcf..0e83a10 100644 --- a/firmware/src/OsekCom/OsekCom.c +++ b/firmware/src/OsekCom/OsekCom.c @@ -150,7 +150,7 @@ #define OT_TX_FRM_SWTLPRIVATEDHUCANFR04 ((uint32_t)(0)) #define PT_TX_FRM_SWTLPRIVATEDHUCANFR04 ((uint32_t)(400)) #define OT_TX_FRM_SWTLPRIVATEDHUCANFR03 ((uint32_t)(0)) -#define PT_TX_FRM_SWTLPRIVATEDHUCANFR03 ((uint32_t)(100)) +#define PT_TX_FRM_SWTLPRIVATEDHUCANFR03 ((uint32_t)(400)) #define OT_TX_FRM_SWTLPRIVATEDHUCANFR02 ((uint32_t)(0)) #define PT_TX_FRM_SWTLPRIVATEDHUCANFR02 ((uint32_t)(100)) #define OT_TX_FRM_SWTLPRIVATEDHUCANFR01 ((uint32_t)(0)) diff --git a/firmware/src/RTE/RTE.c b/firmware/src/RTE/RTE.c index 339ba83..2fc99a9 100644 --- a/firmware/src/RTE/RTE.c +++ b/firmware/src/RTE/RTE.c @@ -33,6 +33,7 @@ #include "plib_systick.h" #include "FunctionState.h" #include "SysDiagDetect.h" +#include "touch_api_ptc.h" // For SWTL // #include "Global.h" @@ -689,9 +690,9 @@ uint8_t RTE_Get_TouchBoard_XY_Touch_And_Below_1N(void) // 0 false 1 true { //满足防误触 Allow_Touch_counter++; - if (Allow_Touch_counter >= 10)//40ms + if (Allow_Touch_counter >= 15)//60ms { - Allow_Touch_counter = 10; + Allow_Touch_counter = 15; Allow_Touch_flag = 0; } } @@ -725,6 +726,8 @@ uint8_t RTE_Get_CAN_ActvnOfSteerWhlIllmn(void) return rtn_data; } + +extern uint8_t Msg30_timeout_flag; // LED Day/Night Mode switch uint8_t RTE_Get_CAN_TwliBriSts(void) { @@ -733,6 +736,11 @@ uint8_t RTE_Get_CAN_TwliBriSts(void) (void)ReceiveMessage(SIG_TWLIBRISTS, &rtn_data); + if (Msg30_timeout_flag == 1) + { + rtn_data = 0; + } + return rtn_data; } @@ -1334,7 +1342,17 @@ void RTE_Set_All_UB(void) InitMessage(SIG_SWTLPARTNOCMPL_UB, &UbInitValue); InitMessage(SIG_SWTLSERNO_UB, &UbInitValue); } +const uint16_t max_on_time_arr[16] = { + // 0 1 2 3 4 5 6 7 + 10,10,10,50,50,50,50,50, + 50,50,50,50,50,10,10,10, +}; +const uint16_t low_baseline_reset_arr[16] = { + // 0 1 2 3 4 5 6 7 + 40,40,40,40,40,40,40,40, + 40,40,40,40,40,40,40,40, +}; #if 1 void RTE_Set_All_Test_Value(void) { @@ -1342,6 +1360,7 @@ void RTE_Set_All_Test_Value(void) uint16_t Press_signal, Press_preload; uint8_t i,frccdata[8]={0}; static uint32_t Press_reset_counter[16], Press_repeat_counter[16], baseline_error_counter, baseline_error_repeat_counter; + static uint32_t low_baseline_reset_counter[16]; Press_baseline = Get_forcedetect_basline_value(); Press_signal = Get_forcedetect_force_value(); Press_preload = Get_forcedetect_preload_value(); @@ -1356,13 +1375,13 @@ void RTE_Set_All_Test_Value(void) if (get_sensor_node_signal(i) > (get_sensor_node_reference(i) + qtlib_key_configs_set1[i].channel_threshold)) { Press_reset_counter[i]++; - if (Press_reset_counter[i] > 25000) // 50s = 50000 ms + if (Press_reset_counter[i] >= (500 * max_on_time_arr[i])) // { if (Press_repeat_counter[i] == 0) { Press_repeat_counter[i] = 55000; // 110S Press_reset_counter[i] = 0; - // update_sensor_node_reference(i,get_sensor_node_signal(i)); + calibrate_node(i); } else { @@ -1379,6 +1398,22 @@ void RTE_Set_All_Test_Value(void) { Press_repeat_counter[i]--; } + if (get_sensor_node_signal(i) + low_baseline_reset_arr[i] < get_sensor_node_reference(i)) + { + low_baseline_reset_counter[i]++; + if (low_baseline_reset_counter[i] > 250) + { + low_baseline_reset_counter[i] = 0; + calibrate_node(i); + } + + } + else + { + low_baseline_reset_counter[i] = 0; + } + + } for (i = 0; i < 16; i++) { diff --git a/firmware/src/TouchPanel/TouchPanel.c b/firmware/src/TouchPanel/TouchPanel.c index 744e308..9764f84 100644 --- a/firmware/src/TouchPanel/TouchPanel.c +++ b/firmware/src/TouchPanel/TouchPanel.c @@ -21,8 +21,8 @@ #include "smartee.h" #include "SysDiagDetect.h" -static TouchButtons_type key_status[BTN_MAX_CH_NUM - 5U] = {0}; -static TouchSurface_type TouchSurface; +static TouchButtons_type key_status[6] = {0}; + static Buttons_SignalType Buttons_Signal[BTN_MAX_CH_NUM] = {BUTTON_RELEASE}; TouchSurface_Convert_type Surface_Convert; @@ -41,6 +41,10 @@ volatile uint8 last_Vibra_force_level = 0; volatile uint8 Over3N_vibra_req = 0x00; volatile uint8 Below1P5N_vibra_req = 0x00; +uint8 K_Vibra_Trig_adas = 0; +uint8 K_Vibra_Trig_cancel = 0; +uint8 K_Vibra_Trig_resume = 0; + uint8 UDS_Vibration_Gain = 0; uint8 UDS_DAC_Timer_Period = 80; uint8 Touch_Flag = TOUCH_KET_OFF; @@ -57,6 +61,48 @@ uint8 Surface_Button = 0xff; #define BTN_RIGHT_DEFAULT 372 #define BTN_CONFIRM_DEFAULT 303 +struct Point +{ + float x; + float y; +}; + + +struct Point Point_Up[4] = { + {76, 0}, + {255, 41}, + {206, 87}, + {135, 87}, +}; + +struct Point Point_Down[4] = { + {135, 169}, + {206, 169}, + {255, 199}, + {106, 255}, +}; + +struct Point Point_Right[4] = { + {76, 21}, + {135, 87}, + {135, 169}, + {96, 255}, +}; + +struct Point Point_Left[4] = { + {206, 87}, + {255, 48}, + {255, 183}, + {206, 169}, +}; + +struct Point Point_Confirm[4] = { + {140, 92}, + {206, 92}, + {206, 164}, + {140, 164}, +}; + // force Trig threshold static uint16 Button0_GetRESUME1_Trig_Threshold(void) { @@ -75,15 +121,6 @@ static uint16 Button0_GetRESUME1_Trig_Threshold(void) // return 800; } -// static uint16 Button1_GetVoice2_Trig_Threshold(void) -//{ -// return 400; -// } - -// static uint16 Button2_GetVol2_Trig_Threshold(void) -//{ -// return 1600; -// } static uint16 Button3_GetADAS1_Trig_Threshold(void) { @@ -101,10 +138,6 @@ static uint16 Button3_GetADAS1_Trig_Threshold(void) return rtn; } -// static uint16 Button4_GetMenu2_Trig_Threshold(void) -//{ -// return 1600; -// } static uint16 Button5_GetCANCEL1_Trig_Threshold(void) { @@ -219,15 +252,6 @@ static uint16 Button0_GetRESUME1_Release_Threshold(void) return rtn; } -// static uint16 Button1_GetVoice2_Release_Threshold(void) -//{ -// return 200; -// } - -// static uint16 Button2_GetVol2_Release_Threshold(void) -//{ -// return 400; -// } static uint16 Button3_GetADAS1_Release_Threshold(void) { @@ -245,10 +269,6 @@ static uint16 Button3_GetADAS1_Release_Threshold(void) return rtn; } -// static uint16 Button4_GetMenu2_Release_Threshold(void) -//{ -// return 400; -// } static uint16 Button5_GetCANCEL1_Release_Threshold(void) { @@ -434,7 +454,7 @@ void TouchPanel_init(void) uint8 index; // touch_init(); uint8_t eedata[5]; - LIB_Mem_MemSet(&TouchSurface, 0x00U, sizeof(TouchSurface_type)); + LIB_Mem_MemSet(&Surface_Convert, 0x00U, sizeof(TouchSurface_Convert_type)); SmartEE_Read(0x780, eedata, 3); if (eedata[0] < 4) @@ -485,12 +505,7 @@ void GetSurface_Position(uint8 *x, uint8 *y) } } -TP_SlideDirection_Enum TouchPanel_SlideEventRead(void) -{ - TP_SlideDirection_Enum Dir = TP_SlideDirection_NONE; - return Dir; -} Buttons_SignalType TouchPanel_BtnSignalRead(Buttons_ChType ChId) { @@ -565,11 +580,7 @@ static PanelPress_LevelType TouchPanel_PressCheck(void) uint16 Backup_Force_Value; Backup_Force_Value = Touch_Sensor_delta03 + Touch_Sensor_delta04 + Touch_Sensor_delta05 + Touch_Sensor_delta06 + Touch_Sensor_delta07 + +Touch_Sensor_delta08 + Touch_Sensor_delta09 + Touch_Sensor_delta10 + Touch_Sensor_delta11 + Touch_Sensor_delta12; - // float32 PressNValueTable[3][2] = { - // {1.21f, 1.73f}, - // {0.5f, 3.0f}, - // {1.0f, 1.8f} - // }; + if (CurrentPosition != 0xff) { @@ -611,162 +622,68 @@ static PanelPress_LevelType TouchPanel_PressCheck(void) if (Force_Sens_Err == 0) { if (FilterValue <= ((float32)tempForceRelease / (float32)0xF2)) - { //< 1.5N - // ForceHcount = 0; - // ForceMcount = 0; - // ForceLcount++; + { P_force_Reach2_flag = 0; - // if(ForceLcount > 40) - //{ - // ForceLcount = 40; - ret_Press = PANEL_PRESS_LEVEL0; - // } - Vibra_force_level = PANEL_PRESS_LEVEL0; } else if (FilterValue >= ((float32)tempForceRelease / (float32)0xF2) && FilterValue < ((float32)tempForcePress / (float32)0xF2)) - { // 1.5N~~3N - // ForceHcount = 0; - // ForceMcount++; - // ForceLcount = 0; - // if(ForceMcount > 40) - // { - // ForceMcount = 40; + { if (P_force_Reach2_flag == 1) { - // if(TOUCH_SCREEN_CONTACT_AREA_INVALID_NUM > get_contact_size()) - //{ - Vibra_force_level = PANEL_PRESS_LEVEL2; ret_Press = PANEL_PRESS_LEVEL2; - //} - // else - //{ - // ret_Press = PANEL_PRESS_LEVEL0; - // Vibra_force_level=PANEL_PRESS_LEVEL0; - //} } else { - // if(TOUCH_SCREEN_CONTACT_AREA_INVALID_NUM > get_contact_size()) - //{ - Vibra_force_level = PANEL_PRESS_LEVEL1; ret_Press = PANEL_PRESS_LEVEL1; - //} - // else - //{ - // ret_Press = PANEL_PRESS_LEVEL0; - // Vibra_force_level=PANEL_PRESS_LEVEL0; - //} } } else - { //>=3 - // ForceHcount++; - // ForceMcount = 0; - // ForceLcount = 0; + { P_force_Reach2_flag = 1; - // if(ForceHcount > 40) - // { - // ForceHcount = 40; - - // if(TOUCH_SCREEN_CONTACT_AREA_INVALID_NUM > get_contact_size()) - //{ + ret_Press = PANEL_PRESS_LEVEL2; - //} - // else - //{ - // ret_Press = PANEL_PRESS_LEVEL0; - // Vibra_force_level=PANEL_PRESS_LEVEL0; - //} - Vibra_force_level = PANEL_PRESS_LEVEL2; } } else // backup When force sensor error happened { if (Backup_Force_Value <= 100) - { //< 1.5N - // ForceHcount = 0; - // ForceMcount = 0; - // ForceLcount++; + { P_force_Reach2_flag = 0; - // if(ForceLcount > 40) - //{ - // ForceLcount = 40; - ret_Press = PANEL_PRESS_LEVEL0; - - // } - Vibra_force_level = PANEL_PRESS_LEVEL0; } else if (Backup_Force_Value >= 100 && Backup_Force_Value < 200) - { // 1.5N~~3N - // ForceHcount = 0; - // ForceMcount++; - // ForceLcount = 0; - // if(ForceMcount > 40) - // { - // ForceMcount = 40; + { if (P_force_Reach2_flag == 1) { - // if(TOUCH_SCREEN_CONTACT_AREA_INVALID_NUM > get_contact_size()) - //{ Vibra_force_level = PANEL_PRESS_LEVEL2; ret_Press = PANEL_PRESS_LEVEL2; - //} - // else - //{ - // ret_Press = PANEL_PRESS_LEVEL0; - // Vibra_force_level=PANEL_PRESS_LEVEL0; - //} + } else { - // if(TOUCH_SCREEN_CONTACT_AREA_INVALID_NUM > get_contact_size()) - //{ - Vibra_force_level = PANEL_PRESS_LEVEL1; ret_Press = PANEL_PRESS_LEVEL1; - //} - // else - //{ - // ret_Press = PANEL_PRESS_LEVEL0; - // Vibra_force_level=PANEL_PRESS_LEVEL0; - //} + } } else - { //>=3 - // ForceHcount++; - // ForceMcount = 0; - // ForceLcount = 0; + { P_force_Reach2_flag = 1; - // if(ForceHcount > 40) - // { - // ForceHcount = 40; - // if(TOUCH_SCREEN_CONTACT_AREA_INVALID_NUM > get_contact_size()) - //{ ret_Press = PANEL_PRESS_LEVEL2; - //} - // else - //{ - // ret_Press = PANEL_PRESS_LEVEL0; - // Vibra_force_level=PANEL_PRESS_LEVEL0; - //} - Vibra_force_level = PANEL_PRESS_LEVEL2; } } @@ -840,10 +757,6 @@ static Buttons_SignalType TouchSurface_BntCheck(Buttons_ChType ChId, TouchPanel_ break; } } - else if (TP_Event == TOUCH_PANEL_BERR_EVENT) - { - BSignal = BUTTON_RELEASE; //////////////BUTTON_INVALID; - } } return BSignal; @@ -856,45 +769,30 @@ static Buttons_SignalType TouchButton_BntCheck(Buttons_ChType ChId) if (ChId == BTN_RESUME1 || ChId == BTN_ADAS1 || ChId == BTN_CANCEL1) { key_status[ChId].status = get_sensor_state(ChId); - if (ChId == BTN_CANCEL1) - { - key_status[ChId].status = (get_sensor_state(ChId) == QTM_KEY_STATE_DETECT || get_sensor_state(ChId + 13) == QTM_KEY_STATE_DETECT) ? QTM_KEY_STATE_DETECT : get_sensor_state(ChId); - } - - if (QTM_KEY_STATE_DETECT == (key_status[ChId].status)) - { // KEY_TOUCHED_MASK - // Touch detect - key_status[ChId].RunCycle++; - if (TP_RUNNING_ERROR_CYCLE <= key_status[ChId].RunCycle) + key_status[ChId+3].status = get_sensor_state(ChId+13); + if (QTM_KEY_STATE_DETECT == (key_status[ChId].status) && QTM_KEY_STATE_DETECT == (key_status[ChId+3].status)) + { + if (Force_Sens_Err == 0) { - key_status[ChId].RunCycle = TP_RUNNING_ERROR_CYCLE; - BSignal = BUTTON_RELEASE; // BUTTON_INVALID; - } - else - { - - if (Force_Sens_Err == 0) - { - switch (TouchPanel_PressLevel) - { - case PANEL_PRESS_LEVEL0: - BSignal = BUTTON_TOUCH; - case PANEL_PRESS_LEVEL1: - BSignal = BUTTON_TOUCH; - // } - break; - case PANEL_PRESS_LEVEL2: - BSignal = BUTTON_TOUCH_AND_PRESS; - break; - default: - break; - } - } - else // backup When force sensor error happened + switch (TouchPanel_PressLevel) { + case PANEL_PRESS_LEVEL0: BSignal = BUTTON_TOUCH; + case PANEL_PRESS_LEVEL1: + BSignal = BUTTON_TOUCH; + break; + case PANEL_PRESS_LEVEL2: + BSignal = BUTTON_TOUCH_AND_PRESS; + break; + default: + break; } } + else // backup When force sensor error happened + { + BSignal = BUTTON_TOUCH; + } + } else { @@ -904,30 +802,9 @@ static Buttons_SignalType TouchButton_BntCheck(Buttons_ChType ChId) } return BSignal; } -static float32 GetSlide_Angle(float32 dx, float32 dy) -{ - return (atan2(dy, dx) * 180 / PI); -} -/**************************************************************/ -// x X(y) -// y <---------- ^(0,0) ^ -// | mapping | -// | =======> | -// | | -// | X(-y)<-------|(0,0) -/*************************************************************/ -static TP_SlideDirection_Enum GetSlide_Direction(uint8 startX, uint8 startY, uint8 endX, uint8 endY) -{ - TP_SlideDirection_Enum result = TP_SlideDirection_NONE; - return result; -} -struct Point -{ - float x; - float y; -}; + // ~{EP6OR;8v5cJG7qTZH}=GPNDZ2?~} uint8_t point_in_triangle(struct Point p, struct Point p1, struct Point p2, struct Point p3) @@ -993,108 +870,45 @@ static void TouchPanel_XY_Convert(uint8 origin_x, uint8 origin_y) Surface_Convert.convert_y = convert_y; // KalmanFilter(convert_y, 0); } -void touch_test(void) +void touch_Position_pro(void) { -} -extern uint8_t Allow_Touch_flag; -// static uint16_t touch_delay = 500; -void TouchPanel_MainFunction(void) -{ - uint8 index; - uint8 Temp_x, Temp_y; - - - uint8 pad_trig_x, pad_trig_y; // by kailong - - uint8 count = 0; - - uint8 K_Vibra_Trig_adas = 0; - uint8 K_Vibra_Trig_cancel = 0; - uint8 K_Vibra_Trig_resume = 0; - - static uint8 threshold_select_resume = 0; - static uint8 threshold_select_adas = 0; - static uint8 threshold_select_cancel = 0; - static uint8 threshold_select_up = 0; - static uint8 threshold_select_down = 0; - static uint8 threshold_select_left = 0; - static uint8 threshold_select_right = 0; - static uint8 threshold_select_confirm = 0; - - touch_process(); - - // kailong add + uint8 pad_trig_x, pad_trig_y; if (QTM_KEY_STATE_DETECT == get_sensor_state(BTN_ADAS1) && QTM_KEY_STATE_DETECT == get_sensor_state(BTN_ADAS1 + 13)) { CurrentPosition = 2; - threshold_select_adas = 1; + K_Vibra_Trig_adas = 1; } else { - threshold_select_adas = 0; + K_Vibra_Trig_adas = 0; } if (QTM_KEY_STATE_DETECT == get_sensor_state(BTN_RESUME1) && QTM_KEY_STATE_DETECT == get_sensor_state(BTN_RESUME1 + 13)) { CurrentPosition = 1; - threshold_select_resume = 1; + K_Vibra_Trig_resume = 1; } else { - threshold_select_resume = 0; + K_Vibra_Trig_resume = 0; } - if (QTM_KEY_STATE_DETECT == get_sensor_state(BTN_CANCEL1) || QTM_KEY_STATE_DETECT == get_sensor_state(BTN_CANCEL1 + 13)) + if (QTM_KEY_STATE_DETECT == get_sensor_state(BTN_CANCEL1) && QTM_KEY_STATE_DETECT == get_sensor_state(BTN_CANCEL1 + 13)) { CurrentPosition = 3; - threshold_select_cancel = 1; + K_Vibra_Trig_cancel = 1; } else { - threshold_select_cancel = 0; + K_Vibra_Trig_cancel = 0; } if ((TouchPanel_SurfaceStatus & TOUCH_ACTIVE) == 1) { struct Point Current_XY; -#if 1 - struct Point Point_Up[4] = { - {76, 0}, - {255, 41}, - {206, 87}, - {135, 87}, - }; - - struct Point Point_Down[4] = { - {135, 169}, - {206, 169}, - {255, 199}, - {106, 255}, - }; - - struct Point Point_Right[4] = { - {76, 21}, - {135, 87}, - {135, 169}, - {96, 255}, - }; - - struct Point Point_Left[4] = { - {206, 87}, - {255, 48}, - {255, 183}, - {206, 169}, - }; - - struct Point Point_Confirm[4] = { - {140, 92}, - {206, 92}, - {206, 164}, - {140, 164}, - }; -#endif + // point_in_quadrilateral(Current_XY,Point_Up[0],Point_Up[1],Point_Up[2],Point_Up[3]) GetSurface_Position(&pad_trig_x, &pad_trig_y); @@ -1107,7 +921,6 @@ void TouchPanel_MainFunction(void) { CurrentPosition = 4; K_Vibra_Trig_pad = 1; - threshold_select_up = 1; Surface_Button = 1; } } @@ -1118,7 +931,6 @@ void TouchPanel_MainFunction(void) { CurrentPosition = 5; K_Vibra_Trig_pad = 1; - threshold_select_down = 1; Surface_Button = 2; } } @@ -1129,7 +941,6 @@ void TouchPanel_MainFunction(void) { CurrentPosition = 7; K_Vibra_Trig_pad = 1; - threshold_select_right = 1; Surface_Button = 4; } } @@ -1140,7 +951,6 @@ void TouchPanel_MainFunction(void) { CurrentPosition = 6; K_Vibra_Trig_pad = 1; - threshold_select_left = 1; Surface_Button = 3; } } @@ -1151,7 +961,6 @@ void TouchPanel_MainFunction(void) { CurrentPosition = 8; K_Vibra_Trig_pad = 1; - threshold_select_confirm = 1; Surface_Button = 5; } } @@ -1160,13 +969,13 @@ void TouchPanel_MainFunction(void) { K_Vibra_Trig_pad = 0; - threshold_select_up = 0; - threshold_select_down = 0; - threshold_select_right = 0; - threshold_select_left = 0; - threshold_select_confirm = 0; Surface_Button = 0; } + +} + +void Threshold_Select_Process(void) +{ switch (CurrentPosition) { case 1: @@ -1204,9 +1013,19 @@ void TouchPanel_MainFunction(void) default: break; } +} + +extern uint8_t Allow_Touch_flag; +// static uint16_t touch_delay = 500; +void TouchPanel_MainFunction(void) +{ + uint8 index; + uint8 Temp_x, Temp_y; + uint8 count = 0; + + touch_process(); TouchPanel_PressLevel = TouchPanel_PressCheck(); - if (measurement_done_touch == 1) { @@ -1223,6 +1042,11 @@ void TouchPanel_MainFunction(void) Surface_Convert.convert_x = 0x00; Surface_Convert.convert_y = 0x00; } + touch_Position_pro(); + + Threshold_Select_Process(); + + for (index = 0; index < BTN_MAX_CH_NUM; index++) { @@ -1234,254 +1058,11 @@ void TouchPanel_MainFunction(void) { Buttons_Signal[index] = TouchSurface_BntCheck(index, 1); } - } - switch (CurrentPosition) - { - case 1: - { - Buttons_Signal[BTN_RESUME1] = TouchButton_BntCheck(BTN_RESUME1); - if (Buttons_Signal[BTN_RESUME1] >= BUTTON_TOUCH) + if (Buttons_Signal[index] < BUTTON_TOUCH) { - break; + count++; } - else - { - for (index = 0; index < BTN_MAX_CH_NUM; index++) - { - if (index < (BTN_MAX_CH_NUM - 5U)) - { - Buttons_Signal[index] = TouchButton_BntCheck(index); - } - else - { - Buttons_Signal[index] = TouchSurface_BntCheck(index, 1); - } - - if (Buttons_Signal[index] < BUTTON_TOUCH) - { - count++; - } - } - } - break; - } - case 2: - { - Buttons_Signal[BTN_ADAS1] = TouchButton_BntCheck(BTN_ADAS1); - if (Buttons_Signal[BTN_ADAS1] >= BUTTON_TOUCH) - { - break; - } - else - { - for (index = 0; index < BTN_MAX_CH_NUM; index++) - { - if (index < (BTN_MAX_CH_NUM - 5U)) - { - Buttons_Signal[index] = TouchButton_BntCheck(index); - } - else - { - Buttons_Signal[index] = TouchSurface_BntCheck(index, 1); - } - - if (Buttons_Signal[index] < BUTTON_TOUCH) - { - count++; - } - } - } - break; - } - case 3: - { - Buttons_Signal[BTN_CANCEL1] = TouchButton_BntCheck(BTN_CANCEL1); - if (Buttons_Signal[BTN_CANCEL1] >= BUTTON_TOUCH) - { - break; - } - else - { - for (index = 0; index < BTN_MAX_CH_NUM; index++) - { - if (index < (BTN_MAX_CH_NUM - 5U)) - { - Buttons_Signal[index] = TouchButton_BntCheck(index); - } - else - { - Buttons_Signal[index] = TouchSurface_BntCheck(index, 1); - } - - if (Buttons_Signal[index] < BUTTON_TOUCH) - { - count++; - } - } - } - break; - } - case 4: - { - Buttons_Signal[BTN_UP] = TouchSurface_BntCheck(BTN_UP, 1); - if (Buttons_Signal[BTN_UP] >= BUTTON_TOUCH) - { - break; - } - else - { - for (index = 0; index < BTN_MAX_CH_NUM; index++) - { - if (index < (BTN_MAX_CH_NUM - 5U)) - { - Buttons_Signal[index] = TouchButton_BntCheck(index); - } - else - { - Buttons_Signal[index] = TouchSurface_BntCheck(index, 1); - } - - if (Buttons_Signal[index] < BUTTON_TOUCH) - { - count++; - } - } - } - break; - } - case 5: - { - Buttons_Signal[BTN_DOWN] = TouchSurface_BntCheck(BTN_DOWN, 1); - if (Buttons_Signal[BTN_DOWN] >= BUTTON_TOUCH) - { - break; - } - else - { - for (index = 0; index < BTN_MAX_CH_NUM; index++) - { - if (index < (BTN_MAX_CH_NUM - 5U)) - { - Buttons_Signal[index] = TouchButton_BntCheck(index); - } - else - { - Buttons_Signal[index] = TouchSurface_BntCheck(index, 1); - } - - if (Buttons_Signal[index] < BUTTON_TOUCH) - { - count++; - } - } - } - break; - } - case 6: - { - Buttons_Signal[BTN_LEFT] = TouchSurface_BntCheck(BTN_LEFT, 1); - if (Buttons_Signal[BTN_LEFT] >= BUTTON_TOUCH) - { - break; - } - else - { - for (index = 0; index < BTN_MAX_CH_NUM; index++) - { - if (index < (BTN_MAX_CH_NUM - 5U)) - { - Buttons_Signal[index] = TouchButton_BntCheck(index); - } - else - { - Buttons_Signal[index] = TouchSurface_BntCheck(index, 1); - } - - if (Buttons_Signal[index] < BUTTON_TOUCH) - { - count++; - } - } - } - break; - } - case 7: - { - Buttons_Signal[BTN_RIGHT] = TouchSurface_BntCheck(BTN_RIGHT, 1); - if (Buttons_Signal[BTN_RIGHT] >= BUTTON_TOUCH) - { - break; - } - else - { - for (index = 0; index < BTN_MAX_CH_NUM; index++) - { - if (index < (BTN_MAX_CH_NUM - 5U)) - { - Buttons_Signal[index] = TouchButton_BntCheck(index); - } - else - { - Buttons_Signal[index] = TouchSurface_BntCheck(index, 1); - } - - if (Buttons_Signal[index] < BUTTON_TOUCH) - { - count++; - } - } - } - break; - } - case 8: - { - Buttons_Signal[BTN_CONFIRM] = TouchSurface_BntCheck(BTN_CONFIRM, 1); - if (Buttons_Signal[BTN_CONFIRM] >= BUTTON_TOUCH) - { - break; - } - else - { - for (index = 0; index < BTN_MAX_CH_NUM; index++) - { - if (index < (BTN_MAX_CH_NUM - 5U)) - { - Buttons_Signal[index] = TouchButton_BntCheck(index); - } - else - { - Buttons_Signal[index] = TouchSurface_BntCheck(index, 1); - } - - if (Buttons_Signal[index] < BUTTON_TOUCH) - { - count++; - } - } - } - break; - } - default: - { - for (index = 0; index < BTN_MAX_CH_NUM; index++) - { - if (index < (BTN_MAX_CH_NUM - 5U)) - { - Buttons_Signal[index] = TouchButton_BntCheck(index); - } - else - { - Buttons_Signal[index] = TouchSurface_BntCheck(index, 1); - } - - if (Buttons_Signal[index] < BUTTON_TOUCH) - { - count++; - } - } - break; - } } if (count == BTN_MAX_CH_NUM) @@ -1490,78 +1071,50 @@ void TouchPanel_MainFunction(void) // Allow_Touch_flag=1; } - - touch_test(); + measurement_done_touch = 0; } - if (threshold_select_adas == 1) - { - K_Vibra_Trig_adas = 1; - } - else - { - K_Vibra_Trig_adas = 0; - } - - if (threshold_select_cancel == 1) - { - K_Vibra_Trig_cancel = 1; - } - else - { - K_Vibra_Trig_cancel = 0; - } - - if (threshold_select_resume == 1) - { - K_Vibra_Trig_resume = 1; - } - else - { - K_Vibra_Trig_resume = 0; - } - if (Vibra_force_level == 2 && last_Vibra_force_level != 2 && Allow_Touch_flag == 1) - { - Over3N_vibra_req = 1; - Below1P5N_vibra_req = 0; - } - else if (Vibra_force_level == 0 && last_Vibra_force_level != 0) - { - Below1P5N_vibra_req = 1; - Over3N_vibra_req = 0; - } - last_Vibra_force_level = Vibra_force_level; - - if ((K_Vibra_Trig_pad == 1 || K_Vibra_Trig_adas == 1 || K_Vibra_Trig_cancel == 1 || K_Vibra_Trig_resume == 1) && Vibra_force_level == 2 && Allow_Touch_flag == 1) - { - Reach2_flag = 1; - } - - // add by kailong - // Vibra_force_level=Vibra_PressCheck(); - - if ((K_Vibra_Trig_pad == 1 || K_Vibra_Trig_adas == 1 || K_Vibra_Trig_cancel == 1 || K_Vibra_Trig_resume == 1) && Over3N_vibra_req == 1 && Allow_Touch_flag == 1) - { - Touch_Flag = TOUCH_KET_ON; - speeker_Tig_Once(49, UDS_Vibration_Gain); - Over3N_vibra_req = 0; - } - else if (Below1P5N_vibra_req == 1 && Reach2_flag == 1) - { - if (TOUCH_KET_ON == Touch_Flag) { - Touch_Flag = TOUCH_KET_OFF; - speeker_Tig_Once(49, UDS_Vibration_Gain); + Over3N_vibra_req = 1; + Below1P5N_vibra_req = 0; } - Below1P5N_vibra_req = 0; - Reach2_flag = 0; - } + else if (Vibra_force_level == 0 && last_Vibra_force_level != 0) + { + Below1P5N_vibra_req = 1; + Over3N_vibra_req = 0; + } + last_Vibra_force_level = Vibra_force_level; - if (CurrentPosition == 0xff) - { - Allow_Touch_flag = 1; - } + if ((K_Vibra_Trig_pad == 1 || K_Vibra_Trig_adas == 1 || K_Vibra_Trig_cancel == 1 || K_Vibra_Trig_resume == 1) && Vibra_force_level == 2 && Allow_Touch_flag == 1) + { + Reach2_flag = 1; + } + + if ((K_Vibra_Trig_pad == 1 || K_Vibra_Trig_adas == 1 || K_Vibra_Trig_cancel == 1 || K_Vibra_Trig_resume == 1) && Over3N_vibra_req == 1 && Allow_Touch_flag == 1) + { + Touch_Flag = TOUCH_KET_ON; + speeker_Tig_Once(49, UDS_Vibration_Gain); + Over3N_vibra_req = 0; + } + else if (Below1P5N_vibra_req == 1 && Reach2_flag == 1) + { + if (TOUCH_KET_ON == Touch_Flag) + { + Touch_Flag = TOUCH_KET_OFF; + speeker_Tig_Once(49, UDS_Vibration_Gain); + } + Below1P5N_vibra_req = 0; + Reach2_flag = 0; + } + + if (CurrentPosition == 0xff) + { + Allow_Touch_flag = 1; + } + + + } diff --git a/firmware/src/TouchPanel/TouchPanel.h b/firmware/src/TouchPanel/TouchPanel.h index 7d31615..0a69ea0 100644 --- a/firmware/src/TouchPanel/TouchPanel.h +++ b/firmware/src/TouchPanel/TouchPanel.h @@ -23,25 +23,11 @@ #define TOUCH_KET_ON 1 #define TOUCH_KET_OFF 0 -typedef enum -{ - TP_SlideDirection_NONE = 0, - TP_SlideDirection_ShortUP, - TP_SlideDirection_LongUP, - TP_SlideDirection_ShortDOWN, - TP_SlideDirection_LongDOWN, - TP_SlideDirection_ShortLEFT, - TP_SlideDirection_LongLEFT, - TP_SlideDirection_ShortRIGHT, - TP_SlideDirection_LongRIGHT -} TP_SlideDirection_Enum; + typedef enum{ TOUCH_PANEL_NONE_EVENT = 0, TOUCH_PANEL_PRESS_EVENT, - TOUCH_PANEL_RES_EVENT, - TOUCH_PANEL_MOVE_EVENT, - TOUCH_PANEL_BERR_EVENT }TouchPanel_EventType; typedef enum{ @@ -51,24 +37,8 @@ typedef enum{ }PanelPress_LevelType; -typedef struct{ - boolean Event; - uint32 keep_cycle; - TP_SlideDirection_Enum Direction; -}TouchSlideEvent_type; -typedef struct{ - uint8 x_position; - uint8 y_position; - uint8 origin_x_pos; - uint8 origin_y_pos; - uint8 end_x_pos; - uint8 end_y_pos; - TouchPanel_EventType Event; - uint32 CheckCycle; - uint32 TouchCycle; -}TouchSurface_type; typedef struct{ uint8 convert_x; @@ -122,7 +92,7 @@ void TouchPanel_init(void); void GetSurface_Position(uint8 *x, uint8 *y); Buttons_SignalType TouchPanel_BtnSignalRead(Buttons_ChType ChId); void TouchPanel_MainFunction(void); -TP_SlideDirection_Enum TouchPanel_SlideEventRead(void); + Buttons_SignalType TouchSurface_XY_StsRead(void); PanelPress_LevelType TouchPanel_PressLevelRead(void); boolean TouchSurface_is_TouchActive(void); diff --git a/firmware/src/config/mcal/touch/touch.h b/firmware/src/config/mcal/touch/touch.h index 8e2bc7f..f820b8c 100644 --- a/firmware/src/config/mcal/touch/touch.h +++ b/firmware/src/config/mcal/touch/touch.h @@ -301,7 +301,7 @@ SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES * Range: 0 to 255. * Default value: 5. */ -#define DEF_ANTI_TCH_DET_INT 50u +#define DEF_ANTI_TCH_DET_INT 0u /* Threshold beyond with automatic sensor recalibration is initiated. * Range: RECAL_100/ RECAL_50 / RECAL_25 / RECAL_12_5 / RECAL_6_25 / MAX_RECAL @@ -342,7 +342,7 @@ SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES * Range: 0-255 * Default value: 0 */ -#define DEF_MAX_ON_DURATION 250u +#define DEF_MAX_ON_DURATION 0u /**********************************************************/ diff --git a/firmware/src/main.c b/firmware/src/main.c index 7ee97b4..c7d7973 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -196,14 +196,15 @@ void CanTx(t_can_handler can_handler, bool notif, uint32_t idtp, uint16_t len, t ; } } +uint8_t Msg30_timeout_flag = 0; void IhuPrivateDHUCanFr01_CALLBACK(void) { - ; + Msg30_timeout_flag = 0; } void IhuPrivateDHUCanFr01_Timeout_CALLBACK(void) { - ; + Msg30_timeout_flag = 1; } // ***************************************************************************** @@ -213,8 +214,10 @@ void IhuPrivateDHUCanFr01_Timeout_CALLBACK(void) // ***************************************************************************** static uint32_t status = 0; uint8_t g_SBC_STATUS[8] = {0}; + void GetResetSource(void) { + uint8_t reset_source_buf[25]; g_SBC_STATUS[0] = (uint8_t)sbc_read_reg(SBC_SUP_STAT_2); g_SBC_STATUS[1] = (uint8_t)sbc_read_reg(SBC_SUP_STAT_1); g_SBC_STATUS[2] = (uint8_t)sbc_read_reg(SBC_DEV_STAT); @@ -224,6 +227,22 @@ void GetResetSource(void) g_SBC_STATUS[6] = 0x00; g_SBC_STATUS[7] = 0x00; CanTx(0, true, 0x420, 8, g_SBC_STATUS); + if (g_SBC_STATUS[1] == 0x80 && g_SBC_STATUS[3] == 0x01) + { + //正常上电 + } + else + { + //异常复位 + SmartEE_Read(0x400,reset_source_buf,20); + reset_source_buf[20] = g_SBC_STATUS[0]; + reset_source_buf[21] = g_SBC_STATUS[1]; + reset_source_buf[22] = g_SBC_STATUS[2]; + reset_source_buf[23] = g_SBC_STATUS[3]; + reset_source_buf[24] = g_SBC_STATUS[4]; + SmartEE_Write(0x400,&reset_source_buf[5],20); + } + } int main(void)