Shih-Ho Hsieh / XYZ_sensor_Platform_SPI

Fork of XYZ_sensor_Platform by Shih-Ho Hsieh

Embed: (wiki syntax)

« Back to documentation index

MagRing Class Reference

Class mag_ring is intended to represent the MEMS Inertial & Environmental Nucleo Expansion Board with the same name. More...

#include <mag_ring.h>

Static Public Member Functions

static MagRingInstance (DevSPI *ext_spi=NULL)
 Get singleton instance.
static MagRingInstance (PinName mosi, PinName miso, PinName sclk)
 Get singleton instance.

Protected Member Functions

 MagRing (DevSPI *ext_spi)
 Constructor.
bool Init (void)
 Initialize the singleton's sensors to default settings.
bool Init_LIS3MDL (void)
 Initialize the singleton's magnetometers.

Detailed Description

Class mag_ring is intended to represent the MEMS Inertial & Environmental Nucleo Expansion Board with the same name.

The expansion board is featuring basically four IPs:

  1. a HTS221 Relative Humidity and Temperature Sensor
  2. a LIS3MDL 3-Axis Magnetometer
  3. a LPS25H MEMS Pressure Sensor (and Temperature Sensor)
  4. and a LSM6DS33 3D Acceleromenter and 3D Gyroscope

The expansion board features also a DIL 24-pin socket which makes it possible to add further MEMS adapters and other sensors (e.g. UV index).

It is intentionally implemented as a singleton because only one mag_ring at a time might be deployed in a HW component stack.
In order to get the singleton instance you have to call class method `Instance()`, e.g.:

 // Inertial & Environmental expansion board singleton instance
 static mag_ring *<TODO>_expansion_board = mag_ring::Instance();

Definition at line 77 of file mag_ring.h.


Constructor & Destructor Documentation

MagRing ( DevSPI ext_spi ) [protected]

Constructor.

Definition at line 50 of file mag_ring.cpp.


Member Function Documentation

bool Init ( void   ) [protected]

Initialize the singleton's sensors to default settings.

Return values:
trueif initialization successful,
falseotherwise

Definition at line 92 of file mag_ring.h.

bool Init_LIS3MDL ( void   ) [protected]

Initialize the singleton's magnetometers.

Return values:
trueif initialization successful,
falseotherwise

Definition at line 143 of file mag_ring.cpp.

MagRing * Instance ( PinName  mosi,
PinName  miso,
PinName  sclk 
) [static]

Get singleton instance.

Returns:
a pointer to the initialized singleton instance of class MagRing. A return value of NULL indicates an out of memory situation.
Parameters:
[in]sdaSPI data line pin. Taken into account only on the very first call of one of the 'Instance' functions. A new DevSPI will be created based on parameters 'sda' and 'scl'. The used DevSPI object gets saved in instance variable dev_spi.
[in]sclSPI clock line pin. Taken into account only on the very first call of one of the 'Instance' functions. A new DevSPI will be created based on parameters 'sda' and 'scl'. The used DevSPI object gets saved in instance variable dev_spi.
[in]ff_irq_pin(optional) PinName of the pin associated to asynchronous (i.e. interrupt based) free fall detection in case a LSM6DS33 3D Acceleromenter and 3D Gyroscope is mounted on top of the DIL 24-pin socket. Defaults to NC. Taken into account only on the very first call of one of the 'Instance' functions. A value of 'NC' will avoid instantiation of the LSM6DS33 even if present.

Definition at line 119 of file mag_ring.cpp.

MagRing * Instance ( DevSPI ext_spi = NULL ) [static]

Get singleton instance.

Returns:
a pointer to the initialized singleton instance of class MagRing. A return value of NULL indicates an out of memory situation.
Parameters:
[in]ext_spi(optional) pointer to an instance of DevSPI to be used for communication on the expansion board. Defaults to NULL. Taken into account only on the very first call of one of the 'Instance' functions. If not provided a new DevSPI will be created with standard configuration parameters. The used DevSPI object gets saved in instance variable dev_spi.
[in]ff_irq_pin(optional) PinName of the pin associated to asynchronous (i.e. interrupt based) free fall detection in case a LSM6DS33 3D Acceleromenter and 3D Gyroscope is mounted on top of the DIL 24-pin socket. Defaults to F746ZG_PIN_FF. Taken into account only on the very first call of one of the 'Instance' functions. A value of 'NC' will avoid instantiation of the LSM6DS33 even if present.

Definition at line 81 of file mag_ring.cpp.