|
esp32_BNO08x 1.3
C++ BNO08x IMU driver component for esp-idf.
|
BNO08x IMU driver class. More...
#include <BNO08x.hpp>

Classes | |
| struct | bno08x_reports_t |
| Contains report implementations. More... | |
Public Types | |
| typedef struct BNO08x::bno08x_reports_t | bno08x_reports_t |
| Contains report implementations. | |
Public Member Functions | |
| BNO08x (bno08x_config_t imu_config=bno08x_config_t()) | |
| BNO08x imu constructor. | |
| ~BNO08x () | |
| BNO08x imu deconstructor. | |
| bool | initialize () |
| Initializes BNO08x sensor. | |
| bool | hard_reset () |
| Hard resets BNO08x device. | |
| bool | soft_reset () |
| Soft resets BNO08x device by sending RESET (1) command on "device" channel. | |
| BNO08xResetReason | get_reset_reason () |
| Returns reason for previous reset via product ID report. | |
| bool | on () |
| Places BNO08x device in on state by sending ON (2) command on "device" channel. | |
| bool | sleep () |
| Places BNO08x device in sleep state by sending SLEEP (3) command on "device" channel. | |
| bool | calibration_start (uint32_t period_us) |
| Starts simple calibration, see ref. manual 6.4.10.1. | |
| bool | calibration_end (sh2_CalStatus_t &status) |
| Ends turn-table calibration, see ref. manual 6.4.10.2. | |
| bool | dynamic_calibration_enable (BNO08xCalSel sensor) |
| Enables dynamic/motion engine calibration for specified sensor(s), see ref. manual 6.4.6.1. | |
| bool | dynamic_calibration_disable (BNO08xCalSel sensor) |
| Disables dynamic/motion engine calibration for specified sensor(s), see ref. manual 6.4.6.1. | |
| bool | dynamic_calibration_autosave_enable () |
| Enables the automatic saving of dynamic/ME calibration data to BNO08x internal flash See ref manual 6.4.7.1. | |
| bool | dynamic_calibration_autosave_disable () |
| Disables the automatic saving of dynamic/ME calibration data to BNO08x internal flash See ref manual 6.4.7.1. | |
| bool | save_dynamic_calibration () |
| Saves dynamic/motion engine calibration data to BNO08x internal flash immediately. See ref manual 6.4.5.1. | |
| bool | clear_dynamic_calibration () |
| Clears dynamic/motion engine calibration data and resets BNO08x device. See ref manual 6.4.9.1. | |
| bool | get_frs (uint16_t frs_ID, uint32_t(&data)[16], uint16_t &rx_data_sz) |
| Retrieves a record from flash record system (if your goal is to retrieve meta data use the BNO08xRpt:get_meta_data() method instead) | |
| sh2_ProductIds_t | get_product_IDs () |
| Returns product ID info sent by IMU at initialization. | |
| bool | data_available () |
| Polls for new data/report to become available. | |
| bool | register_cb (std::function< void(void)> cb_fxn) |
| Registers a callback to execute when new data from a report is received. | |
| bool | register_cb (std::function< void(uint8_t report_ID)> cb_fxn) |
| Registers a callback to execute when new data from a report is received, overloaded with callback param for most recent report ID. | |
| void | print_product_ids () |
| Prints product IDs received at initialization. | |
Static Public Member Functions | |
| static const char * | activity_to_str (BNO08xActivity activity) |
| Converts a BNO08xActivity enum to string. | |
| static const char * | stability_to_str (BNO08xStability stability) |
| Converts a BNO08xStability enum to string. | |
| static const char * | accuracy_to_str (BNO08xAccuracy accuracy) |
Public Attributes | |
| bno08x_reports_t | rpt |
Private Member Functions | |
| void | data_proc_task () |
| Task responsible for parsing/handling sensor events sent by SH2 HAL and updating data that is returned to user. | |
| void | sh2_HAL_service_task () |
| Task responsible for calling shtp_service() when HINT is asserted to dispatch any sh2 HAL lib callbacks. | |
| void | cb_task () |
| Task responsible for executing callbacks registered with register_cb(). | |
| void | lock_sh2_HAL () |
| Locks sh2 HAL lib to only allow the calling task to call its APIs. | |
| void | unlock_sh2_HAL () |
| Unlocks sh2 HAL lib to allow other tasks to call its APIs. | |
| void | lock_user_data () |
| Locks locks user data to only allow the calling task to read/modify it. | |
| void | unlock_user_data () |
| Unlocks user data to allow other tasks to read/modify it. | |
| void | handle_sensor_report (sh2_SensorValue_t *sensor_val) |
| Parses receieved report and updates uer data with it. | |
| void | handle_cb (uint8_t rpt_ID, BNO08xCbGeneric *cb_entry) |
| Determines the flavor of a passed callback and executes it appropriately. | |
| esp_err_t | init_config_args () |
| Initializes required esp-idf SPI data structures with values from user passed bno08x_config_t struct. | |
| esp_err_t | init_gpio () |
| Initializes required gpio. | |
| esp_err_t | init_gpio_inputs () |
| Initializes required gpio inputs. | |
| esp_err_t | init_gpio_outputs () |
| Initializes required gpio outputs. | |
| esp_err_t | init_hint_isr () |
| Initializes host interrupt ISR. | |
| esp_err_t | init_spi () |
| Initializes SPI. | |
| esp_err_t | init_tasks () |
| Initializes data_proc_task. | |
| esp_err_t | init_sh2_HAL () |
| Initializes sh2 HAL. | |
| esp_err_t | deinit_gpio () |
| Deinitializes GPIO, called from deconstructor. | |
| esp_err_t | deinit_gpio_inputs () |
| Deinitializes GPIO inputs, called from deconstructor. | |
| esp_err_t | deinit_gpio_outputs () |
| Deinitializes GPIO outputs, called from deconstructor. | |
| esp_err_t | deinit_hint_isr () |
| Deinitializes host interrupt ISR, called from deconstructor. | |
| esp_err_t | deinit_spi () |
| Deinitializes SPI. | |
| esp_err_t | deinit_tasks () |
| Deinitializes tasks used by BNO08x driver. | |
| esp_err_t | deinit_sh2_HAL () |
| Deinitializes sh2 HAL. | |
| esp_err_t | wait_for_hint () |
| Waits for HINT pin assertion or HOST_INT_TIMEOUT_DEFAULT_MS to elapse. | |
| esp_err_t | wait_for_reset () |
| Waits for SH2 HAL lib to detect reset or HOST_INT_TIMEOUT_DEFAULT_MS to elapse. | |
| void | toggle_reset () |
| Toggles reset gpio pin for hard reset of BNO08x device. | |
| esp_err_t | re_enable_reports () |
| Re-enables all reports enabled by user (called when BNO08x reset is detected by sh2 HAL lib). | |
Static Private Member Functions | |
| static void | data_proc_task_trampoline (void *arg) |
| Static function used to launch data processing task. | |
| static void | sh2_HAL_service_task_trampoline (void *arg) |
| Static function used to launch sh2 HAL service task. | |
| static void | cb_task_trampoline (void *arg) |
| Static function used to launch cb_task task. | |
| static void IRAM_ATTR | hint_handler (void *arg) |
| HINT interrupt service routine, handles falling edge of BNO08x HINT pin. | |
Private Attributes | |
| TaskHandle_t | data_proc_task_hdl |
| data_proc_task() task handle | |
| TaskHandle_t | sh2_HAL_service_task_hdl |
| sh2_HAL_service_task() task handle | |
| TaskHandle_t | cb_task_hdl |
| sh2_HAL_service_task() task handle | |
| SemaphoreHandle_t | sem_kill_tasks |
| Counting Semaphore to count amount of killed tasks. | |
| sh2_Hal_t | sh2_HAL |
| sh2 hardware abstraction layer struct for use with sh2 HAL lib. | |
| QueueHandle_t | queue_rx_sensor_event |
| Queue to send sensor events from sh2 HAL sensor event callback (BNO08xSH2HAL::sensor_event_cb()) to data_proc_task() | |
| QueueHandle_t | queue_cb_report_id |
| Queue to send report ID of most recent report to cb_task() | |
| bno08x_config_t | imu_config {} |
| IMU configuration settings. | |
| spi_bus_config_t | bus_config {} |
| SPI bus GPIO configuration settings. | |
| spi_device_interface_config_t | imu_spi_config {} |
| SPI slave device settings. | |
| spi_device_handle_t | spi_hdl {} |
| SPI device handle. | |
| spi_transaction_t | spi_transaction {} |
| SPI transaction handle. | |
| BNO08xPrivateTypes::bno08x_init_status_t | init_status |
| Initialization status of various functionality, used by deconstructor during cleanup, set during initialization. | |
| BNO08xPrivateTypes::bno08x_sync_ctx_t | sync_ctx |
| Holds context used to synchronize tasks and callback execution. | |
| sh2_ProductIds_t | product_IDs |
| Product ID info returned IMU at initialization, can be viewed with print_product_ids() | |
| etl::map< uint8_t, BNO08xRpt *, TOTAL_RPT_COUNT, etl::less< uint8_t > > | usr_reports |
Static Private Attributes | |
| static const constexpr configSTACK_DEPTH_TYPE | DATA_PROC_TASK_SZ |
| Size of data_proc_task() stack in bytes. | |
| static const constexpr configSTACK_DEPTH_TYPE | SH2_HAL_SERVICE_TASK_SZ |
| Size of sh2_HAL_service_task() stack in bytes. | |
| static const constexpr configSTACK_DEPTH_TYPE | CB_TASK_SZ |
| Size of sh2_HAL_service_task() stack in bytes. | |
| static const constexpr uint16_t | RX_DATA_LENGTH = 300U |
| length buffer containing data received over spi | |
| static const constexpr TickType_t | HOST_INT_TIMEOUT_DEFAULT_MS |
| Max wait between HINT being asserted by BNO08x before transaction is considered failed (in miliseconds). | |
| static const constexpr TickType_t | DATA_AVAILABLE_TIMEOUT_MS |
| Max wait between data_available() being called and no new data/report being detected. | |
| static const constexpr TickType_t | HARD_RESET_DELAY_MS |
| How long RST pin is held low during hard reset (min 10ns according to datasheet, but should be longer for stable operation) | |
| static const constexpr uint32_t | SCLK_MAX_SPEED = 3000000UL |
| Max SPI SCLK speed BNO08x is capable of. | |
| static const constexpr char * | TAG = "BNO08x" |
| Class tag used for serial print statements. | |
Friends | |
| class | BNO08xSH2HAL |
| class | BNO08xTestHelper |
BNO08x IMU driver class.
| typedef struct BNO08x::bno08x_reports_t BNO08x::bno08x_reports_t |
Contains report implementations.
| BNO08x::BNO08x | ( | bno08x_config_t | imu_config = bno08x_config_t() | ) |
BNO08x imu constructor.
Construct a BNO08x object for managing a BNO08x sensor.
| imu_config | Configuration settings (optional), default settings can be seen in bno08x_config_t |
| BNO08x::~BNO08x | ( | ) |
|
static |

