esp32_BNO08x 1.4 C++ BNO08x IMU driver component for esp-idf.

BNO08xPrivateTypes.hpp
Go to the documentation of this file.
1
6#pragma once
7
8// etl includes
9#include <etl/vector.h>
10#include <etl/variant.h>
11// esp-idf includes
12#include <freertos/FreeRTOS.h>
13#include <freertos/semphr.h>
14#include <freertos/event_groups.h>
15// in-house includes
16#include "BNO08xGlobalTypes.hpp"
17#include "BNO08xCbParamRptID.hpp"
18#include "BNO08xCbParamVoid.hpp"
19
20 namespace BNO08xPrivateTypes
21{
22 using bno08x_cb_list_t = etl::vector<etl::variant<BNO08xCbParamVoid, BNO08xCbParamRptID>,
23 CONFIG_ESP32_BNO08X_CB_MAX>;
24
27 typedef struct bno08x_init_status_t
28 {
29 bool gpio_outputs;
30 bool gpio_inputs;
31 bool isr_service;
32 bool isr_handler;
33 bool spi_bus;
34 bool spi_device;
35 bool data_proc_task;
36 bool sh2_HAL_service_task;
37 bool cb_task;
38 bool sh2_HAL;
39
40 bno08x_init_status_t()
41 : gpio_outputs(false)
42 , gpio_inputs(false)
43 , isr_service(false)
44 , isr_handler(false)
45 , spi_bus(false)
46 , spi_device(false)
47 , data_proc_task(false)
48 , sh2_HAL_service_task(false)
49 , cb_task(false)
50 , sh2_HAL(false)
51 {
52 }
53 } bno08x_init_status_t;
54
56 typedef struct bno08x_sync_ctx_t
57 {
58 SemaphoreHandle_t sh2_HAL_lock;
59 SemaphoreHandle_t
60 data_lock;
61 EventGroupHandle_t evt_grp_rpt_en;
62 EventGroupHandle_t
63 evt_grp_rpt_data_available;
64 EventGroupHandle_t evt_grp_task;
65 etl::vector<uint8_t, TOTAL_RPT_COUNT> en_report_ids;
66 bno08x_cb_list_t cb_list;
67
68 bno08x_sync_ctx_t()
69 : sh2_HAL_lock(xSemaphoreCreateMutex())
70 , data_lock(xSemaphoreCreateMutex())
71 , evt_grp_rpt_en(xEventGroupCreate())
72 , evt_grp_rpt_data_available(xEventGroupCreate())
73 , evt_grp_task(xEventGroupCreate())
74 {
75 }
76 } bno08x_sync_ctx_t;
77
79 enum bno08x_rpt_bit_t : EventBits_t
80 {
81 EVT_GRP_RPT_RV_BIT = (1UL << 0U),
82 EVT_GRP_RPT_RV_GAME_BIT = (1UL << 1U),
83 EVT_GRP_RPT_RV_ARVR_S_BIT = (1UL << 2U),
84 EVT_GRP_RPT_RV_ARVR_S_GAME_BIT = (1UL << 3U),
85 EVT_GRP_RPT_GYRO_INTEGRATED_RV_BIT = (1UL << 4U),
86 EVT_GRP_RPT_GEOMAG_RV_BIT = (1UL << 5U),
87 EVT_GRP_RPT_ACCELEROMETER_BIT = (1UL << 6U),
88 EVT_GRP_RPT_LINEAR_ACCELEROMETER_BIT = (1UL << 7U),
89 EVT_GRP_RPT_GRAVITY_BIT = (1UL << 8U),
90 EVT_GRP_RPT_CAL_GYRO_BIT = (1UL << 9U),
91 EVT_GRP_RPT_UNCAL_GYRO_BIT = (1UL << 10U),
92 EVT_GRP_RPT_CAL_MAGNETOMETER_BIT = (1UL << 11U),
93 EVT_GRP_RPT_UNCAL_MAGNETOMETER_BIT = (1UL << 12U),
94 EVT_GRP_RPT_TAP_DETECTOR_BIT = (1UL << 13U),
95 EVT_GRP_RPT_STEP_COUNTER_BIT = (1UL << 14U),
96 EVT_GRP_RPT_STABILITY_CLASSIFIER_BIT = (1UL << 15U),
97 EVT_GRP_RPT_ACTIVITY_CLASSIFIER_BIT = (1UL << 16U),
98 EVT_GRP_RPT_SHAKE_DETECTOR_BIT = (1UL << 17U),
99 EVT_GRP_RPT_RAW_ACCELEROMETER_BIT = (1UL << 18U),
100 EVT_GRP_RPT_RAW_GYRO_BIT = (1UL << 19U),
101 EVT_GRP_RPT_RAW_MAGNETOMETER_BIT = (1UL << 20U),
102 EVT_GRP_RPT_CIRCLE_DETECTOR_BIT = (1UL << 21U),
103
104 EVT_GRP_RPT_ALL = EVT_GRP_RPT_RV_BIT | EVT_GRP_RPT_RV_GAME_BIT | EVT_GRP_RPT_RV_ARVR_S_BIT |
105 EVT_GRP_RPT_RV_ARVR_S_GAME_BIT | EVT_GRP_RPT_LINEAR_ACCELEROMETER_BIT | EVT_GRP_RPT_GRAVITY_BIT |
106 EVT_GRP_RPT_CAL_GYRO_BIT | EVT_GRP_RPT_UNCAL_GYRO_BIT | EVT_GRP_RPT_CAL_MAGNETOMETER_BIT |
107 EVT_GRP_RPT_TAP_DETECTOR_BIT | EVT_GRP_RPT_STEP_COUNTER_BIT | EVT_GRP_RPT_STABILITY_CLASSIFIER_BIT |
108 EVT_GRP_RPT_ACTIVITY_CLASSIFIER_BIT | EVT_GRP_RPT_RAW_ACCELEROMETER_BIT | EVT_GRP_RPT_RAW_GYRO_BIT |
109 EVT_GRP_RPT_RAW_MAGNETOMETER_BIT | EVT_GRP_RPT_UNCAL_MAGNETOMETER_BIT | EVT_GRP_RPT_SHAKE_DETECTOR_BIT |
110 EVT_GRP_RPT_ACCELEROMETER_BIT | EVT_GRP_RPT_GEOMAG_RV_BIT | EVT_GRP_RPT_GYRO_INTEGRATED_RV_BIT |
111 EVT_GRP_RPT_CIRCLE_DETECTOR_BIT
112 };
113
115 enum bno08x_tsk_bit_t : EventBits_t
116 {
117 EVT_GRP_BNO08x_TASKS_RUNNING =
118 (1UL << 0U),
119 EVT_GRP_BNO08x_TASK_HINT_ASSRT_BIT =
120 (1UL << 1U),
121 EVT_GRP_BNO08x_TASK_RESET_OCCURRED =
122 (1UL << 2U),
123 EVT_GRP_BNO08x_TASK_DATA_AVAILABLE =
124 (1UL << 3U)
125 };
126
127 inline static sh2_SensorConfig default_sensor_cfg = {
128 .changeSensitivityEnabled = false,
129 .changeSensitivityRelative = false,
130 .wakeupEnabled = false,
131 .alwaysOnEnabled = false,
132 .changeSensitivity = 0,
133 .reportInterval_us = 0,
134 .batchInterval_us = 0,
135 .sensorSpecific = 0};
136}; // namespace BNO08xPrivateTypes
BNO08xCbParamRptID.hpp
BNO08xCbParamVoid.hpp
BNO08xGlobalTypes.hpp
BNO08xPrivateTypes
Definition: BNO08xPrivateTypes.hpp:21
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:23
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::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_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