upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
Go to the source code of this file.
Data Structures | |
struct | _bno055_context |
Functions | |
bno055_context | bno055_init (int bus, uint8_t addr) |
void | bno055_close (bno055_context dev) |
upm_result_t | bno055_update (const bno055_context dev) |
upm_result_t | bno055_get_chip_id (const bno055_context dev, uint8_t *chip_id) |
upm_result_t | bno055_get_acc_id (const bno055_context dev, uint8_t *chip_id) |
upm_result_t | bno055_get_mag_id (const bno055_context dev, uint8_t *chip_id) |
upm_result_t | bno055_get_gyr_id (const bno055_context dev, uint8_t *chip_id) |
upm_result_t | bno055_get_sw_revision (const bno055_context dev, uint16_t *sw_rev) |
upm_result_t | bno055_get_bootloader_id (const bno055_context dev, uint8_t *bl_id) |
upm_result_t | bno055_set_clock_external (const bno055_context dev, bool extClock) |
upm_result_t | bno055_set_temperature_source (const bno055_context dev, BNO055_TEMP_SOURCES_T src) |
upm_result_t | bno055_set_temperature_units_celsius (const bno055_context dev) |
upm_result_t | bno055_set_operation_mode (const bno055_context dev, BNO055_OPERATION_MODES_T mode) |
upm_result_t | bno055_reset_system (const bno055_context dev) |
upm_result_t | bno055_get_calibration_status (const bno055_context dev, int *mag, int *acc, int *gyr, int *sys) |
bool | bno055_is_fully_calibrated (const bno055_context dev) |
upm_result_t | bno055_read_calibration_data (const bno055_context dev, uint8_t *data, size_t len) |
upm_result_t | bno055_write_calibration_data (const bno055_context dev, uint8_t *data, size_t len) |
float | bno055_get_temperature (const bno055_context dev) |
void | bno055_get_euler_angles (const bno055_context dev, float *heading, float *roll, float *pitch) |
void | bno055_get_quaternions (const bno055_context dev, float *w, float *x, float *y, float *z) |
void | bno055_get_linear_acceleration (const bno055_context dev, float *x, float *y, float *z) |
void | bno055_get_gravity_vectors (const bno055_context dev, float *x, float *y, float *z) |
void | bno055_get_accelerometer (const bno055_context dev, float *x, float *y, float *z) |
void | bno055_get_magnetometer (const bno055_context dev, float *x, float *y, float *z) |
void | bno055_get_gyroscope (const bno055_context dev, float *x, float *y, float *z) |
upm_result_t | bno055_set_acceleration_config (const bno055_context dev, BNO055_ACC_RANGE_T range, BNO055_ACC_BW_T bw, BNO055_ACC_PWR_MODE_T pwr) |
upm_result_t | bno055_set_magnetometer_config (const bno055_context dev, BNO055_MAG_ODR_T odr, BNO055_MAG_OPR_T opr, BNO055_MAG_POWER_T pwr) |
upm_result_t | bno055_set_gyroscope_config (const bno055_context dev, BNO055_GYR_RANGE_T range, BNO055_GYR_BW_T bw, BNO055_GYR_POWER_MODE_T pwr) |
upm_result_t | bno055_set_accelerometer_units (const bno055_context dev, bool mg) |
upm_result_t | bno055_set_gyroscope_units (const bno055_context dev, bool radians) |
upm_result_t | bno055_set_euler_units (const bno055_context dev, bool radians) |
upm_result_t | bno055_reset_interrupt_status (const bno055_context dev) |
upm_result_t | bno055_get_interrupt_status (const bno055_context dev, uint8_t *istat) |
upm_result_t | bno055_get_interrupt_enable (const bno055_context dev, uint8_t *ienable) |
upm_result_t | bno055_set_interrupt_enable (const bno055_context dev, uint8_t enables) |
upm_result_t | bno055_get_interrupt_mask (const bno055_context dev, uint8_t *imask) |
upm_result_t | bno055_set_interrupt_mask (const bno055_context dev, uint8_t mask) |
upm_result_t | bno055_get_system_status (const bno055_context dev, BNO055_SYS_STATUS_T *sys_stat) |
upm_result_t | bno055_get_system_error (const bno055_context dev, BNO055_SYS_ERR_T *sys_err) |
upm_result_t | bno055_install_isr (const bno055_context dev, int gpio, mraa_gpio_edge_t level, void(*isr)(void *), void *arg) |
void | bno055_uninstall_isr (const bno055_context dev) |
upm_result_t | bno055_set_page (const bno055_context dev, uint8_t page, bool force) |
upm_result_t | bno055_read_reg (const bno055_context dev, uint8_t reg, uint8_t *retval) |
upm_result_t | bno055_read_regs (const bno055_context dev, uint8_t reg, uint8_t *buffer, size_t len) |
upm_result_t | bno055_write_reg (const bno055_context dev, uint8_t reg, uint8_t val) |
upm_result_t | bno055_write_regs (const bno055_context dev, uint8_t reg, uint8_t *buffer, size_t len) |
Typedefs | |
typedef struct _bno055_context * | bno055_context |
bno055_context bno055_init | ( | int | bus, |
uint8_t | addr | ||
) |
BNO055 initialization.
By default, this function sets the acceleration units to m/s^2, gyro and Euler units to degrees, and temperature to celsius. It then enters the NDOF fusion mode.
In addition, the internal clock is used so that compatibility with other implementations is assured. If you are using a device with an external clock, call setClockExternal(true) to enable it.
bus | I2C bus to use. |
address | The I2C address for this device. |
void bno055_close | ( | bno055_context | dev | ) |
BNO055 close function.
dev | The device context. |
upm_result_t bno055_update | ( | const bno055_context | dev | ) |
Update the internal stored values from sensor data.
dev | The device context. |
upm_result_t bno055_get_chip_id | ( | const bno055_context | dev, |
uint8_t * | chip_id | ||
) |
Return the chip ID.
dev | The device context. |
chip_id | The chip ID (BNO055_CHIPID). |
upm_result_t bno055_get_acc_id | ( | const bno055_context | dev, |
uint8_t * | chip_id | ||
) |
Return the accelerometer chip ID.
dev | The device context. |
chip_id | The chip ID |
upm_result_t bno055_get_mag_id | ( | const bno055_context | dev, |
uint8_t * | chip_id | ||
) |
Return the magnetometer chip ID.
dev | The device context. |
chip_id | The chip ID |
upm_result_t bno055_get_gyr_id | ( | const bno055_context | dev, |
uint8_t * | chip_id | ||
) |
Return the gyroscope chip ID.
dev | The device context. |
chip_id | The chip ID |
upm_result_t bno055_get_sw_revision | ( | const bno055_context | dev, |
uint16_t * | sw_rev | ||
) |
Return the fusion firmware revison.
dev | The device context. |
sw_rev | The firmware revison. |
upm_result_t bno055_get_bootloader_id | ( | const bno055_context | dev, |
uint8_t * | bl_id | ||
) |
Return the bootloader ID.
dev | The device context. |
bl_id | The bootloader ID. |
upm_result_t bno055_set_clock_external | ( | const bno055_context | dev, |
bool | extClock | ||
) |
Enable or disables the use of the external clock. The Adafriut device does contain an external clock which might be more stable. By default, the internal clock is used.
dev | The device context. |
extClock | true to use external clock, false otherwise. |
upm_result_t bno055_set_temperature_source | ( | const bno055_context | dev, |
BNO055_TEMP_SOURCES_T | src | ||
) |
Select the temperature source. This can be the accelerometer or the gyroscope. By default, the accelerometer temperature is used as the source.
dev | The device context. |
src | One of the TEMP_SOURCES_T values. |
upm_result_t bno055_set_temperature_units_celsius | ( | const bno055_context | dev | ) |
Set the temperature units of the device to Celsius (always).
dev | The device context. |
upm_result_t bno055_set_operation_mode | ( | const bno055_context | dev, |
BNO055_OPERATION_MODES_T | mode | ||
) |
Set the operating mode for the device. This places the device into a config mode, one of 7 non-fusion modes, or one of 5 fusion modes. All stored sensor data is cleared when switching modes. The device must be in config mode for most configuration operations. See the datasheet for details.
dev | The device context. |
mode | One of the OPERATION_MODES_T values. |
upm_result_t bno055_reset_system | ( | const bno055_context | dev | ) |
Reboot the sensor. This is equivalent to a power on reset. All calibration data will be lost, and the device must be re-calibrated.
dev | The device context. |
upm_result_t bno055_get_calibration_status | ( | const bno055_context | dev, |
int * | mag, | ||
int * | acc, | ||
int * | gyr, | ||
int * | sys | ||
) |
Read the calibration status registers and return them. The values range from 0 (uncalibrated) to 3 (fully calibrated).
dev | The device context. |
mag | The calibration status of the magnetometer. |
acc | The calibration status of the accelerometer. |
mag | The calibration status of the gyroscope. |
mag | The calibration status of the overall system. |
bool bno055_is_fully_calibrated | ( | const bno055_context | dev | ) |
Read the calibration status registers and return true or false, indicating whether all of the calibration parameters are fully calibrated.
dev | The device context. |
upm_result_t bno055_read_calibration_data | ( | const bno055_context | dev, |
uint8_t * | data, | ||
size_t | len | ||
) |
Read the calibration data and place it into a buffer. The buffer must be BNO055_CALIBRATION_DATA_SIZE bytes in size. This data can then be saved for later reuse by bno055_write_calibration_data() to restore calibration data after a reset. Note: bno055_is_fully_calibrated() (calibration is complete) must be true or an error will result.
dev | The device context. |
data | A pointer to a buffer to hold the calibration data. This buffer must be BNO055_CALIBRATION_DATA_SIZE bytes in length. |
len | The length of the buffer. An error will be returned if the length is not equal to BNO055_CALIBRATION_DATA_SIZE. |
upm_result_t bno055_write_calibration_data | ( | const bno055_context | dev, |
uint8_t * | data, | ||
size_t | len | ||
) |
Write previously saved calibration data to the calibration registers. The array containing the data must be BNO055_CALIBRATION_DATA_SIZE bytes in size.
dev | The device context. |
data | uint8_t array representing calibration data, as obtained by bno055_read_calibration_data(). |
len | The length of the supplied buffer. An error will be returned if the length is not equal to BNO055_CALIBRATION_DATA_SIZE. |
float bno055_get_temperature | ( | const bno055_context | dev | ) |
Return the current measured temperature. Note, this is not ambient temperature - this is the temperature of the selected source on the chip. update() must have been called prior to calling this method.
dev | The device context. |
void bno055_get_euler_angles | ( | const bno055_context | dev, |
float * | heading, | ||
float * | roll, | ||
float * | pitch | ||
) |
Return current orientation fusion data in the form of Euler Angles. By default, the returned values are in degrees. update() must have been called prior to calling this method.
dev | The device context. |
heading | Pointer to a floating point value that will have the current heading angle placed into it. |
roll | Pointer to a floating point value that will have the current roll angle placed into it. |
pitch | Pointer to a floating point value that will have the current pitch angle placed into it. |
void bno055_get_quaternions | ( | const bno055_context | dev, |
float * | w, | ||
float * | x, | ||
float * | y, | ||
float * | z | ||
) |
Return current orientation fusion data in the form of Quaternions. update() must have been called prior to calling this method.
dev | The device context. |
w | Pointer to a floating point value that will have the current w component placed into it. |
x | Pointer to a floating point value that will have the current x component placed into it. |
y | Pointer to a floating point value that will have the current y component placed into it. |
z | Pointer to a floating point value that will have the current z component placed into it. |
void bno055_get_linear_acceleration | ( | const bno055_context | dev, |
float * | x, | ||
float * | y, | ||
float * | z | ||
) |
Return current orientation fusion data in the form of Linear Acceleration. By default the returned values are in meters per-second squared (m/s^2). update() must have been called prior to calling this method.
dev | The device context. |
x | Pointer to a floating point value that will have the current x component placed into it. |
y | Pointer to a floating point value that will have the current y component placed into it. |
z | Pointer to a floating point value that will have the current z component placed into it. |
void bno055_get_gravity_vectors | ( | const bno055_context | dev, |
float * | x, | ||
float * | y, | ||
float * | z | ||
) |
Return current orientation fusion data in the form of a Gravity Vector per-axis. By default the returned values are in meters per-second squared (m/s^2). update() must have been called prior to calling this method.
dev | The device context. |
x | Pointer to a floating point value that will have the current x component placed into it. |
y | Pointer to a floating point value that will have the current y component placed into it. |
z | Pointer to a floating point value that will have the current z component placed into it. |
void bno055_get_accelerometer | ( | const bno055_context | dev, |
float * | x, | ||
float * | y, | ||
float * | z | ||
) |
Return accelerometer data (non-fusion). In fusion modes, this data will be of little value. By default the returned values are in meters per-second squared (m/s^2). update() must have been called prior to calling this method.
dev | The device context. |
x | Pointer to a floating point value that will have the current x component placed into it. |
y | Pointer to a floating point value that will have the current y component placed into it. |
z | Pointer to a floating point value that will have the current z component placed into it. |
void bno055_get_magnetometer | ( | const bno055_context | dev, |
float * | x, | ||
float * | y, | ||
float * | z | ||
) |
Return magnetometer data (non-fusion). In fusion modes, this data will be of little value. The returned values are in micro-teslas (uT). update() must have been called prior to calling this method.
dev | The device context. |
x | Pointer to a floating point value that will have the current x component placed into it. |
y | Pointer to a floating point value that will have the current y component placed into it. |
z | Pointer to a floating point value that will have the current z component placed into it. |
void bno055_get_gyroscope | ( | const bno055_context | dev, |
float * | x, | ||
float * | y, | ||
float * | z | ||
) |
Return gyroscope data (non-fusion). In fusion modes, this data will be of little value. By default the returned values are in meters per-second squared (m/s^2). update() must have been called prior to calling this method.
dev | The device context. |
x | Pointer to a floating point value that will have the current x component placed into it. |
y | Pointer to a floating point value that will have the current y component placed into it. |
z | Pointer to a floating point value that will have the current z component placed into it. |
upm_result_t bno055_set_acceleration_config | ( | const bno055_context | dev, |
BNO055_ACC_RANGE_T | range, | ||
BNO055_ACC_BW_T | bw, | ||
BNO055_ACC_PWR_MODE_T | pwr | ||
) |
Set the bandwidth, range, and power modes of the accelerometer. In fusion modes, these values will be ignored.
dev | The device context. |
range | One of the BNO055_ACC_RANGE_T values. |
bw | One of the BNO055_ACC_BW_T values. |
pwr | One of the BNO055_ACC_PWR_MODE_T values. |
upm_result_t bno055_set_magnetometer_config | ( | const bno055_context | dev, |
BNO055_MAG_ODR_T | odr, | ||
BNO055_MAG_OPR_T | opr, | ||
BNO055_MAG_POWER_T | pwr | ||
) |
Set the output data rate, operating mode and power mode of the magnetometer. In fusion modes, these values will be ignored.
dev | The device context. |
odr | One of the BNO055_MAG_ODR_T values. |
opr | One of the BNO055_MAG_OPR_T values. |
pwr | One of the BNO055_MAG_POWER_T values. |
upm_result_t bno055_set_gyroscope_config | ( | const bno055_context | dev, |
BNO055_GYR_RANGE_T | range, | ||
BNO055_GYR_BW_T | bw, | ||
BNO055_GYR_POWER_MODE_T | pwr | ||
) |
Set the range, bandwidth and power modes of the gyroscope. In fusion modes, these values will be ignored.
dev | The device context. |
range | One of the BNO055_GYR_RANGE_T values. |
bw | One of the BNO055_GYR_BW_T values. |
pwr | One of the BNO055_GYR_POWER_MODE_T values. |
upm_result_t bno055_set_accelerometer_units | ( | const bno055_context | dev, |
bool | mg | ||
) |
Set the unit of measurement for the accelerometer related sensor values. The choices are mg (milli-gravities) or meters per-second squared (m/s^2). The default is m/s^2.
dev | The device context. |
mg | true for mg, false for m/s^2. |
upm_result_t bno055_set_gyroscope_units | ( | const bno055_context | dev, |
bool | radians | ||
) |
Set the unit of measurement for the gyroscope related sensor values. The choices are degrees and radians. The default is degrees.
dev | The device context. |
radians | true for radians, false for degrees. |
upm_result_t bno055_set_euler_units | ( | const bno055_context | dev, |
bool | radians | ||
) |
Set the unit of measurement for the Euler Angle related sensor values. The choices are degrees and radians. The default is degrees.
dev | The device context. |
radians | true for radians, false for degrees. |
upm_result_t bno055_reset_interrupt_status | ( | const bno055_context | dev | ) |
Reset all interrupt status bits and interrupt output.
dev | The device context. |
upm_result_t bno055_get_interrupt_status | ( | const bno055_context | dev, |
uint8_t * | istat | ||
) |
Get the interrupt status register. This is a bitmask of the INT_STA_BITS_T bits.
dev | The device context. |
istat | A bitmask of INT_STA_BITS_T bits. |
upm_result_t bno055_get_interrupt_enable | ( | const bno055_context | dev, |
uint8_t * | ienable | ||
) |
Get the interrupt enables register. This is a bitmask of the INT_STA_BITS_T bits.
dev | The device context. |
ienable | A bitmask of INT_STA_BITS_T bits currently set in the enable register. |
upm_result_t bno055_set_interrupt_enable | ( | const bno055_context | dev, |
uint8_t | enables | ||
) |
Set the interrupt enable register. This is composed of a bitmask of the INT_STA_BITS_T bits.
dev | The device context. |
enables | a bitmask of INT_STA_BITS_T bits to enable |
upm_result_t bno055_get_interrupt_mask | ( | const bno055_context | dev, |
uint8_t * | imask | ||
) |
Get the interrupt mask register. This is a bitmask of the INT_STA_BITS_T bits. The interrupt mask is used to mask off enabled interrupts from generating a hardware interrupt. The interrupt status register can still be used to detect masked interrupts if they are enabled.
dev | The device context. |
imask | a bitmask of INT_STA_BITS_T bits currently set in the interrupt mask register. |
upm_result_t bno055_set_interrupt_mask | ( | const bno055_context | dev, |
uint8_t | mask | ||
) |
Set the interrupt mask register. This is a bitmask of the INT_STA_BITS_T bits. The interrupt mask is used to mask off enabled interrupts from generating a hardware interrupt. The interrupt status register can still be used to detect masked interrupts if they are enabled.
dev | The device context. |
mask | A bitmask of INT_STA_BITS_T bits to set in the interrupt mask register. |
upm_result_t bno055_get_system_status | ( | const bno055_context | dev, |
BNO055_SYS_STATUS_T * | sys_stat | ||
) |
Get the value of the system status register. This method can be used to determine the overall status of the device.
dev | The device context. |
sys_stat | One of the SYS_STATUS_T values. |
upm_result_t bno055_get_system_error | ( | const bno055_context | dev, |
BNO055_SYS_ERR_T * | sys_err | ||
) |
Return the value of the system error register. This mathod can be used to determine a variety of system related error conditions.
dev | The device context. |
sys_stat | One of the SYS_ERR_T values. |
upm_result_t bno055_install_isr | ( | const bno055_context | dev, |
int | gpio, | ||
mraa_gpio_edge_t | level, | ||
void(*)(void *) | isr, | ||
void * | arg | ||
) |
install an interrupt handler.
dev | The device context. |
gpio | The GPIO pin to use as interrupt pin. |
level | The interrupt trigger level (one of mraa_gpio_edge_t values). Make sure that you have configured the interrupt pin properly (on the device) for whatever level method you choose. |
isr | The interrupt handler, accepting a void * argument. |
arg | The argument to pass the the interrupt handler. |
void bno055_uninstall_isr | ( | const bno055_context | dev | ) |
uninstall a previously installed interrupt handler
dev | The device context. |
upm_result_t bno055_set_page | ( | const bno055_context | dev, |
uint8_t | page, | ||
bool | force | ||
) |
Set the current internal device register page. This is a low level function and should not be used unless you know what you are doing.
dev | The device context. |
page | The page number to set. This can only be 0 or 1. |
force | If true, force the device page state to match indicated internal page state regardless of current state. |
upm_result_t bno055_read_reg | ( | const bno055_context | dev, |
uint8_t | reg, | ||
uint8_t * | retval | ||
) |
Read a register. This is a low level function and should not be used unless you know what you are doing.
dev | The device context. |
reg | The register to read |
retval | The returned value of the register |
upm_result_t bno055_read_regs | ( | const bno055_context | dev, |
uint8_t | reg, | ||
uint8_t * | buffer, | ||
size_t | len | ||
) |
Read contiguous registers into a buffer. This is a low level function and should not be used unless you know what you are doing.
dev | The device context. |
buffer | The buffer to store the results |
len | The number of registers to read |
upm_result_t bno055_write_reg | ( | const bno055_context | dev, |
uint8_t | reg, | ||
uint8_t | val | ||
) |
Write to a register. This is a low level function and should not be used unless you know what you are doing.
dev | The device context. |
reg | The register to write to |
val | The value to write |
upm_result_t bno055_write_regs | ( | const bno055_context | dev, |
uint8_t | reg, | ||
uint8_t * | buffer, | ||
size_t | len | ||
) |
Write data to contiguous registers. This is a low level function and should not be used unless you know what you are doing.
dev | The device context. |
reg | The starting register to write to |
buffer | The buffer containing the data to write |
len | The number of bytes to write |
typedef struct _bno055_context * bno055_context |
Device context