|
static |
Converts a BNO08xActivity enum to string.
| bool BNO08x::calibration_end | ( | sh2_CalStatus_t & | status | ) |
Ends turn-table calibration, see ref. manual 6.4.10.2.
| status | Returned status bits indicating result of turntable calibration. |

| bool BNO08x::calibration_start | ( | uint32_t | period_us | ) |
Starts simple calibration, see ref. manual 6.4.10.1.
| period_us | This interval should be set to whatever rate the sensor hub is expected to run at after calibration. |
After the calibration is started, the IMU should be rotated 180 degrees. After the IMU has been rotated call calibration_end(). See ref. manual 6.4.10 for more detailed instructions.

|
private |
Task responsible for executing callbacks registered with register_cb().


|
staticprivate |
| bool BNO08x::clear_dynamic_calibration | ( | ) |
Clears dynamic/motion engine calibration data and resets BNO08x device. See ref manual 6.4.9.1.


| bool BNO08x::data_available | ( | ) |
Polls for new data/report to become available.

|
private |
Task responsible for parsing/handling sensor events sent by SH2 HAL and updating data that is returned to user.


|
staticprivate |
Static function used to launch data processing task.
Used such that data_proc_task() can be non-static class member.
| arg | void pointer to BNO08x imu object |


|
private |
Deinitializes GPIO, called from deconstructor.


