--remove unused code

This commit is contained in:
Yunhorn 2024-07-29 13:22:30 +08:00
parent e990164543
commit 9a57efd44b
5 changed files with 72 additions and 56 deletions

View File

@ -99,9 +99,15 @@ void Error_Handler(void);
#define HALL2_GPIO_Port GPIOA
#define HALL2_EXTI_IRQn EXTI1_IRQn
#define HALL1_STATE HAL_GPIO_ReadPin(HALL1_GPIO_Port, HALL1_Pin)
#define HALL2_STATE HAL_GPIO_ReadPin(HALL2_GPIO_Port, HALL2_Pin)
#define HALL3_Pin GPIO_PIN_8 // ALARM RESET PIN
#define HALL3_GPIO_Port GPIOA
#define HALL3_EXTI_IRQn EXTI9_5_IRQn
#define ALARM_RESET_Pin HALL3_Pin
#define HALL1_STATE HAL_GPIO_ReadPin(HALL1_GPIO_Port, HALL1_Pin) //DOOR CONTACT
#define HALL2_STATE HAL_GPIO_ReadPin(HALL2_GPIO_Port, HALL2_Pin) //SOS BUTTON
#define HALL3_STATE HAL_GPIO_ReadPin(HALL3_GPIO_Port, HALL3_Pin) //ALARM RESET BUTTON
#else
#define BUT1_Pin GPIO_PIN_0

View File

