Contains added code for stm32-L432KC compatibility

Dependents:   BNO080_stm32_compatible

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BNO080Constants.h Source File

BNO080Constants.h

00001 //
00002 // Constants used in communication with the BNO080
00003 //
00004 
00005 #ifndef HAMSTER_BNO080CONSTANTS_H
00006 #define HAMSTER_BNO080CONSTANTS_H
00007 
00008 
00009 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
00010 
00011 // Channels
00012 #define CHANNEL_COMMAND 0
00013 #define CHANNEL_EXECUTABLE 1
00014 #define CHANNEL_CONTROL 2
00015 #define CHANNEL_REPORTS 3
00016 #define CHANNEL_WAKE_REPORTS 4
00017 #define CHANNEL_GYRO 5
00018 
00019 // Report IDs on the command channel.
00020 // Unlike the other constants, these come from the Sensor Hub Transport Protocol datasheet, section 5.1
00021 #define COMMAND_REPORTID_ADVERTISEMENT 0x0
00022 #define COMMAND_REPORTID_ERRORLIST 0x1
00023 
00024 //All the ways we can configure or talk to the BNO080, figure 34, page 36 reference manual
00025 //These are used for low level communication with the sensor, on channel 2
00026 #define SHTP_REPORT_COMMAND_RESPONSE 0xF1
00027 #define SHTP_REPORT_COMMAND_REQUEST 0xF2
00028 #define SHTP_REPORT_FRS_READ_RESPONSE 0xF3
00029 #define SHTP_REPORT_FRS_READ_REQUEST 0xF4
00030 #define SHTP_REPORT_FRS_WRITE_RESPONSE 0xF5
00031 #define SHTP_REPORT_FRS_WRITE_DATA 0xF6
00032 #define SHTP_REPORT_FRS_WRITE_REQUEST 0xF7
00033 #define SHTP_REPORT_PRODUCT_ID_RESPONSE 0xF8
00034 #define SHTP_REPORT_PRODUCT_ID_REQUEST 0xF9
00035 #define SHTP_REPORT_BASE_TIMESTAMP 0xFB
00036 #define SHTP_REPORT_SET_FEATURE_COMMAND 0xFD
00037 #define SHTP_REPORT_GET_FEATURE_RESPONSE 0xFC
00038 
00039 //All the different sensors and features we can get reports from
00040 //These are used when enabling a given sensor
00041 #define SENSOR_REPORTID_TIMESTAMP_REBASE 0xFA
00042 #define SENSOR_REPORTID_ACCELEROMETER 0x01
00043 #define SENSOR_REPORTID_GYROSCOPE_CALIBRATED 0x02
00044 #define SENSOR_REPORTID_MAGNETIC_FIELD_CALIBRATED 0x03
00045 #define SENSOR_REPORTID_LINEAR_ACCELERATION 0x04
00046 #define SENSOR_REPORTID_ROTATION_VECTOR 0x05
00047 #define SENSOR_REPORTID_GRAVITY 0x06
00048 #define SENSOR_REPORTID_GAME_ROTATION_VECTOR 0x08
00049 #define SENSOR_REPORTID_GEOMAGNETIC_ROTATION_VECTOR 0x09
00050 #define SENSOR_REPORTID_MAGNETIC_FIELD_UNCALIBRATED 0x0F
00051 #define SENSOR_REPORTID_TAP_DETECTOR 0x10
00052 #define SENSOR_REPORTID_STEP_COUNTER 0x11
00053 #define SENSOR_REPORTID_SIGNIFICANT_MOTION 0x12
00054 #define SENSOR_REPORTID_STABILITY_CLASSIFIER 0x13
00055 #define SENSOR_REPORTID_STEP_DETECTOR 0x18
00056 #define SENSOR_REPORTID_SHAKE_DETECTOR 0x19
00057 
00058 // sensor report ID with the largest numeric value
00059 #define MAX_SENSOR_REPORTID SENSOR_REPORTID_SHAKE_DETECTOR
00060 
00061 // Q points for various sensor data elements
00062 #define ACCELEROMETER_Q_POINT 8 // for accelerometer based data
00063 #define GYRO_Q_POINT 9 // for gyroscope data
00064 #define MAGNETOMETER_Q_POINT 4 // for magnetometer data
00065 #define ROTATION_Q_POINT 14 // for rotation data
00066 #define ROTATION_ACCURACY_Q_POINT 12 // for rotation accuracy data
00067 #define POWER_Q_POINT 10 // for power information in the metadata
00068 #define ORIENTATION_QUAT_Q_POINT 14 // for the set orientation command
00069 #define FRS_ORIENTATION_Q_POINT 30 // for the sensor orientation FRS record
00070 
00071 // Report IDs on the Executable channel
00072 // See Figure 1-27 in the BNO080 datasheet
00073 #define EXECUTABLE_REPORTID_RESET 0x1
00074 
00075 //Record IDs from SH-2 figure 28
00076 //These are used to read and set various configuration options
00077 #define FRS_RECORDID_SERIAL_NUMBER 0x4B4B
00078 #define FRS_RECORDID_SYSTEM_ORIENTATION 0x2D3E
00079 
00080 //Command IDs from section 6.4, page 42
00081 //These are used to calibrate, initialize, set orientation, tare etc the sensor
00082 #define COMMAND_ERRORS 1
00083 #define COMMAND_COUNTER 2
00084 #define COMMAND_TARE 3
00085 #define COMMAND_INITIALIZE 4
00086 #define COMMAND_SAVE_DCD 6
00087 #define COMMAND_ME_CALIBRATE 7
00088 #define COMMAND_DCD_PERIOD_SAVE 9
00089 #define COMMAND_OSCILLATOR 10
00090 #define COMMAND_CLEAR_DCD 11
00091 #define COMMAND_UNSOLICITED_INITIALIZE 0x84
00092 
00093 #define CALIBRATE_ACCEL 0
00094 #define CALIBRATE_GYRO 1
00095 #define CALIBRATE_MAG 2
00096 #define CALIBRATE_PLANAR_ACCEL 3
00097 #define CALIBRATE_ACCEL_GYRO_MAG 4
00098 #define CALIBRATE_STOP 5
00099 
00100 // timing for reset
00101 // per my measurement, reset takes about 90ms, so let's take twice that
00102 // By the way, I discovered (by accident) that a symptom of brownout is the chip taking
00103 // a long time to reset.  So if you had to increase this, check that your Vcc is 
00104 // within the allowed range.
00105 #define BNO080_RESET_TIMEOUT .18f
00106 
00107 #endif //HAMSTER_BNO080CONSTANTS_H