|
private |
Deinitializes GPIO inputs, called from deconstructor.

|
private |
Deinitializes GPIO outputs, called from deconstructor.

|
private |
Deinitializes host interrupt ISR, called from deconstructor.

|
private |
Deinitializes sh2 HAL.

|
private |
Deinitializes SPI.

|
private |
Deinitializes tasks used by BNO08x driver.

| bool BNO08x::dynamic_calibration_autosave_disable | ( | ) |
Disables the automatic saving of dynamic/ME calibration data to BNO08x internal flash See ref manual 6.4.7.1.


| bool BNO08x::dynamic_calibration_autosave_enable | ( | ) |
Enables the automatic saving of dynamic/ME calibration data to BNO08x internal flash See ref manual 6.4.7.1.


| bool BNO08x::dynamic_calibration_disable | ( | BNO08xCalSel | sensor | ) |
Disables dynamic/motion engine calibration for specified sensor(s), see ref. manual 6.4.6.1.
| sensor | The sensor(s) to disable dynamic/ME calibration for. |


| bool BNO08x::dynamic_calibration_enable | ( | BNO08xCalSel | sensor | ) |
Enables dynamic/motion engine calibration for specified sensor(s), see ref. manual 6.4.6.1.
| sensor | The sensor(s) to enable dynamic/ME calibration for. |


