BMP581 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Concepts | Enumerations | Variables
bmp581_i2c_interface.hpp File Reference

The I2C port of the BMP581 driver: the CRTP base, the I2cPort concept, the bus requirements and the register framing. More...

#include <array>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <span>
#include "bmp581_detail.hpp"
#include "bmp581_registers.hpp"
#include "bmp581_types.hpp"

Go to the source code of this file.

Classes

class  bmp581::I2cInterface< Derived >
 CRTP base of the platform I2C port. More...
 

Namespaces

namespace  bmp581
 The BMP581 driver: everything it declares lives here; internals in detail.
 
namespace  bmp581::i2c
 What the BMP581 needs from the I2C bus (sections 5.6, 6.2.3, table 4). A port and a board configuration check their settings against these with static_assert (handbook KB-CPP-123).
 

Concepts

concept  bmp581::I2cPort
 Satisfied by a class that derives from I2cInterface<Port> and implements the required hooks with exactly the types above, noexcept and returning bool.
 

Enumerations

enum class  bmp581::I2cFailure : uint8_t { bmp581::Other = 0 , bmp581::AddressNack = 1 , bmp581::DataNack = 2 }
 Why an I2C transfer failed, as the optional GetLastFailure() hook reports it. More...
 

Variables

constexpr uint8_t bmp581::i2c::kI2cAddress = 0x46
 7-bit address with SDO low (section 5.6). SDO must not float on I2C.
 
constexpr uint8_t bmp581::i2c::kI2cAddressSdoHigh = 0x47
 7-bit address with SDO high (section 5.6).
 
constexpr uint32_t bmp581::i2c::kMaxClockHz = 1'000'000
 Highest SCL frequency: fast mode plus, with C_bus below 100 pF (table 4, f_i2c).
 
constexpr uint32_t bmp581::i2c::kMinClockHz = 100'000
 Lowest SCL frequency (table 4, f_i2c).
 
constexpr bool bmp581::i2c::kRepeatedStart = false
 

Detailed Description

The I2C port of the BMP581 driver: the CRTP base, the I2cPort concept, the bus requirements and the register framing.

The driver never calls an SDK. On I2C it calls hooks on a class you derive from bmp581::I2cInterface<Self>:

Hook Contract
bool EnsureInitialized() noexcept Bring the bus up on the first call; true at once afterwards
bool Write(uint8_t addr, const uint8_t* data, std::size_t len) noexcept START, addr + W, len bytes, STOP; false on a NACK or bus error
bool WriteRead(uint8_t addr, const uint8_t* tx, std::size_t tx_len, uint8_t* rx, std::size_t rx_len) noexcept START, addr + W, tx, repeated START (or STOP and START), addr + R, rx_len bytes, STOP
bool GetLastFailure(I2cFailure& failure) noexcept (optional) After Write() or WriteRead() returned false: why. true and failure set when the port knows

addr is the 7-bit address. The port moves raw bytes: the register address travels in the payload, and the port never retries or configures the chip. What the chip needs from the bus is below as constexpr values in bmp581::i2c; a port checks its settings against them with static_assert. DelayUs() and Log() are described in bmp581.hpp.

Section, table and figure numbers refer to the Bosch BMP581 datasheet, document BST-BMP581-DS004-13, revision 1.13.