FXOS8700 3-axis accelerometer/magnetometer

Driver for the FXOS8700 3-axis accelerometer/magnetometer. More...

Detailed Description

Driver for the FXOS8700 3-axis accelerometer/magnetometer.

The connection between the MCU and the FXOS8700 is based on the I2C-interface.

This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities.

Modules

 FXOS8700 accelerometer/magnetometer driver compile configuration
 

Files

file  fxos8700_params.h
 Default configuration for FXOS8700 devices.
 
file  fxos8700_regs.h
 Register definitions for FXOS8700 devices.
 
file  fxos8700.h
 Interface definition for the FXOS8700 sensor driver.
 

Data Structures

struct  fxos8700_params_t
 Parameters needed for device initialization. More...
 
struct  fxos8700_measurement_t
 Individual 3-axis measurement. More...
 
struct  fxos8700_t
 Device descriptor for a FXOS8700 device. More...
 

Enumerations

enum  {
  FXOS8700_OK = 0, FXOS8700_ADDRERR = -1, FXOS8700_NOBUS = -2, FXOS8700_NODEV = -3,
  FXOS8700_BUSERR = -4
}
 FXOS8700 specific return values. More...
 

Functions

int fxos8700_init (fxos8700_t *dev, const fxos8700_params_t *params)
 Initialize an FXOS8700 device. More...
 
int fxos8700_set_active (const fxos8700_t *dev)
 Convenience function for turning on the FXOS8700. More...
 
int fxos8700_set_idle (const fxos8700_t *dev)
 Convenience function for turning off the FXOS8700. More...
 
int fxos8700_read (const fxos8700_t *dev, fxos8700_measurement_t *acc, fxos8700_measurement_t *mag)
 Convenience function for reading acceleration and magnetic field. More...
 
int fxos8700_read_cached (const void *dev, fxos8700_measurement_t *acc, fxos8700_measurement_t *mag)
 Extended read function including caching capability. More...
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

FXOS8700 specific return values.

Enumerator
FXOS8700_OK 

everything went as expected

FXOS8700_ADDRERR 

no FXOS8700 device found on the bus

FXOS8700_NOBUS 

errors while initializing the I2C bus

FXOS8700_NODEV 

no FXOS8700 device found on the bus

FXOS8700_BUSERR 

error during I2C communication

Definition at line 58 of file fxos8700.h.

Function Documentation

◆ fxos8700_init()

int fxos8700_init ( fxos8700_t dev,
const fxos8700_params_t params 
)

Initialize an FXOS8700 device.

Parameters
[out]devdevice descriptor
[in]paramsparameters for device
Returns
FXOS8700_OK on success
FXOS8700_NOBUS on I2C initialization error
FXOS8700_BUSERR on I2C communication error
FXOS8700_ADDRERR on invalid address
FXOS8700_NODEV if no FXOS8700 device found on bus

◆ fxos8700_read()

int fxos8700_read ( const fxos8700_t dev,
fxos8700_measurement_t acc,
fxos8700_measurement_t mag 
)

Convenience function for reading acceleration and magnetic field.

This function will trigger a new conversion, wait for the conversion to be finished and the get the results from the device.

Parameters
[in]devdevice descriptor of sensor
[out]acc3-axis acceleration [in milli grativy acceleration (mg) ]
[out]mag3-axis magnetic field [in degree milli Gauss (mGs) ]
Returns
FXOS8700_OK on success
FXOS8700_BUSERR on I2C communication failures

◆ fxos8700_read_cached()

int fxos8700_read_cached ( const void *  dev,
fxos8700_measurement_t acc,
fxos8700_measurement_t mag 
)

Extended read function including caching capability.

This function will return cached values if they are within the sampling period (FXOS8700_RENEW_INTERVAL), or will trigger a new conversion, wait for the conversion to be finished and the get the results from the device.

Parameters
[in]devdevice descriptor of sensor
[out]acc3-axis acceleration [in milli grativy acceleration (mg) ]
[out]mag3-axis magnetic field [in degree milli Gauss (mGs) ]
Returns
FXOS8700_OK on success
FXOS8700_BUSERR on I2C communication failures

◆ fxos8700_set_active()

int fxos8700_set_active ( const fxos8700_t dev)

Convenience function for turning on the FXOS8700.

This function will trigger a new conversion, wait for the conversion to be finished and the get the results from the device.

Parameters
[in]devdevice descriptor of sensor
Returns
FXOS8700_OK on success
FXOS8700_BUSERR on I2C communication failures

◆ fxos8700_set_idle()

int fxos8700_set_idle ( const fxos8700_t dev)

Convenience function for turning off the FXOS8700.

This function will trigger a new conversion, wait for the conversion to be finished and the get the results from the device.

Parameters
[in]devdevice descriptor of sensor
Returns
FXOS8700_OK on success
FXOS8700_BUSERR on I2C communication failures