47typedef enum : uint32_t {
54typedef enum : uint8_t {
60typedef enum : uint8_t {
70typedef enum : uint8_t {
77typedef enum : uint8_t {
88typedef enum : int32_t {
95typedef enum : uint8_t {
302 uint8_t current = 0U;
307 const uint8_t merged =
329 uint8_t current = 0U;
355 const uint8_t odr_bits =
405 uint8_t bytes[6] = {};
447 uint8_t bytes[2] = {};
493 uint8_t status[2] = {};
575 const uint8_t* out_buf,
577 const uint32_t* out_words)
583 if (max_words == 0U) {
596 if (out_words !=
nullptr) {
609 const uint32_t to_read = (live > max_words) ? max_words : live;
617 *out_words = to_read;
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_VALIDATE_INIT(initialized, tag, message)
Precondition: module must be initialized.
#define RA8_CHECK_RANGE_TAG(value, min, max, errcode, tag)
Tagged range check (adds a component tag to the log line).
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_error(tag, message)
RA8 log error.
ra8_err_t ra8_lsm6dso_set_odr(ra8_lsm6dso_t *dev, ra8_lsm6dso_odr_t odr)
Program the Output Data Rate for both the accelerometer and the gyroscope.
static ra8_err_t internal_lsm6dso_read_xyz(ra8_lsm6dso_t *dev, uint8_t reg, ra8_lsm6dso_xyz_t *out)
Common XYZ burst-read used by both read_accel and read_gyro.
ra8_lsm6dso_burst_bytes_t
Layout constants used by burst-read helpers.
@ k_lsm6dso_fifo_status_bytes
FIFO_STATUS1 + FIFO_STATUS2 (DS12140 sec 9.44).
@ k_lsm6dso_xyz_burst_bytes
3 axes * 2 bytes (DS12140 sec 9.29 / 9.35).
@ k_lsm6dso_temp_burst_bytes
OUT_TEMP_L + OUT_TEMP_H (DS12140 sec 9.27).
ra8_lsm6dso_cap_t
Enum upper bounds used by RA8_CHECK_RANGE_TAG.
@ k_lsm6dso_odr_cap
Highest ODR code.
@ k_lsm6dso_g_fs_cap
Highest G FS code.
@ k_lsm6dso_xl_fs_cap
Highest XL FS code.
@ k_lsm6dso_xl_fs_max
shared cap value 0x04.
ra8_err_t ra8_lsm6dso_read_temp(ra8_lsm6dso_t *dev, int32_t *out_centi_c)
Read the on-die temperature in centi-degrees Celsius.
ra8_err_t ra8_lsm6dso_read_xl_gyro_fifo(ra8_lsm6dso_t *dev, uint8_t *out_buf, uint32_t max_words, uint32_t *out_words)
Drain up to max_samples paired XL+G samples from the embedded FIFO.
ra8_err_t ra8_lsm6dso_read_gyro(ra8_lsm6dso_t *dev, ra8_lsm6dso_xyz_t *out)
Read one gyroscope sample (raw 16-bit two's-complement).
ra8_err_t ra8_lsm6dso_init(ra8_lsm6dso_t *out_dev, const ra8_lsm6dso_bus_t *bus)
Bind a transport to a driver instance.
static ra8_err_t internal_lsm6dso_fifo_check_args(const ra8_lsm6dso_t *dev, const uint8_t *out_buf, uint32_t max_words, const uint32_t *out_words)
Validate the inputs to ra8_lsm6dso_read_xl_gyro_fifo.
ra8_lsm6dso_shift_t
CTRL1_XL / CTRL2_G field positions (DS12140 sec 9.12 / 9.13).
@ k_lsm6dso_shift_fs_xl
FS_XL[1:0] occupies bits [3:2].
@ k_lsm6dso_shift_fs_125
FS_125 select bit occupies bit [1].
@ k_lsm6dso_shift_odr
ODR_xL[3:0] / ODR_G[3:0] occupy bits [7:4].
@ k_lsm6dso_shift_fs_g
FS_G[1:0] occupies bits [3:2].
ra8_err_t ra8_lsm6dso_set_gyro_range(ra8_lsm6dso_t *dev, ra8_lsm6dso_g_fs_t fs)
Program the gyroscope full-scale range.
static ra8_err_t internal_lsm6dso_write_byte(ra8_lsm6dso_t *dev, uint8_t reg, uint8_t val)
Write a single byte to reg via the bound transport.
@ k_lsm6dso_mask_fs_g_full
FS_G + FS_125 combined.
@ k_lsm6dso_mask_byte
Full byte mask.
@ k_lsm6dso_mask_fs_g
Bits [3:2]: FS_G field.
@ k_lsm6dso_mask_nibble
Low nibble (used for FIFO len high).
@ k_lsm6dso_mask_odr
Bits [7:4]: ODR field.
@ k_lsm6dso_mask_fs_xl
Bits [3:2]: FS_XL field.
@ k_lsm6dso_mask_fs_125
Bit [1]: FS_125 select.
ra8_lsm6dso_xyz_off_t
XYZ sample byte offsets within the 6-byte burst.
@ k_lsm6dso_xyz_off_x_h
Lsm6dso xyz off x h.
@ k_lsm6dso_xyz_off_y_l
Lsm6dso xyz off y l.
@ k_lsm6dso_xyz_off_z_h
Lsm6dso xyz off z h.
@ k_lsm6dso_xyz_off_x_l
Lsm6dso xyz off x l.
@ k_lsm6dso_xyz_off_y_h
Lsm6dso xyz off y h.
@ k_lsm6dso_xyz_off_z_l
Lsm6dso xyz off z l.
static ra8_err_t internal_lsm6dso_rmw_odr(ra8_lsm6dso_t *dev, uint8_t reg, uint8_t odr_bits)
Read-modify-write the ODR nibble [7:4] of a CTRL register.
static ra8_err_t internal_lsm6dso_burst_fifo(ra8_lsm6dso_t *dev, uint8_t *out_buf, uint32_t n_words)
Burst-read n_words 7-byte FIFO records from FIFO_DATA_OUT_TAG.
ra8_err_t ra8_lsm6dso_read_accel(ra8_lsm6dso_t *dev, ra8_lsm6dso_xyz_t *out)
Read one accelerometer sample (raw 16-bit two's-complement).
static uint8_t internal_lsm6dso_g_fs_bits(ra8_lsm6dso_g_fs_t fs)
Compose the FS_G + FS_125 sub-field of CTRL2_G for the requested gyro full-scale code.
static ra8_err_t internal_lsm6dso_read_byte(ra8_lsm6dso_t *dev, uint8_t reg, uint8_t *out)
Read a single byte from reg via the bound transport.
static ra8_err_t internal_lsm6dso_read_fifo_depth(ra8_lsm6dso_t *dev, uint32_t *out_n)
Read the live FIFO word count (DIFF_FIFO[9:0]).
ra8_err_t ra8_lsm6dso_who_am_i(ra8_lsm6dso_t *dev, uint8_t *out_id)
Read the WHO_AM_I register.
static const char *const s_lsm6dso_tag
Tag for ra8_log_error / ra8_log_info lines from this TU.
ra8_lsm6dso_temp_const_t
Temperature conversion constants per DS12140 sec 9.27.
@ k_lsm6dso_temp_scale_den
Denominator for centi-C convert.
@ k_lsm6dso_temp_scale_num
Numerator for centi-C convert.
@ k_lsm6dso_temp_offset_centi_c
+25 C zero offset, scaled x100.
ra8_lsm6dso_endian_idx_t
Two's-complement byte combination – 0..1 indices.
@ k_lsm6dso_idx_low
Little-endian low byte.
@ k_lsm6dso_idx_high
Little-endian high byte.
ra8_err_t ra8_lsm6dso_set_accel_range(ra8_lsm6dso_t *dev, ra8_lsm6dso_xl_fs_t fs)
Program the accelerometer full-scale range.
ST LSM6DSO 6-DoF IMU driver (accel + gyro + temperature).
@ k_lsm6dso_fifo_bytes_word
Bytes per FIFO word (TAG + 6 data, sec 9.7).
ra8_lsm6dso_odr_t
Output Data Rate codes (shared between XL and G).
@ k_lsm6dso_odr_6660hz
6.66 kHz.
@ k_lsm6dso_odr_off
Power-down (default).
@ k_lsm6dso_reg_fifo_status1
FIFO_STATUS1 (DS12140 sec 9.44).
@ k_lsm6dso_reg_ctrl2_g
CTRL2_G (DS12140 sec 9.13).
@ k_lsm6dso_reg_out_temp_l
OUT_TEMP_L (DS12140 sec 9.27).
@ k_lsm6dso_reg_outx_l_a
OUTX_L_A (DS12140 sec 9.35).
@ k_lsm6dso_reg_outx_l_g
OUTX_L_G (DS12140 sec 9.29).
@ k_lsm6dso_reg_fifo_data_out
FIFO_DATA_OUT_TAG (DS12140 sec 9.60).
@ k_lsm6dso_reg_who_am_i
WHO_AM_I (DS12140 sec 9.11).
@ k_lsm6dso_reg_ctrl1_xl
CTRL1_XL (DS12140 sec 9.12).
ra8_lsm6dso_g_fs_t
Gyroscope full-scale (FS_G) range codes.
@ k_lsm6dso_g_fs_125dps
+-125 dps narrow scale (FS_125 = 1).
@ k_lsm6dso_g_fs_2000dps
+-2000 dps.
@ k_lsm6dso_g_fs_250dps
+-250 dps (default).
ra8_lsm6dso_xl_fs_t
Accelerometer full-scale (FS_XL) range codes.
@ k_lsm6dso_xl_fs_8g
+-8 g, sens 0.244 mg/LSB.
@ k_lsm6dso_xl_fs_2g
+-2 g, sens 0.061 mg/LSB (default).
Transport interface bound at ra8_lsm6dso_init time.
void * ctx
Caller-supplied context.
ra8_lsm6dso_write_fn_t write_regs
Write callback.
ra8_lsm6dso_read_fn_t read_regs
Read callback.
Per-instance driver state.
ra8_lsm6dso_g_fs_t gyro_fs_code
Last gyro full-scale code written.
bool initialized
True after a successful _init.
ra8_lsm6dso_xl_fs_t accel_fs_code
Last accel full-scale code written.
ra8_lsm6dso_odr_t odr_code
Last ODR code written to both blocks.
ra8_lsm6dso_bus_t bus
Transport interface.
3-axis raw sample (X, Y, Z as 16-bit two's-complement counts).
int16_t y
Y-axis raw count.
int16_t z
Z-axis raw count.
int16_t x
X-axis raw count.