Fully featured I2C and SPI driver for CEVA (Hilcrest)'s BNO080 and FSM300 Inertial Measurement Units.
Dependents: BNO080-Examples BNO080-Examples
BNO080SPI Class Reference
Version of the BNO080 driver which uses the SPI interface. More...
#include <BNO080.h>
Inherits BNO080Base.
Inherited by BNO080Async.
Public Types | |
enum | Report { TOTAL_ACCELERATION = SENSOR_REPORTID_ACCELEROMETER, LINEAR_ACCELERATION = SENSOR_REPORTID_LINEAR_ACCELERATION, GRAVITY_ACCELERATION = SENSOR_REPORTID_GRAVITY, GYROSCOPE = SENSOR_REPORTID_GYROSCOPE_CALIBRATED, MAG_FIELD = SENSOR_REPORTID_MAGNETIC_FIELD_CALIBRATED, MAG_FIELD_UNCALIBRATED = SENSOR_REPORTID_MAGNETIC_FIELD_UNCALIBRATED, ROTATION = SENSOR_REPORTID_ROTATION_VECTOR, GEOMAGNETIC_ROTATION = SENSOR_REPORTID_GEOMAGNETIC_ROTATION_VECTOR, GAME_ROTATION = SENSOR_REPORTID_GAME_ROTATION_VECTOR, TAP_DETECTOR = SENSOR_REPORTID_TAP_DETECTOR, STABILITY_CLASSIFIER = SENSOR_REPORTID_STABILITY_CLASSIFIER, STEP_DETECTOR = SENSOR_REPORTID_STEP_DETECTOR, STEP_COUNTER = SENSOR_REPORTID_STEP_COUNTER, SIGNIFICANT_MOTION = SENSOR_REPORTID_SIGNIFICANT_MOTION, SHAKE_DETECTOR = SENSOR_REPORTID_SHAKE_DETECTOR } |
List of all sensor reports that the IMU supports. More... | |
enum | Stability { UNKNOWN = 0, ON_TABLE = 1, STATIONARY = 2, STABLE = 3, MOTION = 4 } |
Enum to represent the different stability types. More... | |
Public Member Functions | |
BNO080SPI (Stream *debugPort, PinName rstPin, PinName intPin, PinName wakePin, PinName misoPin, PinName mosiPin, PinName sclkPin, PinName csPin, int spiSpeed=3000000) | |
Construct a BNO080 driver for the SPI bus, providing pins and parameters. | |
virtual bool | begin () |
Resets and connects to the IMU. | |
void | tare (bool zOnly=false) |
Tells the IMU to use its current rotation vector as the "zero" rotation vector and to reorient all outputs accordingly. | |
bool | enableCalibration (bool calibrateAccel, bool calibrateGyro, bool calibrateMag) |
Tells the IMU to begin a dynamic sensor calibration. | |
bool | saveCalibration () |
Saves the calibration started with startCalibration() and ends the calibration. | |
void | setSensorOrientation (Quaternion orientation) |
Sets the orientation quaternion, telling the sensor how it's mounted in relation to world space. | |
bool | setPermanentOrientation (Quaternion orientation) |
Sets the orientation quaternion, telling the sensor how it's mounted in relation to world space. | |
virtual void | lockMutex () |
No-op on synchronous driver. | |
virtual void | unlockMutex () |
No-op on synchronous driver. | |
virtual bool | updateData () |
Checks for new data packets queued on the IMU. | |
uint8_t | getReportStatus (Report report) |
Gets the status of a report as a 2 bit number. | |
const char * | getReportStatusString (Report report) |
Get a string for printout describing the status of a sensor. | |
bool | hasNewData (Report report) |
Checks if a specific report has gotten new data since the last call to this function. | |
void | enableReport (Report report, uint16_t timeBetweenReports) |
Enable a data report from the IMU. | |
void | disableReport (Report report) |
Disable a data report from the IMU. | |
uint32_t | getSerialNumber () |
Gets the serial number (used to uniquely identify each individual device). | |
float | getRange (Report report) |
Gets the range of a report as reported by the IMU. | |
float | getResolution (Report report) |
Gets the resolution of a report as reported by the IMU. | |
float | getPower (Report report) |
Get the power used by a report when it's operating, according to the IMU. | |
float | getMinPeriod (Report report) |
Gets the smallest polling period that a report supports. | |
float | getMaxPeriod (Report report) |
Gets the larges polling period that a report supports. | |
void | printMetadataSummary (Report report) |
Prints a summary of a report's metadata to the debug stream. | |
Data Fields | |
TVector3 | totalAcceleration |
Readout from Accleration report. | |
TVector3 | linearAcceleration |
Readout from Linear Acceleration report. | |
TVector3 | gravityAcceleration |
Readout from Gravity report. | |
TVector3 | gyroRotation |
Readout from Calibrated Gyroscope report Represents the angular velocities of the chip in rad/s in the X, Y, and Z axes. | |
TVector3 | magField |
Readout from the Magnetic Field Calibrated report. | |
TVector3 | magFieldUncalibrated |
Readout from the Magnetic Field Uncalibrated report. | |
TVector3 | hardIronOffset |
Auxiliary readout from the Magnetic Field Uncalibrated report. | |
Quaternion | rotationVector |
Readout from the Rotation Vector report. | |
float | rotationAccuracy |
Auxiliary accuracy readout from the Rotation Vector report. | |
Quaternion | gameRotationVector |
Readout from the Game Rotation Vector report. | |
Quaternion | geomagneticRotationVector |
Readout from the Geomagnetic Rotation Vector report. | |
float | geomagneticRotationAccuracy |
Auxiliary accuracy readout from the Geomagnetic Rotation Vector report. | |
bool | tapDetected |
Tap readout from the Tap Detector report. | |
bool | doubleTap |
Whether the last tap detected was a single or double tap. | |
Stability | stability |
Readout from the stability classifier. | |
bool | stepDetected |
Readout from the Step Detector report. | |
uint16_t | stepCount |
Readout from the Step Counter report. | |
bool | significantMotionDetected |
Readout from the Significant Motion Detector report. | |
bool | shakeDetected |
Readout from the Shake Detector report. | |
uint8_t | majorSoftwareVersion |
Version info read from the IMU when it starts up. | |
bool | xAxisShake |
The axis/axes that shaking was detected in in the latest shaking report. | |
Protected Member Functions | |
bool | receivePacket (std::chrono::milliseconds timeout=200ms) override |
Reads a packet from the IMU and stores it in the class variables. | |
bool | sendPacket (uint8_t channelNumber, uint8_t dataLength) override |
Sends the current shtpData contents to the BNO. | |
bool | receiveCompletePacket (size_t bytesRead, std::chrono::milliseconds timeout=200ms) |
Assuming that at least a packet header has been read into the RX buffer, receive the remainder of the packet. | |
void | spiTransferAndWait (const uint8_t *tx_buffer, int tx_length, uint8_t *rx_buffer, int rx_length) |
Start an SPI transfer and suspend the current thread until it is complete. | |
void | spiTransferAndWait (const uint8_t *tx_buffer, int tx_length, uint8_t *rx_buffer, int rx_length) |
Start an SPI transfer and wait for it to complete. | |
uint16_t | getMetaVersion () |
Gets the version of the metadata stored in the buffer. | |
void | processPacket () |
Processes the packet currently stored in the buffer, and updates class variables to reflect the data it contains. | |
void | parseSensorDataPacket () |
Processes the sensor data packet currently stored in the buffer. | |
virtual bool | waitForPacket (int channel, uint8_t reportID, std::chrono::milliseconds timeout=125ms) |
Call to wait for a packet with the given parameters to come in. | |
float | qToFloat (int16_t fixedPointValue, uint8_t qPoint) |
Given a Q value, converts fixed point floating to regular floating point number. | |
float | qToFloat_dword (uint32_t fixedPointValue, int16_t qPoint) |
Given a Q value, converts fixed point floating to regular floating point number. | |
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) | |
int32_t | floatToQ_dword (float qFloat, uint16_t qPoint) |
Given a floating point value and a Q point, convert to Q See https://en.wikipedia.org/wiki/Q_(number_format) | |
void | sendCommand (uint8_t command) |
Tell the sensor to do a command. | |
void | setFeatureCommand (uint8_t reportID, uint16_t timeBetweenReports, uint32_t specificConfig=0) |
Given a sensor's report ID, this tells the BNO080 to begin reporting the values. | |
bool | readFRSRecord (uint16_t recordID, uint32_t *readBuffer, uint16_t readLength) |
Read a record from the FRS (Flash Record System) on the IMU. | |
bool | writeFRSRecord (uint16_t recordID, uint32_t *buffer, uint16_t length) |
Write a record to the FRS (Flash Record System) on the IMU. | |
void | printPacket (uint8_t *buffer) |
Prints the current shtp packet stored in the buffer. | |
virtual void | clearSendBuffer () |
Erases the current SHTP TX packet buffer. | |
bool | loadReportMetadata (Report report) |
Loads the metadata for this report into the metadata buffer. | |
int16_t | getQ1 (Report report) |
Gets the Q point from a report's metadata, which essentially defines where the decimal point goes in the sensor's output. | |
Protected Attributes | |
SPI | _spiPort |
I2C port object. | |
int | _spiSpeed |
user defined port speed | |
Stream * | _debugPort |
Serial stream to print debug info to. | |
InterruptIn | _int |
Interrupt pin -- signals to the host that the IMU has data to send. | |
uint8_t * | txShtpHeader = txPacketBuffer |
Each SHTP packet starts with a header of 4 uint8_ts. | |
uint8_t * | txShtpData = txPacketBuffer + SHTP_HEADER_SIZE |
Stores data contained in each packet. | |
uint16_t | rxPacketLength |
Length of packet that was received into buffer. Does NOT include header bytes. | |
uint8_t | sequenceNumber [6] |
Current sequence number for each channel, incremented after transmission. | |
uint8_t | commandSequenceNumber |
Commands have a seqNum as well. These are inside command packet, the header uses its own seqNum per channel. | |
uint16_t | bufferMetadataRecord |
Record ID of the metadata record currently stored in the metadataRecord[] buffer. | |
uint32_t | metadataRecord [METADATA_BUFFER_LEN] |
Buffer for current metadata record. | |
uint8_t | reportStatus [STATUS_ARRAY_LEN] |
stores status of each sensor, indexed by report ID | |
bool | reportHasBeenUpdated [STATUS_ARRAY_LEN] |
stores whether a sensor has been updated since the last call to hasNewData() |
Detailed Description
Version of the BNO080 driver which uses the SPI interface.
WARNING: The SPI interface, unlike the I2C interface, of this chip has some god-awful timing requirements that are difficult to satisfy.
In order for the chip to produce data, you must call updateData() at at more than twice the frequency of the fastest sensor poll rate you have set. Otherwise, for reasons that I don't exactly understand, the IMU will have some kind of internal watchdog timeout error and shut itself down. Also, you have about 500ms after calling begin() to configure reports and start receiving data, or the same thing happens.
If this timing error happens to you, the symptoms are strange: the IMU will just stop sending data, several seconds later. No error or anything, just no data. To recover from the error, you would have to call begin() again and reconfigure it from scratch.
Definition at line 847 of file BNO080.h.
Member Enumeration Documentation
enum Report [inherited] |
List of all sensor reports that the IMU supports.
- Enumerator:
enum Stability [inherited] |
Enum to represent the different stability types.
See BNO datasheet section 2.4.1 and SH-2 section 6.5.31.2 for details.
- Enumerator:
Constructor & Destructor Documentation
BNO080SPI | ( | Stream * | debugPort, |
PinName | rstPin, | ||
PinName | intPin, | ||
PinName | wakePin, | ||
PinName | misoPin, | ||
PinName | mosiPin, | ||
PinName | sclkPin, | ||
PinName | csPin, | ||
int | spiSpeed = 3000000 |
||
) |
Construct a BNO080 driver for the SPI bus, providing pins and parameters.
This doesn't actually initialize the chip, you will need to call begin() for that.
NOTE: while some schematics tell you to connect the BOOTN pin to the processor, this driver does not use or require it. Just tie it to VCC per the datasheet.
- Parameters:
-
debugPort Serial port to write output to. Cannot be nullptr. rstPin Hardware reset pin, resets the IMU intPin Hardware interrupt pin, this is used for the IMU to signal the host that it has a message to send wakePin Hardware wake pin, this is used by the processor to signal the BNO to wake up and receive a message misoPin SPI MISO pin mosiPin SPI MOSI pin sclkPin SPI SCLK pin csPin SPI CS pin spiSpeed SPI frequency. The BNO's max is 3MHz.
Definition at line 1495 of file BNO080.cpp.
Member Function Documentation
bool begin | ( | ) | [virtual, inherited] |
Resets and connects to the IMU.
Verifies that it's connected, and reads out its version info into the class variables above.
If this function is failing, it would be a good idea to turn on BNO_DEBUG in the cpp file to get detailed output.
Note: this function takes several hundred ms to execute, mainly due to waiting for the BNO to boot.
- Returns:
- whether or not initialization was successful
Reimplemented in BNO080Async.
Definition at line 94 of file BNO080.cpp.
void clearSendBuffer | ( | ) | [protected, virtual, inherited] |
Erases the current SHTP TX packet buffer.
In BNO080Async, this blocks until the buffer is available.
Definition at line 1217 of file BNO080.cpp.
void disableReport | ( | Report | report ) | [inherited] |
Disable a data report from the IMU.
- Parameters:
-
report The report to disable.
Definition at line 428 of file BNO080.cpp.
bool enableCalibration | ( | bool | calibrateAccel, |
bool | calibrateGyro, | ||
bool | calibrateMag | ||
) | [inherited] |
Tells the IMU to begin a dynamic sensor calibration.
To calibrate the IMU, call this function and move the IMU according to the instructions in the "BNO080 Sensor Calibration Procedure" app note (http://www.hillcrestlabs.com/download/59de9014566d0727bd002ae7).
To tell when the calibration is complete, look at the status bits for Game Rotation Vector (for accel and gyro) and Magnetic Field (for the magnetometer).
The gyro and accelerometer should only need to be calibrated once, but the magnetometer will need to be recalibrated every time the orientation of ferrous metals around the IMU changes (e.g. when it is put into a new enclosure).
The new calibration will not be saved in flash until you call saveCalibration().
NOTE: calling this with all false values will cancel any calibration in progress. However, the calibration data being created will remain in use until the next chip reset (I think!)
- Parameters:
-
calibrateAccel Whether to calibrate the accelerometer. calibrateGyro Whether to calibrate the gyro. calibrateMag Whether to calibrate the magnetometer.
- Returns:
- whether the operation succeeded
Definition at line 216 of file BNO080.cpp.
void enableReport | ( | Report | report, |
uint16_t | timeBetweenReports | ||
) | [inherited] |
Enable a data report from the IMU.
Look at the comments above to see what the reports do. This function checks your polling period against the report's max speed in the IMU's metadata, and reports an error if you're trying to poll too fast.
- Parameters:
-
timeBetweenReports time in milliseconds between data updates.
Definition at line 409 of file BNO080.cpp.
int16_t floatToQ | ( | float | qFloat, |
uint8_t | qPoint | ||
) | [protected, inherited] |
Given a floating point value and a Q point, convert to Q See https://en.wikipedia.org/wiki/Q_(number_format)
- Parameters:
-
qFloat qPoint
- Returns:
Definition at line 850 of file BNO080.cpp.
int32_t floatToQ_dword | ( | float | qFloat, |
uint16_t | qPoint | ||
) | [protected, inherited] |
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.
- Parameters:
-
qFloat qPoint
- Returns:
Definition at line 856 of file BNO080.cpp.
float getMaxPeriod | ( | Report | report ) | [inherited] |
Gets the larges polling period that a report supports.
Some reports don't have a max period, in which case this function will return -1.0.
- Returns:
- Period in seconds, or -1.0 on error.
Definition at line 477 of file BNO080.cpp.
uint16_t getMetaVersion | ( | ) | [protected, inherited] |
float getMinPeriod | ( | Report | report ) | [inherited] |
Gets the smallest polling period that a report supports.
- Returns:
- Period in seconds.
Definition at line 470 of file BNO080.cpp.
float getPower | ( | Report | report ) | [inherited] |
Get the power used by a report when it's operating, according to the IMU.
- Parameters:
-
report
- Returns:
- Power used in mA.
Definition at line 461 of file BNO080.cpp.
int16_t getQ1 | ( | Report | report ) | [protected, inherited] |
Gets the Q point from a report's metadata, which essentially defines where the decimal point goes in the sensor's output.
The 1/2/3 Q values are used in different places in the metadata, see SH-2 section 5.1 for details.
- Parameters:
-
report
- Returns:
Definition at line 509 of file BNO080.cpp.
float getRange | ( | Report | report ) | [inherited] |
Gets the range of a report as reported by the IMU.
Units are the same as the report's output data.
- Returns:
Definition at line 446 of file BNO080.cpp.
uint8_t getReportStatus | ( | Report | report ) | [inherited] |
Gets the status of a report as a 2 bit number.
per SH-2 section 6.5.1, this is interpreted as:
0 - unreliable
1 - accuracy low
2 - accuracy medium
3 - accuracy high
of course, these are only updated if a given report is enabled.
- Parameters:
-
report
- Returns:
Definition at line 367 of file BNO080.cpp.
const char * getReportStatusString | ( | Report | report ) | [inherited] |
Get a string for printout describing the status of a sensor.
- Returns:
Definition at line 378 of file BNO080.cpp.
float getResolution | ( | Report | report ) | [inherited] |
Gets the resolution of a report as reported by the IMU.
Units are the same as the report's output data.
- Parameters:
-
report
- Returns:
Definition at line 454 of file BNO080.cpp.
uint32_t getSerialNumber | ( | ) | [inherited] |
Gets the serial number (used to uniquely identify each individual device).
NOTE: this function should work according to the datasheet, but the device I was testing with appears to have an empty serial number record as shipped, and I could never get anything out of it. Your mileage may vary.
- Returns:
- The serial number, or 0 on error.
Definition at line 434 of file BNO080.cpp.
bool hasNewData | ( | Report | report ) | [inherited] |
Checks if a specific report has gotten new data since the last call to this function.
- Parameters:
-
report The report to check.
- Returns:
- Whether the report has received new data.
Definition at line 395 of file BNO080.cpp.
bool loadReportMetadata | ( | BNO080Base::Report | report ) | [protected, inherited] |
Loads the metadata for this report into the metadata buffer.
- Parameters:
-
report
- Returns:
- Whether the operation succeeded.
Definition at line 1222 of file BNO080.cpp.
virtual void lockMutex | ( | ) | [virtual, inherited] |
void parseSensorDataPacket | ( | ) | [protected, inherited] |
Processes the sensor data packet currently stored in the buffer.
Only called from processPacket()
Definition at line 572 of file BNO080.cpp.
void printMetadataSummary | ( | Report | report ) | [inherited] |
Prints a summary of a report's metadata to the debug stream.
Should be useful for debugging and setting up reports since lots of this data isn't given in the datasheets.
Note: to save string constant space, this function is only available when BNO_DEBUG is 1.
Definition at line 490 of file BNO080.cpp.
void printPacket | ( | uint8_t * | buffer ) | [protected, inherited] |
Prints the current shtp packet stored in the buffer.
- Parameters:
-
length
Definition at line 1174 of file BNO080.cpp.
void processPacket | ( | ) | [protected, inherited] |
Processes the packet currently stored in the buffer, and updates class variables to reflect the data it contains.
Definition at line 530 of file BNO080.cpp.
float qToFloat | ( | int16_t | fixedPointValue, |
uint8_t | qPoint | ||
) | [protected, inherited] |
Given a Q value, converts fixed point floating to regular floating point number.
- Parameters:
-
fixedPointValue qPoint
- Returns:
Definition at line 834 of file BNO080.cpp.
float qToFloat_dword | ( | uint32_t | fixedPointValue, |
int16_t | qPoint | ||
) | [protected, inherited] |
Given a Q value, converts fixed point floating to regular floating point number.
This version is used for the unsigned 32-bit values in metadata records.
- Parameters:
-
fixedPointValue qPoint
- Returns:
Definition at line 841 of file BNO080.cpp.
bool readFRSRecord | ( | uint16_t | recordID, |
uint32_t * | readBuffer, | ||
uint16_t | readLength | ||
) | [protected, inherited] |
Read a record from 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 read.
- Parameters:
-
recordID Record ID to read. See SH-2 figures 28 and 29 for a list of these. Sometimes also called the "FRS Type" by the datasheet (???). readBuffer Buffer to read data into. readLength Amount of words to read from the record. Must be <= the length of the record.
- Returns:
- whether the request succeeded
Definition at line 915 of file BNO080.cpp.
bool receiveCompletePacket | ( | size_t | bytesRead, |
std::chrono::milliseconds | timeout = 200ms |
||
) | [protected] |
Assuming that at least a packet header has been read into the RX buffer, receive the remainder of the packet.
- Parameters:
-
bytesRead The number of bytes (including the header) of the packet that have already been read.
- Returns:
Definition at line 1597 of file BNO080.cpp.
bool receivePacket | ( | std::chrono::milliseconds | timeout = 200ms ) |
[override, protected, virtual] |
Reads a packet from the IMU and stores it in the class variables.
- Parameters:
-
timeout how long to wait for there to be a packet
- Returns:
- whether a packet was recieved.
Implements BNO080Base.
Definition at line 1575 of file BNO080.cpp.
bool saveCalibration | ( | ) | [inherited] |
Saves the calibration started with startCalibration() and ends the calibration.
You will want to call this once the status bits read as "accuracy high".
WARNING: if you paid for a factory calibrated IMU, then this WILL OVERWRITE THE FACTORY CALIBRATION in whatever sensors are being calibrated. Use with caution!
- Returns:
- whether the operation succeeded
Definition at line 260 of file BNO080.cpp.
void sendCommand | ( | uint8_t | command ) | [protected, inherited] |
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
Definition at line 864 of file BNO080.cpp.
bool sendPacket | ( | uint8_t | channelNumber, |
uint8_t | dataLength | ||
) | [override, protected, virtual] |
Sends the current shtpData contents to the BNO.
It's a good idea to disable interrupts before you call this.
- Parameters:
-
channelNumber the channel to send on dataLength How many bits of shtpData to send
- Returns:
Implements BNO080Base.
Definition at line 1507 of file BNO080.cpp.
void setFeatureCommand | ( | uint8_t | reportID, |
uint16_t | timeBetweenReports, | ||
uint32_t | specificConfig = 0 |
||
) | [protected, inherited] |
Given a sensor's report ID, this tells the BNO080 to begin reporting the values.
- Parameters:
-
reportID timeBetweenReports specificConfig the specific config word. Useful for personal activity classifier.
Definition at line 887 of file BNO080.cpp.
bool setPermanentOrientation | ( | Quaternion | orientation ) | [inherited] |
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.
- Parameters:
-
orientation quaternion mapping from IMU space to world space.
- Returns:
- true if the operation succeeded, false if it failed.
Definition at line 328 of file BNO080.cpp.
void setSensorOrientation | ( | Quaternion | orientation ) | [inherited] |
Sets the orientation quaternion, telling the sensor how it's mounted in relation to world space.
See page 40 of the BNO080 datasheet.
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. Use setPermanentOrientation() for that.
- Parameters:
-
orientation quaternion mapping from IMU space to world space.
Definition at line 296 of file BNO080.cpp.
void spiTransferAndWait | ( | const uint8_t * | tx_buffer, |
int | tx_length, | ||
uint8_t * | rx_buffer, | ||
int | rx_length | ||
) | [protected] |
Start an SPI transfer and wait for it to complete.
BNO080Async swaps in a threaded implementation here. API same as SPI::write().
void spiTransferAndWait | ( | const uint8_t * | tx_buffer, |
int | tx_length, | ||
uint8_t * | rx_buffer, | ||
int | rx_length | ||
) | [protected] |
Start an SPI transfer and suspend the current thread until it is complete.
Used by functions in BNO080SPI. Note: should only be called by one thread at a time.
- Parameters:
-
tx_buffer tx_length rx_buffer rx_length
Definition at line 1685 of file BNO080.cpp.
void tare | ( | bool | zOnly = false ) |
[inherited] |
Tells the IMU to use its current rotation vector as the "zero" rotation vector and to reorient all outputs accordingly.
- Parameters:
-
zOnly If true, only the rotation about the Z axis (the heading) will be tared.
Definition at line 195 of file BNO080.cpp.
virtual void unlockMutex | ( | ) | [virtual, inherited] |
bool updateData | ( | ) | [virtual, inherited] |
Checks for new data packets queued on the IMU.
If there are packets queued, receives all of them and updates the class variables with the results.
Note that with some backends (SPI), sending commands will also update data, which can cause updateData() to return false even though new data has been received. hasNewData() is a more reliable way to determine if a sensor has new data.
- Returns:
- True iff new data packets of any kind were received. If you need more fine-grained data change reporting, check out hasNewData().
Reimplemented in BNO080Async.
Definition at line 341 of file BNO080.cpp.
bool waitForPacket | ( | int | channel, |
uint8_t | reportID, | ||
std::chrono::milliseconds | timeout = 125ms |
||
) | [protected, virtual, inherited] |
Call to wait for a packet with the given parameters to come in.
Note: on BNO080Async, the received packet data will stay in the RX buffer until either the public IMU function that was called returns, or you call sendPacket() or waitForPacket() again.
- Parameters:
-
channel Channel of the packet reportID Report ID (first data byte) of the packet timeout how long to wait for the packet
- Returns:
- true if the packet has been received, false if it timed out
Definition at line 801 of file BNO080.cpp.
bool writeFRSRecord | ( | uint16_t | recordID, |
uint32_t * | buffer, | ||
uint16_t | length | ||
) | [protected, inherited] |
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.
- Parameters:
-
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 (???). buffer Buffer to write data into. length Amount of words to write to the record. Must be <= the length of the record.
- Returns:
- whether the request succeeded
Definition at line 1024 of file BNO080.cpp.
Field Documentation
Stream* _debugPort [protected, inherited] |
InterruptIn _int [protected, inherited] |
SPI _spiPort [protected] |
uint16_t bufferMetadataRecord [protected, inherited] |
uint8_t commandSequenceNumber [protected, inherited] |
bool doubleTap [inherited] |
Quaternion gameRotationVector [inherited] |
float geomagneticRotationAccuracy [inherited] |
Quaternion geomagneticRotationVector [inherited] |
TVector3 gravityAcceleration [inherited] |
TVector3 gyroRotation [inherited] |
TVector3 hardIronOffset [inherited] |
TVector3 linearAcceleration [inherited] |
TVector3 magFieldUncalibrated [inherited] |
uint8_t majorSoftwareVersion [inherited] |
uint32_t metadataRecord[METADATA_BUFFER_LEN] [protected, inherited] |
bool reportHasBeenUpdated[STATUS_ARRAY_LEN] [protected, inherited] |
stores whether a sensor has been updated since the last call to hasNewData()
uint8_t reportStatus[STATUS_ARRAY_LEN] [protected, inherited] |
float rotationAccuracy [inherited] |
Quaternion rotationVector [inherited] |
uint16_t rxPacketLength [protected, inherited] |
uint8_t sequenceNumber[6] [protected, inherited] |
bool shakeDetected [inherited] |
bool significantMotionDetected [inherited] |
uint16_t stepCount [inherited] |
bool stepDetected [inherited] |
bool tapDetected [inherited] |
TVector3 totalAcceleration [inherited] |
uint8_t* txShtpData = txPacketBuffer + SHTP_HEADER_SIZE [protected, inherited] |
uint8_t* txShtpHeader = txPacketBuffer [protected, inherited] |
bool xAxisShake [inherited] |
Generated on Wed Jul 13 2022 10:30:01 by
