workable l8 with debug for PWH f2

This commit is contained in:
Yunhorn 2025-05-19 18:30:04 +08:00
parent c77bfc5067
commit 65b0ad42da
9 changed files with 67 additions and 30 deletions

View File

@ -92,7 +92,7 @@ typedef enum
#if defined(STS_R1)||defined(STS_R1D)||defined(STS_R5)||defined(STS_R2) #if defined(STS_R1)||defined(STS_R1D)||defined(STS_R5)||defined(STS_R2)
CFG_SEQ_Task_YunhornSTSEventP4, /* TOF RANGE */ CFG_SEQ_Task_YunhornSTSEventP4, /* TOF RANGE */
#endif #endif
#if defined(STS_P2)||defined(STS_T6)||defined(L8) #if defined(STS_P2)||defined(STS_T6)||defined(STS_L8)
CFG_SEQ_Task_YunhornSTSEventP5, /* TOF IN-OUT */ CFG_SEQ_Task_YunhornSTSEventP5, /* TOF IN-OUT */
#endif #endif
#ifdef STS_R4 #ifdef STS_R4
@ -107,6 +107,9 @@ typedef enum
#ifdef MODBUS_RS485 #ifdef MODBUS_RS485
STS_YunhornSTSEventPIORS485_Process, /* RS485 MODBUS RTU */ STS_YunhornSTSEventPIORS485_Process, /* RS485 MODBUS RTU */
#endif #endif
#if defined(STS_L8)
CFG_SEQ_Task_YunhornSTSEventSelfTestProcess, /* Self Function Test Process */
#endif
/* USER CODE END CFG_SEQ_Task_Id_t */ /* USER CODE END CFG_SEQ_Task_Id_t */
CFG_SEQ_Task_NBR CFG_SEQ_Task_NBR

View File

@ -21,6 +21,7 @@
#include "app_lorawan.h" #include "app_lorawan.h"
#include "gpio.h" #include "gpio.h"
#include <stdio.h> #include <stdio.h>
#include "iwdg.h"
/* Private includes ----------------------------------------------------------*/ /* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
//#include "i2c.h" //#include "i2c.h"
@ -130,8 +131,9 @@ int main(void)
STS_Sensor_Init(); STS_Sensor_Init();
/* USER CODE END 2 */ /* USER CODE END 2 */
//MX_TOF_Init();
//STS_SENSOR_Distance_Test_Process(); STS_Sensor_Prepare();
/* Infinite loop */ /* Infinite loop */
/* USER CODE BEGIN WHILE */ /* USER CODE BEGIN WHILE */
while (1) while (1)

View File

