Bosch BMA180 3-axis accelerometer driver.
This file contains functions for initializing and reading data from a Bosch BMA180 3-axis accelerometer.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
Functions | |
static bool | bma180_device_id (sensor_hal_t *hal, sensor_data_t *data) |
Read BMA180 device ID and revision numbers. More... | |
static bool | bma180_get_accel (sensor_hal_t *hal, sensor_data_t *data) |
Read accelerometer data. More... | |
static bool | bma180_get_temperature (sensor_hal_t *hal, sensor_data_t *data) |
Read BMA180 integrated temperature sensor data. More... | |
bool | bma180_init (sensor_t *sensor, int resvd) |
Bosch BMA180 accelerometer driver initialization. More... | |
static bool | bma180_ioctl (sensor_t *sensor, sensor_command_t cmd, void *arg) |
BMA180 ioctl control entry point. More... | |
static bool | bma180_read (sensor_t *sensor, sensor_read_t type, sensor_data_t *data) |
Read sensor data. More... | |
static bool | bma180_set_bandwidth (sensor_hal_t *hal, int16_t band) |
Set the BMA180 ADC output data bandwidth. More... | |
static bool | bma180_set_range (sensor_hal_t *hal, int16_t range) |
Set the BMA180 full scale acceleration range. More... | |
static bool | bma180_set_state (sensor_hal_t *hal, sensor_state_t state) |
Set the BMA180 execution mode. More... | |
Variables | |
static const sensor_map_t | band_table [] |
Bosch BMA180 Bandwidth Table (hertz, register value) More... | |
static const sensor_map_t | range_table [] |
Bosch BMA180 Range Table (milli-g, register value) More... | |
|
static |
Read BMA180 device ID and revision numbers.
This function reads the accelerometer hardware identification registers and returns these values in the specified data structure.
hal | Address of an initialized sensor hardware descriptor. |
data | Address of sensor_data_t structure to return values. |
References BMA180_CHIP_ID, BMA180_CHIP_VERSION, sensor_data_t::device, and sensor_bus_get.
Referenced by bma180_read().
|
static |
Read accelerometer data.
This function obtains accelerometer data for all three axes of the Bosch device. The data is read from six device registers using a multi-byte bus transfer. The 10-bit raw results are then assembled from the two register values for each axis, including extending the sign bit, to form a signed 32-bit value.
Along with the actual sensor data, the LSB byte contains a "new" flag indicating if the data for this axis has been updated since the last time the axis data was read. Reading either LSB or MSB data will clear this flag.
hal | Address of an initialized sensor hardware descriptor. |
data | The address of a vector storing sensor axis data. |
References sensor_hal::burst_addr, and sensor_bus_read.
Referenced by bma180_ioctl(), and bma180_read().
|
static |
Read BMA180 integrated temperature sensor data.
hal | Address of an initialized sensor hardware descriptor. |
data | The address where temperature samples are returned. |
References BMA180_TEMP, BMA180_TEMP_OFFSET, sensor_hal::bus, sensor_data_t::scaled, sensor_bus_get, bus_desc_t::status, STATUS_OK, and sensor_data_t::temperature.
Referenced by bma180_read().
Bosch BMA180 accelerometer driver initialization.
This is the main initialization function for the BMA180 device. The accelerometer range and bandwidth are set based on user-specified values from the system configuration.
sensor | Address of a sensor device descriptor. |
resvd | Reserved value. |
References ARRAYSIZE, band_table, sensor_hal::bandwidth, BMA180_ACC_X_LSB, BMA180_CHIP_ID, BMA180_DATA_RESOLUTION, BMA180_ID_VAL, bma180_ioctl(), bma180_read(), bma180_set_bandwidth(), bma180_set_range(), sensor_hal::burst_addr, sensor_hal::bus, sensor_desc::drv, sensor_device_t::func, sensor_desc::hal, sensor_hal::range, range_table, sensor_funcs_t::read, sensor_hal::resolution, sensor_bus_get, SENSOR_CAPS_3_AXIS, SENSOR_CAPS_AUX_TEMP, SENSOR_CAPS_HI_G_EVENT, SENSOR_CAPS_LO_G_EVENT, SENSOR_CAPS_SELFTEST, SENSOR_SCALE_milli, SENSOR_UNITS_g0, SENSOR_VENDOR_BOSCH, status, bus_desc_t::status, and STATUS_OK.
|
static |
BMA180 ioctl control entry point.
hal | Address of an initialized sensor hardware descriptor. |
cmd | Command to execute |
arg | Argument for command (varies) |
References sensor_data_t::axis, bma180_get_accel(), bma180_set_bandwidth(), bma180_set_range(), bma180_set_state(), sensor_desc::err, sensor_desc::hal, sensor_data_t::scaled, SENSOR_ERR_UNSUPPORTED, SENSOR_READ_VECTOR, SENSOR_SET_BANDWIDTH, SENSOR_SET_RANGE, SENSOR_SET_STATE, vector3_t::x, vector3_t::y, and vector3_t::z.
Referenced by bma180_init().
|
static |
Read sensor data.
This routine calls the appropriate internal data function to obtain the specified type of data from the sensor device.
sensor | Address of an initialized sensor device descriptor. |
type | Type of sensor data to read. |
data | The address where data values are returned. |
References bma180_device_id(), bma180_get_accel(), bma180_get_temperature(), sensor_desc::err, sensor_desc::hal, SENSOR_ERR_FUNCTION, SENSOR_READ_ACCELERATION, SENSOR_READ_ID, and SENSOR_READ_TEMPERATURE.
Referenced by bma180_init().
|
static |
Set the BMA180 ADC output data bandwidth.
hal | Address of an initialized sensor hardware descriptor. |
band | The index of a driver-specific bandwidth table entry. |
References BMA180_BW_TCS, BW, sensor_bus_get, and sensor_bus_put.
Referenced by bma180_init(), and bma180_ioctl().
|
static |
Set the BMA180 full scale acceleration range.
hal | Address of an initialized sensor hardware descriptor. |
range | The index o a driver-specific range table entry. |
References BMA180_OFFSET_LSB1, RANGE, sensor_bus_get, and sensor_bus_put.
Referenced by bma180_init(), and bma180_ioctl().
|
static |
Set the BMA180 execution mode.
hal | Address of an initialized sensor hardware descriptor. |
state | A specified sensor operational state. |
Referenced by bma180_ioctl().
|
static |
Bosch BMA180 Bandwidth Table (hertz, register value)
Referenced by bma180_init().
|
static |
Bosch BMA180 Range Table (milli-g, register value)
Referenced by bma180_init().