Commit 0099c5eb authored by aohui.li's avatar aohui.li

继续修改

parent 1d88e1f1
...@@ -110,8 +110,9 @@ void app_main(void) ...@@ -110,8 +110,9 @@ void app_main(void)
ESP_LOGI(TAG, "Turning the LED %s!", s_led_state == true ? "ON" : "OFF"); ESP_LOGI(TAG, "Turning the LED %s!", s_led_state == true ? "ON" : "OFF");
blink_led(); blink_led();
blink_led_g(); blink_led_g();
lis2dw12_wakeup_judgment();
/* Toggle the LED state */ /* Toggle the LED state */
s_led_state = !s_led_state; s_led_state = !s_led_state;
vTaskDelay(1000 / portTICK_PERIOD_MS); // vTaskDelay(1000 / portTICK_PERIOD_MS);
} }
} }
...@@ -90,7 +90,6 @@ static void WakeupEnable(void) ...@@ -90,7 +90,6 @@ static void WakeupEnable(void)
void lis2dw12_init() void lis2dw12_init()
{ {
static uint8_t whoamI, rst; static uint8_t whoamI, rst;
uint8_t tx_buffer[1000];
esp_err_t ret; esp_err_t ret;
ESP_LOGI(TAG, "LIS2DW12 Init"); ESP_LOGI(TAG, "LIS2DW12 Init");
...@@ -135,8 +134,6 @@ void lis2dw12_init() ...@@ -135,8 +134,6 @@ void lis2dw12_init()
vTaskDelay(pdMS_TO_TICKS(50)); vTaskDelay(pdMS_TO_TICKS(50));
} }
/* Restore default configuration */ /* Restore default configuration */
lis2dw12_reset_set(&dev_ctx, PROPERTY_ENABLE); lis2dw12_reset_set(&dev_ctx, PROPERTY_ENABLE);
...@@ -152,30 +149,30 @@ void lis2dw12_init() ...@@ -152,30 +149,30 @@ void lis2dw12_init()
ESP_LOGI(TAG, "LIS2DW12 Start Config Done"); ESP_LOGI(TAG, "LIS2DW12 Start Config Done");
while (1) { // while (1) {
lis2dw12_all_sources_t all_source; // lis2dw12_all_sources_t all_source;
/* Check Wake-Up events */ // /* Check Wake-Up events */
lis2dw12_all_sources_get(&dev_ctx, &all_source); // lis2dw12_all_sources_get(&dev_ctx, &all_source);
if (all_source.wake_up_src.wu_ia) { // if (all_source.wake_up_src.wu_ia) {
snprintf((char *)tx_buffer, sizeof(tx_buffer), "Wake-Up event on "); // snprintf((char *)tx_buffer, sizeof(tx_buffer), "Wake-Up event on ");
if (all_source.wake_up_src.x_wu) { // if (all_source.wake_up_src.x_wu) {
strcat((char *)tx_buffer, "X"); // strcat((char *)tx_buffer, "X");
} // }
if (all_source.wake_up_src.y_wu) { // if (all_source.wake_up_src.y_wu) {
strcat((char *)tx_buffer, "Y"); // strcat((char *)tx_buffer, "Y");
} // }
if (all_source.wake_up_src.z_wu) { // if (all_source.wake_up_src.z_wu) {
strcat((char *)tx_buffer, "Z"); // strcat((char *)tx_buffer, "Z");
} // }
strcat((char *)tx_buffer, " direction\r\n"); // strcat((char *)tx_buffer, " direction\r\n");
ESP_LOGI(TAG, "%s", tx_buffer); // ESP_LOGI(TAG, "%s", tx_buffer);
} // }
} // }
} }
static void lis2dw12_wake_config(void) static void lis2dw12_wake_config(void)
...@@ -207,4 +204,32 @@ static void lis2dw12_wake_config(void) ...@@ -207,4 +204,32 @@ static void lis2dw12_wake_config(void)
lis2dw12_pin_int1_route_get(&dev_ctx, &int_route.ctrl4_int1_pad_ctrl); lis2dw12_pin_int1_route_get(&dev_ctx, &int_route.ctrl4_int1_pad_ctrl);
int_route.ctrl4_int1_pad_ctrl.int1_wu = PROPERTY_ENABLE; int_route.ctrl4_int1_pad_ctrl.int1_wu = PROPERTY_ENABLE;
lis2dw12_pin_int1_route_set(&dev_ctx, &int_route.ctrl4_int1_pad_ctrl); lis2dw12_pin_int1_route_set(&dev_ctx, &int_route.ctrl4_int1_pad_ctrl);
}
void lis2dw12_wakeup_judgment(void)
{
uint8_t tx_buffer[1000];
lis2dw12_all_sources_t all_source;
/* Check Wake-Up events */
lis2dw12_all_sources_get(&dev_ctx, &all_source);
if (all_source.wake_up_src.wu_ia) {
snprintf((char *)tx_buffer, sizeof(tx_buffer), "Wake-Up event on ");
if (all_source.wake_up_src.x_wu) {
strcat((char *)tx_buffer, "X");
}
if (all_source.wake_up_src.y_wu) {
strcat((char *)tx_buffer, "Y");
}
if (all_source.wake_up_src.z_wu) {
strcat((char *)tx_buffer, "Z");
}
strcat((char *)tx_buffer, " direction\r\n");
ESP_LOGI(TAG, "%s", tx_buffer);
}
} }
\ No newline at end of file
...@@ -5,5 +5,6 @@ ...@@ -5,5 +5,6 @@
#include "stdlib.h" #include "stdlib.h"
void lis2dw12_init(); void lis2dw12_init();
void lis2dw12_wakeup_judgment(void);
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment