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

BNO08xTestHelper.hpp
Go to the documentation of this file.
1
6#pragma once
7
8// in-house includes
9#include "BNO08x.hpp"
10
16 class BNO08xTestHelper
17{
18 private:
19 static inline uint8_t test_imu_buffer[sizeof(BNO08x)];
20 inline static BNO08x* test_imu = nullptr;
21 inline static bno08x_config_t imu_cfg;
22
23 static const constexpr char* TAG = "BNO08xTestHelper";
24
25 public:
33 static void print_test_start_banner(const char* TEST_TAG)
34 {
35 printf("------------------------ BEGIN TEST: %s ------------------------\n\r", TEST_TAG);
36 }
37
45 static void print_test_end_banner(const char* TEST_TAG)
46 {
47 printf("------------------------ END TEST: %s ------------------------\n\r", TEST_TAG);
48 }
49
58 static void print_test_msg(const char* TEST_TAG, const char* msg)
59 {
60 printf("%s: %s: %s\n\r", TAG, TEST_TAG, msg);
61 }
62
70 static void set_test_imu_cfg(bno08x_config_t cfg)
71 {
72 imu_cfg = cfg;
73 }
74
80 static void create_test_imu()
81 {
82 if (test_imu != nullptr)
83 destroy_test_imu();
84
85 test_imu = new (&test_imu_buffer) BNO08x();
86 }
87
93 static void destroy_test_imu()
94 {
95 if (test_imu != nullptr)
96 {
97 test_imu->~BNO08x();
98 test_imu = nullptr;
99 }
100 }
101
107 static BNO08x* get_test_imu()
108 {
109 return test_imu;
110 }
111
117 static esp_err_t call_init_config_args()
118 {
119 if (test_imu == nullptr)
120 return ESP_FAIL;
121
122 return test_imu->init_config_args();
123 }
124
130 static esp_err_t call_init_gpio()
131 {
132 if (test_imu == nullptr)
133 return ESP_FAIL;
134
135 return test_imu->init_gpio();
136 }
137
143 static esp_err_t call_init_hint_isr()
144 {
145 if (test_imu == nullptr)
146 return ESP_FAIL;
147
148 return test_imu->init_hint_isr();
149 }
150
156 static esp_err_t call_init_spi()
157 {
158 if (test_imu == nullptr)
159 return ESP_FAIL;
160
161 return test_imu->init_spi();
162 }
163
169 static esp_err_t call_init_tasks()
170 {
171 if (test_imu == nullptr)
172 return ESP_FAIL;
173
174 return test_imu->init_tasks();
175 }
176
182 static esp_err_t call_init_sh2_HAL()
183 {
184 if (test_imu == nullptr)
185 return ESP_FAIL;
186
187 return test_imu->init_sh2_HAL();
188 }
189
195 static esp_err_t call_deinit_gpio()
196 {
197 if (test_imu == nullptr)
198 return ESP_FAIL;
199
200 return test_imu->deinit_gpio();
201 }
202
208 static esp_err_t call_deinit_hint_isr()
209 {
210 if (test_imu == nullptr)
211 return ESP_FAIL;
212
213 return test_imu->deinit_hint_isr();
214 }
215
221 static esp_err_t call_deinit_spi()
222 {
223 if (test_imu == nullptr)
224 return ESP_FAIL;
225
226 return test_imu->deinit_spi();
227 }
228
234 static esp_err_t call_deinit_tasks()
235 {
236 if (test_imu == nullptr)
237 return ESP_FAIL;
238
239 return test_imu->deinit_tasks();
240 }
241
247 static esp_err_t call_deinit_sh2_HAL()
248 {
249 if (test_imu == nullptr)
250 return ESP_FAIL;
251
252 return test_imu->deinit_sh2_HAL();
253 }
254};
BNO08x.hpp
BNO08x
BNO08x IMU driver class.
Definition: BNO08x.hpp:33
BNO08xTestHelper
BNO08x unit test helper class.
Definition: BNO08xTestHelper.hpp:17
BNO08xTestHelper::print_test_start_banner
static void print_test_start_banner(const char *TEST_TAG)
Prints test begin banner.
Definition: BNO08xTestHelper.hpp:33
BNO08xTestHelper::print_test_end_banner
static void print_test_end_banner(const char *TEST_TAG)
Prints end begin banner.
Definition: BNO08xTestHelper.hpp:45
BNO08xTestHelper::print_test_msg
static void print_test_msg(const char *TEST_TAG, const char *msg)
Prints a message during a test.
Definition: BNO08xTestHelper.hpp:58
BNO08xTestHelper::call_deinit_gpio
static esp_err_t call_deinit_gpio()
Used to call private BNO08x::deinit_gpio() member for tests.
Definition: BNO08xTestHelper.hpp:195
BNO08xTestHelper::call_deinit_tasks
static esp_err_t call_deinit_tasks()
Used to call private BNO08x::deinit_tasks() member for tests.
Definition: BNO08xTestHelper.hpp:234
BNO08xTestHelper::get_test_imu
static BNO08x * get_test_imu()
Deletes test IMU calling deconstructor and releases heap allocated memory.
Definition: BNO08xTestHelper.hpp:107
BNO08xTestHelper::call_init_gpio
static esp_err_t call_init_gpio()
Used to call private BNO08x::init_gpio() member for tests.
Definition: BNO08xTestHelper.hpp:130
BNO08xTestHelper::call_deinit_spi
static esp_err_t call_deinit_spi()
Used to call private BNO08x::deinit_spi() member for tests.
Definition: BNO08xTestHelper.hpp:221
BNO08xTestHelper::create_test_imu
static void create_test_imu()
Calls BNO08x constructor and creates new test IMU on heap.
Definition: BNO08xTestHelper.hpp:80
BNO08xTestHelper::call_init_config_args
static esp_err_t call_init_config_args()
Used to call private BNO08x::init_config_args() member for tests.
Definition: BNO08xTestHelper.hpp:117
BNO08xTestHelper::call_init_spi
static esp_err_t call_init_spi()
Used to call private BNO08x::init_spi() member for tests.
Definition: BNO08xTestHelper.hpp:156
BNO08xTestHelper::call_init_hint_isr
static esp_err_t call_init_hint_isr()
Used to call private BNO08x::init_hint_isr() member for tests.
Definition: BNO08xTestHelper.hpp:143
BNO08xTestHelper::call_init_sh2_HAL
static esp_err_t call_init_sh2_HAL()
Used to call private BNO08x::init_tasks() member for tests.
Definition: BNO08xTestHelper.hpp:182
BNO08xTestHelper::call_init_tasks
static esp_err_t call_init_tasks()
Used to call private BNO08x::init_tasks() member for tests.
Definition: BNO08xTestHelper.hpp:169
BNO08xTestHelper::set_test_imu_cfg
static void set_test_imu_cfg(bno08x_config_t cfg)
Set test imu configuration used with create_test_imu()
Definition: BNO08xTestHelper.hpp:70
BNO08xTestHelper::call_deinit_sh2_HAL
static esp_err_t call_deinit_sh2_HAL()
Used to call private BNO08x::deinit_tasks() member for tests.
Definition: BNO08xTestHelper.hpp:247
BNO08xTestHelper::call_deinit_hint_isr
static esp_err_t call_deinit_hint_isr()
Used to call private BNO08x::deinit_hint_isr() member for tests.
Definition: BNO08xTestHelper.hpp:208
BNO08xTestHelper::destroy_test_imu
static void destroy_test_imu()
Deletes test IMU calling deconstructor and releases heap allocated memory.
Definition: BNO08xTestHelper.hpp:93
bno08x_config_t
IMU configuration settings passed into constructor.
Definition: BNO08xGlobalTypes.hpp:38