"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:
69:12b1170b510a
Parent:
62:67e2353604be
--- a/main.cpp	Thu Mar 23 13:06:41 2017 +0000
+++ b/main.cpp	Fri Mar 24 10:58:11 2017 +0100
@@ -176,8 +176,8 @@
 	uint8_t id1, id2;
 
 	/* Determine ID of Humidity & Temperature Sensor */
-	CALL_METH(humidity_sensor, ReadID, &id1, 0x0);
-	CALL_METH(temp_sensor1, ReadID, &id2, 0x0);
+	CALL_METH(humidity_sensor, read_id, &id1, 0x0);
+	CALL_METH(temp_sensor1, read_id, &id2, 0x0);
     	printf("Humidity  | Temperature Sensor ID = %s (0x%x | 0x%x)\n", 
 	       ((id1 == I_AM_HTS221) ? "HTS221 " : "UNKNOWN"),
 	       id1, id2
@@ -187,8 +187,8 @@
 	/* Determine ID of Gyro & Motion Sensor */
 	assert((mems_expansion_board->gyro_lsm6ds0 == NULL) ||
 	       (mems_expansion_board->gyro_lsm6ds3 == NULL));
-	CALL_METH(gyroscope, ReadID, &id1, 0x0);
-	CALL_METH(accelerometer, ReadID, &id2, 0x0);
+	CALL_METH(gyroscope, read_id, &id1, 0x0);
+	CALL_METH(accelerometer, read_id, &id2, 0x0);
     	printf("Gyroscope | Motion Sensor ID      = %s (0x%x | 0x%x)\n", 
 	       ((id1 == I_AM_LSM6DS3_XG) ? "LSM6DS3" : 
 		((id1 == I_AM_LSM6DS0_XG) ? "LSM6DS0" : "UNKNOWN")),
@@ -223,13 +223,13 @@
 	printf("===\n");
 
 	/* Determine Environmental Values */
-	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);
+	ret |= (!CALL_METH(temp_sensor1, get_temperature, &TEMPERATURE_Value, 0.0f) ? 0x0 : 0x1);
+	ret |= (!CALL_METH(humidity_sensor, get_humidity, &HUMIDITY_Value, 0.0f) ? 0x0 : 0x2);;
+	ret |= (!CALL_METH(pressure_sensor, get_pressure, &PRESSURE_Value, 0.0f) ? 0x0 : 0x4);;
+	ret |= (!CALL_METH(temp_sensor2, get_fahrenheit, &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("I2C [errors]: 0x%.2x    X         Y         Z\n", ret);