# esp32_BNO08x: include/BNO08xPrivateTypes.hpp Source File

Loading...
Searching...
No Matches
BNO08xPrivateTypes.hpp
Go to the documentation of this file.
#pragma once
// etl includes
#include <etl/vector.h>
#include <etl/variant.h>
// esp-idf includes
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
#include <freertos/event_groups.h>
// in-house includes
#include "BNO08xGlobalTypes.hpp"
#include "BNO08xCbParamRptID.hpp"
#include "BNO08xCbParamVoid.hpp"
namespace BNO08xPrivateTypes
{
using bno08x_cb_list_t = etl::vector<etl::variant<BNO08xCbParamVoid, BNO08xCbParamRptID>,
CONFIG_ESP32_BNO08X_CB_MAX>;
typedef struct bno08x_init_status_t
{
bool gpio_outputs;
bool gpio_inputs;
bool isr_service;
bool isr_handler;
bool spi_bus;
bool spi_device;
bool data_proc_task;
bool sh2_HAL_service_task;
bool cb_task;
bool sh2_HAL;
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)
, cb_task(false)
, sh2_HAL(false)
{
}
} bno08x_init_status_t;
typedef struct bno08x_sync_ctx_t
{
SemaphoreHandle_t sh2_HAL_lock;
SemaphoreHandle_t
data_lock;
EventGroupHandle_t evt_grp_rpt_en;
EventGroupHandle_t
evt_grp_rpt_data_available;
EventGroupHandle_t evt_grp_task;
etl::vector<uint8_t, TOTAL_RPT_COUNT> en_report_ids;
bno08x_cb_list_t cb_list;
bno08x_sync_ctx_t()
: sh2_HAL_lock(xSemaphoreCreateMutex())
, data_lock(xSemaphoreCreateMutex())
, evt_grp_rpt_en(xEventGroupCreate())
, evt_grp_rpt_data_available(xEventGroupCreate())
, evt_grp_task(xEventGroupCreate())
{
}
} bno08x_sync_ctx_t;
enum bno08x_rpt_bit_t : EventBits_t
{
EVT_GRP_RPT_RV_BIT = (1UL << 0U),
EVT_GRP_RPT_RV_GAME_BIT = (1UL << 1U),
EVT_GRP_RPT_RV_ARVR_S_BIT = (1UL << 2U),
EVT_GRP_RPT_RV_ARVR_S_GAME_BIT = (1UL << 3U),
EVT_GRP_RPT_GYRO_INTEGRATED_RV_BIT = (1UL << 4U),
EVT_GRP_RPT_GEOMAG_RV_BIT = (1UL << 5U),
EVT_GRP_RPT_ACCELEROMETER_BIT = (1UL << 6U),
EVT_GRP_RPT_LINEAR_ACCELEROMETER_BIT = (1UL << 7U),
EVT_GRP_RPT_GRAVITY_BIT = (1UL << 8U),
EVT_GRP_RPT_CAL_GYRO_BIT = (1UL << 9U),
EVT_GRP_RPT_UNCAL_GYRO_BIT = (1UL << 10U),
EVT_GRP_RPT_CAL_MAGNETOMETER_BIT = (1UL << 11U),
EVT_GRP_RPT_UNCAL_MAGNETOMETER_BIT = (1UL << 12U),
EVT_GRP_RPT_TAP_DETECTOR_BIT = (1UL << 13U),
EVT_GRP_RPT_STEP_COUNTER_BIT = (1UL << 14U),
EVT_GRP_RPT_STABILITY_CLASSIFIER_BIT = (1UL << 15U),
EVT_GRP_RPT_ACTIVITY_CLASSIFIER_BIT = (1UL << 16U),
EVT_GRP_RPT_SHAKE_DETECTOR_BIT = (1UL << 17U),
EVT_GRP_RPT_RAW_ACCELEROMETER_BIT = (1UL << 18U),
EVT_GRP_RPT_RAW_GYRO_BIT = (1UL << 19U),
EVT_GRP_RPT_RAW_MAGNETOMETER_BIT = (1UL << 20U),
EVT_GRP_RPT_CIRCLE_DETECTOR_BIT = (1UL << 21U),
EVT_GRP_RPT_ALL = EVT_GRP_RPT_RV_BIT | EVT_GRP_RPT_RV_GAME_BIT | EVT_GRP_RPT_RV_ARVR_S_BIT |
EVT_GRP_RPT_RV_ARVR_S_GAME_BIT | EVT_GRP_RPT_LINEAR_ACCELEROMETER_BIT | EVT_GRP_RPT_GRAVITY_BIT |
EVT_GRP_RPT_CAL_GYRO_BIT | EVT_GRP_RPT_UNCAL_GYRO_BIT | EVT_GRP_RPT_CAL_MAGNETOMETER_BIT |
EVT_GRP_RPT_TAP_DETECTOR_BIT | EVT_GRP_RPT_STEP_COUNTER_BIT | EVT_GRP_RPT_STABILITY_CLASSIFIER_BIT |
EVT_GRP_RPT_ACTIVITY_CLASSIFIER_BIT | EVT_GRP_RPT_RAW_ACCELEROMETER_BIT | EVT_GRP_RPT_RAW_GYRO_BIT |
EVT_GRP_RPT_RAW_MAGNETOMETER_BIT | EVT_GRP_RPT_UNCAL_MAGNETOMETER_BIT | EVT_GRP_RPT_SHAKE_DETECTOR_BIT |
EVT_GRP_RPT_ACCELEROMETER_BIT | EVT_GRP_RPT_GEOMAG_RV_BIT | EVT_GRP_RPT_GYRO_INTEGRATED_RV_BIT |
EVT_GRP_RPT_CIRCLE_DETECTOR_BIT
};
enum bno08x_tsk_bit_t : EventBits_t
{
EVT_GRP_BNO08x_TASKS_RUNNING =
(1UL << 0U),
EVT_GRP_BNO08x_TASK_HINT_ASSRT_BIT =
(1UL << 1U),
EVT_GRP_BNO08x_TASK_RESET_OCCURRED =
(1UL << 2U),
EVT_GRP_BNO08x_TASK_DATA_AVAILABLE =
(1UL << 3U)
};
inline static sh2_SensorConfig default_sensor_cfg = {
.changeSensitivityEnabled = false,
.changeSensitivityRelative = false,
.wakeupEnabled = false,
.alwaysOnEnabled = false,
.changeSensitivity = 0,
.reportInterval_us = 0,
.batchInterval_us = 0,
.sensorSpecific = 0};
}; // namespace BNO08xPrivateTypes
BNO08xCbParamRptID.hpp
BNO08xCbParamVoid.hpp
BNO08xGlobalTypes.hpp
BNO08xPrivateTypes
Definition BNO08xPrivateTypes.hpp:21
BNO08xPrivateTypes::bno08x_init_status_t
struct BNO08xPrivateTypes::bno08x_init_status_t bno08x_init_status_t
Holds info about which functionality has been successfully initialized (used by deconstructor during ...
BNO08xPrivateTypes::default_sensor_cfg
static sh2_SensorConfig default_sensor_cfg
Definition BNO08xPrivateTypes.hpp:127
BNO08xPrivateTypes::bno08x_tsk_bit_t
bno08x_tsk_bit_t
Bits for evt_grp_bno08x_task.
Definition BNO08xPrivateTypes.hpp:116
BNO08xPrivateTypes::EVT_GRP_BNO08x_TASK_DATA_AVAILABLE
@ EVT_GRP_BNO08x_TASK_DATA_AVAILABLE
When this bit is set it indicates a report has been received for the user to read,...
Definition BNO08xPrivateTypes.hpp:123
BNO08xPrivateTypes::EVT_GRP_BNO08x_TASKS_RUNNING
@ EVT_GRP_BNO08x_TASKS_RUNNING
When this bit is set it indicates the BNO08x tasks are running, it is always set to 1 for the duratio...
Definition BNO08xPrivateTypes.hpp:117
BNO08xPrivateTypes::EVT_GRP_BNO08x_TASK_HINT_ASSRT_BIT
@ EVT_GRP_BNO08x_TASK_HINT_ASSRT_BIT
When this bit is set it indicates the BNO08x has asserted its host interrupt pin, thus an SPI transac...
Definition BNO08xPrivateTypes.hpp:119
BNO08xPrivateTypes::EVT_GRP_BNO08x_TASK_RESET_OCCURRED
@ EVT_GRP_BNO08x_TASK_RESET_OCCURRED
When this bit is set it indicates the SH2 HAL lib has reset the IMU, any reports enabled by the user ...
Definition BNO08xPrivateTypes.hpp:121
BNO08xPrivateTypes::bno08x_sync_ctx_t
struct BNO08xPrivateTypes::bno08x_sync_ctx_t bno08x_sync_ctx_t
Holds context used to synchronize tasks and callback execution.
BNO08xPrivateTypes::bno08x_cb_list_t
etl::vector< etl::variant< BNO08xCbParamVoid, BNO08xCbParamRptID >, CONFIG_ESP32_BNO08X_CB_MAX > bno08x_cb_list_t
Alias for vector type to contain both cb flavors.
Definition BNO08xPrivateTypes.hpp:22
BNO08xPrivateTypes::bno08x_rpt_bit_t
bno08x_rpt_bit_t
Bits for evt_grp_rpt_en & evt_grp_rpt_data_available.
Definition BNO08xPrivateTypes.hpp:80
BNO08xPrivateTypes::EVT_GRP_RPT_UNCAL_GYRO_BIT
@ EVT_GRP_RPT_UNCAL_GYRO_BIT
When set, uncalibrated gyro reports are active.
Definition BNO08xPrivateTypes.hpp:91
BNO08xPrivateTypes::EVT_GRP_RPT_GYRO_INTEGRATED_RV_BIT
@ EVT_GRP_RPT_GYRO_INTEGRATED_RV_BIT
When set, gyro integrator rotation vector reports are active.
Definition BNO08xPrivateTypes.hpp:85
BNO08xPrivateTypes::EVT_GRP_RPT_LINEAR_ACCELEROMETER_BIT
@ EVT_GRP_RPT_LINEAR_ACCELEROMETER_BIT
When set, linear accelerometer reports are active.
Definition BNO08xPrivateTypes.hpp:88
BNO08xPrivateTypes::EVT_GRP_RPT_ALL
@ EVT_GRP_RPT_ALL
Definition BNO08xPrivateTypes.hpp:104
BNO08xPrivateTypes::EVT_GRP_RPT_GEOMAG_RV_BIT
@ EVT_GRP_RPT_GEOMAG_RV_BIT
When set, geomagnetic rotation vector reports are active.
Definition BNO08xPrivateTypes.hpp:86
BNO08xPrivateTypes::EVT_GRP_RPT_ACTIVITY_CLASSIFIER_BIT
@ EVT_GRP_RPT_ACTIVITY_CLASSIFIER_BIT
When set, activity classifier reports are active.
Definition BNO08xPrivateTypes.hpp:97
BNO08xPrivateTypes::EVT_GRP_RPT_UNCAL_MAGNETOMETER_BIT
@ EVT_GRP_RPT_UNCAL_MAGNETOMETER_BIT
When set, uncalibrated magnetometer reports are active.
Definition BNO08xPrivateTypes.hpp:93
BNO08xPrivateTypes::EVT_GRP_RPT_ACCELEROMETER_BIT
@ EVT_GRP_RPT_ACCELEROMETER_BIT
When set, accelerometer reports are active.
Definition BNO08xPrivateTypes.hpp:87
BNO08xPrivateTypes::EVT_GRP_RPT_RAW_MAGNETOMETER_BIT
@ EVT_GRP_RPT_RAW_MAGNETOMETER_BIT
When set, raw magnetometer reports are active.
Definition BNO08xPrivateTypes.hpp:101
BNO08xPrivateTypes::EVT_GRP_RPT_RV_ARVR_S_BIT
@ EVT_GRP_RPT_RV_ARVR_S_BIT
When set, ARVR stabilized rotation vector reports are active.
Definition BNO08xPrivateTypes.hpp:83
BNO08xPrivateTypes::EVT_GRP_RPT_CIRCLE_DETECTOR_BIT
@ EVT_GRP_RPT_CIRCLE_DETECTOR_BIT
When set, circle detector reports are active.
Definition BNO08xPrivateTypes.hpp:102
BNO08xPrivateTypes::EVT_GRP_RPT_RV_ARVR_S_GAME_BIT
@ EVT_GRP_RPT_RV_ARVR_S_GAME_BIT
When set, ARVR stabilized game rotation vector reports are active.
Definition BNO08xPrivateTypes.hpp:84
BNO08xPrivateTypes::EVT_GRP_RPT_RAW_ACCELEROMETER_BIT
@ EVT_GRP_RPT_RAW_ACCELEROMETER_BIT
When set, raw accelerometer reports are active.
Definition BNO08xPrivateTypes.hpp:99
BNO08xPrivateTypes::EVT_GRP_RPT_GRAVITY_BIT
@ EVT_GRP_RPT_GRAVITY_BIT
When set, gravity reports are active.
Definition BNO08xPrivateTypes.hpp:89
BNO08xPrivateTypes::EVT_GRP_RPT_RV_BIT
@ EVT_GRP_RPT_RV_BIT
When set, rotation vector reports are active.
Definition BNO08xPrivateTypes.hpp:81
BNO08xPrivateTypes::EVT_GRP_RPT_CAL_MAGNETOMETER_BIT
@ EVT_GRP_RPT_CAL_MAGNETOMETER_BIT
When set, calibrated magnetometer reports are active.
Definition BNO08xPrivateTypes.hpp:92
BNO08xPrivateTypes::EVT_GRP_RPT_RV_GAME_BIT
@ EVT_GRP_RPT_RV_GAME_BIT
When set, game rotation vector reports are active.
Definition BNO08xPrivateTypes.hpp:82
BNO08xPrivateTypes::EVT_GRP_RPT_TAP_DETECTOR_BIT
@ EVT_GRP_RPT_TAP_DETECTOR_BIT
When set, tap detector reports are active.
Definition BNO08xPrivateTypes.hpp:94
BNO08xPrivateTypes::EVT_GRP_RPT_SHAKE_DETECTOR_BIT
@ EVT_GRP_RPT_SHAKE_DETECTOR_BIT
When set, shake detector reports are active.
Definition BNO08xPrivateTypes.hpp:98
BNO08xPrivateTypes::EVT_GRP_RPT_RAW_GYRO_BIT
@ EVT_GRP_RPT_RAW_GYRO_BIT
When set, raw gyro reports are active.
Definition BNO08xPrivateTypes.hpp:100
BNO08xPrivateTypes::EVT_GRP_RPT_STABILITY_CLASSIFIER_BIT
@ EVT_GRP_RPT_STABILITY_CLASSIFIER_BIT
When set, stability classifier reports are active.
Definition BNO08xPrivateTypes.hpp:96
BNO08xPrivateTypes::EVT_GRP_RPT_CAL_GYRO_BIT
@ EVT_GRP_RPT_CAL_GYRO_BIT
When set, calibrated gyro reports are active.
Definition BNO08xPrivateTypes.hpp:90
BNO08xPrivateTypes::EVT_GRP_RPT_STEP_COUNTER_BIT
@ EVT_GRP_RPT_STEP_COUNTER_BIT
When set, step counter reports are active.
Definition BNO08xPrivateTypes.hpp:95
BNO08xPrivateTypes::bno08x_init_status_t
Holds info about which functionality has been successfully initialized (used by deconstructor during ...
Definition BNO08xPrivateTypes.hpp:28
BNO08xPrivateTypes::bno08x_init_status_t::sh2_HAL_service_task
bool sh2_HAL_service_task
True if xTaskCreate has been called successfully for sh2_HAL_service_task.
Definition BNO08xPrivateTypes.hpp:36
BNO08xPrivateTypes::bno08x_init_status_t::isr_service
bool isr_service
True if global ISR service has been initialized.
Definition BNO08xPrivateTypes.hpp:31
BNO08xPrivateTypes::bno08x_init_status_t::sh2_HAL
bool sh2_HAL
True if sh2_open() has been called successfully.
Definition BNO08xPrivateTypes.hpp:38
BNO08xPrivateTypes::bno08x_init_status_t::bno08x_init_status_t
bno08x_init_status_t()
Definition BNO08xPrivateTypes.hpp:40
BNO08xPrivateTypes::bno08x_init_status_t::isr_handler
bool isr_handler
True if HINT ISR handler has been initialized.
Definition BNO08xPrivateTypes.hpp:32
BNO08xPrivateTypes::bno08x_init_status_t::spi_bus
bool spi_bus
True if spi_bus_initialize() has been called successfully.
Definition BNO08xPrivateTypes.hpp:33
BNO08xPrivateTypes::bno08x_init_status_t::gpio_inputs
bool gpio_inputs
True if GPIO inputs have been initialized.
Definition BNO08xPrivateTypes.hpp:30
BNO08xPrivateTypes::bno08x_init_status_t::spi_device
bool spi_device
True if spi_bus_add_device() has been called successfully.
Definition BNO08xPrivateTypes.hpp:34
BNO08xPrivateTypes::bno08x_init_status_t::gpio_outputs
bool gpio_outputs
True if GPIO outputs have been initialized.
Definition BNO08xPrivateTypes.hpp:29
BNO08xPrivateTypes::bno08x_init_status_t::cb_task
bool cb_task
True if xTaskCreate has been called successfully for cb_task.
Definition BNO08xPrivateTypes.hpp:37
BNO08xPrivateTypes::bno08x_init_status_t::data_proc_task
bool data_proc_task
True if xTaskCreate has been called successfully for data_proc_task.
Definition BNO08xPrivateTypes.hpp:35
BNO08xPrivateTypes::bno08x_sync_ctx_t
Holds context used to synchronize tasks and callback execution.
Definition BNO08xPrivateTypes.hpp:57
BNO08xPrivateTypes::bno08x_sync_ctx_t::evt_grp_rpt_data_available
EventGroupHandle_t evt_grp_rpt_data_available
Event group for indicating to BNO08xRpt::has_new_data() that a module received a new report.
Definition BNO08xPrivateTypes.hpp:63
BNO08xPrivateTypes::bno08x_sync_ctx_t::bno08x_sync_ctx_t
bno08x_sync_ctx_t()
Definition BNO08xPrivateTypes.hpp:68
BNO08xPrivateTypes::bno08x_sync_ctx_t::sh2_HAL_lock
SemaphoreHandle_t sh2_HAL_lock
Mutex to prevent sh2 HAL lib functions from being accessed at same time.
Definition BNO08xPrivateTypes.hpp:58
BNO08xPrivateTypes::bno08x_sync_ctx_t::data_lock
SemaphoreHandle_t data_lock
Mutex to prevent user from reading data while data_proc_task() updates it, and vice versa.
Definition BNO08xPrivateTypes.hpp:60
BNO08xPrivateTypes::bno08x_sync_ctx_t::en_report_ids
etl::vector< uint8_t, TOTAL_RPT_COUNT > en_report_ids
Vector to contain IDs of currently enabled reports.
Definition BNO08xPrivateTypes.hpp:65
BNO08xPrivateTypes::bno08x_sync_ctx_t::evt_grp_task
EventGroupHandle_t evt_grp_task
Event group for indicating various BNO08x related events between tasks.
Definition BNO08xPrivateTypes.hpp:64
BNO08xPrivateTypes::bno08x_sync_ctx_t::cb_list
bno08x_cb_list_t cb_list
Vector to contain registered callbacks.
Definition BNO08xPrivateTypes.hpp:66
BNO08xPrivateTypes::bno08x_sync_ctx_t::evt_grp_rpt_en
EventGroupHandle_t evt_grp_rpt_en
Event group for indicating which reports are currently enabled.
Definition BNO08xPrivateTypes.hpp:61