"Sensors Reader" Sample Application for X-NUCLEO-IKS01A1 Expansion Board

Dependencies:   X_NUCLEO_IKS01A1 mbed

Fork of Sensors_Reader by ST Expansion SW Team

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
Revision:
50:4a902230142d
Parent:
49:0223aee4b17a
Child:
51:5ce8202680b4
--- a/main.cpp	Tue Jun 23 14:46:09 2015 +0200
+++ b/main.cpp	Wed Jun 24 14:03:07 2015 +0200
@@ -196,22 +196,23 @@
 	char buffer2[32];
 	char buffer3[32];
 	char buffer4[32];
-
+	unsigned int ret = 0;
+	
 	/* Switch LED On */
 	myled = LED_ON;
 	printf("===\n");
 
 	/* Determine Environmental Values */
-	CALL_METH(temp_sensor1, GetTemperature, &TEMPERATURE_Value, 0.0f);
-	CALL_METH(humidity_sensor, GetHumidity, &HUMIDITY_Value, 0.0f);
-	CALL_METH(pressure_sensor, GetPressure, &PRESSURE_Value, 0.0f);
-	CALL_METH(temp_sensor2, GetFahrenheit, &PRESSURE_Temp_Value, 0.0f);
-	CALL_METH(magnetometer, Get_M_Axes, (int32_t *)&MAG_Value, 0);
-	CALL_METH(accelerometer, Get_X_Axes, (int32_t *)&ACC_Value, 0);
-	CALL_METH(gyroscope, Get_G_Axes, (int32_t *)&GYR_Value, 0);
+	ret |= (!CALL_METH(temp_sensor1, GetTemperature, &TEMPERATURE_Value, 0.0f) ? 0x0 : 0x1);
+	ret |= (!CALL_METH(humidity_sensor, GetHumidity, &HUMIDITY_Value, 0.0f) ? 0x0 : 0x2);;
+	ret |= (!CALL_METH(pressure_sensor, GetPressure, &PRESSURE_Value, 0.0f) ? 0x0 : 0x4);;
+	ret |= (!CALL_METH(temp_sensor2, GetFahrenheit, &PRESSURE_Temp_Value, 0.0f) ? 0x0 : 0x8);;
+	ret |= (!CALL_METH(magnetometer, Get_M_Axes, (int32_t *)&MAG_Value, 0) ? 0x0 : 0x10);;
+	ret |= (!CALL_METH(accelerometer, Get_X_Axes, (int32_t *)&ACC_Value, 0) ? 0x0 : 0x20);;
+	ret |= (!CALL_METH(gyroscope, Get_G_Axes, (int32_t *)&GYR_Value, 0) ? 0x0 : 0x40);
 
 	/* Print Values Out */
-        printf("                      X         Y         Z\n"); 
+        printf("I2C errors: 0x%.2x      X         Y         Z\n", ret); 
         printf("MAG [mgauss]: %9ld %9ld %9ld\n", 
 	       MAG_Value.AXIS_X, MAG_Value.AXIS_Y, MAG_Value.AXIS_Z);
         printf("ACC [mg]:     %9ld %9ld %9ld\n",