@@ -153,7 +153,7 @@ int Rtc::getSeconds() {
153153 return -1 ;
154154}
155155
156- #ifdef CONFIG_RTC_STM32
156+ #if defined( CONFIG_RTC_STM32) || defined(CONFIG_RTC_RPI_PICO)
157157
158158#if DT_NODE_EXISTS(DT_NODELABEL(rtc))
159159#define RTC_NODE DT_NODELABEL (rtc)
@@ -165,7 +165,7 @@ int Rtc::getSeconds() {
165165/* *
166166 * @brief Rtc library constructor
167167 *
168- * Constructor used with the STM32 microcontroller based boards (OPTA, PORTENTA H7, GIGA R1)
168+ * Constructor used with STM32 and RP2040- based boards using Zephyr RTC drivers
169169 *
170170 */
171171Rtc::Rtc () {
@@ -401,10 +401,14 @@ void Rtc::alarmCallbackWrapper([[maybe_unused]] const struct device *dev,
401401 * @param void *user_data is a void pointer the user can set when registering the callback
402402 */
403403int Rtc::setUpdateCallback (RtcUpdateCallback cb, void *user_data) {
404+ #if defined(CONFIG_RTC_RPI_PICO)
405+ return -1 ;
406+ #else
404407 userUpdateCallback = cb;
405408 userUpdateCallbackData = user_data;
406409
407410 return rtc_update_set_callback (rtc_dev, Rtc::updateCallbackWrapper, this );
411+ #endif
408412}
409413
410414/* *
@@ -434,7 +438,11 @@ void Rtc::updateCallbackWrapper([[maybe_unused]] const struct device *dev, void
434438 * @return 0 if successful, or a negative error code on failure.
435439 */
436440int Rtc::setCalibration (int32_t calibration) {
441+ #if defined(CONFIG_RTC_RPI_PICO)
442+ return -1 ;
443+ #else
437444 return rtc_set_calibration (rtc_dev, calibration);
445+ #endif
438446}
439447
440448/* *
@@ -447,13 +455,19 @@ int Rtc::setCalibration(int32_t calibration) {
447455 * @return 0 if successful, or a negative error code on failure.
448456 */
449457int Rtc::getCalibration (int32_t &calibration) {
458+ #if defined(CONFIG_RTC_RPI_PICO)
459+ return -1 ;
460+ #else
450461 return rtc_get_calibration (rtc_dev, &calibration);
462+ #endif
451463}
452464
453- #else // For non-STM32 platforms (nordic), we must use the generic counter API to implement RTC
465+ #elif defined(CONFIG_COUNTER_NRF_RTC) // For other platforms (nordic), we must use the counter API to implement RTC
454466 // functionality
455467
456- #if DT_NODE_EXISTS(DT_NODELABEL(rtc2))
468+ #if DT_NODE_EXISTS(DT_NODELABEL(rtc1))
469+ #define COUNTER_NODE DT_NODELABEL (rtc1)
470+ #elif DT_NODE_EXISTS(DT_NODELABEL(rtc2))
457471#define COUNTER_NODE DT_NODELABEL (rtc2)
458472#else
459473#warning "RTC node not found in devicetree"
@@ -796,4 +810,6 @@ void Rtc::epochToDatetime(time_t t, int &year, int &month, int &day, int &hour,
796810 month = m + 1 ;
797811 day = days + 1 ;
798812}
799- #endif /* CONFIG_RTC_STM32*/
813+ #else
814+ #error "Unsupported RTC configuration"
815+ #endif /* CONFIG_RTC_STM32 || CONFIG_RTC_RPI_PICO */
0 commit comments