"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:
- 49:0223aee4b17a
- Parent:
- 48:9631c81e1d87
- Child:
- 50:4a902230142d
--- a/main.cpp Mon Jun 22 11:46:53 2015 +0200 +++ b/main.cpp Tue Jun 23 14:46:09 2015 +0200 @@ -230,8 +230,6 @@ /*** Main function ------------------------------------------------------------- ***/ -#define D_SLEEP_VERSION 4 - /* Generic main function/loop for enabling WFI in case of interrupt based cyclic execution */ @@ -244,51 +242,6 @@ /* 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) { - timer_irq_triggered = false; - __enable_irq(); - main_cycle(); - } else if(ff_irq_triggered) { - ff_irq_triggered = false; - __enable_irq(); - handle_ff_irq(); - } else { - __WFI(); - __enable_irq(); /* do NOT enable irqs before WFI to avoid - opening a window in which you can loose - 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; @@ -297,10 +250,8 @@ ff_irq_triggered = false; handle_ff_irq(); } else { - __WFE(); /* assuming that SEVONPEND in the System Control Register is NOT set */ + __WFE(); /* it is recommended 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] }