Expand description
The C ABI for the sensor drivers that run over an I2C bus.
A driver runs the datasheet’s whole conversation with a part over a PamojaI2cBus:
reset, identify, read the calibration, configure, measure. It holds a share of the bus, so
the caller may free its own bus handle straight after building the driver, or keep it to
look at the bus between reads. A driver waits as its datasheet asks through the bus’s
delay, which sleeps only when real parts are on the other end.
Every part has a simulated twin that answers a driver with nothing plugged in: a
_sim_part that reads the datasheet’s typical values and a _sim_reporting that reads
whatever it is asked to. Either goes on a simulated bus with
pamoja_i2c_bus_attach.
A driver’s failure is PamojaStatus::Io when the bus failed or the part never finished,
and PamojaStatus::Codec when a part answered but is not the one the driver expected or
its checksum failed, with the reason in the last error message either way.
The DS18B20 is the exception: on a Linux board it is not driven over a bus but read through
the files the kernel’s 1-Wire driver serves, which pamoja_ds18b20_thermometer_read does.
Structs§
- Pamoja
Ads1115 - An ADS1115 driven over an I2C bus. Opaque; release it with
pamoja_ads1115_free. - Pamoja
Ads1115 Sample - One ADS1115 conversion.
- Pamoja
Ads1115 Settings - How an ADS1115 driver converts: which input, at which range, how fast.
- Pamoja
Bme280 - A BME280 driven over an I2C bus. Opaque; release it with
pamoja_bme280_free. - Pamoja
Bme280 Settings - How a BME280 driver measures: the oversampling of each measurement and the IIR filter.
- Pamoja
Bmp280 - A BMP280 driven over an I2C bus. Opaque; release it with
pamoja_bmp280_free. - Pamoja
Bmp280 Settings - How a BMP280 driver measures: the oversampling of each measurement and the IIR filter.
- Pamoja
Ds18b20 Thermometer - A DS18B20 the Linux kernel serves as a
w1_slavefile. Opaque; release it withpamoja_ds18b20_thermometer_free. - Pamoja
Ds18b20 Thermometers - The DS18B20s the kernel has found, in order of their directory names. Opaque; release it
with
pamoja_ds18b20_thermometers_free. - Pamoja
Hdc1080 - An HDC1080 driven over an I2C bus. Opaque; release it with
pamoja_hdc1080_free. - Pamoja
Hdc1080 Settings - How an HDC1080 driver measures: the resolution of each channel.
- Pamoja
Ina219 - An INA219 driven over an I2C bus. Opaque; release it with
pamoja_ina219_free. - Pamoja
Ina226 - An INA226 driven over an I2C bus. Opaque; release it with
pamoja_ina226_free. - Pamoja
Ina219 Reading - One INA219 conversion: the four result registers as read, and what they mean.
- Pamoja
Ina219 Settings - How an INA219 driver measures: the shunt, the current it is sized for, and the register settings.
- Pamoja
Ina226 Reading - One INA226 conversion: the four result registers as read, and what they mean.
- Pamoja
Ina226 Settings - How an INA226 driver measures: the shunt, the current it is sized for, and the register settings.
- Pamoja
Opt3001 - An OPT3001 driven over an I2C bus. Opaque; release it with
pamoja_opt3001_free. - Pamoja
Opt3001 Reading - An OPT3001 illuminance result.
- Pamoja
Opt3001 Settings - How an OPT3001 driver measures.
- Pamoja
Scd4x - An SCD40 or SCD41 driven over an I2C bus. Opaque; release it with
pamoja_scd4x_free. - Pamoja
Sht3x - An SHT3x driven over an I2C bus. Opaque; release it with
pamoja_sht3x_free. - Pamoja
Tmp117 - A TMP117 driven over an I2C bus. Opaque; release it with
pamoja_tmp117_free. - Pamoja
Tmp117 Alerts - The TMP117’s alert flags: whether a result since they were last read crossed a limit.
- Pamoja
Tmp117 Reading - A TMP117 temperature result.
Constants§
- PAMOJA_
ADS1115_ SIM_ VOLTS - The voltage a simulated ADS1115 reports unless it is asked for another: half a 3.3 V supply.
- PAMOJA_
BME280_ SIM_ STATUS_ IDLE - The status a simulated BME280 reports when it is neither measuring nor loading its calibration.
- PAMOJA_
BMP280_ SIM_ STATUS_ IDLE - The status a simulated BMP280 reports when it is neither measuring nor loading its calibration.
- PAMOJA_
HDC1080_ SIM_ CELSIUS - The temperature a simulated HDC1080 reports unless it is asked for another.
- PAMOJA_
HDC1080_ SIM_ RELATIVE_ HUMIDITY - The relative humidity a simulated HDC1080 reports unless it is asked for another.
- PAMOJA_
INA219_ SIM_ BUS_ MILLIVOLTS - The bus voltage a simulated INA219 reports unless it is asked for another, in millivolts.
- PAMOJA_
INA219_ SIM_ MAX_ MICROAMPS - The largest current a simulated INA219 is sized for, in microamps.
- PAMOJA_
INA219_ SIM_ MICROAMPS - The current a simulated INA219 reports unless it is asked for another, in microamps.
- PAMOJA_
INA219_ SIM_ SHUNT_ MILLIOHMS - The shunt a simulated INA219 sits across, in milliohms: the common breakout’s.
- PAMOJA_
INA226_ SIM_ BUS_ MICROVOLTS - The bus voltage a simulated INA226 reports unless it is asked for another, in microvolts.
- PAMOJA_
INA226_ SIM_ MAX_ MICROAMPS - The largest current a simulated INA226 is sized for, in microamps.
- PAMOJA_
INA226_ SIM_ MICROAMPS - The current a simulated INA226 reports unless it is asked for another, in microamps.
- PAMOJA_
INA226_ SIM_ SHUNT_ MILLIOHMS - The shunt a simulated INA226 sits across, in milliohms.
- PAMOJA_
OPT3001_ SIM_ LUX - The illuminance a simulated OPT3001 reports unless it is asked for another.
- PAMOJA_
SCD4X_ SIM_ CELSIUS - The temperature a simulated SCD4x reports unless it is asked for another.
- PAMOJA_
SCD4X_ SIM_ CO2_ PPM - The carbon dioxide a simulated SCD4x reports unless it is asked for another, in parts per million.
- PAMOJA_
SCD4X_ SIM_ RELATIVE_ HUMIDITY - The relative humidity a simulated SCD4x reports unless it is asked for another.
- PAMOJA_
SCD4X_ SIM_ SERIAL - The serial number every simulated SCD4x reports.
- PAMOJA_
SHT3X_ SIM_ CELSIUS - The temperature a simulated SHT3x reports unless it is asked for another.
- PAMOJA_
SHT3X_ SIM_ RELATIVE_ HUMIDITY - The relative humidity a simulated SHT3x reports unless it is asked for another.
- PAMOJA_
TMP117_ SIM_ CELSIUS - The temperature a simulated TMP117 reports unless it is asked for another.
Functions§
- pamoja_
ads1115_ ⚠config - Copies the configuration an ADS1115 driver writes.
- pamoja_
ads1115_ ⚠free - Releases a driver and its share of the bus. A null pointer is ignored.
- pamoja_
ads1115_ ⚠init - Writes the input, range, and data rate, and reads the configuration back, which is the identity check a part with no id register allows.
- pamoja_
ads1115_ ⚠new - Creates an ADS1115 driver on a bus. Nothing is sent until
pamoja_ads1115_initor the firstpamoja_ads1115_sample. - pamoja_
ads1115_ ⚠sample - Runs one conversion of the configured input, initializing the part first if
pamoja_ads1115_inithas not run. - pamoja_
ads1115_ ⚠sample_ input - Converts another input once, leaving the configured input as it was.
- pamoja_
ads1115_ settings_ default - Returns the settings an ADS1115 driver starts with, the part’s own reset settings: AIN0 against AIN1, the 2.048 V range, and 128 samples per second.
- pamoja_
ads1115_ sim_ part - Creates a simulated ADS1115 reading
PAMOJA_ADS1115_SIM_VOLTSat the range a driver starts with. - pamoja_
ads1115_ sim_ reporting - Creates a simulated ADS1115 that reads what it is asked to at the range a driver converts at.
- pamoja_
bme280_ ⚠free - Releases a driver and its share of the bus. A null pointer is ignored.
- pamoja_
bme280_ ⚠init - Resets the part, checks it is a BME280, reads its calibration, and writes the settings, in the order the datasheet requires, leaving the part asleep.
- pamoja_
bme280_ ⚠measure - Runs one forced measurement and compensates it, initializing the part first if
pamoja_bme280_inithas not run. - pamoja_
bme280_ ⚠new - Creates a BME280 driver on a bus. Nothing is sent until
pamoja_bme280_initor the firstpamoja_bme280_measure. - pamoja_
bme280_ settings_ default - Returns the settings a BME280 driver starts with: every measurement at oversampling x1 and the filter off.
- pamoja_
bme280_ ⚠sim_ burst - Copies the one measurement a simulated BME280 holds: the eight data registers a real part read, which compensate to 20.44 C, 848.05 hPa, and 44.65 % against its calibration.
- pamoja_
bme280_ ⚠sim_ burst_ for - Builds the eight data registers a simulated BME280 holds when it reports a reading.
- pamoja_
bme280_ ⚠sim_ calibration - Copies the calibration a simulated BME280 holds: the two blocks a driver reads at start-up.
- pamoja_
bme280_ sim_ part - Creates a simulated BME280 holding a real part’s calibration and one measurement it took, which compensate to 20.44 C, 848.05 hPa, and 44.65 %.
- pamoja_
bme280_ sim_ reporting - Creates a simulated BME280 that reads what it is asked to.
- pamoja_
bmp280_ ⚠coefficients - Copies the trimming coefficients a BMP280 driver read at initialization.
- pamoja_
bmp280_ ⚠free - Releases a driver and its share of the bus. A null pointer is ignored.
- pamoja_
bmp280_ ⚠init - Resets the part, checks it is a BMP280, reads its trimming coefficients, and writes the settings, leaving the part asleep.
- pamoja_
bmp280_ ⚠measure - Runs one forced measurement and compensates it, initializing the part first if
pamoja_bmp280_inithas not run. - pamoja_
bmp280_ ⚠new - Creates a BMP280 driver on a bus. Nothing is sent until
pamoja_bmp280_initor the firstpamoja_bmp280_measure. - pamoja_
bmp280_ settings_ default - Returns the settings a BMP280 driver starts with: both measurements at oversampling x1 and the filter off.
- pamoja_
bmp280_ ⚠sim_ burst - Copies the six data registers a simulated BMP280 holds: one measurement a real part took.
- pamoja_
bmp280_ ⚠sim_ burst_ for - Builds the six data registers a simulated BMP280 holds when it reports a reading.
- pamoja_
bmp280_ ⚠sim_ calibration - Copies the 24 trimming bytes a simulated BMP280 holds.
- pamoja_
bmp280_ sim_ part - Creates a simulated BMP280 holding a real part’s trimming and one measurement it took, which compensate to 20.44 C and 848.05 hPa.
- pamoja_
bmp280_ sim_ reporting - Creates a simulated BMP280 that reads what it is asked to.
- pamoja_
ds18b20_ ⚠discover - Lists every DS18B20 the kernel has found: one per
28-directory. - pamoja_
ds18b20_ ⚠thermometer_ at - Names a DS18B20 by the path of its
w1_slavefile, for a system that mounts sysfs elsewhere or a test that writes the file itself. - pamoja_
ds18b20_ ⚠thermometer_ free - Releases a thermometer. A null pointer is ignored.
- pamoja_
ds18b20_ ⚠thermometer_ new - Names a DS18B20 the kernel serves by the serial in its directory name, reading
/sys/bus/w1/devices/28-<serial>/w1_slave. - pamoja_
ds18b20_ ⚠thermometer_ path - Returns the path of the file a thermometer reads.
- pamoja_
ds18b20_ ⚠thermometer_ read - Reads a thermometer’s file, which makes the kernel run a conversion, and decodes it.
- pamoja_
ds18b20_ ⚠thermometer_ serial - Returns the serial the kernel named a thermometer’s directory after.
- pamoja_
ds18b20_ ⚠thermometers_ free - Releases a list of thermometers. A null pointer is ignored.
- pamoja_
ds18b20_ ⚠thermometers_ get - Copies one thermometer out of a list.
- pamoja_
ds18b20_ ⚠thermometers_ len - Returns how many thermometers a list holds.
- pamoja_
hdc1080_ ⚠configuration - Copies the configuration an HDC1080 driver writes.
- pamoja_
hdc1080_ ⚠free - Releases a driver and its share of the bus. A null pointer is ignored.
- pamoja_
hdc1080_ ⚠heater - Switches the on-die heater, which runs only during acquisitions, on or off.
- pamoja_
hdc1080_ ⚠init - Checks the part is an HDC1080 and writes the configuration.
- pamoja_
hdc1080_ ⚠measure - Triggers one acquisition of both channels and reads them, initializing the part first if
pamoja_hdc1080_inithas not run. - pamoja_
hdc1080_ ⚠new - Creates an HDC1080 driver on a bus; the part has one address. Nothing is sent until
pamoja_hdc1080_initor the firstpamoja_hdc1080_measure. - pamoja_
hdc1080_ settings_ default - Returns the settings an HDC1080 driver starts with: both channels at 14 bits.
- pamoja_
hdc1080_ sim_ part - Creates a simulated HDC1080 reading
PAMOJA_HDC1080_SIM_CELSIUSandPAMOJA_HDC1080_SIM_RELATIVE_HUMIDITY. - pamoja_
hdc1080_ sim_ reporting - Creates a simulated HDC1080 that reads what it is asked to.
- pamoja_
ina219_ ⚠calibration_ word - Returns the calibration word an INA219 driver programs.
- pamoja_
ina219_ ⚠current_ lsb - Returns the current step an INA219 driver programs.
- pamoja_
ina219_ ⚠free - Releases a driver and its share of the bus. A null pointer is ignored.
- pamoja_
ina219_ ⚠init - Resets the part, writes the configuration and the calibration, and reads the calibration back, which is the identity check a part with no id register allows.
- pamoja_
ina219_ ⚠measure - Triggers one shunt and bus conversion and reads every result, initializing the part first
if
pamoja_ina219_inithas not run. - pamoja_
ina219_ ⚠new - Creates an INA219 driver on a bus. Nothing is sent until
pamoja_ina219_initor the firstpamoja_ina219_measure. - pamoja_
ina219_ settings_ default - Returns the settings an INA219 driver starts with: a 100 milliohm shunt sized for 3.2 A, the common breakout, the finest current step for it, and the power-on register settings.
- pamoja_
ina219_ sim_ part - Creates a simulated INA219 carrying
PAMOJA_INA219_SIM_MICROAMPSatPAMOJA_INA219_SIM_BUS_MILLIVOLTSthrough the shunt a driver starts with. - pamoja_
ina219_ sim_ reporting - Creates a simulated INA219 that reads what it is asked to, calibrated for the same shunt and largest current a driver is given.
- pamoja_
ina226_ ⚠calibration_ word - Returns the calibration word an INA226 driver programs.
- pamoja_
ina226_ ⚠current_ lsb - Returns the current step an INA226 driver programs.
- pamoja_
ina226_ ⚠free - Releases a driver and its share of the bus. A null pointer is ignored.
- pamoja_
ina226_ ⚠identity - Reports the die id an INA226 driver read at initialization.
- pamoja_
ina226_ ⚠init - Resets the part, checks it is an INA226, writes the configuration and the calibration, and reads the calibration back.
- pamoja_
ina226_ ⚠measure - Triggers one shunt and bus conversion and reads every result, initializing the part first
if
pamoja_ina226_inithas not run. - pamoja_
ina226_ ⚠new - Creates an INA226 driver on a bus. Nothing is sent until
pamoja_ina226_initor the firstpamoja_ina226_measure. - pamoja_
ina226_ ⚠set_ alert - Programs the alert pin: which limit it watches, and the limit.
- pamoja_
ina226_ settings_ default - Returns the settings an INA226 driver starts with: a 100 milliohm shunt sized for 3.2 A, the finest current step for it, and the power-on register settings.
- pamoja_
ina226_ sim_ part - Creates a simulated INA226 carrying
PAMOJA_INA226_SIM_MICROAMPSatPAMOJA_INA226_SIM_BUS_MICROVOLTSthrough the shunt a driver starts with. - pamoja_
ina226_ sim_ reporting - Creates a simulated INA226 that reads what it is asked to, calibrated for the same shunt and largest current a driver is given.
- pamoja_
opt3001_ ⚠configuration - Copies the configuration an OPT3001 driver writes, with the part in shutdown.
- pamoja_
opt3001_ ⚠free - Releases a driver and its share of the bus. A null pointer is ignored.
- pamoja_
opt3001_ ⚠init - Checks the part is an OPT3001 and writes the settings with the part in shutdown.
- pamoja_
opt3001_ ⚠measure - Runs one conversion and reads the illuminance, initializing the part first if
pamoja_opt3001_inithas not run. - pamoja_
opt3001_ ⚠new - Creates an OPT3001 driver on a bus. Nothing is sent until
pamoja_opt3001_initor the firstpamoja_opt3001_measure. - pamoja_
opt3001_ ⚠set_ limits - Writes the low and high limits the part’s interrupt pin compares each result against.
- pamoja_
opt3001_ settings_ default - Returns the settings an OPT3001 driver starts with, the part’s own reset settings: the 800 ms integration time and the range chosen automatically.
- pamoja_
opt3001_ sim_ part - Creates a simulated OPT3001 reading
PAMOJA_OPT3001_SIM_LUX. - pamoja_
opt3001_ sim_ reporting - Creates a simulated OPT3001 that reads what it is asked to. Its configuration register keeps the flags the part sets for itself, with the conversion-ready flag set.
- pamoja_
scd4x_ ⚠free - Releases a driver and its share of the bus. A null pointer is ignored.
- pamoja_
scd4x_ ⚠init - Stops any running measurement, reads the serial number, and starts periodic measurement, after which the part has a new result every five seconds.
- pamoja_
scd4x_ ⚠measure - Waits for the next periodic result and reads it, initializing the part first if
pamoja_scd4x_inithas not run. - pamoja_
scd4x_ ⚠measure_ single_ shot - Runs one on-demand measurement on an SCD41, which takes five seconds. The part must not be
measuring periodically: call
pamoja_scd4x_stopfirst, or use this in place ofpamoja_scd4x_init. - pamoja_
scd4x_ ⚠new - Creates an SCD40 or SCD41 driver on a bus; the part has one address. Nothing is sent until
pamoja_scd4x_initor the firstpamoja_scd4x_measure. - pamoja_
scd4x_ ⚠poll_ ready - Asks the part whether a periodic result is waiting.
- pamoja_
scd4x_ ⚠serial - Reports the serial number an SCD4x driver read at initialization.
- pamoja_
scd4x_ ⚠set_ sensor_ altitude - Sets the altitude the part corrects its carbon dioxide reading for, stopping periodic measurement to write it and starting it again.
- pamoja_
scd4x_ ⚠set_ temperature_ offset - Sets the temperature offset that compensates the part’s own warmth, stopping periodic measurement to write it and starting it again. The setting lasts until power is lost.
- pamoja_
scd4x_ sim_ part - Creates a simulated SCD4x reading
PAMOJA_SCD4X_SIM_CO2_PPM,PAMOJA_SCD4X_SIM_CELSIUS, andPAMOJA_SCD4X_SIM_RELATIVE_HUMIDITY. - pamoja_
scd4x_ sim_ reporting - Creates a simulated SCD4x that reads what it is asked to. It answers the serial number, data-ready, and measurement commands, and always has a result waiting.
- pamoja_
scd4x_ ⚠start - Starts periodic measurement.
- pamoja_
scd4x_ ⚠stop - Stops periodic measurement, after which the part takes its settings commands.
- pamoja_
sht3x_ ⚠free - Releases a driver and its share of the bus. A null pointer is ignored.
- pamoja_
sht3x_ ⚠heater_ off - Switches the heater off, which is its state after any reset.
- pamoja_
sht3x_ ⚠heater_ on - Switches the plausibility-check heater on, initializing the part first if needed, since the reset in initialization switches it off.
- pamoja_
sht3x_ ⚠init - Soft-resets the part and reads its status; a status word whose CRC checks is what confirms an SHT3x answers, as the part has no id register.
- pamoja_
sht3x_ ⚠last_ status - Reports the status an SHT3x driver last read, without reading it again.
- pamoja_
sht3x_ ⚠measure - Runs one single-shot measurement, initializing the part first if
pamoja_sht3x_inithas not run. - pamoja_
sht3x_ ⚠new - Creates an SHT3x driver on a bus. Nothing is sent until
pamoja_sht3x_initor the firstpamoja_sht3x_measure. - pamoja_
sht3x_ ⚠read_ status - Reads the status register.
- pamoja_
sht3x_ sim_ part - Creates a simulated SHT3x reading
PAMOJA_SHT3X_SIM_CELSIUSandPAMOJA_SHT3X_SIM_RELATIVE_HUMIDITY. - pamoja_
sht3x_ sim_ reporting - Creates a simulated SHT3x that reads what it is asked to. It answers every single-shot command, a periodic fetch, and the status command with the replies a real part gives.
- pamoja_
tmp117_ ⚠alerts - Reads the alert flags: whether a result since the last call was above the high limit or below the low limit, including results the driver’s own reads saw.
- pamoja_
tmp117_ ⚠free - Releases a driver and its share of the bus. A null pointer is ignored.
- pamoja_
tmp117_ ⚠init - Checks the part is a TMP117, waits for its EEPROM to finish loading, and writes the settings with the part in shutdown.
- pamoja_
tmp117_ ⚠measure - Runs one conversion and reads the temperature, initializing the part first if
pamoja_tmp117_inithas not run. - pamoja_
tmp117_ ⚠new - Creates a TMP117 driver on a bus. Nothing is sent until
pamoja_tmp117_initor the firstpamoja_tmp117_measure. - pamoja_
tmp117_ ⚠set_ alert_ limits - Writes the high and low limits the part compares each result against.
- pamoja_
tmp117_ ⚠silicon_ revision - Reports the silicon revision a TMP117 driver read at initialization.
- pamoja_
tmp117_ sim_ part - Creates a simulated TMP117 reading
PAMOJA_TMP117_SIM_CELSIUS. - pamoja_
tmp117_ sim_ reporting - Creates a simulated TMP117 that reads what it is asked to. Its configuration register keeps the flags the part sets for itself, with the data-ready flag set.