|
PCA9685 Driver 0.1.0
API reference
|
The I2C port of the PCA9685 driver: the bus requirements, the CRTP base, the I2cPort concept, the optional port hooks and the register framing.
More...
#include <array>#include <concepts>#include <cstddef>#include <cstdint>#include <span>#include "pca9685_detail.hpp"#include "pca9685_types.hpp"Go to the source code of this file.
Classes | |
| class | pca9685::I2cInterface< Derived > |
| CRTP base of the platform I2C port. More... | |
Namespaces | |
| namespace | pca9685 |
The PCA9685 driver: everything it declares lives here; internals in detail. | |
Concepts | |
| concept | pca9685::I2cPort |
Satisfied by a class that derives from I2cInterface<Port> and implements the required bus hooks with exactly the types above, noexcept and returning bool. | |
Enumerations | |
| enum class | pca9685::CtrlPin : uint8_t { pca9685::OutputEnable = 0 } |
Control pins the port may drive through the optional GpioSet() hook. More... | |
| enum class | pca9685::GpioSignal : uint8_t { pca9685::INACTIVE = 0 , pca9685::ACTIVE = 1 } |
| Logical level of a control pin; the port maps it to the physical polarity. More... | |
| enum class | pca9685::I2cFailure : uint8_t { pca9685::Other = 0 , pca9685::AddressNack = 1 , pca9685::DataNack = 2 } |
Why a Write() or WriteRead() hook returned false, as the optional GetLastFailure() hook reports it. More... | |
Variables | |
Bus requirements | |
What the PCA9685 needs from the I2C bus. A port and a board configuration check their settings against these with | |
| constexpr uint8_t | pca9685::kI2cAddress = kMinI2cAddress |
| 7-bit I2C address with A5 to A0 low, 1000000 (section 7.1.1, figure 4); the pins add 0 to 63. | |
| constexpr uint32_t | pca9685::kMaxClockHz = 1'000'000U |
| Highest SCL frequency: Fast-mode Plus, 1 MHz (table 15, f_SCL). | |
| constexpr bool | pca9685::kRepeatedStart = true |
The I2C port of the PCA9685 driver: the bus requirements, the CRTP base, the I2cPort concept, the optional port hooks and the register framing.
The driver never calls an SDK. It calls hooks on a class you derive from pca9685::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. After a NACK the port still sends the STOP |
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, addr + R, rx_len bytes (NACK on the last), STOP |
void DelayUs(uint32_t us) noexcept | Wait at least us microseconds: the 500 us oscillator start-up |
bool GpioSet(CtrlPin pin, GpioSignal signal) noexcept (optional) | Drive the OE pin: ACTIVE enables the outputs (OE low), INACTIVE disables them (OE high) |
bool GetLastFailure(I2cFailure& failure) noexcept (optional) | After Write() or WriteRead() returned false: why. true and failure set when the port knows |
void Log(LogLevel level, const char* message) noexcept (optional) | One plain-text line per lifecycle event or failure |
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 (kI2cAddress, kMaxClockHz, kRepeatedStart); a port checks its settings against them with static_assert.
Section, table and figure numbers refer to the NXP PCA9685 product data sheet, Rev. 4 (16 April 2015).