/** * @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: BNO08x(bno08x_config_t imu_config = bno08x_config_t()); ~BNO08x(); bool initialize(); void hard_reset(); void register_cb(std::function 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. uint8_t task_count; ///< How many successfully initialized tasks (max of TSK_CNT) bool data_proc_task; ///< True if xTaskCreate has been called successfully for data_proc_task. bool spi_task; ///< True if xTaskCreate has been called successfully for spi_task. 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. bno08x_init_status_t() : gpio_outputs(false) , gpio_inputs(false) , isr_service(false) , isr_handler(false) , task_count(0) , data_proc_task(false) , spi_task(false) , spi_bus(false) , spi_device(false) { } } bno08x_init_status_t; esp_err_t init_config_args(); esp_err_t init_gpio(); esp_err_t init_gpio_inputs(); esp_err_t init_gpio_outputs(); esp_err_t init_hint_isr(); esp_err_t init_spi(); esp_err_t init_sh2_HAL(); esp_err_t deinit_gpio(); esp_err_t deinit_gpio_inputs(); esp_err_t deinit_gpio_outputs(); esp_err_t deinit_hint_isr(); esp_err_t deinit_spi(); esp_err_t deinit_sh2_HAL(); esp_err_t wait_for_hint(); sh2_Hal_t sh2_HAL; ///< SH2 hardware abstraction layer struct for use with SH-2 lib. EventGroupHandle_t evt_grp_spi; ///> cb_list; // Vector for storing any call-back functions added with register_cb() bno08x_config_t imu_config{}; ///