diff --git a/Core/Src/acc_hal_integration_a111.c b/Core/Src/acc_hal_integration_a111.c index c13c274..3c78919 100644 --- a/Core/Src/acc_hal_integration_a111.c +++ b/Core/Src/acc_hal_integration_a111.c @@ -40,7 +40,7 @@ extern SPI_HandleTypeDef A111_SPI_HANDLE; * @brief Size of SPI transfer buffer */ #ifndef A111_SPI_MAX_TRANSFER_SIZE -#define A111_SPI_MAX_TRANSFER_SIZE 65535 //4096 //65535 +#define A111_SPI_MAX_TRANSFER_SIZE 4096 //4096 //65535 #endif /** diff --git a/Core/Src/yunhorn_sts_presence_rss.c b/Core/Src/yunhorn_sts_presence_rss.c index 14e8c95..5f58e47 100644 --- a/Core/Src/yunhorn_sts_presence_rss.c +++ b/Core/Src/yunhorn_sts_presence_rss.c @@ -410,6 +410,97 @@ static void print_current_configuration(acc_detector_presence_configuration_t pr (int)(1000*sts_run_f_intra_frame_time_const),(int)(1000*sts_run_f_intra_frame_weight),(int)(1000*sts_run_f_output_time_const)); } + + +uint8_t yes_count=0; +uint8_t no_count=0; +#define TIME_C 4 + +static void sts_print_result(acc_detector_presence_result_t result) +{ + uint16_t signal=0; + uint16_t dist=0; + uint8_t i=0; + uint16_t threshold = sts_presence_rss_config.default_threshold*1000.0f; + + signal=(int)(result.presence_score * 1000.0f); + dist =(int)(result.presence_distance * 1000.0f); + + uint8_t flag=0; + if (signal>threshold) + { + if(dist<500) + { + if(signal>(threshold+1000)) + { + LED1_ON; + if(yes_count(TIME_C-1)) + { + //Out1_ON + //Out2_OFF + APP_LOG(TS_OFF, VLEVEL_M,"Motion (%5d), Distance: %4dmm\r\n", signal,dist); + } + else if(no_count>(TIME_C-1)) + { + //Out1_OFF + //Out2_ON + APP_LOG(TS_OFF, VLEVEL_M,"NO motion(%5d), Distance: %4dmm\r\n", signal,dist); + } + +} + static void print_result(acc_detector_presence_result_t result) { if (result.presence_detected) @@ -665,6 +756,7 @@ int sts_presence_rss_fall_rise_detection(void) } //print_result(result); + sts_print_result(result); if (!result.data_saturated) { //APP_LOG(TS_OFF, VLEVEL_H,"\n%u ", i); @@ -700,7 +792,7 @@ int sts_presence_rss_fall_rise_detection(void) //acc_integration_sleep_ms(1000 / DEFAULT_UPDATE_RATE_PRESENCE); // 15ms, DEFAULT_UPDATE_RATE); //acc_integration_sleep_ms(10); // --- around 1500 ms in total //acc_integration_sleep_ms(2); //--- around 1000ms in total - acc_integration_sleep_ms(1000 / 10); + acc_integration_sleep_ms(1000 / 20); } deactivated = acc_detector_presence_deactivate(handle); diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 51abfdf..229dd46 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -1194,18 +1194,20 @@ static void OnTxTimerEvent(void *context) { /* USER CODE BEGIN OnTxTimerEvent_1 */ - if (sts_warm_up_count < 5) + if (sts_warm_up_count <= 5) { - /* USER CODE END OnTxTimerEvent_1 */ - //if ((sensor_data_ready ==1)) //|| (sts_reed_hall_changed_flag)) //||(sts_rss_result_changed_flag)||(sts_fall_rising_detected_result_changed_flag)) - //if ((sensor_data_ready ==1) || (sts_reed_hall_changed_flag) || (sts_rss_result_changed_flag)||(sts_fall_rising_detected_result_changed_flag)) - { - UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0); + /* USER CODE END OnTxTimerEvent_1 */ + //if ((sensor_data_ready ==1)) //|| (sts_reed_hall_changed_flag)) //||(sts_rss_result_changed_flag)||(sts_fall_rising_detected_result_changed_flag)) + //if ((sensor_data_ready ==1) || (sts_reed_hall_changed_flag) || (sts_rss_result_changed_flag)||(sts_fall_rising_detected_result_changed_flag)) + { + UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0); + } + /*Wait for next tx slot*/ + sts_warm_up_count++; + + UTIL_TIMER_Start(&TxTimer); } - /*Wait for next tx slot*/ - sts_warm_up_count++; - } - UTIL_TIMER_Start(&TxTimer); + //} /* USER CODE BEGIN OnTxTimerEvent_2 */ @@ -1783,6 +1785,8 @@ static void OnRestoreContextRequest(void *nvm, uint32_t nvm_size) */ static void OnYunhornSTSOORSSWakeUpTimerEvent(void *context) { + //UTIL_TIMER_Stop(&YunhornSTSRSSWakeUpTimer); + if ((sts_work_mode == STS_RSS_MODE)||(sts_work_mode == STS_DUAL_MODE)||(sts_work_mode == STS_UNI_MODE)) { UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP2), CFG_SEQ_Prio_0); diff --git a/STM32CubeIDE/Release/STS_O7.bin b/STM32CubeIDE/Release/STS_O7.bin index ac433d0..b749309 100644 Binary files a/STM32CubeIDE/Release/STS_O7.bin and b/STM32CubeIDE/Release/STS_O7.bin differ