Example of wake up detection for LSM6DSL in X-NUCLEO-IKS01A2
Dependencies: X_NUCLEO_IKS01A2 mbed
Fork of WakeUp_IKS01A2 by
Wake up Demo Application based on sensor expansion board X-NUCLEO-IKS01A2
Main function is to show how to detect the wake up event using the sensor expansion board and send a notification using UART to a connected PC or Desktop and display it on terminal applications like TeraTerm.
After connection has been established:
- the user can try to shake the board and then view the notification using an hyper terminal. When the wake up event is detected, the LED is switched on for a while.
- the user button can be used to enable/disable the wake up detection feature.
Diff: main.cpp
- Revision:
- 13:9d182146ebf4
- Parent:
- 8:b372cdda7fe2
--- a/main.cpp Fri Dec 16 09:48:12 2016 +0000 +++ b/main.cpp Tue Mar 14 13:44:03 2017 +0100 @@ -38,10 +38,10 @@ /* Includes */ #include "mbed.h" -#include "x_nucleo_iks01a2.h" +#include "XNucleoIKS01A2.h" /* Instantiate the expansion board */ -static X_NUCLEO_IKS01A2 *mems_expansion_board = X_NUCLEO_IKS01A2::Instance(D14, D15, D4, D5); +static XNucleoIKS01A2 *mems_expansion_board = XNucleoIKS01A2::instance(D14, D15, D4, D5); /* Retrieve the composing elements of the expansion board */ static LSM6DSLSensor *acc_gyro = mems_expansion_board->acc_gyro; @@ -61,12 +61,12 @@ /* Attach callback to User button press */ mybutton.fall(&pressed_cb); /* Attach callback to LSM6DSL INT2 */ - acc_gyro->AttachINT2IRQ(&INT2_cb); + acc_gyro->attach_int2_irq(&INT2_cb); /* Enable LSM6DSL accelerometer */ - acc_gyro->Enable_X(); + acc_gyro->enable_x(); /* Enable Wake-Up Detection. */ - acc_gyro->Enable_Wake_Up_Detection(); + acc_gyro->enable_wake_up_detection(); printf("\r\n--- Starting new run ---\r\n"); @@ -74,10 +74,10 @@ if(toggle_wake_up_enable) { toggle_wake_up_enable = 0; if(wake_up_is_enabled == 0) { - acc_gyro->Enable_Wake_Up_Detection(); + acc_gyro->enable_wake_up_detection(); wake_up_is_enabled = 1; } else { - acc_gyro->Disable_Wake_Up_Detection(); + acc_gyro->disable_wake_up_detection(); wake_up_is_enabled = 0; } } @@ -85,7 +85,7 @@ if (mems_event) { mems_event = 0; LSM6DSL_Event_Status_t status; - acc_gyro->Get_Event_Status(&status); + acc_gyro->get_event_status(&status); if (status.WakeUpStatus) { /* Led blinking. */ myled = 1;