Nexus Embedded Platform 0.1.0
Statically assembled reusable embedded mechanisms
Loading...
Searching...
No Matches
bmp280.h File Reference

BMP280 calibration and explicit forced-conversion driver. More...

#include "nexus/core/time.h"

Go to the source code of this file.

Data Structures

struct  nx_bmp280_transport_port_t
 Synchronous settled SPI transaction port. More...
struct  nx_bmp280_calibration_t
 Register calibration, owned by one device instance. More...
struct  nx_bmp280_sample_t
 Output is valid only on successful conversion/compensation. More...
struct  nx_bmp280_t
 Explicit device context, no Board pins or automatic sampling task. More...

Functions

nx_result_t nx_bmp280_parse_calibration (const uint8_t *bytes, size_t length, nx_bmp280_calibration_t *calibration)
 Parse the exact 24-byte little-endian calibration block.
nx_result_t nx_bmp280_compensate (const nx_bmp280_calibration_t *calibration, uint32_t raw_temperature, uint32_t raw_pressure, nx_bmp280_sample_t *sample)
 Compensate one raw sample using checked integer arithmetic.
nx_result_t nx_bmp280_init (nx_bmp280_t *device, nx_bmp280_transport_port_t transport, nx_time_us_t deadline)
 Validate chip ID and load calibration, without scanning.
nx_result_t nx_bmp280_begin (nx_bmp280_t *device, nx_time_us_t deadline)
 Start one forced temperature/pressure conversion.
nx_result_t nx_bmp280_poll (nx_bmp280_t *device, nx_bmp280_sample_t *sample)
 Poll conversion without an implicit worker or blocking delay.
void nx_bmp280_stop (nx_bmp280_t *device)
 Stop software use after all synchronous calls have exited.

Detailed Description

BMP280 calibration and explicit forced-conversion driver.

Author
Nexus Team

Definition in file bmp280.h.

Function Documentation

◆ nx_bmp280_begin()

nx_result_t nx_bmp280_begin ( nx_bmp280_t * device,
nx_time_us_t deadline )

Start one forced temperature/pressure conversion.

Parameters
[in,out]deviceInitialized non-measuring instance
[in]deadlineAbsolute deadline covering conversion and reads
Returns
SUCCESS, BUSY, TIMEOUT or transport error
Note
Task-only serialized driver owner; oversampling x1/x1.

◆ nx_bmp280_compensate()

nx_result_t nx_bmp280_compensate ( const nx_bmp280_calibration_t * calibration,
uint32_t raw_temperature,
uint32_t raw_pressure,
nx_bmp280_sample_t * sample )

Compensate one raw sample using checked integer arithmetic.

Parameters
[in]calibrationParsed calibration
[in]raw_temperatureUnsigned 20-bit ADC value
[in]raw_pressureUnsigned 20-bit ADC value
[out]sampleWritten only on success
Returns
SUCCESS, INVALID for malformed/overflow calibration or IO for disabled ADC sentinel/out-of-datasheet-range physical output

◆ nx_bmp280_init()

nx_result_t nx_bmp280_init ( nx_bmp280_t * device,
nx_bmp280_transport_port_t transport,
nx_time_us_t deadline )

Validate chip ID and load calibration, without scanning.

Parameters
[out]deviceZero-initialized unused instance
[in]transportSynchronous settled port and live monotonic clock
[in]deadlineAbsolute deadline for all initialization accesses
Returns
SUCCESS, BUSY for NVM update, or transport/identity error
Note
Task context; failure leaves initialized false and no borrow. Does not soft-reset the part or create a wait loop/task. Retry BUSY explicitly.

◆ nx_bmp280_parse_calibration()

nx_result_t nx_bmp280_parse_calibration ( const uint8_t * bytes,
size_t length,
nx_bmp280_calibration_t * calibration )

Parse the exact 24-byte little-endian calibration block.

Parameters
[in]bytesRegister block beginning at 0x88
[in]lengthMust be exactly 24
[out]calibrationWritten only on success
Returns
SUCCESS or INVALID for length/zero pressure divisor

◆ nx_bmp280_poll()

nx_result_t nx_bmp280_poll ( nx_bmp280_t * device,
nx_bmp280_sample_t * sample )

Poll conversion without an implicit worker or blocking delay.

Parameters
[in,out]deviceInstance with a previously started conversion
[out]sampleWritten only on SUCCESS
Returns
SUCCESS, BUSY while converting, TIMEOUT or transport error
Note
Task-only. Every port call releases temporary buffers before return. BUSY retains device conversion state, never stack or caller buffers. After terminal failure, begin may retry; the external owner chooses policy.

◆ nx_bmp280_stop()

void nx_bmp280_stop ( nx_bmp280_t * device)

Stop software use after all synchronous calls have exited.

Parameters
[in,out]deviceQuiesced driver instance
Note
Does not power off or reset a physical part. Sensor-internal conversion can finish without accessing MCU storage. No MCU borrow remains.