Bosch BMA020 3-axis accelerometer.
This file contains functions for initializing and reading data from a Bosch BMA020 3-axis accelerometer.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
Functions | |
static bool | bma020_device_id (sensor_hal_t *hal, sensor_data_t *data) |
Read accelerometer device ID and revision numbers. More... | |
static bool | bma020_get_accel (sensor_hal_t *hal, sensor_data_t *data) |
Read accelerometer vector data. More... | |
bool | bma020_init (sensor_t *sensor, int resvd) |
Bosch BMA020 accelerometer driver initialization. More... | |
static bool | bma020_ioctl (sensor_t *sensor, sensor_command_t cmd, void *arg) |
BMA020 ioctl control entry point. More... | |
static bool | bma020_read (sensor_t *sensor, sensor_read_t type, sensor_data_t *data) |
Read sensor data. More... | |
static bool | bma020_set_bandwidth (sensor_hal_t *hal, int16_t band) |
Set the BMA020 ADC output data bandwidth. More... | |
static bool | bma020_set_range (sensor_hal_t *hal, int16_t range) |
Set the BMA020 full scale acceleration range. More... | |
Variables | |
static const sensor_map_t | band_table [] |
Bosch BMA020 Bandwidth Table (hertz, register value) More... | |
static const sensor_map_t | range_table [] |
Bosch BMA020 Range Table (milli-g, register value) More... | |
|
static |
Read accelerometer 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 BMA020_CHIP_ID, BMA020_CHIP_VERSION, sensor_data_t::device, and sensor_bus_get.
Referenced by bma020_read().
|
static |
Read accelerometer vector 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 bma020_ioctl(), and bma020_read().
Bosch BMA020 accelerometer driver initialization.
This is the main initialization function for the BMA020 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, BMA020_ACC_X_LSB, BMA020_CHIP_ID, BMA020_DATA_RESOLUTION, BMA020_ID_VAL, bma020_ioctl(), bma020_read(), bma020_set_bandwidth(), bma020_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_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 |
BMA020 ioctl control entry point.
hal | Address of an initialized sensor device descriptor. |
cmd | Command to execute |
arg | Argument for command (varies) |
References sensor_data_t::axis, bma020_get_accel(), bma020_set_bandwidth(), bma020_set_range(), sensor_desc::err, sensor_desc::hal, sensor_data_t::scaled, SENSOR_ERR_UNSUPPORTED, SENSOR_READ_VECTOR, SENSOR_SET_BANDWIDTH, SENSOR_SET_RANGE, vector3_t::x, vector3_t::y, and vector3_t::z.
Referenced by bma020_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 bma020_device_id(), bma020_get_accel(), sensor_desc::err, sensor_desc::hal, SENSOR_ERR_FUNCTION, SENSOR_READ_ACCELERATION, and SENSOR_READ_ID.
Referenced by bma020_init().
|
static |
Set the BMA020 ADC output data bandwidth.
hal | Address of an initialized sensor hardware descriptor. |
band | The index of a driver-specific bandwidth table entry. |
References BMA020_CTRL4, CTRL4_BANDWIDTH, sensor_bus_get, and sensor_bus_put.
Referenced by bma020_init(), and bma020_ioctl().
|
static |
Set the BMA020 full scale acceleration range.
hal | Address of an initialized sensor hardware descriptor. |
range | The index of a driver-specific range table entry. |
References BMA020_CTRL4, CTRL4_RANGE, sensor_bus_get, and sensor_bus_put.
Referenced by bma020_init(), and bma020_ioctl().
|
static |
Bosch BMA020 Bandwidth Table (hertz, register value)
Referenced by bma020_init().
|
static |