|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
ST LSM6DSO 6-DoF IMU driver – implementation. More...
#include "ra8_lsm6dso.h"#include <stdint.h>#include "ra8_attributes.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_log.h"Go to the source code of this file.
Enumerations | |
| enum | ra8_lsm6dso_burst_bytes_t : uint32_t { k_lsm6dso_xyz_burst_bytes = 6U , k_lsm6dso_temp_burst_bytes = 2U , k_lsm6dso_fifo_status_bytes = 2U } |
| Layout constants used by burst-read helpers. More... | |
| enum | ra8_lsm6dso_endian_idx_t : uint8_t { k_lsm6dso_idx_low = 0U , k_lsm6dso_idx_high = 1U } |
| Two's-complement byte combination – 0..1 indices. More... | |
| enum | ra8_lsm6dso_xyz_off_t : uint8_t { k_lsm6dso_xyz_off_x_l = 0U , k_lsm6dso_xyz_off_x_h = 1U , k_lsm6dso_xyz_off_y_l = 2U , k_lsm6dso_xyz_off_y_h = 3U , k_lsm6dso_xyz_off_z_l = 4U , k_lsm6dso_xyz_off_z_h = 5U } |
| XYZ sample byte offsets within the 6-byte burst. More... | |
| enum | ra8_lsm6dso_shift_t : uint8_t { k_lsm6dso_shift_odr = 4U , k_lsm6dso_shift_fs_xl = 2U , k_lsm6dso_shift_fs_g = 2U , k_lsm6dso_shift_fs_125 = 1U } |
| CTRL1_XL / CTRL2_G field positions (DS12140 sec 9.12 / 9.13). More... | |
| enum | ra8_lsm6dso_mask_t : uint8_t { k_lsm6dso_mask_odr = 0xF0U , k_lsm6dso_mask_fs_xl = 0x0CU , k_lsm6dso_mask_fs_g = 0x0CU , k_lsm6dso_mask_fs_125 = 0x02U , k_lsm6dso_mask_fs_g_full = 0x0EU , k_lsm6dso_mask_nibble = 0x0FU , k_lsm6dso_mask_byte = 0xFFU } |
| enum | ra8_lsm6dso_temp_const_t : int32_t { k_lsm6dso_temp_offset_centi_c = 2500 , k_lsm6dso_temp_scale_num = 100 , k_lsm6dso_temp_scale_den = 256 } |
| Temperature conversion constants per DS12140 sec 9.27. More... | |
| enum | ra8_lsm6dso_cap_t : uint8_t { k_lsm6dso_xl_fs_max = (uint8_t)k_lsm6dso_g_fs_2000dps , k_lsm6dso_xl_fs_cap = (uint8_t)k_lsm6dso_xl_fs_8g , k_lsm6dso_g_fs_cap = (uint8_t)k_lsm6dso_g_fs_2000dps , k_lsm6dso_odr_cap = (uint8_t)k_lsm6dso_odr_6660hz } |
| Enum upper bounds used by RA8_CHECK_RANGE_TAG. More... | |
Functions | |
| 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_write_byte (ra8_lsm6dso_t *dev, uint8_t reg, uint8_t val) |
| Write a single byte to reg via the bound transport. | |
| 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_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. | |
| 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_who_am_i (ra8_lsm6dso_t *dev, uint8_t *out_id) |
| Read the WHO_AM_I register. | |
| 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_err_t | ra8_lsm6dso_set_gyro_range (ra8_lsm6dso_t *dev, ra8_lsm6dso_g_fs_t fs) |
| Program the gyroscope full-scale range. | |
| 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_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_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_read_temp (ra8_lsm6dso_t *dev, int32_t *out_centi_c) |
| Read the on-die temperature in centi-degrees Celsius. | |
| 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]). | |
| 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. | |
| 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_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. | |
Variables | |
| static const char *const | s_lsm6dso_tag = "lsm6dso" |
| Tag for ra8_log_error / ra8_log_info lines from this TU. | |
ST LSM6DSO 6-DoF IMU driver – implementation.
Polling, transport-agnostic implementation. All register-level citations point at LSM6DSO DS12140 Rev 4 (Sept 2019). The transport is supplied by the caller (Dependency Inversion) so this TU does not link against ra8_i3c_i2c or ra8_spi.
Algorithm style throughout this file:
Each public function carries at least two precondition checks and two postcondition statements to satisfy NASA P10 Rule 5.
Definition in file ra8_lsm6dso.c.
| enum ra8_lsm6dso_burst_bytes_t : uint32_t |
Layout constants used by burst-read helpers.
Definition at line 47 of file ra8_lsm6dso.c.
| enum ra8_lsm6dso_cap_t : uint8_t |
Enum upper bounds used by RA8_CHECK_RANGE_TAG.
| Enumerator | |
|---|---|
| k_lsm6dso_xl_fs_max | shared cap value 0x04. |
| k_lsm6dso_xl_fs_cap | Highest XL FS code. |
| k_lsm6dso_g_fs_cap | Highest G FS code. |
| k_lsm6dso_odr_cap | Highest ODR code. |
Definition at line 95 of file ra8_lsm6dso.c.
| enum ra8_lsm6dso_endian_idx_t : uint8_t |
Two's-complement byte combination – 0..1 indices.
| Enumerator | |
|---|---|
| k_lsm6dso_idx_low | Little-endian low byte. |
| k_lsm6dso_idx_high | Little-endian high byte. |
Definition at line 54 of file ra8_lsm6dso.c.
| enum ra8_lsm6dso_mask_t : uint8_t |
Definition at line 77 of file ra8_lsm6dso.c.
| enum ra8_lsm6dso_shift_t : uint8_t |
CTRL1_XL / CTRL2_G field positions (DS12140 sec 9.12 / 9.13).
Definition at line 70 of file ra8_lsm6dso.c.
| enum ra8_lsm6dso_temp_const_t : int32_t |
Temperature conversion constants per DS12140 sec 9.27.
| Enumerator | |
|---|---|
| k_lsm6dso_temp_offset_centi_c | +25 C zero offset, scaled x100. |
| k_lsm6dso_temp_scale_num | Numerator for centi-C convert. |
| k_lsm6dso_temp_scale_den | Denominator for centi-C convert. |
Definition at line 88 of file ra8_lsm6dso.c.
| enum ra8_lsm6dso_xyz_off_t : uint8_t |
XYZ sample byte offsets within the 6-byte burst.
Definition at line 60 of file ra8_lsm6dso.c.
|
static |
Burst-read n_words 7-byte FIFO records from FIFO_DATA_OUT_TAG.
Per DS12140 sec 9.60 FIFO_DATA_OUT_TAG (78h) the FIFO data registers auto-increment across the 7-byte word (1 TAG + 6 sample bytes). We issue a single bus burst so the IIC/SPI controller can stream the entire window without per-byte START/STOP overhead.
| [in] | dev | Driver instance (already validated by caller). |
| [out] | out_buf | Destination buffer (must be >= n_words * 7). |
| [in] | n_words | Number of 7-byte words to fetch (must be > 0). |
| k_ra8_ok | out_buf populated with n_words * 7 bytes. |
| other | Forwarded from dev->bus.read_regs. |
Definition at line 532 of file ra8_lsm6dso.c.
References ra8_lsm6dso_t::bus, ra8_lsm6dso_bus_t::ctx, k_lsm6dso_fifo_bytes_word, k_lsm6dso_reg_fifo_data_out, and ra8_lsm6dso_bus_t::read_regs.
Referenced by ra8_lsm6dso_read_xl_gyro_fifo().
|
static |
Validate the inputs to ra8_lsm6dso_read_xl_gyro_fifo.
Returns the same error codes as the public entry point would on each individual check, but lives in its own function so the public entry stays within the NASA P10 Rule 4 statement budget. Behaviour matches the public API one-to-one: NULL pointer -> k_ra8_err_null_ptr, not initialized -> k_ra8_err_not_initialized, zero max_words -> k_ra8_err_invalid_arg.
| [in] | dev | Driver instance. |
| [in] | out_buf | Caller buffer. |
| [in] | max_words | Caller's word cap. |
| [in] | out_words | Caller's output count pointer. |
| k_ra8_ok | All preconditions satisfied. |
| k_ra8_err_null_ptr | Any of dev / out_buf / out_words is NULL. |
| k_ra8_err_not_initialized | dev->initialized is false. |
| k_ra8_err_invalid_arg | max_words is zero. |
Definition at line 574 of file ra8_lsm6dso.c.
References ra8_lsm6dso_t::initialized, k_ra8_err_invalid_arg, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_log_error, RA8_VALIDATE_INIT, and s_lsm6dso_tag.
Referenced by ra8_lsm6dso_read_xl_gyro_fifo().
|
static |
Compose the FS_G + FS_125 sub-field of CTRL2_G for the requested gyro full-scale code.
Per DS12140 sec 9.13 "CTRL2_G (11h)":
The return value is the 3-bit sub-field [3:1] of CTRL2_G, pre-shifted into place. The caller masks in the ODR nibble.
| [in] | fs | Gyro full-scale code. |
| 0x02 | FS_125 path (fs == k_lsm6dso_g_fs_125dps). |
| other | Encoded FS_G[1:0] field for the wider scales. |
Definition at line 138 of file ra8_lsm6dso.c.
References k_lsm6dso_g_fs_125dps, k_lsm6dso_g_fs_250dps, k_lsm6dso_shift_fs_125, and k_lsm6dso_shift_fs_g.
Referenced by ra8_lsm6dso_set_gyro_range().
|
static |
Read a single byte from reg via the bound transport.
Thin wrapper around dev->bus.read_regs that pins the byte count to 1. All real validation lives in the public entry that invokes this helper.
| [in] | dev | Driver instance (already validated). |
| [in] | reg | Register address. |
| [out] | out | Receives the byte on success. |
| k_ra8_ok | *out populated. |
| other | Forwarded from dev->bus.read_regs; *out unchanged. |
Definition at line 206 of file ra8_lsm6dso.c.
References ra8_lsm6dso_t::bus, ra8_lsm6dso_bus_t::ctx, and ra8_lsm6dso_bus_t::read_regs.
Referenced by internal_lsm6dso_rmw_odr(), ra8_lsm6dso_set_accel_range(), ra8_lsm6dso_set_gyro_range(), and ra8_lsm6dso_who_am_i().
|
static |
Read the live FIFO word count (DIFF_FIFO[9:0]).
Reads FIFO_STATUS1 + FIFO_STATUS2 (DS12140 sec 9.44 / 9.45) and extracts the 10-bit DIFF_FIFO field into a 32-bit count. The low 8 bits live in FIFO_STATUS1, the upper 2 bits live in the low nibble of FIFO_STATUS2.
| [in] | dev | Driver instance (already validated by caller). |
| [out] | out_n | Receives the live FIFO word count on success. |
| k_ra8_ok | *out_n populated with the DIFF_FIFO count. |
| other | Forwarded from dev->bus.read_regs; *out_n unchanged. |
Definition at line 491 of file ra8_lsm6dso.c.
References ra8_lsm6dso_t::bus, ra8_lsm6dso_bus_t::ctx, k_lsm6dso_fifo_status_bytes, k_lsm6dso_idx_high, k_lsm6dso_idx_low, k_lsm6dso_mask_nibble, k_lsm6dso_reg_fifo_status1, k_ra8_ok, and ra8_lsm6dso_bus_t::read_regs.
Referenced by ra8_lsm6dso_read_xl_gyro_fifo().
|
static |
Common XYZ burst-read used by both read_accel and read_gyro.
Issues a single 6-byte burst at reg (auto-incrementing across X/Y/Z low+high bytes per DS12140 sec 9.29 .. 9.40) and packs the little-endian two's-complement bytes into the caller's ra8_lsm6dso_xyz_t struct.
| [in] | dev | Driver instance (validated). |
| [in] | reg | First register address (OUTX_L_A / OUTX_L_G). |
| [out] | out | 3-axis raw sample. |
| k_ra8_ok | *out populated with the latest sample. |
| other | Forwarded from dev->bus.read_regs. |
Definition at line 403 of file ra8_lsm6dso.c.
References ra8_lsm6dso_t::bus, ra8_lsm6dso_bus_t::ctx, k_lsm6dso_xyz_burst_bytes, k_lsm6dso_xyz_off_x_h, k_lsm6dso_xyz_off_x_l, k_lsm6dso_xyz_off_y_h, k_lsm6dso_xyz_off_y_l, k_lsm6dso_xyz_off_z_h, k_lsm6dso_xyz_off_z_l, k_ra8_ok, ra8_lsm6dso_bus_t::read_regs, ra8_lsm6dso_xyz_t::x, ra8_lsm6dso_xyz_t::y, and ra8_lsm6dso_xyz_t::z.
Referenced by ra8_lsm6dso_read_accel(), and ra8_lsm6dso_read_gyro().
|
static |
Read-modify-write the ODR nibble [7:4] of a CTRL register.
Used to share the ODR write path between CTRL1_XL (DS12140 sec 9.12) and CTRL2_G (DS12140 sec 9.13) – both registers place the ODR field in bits [7:4] with the rest of the byte reserved for the per-axis full-scale select. This helper reads the current register value, masks off the existing ODR nibble, OR's in the new ODR bits, and writes the merged byte back.
| [in] | dev | Driver instance (already validated by caller). |
| [in] | reg | CTRL register address (CTRL1_XL or CTRL2_G). |
| [in] | odr_bits | New ODR field, pre-shifted into bits [7:4]. |
| k_ra8_ok | Register byte updated. |
| other | Forwarded from the read or write transport call. |
Definition at line 240 of file ra8_lsm6dso.c.
References internal_lsm6dso_read_byte(), internal_lsm6dso_write_byte(), k_lsm6dso_mask_odr, and k_ra8_ok.
Referenced by ra8_lsm6dso_set_odr().
|
static |
Write a single byte to reg via the bound transport.
Thin wrapper around dev->bus.write_regs that pins the byte count to 1 and stages the value on the caller's stack so the transport can DMA from it. All real validation lives in the public entry that invokes this helper.
| [in] | dev | Driver instance (already validated by caller). |
| [in] | reg | Register address. |
| [in] | val | Byte to write. |
| k_ra8_ok | Byte written. |
| other | Forwarded from dev->bus.write_regs. |
Definition at line 176 of file ra8_lsm6dso.c.
References ra8_lsm6dso_t::bus, ra8_lsm6dso_bus_t::ctx, and ra8_lsm6dso_bus_t::write_regs.
Referenced by internal_lsm6dso_rmw_odr(), ra8_lsm6dso_set_accel_range(), and ra8_lsm6dso_set_gyro_range().
|
nodiscard |
Bind a transport to a driver instance.
Copies the supplied bus interface into out_dev and marks the instance initialised. Does not touch the wire – the caller is expected to follow this with ra8_lsm6dso_who_am_i (sanity check) and then ra8_lsm6dso_set_* calls to configure the part.
| [out] | out_dev | Driver state, populated on success. |
| [in] | bus | Transport interface (must have non-NULL read_regs and write_regs). |
| k_ra8_ok | Driver state initialized. |
| k_ra8_err_null_ptr | out_dev or bus is NULL, or one of the callbacks in bus is NULL. |
Definition at line 256 of file ra8_lsm6dso.c.
References ra8_lsm6dso_t::accel_fs_code, ra8_lsm6dso_t::bus, ra8_lsm6dso_t::gyro_fs_code, ra8_lsm6dso_t::initialized, k_lsm6dso_g_fs_250dps, k_lsm6dso_odr_off, k_lsm6dso_xl_fs_2g, k_ra8_ok, ra8_lsm6dso_t::odr_code, RA8_CHECK_NULL_PTR, ra8_lsm6dso_bus_t::read_regs, s_lsm6dso_tag, and ra8_lsm6dso_bus_t::write_regs.
Referenced by main().
|
nodiscard |
Read one accelerometer sample (raw 16-bit two's-complement).
Burst-reads 6 bytes starting at OUTX_L_A (0x28) into a 3x16 sample (DS12140 sec 9.35 .. 9.40). The LSM6DSO is little-endian so the bytes are combined as (high << 8) | low.
| [in] | dev | Driver instance. |
| [out] | out | 3-axis raw sample. |
| k_ra8_ok | Sample read. |
| k_ra8_err_null_ptr | dev or out is NULL. |
| k_ra8_err_invalid_state | dev not initialized. |
| k_ra8_err_nack | Transport reported a NACK. |
Definition at line 422 of file ra8_lsm6dso.c.
References ra8_lsm6dso_t::initialized, internal_lsm6dso_read_xyz(), k_lsm6dso_reg_outx_l_a, RA8_CHECK_NULL_PTR, RA8_VALIDATE_INIT, and s_lsm6dso_tag.
Referenced by imu_demo_sample_and_emit().
|
nodiscard |
Read one gyroscope sample (raw 16-bit two's-complement).
Burst-reads 6 bytes starting at OUTX_L_G (0x22) into a 3x16 sample (DS12140 sec 9.29 .. 9.34). The LSM6DSO is little-endian so the bytes are combined as (high << 8) | low.
| [in] | dev | Driver instance. |
| [out] | out | 3-axis raw sample. |
| k_ra8_ok | Sample read. |
| k_ra8_err_null_ptr | dev or out is NULL. |
| k_ra8_err_invalid_state | dev not initialized. |
| k_ra8_err_nack | Transport reported a NACK. |
Definition at line 431 of file ra8_lsm6dso.c.
References ra8_lsm6dso_t::initialized, internal_lsm6dso_read_xyz(), k_lsm6dso_reg_outx_l_g, RA8_CHECK_NULL_PTR, RA8_VALIDATE_INIT, and s_lsm6dso_tag.
Referenced by imu_demo_sample_and_emit().
|
nodiscard |
Read the on-die temperature in centi-degrees Celsius.
Reads the 16-bit two's-complement OUT_TEMP register pair (0x20..0x21, DS12140 sec 9.27 / 9.28) and converts to centi-degrees Celsius using the datasheet formula T[C] = (raw / 256) + 25. Multiplied by 100 to stay in integer arithmetic the formula becomes out_centi_c = (raw * 100) / 256 + 2500, which is what the driver implements.
| [in] | dev | Driver instance. |
| [out] | out_centi_c | Receives the temperature in centi-deg C. |
| k_ra8_ok | Temperature read. |
| k_ra8_err_null_ptr | dev or out_centi_c is NULL. |
| k_ra8_err_invalid_state | dev not initialized. |
| k_ra8_err_nack | Transport reported a NACK. |
Definition at line 440 of file ra8_lsm6dso.c.
References ra8_lsm6dso_t::bus, ra8_lsm6dso_bus_t::ctx, ra8_lsm6dso_t::initialized, k_lsm6dso_idx_high, k_lsm6dso_idx_low, k_lsm6dso_reg_out_temp_l, k_lsm6dso_temp_burst_bytes, k_lsm6dso_temp_offset_centi_c, k_lsm6dso_temp_scale_den, k_lsm6dso_temp_scale_num, k_ra8_ok, RA8_CHECK_NULL_PTR, RA8_VALIDATE_INIT, ra8_lsm6dso_bus_t::read_regs, and s_lsm6dso_tag.
Referenced by imu_demo_sample_and_emit().
|
nodiscard |
Drain up to max_samples paired XL+G samples from the embedded FIFO.
Polls FIFO_STATUS1/2 (DS12140 sec 9.44 / 9.45) for the live sample count, then issues a burst read of FIFO_DATA_OUT_TAG (0x78, DS12140 sec 9.60 .. 9.66) for each available 7-byte FIFO word. The tag byte identifies the source (XL vs G) per Table 167 "Tag codes"; this helper returns whatever the FIFO happens to hold and lets the caller demux.
| [in] | dev | Driver instance. |
| [out] | out_buf | Destination buffer; receives raw FIFO words laid out as [tag][b0 b1 b2 b3 b4 b5] repeated. |
| [in] | max_words | Maximum FIFO words the caller can store (capacity of out_buf in bytes is max_words * k_lsm6dso_fifo_bytes_word). |
| [out] | out_words | Number of FIFO words actually read into out_buf. |
| k_ra8_ok | FIFO drained (possibly to zero words). |
| k_ra8_err_null_ptr | Any of the pointers is NULL. |
| k_ra8_err_invalid_state | dev not initialized. |
| k_ra8_err_invalid_arg | max_words == 0. |
| k_ra8_err_nack | Transport reported a NACK. |
Definition at line 590 of file ra8_lsm6dso.c.
References internal_lsm6dso_burst_fifo(), internal_lsm6dso_fifo_check_args(), internal_lsm6dso_read_fifo_depth(), and k_ra8_ok.
|
nodiscard |
Program the accelerometer full-scale range.
Read-modify-writes the FS_XL field in CTRL1_XL (DS12140 sec 9.12). The ODR_XL nibble is preserved by reading the current value first.
| [in,out] | dev | Driver instance. |
| [in] | fs | Range code (one of k_lsm6dso_xl_fs_*). |
| k_ra8_ok | Range programmed. |
| k_ra8_err_null_ptr | dev is NULL. |
| k_ra8_err_invalid_state | dev not initialized. |
| k_ra8_err_invalid_arg | fs out of range. |
| k_ra8_err_nack | Transport reported a NACK. |
Definition at line 291 of file ra8_lsm6dso.c.
References ra8_lsm6dso_t::accel_fs_code, ra8_lsm6dso_t::initialized, internal_lsm6dso_read_byte(), internal_lsm6dso_write_byte(), k_lsm6dso_mask_fs_xl, k_lsm6dso_reg_ctrl1_xl, k_lsm6dso_shift_fs_xl, k_lsm6dso_xl_fs_cap, k_ra8_err_invalid_arg, k_ra8_ok, RA8_CHECK_NULL_PTR, RA8_CHECK_RANGE_TAG, RA8_VALIDATE_INIT, and s_lsm6dso_tag.
Referenced by imu_demo_configure().
|
nodiscard |
Program the gyroscope full-scale range.
Read-modify-writes the FS_G[1:0] and FS_125 fields in CTRL2_G (DS12140 sec 9.13). The ODR_G nibble is preserved by reading the current value first.
| [in,out] | dev | Driver instance. |
| [in] | fs | Range code (one of k_lsm6dso_g_fs_*). |
| k_ra8_ok | Range programmed. |
| k_ra8_err_null_ptr | dev is NULL. |
| k_ra8_err_invalid_state | dev not initialized. |
| k_ra8_err_invalid_arg | fs out of range. |
| k_ra8_err_nack | Transport reported a NACK. |
Definition at line 318 of file ra8_lsm6dso.c.
References ra8_lsm6dso_t::gyro_fs_code, ra8_lsm6dso_t::initialized, internal_lsm6dso_g_fs_bits(), internal_lsm6dso_read_byte(), internal_lsm6dso_write_byte(), k_lsm6dso_g_fs_cap, k_lsm6dso_mask_fs_g_full, k_lsm6dso_reg_ctrl2_g, k_ra8_err_invalid_arg, k_ra8_ok, RA8_CHECK_NULL_PTR, RA8_CHECK_RANGE_TAG, RA8_VALIDATE_INIT, and s_lsm6dso_tag.
Referenced by imu_demo_configure().
|
nodiscard |
Program the Output Data Rate for both the accelerometer and the gyroscope.
Writes odr into the ODR_XL field of CTRL1_XL and the ODR_G field of CTRL2_G. The full-scale nibble of each register is preserved by reading the current value first. The two blocks share an ODR scale (DS12140 sec 5.3 "Output data rate and bandwidth selection") so one parameter covers both.
| [in,out] | dev | Driver instance. |
| [in] | odr | ODR code (one of k_lsm6dso_odr_*). |
| k_ra8_ok | ODR programmed for XL and G. |
| k_ra8_err_null_ptr | dev is NULL. |
| k_ra8_err_invalid_state | dev not initialized. |
| k_ra8_err_invalid_arg | odr out of range. |
| k_ra8_err_nack | Transport reported a NACK. |
Definition at line 344 of file ra8_lsm6dso.c.
References ra8_lsm6dso_t::initialized, internal_lsm6dso_rmw_odr(), k_lsm6dso_mask_nibble, k_lsm6dso_odr_cap, k_lsm6dso_reg_ctrl1_xl, k_lsm6dso_reg_ctrl2_g, k_lsm6dso_shift_odr, k_ra8_err_invalid_arg, k_ra8_ok, ra8_lsm6dso_t::odr_code, RA8_CHECK_NULL_PTR, RA8_CHECK_RANGE_TAG, RA8_VALIDATE_INIT, and s_lsm6dso_tag.
Referenced by imu_demo_configure().
|
nodiscard |
Read the WHO_AM_I register.
Reads register 0x0F and returns the raw byte. On a healthy LSM6DSO this is 0x6C (k_lsm6dso_who_am_i_value); any other value means the wrong part is wired or the bus is mis-addressed.
| [in] | dev | Driver instance. |
| [out] | out_id | Receives the WHO_AM_I byte. |
| k_ra8_ok | *out_id populated. |
| k_ra8_err_null_ptr | dev or out_id is NULL. |
| k_ra8_err_invalid_state | dev has not been initialized. |
| k_ra8_err_nack | Transport reported a NACK. |
Definition at line 276 of file ra8_lsm6dso.c.
References ra8_lsm6dso_t::initialized, internal_lsm6dso_read_byte(), k_lsm6dso_reg_who_am_i, RA8_CHECK_NULL_PTR, RA8_VALIDATE_INIT, and s_lsm6dso_tag.
Referenced by imu_demo_check_who_am_i().
|
static |
Tag for ra8_log_error / ra8_log_info lines from this TU.
Definition at line 44 of file ra8_lsm6dso.c.
Referenced by internal_lsm6dso_fifo_check_args(), ra8_lsm6dso_init(), ra8_lsm6dso_read_accel(), ra8_lsm6dso_read_gyro(), ra8_lsm6dso_read_temp(), ra8_lsm6dso_set_accel_range(), ra8_lsm6dso_set_gyro_range(), ra8_lsm6dso_set_odr(), and ra8_lsm6dso_who_am_i().