/** * @file BNO08x.hpp * @author Myles Parfeniuk */ #pragma once // standard library includes #include #include #include #include #include #include // esp-idf includes #include #include #include #include #include #include #include // in-house includes #include "BNO08x_global_types.hpp" #include "BNO08xSH2HAL.hpp" /** * @class BNO08x * * @brief BNO08x IMU driver class. * */ class BNO08x { public: inline static sh2_SensorConfig default_sensor_cfg = {.changeSensitivityEnabled = false, /// cb_fxn); void print_product_ids(); private: /// @brief Holds info about which functionality has been successfully initialized (used by deconstructor during cleanup). typedef struct bno08x_init_status_t { bool gpio_outputs; ///< True if GPIO outputs have been initialized. bool gpio_inputs; ///< True if GPIO inputs have been initialized. bool isr_service; ///< True if global ISR service has been initialized. bool isr_handler; ///< True if HINT ISR handler has been initialized. bool spi_bus; ///< True if spi_bus_initialize() has been called successfully. bool spi_device; ///< True if spi_bus_add_device() has been called successfully. bool sh2_HAL; ///< True if sh2_open() has been called successfully. bool data_proc_task; ///< True if xTaskCreate has been called successfully for data_proc_task. bool sh2_HAL_service_task; ///< True if xTaskCreate has been called successfully for sh2_HAL_service_task. uint8_t task_init_cnt; ///< Amount of tasks that have been successfully initialized. bno08x_init_status_t() : gpio_outputs(false) , gpio_inputs(false) , isr_service(false) , isr_handler(false) , spi_bus(false) , spi_device(false) , data_proc_task(false) , sh2_HAL_service_task(false) , task_init_cnt(0) { } } bno08x_init_status_t; /// @brief Holds data returned from sensor reports. typedef struct bno08x_data_t { bno08x_accel_data_t gravity; bno08x_accel_data_t linear_acceleration; bno08x_accel_data_t acceleration; bno08x_magf_data_t cal_magnetometer; bno08x_step_counter_data_t step_counter; bno08x_activity_classifier_data_t activity_classifier; bno08x_gyro_data_t cal_gyro; bno08x_raw_gyro_data_t mems_raw_gyro; bno08x_raw_accel_data_t mems_raw_accel; bno08x_raw_magf_data_t mems_raw_magnetometer; bno08x_quat_w_acc_t rotation_vector; bno08x_data_t() : gravity({0.0f, 0.0f, 0.0f}) , linear_acceleration({0.0f, 0.0f, 0.0f}) , acceleration({0.0f, 0.0f, 0.0f}) , cal_magnetometer({0.0f, 0.0f, 0.0f}) , step_counter({0UL, 0U}) , activity_classifier({0U, false, BNO08xActivity::UNKNOWN, {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U}}) , cal_gyro({0.0f, 0.0f, 0.0f}) , mems_raw_gyro({0, 0, 0, 0, 0UL}) , mems_raw_accel({0, 0, 0, 0UL}) , mems_raw_magnetometer({0, 0, 0, 0UL}) , rotation_vector({0.0f, 0.0f, 0.0f, 0.0f, 0.0f}) { } } bno08x_data_t; typedef struct bno08x_usr_report_periods_t { uint32_t gravity; uint32_t linear_accelerometer; uint32_t accelerometer; uint32_t cal_magnetometer; uint32_t step_counter; uint32_t activity_classifier; uint32_t cal_gyro; uint32_t raw_mems_gyro; uint32_t raw_mems_accelerometer; uint32_t raw_mems_magnetometer; uint32_t rotation_vector; bno08x_usr_report_periods_t() : gravity(0UL) , linear_accelerometer(0UL) , accelerometer(0UL) , cal_magnetometer(0UL) , step_counter(0UL) , activity_classifier(0UL) , cal_gyro(0UL) , raw_mems_gyro(0UL) , raw_mems_accelerometer(0UL) , raw_mems_magnetometer(0UL) , rotation_vector(0UL) { } } bno08x_usr_report_periods_t; bno08x_data_t data; ///< Holds all data returned from enabled reports. bno08x_usr_report_periods_t user_report_periods; ///< Holds periods for reports enabled by user (0 == disabled report) // data processing task TaskHandle_t data_proc_task_hdl; ///> cb_list; // Vector for storing any call-back functions added with register_cb() bno08x_config_t imu_config{}; ///