| bool BNO08x::get_frs | ( | uint16_t | frs_ID, |
| uint32_t(&) | data[16], | ||
| uint16_t & | rx_data_sz ) |
Retrieves a record from flash record system (if your goal is to retrieve meta data use the BNO08xRpt:get_meta_data() method instead)
For more details on returned and data and frs_ID see ref. manual 6.3.7 & 4.3
| frs_ID | The ID of the desired record to retrieve from flash. |
| data | Buffer of 16 uint32_t to store retrieved data. |
| rx_data_sz | Reference to store number of 32 bit words retrieved from flash. |

| sh2_ProductIds_t BNO08x::get_product_IDs | ( | ) |
Returns product ID info sent by IMU at initialization.
| BNO08xResetReason BNO08x::get_reset_reason | ( | ) |
Returns reason for previous reset via product ID report.


|
private |
Determines the flavor of a passed callback and executes it appropriately.


|
private |
Parses receieved report and updates uer data with it.

| bool BNO08x::hard_reset | ( | ) |
Hard resets BNO08x device.


|
staticprivate |
|
private |
Initializes required esp-idf SPI data structures with values from user passed bno08x_config_t struct.

|
private |
Initializes required gpio.


|
private |
Initializes required gpio inputs.

|
private |
Initializes required gpio outputs.

|
private |
Initializes host interrupt ISR.


|
private |
Initializes sh2 HAL.


|
private |
Initializes SPI.

|
private |
Initializes data_proc_task.


| bool BNO08x::initialize | ( | ) |
Initializes BNO08x sensor.
Resets sensor and goes through initialization process. Configures GPIO, required ISRs, and launches two tasks, one to manage SPI transactions, another to process any received data.


|
private |
Locks sh2 HAL lib to only allow the calling task to call its APIs.

|
private |
Locks locks user data to only allow the calling task to read/modify it.
| bool BNO08x::on | ( | ) |
Places BNO08x device in on state by sending ON (2) command on "device" channel.


