PCAL9555 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Enumerations | Functions | Variables
pcal9555_types.hpp File Reference

Public types of the PCAL9555 driver: errors, Result<T>, pins and configuration. More...

#include <cstdint>
#include "pcal9555_version.h"

Go to the source code of this file.

Classes

struct  pcal9555::Result< T >
 The value of a call, or why there is none. More...
 
struct  pcal9555::Result< void >
 The result of a call that returns no value. More...
 
struct  pcal9555::Config
 Everything EnsureInitialized() and ApplyConfig() write to the chip. More...
 

Namespaces

namespace  pcal9555
 The PCAL9555 driver: everything it declares lives here; internals in detail.
 

Enumerations

enum class  pcal9555::Error : uint8_t {
  pcal9555::Error::Ok = 0 , pcal9555::Error::NotInitialized = 1 , pcal9555::Error::InvalidArgument = 2 , pcal9555::Error::Bus = 3 ,
  pcal9555::Error::Timeout = 4 , pcal9555::Error::DeviceIdMismatch = 5 , pcal9555::Error::Crc = 6 , pcal9555::Error::Busy = 7 ,
  pcal9555::Error::DeviceFault = 8 , pcal9555::Error::Unsupported = 9 , pcal9555::Error::WriteMismatch = 16 , pcal9555::Error::NoDevice = 17 ,
  pcal9555::Error::DeviceReset = 18
}
 Why a call failed. Every call of the driver returns one of these in its Result. More...
 
enum class  pcal9555::LogLevel : uint8_t { pcal9555::LogLevel::Error = 0 , pcal9555::LogLevel::Warning , pcal9555::LogLevel::Info , pcal9555::LogLevel::Debug }
 Severity passed to the optional Log() hook. More...
 
enum class  pcal9555::Variant : uint8_t { pcal9555::Variant::Pca9555 = 0 , pcal9555::Variant::Pcal9555a = 1 }
 Which part is on the bus. The driver does not detect it: the data sheets do not say how a PCA9555 answers a command byte it does not implement, so probing the Agile I/O bank is not safe. More...
 
enum class  pcal9555::Direction : uint8_t { pcal9555::Direction::Output = 0 , pcal9555::Direction::Input = 1 }
 Direction of a pin (configuration register: 1 = input). More...
 
enum class  pcal9555::DriveStrength : uint8_t { pcal9555::DriveStrength::Quarter = 0 , pcal9555::DriveStrength::Half = 1 , pcal9555::DriveStrength::ThreeQuarters = 2 , pcal9555::DriveStrength::Full = 3 }
 Output drive strength of a pin, PCAL9555A only (data sheet section 6.2.6). More...
 
enum class  pcal9555::Verify : uint8_t { pcal9555::Verify::None = 0 , pcal9555::Verify::ReadBack = 1 }
 Whether a pin call reads back what it wrote, chosen per call (the last parameter of every pin and Agile I/O setter). More...
 
enum class  pcal9555::Pull : uint8_t { pcal9555::Pull::None = 0 , pcal9555::Pull::Up = 1 , pcal9555::Pull::Down = 2 }
 Pull resistor of a pin, PCAL9555A only (pull enable and selection registers). More...
 
enum class  pcal9555::OutputMode : uint8_t { pcal9555::OutputMode::PushPull = 0 , pcal9555::OutputMode::OpenDrain = 1 }
 Output stage of a whole port, PCAL9555A only (output port configuration register). More...
 
enum class  pcal9555::Bank : uint8_t { pcal9555::Bank::Port0 = 0 , pcal9555::Bank::Port1 = 1 }
 One of the two 8-pin ports. More...
 

Functions

constexpr const char * pcal9555::ToString (Error error) noexcept
 The name of an error, for logs.
 
constexpr uint16_t pcal9555::PinMask (uint8_t pin) noexcept
 The mask of one pin.
 
constexpr uint8_t pcal9555::AddressFromPins (bool a2, bool a1, bool a0) noexcept
 The 7-bit address for the levels of the address pins.
 
constexpr uint32_t pcal9555::DriveStrengthAll (DriveStrength level) noexcept
 Drive strength codes with every pin at one level, in the layout of Config.
 
constexpr Error pcal9555::Validate (const Config &config) noexcept
 Check a configuration without touching the chip.
 
constexpr const char * pcal9555::GetDriverVersion () noexcept
 
constexpr uint32_t pcal9555::GetDriverVersionMajor () noexcept
 
constexpr uint32_t pcal9555::GetDriverVersionMinor () noexcept
 
constexpr uint32_t pcal9555::GetDriverVersionPatch () noexcept
 

Variables

constexpr uint8_t pcal9555::kPinCount = 16
 Number of pins.
 
constexpr uint16_t pcal9555::kAllPins = 0xFFFF
 Mask of every pin.
 
constexpr uint8_t pcal9555::kMinI2cAddress = 0x20
 Lowest 7-bit I2C address (A2, A1, A0 all low): 0100 A2 A1 A0 (data sheet section 6.1).
 
constexpr uint8_t pcal9555::kMaxI2cAddress = 0x27
 Highest 7-bit I2C address (A2, A1, A0 all high).
 
constexpr uint8_t pcal9555::kDefaultI2cAddress = kMinI2cAddress
 

Detailed Description

Public types of the PCAL9555 driver: errors, Result<T>, pins and configuration.

Everything here is plain data with no platform dependency, so handlers, tests and tools can include it without the driver template. The configuration defaults are the power-up values of the registers (PCAL9555A data sheet Rev. 2, table 4), so Config{} describes a chip that was just powered up.