Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pcf85063a: RP2350 Fixes #1030

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions drivers/pcf85063a/pcf85063a.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
set(DRIVER_NAME pcf85063a)
add_library(${DRIVER_NAME} INTERFACE)

target_sources(${DRIVER_NAME} INTERFACE
${CMAKE_CURRENT_LIST_DIR}/${DRIVER_NAME}.cpp)

target_include_directories(${DRIVER_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR})

# Pull in pico libraries that we need
target_link_libraries(${DRIVER_NAME} INTERFACE pico_stdlib hardware_i2c hardware_rtc pimoroni_i2c)
set(DRIVER_NAME pcf85063a)
add_library(${DRIVER_NAME} INTERFACE)

target_sources(${DRIVER_NAME} INTERFACE
${CMAKE_CURRENT_LIST_DIR}/${DRIVER_NAME}.cpp)

target_include_directories(${DRIVER_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR})

# Include datetime_t for cross-compatibility with RP2350 (no RTC) boards
# TODO: We should migrate away from using this non-standard type
target_compile_definitions(${DRIVER_NAME} INTERFACE PICO_INCLUDE_RTC_DATETIME=1)

# Pull in pico libraries that we need
target_link_libraries(${DRIVER_NAME} INTERFACE pico_stdlib pico_util hardware_i2c pimoroni_i2c)
4 changes: 4 additions & 0 deletions drivers/pcf85063a/pcf85063a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ namespace pimoroni {
return interrupt;
}

#if PICO_INCLUDE_RTC_DATETIME

datetime_t PCF85063A::get_datetime() {
uint8_t result[7] = {0};

Expand Down Expand Up @@ -85,6 +87,8 @@ namespace pimoroni {
i2c->write_bytes(address, Registers::SECONDS, data, 7);
}

#endif

void PCF85063A::set_alarm(int second, int minute, int hour, int day) {
uint8_t alarm[5] = {
uint8_t(second != PARAM_UNUSED ? bcd_encode(second) : 0x80),
Expand Down
2 changes: 2 additions & 0 deletions drivers/pcf85063a/pcf85063a.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ namespace pimoroni {
int get_scl() const;
int get_int() const;

#if PICO_INCLUDE_RTC_DATETIME
// Set and get the date and time
// Uses datetime_t from pico sdk (hardware/rtc) for compatibility
datetime_t get_datetime();
void set_datetime(datetime_t *t);
#endif

// Alarm manipulation methods
void set_alarm(int second = PARAM_UNUSED, int minute = PARAM_UNUSED,
Expand Down