Contains added code for stm32-L432KC compatibility
Dependents: BNO080_stm32_compatible
Diff: BNO080.h
- Revision:
- 3:197ad972fb7c
- Parent:
- 2:2269b723d16a
- Child:
- 8:92d4109beb3c
diff -r 2269b723d16a -r 197ad972fb7c BNO080.h --- a/BNO080.h Sat Dec 29 04:09:34 2018 -0800 +++ b/BNO080.h Fri Jun 14 20:31:37 2019 -0700 @@ -27,7 +27,7 @@ #include "BNO080Constants.h" // useful define when working with orientation quaternions -#define SQRT_2 1.414213562 +#define SQRT_2 1.414213562f /** Class to drive the BNO080 9-axis IMU. @@ -63,8 +63,8 @@ #define SHTP_HEADER_SIZE 4 -// Arbitrarily chosen, but should hopefully be large enough for all packets we need. -// If you enable lots of sensor reports and get an error, you might need to increase this. + // Arbitrarily chosen, but should hopefully be large enough for all packets we need. + // If you enable lots of sensor reports and get an error, you might need to increase this. #define STORED_PACKET_SIZE 128 /// Each SHTP packet has a header of 4 uint8_ts @@ -397,7 +397,7 @@ PinName user_INTPin, PinName user_RSTPin, uint8_t i2cAddress=0x4a, - int i2cPortSpeed=400000); + int i2cPortSpeed=100000); /** * Resets and connects to the IMU. Verifies that it's connected, and reads out its version @@ -460,13 +460,25 @@ * NOTE: this driver provides the macro SQRT_2 to help with entering values from that table. * * NOTE 2: this setting does not persist and will have to be re-applied every time the chip is reset. - * It is possible to set an FRS record and cause it to persist, but that method is not currently - * supported by this driver, + * Use setPermanentOrientation() for that. * * @param orientation quaternion mapping from IMU space to world space. */ void setSensorOrientation(Quaternion orientation); + /** + * Sets the orientation quaternion, telling the sensor how it's mounted + * in relation to world space. See page 40 of the BNO080 datasheet. + * + * Unlike setSensorOrientation(), this setting will persist across sensor restarts. + * However, it will also take a few hundred milliseconds to write. + * + * @param orientation quaternion mapping from IMU space to world space. + * + * @return true if the operation succeeded, false if it failed. + */ + bool setPermanentOrientation(Quaternion orientation); + // Report functions //----------------------------------------------------------------------------------------------------------------- @@ -654,6 +666,18 @@ int16_t floatToQ(float qFloat, uint8_t qPoint); /** + * Given a floating point value and a Q point, convert to Q + * See https://en.wikipedia.org/wiki/Q_(number_format) + * + * This version is used for the signed 32-bit values in metadata records. + * + * @param qFloat + * @param qPoint + * @return + */ + int32_t floatToQ_dword(float qFloat, uint16_t qPoint); + + /** * Tell the sensor to do a command. * See SH-2 Reference Manual section 6.3.8 page 42, Command request * The caller is expected to set shtpData 3 though 11 prior to calling @@ -684,6 +708,20 @@ bool readFRSRecord(uint16_t recordID, uint32_t* readBuffer, uint16_t readLength); /** + * Write a record to the FRS (Flash Record System) on the IMU. FRS records are composed of 32-bit words, + * with the size of each record determined by the record type. + * + * Will block until the entire record has been written. + * @param recordID Record ID to write. See SH-2 figures 28 and 29 for a list of these. Sometimes also called + * the "FRS Type" by the datasheet (???). + * @param buffer Buffer to write data into. + * @param length Amount of words to write to the record. Must be <= the length of the record. + * + * @return whether the request succeeded + */ + bool writeFRSRecord(uint16_t recordID, uint32_t* buffer, uint16_t length); + + /** * Reads a packet from the IMU and stores it in the class variables. * * @param timeout how long to wait for there to be a packet