Skip to main content

Crate edrv_spl06

Crate edrv_spl06 

Source
Expand description

Driver for the Goertek SPL06-001 and the register-compatible SPL06-007 digital barometric pressure sensor.

The SPL06-001 / SPL06-007 is a calibrated digital barometer with 24-bit pressure and temperature conversion results. This crate provides both an asynchronous driver (SPL06) and a blocking one (blocking::SPL06) with identical APIs, built on embedded-hal v1.

§Compensation

The datasheet defines the compensation as a real-number polynomial (SPL06-001 V1.0 sections 5.7.1/5.7.2, SPL06-007 V1.0 sections 5.6.1/5.6.2):

Traw_sc = Traw / kT
Praw_sc = Praw / kP

Tcomp(degC) = c0 * 0.5 + c1 * Traw_sc
Pcomp(Pa)   = c00 + Praw_sc * (c10 + Praw_sc * (c20 + Praw_sc * c30))
                   + Traw_sc * c01
                   + Traw_sc * Praw_sc * (c11 + Praw_sc * c21)

kP and kT are not constants. Each depends on the configured oversampling rate (Table 7 of the SPL06-001 datasheet), so the raw 24-bit values must be divided by the factor that belongs to the oversampling the driver is actually using. Using the wrong factor silently produces a plausible-looking but wrong reading.

The driver evaluates the polynomial in integer Q24 fixed-point arithmetic, so it does no floating point itself; the f32 accessors on Measurements are the only conversion and stay out of the generated code for a target without an FPU unless they are actually called.

§Init and reset

SPL06::init reads the product/revision ID register (0x0D, expected value PRODUCT_ID = 0x10) and the 18-byte calibration block at 0x10, then programs the default oversampling. Like edrv-bme280 and edrv-bme680, init deliberately does not soft reset; SPL06::reset is a separate, explicit step.

§Licence

This crate is distributed under MIT OR Apache-2.0.

Modules§

blocking
Blocking API.
regs
Register addresses, register field masks and block lengths.

Structs§

CalibrationData
Calibration coefficients, named after the datasheet’s COEF registers.
Config
Oversampling configuration, with the register writes it implies.
Measurements
One compensated measurement.
SPL06
Async SPL06-001 / SPL06-007 driver.

Enums§

Error
Errors returned by the SPL06 driver.
Oversampling
Oversampling (precision) setting for one measurement channel.

Constants§

ADDRESS
I2C address with SDO high - the sensor’s default address.
ADDRESS_ALT
I2C address with SDO pulled down to GND.
PRODUCT_ID
Value expected in the product/revision ID register (regs::ID).
SOFT_RESET_COMMAND
Value written to regs::RESET to trigger a soft reset.