@ -89,7 +89,7 @@ void MX_GPIO_Init(void)
HAL_GPIO_Init(A111_SENSOR_INTERRUPT_GPIO_Port, &GPIO_InitStruct);
#ifdef STS_O7
GPIO_InitStruct.Pin = HALL1_Pin|HALL2_Pin;
GPIO_InitStruct.Pin = HALL1_Pin|HALL2_Pin|HALL3_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
@ -123,6 +123,9 @@ void MX_GPIO_Init(void)
HAL_NVIC_SetPriority(HALL2_EXTI_IRQn, 15, 0);
HAL_NVIC_EnableIRQ(HALL2_EXTI_IRQn);
HAL_NVIC_SetPriority(HALL3_EXTI_IRQn, 15, 0);
HAL_NVIC_EnableIRQ(HALL3_EXTI_IRQn);
HAL_NVIC_SetPriority(A111_SENSOR_INTERRUPT_EXTI_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(A111_SENSOR_INTERRUPT_EXTI_IRQn);

View File

@ -358,20 +358,22 @@ void DMA1_Channel7_IRQHandler(void)
/**
* @brief This function handles EXTI Lines [9:5] Interrupt.
*/
#if 1
void EXTI9_5_IRQHandler(void)
{
/* USER CODE BEGIN EXTI9_5_IRQn 0 */
/* USER CODE END EXTI9_5_IRQn 0 */
//HAL_GPIO_EXTI_IRQHandler(BUT3_Pin);
HAL_GPIO_EXTI_IRQHandler(HALL2_Pin);
/* USER CODE BEGIN EXTI9_5_IRQn 1 */
#ifdef RM2
HAL_GPIO_EXTI_IRQHandler(A111_SENSOR_INTERRUPT_Pin);
#endif
/* USER CODE END EXTI9_5_IRQn 1 */
}
#endif
/**
* @brief This function handles SPI1 Interrupt.
*/

View File

@ -37,44 +37,45 @@
/* USER CODE BEGIN Includes */
extern volatile sts_cfg_nvm_t sts_cfg_nvm;
extern volatile uint8_t sts_ac_code[20];
volatile uint8_t sts_work_mode = STS_DUAL_MODE;
volatile uint8_t sts_service_mask=0;
volatile uint32_t rfac_timer;
volatile uint8_t sensor_data_ready=0;
volatile STS_PRESENCE_SENSOR_Event_Status_t sts_o7_event_status;
// GPIO reed hall pin
extern volatile uint8_t sts_reed_hall_result;
volatile uint8_t last_sts_reed_hall_result;
extern volatile uint8_t sts_hall1_read,sts_hall2_read, sts_hall3_read;
volatile uint8_t sts_reed_hall_1_result=STS_Status_Door_Open,sts_reed_hall_2_result=STS_Status_SOS_Release, last_sts_reed_hall_1_result=STS_Status_Door_Open, last_sts_reed_hall_2_result=STS_Status_SOS_Release,sts_reed_hall_3_result=STS_Status_Door_Open, last_sts_reed_hall_3_result=STS_Status_Door_Open;
volatile uint8_t sts_soap_level_state;
// RSS motion and distance
volatile STS_OO_SensorStatusDataTypeDef sts_o7_sensorData;
volatile STS_PRESENCE_SENSOR_Event_Status_t sts_o7_event_status;
volatile float sts_distance_rss_distance, sts_sensor_install_height=0;//in mm
extern volatile float sts_presence_rss_distance, sts_presence_rss_score;
extern volatile uint8_t sts_hall1_read,sts_hall2_read;
volatile uint8_t sts_reed_hall_1_result=STS_Status_Door_Open,sts_reed_hall_2_result=STS_Status_SOS_Release, last_sts_reed_hall_1_result=STS_Status_Door_Open, last_sts_reed_hall_2_result=STS_Status_SOS_Release;
volatile uint8_t sts_rss_config_updated_flag = 0;
extern volatile uint8_t mems_int1_detected, link_wakeup, link_sleep;
volatile uint32_t event_start_time=0, event_stop_time=0;
volatile uint32_t event_door_lock_start_time=0,event_door_lock_stop_time=0;
extern volatile uint8_t sts_occupancy_overtime_state;
//extern volatile STS_OO_RSS_SensorTuneDataTypeDef sts_presence_rss_config;
extern volatile sts_cfg_nvm_t sts_cfg_nvm;
extern volatile uint8_t sts_fall_detection_acc_threshold, sts_fall_detection_depth_threshold, sts_occupancy_overtime_threshold_in_10min;
extern volatile uint8_t sts_fall_rising_detected_result_changed_flag;
extern volatile uint8_t last_sts_fall_rising_detected_result;
extern volatile uint16_t sts_motionless_duration_threshold_in_min;
extern volatile uint8_t sts_emergency_button_pushed, sts_rss_2nd_result,sts_tof_result, sts_status_color, sts_lamp_bar_color, sts_service_mask;
extern volatile distance_measure_cfg_t distance_cfg;
extern uint8_t sts_fall_rising_detected_result;
extern volatile uint16_t sts_fall_rising_pattern_factor1;
extern volatile uint16_t sts_roc_acc_standard_variance;
volatile uint32_t last_sts_rss_time_stamp=0;
// RSS fall detection
extern volatile uint8_t sts_fall_detection_acc_threshold, sts_fall_detection_depth_threshold, sts_occupancy_overtime_threshold_in_10min;
extern volatile uint8_t sts_fall_rising_detected_result, sts_fall_rising_detected_result_changed_flag;
extern volatile uint8_t last_sts_fall_rising_detected_result;
extern volatile uint16_t sts_motionless_duration_threshold_in_min;
extern volatile uint8_t sts_status_color, sts_lamp_bar_color;//puColor
extern volatile uint8_t sts_cloud_netcolor; //netColor
extern uint8_t luminance_level;
SysTime_t mems_event_time;
volatile uint32_t last_sts_rss_time_stamp=0;
extern volatile uint8_t sts_reed_hall_ext_int;
volatile uint8_t sts_occupancy_status;
volatile uint8_t sts_hall1_changed_flag=0, sts_hall2_changed_flag=0, last_sts_hall1_result=0, last_sts_hall2_result=0;
volatile uint8_t sts_reed_hall_changed_flag = 0;
@ -96,12 +97,7 @@ extern volatile uint8_t detected_hs_zone;
extern volatile STS_OO_RSS_SensorTuneDataTypeDef sts_presence_rss_config;
volatile uint32_t cnt=0;
extern volatile distance_measure_cfg_t distance_cfg;
volatile uint8_t sts_work_mode = STS_DUAL_MODE;
extern uint8_t luminance_level;
extern volatile uint8_t sts_status_color;
extern volatile uint8_t sts_lamp_bar_color; //puColor
extern volatile uint8_t sts_cloud_netcolor; //netColor
volatile uint8_t sts_tof_result_changed_flag = 0;
@ -228,6 +224,9 @@ void STS_YunhornSTSEventP1_Process(void)
sts_reed_hall_2_result = HALL2_STATE;// sts_hall2_read;
last_sts_reed_hall_2_result = sts_reed_hall_2_result;
sts_reed_hall_3_result = HALL3_STATE;// sts_hall3_read;
last_sts_reed_hall_3_result = sts_reed_hall_3_result;
STS_Combined_Status_Processing();
}
@ -266,7 +265,7 @@ void STS_Reed_Hall_Presence_Detection(void)
// HAL_Delay(50); // BOUNCING ELIMIATION
sts_reed_hall_1_result = (sts_hall1_read==0)?STS_Status_Door_Close:STS_Status_Door_Open;
sts_reed_hall_2_result = (sts_hall2_read==0)?STS_Status_Door_Close:STS_Status_Door_Open;
sts_reed_hall_3_result = (sts_hall3_read==0)?STS_Status_Door_Close:STS_Status_Door_Open;
//sts_reed_hall_result = ((STS_Reed_Hall_State)&STS_Status_Door_Open);
@ -274,7 +273,7 @@ void STS_Reed_Hall_Presence_Detection(void)
sts_reed_hall_changed_flag = 0;
sts_reed_hall_ext_int = 0;
}
@ -856,7 +855,7 @@ void STS_PRESENCE_SENSOR_Init(void)
//HAL_Delay(2000);
//STS_PRESENCE_SENSOR_Distance_Measure_Process();
mems_int1_detected=0;
}
void STS_PRESENCE_SENSOR_TOF_Init(void)
@ -893,7 +892,7 @@ void STS_PRESENCE_SENSOR_RSS_Init(void)
sts_rss_config_updated_flag = STS_RSS_CONFIG_DEFAULT;
mems_int1_detected=0;
}
@ -940,7 +939,7 @@ void STS_PRESENCE_SENSOR_Function_Test_Process(uint8_t *self_test_result, uint8_
HAL_Delay(1000);
memcpy(self_test_result, bring_up_result, 10);
mems_int1_detected=0;
}
uint8_t STS_SENSOR_MEMS_Get_ID(uint8_t *devID)
@ -963,20 +962,6 @@ uint8_t STS_SENSOR_MEMS_Get_ID(uint8_t *devID)
}
void STS_SENSOR_MEMS_Reset(uint8_t cnt)
{
switch (cnt) {
case 0:
case 1:
case 2:
HAL_GPIO_TogglePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin);
break;
default:
break;
}
}
#ifdef STS_R4
void YUNHORN_STS_R4_SENSOR_Read(STS_R0_SensorDataTypeDef *r4_data)
{

View File

@ -52,9 +52,9 @@ extern volatile uint8_t sts_service_mask;
extern volatile uint32_t rfac_timer;
volatile uint8_t sts_ac_code[YUNHORN_STS_AC_CODE_SIZE]={0x0};
extern hmac_result_t hmac_result;
extern volatile uint8_t sts_reed_hall_ext_int;
extern volatile uint8_t sts_hall1_read, sts_hall2_read;
volatile uint8_t last_sts_hall1_read=STS_Status_Door_Open, last_sts_hall2_read=STS_Status_SOS_Release;
volatile uint8_t last_sts_hall1_read=STS_Status_Door_Open, last_sts_hall2_read=STS_Status_SOS_Release, last_sts_hall3_read=STS_Status_Door_Open;
volatile uint8_t sts_reed_hall_result =0, sts_emergency_button_pushed=0; // inital 0 = close
extern volatile uint8_t sts_work_mode, sts_cloud_netcolor, sts_lamp_bar_color, sts_status_color;
@ -78,7 +78,7 @@ volatile uint8_t sts_presence_fall_detection=TRUE;
volatile uint32_t SamplingPeriodicity = 1000; //unit ms
volatile uint32_t HeartBeatPeriodicity = 120000; //unit ms
volatile uint8_t STS_LoRa_WAN_Joined = 0;
volatile uint8_t mems_int1_detected = 0;
volatile uint8_t upload_message_timer=0;
volatile uint8_t heart_beat_timer =0;
volatile uint32_t wcnt=0;
@ -750,12 +750,30 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
}
break;
case ALARM_RESET_Pin:
sts_hall2_read = HALL2_STATE;
HAL_Delay(30); //de-bouncing
if (sts_hall2_read == HALL2_STATE)
{
APP_LOG(TS_OFF, VLEVEL_L, "\n\n SOS Button Read = %02x --%s\r\n", sts_hall2_read, sts_sos_status_code[sts_hall2_read]);
OnSensor2StateChanged();
//sensor_data_ready =1;
//UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), CFG_SEQ_Prio_0);
{
STS_YunhornSTSEventP1_Process();
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
}
last_sts_hall2_read = sts_hall2_read;
}
break;
#else
case BUT1_Pin:
HAL_Delay(20); //de-bouncing
//sts_reed_hall_ext_int = 1;
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), CFG_SEQ_Prio_0);
//sts_reed_hall_ext_int = 0;
/* Note: when "EventType == TX_ON_TIMER" this GPIO is not initialized */
// if (EventType == TX_ON_EVENT)
{
@ -2099,7 +2117,9 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
case 'H':
// TODO # of modules
if (((uint8_t)(tlv_buf[CFG_CMD3]-0x30) >= 0) && ((uint8_t)tlv_buf[CFG_CMD3]-0x30) <=9) {
STS_SENSOR_MEMS_Reset((tlv_buf[CFG_CMD3]-0x30));
PME_ON;
PME_OFF;
PME_ON;
i=0;
outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD1];
outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD2];