10#include "sh2_SensorValue.h"
24#define UINT16_CLR_MSB(val_16bit) ((val_16bit) & 0x00FFU)
32#define UINT16_CLR_LSB(val_16bit) ((val_16bit) & 0xFF00U)
41#define UINT32_CLR_BYTE(val_32bit, byte2clear) ((val_32bit) & ~(0xFFUL << (byte2clear * 8UL)))
50#define UINT32_MSK_BYTE(val_32bit, byte2mask) ((val_32bit) & (0xFFUL << (byte2mask * 8UL)))
60#define PARSE_PACKET_LENGTH(header) \
61 (UINT16_CLR_LSB(static_cast<uint16_t>(header[1]) << 8U) | UINT16_CLR_MSB(static_cast<uint16_t>(header[0])))
76 static int spi_open(sh2_Hal_t* self);
78 static int spi_read(sh2_Hal_t* self, uint8_t* pBuffer,
unsigned len, uint32_t* t_us);
79 static int spi_write(sh2_Hal_t* self, uint8_t* pBuffer,
unsigned len);
81 static void hal_cb(
void* cookie, sh2_AsyncEvent_t* pEvent);
86 static void hardware_reset();
87 static bool spi_wait_for_int();
88 static uint16_t spi_read_sh2_packet_header(uint8_t* pBuffer);
89 static int spi_read_sh2_packet_body(uint8_t* pBuffer, uint16_t packet_sz);
91 static const constexpr char* TAG =
"BNO08xSH2HAL";
BNO08x IMU driver class.
Definition: BNO08x.hpp:33
Fully static class containing callback implementations for sh2 HAL lib.
Definition: BNO08xSH2HAL.hpp:72
static void sensor_event_cb(void *cookie, sh2_SensorEvent_t *event)
Sensor event callback for sh2 HAL lib, sends received reports to data_proc_task().
Definition: BNO08xSH2HAL.cpp:155
static void hal_cb(void *cookie, sh2_AsyncEvent_t *pEvent)
General event callback for sh2 HAL lib, used to notify tasks of reset.
Definition: BNO08xSH2HAL.cpp:141
static void set_hal_imu(BNO08x *hal_imu)
Sets the BNO08x driver object to be used with sh2 HAL lib callbacks.
Definition: BNO08xSH2HAL.cpp:18
static int spi_read(sh2_Hal_t *self, uint8_t *pBuffer, unsigned len, uint32_t *t_us)
SPI rx callback for sh2 HAL lib.
Definition: BNO08xSH2HAL.cpp:56
static void spi_close(sh2_Hal_t *self)
Closes SPI instance (nothing to do here, but required by sh2 HAL lib for cases where other communicat...
Definition: BNO08xSH2HAL.cpp:41
static int spi_write(sh2_Hal_t *self, uint8_t *pBuffer, unsigned len)
SPI tx callback for sh2 HAL lib.
Definition: BNO08xSH2HAL.cpp:92
static uint32_t get_time_us(sh2_Hal_t *self)
Get time in microseconds callback for sh2 HAL lib.
Definition: BNO08xSH2HAL.cpp:123
static int spi_open(sh2_Hal_t *self)
Opens SPI instance by waiting for interrupt.
Definition: BNO08xSH2HAL.cpp:28