HF-PCAL95555 0.1.0-dev
Loading...
Searching...
No Matches
PCAL95555 — CMake Integration Guide

How to consume the PCAL95555 driver in your CMake or ESP-IDF project.

ESP-IDF Integration

The driver ships with an ESP-IDF component wrapper in examples/esp32/components/hf_pcal95555/.

1. Reference the Component

Option 1 — Symlink or copy the wrapper:

your-esp-project/
├── CMakeLists.txt
├── main/
│ ├── CMakeLists.txt
│ └── app_main.cpp
└── components/
└── hf_pcal95555/
└── CMakeLists.txt ← copy from driver's examples/esp32/components/

Option 2 — Use EXTRA_COMPONENT_DIRS:

# In your project-level CMakeLists.txt, before include($ENV{IDF_PATH}/...)
set(EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/../path/to/hf-pcal95555-driver/examples/esp32/components")

2. Override the Driver Root (if needed)

The component wrapper auto-detects the driver root via a relative path. If your directory layout differs, override it:

set(HF_PCAL95555_ROOT "/absolute/path/to/hf-pcal95555-driver" CACHE PATH "")

3. Require the Component

In your main/CMakeLists.txt:

idf_component_register(
SRCS "app_main.cpp"
INCLUDE_DIRS "."
REQUIRES hf_pcal95555 driver
)
target_compile_features(${COMPONENT_LIB} PRIVATE cxx_std_20)

4. Include and Use

#include "pcal95555.hpp"
#include "pcal95555_version.h" // optional — version macros
// Create your platform I2C implementation, then:
pcal95555::PCAL95555<MyI2cBus> driver(&bus, /*a0=*/false, /*a1=*/false, /*a2=*/false);
driver.EnsureInitialized();

Version Header

The build system generates pcal95555_version.h from inc/pcal95555_version.h.in at configure time. It provides:

#define HF_PCAL95555_VERSION_MAJOR 1
#define HF_PCAL95555_VERSION_MINOR 0
#define HF_PCAL95555_VERSION_PATCH 0
#define HF_PCAL95555_VERSION_STRING "1.0.0"

Include it in your application to verify at runtime which version is compiled in:

#include "pcal95555_version.h"
printf("PCAL95555 driver v%s\n", HF_PCAL95555_VERSION_STRING);