| void BNO08x::print_product_ids | ( | ) |
Prints product IDs received at initialization.

|
private |
Re-enables all reports enabled by user (called when BNO08x reset is detected by sh2 HAL lib).

| bool BNO08x::register_cb | ( | std::function< void(uint8_t report_ID)> | cb_fxn | ) |
Registers a callback to execute when new data from a report is received, overloaded with callback param for most recent report ID.
| cb_fxn | Pointer to the call-back function should be of void return type with single input param of uint8_t for most recent report ID. |
| bool BNO08x::register_cb | ( | std::function< void(void)> | cb_fxn | ) |
Registers a callback to execute when new data from a report is received.
| cb_fxn | Pointer to the call-back function should be of void return type void input param. |

| bool BNO08x::save_dynamic_calibration | ( | ) |
Saves dynamic/motion engine calibration data to BNO08x internal flash immediately. See ref manual 6.4.5.1.


|
private |
Task responsible for calling shtp_service() when HINT is asserted to dispatch any sh2 HAL lib callbacks.


|
staticprivate |
Static function used to launch sh2 HAL service task.
Used such that sh2_HAL_service_task() can be non-static class member.
| arg | void pointer to BNO08x imu object |


| bool BNO08x::sleep | ( | ) |
Places BNO08x device in sleep state by sending SLEEP (3) command on "device" channel.


| bool BNO08x::soft_reset | ( | ) |
Soft resets BNO08x device by sending RESET (1) command on "device" channel.


|
static |
Converts a BNO08xStability enum to string.
|
private |
Toggles reset gpio pin for hard reset of BNO08x device.

|
private |
Unlocks sh2 HAL lib to allow other tasks to call its APIs.

|
private |
Unlocks user data to allow other tasks to read/modify it.
|
private |
Waits for HINT pin assertion or HOST_INT_TIMEOUT_DEFAULT_MS to elapse.

|
private |
Waits for SH2 HAL lib to detect reset or HOST_INT_TIMEOUT_DEFAULT_MS to elapse.

|
friend |
|
friend |
|
private |
SPI bus GPIO configuration settings.
|
private |
sh2_HAL_service_task() task handle
|
staticconstexprprivate |
Size of sh2_HAL_service_task() stack in bytes.
|
staticconstexprprivate |
Max wait between data_available() being called and no new data/report being detected.
|
private |
data_proc_task() task handle
|
staticconstexprprivate |
Size of data_proc_task() stack in bytes.
|
staticconstexprprivate |
How long RST pin is held low during hard reset (min 10ns according to datasheet, but should be longer for stable operation)
|
staticconstexprprivate |
Max wait between HINT being asserted by BNO08x before transaction is considered failed (in miliseconds).
|
private |
IMU configuration settings.
|
private |
SPI slave device settings.
|
private |
Initialization status of various functionality, used by deconstructor during cleanup, set during initialization.
|
private |
Product ID info returned IMU at initialization, can be viewed with print_product_ids()
|
private |
Queue to send report ID of most recent report to cb_task()
|
private |
Queue to send sensor events from sh2 HAL sensor event callback (BNO08xSH2HAL::sensor_event_cb()) to data_proc_task()
| bno08x_reports_t BNO08x::rpt |
|
staticconstexprprivate |
length buffer containing data received over spi
|
staticconstexprprivate |
Max SPI SCLK speed BNO08x is capable of.
|
private |
Counting Semaphore to count amount of killed tasks.
|
private |
sh2 hardware abstraction layer struct for use with sh2 HAL lib.
|
private |
sh2_HAL_service_task() task handle
|
staticconstexprprivate |
Size of sh2_HAL_service_task() stack in bytes.
|
private |
SPI device handle.
|
private |
SPI transaction handle.
|
private |
Holds context used to synchronize tasks and callback execution.
|
staticconstexprprivate |
Class tag used for serial print statements.
|
private |