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:
- 7:6ad7b6ae4b93
- Parent:
- 6:06f4a71c4743
- Child:
- 8:b372cdda7fe2
diff -r 06f4a71c4743 -r 6ad7b6ae4b93 main.cpp
--- a/main.cpp Wed Nov 23 16:46:48 2016 +0000
+++ b/main.cpp Thu Nov 24 16:46:30 2016 +0000
@@ -49,19 +49,19 @@
InterruptIn mybutton(USER_BUTTON);
DigitalOut myled(LED1);
-volatile int wake_up = 0;
+volatile int mems_event = 0;
volatile int toggle_wake_up_enable = 0;
static int wake_up_is_enabled = 1;
-void pressed();
-void wakeup();
+void pressed_cb();
+void INT2_cb();
/* Simple main function */
int main() {
/* Attach callback to User button press */
- mybutton.fall(&pressed);
+ mybutton.fall(&pressed_cb);
/* Attach callback to LSM6DSL INT2 */
- acc_gyro->AttachINT2IRQ(&wakeup);
+ acc_gyro->AttachINT2IRQ(&INT2_cb);
/* Enable LSM6DSL accelerometer */
acc_gyro->Enable_X();
@@ -82,8 +82,8 @@
}
}
- if (wake_up) {
- wake_up = 0;
+ if (mems_event) {
+ mems_event = 0;
LSM6DSL_Event_Status_t status;
acc_gyro->Get_Event_Status(&status);
if (status.WakeUpStatus) {
@@ -99,10 +99,10 @@
}
}
-void pressed() {
+void pressed_cb() {
toggle_wake_up_enable = 1;
}
-void wakeup() {
- wake_up = 1;
+void INT2_cb() {
+ mems_event = 1;
}