@ -84,8 +84,8 @@ uint32_t check_time=0;
volatile bool motionDetected =false; volatile bool motionDetected =false;
uint32_t lastMotionTime =0; uint32_t lastMotionTime =0;
const uint32_t ledOnDuration = 10000; const uint32_t ledOnDuration = 10000;
static uint8_t sts_warm_up_message_counter=0; volatile uint32_t sts_warm_up_message_counter=0;
static bool sts_function_test_success=false;
/* USER CODE END EV */ /* USER CODE END EV */
/* Private typedef -----------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/
@ -304,6 +304,8 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context);
// static void OnYunhornSTSOORSSWakeUpTimerEvent(void *context); // static void OnYunhornSTSOORSSWakeUpTimerEvent(void *context);
static void OnYunhornSTSSelfFunctionTestStartEvent(void *context);
/** /**
* @brief Yunhorn STS Heart beat timer callback function * @brief Yunhorn STS Heart beat timer callback function
* @param context ptr of context * @param context ptr of context
@ -394,6 +396,8 @@ static UTIL_TIMER_Object_t YunhornSTSWakeUpScanTimer;
*/ */
static UTIL_TIMER_Object_t YunhornSTSHeartBeatTimer; static UTIL_TIMER_Object_t YunhornSTSHeartBeatTimer;
static UTIL_TIMER_Object_t YunhornSTSSelfFunctionTestTimer;
/** /**
* @brief Timer to handle the application Lamp Bar LED Timer refresh * @brief Timer to handle the application Lamp Bar LED Timer refresh
*/ */
@ -601,8 +605,6 @@ void LoRaWAN_Init(void)
void STS_Sensor_Init(void) void STS_Sensor_Init(void)
{ {
//STS_TOF_VL53LX_PresenceDetection_Process_Init();
//STS_Lamp_Bar_Self_Test_Simple(); //STS_Lamp_Bar_Self_Test_Simple();
//STS_Lamp_Bar_Self_Test(); //STS_Lamp_Bar_Self_Test();
@ -632,6 +634,7 @@ void STS_Sensor_Init(void)
#if defined(STS_P2)||defined(STS_T6)||defined(L8) #if defined(STS_P2)||defined(STS_T6)||defined(L8)
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP5), UTIL_SEQ_RFU, STS_YunhornSTSEventP5_Process); UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP5), UTIL_SEQ_RFU, STS_YunhornSTSEventP5_Process);
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventSelfTestProcess), UTIL_SEQ_RFU, STS_SENSOR_Function_Test_Process);
#endif #endif
#ifdef STS_R4 #ifdef STS_R4
@ -653,16 +656,23 @@ void STS_Sensor_Init(void)
UTIL_TIMER_Start(&STSLampBarColorTimer); UTIL_TIMER_Start(&STSLampBarColorTimer);
UTIL_TIMER_Start(&STSDurationCheckTimer); UTIL_TIMER_Start(&STSDurationCheckTimer);
//UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_PERIODIC, OnYunhornSTSHeartBeatTimerEvent, NULL);
UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_ONESHOT, OnYunhornSTSHeartBeatTimerEvent, NULL); UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_ONESHOT, OnYunhornSTSHeartBeatTimerEvent, NULL);
// UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
UTIL_TIMER_Create(&YunhornSTSSelfFunctionTestTimer, 1000*(120), UTIL_TIMER_ONESHOT, (void*)OnYunhornSTSSelfFunctionTestStartEvent, NULL);
/* VVVVVV migrated to yunhorn_sts_process.c */ /* VVVVVV migrated to yunhorn_sts_process.c */
APP_LOG(TS_OFF, VLEVEL_M, "\r\n ------- L8 Init\r\n");
STS_TOF_L8_Init(); STS_TOF_L8_Init();
//HAL_Delay(1000);
//STS_SENSOR_Function_Test_Process();
} }
void STS_Sensor_Prepare(void)
{
UTIL_TIMER_Stop(&TxTimer);
UTIL_TIMER_Start(&TxTimer);
}
/* USER CODE BEGIN PB_Callbacks */ /* USER CODE BEGIN PB_Callbacks */
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
@ -706,9 +716,11 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
fhmos_occupancy = 1; fhmos_occupancy = 1;
} }
#endif #endif
if (sts_hall1_read != last_sts_hall1_read)
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0); {
last_sts_hall1_read = sts_hall1_read; UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
last_sts_hall1_read = sts_hall1_read;
}
} //else { } //else {
//APP_LOG(TS_OFF, VLEVEL_M, "\r\n --- ---- ----- -------- hall 1, door close again \r\n"); //APP_LOG(TS_OFF, VLEVEL_M, "\r\n --- ---- ----- -------- hall 1, door close again \r\n");
//} //}
@ -1382,16 +1394,16 @@ static void OnTxTimerEvent(void *context)
APP_LOG(TS_OFF, VLEVEL_M, "\nSET TASK P4\r\n"); APP_LOG(TS_OFF, VLEVEL_M, "\nSET TASK P4\r\n");
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP4), CFG_SEQ_Prio_0); UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP4), CFG_SEQ_Prio_0);
#endif #endif
UTIL_TIMER_Stop(&TxTimer);
if (sts_warm_up_message_counter < 5) if (sts_warm_up_message_counter < 5)
{ {
//UTIL_TIMER_Stop(&TxTimer); //UTIL_TIMER_Stop(&TxTimer);
sts_warm_up_message_counter ++; sts_warm_up_message_counter ++;
APP_LOG(TS_OFF, VLEVEL_M, "\r\n warm counter=%d \r\n", sts_warm_up_message_counter);
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0); UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
//UTIL_TIMER_Start(&TxTimer); UTIL_TIMER_Start(&TxTimer);
} }
/*Wait for next tx slot*/ /*Wait for next tx slot*/
/* USER CODE BEGIN OnTxTimerEvent_2 */ /* USER CODE BEGIN OnTxTimerEvent_2 */
@ -1485,6 +1497,7 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer); UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
UTIL_TIMER_Start(&YunhornSTSSelfFunctionTestTimer);
// UTIL_TIMER_Start(&TxTimer); // UTIL_TIMER_Start(&TxTimer);
// UTIL_TIMER_Start(&YunhornSTSWakeUpScanTimer); // UTIL_TIMER_Start(&YunhornSTSWakeUpScanTimer);
@ -1790,11 +1803,23 @@ static void OnYunhornSTSOORSSWakeUpTimerEvent(void *context)
* @param context ptr of context * @param context ptr of context
*/ */
static void OnYunhornSTSSelfFunctionTestStartEvent(void *context)
{
#if 1
if ((!sts_function_test_success)&&(sts_warm_up_message_counter==5))
{
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventSelfTestProcess), CFG_SEQ_Prio_0);
sts_function_test_success = true;
}
#endif
}
static void OnYunhornSTSHeartBeatTimerEvent(void *context) static void OnYunhornSTSHeartBeatTimerEvent(void *context)
{ {
// UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventRFAC), CFG_SEQ_Prio_0); // UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventRFAC), CFG_SEQ_Prio_0);
UTIL_TIMER_Stop(&YunhornSTSHeartBeatTimer); UTIL_TIMER_Stop(&YunhornSTSHeartBeatTimer);
uint8_t appHeartBeatDataPort=2, appHeartBeatBufferSize=2, appHeartBeatDataBuffer[32]={0x0}; uint8_t appHeartBeatDataPort=2, appHeartBeatBufferSize=2, appHeartBeatDataBuffer[32]={0x0};
if ((rfac_timer <(STS_BURN_IN_RFAC+3))&&(sts_cfg_nvm.ac[0]==0x0)&&(sts_cfg_nvm.ac[19]==0x0)) if ((rfac_timer <(STS_BURN_IN_RFAC+3))&&(sts_cfg_nvm.ac[0]==0x0)&&(sts_cfg_nvm.ac[19]==0x0))
@ -1911,6 +1936,7 @@ void STS_SENSOR_Warm_Up(void)
status = LmHandlerSend(&AppData, LmHandlerParams.IsTxConfirmed, false); status = LmHandlerSend(&AppData, LmHandlerParams.IsTxConfirmed, false);
} }
} }
void STS_ClockSync_process(void) void STS_ClockSync_process(void)
{ {
LmHandlerErrorStatus_t status = LORAMAC_HANDLER_ERROR; LmHandlerErrorStatus_t status = LORAMAC_HANDLER_ERROR;

Binary file not shown.

View File

@ -186,8 +186,8 @@
/* General Settings */ /* General Settings */
#define MajorVer 25U #define MajorVer 25U
#define MinorVer 1U #define MinorVer 5U
#define SubMinorVer 8U #define SubMinorVer 19U
#define FirmwareVersion 3U #define FirmwareVersion 3U
#define YUNHORN_STS_MAX_NVM_CFG_SIZE 64U #define YUNHORN_STS_MAX_NVM_CFG_SIZE 64U
#define YUNHORN_STS_AC_CODE_SIZE 20U #define YUNHORN_STS_AC_CODE_SIZE 20U

View File

@ -79,6 +79,7 @@ volatile uint8_t sts_head_level_low =0, last_head_level_low_state=0;
extern volatile uint8_t fhmos_gesture_bitmap[8]; extern volatile uint8_t fhmos_gesture_bitmap[8];
extern volatile sts_fhmos_sensor_data_t fhmos_data; extern volatile sts_fhmos_sensor_data_t fhmos_data;
extern volatile uint8_t sts_mask_bitmap[8]; extern volatile uint8_t sts_mask_bitmap[8];
extern uint32_t sts_warm_up_message_counter;
#endif #endif
volatile sts_cfg_nvm_t sts_cfg_nvm = { volatile sts_cfg_nvm_t sts_cfg_nvm = {
sts_mtmcode1, sts_mtmcode1,
@ -542,7 +543,7 @@ void STS_YunhornSTSEventP5_Process(void)
} }
#elif defined(L8) #elif defined(L8)
//STS_TOF_VL53L8X_Process(); //STS_TOF_VL53L8X_Process();
//printf("\r\n P5 process \r\n"); printf("\r\n P5 process \r\n");
STSWakeupScanTimerStop(); STSWakeupScanTimerStop();
STS_TOF_L8_Process(); STS_TOF_L8_Process();
@ -566,6 +567,7 @@ void STS_YunhornSTSEventP5_Process(void)
} }
#endif #endif
STSWakeupScanTimerStart(); STSWakeupScanTimerStart();
#endif #endif
@ -2094,7 +2096,7 @@ void STS_SENSOR_Distance_Test_Process(void)
rpt++; rpt++;
range_sum += range_once ; range_sum += range_once ;
} }
HAL_Delay(150); HAL_Delay(10);
}while (rpt<3); }while (rpt<3);
sts_sensor_install_height = range_sum/rpt; sts_sensor_install_height = range_sum/rpt;
@ -2118,15 +2120,15 @@ void STS_SENSOR_Distance_Test_Process(void)
void STS_SENSOR_MEMS_Get_ID(uint16_t *devID) void STS_SENSOR_MEMS_Get_ID(uint16_t *devID)
{ {
#ifdef VL53LX //#ifdef VL53LX
*devID = sensor_id; *devID = sensor_id;
#endif //#endif
} }
void STS_SENSOR_Function_Test_Process(void) void STS_SENSOR_Function_Test_Process(void)
{ {
char tstbuf[128] =""; uint8_t i=0; char tstbuf[128] =""; uint8_t i=0;
uint16_t my_id=0;
tstbuf[i++] = (uint8_t) 'S'; tstbuf[i++] = (uint8_t) 'S';
tstbuf[i++] = (uint8_t) sts_mtmcode1; tstbuf[i++] = (uint8_t) sts_mtmcode1;
tstbuf[i++] = (uint8_t) sts_mtmcode2; tstbuf[i++] = (uint8_t) sts_mtmcode2;
@ -2135,10 +2137,10 @@ void STS_SENSOR_Function_Test_Process(void)
tstbuf[i++] = (uint8_t) (99*GetBatteryLevel()/254)&0xff; tstbuf[i++] = (uint8_t) (99*GetBatteryLevel()/254)&0xff;
#if (defined(STS_P2)||defined(STS_T6))||defined(L8) #if (defined(STS_P2)||defined(STS_T6))||defined(L8)
STS_SENSOR_MEMS_Get_ID(&sensor_id); STS_SENSOR_MEMS_Get_ID(&my_id);
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Sensor id =%04x \r\n", sensor_id); APP_LOG(TS_OFF, VLEVEL_M, "\r\n Sensor id =%04x \r\n", my_id);
#if defined(L8) #if defined(L8)
if (((sensor_id & 0xff)!= 0x0C) && (((sensor_id >>8) & 0xFF)!=0xF0)) // no VL53L8X found if (((my_id & 0xff)!= 0x0C) && (((my_id >>8) & 0xFF)!=0xF0)) // no VL53L8X found
{ {
tstbuf[i++] = (uint8_t) 'X'; // Slave MEMS Not Avaliable tstbuf[i++] = (uint8_t) 'X'; // Slave MEMS Not Avaliable
} }

View File

@ -153,7 +153,7 @@ void MX_TOF_Init(void)
/* USER CODE END TOF_Init_PreTreatment */ /* USER CODE END TOF_Init_PreTreatment */
/* Initialize the peripherals and the TOF components */ /* Initialize the peripherals and the TOF components */
//APP_LOG(TS_OFF,VLEVEL_L,"\r\n###################### MX TOF Init... \r\n"); APP_LOG(TS_OFF,VLEVEL_M,"\r\n###################### MX TOF Init... \r\n");
//MX_53L1A2_SimpleRanging_Init(); //MX_53L1A2_SimpleRanging_Init();
//STS_TOF_VL53LX_PeopleCounting_Process(); //STS_TOF_VL53LX_PeopleCounting_Process();
@ -439,10 +439,13 @@ uint16_t MX_TOF_Ranging_Process(void)
return (uint16_t) range_distance; return (uint16_t) range_distance;
#elif defined(L8) #elif defined(L8)
//RANGING_SENSOR_Result_t *Result;
uint32_t range_distance=0; uint32_t range_distance=0;
//uint8_t center_roi[4] = {27,28,35,36}; //uint8_t center_roi[4] = {27,28,35,36};
if (ToF_EventDetected != 0) APP_LOG(TS_OFF, VLEVEL_M, "\r\n RANGING...\r\n");
while(ToF_EventDetected==0){};
//if (ToF_EventDetected != 0)
{ {
ToF_EventDetected = 0; ToF_EventDetected = 0;
status = VL53L8A1_RANGING_SENSOR_GetDistance(VL53L8A1_DEV_CENTER, &Result); status = VL53L8A1_RANGING_SENSOR_GetDistance(VL53L8A1_DEV_CENTER, &Result);
@ -552,6 +555,7 @@ static void MX_53L8A1_ThresholdDetection_Init(void)
printf("VL53L8A1_RANGING_SENSOR_Init failed\n"); printf("VL53L8A1_RANGING_SENSOR_Init failed\n");
//while (1); //while (1);
} }
APP_LOG(TS_OFF, VLEVEL_M, "\r\n ----------- SERNSOR ID =%4x \r\n", sensor_id);
} }
void MX_53L8A1_ThresholdDetection_ConfigIT(uint32_t low_threshold, uint32_t high_threshold) void MX_53L8A1_ThresholdDetection_ConfigIT(uint32_t low_threshold, uint32_t high_threshold)