L8 #81
|
@ -47,12 +47,12 @@ extern "C" {
|
|||
/**
|
||||
* @brief Verbose level for all trace logs
|
||||
*/
|
||||
#define VERBOSE_LEVEL VLEVEL_OFF
|
||||
#define VERBOSE_LEVEL VLEVEL_M
|
||||
|
||||
/**
|
||||
* @brief Enable trace logs
|
||||
*/
|
||||
#define APP_LOG_ENABLED 0
|
||||
#define APP_LOG_ENABLED 1
|
||||
|
||||
/**
|
||||
* @brief Activate monitoring (probes) of some internal RF signals for debug purpose
|
||||
|
@ -75,7 +75,7 @@ extern "C" {
|
|||
* @brief Enable/Disable MCU Debugger pins (dbg serial wires)
|
||||
* @note by HW serial wires are ON by default, need to put them OFF to save power
|
||||
*/
|
||||
#define DEBUGGER_ENABLED 0
|
||||
#define DEBUGGER_ENABLED 1
|
||||
|
||||
/**
|
||||
* @brief Disable Low Power mode
|
||||
|
|
|
@ -76,16 +76,16 @@ extern volatile uint8_t sts_hall1_read, sts_hall2_read; // Above hall1_read == r
|
|||
extern volatile uint8_t sts_hall3_read, sts_hall4_read;
|
||||
//extern volatile uint8_t sts_pir_state, sts_pir_result;
|
||||
extern volatile uint8_t last_sts_hall1_read, last_sts_hall2_read, last_sts_hall3_read, last_sts_hall4_read, last_sts_pir_read;
|
||||
//volatile uint8_t sts_PIR_read = 0;
|
||||
volatile bool locklow = false;
|
||||
volatile uint32_t lowin=0;
|
||||
volatile bool takelowTime;
|
||||
volatile uint8_t PIRValue = 0, prev_sts_pir_state=0, sts_pir_state_changed=0;;
|
||||
uint32_t check_time=0;
|
||||
volatile bool motionDetected =false;
|
||||
uint32_t lowIn=0;
|
||||
volatile bool lockLow = true, takeLowTime;
|
||||
uint32_t lastMotionTime =0;
|
||||
const uint32_t ledOnDuration = 10000;
|
||||
volatile uint32_t sts_warm_up_message_counter=0;
|
||||
static bool sts_function_test_success=false;
|
||||
SysTime_t sts_pir_start_time, sts_pir_duration_check_time;
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
|
@ -777,7 +777,56 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
case PIR_Pin:
|
||||
sts_pir_read = PIR_STATE;
|
||||
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
|
||||
if (sts_pir_read == 1)
|
||||
{
|
||||
if (lockLow)
|
||||
{
|
||||
PIRValue = 1;
|
||||
lockLow = false;
|
||||
sts_pir_start_time = SysTimeGet();
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n PIRValue=%d \r\n", PIRValue);
|
||||
if (sts_pir_read != prev_sts_pir_state) {
|
||||
sts_pir_state_changed = 1;
|
||||
}
|
||||
prev_sts_pir_state = sts_pir_read;
|
||||
}
|
||||
takeLowTime = true;
|
||||
}
|
||||
|
||||
if (sts_pir_read ==0)
|
||||
{
|
||||
|
||||
if (takeLowTime)
|
||||
{
|
||||
sts_pir_duration_check_time = SysTimeGet();
|
||||
lowIn = sts_pir_duration_check_time.Seconds;
|
||||
takeLowTime = false;
|
||||
}
|
||||
|
||||
sts_pir_duration_check_time = SysTimeGet();
|
||||
if ((!lockLow && (sts_pir_duration_check_time.Seconds - lowIn) > 5))
|
||||
{
|
||||
PIRValue = 0;
|
||||
lockLow = true;
|
||||
sts_pir_read = 0;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n PIRValue=%d \r\n", PIRValue);
|
||||
if (sts_pir_read != prev_sts_pir_state) {
|
||||
sts_pir_state_changed = 1;
|
||||
}
|
||||
prev_sts_pir_state = sts_pir_read;
|
||||
}
|
||||
}
|
||||
// HAL_Delay(50);
|
||||
//__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
|
||||
// APP_LOG(TS_OFF, VLEVEL_M, "\r\nMotion Detection result=%d \r\n", sts_pir_state);
|
||||
OnSensorPIR1StateChanged();
|
||||
|
||||
if ( sts_pir_state_changed == 1)
|
||||
{
|
||||
sts_pir_state_changed = 0;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
}
|
||||
|
||||
#endif
|
||||
//OnSensor3StateChanged();
|
||||
//OnSensorPIR1StateChanged();
|
||||
|
@ -797,13 +846,14 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
if (sts_pir_read != last_sts_pir_read)
|
||||
{
|
||||
last_sts_pir_read = sts_pir_read;
|
||||
// disable PIR status upload 2025 04 18
|
||||
// UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
}
|
||||
|
||||
#endif
|
||||
break;
|
||||
#if 0
|
||||
case HALL4_Pin:
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue