Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BMI160 max32630hsp3 MemoryLCD USBDevice
Fork of Host_Software_MAX32664GWEC_SpO2_HR-_EXTE by
accelerometer/bmi160.h@0:b259fd1a88f5, 2019-03-18 (annotated)
- Committer:
- seyhmus.cacina
- Date:
- Mon Mar 18 14:09:48 2019 +0300
- Revision:
- 0:b259fd1a88f5
ME11C Sample Code First Commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| seyhmus.cacina | 0:b259fd1a88f5 | 1 | /********************************************************************** |
| seyhmus.cacina | 0:b259fd1a88f5 | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
| seyhmus.cacina | 0:b259fd1a88f5 | 3 | * |
| seyhmus.cacina | 0:b259fd1a88f5 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| seyhmus.cacina | 0:b259fd1a88f5 | 5 | * copy of this software and associated documentation files (the "Software"), |
| seyhmus.cacina | 0:b259fd1a88f5 | 6 | * to deal in the Software without restriction, including without limitation |
| seyhmus.cacina | 0:b259fd1a88f5 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| seyhmus.cacina | 0:b259fd1a88f5 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| seyhmus.cacina | 0:b259fd1a88f5 | 9 | * Software is furnished to do so, subject to the following conditions: |
| seyhmus.cacina | 0:b259fd1a88f5 | 10 | * |
| seyhmus.cacina | 0:b259fd1a88f5 | 11 | * The above copyright notice and this permission notice shall be included |
| seyhmus.cacina | 0:b259fd1a88f5 | 12 | * in all copies or substantial portions of the Software. |
| seyhmus.cacina | 0:b259fd1a88f5 | 13 | * |
| seyhmus.cacina | 0:b259fd1a88f5 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| seyhmus.cacina | 0:b259fd1a88f5 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| seyhmus.cacina | 0:b259fd1a88f5 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| seyhmus.cacina | 0:b259fd1a88f5 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
| seyhmus.cacina | 0:b259fd1a88f5 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| seyhmus.cacina | 0:b259fd1a88f5 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| seyhmus.cacina | 0:b259fd1a88f5 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| seyhmus.cacina | 0:b259fd1a88f5 | 21 | * |
| seyhmus.cacina | 0:b259fd1a88f5 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
| seyhmus.cacina | 0:b259fd1a88f5 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
| seyhmus.cacina | 0:b259fd1a88f5 | 24 | * Products, Inc. Branding Policy. |
| seyhmus.cacina | 0:b259fd1a88f5 | 25 | * |
| seyhmus.cacina | 0:b259fd1a88f5 | 26 | * The mere transfer of this software does not imply any licenses |
| seyhmus.cacina | 0:b259fd1a88f5 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
| seyhmus.cacina | 0:b259fd1a88f5 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
| seyhmus.cacina | 0:b259fd1a88f5 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
| seyhmus.cacina | 0:b259fd1a88f5 | 30 | * ownership rights. |
| seyhmus.cacina | 0:b259fd1a88f5 | 31 | **********************************************************************/ |
| seyhmus.cacina | 0:b259fd1a88f5 | 32 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 33 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 34 | #ifndef BMI160_H |
| seyhmus.cacina | 0:b259fd1a88f5 | 35 | #define BMI160_H |
| seyhmus.cacina | 0:b259fd1a88f5 | 36 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 37 | #include "mbed.h" |
| seyhmus.cacina | 0:b259fd1a88f5 | 38 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 39 | /** |
| seyhmus.cacina | 0:b259fd1a88f5 | 40 | @brief The BMI160 is a small, low power, low noise 16-bit inertial measurement |
| seyhmus.cacina | 0:b259fd1a88f5 | 41 | unit designed for use in mobile applications like augmented reality or indoor |
| seyhmus.cacina | 0:b259fd1a88f5 | 42 | navigation which require highly accurate, real-time sensor data. |
| seyhmus.cacina | 0:b259fd1a88f5 | 43 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 44 | In full operation mode, with both the accelerometer and gyroscope enabled, the |
| seyhmus.cacina | 0:b259fd1a88f5 | 45 | current consumption is typically 950 μA, enabling always-on applications in |
| seyhmus.cacina | 0:b259fd1a88f5 | 46 | battery driven devices. It is available in a compact 14-pin 2.5 x 3.0 x 0.8 mm³ |
| seyhmus.cacina | 0:b259fd1a88f5 | 47 | LGA package." |
| seyhmus.cacina | 0:b259fd1a88f5 | 48 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 49 | This class is an abstract base class and can not be instaniated, use BMI160_I2C |
| seyhmus.cacina | 0:b259fd1a88f5 | 50 | or BMI160_SPI. |
| seyhmus.cacina | 0:b259fd1a88f5 | 51 | */ |
| seyhmus.cacina | 0:b259fd1a88f5 | 52 | class BMI160 |
| seyhmus.cacina | 0:b259fd1a88f5 | 53 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 54 | public: |
| seyhmus.cacina | 0:b259fd1a88f5 | 55 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 56 | ///Return value on success. |
| seyhmus.cacina | 0:b259fd1a88f5 | 57 | static const uint8_t RTN_NO_ERROR = 0; |
| seyhmus.cacina | 0:b259fd1a88f5 | 58 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 59 | ///Sensor types |
| seyhmus.cacina | 0:b259fd1a88f5 | 60 | enum Sensors |
| seyhmus.cacina | 0:b259fd1a88f5 | 61 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 62 | MAG = 0, ///<Optional external sensor |
| seyhmus.cacina | 0:b259fd1a88f5 | 63 | GYRO, ///<Angular rate sensor |
| seyhmus.cacina | 0:b259fd1a88f5 | 64 | ACC ///<g sensor |
| seyhmus.cacina | 0:b259fd1a88f5 | 65 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 66 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 67 | ///Sensor Axis |
| seyhmus.cacina | 0:b259fd1a88f5 | 68 | enum SensorAxis |
| seyhmus.cacina | 0:b259fd1a88f5 | 69 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 70 | X_AXIS = 0, |
| seyhmus.cacina | 0:b259fd1a88f5 | 71 | Y_AXIS, |
| seyhmus.cacina | 0:b259fd1a88f5 | 72 | Z_AXIS |
| seyhmus.cacina | 0:b259fd1a88f5 | 73 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 74 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 75 | ///Structure for axis data |
| seyhmus.cacina | 0:b259fd1a88f5 | 76 | struct AxisData |
| seyhmus.cacina | 0:b259fd1a88f5 | 77 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 78 | int16_t raw; ///<Axis raw data |
| seyhmus.cacina | 0:b259fd1a88f5 | 79 | float scaled; ///<Axis scaled data |
| seyhmus.cacina | 0:b259fd1a88f5 | 80 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 81 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 82 | ///Structure for sensor time data |
| seyhmus.cacina | 0:b259fd1a88f5 | 83 | struct SensorTime |
| seyhmus.cacina | 0:b259fd1a88f5 | 84 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 85 | uint32_t raw; ///<raw SensorTime |
| seyhmus.cacina | 0:b259fd1a88f5 | 86 | float seconds; ///<SensorTime as seconds |
| seyhmus.cacina | 0:b259fd1a88f5 | 87 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 88 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 89 | ///Period of internal counter |
| seyhmus.cacina | 0:b259fd1a88f5 | 90 | static const float SENSOR_TIME_LSB = 39e-6; |
| seyhmus.cacina | 0:b259fd1a88f5 | 91 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 92 | ///Structure for holding sensor data |
| seyhmus.cacina | 0:b259fd1a88f5 | 93 | struct SensorData |
| seyhmus.cacina | 0:b259fd1a88f5 | 94 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 95 | AxisData xAxis; ///<Sensor X axis data |
| seyhmus.cacina | 0:b259fd1a88f5 | 96 | AxisData yAxis; ///<Sensor Y axis data |
| seyhmus.cacina | 0:b259fd1a88f5 | 97 | AxisData zAxis; ///<Sensor Z axis data |
| seyhmus.cacina | 0:b259fd1a88f5 | 98 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 99 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 100 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 101 | ///BMI160 registers |
| seyhmus.cacina | 0:b259fd1a88f5 | 102 | enum Registers |
| seyhmus.cacina | 0:b259fd1a88f5 | 103 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 104 | CHIP_ID = 0x00, ///<Chip Identification. |
| seyhmus.cacina | 0:b259fd1a88f5 | 105 | ERR_REG = 0x02, ///<Reports sensor error flags. Flags reset when read. |
| seyhmus.cacina | 0:b259fd1a88f5 | 106 | PMU_STATUS, ///<Reports current power mode for sensors. |
| seyhmus.cacina | 0:b259fd1a88f5 | 107 | DATA_0, ///<MAG_X axis bits7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 108 | DATA_1, ///<MAG_X axis bits15:8 |
| seyhmus.cacina | 0:b259fd1a88f5 | 109 | DATA_2, ///<MAG_Y axis bits7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 110 | DATA_3, ///<MAG_Y axis bits15:8 |
| seyhmus.cacina | 0:b259fd1a88f5 | 111 | DATA_4, ///<MAG_Z axis bits7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 112 | DATA_5, ///<MAG_Z axis bits15:8 |
| seyhmus.cacina | 0:b259fd1a88f5 | 113 | DATA_6, ///<RHALL bits7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 114 | DATA_7, ///<RHALL bits15:8 |
| seyhmus.cacina | 0:b259fd1a88f5 | 115 | DATA_8, ///<GYR_X axis bits7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 116 | DATA_9, ///<GYR_X axis bits15:8 |
| seyhmus.cacina | 0:b259fd1a88f5 | 117 | DATA_10, ///<GYR_Y axis bits7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 118 | DATA_11, ///<GYR_Y axis bits15:8 |
| seyhmus.cacina | 0:b259fd1a88f5 | 119 | DATA_12, ///<GYR_Z axis bits7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 120 | DATA_13, ///<GYR_Z axis bits15:8 |
| seyhmus.cacina | 0:b259fd1a88f5 | 121 | DATA_14, ///<ACC_X axis bits7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 122 | DATA_15, ///<ACC_X axis bits15:8 |
| seyhmus.cacina | 0:b259fd1a88f5 | 123 | DATA_16, ///<ACC_Y axis bits7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 124 | DATA_17, ///<ACC_Y axis bits15:8 |
| seyhmus.cacina | 0:b259fd1a88f5 | 125 | DATA_18, ///<ACC_Z axis bits7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 126 | DATA_19, ///<ACC_Z axis bits15:8 |
| seyhmus.cacina | 0:b259fd1a88f5 | 127 | SENSORTIME_0, ///<24bit counter synchronized with data, bits7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 128 | SENSORTIME_1, ///<24bit counter synchronized with data, bits15:8 |
| seyhmus.cacina | 0:b259fd1a88f5 | 129 | SENSORTIME_2, ///<24bit counter synchronized with data, bits23:16 |
| seyhmus.cacina | 0:b259fd1a88f5 | 130 | STATUS, ///<Reports sensors status flags |
| seyhmus.cacina | 0:b259fd1a88f5 | 131 | INT_STATUS_0, ///<Contains interrupt status flags |
| seyhmus.cacina | 0:b259fd1a88f5 | 132 | INT_STATUS_1, ///<Contains interrupt status flags |
| seyhmus.cacina | 0:b259fd1a88f5 | 133 | INT_STATUS_2, ///<Contains interrupt status flags |
| seyhmus.cacina | 0:b259fd1a88f5 | 134 | INT_STATUS_3, ///<Contains interrupt status flags |
| seyhmus.cacina | 0:b259fd1a88f5 | 135 | TEMPERATURE_0, ///<Contains temperature of sensor, bits7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 136 | TEMPERATURE_1, ///<Contains temperature of sensor, bits15:8 |
| seyhmus.cacina | 0:b259fd1a88f5 | 137 | FIFO_LENGTH_0, ///<Current fill level of FIFO, bits7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 138 | FIFO_LENGTH_1, ///<Current fill level of FIFO, bits10:8 |
| seyhmus.cacina | 0:b259fd1a88f5 | 139 | FIFO_DATA, ///<FIFO data read out register, burst read |
| seyhmus.cacina | 0:b259fd1a88f5 | 140 | ACC_CONF = 0x40, ///<Set ODR, bandwidth, and read mode of accelerometer |
| seyhmus.cacina | 0:b259fd1a88f5 | 141 | ACC_RANGE, ///<Sets accelerometer g-range |
| seyhmus.cacina | 0:b259fd1a88f5 | 142 | GYR_CONF, ///<Set ODR, bandwidth, and read mode of gyroscope |
| seyhmus.cacina | 0:b259fd1a88f5 | 143 | GYR_RANGE, ///<Sets gyroscope angular rate measurement range |
| seyhmus.cacina | 0:b259fd1a88f5 | 144 | MAG_CONF, ///<Sets ODR of magnetometer interface |
| seyhmus.cacina | 0:b259fd1a88f5 | 145 | FIFO_DOWNS, ///<Sets down sampling ratios of accel and gyro data |
| seyhmus.cacina | 0:b259fd1a88f5 | 146 | ///<for FIFO |
| seyhmus.cacina | 0:b259fd1a88f5 | 147 | FIFO_CONFIG_0, ///<Sets FIFO Watermark |
| seyhmus.cacina | 0:b259fd1a88f5 | 148 | FIFO_CONFIG_1, ///<Sets which sensor data is available in FIFO, |
| seyhmus.cacina | 0:b259fd1a88f5 | 149 | ///<Header/Headerless mode, Ext Int tagging, Sensortime |
| seyhmus.cacina | 0:b259fd1a88f5 | 150 | MAG_IF_0 = 0x4B, ///<Magnetometer 7-bit I2C address, bits7:1 |
| seyhmus.cacina | 0:b259fd1a88f5 | 151 | MAG_IF_1, ///<Magnetometer interface configuration |
| seyhmus.cacina | 0:b259fd1a88f5 | 152 | MAG_IF_2, ///<Magnetometer address to read |
| seyhmus.cacina | 0:b259fd1a88f5 | 153 | MAG_IF_3, ///<Magnetometer address to write |
| seyhmus.cacina | 0:b259fd1a88f5 | 154 | MAG_IF_4, ///<Magnetometer data to write |
| seyhmus.cacina | 0:b259fd1a88f5 | 155 | INT_EN_0, ///<Interrupt enable bits |
| seyhmus.cacina | 0:b259fd1a88f5 | 156 | INT_EN_1, ///<Interrupt enable bits |
| seyhmus.cacina | 0:b259fd1a88f5 | 157 | INT_EN_2, ///<Interrupt enable bits |
| seyhmus.cacina | 0:b259fd1a88f5 | 158 | INT_OUT_CTRL, ///<Contains the behavioral configuration of INT pins |
| seyhmus.cacina | 0:b259fd1a88f5 | 159 | INT_LATCH, ///<Contains the interrupt rest bit and the interrupt |
| seyhmus.cacina | 0:b259fd1a88f5 | 160 | ///<mode selection |
| seyhmus.cacina | 0:b259fd1a88f5 | 161 | INT_MAP_0, ///<Controls which interrupt signals are mapped to the |
| seyhmus.cacina | 0:b259fd1a88f5 | 162 | ///<INT1 and INT2 pins |
| seyhmus.cacina | 0:b259fd1a88f5 | 163 | INT_MAP_1, ///<Controls which interrupt signals are mapped to the |
| seyhmus.cacina | 0:b259fd1a88f5 | 164 | ///<INT1 and INT2 pins |
| seyhmus.cacina | 0:b259fd1a88f5 | 165 | INT_MAP_2, ///<Controls which interrupt signals are mapped to the |
| seyhmus.cacina | 0:b259fd1a88f5 | 166 | ///<INT1 and INT2 pins |
| seyhmus.cacina | 0:b259fd1a88f5 | 167 | INT_DATA_0, ///<Contains the data source definition for the two |
| seyhmus.cacina | 0:b259fd1a88f5 | 168 | ///<interrupt groups |
| seyhmus.cacina | 0:b259fd1a88f5 | 169 | INT_DATA_1, ///<Contains the data source definition for the two |
| seyhmus.cacina | 0:b259fd1a88f5 | 170 | ///<interrupt groups |
| seyhmus.cacina | 0:b259fd1a88f5 | 171 | INT_LOWHIGH_0, ///<Contains the configuration for the low g interrupt |
| seyhmus.cacina | 0:b259fd1a88f5 | 172 | INT_LOWHIGH_1, ///<Contains the configuration for the low g interrupt |
| seyhmus.cacina | 0:b259fd1a88f5 | 173 | INT_LOWHIGH_2, ///<Contains the configuration for the low g interrupt |
| seyhmus.cacina | 0:b259fd1a88f5 | 174 | INT_LOWHIGH_3, ///<Contains the configuration for the low g interrupt |
| seyhmus.cacina | 0:b259fd1a88f5 | 175 | INT_LOWHIGH_4, ///<Contains the configuration for the low g interrupt |
| seyhmus.cacina | 0:b259fd1a88f5 | 176 | INT_MOTION_0, ///<Contains the configuration for the any motion and |
| seyhmus.cacina | 0:b259fd1a88f5 | 177 | ///<no motion interrupts |
| seyhmus.cacina | 0:b259fd1a88f5 | 178 | INT_MOTION_1, ///<Contains the configuration for the any motion and |
| seyhmus.cacina | 0:b259fd1a88f5 | 179 | ///<no motion interrupts |
| seyhmus.cacina | 0:b259fd1a88f5 | 180 | INT_MOTION_2, ///<Contains the configuration for the any motion and |
| seyhmus.cacina | 0:b259fd1a88f5 | 181 | ///<no motion interrupts |
| seyhmus.cacina | 0:b259fd1a88f5 | 182 | INT_MOTION_3, ///<Contains the configuration for the any motion and |
| seyhmus.cacina | 0:b259fd1a88f5 | 183 | ///<no motion interrupts |
| seyhmus.cacina | 0:b259fd1a88f5 | 184 | INT_TAP_0, ///<Contains the configuration for the tap interrupts |
| seyhmus.cacina | 0:b259fd1a88f5 | 185 | INT_TAP_1, ///<Contains the configuration for the tap interrupts |
| seyhmus.cacina | 0:b259fd1a88f5 | 186 | INT_ORIENT_0, ///<Contains the configuration for the oeientation |
| seyhmus.cacina | 0:b259fd1a88f5 | 187 | ///<interrupt |
| seyhmus.cacina | 0:b259fd1a88f5 | 188 | INT_ORIENT_1, ///<Contains the configuration for the oeientation |
| seyhmus.cacina | 0:b259fd1a88f5 | 189 | ///<interrupt |
| seyhmus.cacina | 0:b259fd1a88f5 | 190 | INT_FLAT_0, ///<Contains the configuration for the flat interrupt |
| seyhmus.cacina | 0:b259fd1a88f5 | 191 | INT_FLAT_1, ///<Contains the configuration for the flat interrupt |
| seyhmus.cacina | 0:b259fd1a88f5 | 192 | FOC_CONF, ///<Contains configuration for the fast offset |
| seyhmus.cacina | 0:b259fd1a88f5 | 193 | ///<compensation for the accelerometer and gyroscope |
| seyhmus.cacina | 0:b259fd1a88f5 | 194 | CONF, ///<Configuration of sensor, nvm_prog_en bit |
| seyhmus.cacina | 0:b259fd1a88f5 | 195 | IF_CONF, ///<Contains settings for the digital interface |
| seyhmus.cacina | 0:b259fd1a88f5 | 196 | PMU_TRIGGER, ///<Sets trigger conditions to change gyro power modes |
| seyhmus.cacina | 0:b259fd1a88f5 | 197 | SELF_TEST, ///<Self test configuration |
| seyhmus.cacina | 0:b259fd1a88f5 | 198 | NV_CONF = 0x70, ///<Contains settings for the digital interface |
| seyhmus.cacina | 0:b259fd1a88f5 | 199 | OFFSET_0, ///<Contains offset comp values for acc_off_x7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 200 | OFFSET_1, ///<Contains offset comp values for acc_off_y7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 201 | OFFSET_2, ///<Contains offset comp values for acc_off_z7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 202 | OFFSET_3, ///<Contains offset comp values for gyr_off_x7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 203 | OFFSET_4, ///<Contains offset comp values for gyr_off_y7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 204 | OFFSET_5, ///<Contains offset comp values for gyr_off_z7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 205 | OFFSET_6, ///<gyr/acc offset enable bit and gyr_off_(zyx) bits9:8 |
| seyhmus.cacina | 0:b259fd1a88f5 | 206 | STEP_CNT_0, ///<Step counter bits 15:8 |
| seyhmus.cacina | 0:b259fd1a88f5 | 207 | STEP_CNT_1, ///<Step counter bits 7:0 |
| seyhmus.cacina | 0:b259fd1a88f5 | 208 | STEP_CONF_0, ///<Contains configuration of the step detector |
| seyhmus.cacina | 0:b259fd1a88f5 | 209 | STEP_CONF_1, ///<Contains configuration of the step detector |
| seyhmus.cacina | 0:b259fd1a88f5 | 210 | CMD = 0x7E ///<Command register triggers operations like |
| seyhmus.cacina | 0:b259fd1a88f5 | 211 | ///<softreset, NVM programming, etc. |
| seyhmus.cacina | 0:b259fd1a88f5 | 212 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 213 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 214 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 215 | ///@name ERR_REG(0x02) |
| seyhmus.cacina | 0:b259fd1a88f5 | 216 | ///Error register data |
| seyhmus.cacina | 0:b259fd1a88f5 | 217 | ///@{ |
| seyhmus.cacina | 0:b259fd1a88f5 | 218 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 219 | static const uint8_t FATAL_ERR_MASK = 0x01; |
| seyhmus.cacina | 0:b259fd1a88f5 | 220 | static const uint8_t FATAL_ERR_POS = 0x00; |
| seyhmus.cacina | 0:b259fd1a88f5 | 221 | static const uint8_t ERR_CODE_MASK = 0x1E; |
| seyhmus.cacina | 0:b259fd1a88f5 | 222 | static const uint8_t ERR_CODE_POS = 0x01; |
| seyhmus.cacina | 0:b259fd1a88f5 | 223 | static const uint8_t I2C_FAIL_ERR_MASK = 0x20; |
| seyhmus.cacina | 0:b259fd1a88f5 | 224 | static const uint8_t I2C_FAIL_ERR_POS = 0x05; |
| seyhmus.cacina | 0:b259fd1a88f5 | 225 | static const uint8_t DROP_CMD_ERR_MASK = 0x40; |
| seyhmus.cacina | 0:b259fd1a88f5 | 226 | static const uint8_t DROP_CMD_ERR_POS = 0x06; |
| seyhmus.cacina | 0:b259fd1a88f5 | 227 | static const uint8_t MAG_DRDY_ERR_MASK = 0x80; |
| seyhmus.cacina | 0:b259fd1a88f5 | 228 | static const uint8_t MAG_DRDY_ERR_POS = 0x08; |
| seyhmus.cacina | 0:b259fd1a88f5 | 229 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 230 | ///Enumerated error codes |
| seyhmus.cacina | 0:b259fd1a88f5 | 231 | enum ErrorCodes |
| seyhmus.cacina | 0:b259fd1a88f5 | 232 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 233 | NO_ERROR = 0, ///<No Error |
| seyhmus.cacina | 0:b259fd1a88f5 | 234 | ERROR_1, ///<Listed as error |
| seyhmus.cacina | 0:b259fd1a88f5 | 235 | ERROR_2, ///<Listed as error |
| seyhmus.cacina | 0:b259fd1a88f5 | 236 | LPM_INT_PFD, ///<Low-power mode and interrupt uses pre-filtered |
| seyhmus.cacina | 0:b259fd1a88f5 | 237 | ///<data |
| seyhmus.cacina | 0:b259fd1a88f5 | 238 | ODR_MISMATCH = 0x06, ///<ODRs of enabled sensors in headerless mode do |
| seyhmus.cacina | 0:b259fd1a88f5 | 239 | ///<not match |
| seyhmus.cacina | 0:b259fd1a88f5 | 240 | PFD_USED_LPM ///<Pre-filtered data are used in low power mode |
| seyhmus.cacina | 0:b259fd1a88f5 | 241 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 242 | ///@} |
| seyhmus.cacina | 0:b259fd1a88f5 | 243 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 244 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 245 | ///@name ACC_CONF(0x40) and ACC_RANGE(0x41) |
| seyhmus.cacina | 0:b259fd1a88f5 | 246 | ///Data for configuring accelerometer |
| seyhmus.cacina | 0:b259fd1a88f5 | 247 | ///@{ |
| seyhmus.cacina | 0:b259fd1a88f5 | 248 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 249 | static const uint8_t ACC_ODR_MASK = 0x0F; |
| seyhmus.cacina | 0:b259fd1a88f5 | 250 | static const uint8_t ACC_ODR_POS = 0x00; |
| seyhmus.cacina | 0:b259fd1a88f5 | 251 | static const uint8_t ACC_BWP_MASK = 0x70; |
| seyhmus.cacina | 0:b259fd1a88f5 | 252 | static const uint8_t ACC_BWP_POS = 0x04; |
| seyhmus.cacina | 0:b259fd1a88f5 | 253 | static const uint8_t ACC_US_MASK = 0x80; |
| seyhmus.cacina | 0:b259fd1a88f5 | 254 | static const uint8_t ACC_US_POS = 0x07; |
| seyhmus.cacina | 0:b259fd1a88f5 | 255 | static const uint8_t ACC_RANGE_MASK = 0x0F; |
| seyhmus.cacina | 0:b259fd1a88f5 | 256 | static const uint8_t ACC_RANGE_POS = 0x00; |
| seyhmus.cacina | 0:b259fd1a88f5 | 257 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 258 | ///Accelerometer output data rates |
| seyhmus.cacina | 0:b259fd1a88f5 | 259 | enum AccOutputDataRate |
| seyhmus.cacina | 0:b259fd1a88f5 | 260 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 261 | ACC_ODR_1 = 1, ///< 25/32Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 262 | ACC_ODR_2, ///< 25/16Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 263 | ACC_ODR_3, ///< 25/8Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 264 | ACC_ODR_4, ///< 25/4Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 265 | ACC_ODR_5, ///< 25/2Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 266 | ACC_ODR_6, ///< 25Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 267 | ACC_ODR_7, ///< 50Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 268 | ACC_ODR_8, ///< 100Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 269 | ACC_ODR_9, ///< 200Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 270 | ACC_ODR_10, ///< 400Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 271 | ACC_ODR_11, ///< 800Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 272 | ACC_ODR_12 ///< 1600Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 273 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 274 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 275 | ///Accelerometer bandwidth parameters |
| seyhmus.cacina | 0:b259fd1a88f5 | 276 | enum AccBandWidthParam |
| seyhmus.cacina | 0:b259fd1a88f5 | 277 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 278 | ACC_BWP_0 = 0, ///< Average 1 cycle; when acc_us = 0 OSR4 |
| seyhmus.cacina | 0:b259fd1a88f5 | 279 | ACC_BWP_1, ///< Average 2 cycles; when acc_us = 0 OSR2 |
| seyhmus.cacina | 0:b259fd1a88f5 | 280 | ACC_BWP_2, ///< Average 4 cycles; when acc_us = 0 normal mode |
| seyhmus.cacina | 0:b259fd1a88f5 | 281 | ACC_BWP_3, ///< Average 8 cycles |
| seyhmus.cacina | 0:b259fd1a88f5 | 282 | ACC_BWP_4, ///< Average 16 cycles |
| seyhmus.cacina | 0:b259fd1a88f5 | 283 | ACC_BWP_5, ///< Average 32 cycles |
| seyhmus.cacina | 0:b259fd1a88f5 | 284 | ACC_BWP_6, ///< Average 64 cycles |
| seyhmus.cacina | 0:b259fd1a88f5 | 285 | ACC_BWP_7 ///< Average 128 cycles |
| seyhmus.cacina | 0:b259fd1a88f5 | 286 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 287 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 288 | ///Accelerometer undersampling |
| seyhmus.cacina | 0:b259fd1a88f5 | 289 | enum AccUnderSampling |
| seyhmus.cacina | 0:b259fd1a88f5 | 290 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 291 | ACC_US_OFF = 0, |
| seyhmus.cacina | 0:b259fd1a88f5 | 292 | ACC_US_ON |
| seyhmus.cacina | 0:b259fd1a88f5 | 293 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 294 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 295 | ///Accelerometer ranges |
| seyhmus.cacina | 0:b259fd1a88f5 | 296 | enum AccRange |
| seyhmus.cacina | 0:b259fd1a88f5 | 297 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 298 | SENS_2G = 0x03, ///<Accelerometer range +-2G |
| seyhmus.cacina | 0:b259fd1a88f5 | 299 | SENS_4G = 0x05, ///<Accelerometer range +-4G |
| seyhmus.cacina | 0:b259fd1a88f5 | 300 | SENS_8G = 0x08, ///<Accelerometer range +-8G |
| seyhmus.cacina | 0:b259fd1a88f5 | 301 | SENS_16G = 0x0C ///<Accelerometer range +-16G |
| seyhmus.cacina | 0:b259fd1a88f5 | 302 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 303 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 304 | static const float SENS_2G_LSB_PER_G = 16384.0F; |
| seyhmus.cacina | 0:b259fd1a88f5 | 305 | static const float SENS_4G_LSB_PER_G = 8192.0F; |
| seyhmus.cacina | 0:b259fd1a88f5 | 306 | static const float SENS_8G_LSB_PER_G = 4096.0F; |
| seyhmus.cacina | 0:b259fd1a88f5 | 307 | static const float SENS_16G_LSB_PER_G = 2048.0F; |
| seyhmus.cacina | 0:b259fd1a88f5 | 308 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 309 | ///Accelerometer configuration data structure |
| seyhmus.cacina | 0:b259fd1a88f5 | 310 | struct AccConfig |
| seyhmus.cacina | 0:b259fd1a88f5 | 311 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 312 | AccRange range; ///<Accelerometer range |
| seyhmus.cacina | 0:b259fd1a88f5 | 313 | AccUnderSampling us; ///<Accelerometr undersampling mode |
| seyhmus.cacina | 0:b259fd1a88f5 | 314 | AccBandWidthParam bwp; ///<Accelerometer bandwidth param |
| seyhmus.cacina | 0:b259fd1a88f5 | 315 | AccOutputDataRate odr; ///<Accelerometr output data rate |
| seyhmus.cacina | 0:b259fd1a88f5 | 316 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 317 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 318 | ///Accelerometer default configuration |
| seyhmus.cacina | 0:b259fd1a88f5 | 319 | static const AccConfig DEFAULT_ACC_CONFIG; |
| seyhmus.cacina | 0:b259fd1a88f5 | 320 | ///@} |
| seyhmus.cacina | 0:b259fd1a88f5 | 321 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 322 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 323 | ///@name GYR_CONF(0x42) and GYR_RANGE(0x43) |
| seyhmus.cacina | 0:b259fd1a88f5 | 324 | ///Data for configuring gyroscope |
| seyhmus.cacina | 0:b259fd1a88f5 | 325 | ///@{ |
| seyhmus.cacina | 0:b259fd1a88f5 | 326 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 327 | static const uint8_t GYRO_ODR_MASK = 0x0F; |
| seyhmus.cacina | 0:b259fd1a88f5 | 328 | static const uint8_t GYRO_ODR_POS = 0x00; |
| seyhmus.cacina | 0:b259fd1a88f5 | 329 | static const uint8_t GYRO_BWP_MASK = 0x30; |
| seyhmus.cacina | 0:b259fd1a88f5 | 330 | static const uint8_t GYRO_BWP_POS = 0x04; |
| seyhmus.cacina | 0:b259fd1a88f5 | 331 | static const uint8_t GYRO_RANGE_MASK = 0x07; |
| seyhmus.cacina | 0:b259fd1a88f5 | 332 | static const uint8_t GYRO_RANGE_POS = 0x00; |
| seyhmus.cacina | 0:b259fd1a88f5 | 333 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 334 | ///Gyroscope output data rates |
| seyhmus.cacina | 0:b259fd1a88f5 | 335 | enum GyroOutputDataRate |
| seyhmus.cacina | 0:b259fd1a88f5 | 336 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 337 | GYRO_ODR_6 = 0x06, ///<25Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 338 | GYRO_ODR_7 = 0x07, ///<50Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 339 | GYRO_ODR_8 = 0x08, ///<100Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 340 | GYRO_ODR_9 = 0x09, ///<200Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 341 | GYRO_ODR_10 = 0x0A, ///<400Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 342 | GYRO_ODR_11 = 0x0B, ///<800Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 343 | GYRO_ODR_12 = 0x0C, ///<1600Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 344 | GYRO_ODR_13 = 0x0D ///<3200Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 345 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 346 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 347 | ///Gyroscope bandwidth paramaters |
| seyhmus.cacina | 0:b259fd1a88f5 | 348 | enum GyroBandWidthParam |
| seyhmus.cacina | 0:b259fd1a88f5 | 349 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 350 | GYRO_BWP_0 = 0, ///<OSR4 Over Sampling Rate of 4 |
| seyhmus.cacina | 0:b259fd1a88f5 | 351 | GYRO_BWP_1, ///<OSR2 Over Sampling Rate of 2 |
| seyhmus.cacina | 0:b259fd1a88f5 | 352 | GYRO_BWP_2 ///<Normal Mode, Equidistant Sampling |
| seyhmus.cacina | 0:b259fd1a88f5 | 353 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 354 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 355 | ///Gyroscope ranges |
| seyhmus.cacina | 0:b259fd1a88f5 | 356 | enum GyroRange |
| seyhmus.cacina | 0:b259fd1a88f5 | 357 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 358 | DPS_2000 = 0, ///<+-2000dps, 16.4LSB/dps |
| seyhmus.cacina | 0:b259fd1a88f5 | 359 | DPS_1000, ///<+-1000dps, 32.8LSB/dps |
| seyhmus.cacina | 0:b259fd1a88f5 | 360 | DPS_500, ///<+-500dps, 65.6LSB/dps |
| seyhmus.cacina | 0:b259fd1a88f5 | 361 | DPS_250, ///<+-250dps, 131.2LSB/dps |
| seyhmus.cacina | 0:b259fd1a88f5 | 362 | DPS_125 ///<+-125dps, 262.4LSB/dps, |
| seyhmus.cacina | 0:b259fd1a88f5 | 363 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 364 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 365 | static const float SENS_2000_DPS_LSB_PER_DPS = 16.4F; |
| seyhmus.cacina | 0:b259fd1a88f5 | 366 | static const float SENS_1000_DPS_LSB_PER_DPS = 32.8F; |
| seyhmus.cacina | 0:b259fd1a88f5 | 367 | static const float SENS_500_DPS_LSB_PER_DPS = 65.6F; |
| seyhmus.cacina | 0:b259fd1a88f5 | 368 | static const float SENS_250_DPS_LSB_PER_DPS = 131.2F; |
| seyhmus.cacina | 0:b259fd1a88f5 | 369 | static const float SENS_125_DPS_LSB_PER_DPS = 262.4F; |
| seyhmus.cacina | 0:b259fd1a88f5 | 370 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 371 | ///Gyroscope configuration data structure |
| seyhmus.cacina | 0:b259fd1a88f5 | 372 | struct GyroConfig |
| seyhmus.cacina | 0:b259fd1a88f5 | 373 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 374 | GyroRange range; ///<Gyroscope range |
| seyhmus.cacina | 0:b259fd1a88f5 | 375 | GyroBandWidthParam bwp; ///<Gyroscope bandwidth param |
| seyhmus.cacina | 0:b259fd1a88f5 | 376 | GyroOutputDataRate odr; ///<Gyroscope output data rate |
| seyhmus.cacina | 0:b259fd1a88f5 | 377 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 378 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 379 | ///Gyroscope default configuration |
| seyhmus.cacina | 0:b259fd1a88f5 | 380 | static const GyroConfig DEFAULT_GYRO_CONFIG; |
| seyhmus.cacina | 0:b259fd1a88f5 | 381 | ///@} |
| seyhmus.cacina | 0:b259fd1a88f5 | 382 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 383 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 384 | ///Enumerated power modes |
| seyhmus.cacina | 0:b259fd1a88f5 | 385 | enum PowerModes |
| seyhmus.cacina | 0:b259fd1a88f5 | 386 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 387 | SUSPEND = 0, ///<Acc and Gyro, No sampling, No FIFO data readout |
| seyhmus.cacina | 0:b259fd1a88f5 | 388 | NORMAL, ///<Acc and Gyro, Full chip operation |
| seyhmus.cacina | 0:b259fd1a88f5 | 389 | LOW_POWER, ///<Acc duty-cycling between suspend and normal |
| seyhmus.cacina | 0:b259fd1a88f5 | 390 | FAST_START_UP ///<Gyro start up delay time to normal mode <= 10 ms |
| seyhmus.cacina | 0:b259fd1a88f5 | 391 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 392 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 393 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 394 | ///Enumerated commands used with CMD register |
| seyhmus.cacina | 0:b259fd1a88f5 | 395 | enum Commands |
| seyhmus.cacina | 0:b259fd1a88f5 | 396 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 397 | START_FOC = 0x03, ///<Starts Fast Offset Calibrartion |
| seyhmus.cacina | 0:b259fd1a88f5 | 398 | ACC_SET_PMU_MODE = 0x10, ///<Sets acc power mode |
| seyhmus.cacina | 0:b259fd1a88f5 | 399 | GYR_SET_PMU_MODE = 0x14, ///<Sets gyro power mode |
| seyhmus.cacina | 0:b259fd1a88f5 | 400 | MAG_SET_PMU_MODE = 0x18, ///<Sets mag power mode |
| seyhmus.cacina | 0:b259fd1a88f5 | 401 | PROG_NVM = 0xA0, ///<Writes NVM backed registers into NVM |
| seyhmus.cacina | 0:b259fd1a88f5 | 402 | FIFO_FLUSH = 0xB0, ///<Clears FIFO |
| seyhmus.cacina | 0:b259fd1a88f5 | 403 | INT_RESET, ///<Clears interrupt engine, INT_STATUS, and |
| seyhmus.cacina | 0:b259fd1a88f5 | 404 | ///<the interrupt pin |
| seyhmus.cacina | 0:b259fd1a88f5 | 405 | STEP_CNT_CLR, ///<Triggers reset of the step counter |
| seyhmus.cacina | 0:b259fd1a88f5 | 406 | SOFT_RESET = 0xB6 ///<Triggers a reset including a reboot. |
| seyhmus.cacina | 0:b259fd1a88f5 | 407 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 408 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 409 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 410 | ///@brief BMI160 Destructor.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 411 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 412 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 413 | ///@param[in] none |
| seyhmus.cacina | 0:b259fd1a88f5 | 414 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 415 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 416 | ///@param[out] none |
| seyhmus.cacina | 0:b259fd1a88f5 | 417 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 418 | ///@returns none |
| seyhmus.cacina | 0:b259fd1a88f5 | 419 | virtual ~BMI160(){ } |
| seyhmus.cacina | 0:b259fd1a88f5 | 420 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 421 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 422 | ///@brief Reads a single register.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 423 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 424 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 425 | ///@param[in] data - pointer to memory for storing read data |
| seyhmus.cacina | 0:b259fd1a88f5 | 426 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 427 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 428 | ///@param[out] data - holds contents of read register on success |
| seyhmus.cacina | 0:b259fd1a88f5 | 429 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 430 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 431 | virtual int32_t readRegister(Registers reg, uint8_t *data) = 0; |
| seyhmus.cacina | 0:b259fd1a88f5 | 432 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 433 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 434 | ///@brief Writes a single register.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 435 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 436 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 437 | ///@param[in] data - data to write to register |
| seyhmus.cacina | 0:b259fd1a88f5 | 438 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 439 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 440 | ///@param[out] none |
| seyhmus.cacina | 0:b259fd1a88f5 | 441 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 442 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 443 | virtual int32_t writeRegister(Registers reg, const uint8_t data) = 0; |
| seyhmus.cacina | 0:b259fd1a88f5 | 444 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 445 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 446 | ///@brief Reads a block of registers.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 447 | ///@detail User must ensure that all registers between 'startReg' and |
| seyhmus.cacina | 0:b259fd1a88f5 | 448 | ///'stopReg' exist and are readable. Function reads up to, including, |
| seyhmus.cacina | 0:b259fd1a88f5 | 449 | ///'stopReg'.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 450 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 451 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 452 | ///@param[in] startReg - register to start reading from |
| seyhmus.cacina | 0:b259fd1a88f5 | 453 | ///@param[in] stopReg - register to stop reading from |
| seyhmus.cacina | 0:b259fd1a88f5 | 454 | ///@param[in] data - pointer to memory for storing read data |
| seyhmus.cacina | 0:b259fd1a88f5 | 455 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 456 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 457 | ///@param[out] data - holds contents of read registers on success |
| seyhmus.cacina | 0:b259fd1a88f5 | 458 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 459 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 460 | virtual int32_t readBlock(Registers startReg, Registers stopReg, |
| seyhmus.cacina | 0:b259fd1a88f5 | 461 | uint8_t *data) = 0; |
| seyhmus.cacina | 0:b259fd1a88f5 | 462 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 463 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 464 | ///@brief Writes a block of registers.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 465 | ///@detail User must ensure that all registers between 'startReg' and |
| seyhmus.cacina | 0:b259fd1a88f5 | 466 | ///'stopReg' exist and are writeable. Function writes up to, including, |
| seyhmus.cacina | 0:b259fd1a88f5 | 467 | ///'stopReg'.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 468 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 469 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 470 | ///@param[in] startReg - register to start writing at |
| seyhmus.cacina | 0:b259fd1a88f5 | 471 | ///@param[in] stopReg - register to stop writing at |
| seyhmus.cacina | 0:b259fd1a88f5 | 472 | ///@param[in] data - pointer to data to write to registers |
| seyhmus.cacina | 0:b259fd1a88f5 | 473 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 474 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 475 | ///@param[out] none |
| seyhmus.cacina | 0:b259fd1a88f5 | 476 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 477 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 478 | virtual int32_t writeBlock(Registers startReg, Registers stopReg, |
| seyhmus.cacina | 0:b259fd1a88f5 | 479 | const uint8_t *data) = 0; |
| seyhmus.cacina | 0:b259fd1a88f5 | 480 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 481 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 482 | ///@brief Sets sensors power mode through CMD register.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 483 | ///@details Observe command execution times given in datasheet.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 484 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 485 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 486 | ///@param[in] sensor - Sensor which power mode we are setting |
| seyhmus.cacina | 0:b259fd1a88f5 | 487 | ///@param[in] pwrMode - Desired powermode of the sensor |
| seyhmus.cacina | 0:b259fd1a88f5 | 488 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 489 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 490 | ///@param[out] |
| seyhmus.cacina | 0:b259fd1a88f5 | 491 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 492 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 493 | int32_t setSensorPowerMode(Sensors sensor, PowerModes pwrMode); |
| seyhmus.cacina | 0:b259fd1a88f5 | 494 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 495 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 496 | ///@brief Configure sensor.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 497 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 498 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 499 | ///@param[in] config - sSensor configuration data structure |
| seyhmus.cacina | 0:b259fd1a88f5 | 500 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 501 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 502 | ///@param[out] none |
| seyhmus.cacina | 0:b259fd1a88f5 | 503 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 504 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 505 | int32_t setSensorConfig(const AccConfig &config); |
| seyhmus.cacina | 0:b259fd1a88f5 | 506 | int32_t setSensorConfig(const GyroConfig &config); |
| seyhmus.cacina | 0:b259fd1a88f5 | 507 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 508 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 509 | ///@brief Get sensor configuration.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 510 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 511 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 512 | ///@param[in] config - Sensor configuration data structure |
| seyhmus.cacina | 0:b259fd1a88f5 | 513 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 514 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 515 | ///@param[out] config - on success, holds sensor's current |
| seyhmus.cacina | 0:b259fd1a88f5 | 516 | ///configuration |
| seyhmus.cacina | 0:b259fd1a88f5 | 517 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 518 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 519 | int32_t getSensorConfig(AccConfig &config); |
| seyhmus.cacina | 0:b259fd1a88f5 | 520 | int32_t getSensorConfig(GyroConfig &config); |
| seyhmus.cacina | 0:b259fd1a88f5 | 521 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 522 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 523 | ///@brief Get sensor axis.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 524 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 525 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 526 | ///@param[in] axis - Sensor axis |
| seyhmus.cacina | 0:b259fd1a88f5 | 527 | ///@param[in] data - AxisData structure |
| seyhmus.cacina | 0:b259fd1a88f5 | 528 | ///@param[in] range - Sensor range |
| seyhmus.cacina | 0:b259fd1a88f5 | 529 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 530 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 531 | ///@param[out] data - Structure holds raw and scaled axis data |
| seyhmus.cacina | 0:b259fd1a88f5 | 532 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 533 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 534 | int32_t getSensorAxis(SensorAxis axis, AxisData &data, AccRange range); |
| seyhmus.cacina | 0:b259fd1a88f5 | 535 | int32_t getSensorAxis(SensorAxis axis, AxisData &data, GyroRange range); |
| seyhmus.cacina | 0:b259fd1a88f5 | 536 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 537 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 538 | ///@brief Get sensor xyz axis.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 539 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 540 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 541 | ///@param[in] data - SensorData structure |
| seyhmus.cacina | 0:b259fd1a88f5 | 542 | ///@param[in] range - Sensor range |
| seyhmus.cacina | 0:b259fd1a88f5 | 543 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 544 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 545 | ///@param[out] data - Structure holds raw and scaled data for all three axis |
| seyhmus.cacina | 0:b259fd1a88f5 | 546 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 547 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 548 | int32_t getSensorXYZ(SensorData &data, AccRange range); |
| seyhmus.cacina | 0:b259fd1a88f5 | 549 | int32_t getSensorXYZ(SensorData &data, GyroRange range); |
| seyhmus.cacina | 0:b259fd1a88f5 | 550 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 551 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 552 | ///@brief Get sensor xyz axis and sensor time.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 553 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 554 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 555 | ///@param[in] data - SensorData structure |
| seyhmus.cacina | 0:b259fd1a88f5 | 556 | ///@param[in] sensorTime - SensorTime structure for data |
| seyhmus.cacina | 0:b259fd1a88f5 | 557 | ///@param[in] range - Sensor range |
| seyhmus.cacina | 0:b259fd1a88f5 | 558 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 559 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 560 | ///@param[out] data - Structure holds raw and scaled data for all three axis |
| seyhmus.cacina | 0:b259fd1a88f5 | 561 | ///@param[out] sensorTime - Holds sensor time on success |
| seyhmus.cacina | 0:b259fd1a88f5 | 562 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 563 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 564 | int32_t getSensorXYZandSensorTime(SensorData &data, SensorTime &sensorTime, |
| seyhmus.cacina | 0:b259fd1a88f5 | 565 | AccRange range); |
| seyhmus.cacina | 0:b259fd1a88f5 | 566 | int32_t getSensorXYZandSensorTime(SensorData &data, SensorTime &sensorTime, |
| seyhmus.cacina | 0:b259fd1a88f5 | 567 | GyroRange range); |
| seyhmus.cacina | 0:b259fd1a88f5 | 568 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 569 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 570 | ///@brief Get Gyroscope/Accelerometer data and sensor time.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 571 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 572 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 573 | ///@param[in] accData - Sensor data structure for accelerometer |
| seyhmus.cacina | 0:b259fd1a88f5 | 574 | ///@param[in] gyroData - Sensor data structure for gyroscope |
| seyhmus.cacina | 0:b259fd1a88f5 | 575 | ///@param[in] sensorTime - SensorTime data structure |
| seyhmus.cacina | 0:b259fd1a88f5 | 576 | ///@param[in] accRange - Accelerometer range |
| seyhmus.cacina | 0:b259fd1a88f5 | 577 | ///@param[in] gyroRange - Gyroscope range |
| seyhmus.cacina | 0:b259fd1a88f5 | 578 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 579 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 580 | ///@param[out] accData - Synchronized accelerometer data |
| seyhmus.cacina | 0:b259fd1a88f5 | 581 | ///@param[out] gyroData - Synchronized gyroscope data |
| seyhmus.cacina | 0:b259fd1a88f5 | 582 | ///@param[out] sensorTime - Synchronized sensor time |
| seyhmus.cacina | 0:b259fd1a88f5 | 583 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 584 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 585 | int32_t getGyroAccXYZandSensorTime(SensorData &accData, |
| seyhmus.cacina | 0:b259fd1a88f5 | 586 | SensorData &gyroData, |
| seyhmus.cacina | 0:b259fd1a88f5 | 587 | SensorTime &sensorTime, |
| seyhmus.cacina | 0:b259fd1a88f5 | 588 | AccRange accRange, GyroRange gyroRange); |
| seyhmus.cacina | 0:b259fd1a88f5 | 589 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 590 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 591 | ///@brief Get sensor time.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 592 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 593 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 594 | ///@param[in] sensorTime - SensorTime structure for data |
| seyhmus.cacina | 0:b259fd1a88f5 | 595 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 596 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 597 | ///@param[out] sensorTime - Holds sensor time on success |
| seyhmus.cacina | 0:b259fd1a88f5 | 598 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 599 | ///@returns returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 600 | int32_t getSensorTime(SensorTime &sensorTime); |
| seyhmus.cacina | 0:b259fd1a88f5 | 601 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 602 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 603 | ///@brief Get die temperature.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 604 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 605 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 606 | ///@param[in] temp - pointer to float for temperature |
| seyhmus.cacina | 0:b259fd1a88f5 | 607 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 608 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 609 | ///@param[out] temp - on success, holds the die temperature |
| seyhmus.cacina | 0:b259fd1a88f5 | 610 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 611 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 612 | int32_t getTemperature(float *temp); |
| seyhmus.cacina | 0:b259fd1a88f5 | 613 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 614 | // Initialize BMI160 with default parameters: |
| seyhmus.cacina | 0:b259fd1a88f5 | 615 | // set GYRO: Suspended, Acc Normal Mode, ODR:25 Hz |
| seyhmus.cacina | 0:b259fd1a88f5 | 616 | int32_t BMI160_DefaultInitalize(); |
| seyhmus.cacina | 0:b259fd1a88f5 | 617 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 618 | // |
| seyhmus.cacina | 0:b259fd1a88f5 | 619 | // |
| seyhmus.cacina | 0:b259fd1a88f5 | 620 | int32_t enable_data_ready_interrupt(); |
| seyhmus.cacina | 0:b259fd1a88f5 | 621 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 622 | // |
| seyhmus.cacina | 0:b259fd1a88f5 | 623 | // Set sample rate |
| seyhmus.cacina | 0:b259fd1a88f5 | 624 | // This function can be alled after BMI160_DefaultInitalize |
| seyhmus.cacina | 0:b259fd1a88f5 | 625 | int32_t setSampleRate(int sample_rate); |
| seyhmus.cacina | 0:b259fd1a88f5 | 626 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 627 | /// @brief Soft reset |
| seyhmus.cacina | 0:b259fd1a88f5 | 628 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 629 | int32_t reset(); |
| seyhmus.cacina | 0:b259fd1a88f5 | 630 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 631 | private: |
| seyhmus.cacina | 0:b259fd1a88f5 | 632 | bool m_use_irq; |
| seyhmus.cacina | 0:b259fd1a88f5 | 633 | bool bmi160_irq_asserted; |
| seyhmus.cacina | 0:b259fd1a88f5 | 634 | InterruptIn *m_bmi160_irq; |
| seyhmus.cacina | 0:b259fd1a88f5 | 635 | void irq_handler(); |
| seyhmus.cacina | 0:b259fd1a88f5 | 636 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 637 | protected: |
| seyhmus.cacina | 0:b259fd1a88f5 | 638 | BMI160(InterruptIn *int_pin): m_bmi160_irq(int_pin), m_use_irq(true) { |
| seyhmus.cacina | 0:b259fd1a88f5 | 639 | bmi160_irq_asserted = false; |
| seyhmus.cacina | 0:b259fd1a88f5 | 640 | } |
| seyhmus.cacina | 0:b259fd1a88f5 | 641 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 642 | BMI160(): m_use_irq(false) { } |
| seyhmus.cacina | 0:b259fd1a88f5 | 643 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 644 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 645 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 646 | /** |
| seyhmus.cacina | 0:b259fd1a88f5 | 647 | @brief BMI160_I2C - supports BMI160 object with I2C interface |
| seyhmus.cacina | 0:b259fd1a88f5 | 648 | */ |
| seyhmus.cacina | 0:b259fd1a88f5 | 649 | class BMI160_I2C: public BMI160 |
| seyhmus.cacina | 0:b259fd1a88f5 | 650 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 651 | public: |
| seyhmus.cacina | 0:b259fd1a88f5 | 652 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 653 | ///BMI160 default I2C address. |
| seyhmus.cacina | 0:b259fd1a88f5 | 654 | static const uint8_t I2C_ADRS_SDO_LO = 0x68; |
| seyhmus.cacina | 0:b259fd1a88f5 | 655 | ///BMI160 optional I2C address. |
| seyhmus.cacina | 0:b259fd1a88f5 | 656 | static const uint8_t I2C_ADRS_SDO_HI = 0x69; |
| seyhmus.cacina | 0:b259fd1a88f5 | 657 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 658 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 659 | ///@brief BMI160_I2C Constructor.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 660 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 661 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 662 | ///@param[in] i2cBus - reference to I2C bus for this device |
| seyhmus.cacina | 0:b259fd1a88f5 | 663 | ///@param[in] i2cAdrs - 7-bit I2C address |
| seyhmus.cacina | 0:b259fd1a88f5 | 664 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 665 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 666 | ///@param[out] none |
| seyhmus.cacina | 0:b259fd1a88f5 | 667 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 668 | ///@returns none |
| seyhmus.cacina | 0:b259fd1a88f5 | 669 | BMI160_I2C(I2C *i2cBus, uint8_t i2cAdrs); |
| seyhmus.cacina | 0:b259fd1a88f5 | 670 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 671 | ///@brief BMI160_I2C Constructor.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 672 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 673 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 674 | ///@param[in] i2cBus - reference to I2C bus for this device |
| seyhmus.cacina | 0:b259fd1a88f5 | 675 | ///@param[in] i2cAdrs - 7-bit I2C address |
| seyhmus.cacina | 0:b259fd1a88f5 | 676 | ///@param[in] int_pin - Interrupt pin |
| seyhmus.cacina | 0:b259fd1a88f5 | 677 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 678 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 679 | ///@param[out] none |
| seyhmus.cacina | 0:b259fd1a88f5 | 680 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 681 | ///@returns none |
| seyhmus.cacina | 0:b259fd1a88f5 | 682 | BMI160_I2C(I2C *i2cBus, uint8_t i2cAdrs, InterruptIn *int_pin); |
| seyhmus.cacina | 0:b259fd1a88f5 | 683 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 684 | ///@brief Reads a single register.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 685 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 686 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 687 | ///@param[in] data - pointer to memory for storing read data |
| seyhmus.cacina | 0:b259fd1a88f5 | 688 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 689 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 690 | ///@param[out] data - holds contents of read register on success |
| seyhmus.cacina | 0:b259fd1a88f5 | 691 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 692 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 693 | virtual int32_t readRegister(Registers reg, uint8_t *data); |
| seyhmus.cacina | 0:b259fd1a88f5 | 694 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 695 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 696 | ///@brief Writes a single register.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 697 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 698 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 699 | ///@param[in] data - data to write to register |
| seyhmus.cacina | 0:b259fd1a88f5 | 700 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 701 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 702 | ///@param[out] none |
| seyhmus.cacina | 0:b259fd1a88f5 | 703 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 704 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 705 | virtual int32_t writeRegister(Registers reg, const uint8_t data); |
| seyhmus.cacina | 0:b259fd1a88f5 | 706 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 707 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 708 | ///@brief Reads a block of registers.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 709 | ///@detail User must ensure that all registers between 'startReg' and |
| seyhmus.cacina | 0:b259fd1a88f5 | 710 | ///'stopReg' exist and are readable. Function reads up to, including, |
| seyhmus.cacina | 0:b259fd1a88f5 | 711 | ///'stopReg'.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 712 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 713 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 714 | ///@param[in] startReg - register to start reading from |
| seyhmus.cacina | 0:b259fd1a88f5 | 715 | ///@param[in] stopReg - register to stop reading from |
| seyhmus.cacina | 0:b259fd1a88f5 | 716 | ///@param[in] data - pointer to memory for storing read data |
| seyhmus.cacina | 0:b259fd1a88f5 | 717 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 718 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 719 | ///@param[out] data - holds contents of read registers on success |
| seyhmus.cacina | 0:b259fd1a88f5 | 720 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 721 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 722 | virtual int32_t readBlock(Registers startReg, Registers stopReg, |
| seyhmus.cacina | 0:b259fd1a88f5 | 723 | uint8_t *data); |
| seyhmus.cacina | 0:b259fd1a88f5 | 724 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 725 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 726 | ///@brief Writes a block of registers.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 727 | ///@detail User must ensure that all registers between 'startReg' and |
| seyhmus.cacina | 0:b259fd1a88f5 | 728 | ///'stopReg' exist and are writeable. Function writes up to, including, |
| seyhmus.cacina | 0:b259fd1a88f5 | 729 | ///'stopReg'.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 730 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 731 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 732 | ///@param[in] startReg - register to start writing at |
| seyhmus.cacina | 0:b259fd1a88f5 | 733 | ///@param[in] stopReg - register to stop writing at |
| seyhmus.cacina | 0:b259fd1a88f5 | 734 | ///@param[in] data - pointer to data to write to registers |
| seyhmus.cacina | 0:b259fd1a88f5 | 735 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 736 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 737 | ///@param[out] none |
| seyhmus.cacina | 0:b259fd1a88f5 | 738 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 739 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 740 | virtual int32_t writeBlock(Registers startReg, Registers stopReg, |
| seyhmus.cacina | 0:b259fd1a88f5 | 741 | const uint8_t *data); |
| seyhmus.cacina | 0:b259fd1a88f5 | 742 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 743 | private: |
| seyhmus.cacina | 0:b259fd1a88f5 | 744 | I2C *m_i2cBus; |
| seyhmus.cacina | 0:b259fd1a88f5 | 745 | uint8_t m_Wadrs, m_Radrs; |
| seyhmus.cacina | 0:b259fd1a88f5 | 746 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 747 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 748 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 749 | /** |
| seyhmus.cacina | 0:b259fd1a88f5 | 750 | @brief BMI160_SPI - supports BMI160 object with SPI interface |
| seyhmus.cacina | 0:b259fd1a88f5 | 751 | */ |
| seyhmus.cacina | 0:b259fd1a88f5 | 752 | class BMI160_SPI: public BMI160 |
| seyhmus.cacina | 0:b259fd1a88f5 | 753 | { |
| seyhmus.cacina | 0:b259fd1a88f5 | 754 | public: |
| seyhmus.cacina | 0:b259fd1a88f5 | 755 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 756 | ///@brief BMI160_SPI Constructor.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 757 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 758 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 759 | ///@param[in] spiBus - reference to SPI bus for this device |
| seyhmus.cacina | 0:b259fd1a88f5 | 760 | ///@param[in] cs - reference to DigitalOut used for chip select |
| seyhmus.cacina | 0:b259fd1a88f5 | 761 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 762 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 763 | ///@param[out] none |
| seyhmus.cacina | 0:b259fd1a88f5 | 764 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 765 | ///@returns none |
| seyhmus.cacina | 0:b259fd1a88f5 | 766 | BMI160_SPI(SPI *spiBus, DigitalOut &cs); |
| seyhmus.cacina | 0:b259fd1a88f5 | 767 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 768 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 769 | ///@brief Reads a single register.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 770 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 771 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 772 | ///@param[in] data - pointer to memory for storing read data |
| seyhmus.cacina | 0:b259fd1a88f5 | 773 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 774 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 775 | ///@param[out] data - holds contents of read register on success |
| seyhmus.cacina | 0:b259fd1a88f5 | 776 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 777 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 778 | virtual int32_t readRegister(Registers reg, uint8_t *data); |
| seyhmus.cacina | 0:b259fd1a88f5 | 779 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 780 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 781 | ///@brief Writes a single register.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 782 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 783 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 784 | ///@param[in] data - data to write to register |
| seyhmus.cacina | 0:b259fd1a88f5 | 785 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 786 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 787 | ///@param[out] none |
| seyhmus.cacina | 0:b259fd1a88f5 | 788 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 789 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 790 | virtual int32_t writeRegister(Registers reg, const uint8_t data); |
| seyhmus.cacina | 0:b259fd1a88f5 | 791 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 792 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 793 | ///@brief Reads a block of registers.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 794 | ///@detail User must ensure that all registers between 'startReg' and |
| seyhmus.cacina | 0:b259fd1a88f5 | 795 | ///'stopReg' exist and are readable. Function reads up to, including, |
| seyhmus.cacina | 0:b259fd1a88f5 | 796 | ///'stopReg'.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 797 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 798 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 799 | ///@param[in] startReg - register to start reading from |
| seyhmus.cacina | 0:b259fd1a88f5 | 800 | ///@param[in] stopReg - register to stop reading from |
| seyhmus.cacina | 0:b259fd1a88f5 | 801 | ///@param[in] data - pointer to memory for storing read data |
| seyhmus.cacina | 0:b259fd1a88f5 | 802 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 803 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 804 | ///@param[out] data - holds contents of read registers on success |
| seyhmus.cacina | 0:b259fd1a88f5 | 805 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 806 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 807 | virtual int32_t readBlock(Registers startReg, Registers stopReg, |
| seyhmus.cacina | 0:b259fd1a88f5 | 808 | uint8_t *data); |
| seyhmus.cacina | 0:b259fd1a88f5 | 809 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 810 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 811 | ///@brief Writes a block of registers.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 812 | ///@detail User must ensure that all registers between 'startReg' and |
| seyhmus.cacina | 0:b259fd1a88f5 | 813 | ///'stopReg' exist and are writeable. Function writes up to, including, |
| seyhmus.cacina | 0:b259fd1a88f5 | 814 | ///'stopReg'.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 815 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 816 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 817 | ///@param[in] startReg - register to start writing at |
| seyhmus.cacina | 0:b259fd1a88f5 | 818 | ///@param[in] stopReg - register to stop writing at |
| seyhmus.cacina | 0:b259fd1a88f5 | 819 | ///@param[in] data - pointer to data to write to registers |
| seyhmus.cacina | 0:b259fd1a88f5 | 820 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 821 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 822 | ///@param[out] none |
| seyhmus.cacina | 0:b259fd1a88f5 | 823 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 824 | ///@returns 0 on success, non 0 on failure |
| seyhmus.cacina | 0:b259fd1a88f5 | 825 | virtual int32_t writeBlock(Registers startReg, Registers stopReg, |
| seyhmus.cacina | 0:b259fd1a88f5 | 826 | const uint8_t *data); |
| seyhmus.cacina | 0:b259fd1a88f5 | 827 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 828 | private: |
| seyhmus.cacina | 0:b259fd1a88f5 | 829 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 830 | SPI *m_spiBus; |
| seyhmus.cacina | 0:b259fd1a88f5 | 831 | DigitalOut m_cs; |
| seyhmus.cacina | 0:b259fd1a88f5 | 832 | }; |
| seyhmus.cacina | 0:b259fd1a88f5 | 833 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 834 | #endif /* BMI160_H */ |
| seyhmus.cacina | 0:b259fd1a88f5 | 835 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 836 | |
| seyhmus.cacina | 0:b259fd1a88f5 | 837 | ///@brief fx documentation template.\n |
| seyhmus.cacina | 0:b259fd1a88f5 | 838 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 839 | ///On Entry: |
| seyhmus.cacina | 0:b259fd1a88f5 | 840 | ///@param[in] none |
| seyhmus.cacina | 0:b259fd1a88f5 | 841 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 842 | ///On Exit: |
| seyhmus.cacina | 0:b259fd1a88f5 | 843 | ///@param[out] none |
| seyhmus.cacina | 0:b259fd1a88f5 | 844 | /// |
| seyhmus.cacina | 0:b259fd1a88f5 | 845 | ///@returns none |
| seyhmus.cacina | 0:b259fd1a88f5 | 846 |
