ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_lsm6dso.h
Go to the documentation of this file.
1
52
53#pragma once
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59#include <stdint.h>
60
61#include "ra8_err.h"
62
63/* =============================================================================
64 * Public typed-enum constants
65 * =============================================================================
66 */
67
83
100
128
147
169
194
205typedef struct {
206 int16_t x;
207 int16_t y;
208 int16_t z;
210
211/* =============================================================================
212 * Transport abstraction (Dependency Inversion)
213 * =============================================================================
214 */
215
238typedef ra8_err_t (*ra8_lsm6dso_read_fn_t)(void* ctx, uint8_t reg, uint8_t* buf, uint32_t len);
239
252 uint8_t reg,
253 const uint8_t* buf,
254 uint32_t len);
255
271
290
291/* =============================================================================
292 * Lifecycle
293 * =============================================================================
294 */
295
323[[nodiscard]] ra8_err_t ra8_lsm6dso_init(ra8_lsm6dso_t* out_dev, const ra8_lsm6dso_bus_t* bus);
324
325/* =============================================================================
326 * Identification
327 * =============================================================================
328 */
329
355[[nodiscard]] ra8_err_t ra8_lsm6dso_who_am_i(ra8_lsm6dso_t* dev, uint8_t* out_id);
356
357/* =============================================================================
358 * Configuration
359 * =============================================================================
360 */
361
388
416
447
448/* =============================================================================
449 * Sample read paths
450 * =============================================================================
451 */
452
479
506
536[[nodiscard]] ra8_err_t ra8_lsm6dso_read_temp(ra8_lsm6dso_t* dev, int32_t* out_centi_c);
537
576 uint8_t* out_buf,
577 uint32_t max_words,
578 uint32_t* out_words);
579
580#ifdef __cplusplus
581}
582#endif
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
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.
ra8_err_t(* ra8_lsm6dso_read_fn_t)(void *ctx, uint8_t reg, uint8_t *buf, uint32_t len)
Read len bytes from reg on the target.
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.
ra8_err_t ra8_lsm6dso_set_gyro_range(ra8_lsm6dso_t *dev, ra8_lsm6dso_g_fs_t fs)
Program the gyroscope full-scale range.
ra8_lsm6dso_i2c_addr_t
Default 7-bit I2C target addresses.
Definition ra8_lsm6dso.h:96
@ k_lsm6dso_i2c_addr_sa0_high
SDO/SA0 tied high.
Definition ra8_lsm6dso.h:98
@ k_lsm6dso_i2c_addr_sa0_low
SDO/SA0 tied low.
Definition ra8_lsm6dso.h:97
ra8_lsm6dso_const_t
Part-level identification + sizing constants.
Definition ra8_lsm6dso.h:78
@ k_lsm6dso_who_am_i_value
WHO_AM_I expected value (DS12140 sec 9.11).
Definition ra8_lsm6dso.h:79
@ k_lsm6dso_fifo_words_max
Default FIFO-batch cap exposed to callers.
Definition ra8_lsm6dso.h:80
@ k_lsm6dso_fifo_bytes_word
Bytes per FIFO word (TAG + 6 data, sec 9.7).
Definition ra8_lsm6dso.h:81
ra8_err_t(* ra8_lsm6dso_write_fn_t)(void *ctx, uint8_t reg, const uint8_t *buf, uint32_t len)
Write len bytes starting at reg on the target.
ra8_lsm6dso_odr_t
Output Data Rate codes (shared between XL and G).
@ k_lsm6dso_odr_416hz
416 Hz.
@ k_lsm6dso_odr_52hz
52 Hz.
@ k_lsm6dso_odr_208hz
208 Hz.
@ k_lsm6dso_odr_3330hz
3.33 kHz.
@ k_lsm6dso_odr_6660hz
6.66 kHz.
@ k_lsm6dso_odr_1660hz
1.66 kHz.
@ k_lsm6dso_odr_12_5hz
12.5 Hz (low-power).
@ k_lsm6dso_odr_833hz
833 Hz.
@ k_lsm6dso_odr_26hz
26 Hz.
@ k_lsm6dso_odr_off
Power-down (default).
@ k_lsm6dso_odr_104hz
104 Hz (normal mode).
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).
ra8_err_t ra8_lsm6dso_who_am_i(ra8_lsm6dso_t *dev, uint8_t *out_id)
Read the WHO_AM_I register.
ra8_lsm6dso_reg_t
Register-map addresses used by this driver.
@ k_lsm6dso_reg_ctrl3_c
CTRL3_C (DS12140 sec 9.14).
@ k_lsm6dso_reg_fifo_ctrl1
FIFO_CTRL1 (DS12140 sec 9.6).
@ k_lsm6dso_reg_fifo_status1
FIFO_STATUS1 (DS12140 sec 9.44).
@ k_lsm6dso_reg_ctrl7_g
CTRL7_G (DS12140 sec 9.18).
@ k_lsm6dso_reg_ctrl6_c
CTRL6_C (DS12140 sec 9.17).
@ k_lsm6dso_reg_fifo_ctrl3
FIFO_CTRL3 (DS12140 sec 9.8).
@ k_lsm6dso_reg_ctrl2_g
CTRL2_G (DS12140 sec 9.13).
@ k_lsm6dso_reg_fifo_ctrl4
FIFO_CTRL4 (DS12140 sec 9.9).
@ k_lsm6dso_reg_fifo_ctrl2
FIFO_CTRL2 (DS12140 sec 9.7).
@ 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_err_t ra8_lsm6dso_set_accel_range(ra8_lsm6dso_t *dev, ra8_lsm6dso_xl_fs_t fs)
Program the accelerometer full-scale range.
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_500dps
+-500 dps.
@ k_lsm6dso_g_fs_2000dps
+-2000 dps.
@ k_lsm6dso_g_fs_1000dps
+-1000 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_4g
+-4 g, sens 0.122 mg/LSB.
@ k_lsm6dso_xl_fs_2g
+-2 g, sens 0.061 mg/LSB (default).
@ k_lsm6dso_xl_fs_16g
+-16 g, sens 0.488 mg/LSB.
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.