"Sensors Reader" Sample Application for X-NUCLEO-IKS01A1 Expansion Board
Dependencies: X_NUCLEO_IKS01A1 mbed
Fork of Sensors_Reader by
X-NUCLEO-IKS01A1 MEMS Inertial & Environmental Sensor Nucleo Expansion Board Firmware Package
Introduction
This firmware package includes Components Device Drivers, Board Support Package and example applications for STMicroelectronics X-NUCLEO-IKS01A1 MEMS Inertial & Environmental Nucleo Expansion Board.
Example Application
First of all, the example application outputs information retrieved from the Expansion Board over UART.
Launch a terminal application (e.g.: PuTTY
on Windows, Minicom
on Linux) and set the UART port to 9600 bps, 8 bit, No Parity,
1 stop bit.
The "Sensors Reader" program is a more complex example of how to use the X-NUCLEO-IKS01A1 expansion board featuring among others:
- Support for LSM6DS3 3D Accelerometer & Gyroscope (on DIL 24-pin socket) including free-fall detection
- Usage of LED & Ticker
- Exploitation of wait for event
- (Top-/Bottom-Half) Interrupt handling
Diff: main.cpp
- Revision:
- 47:6a63161486cf
- Parent:
- 40:f567538352e1
- Child:
- 48:9631c81e1d87
--- a/main.cpp Tue Jun 16 13:21:37 2015 +0200 +++ b/main.cpp Mon Jun 22 11:24:50 2015 +0200 @@ -230,6 +230,8 @@ /*** Main function ------------------------------------------------------------- ***/ +#define D_SLEEP_VERSION 1 + /* Generic main function/loop for enabling WFI in case of interrupt based cyclic execution */ @@ -242,6 +244,17 @@ /* Start timer irq */ ticker.attach_us(timer_irq, MS_INTERVALS * APP_LOOP_PERIOD); +#if D_SLEEP_VERSION == 1 // version without WFI/WFE and without IRQ synchronization + while (true) { + if(timer_irq_triggered) { + timer_irq_triggered = false; + main_cycle(); + } else if(ff_irq_triggered) { + ff_irq_triggered = false; + handle_ff_irq(); + } + } +#elif D_SLEEP_VERSION == 2 // classical version with WFI and with IRQ synchronization while (true) { __disable_irq(); if(timer_irq_triggered) { @@ -259,4 +272,35 @@ irq arrivals before going into WFI */ } } +#elif D_SLEEP_VERSION == 3 // version with WFE and with IRQ synchronization + while (true) { + __disable_irq(); + if(timer_irq_triggered) { + timer_irq_triggered = false; + __enable_irq(); + main_cycle(); + } else if(ff_irq_triggered) { + ff_irq_triggered = false; + __enable_irq(); + handle_ff_irq(); + } else { + __enable_irq(); + __WFE(); /* assuming that SEVONPEND in the System Control Register is NOT set */ + } + } +#elif D_SLEEP_VERSION == 4 // version with WFE and without IRQ synchronization + while (true) { + if(timer_irq_triggered) { + timer_irq_triggered = false; + main_cycle(); + } else if(ff_irq_triggered) { + ff_irq_triggered = false; + handle_ff_irq(); + } else { + __WFE(); /* assuming that SEVONPEND in the System Control Register is NOT set */ + } + } +#else // D_SLEEP_VERSION != [1|2|3|4] +#error "Unsupported D_SLEEP_VERSION selected!" +#endif // D_SLEEP_VERSION != [1|2|3|4] }