The register sugar now rides the bus's own master role - device<Bus> resolves avr::i2c::device<typename Bus::master, bus_address>, so a consumer keeps handing over its declared dev::i2c<...> unchanged - and the DS3231's hardwired 0x68 is a named constant. The example's four discards became the LED's own error signal (a failed seed or a failed alarm clear holds it dark, the same word a stuck bus says), the tree is reformatted under InsertBraces, the sources are ASCII, and the README's stale Studio byte counts are replaced by the claim its check-flags gate holds. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
26 lines
880 B
CMake
26 lines
880 B
CMake
cmake_minimum_required(VERSION 3.28)
|
|
|
|
project(ds3231 LANGUAGES CXX)
|
|
|
|
# libavr rides as the pinned submodule; LIBAVR_ROOT (cache or environment)
|
|
# overrides it for tandem development against a working tree. The toolchain
|
|
# file comes from the submodule via CMakePresets.json either way.
|
|
if(NOT LIBAVR_ROOT AND DEFINED ENV{LIBAVR_ROOT})
|
|
set(LIBAVR_ROOT $ENV{LIBAVR_ROOT})
|
|
endif()
|
|
if(NOT LIBAVR_ROOT)
|
|
set(LIBAVR_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/libavr)
|
|
endif()
|
|
if(NOT EXISTS ${LIBAVR_ROOT}/CMakeLists.txt)
|
|
message(FATAL_ERROR "libavr not found at ${LIBAVR_ROOT} - run: git submodule update --init libavr")
|
|
endif()
|
|
add_subdirectory(${LIBAVR_ROOT} libavr-build)
|
|
|
|
add_library(ds3231 INTERFACE)
|
|
target_include_directories(ds3231 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
target_link_libraries(ds3231 INTERFACE libavr)
|
|
|
|
if(PROJECT_IS_TOP_LEVEL)
|
|
add_subdirectory(example)
|
|
endif()
|