From 467e15ddd3ea1c58c5f3f514480e63a04e58d5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5ns=20Ansgariusson?= Date: Fri, 28 Feb 2025 09:38:20 +0100 Subject: [PATCH] drivers: rtc: rx8130ce: day alarm fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The day alarm was not being set correctly. The day alarm should be set using the WADA bit in the control register. This patch fixes the issue by setting the WADA bit in the control register when setting the day alarm. Signed-off-by: Måns Ansgariusson --- drivers/rtc/rtc_rx8130ce.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/rtc/rtc_rx8130ce.c b/drivers/rtc/rtc_rx8130ce.c index d181bea8a0f..89a5430d51c 100644 --- a/drivers/rtc/rtc_rx8130ce.c +++ b/drivers/rtc/rtc_rx8130ce.c @@ -316,7 +316,7 @@ static int rx8130ce_alarm_set_time(const struct device *dev, uint16_t id, uint16 const struct rtc_time *timeptr) { int rc = 0; - bool alarm_enabled; + bool alarm_enabled = false; struct rx8130ce_alarm alarm_time; struct rx8130ce_data *data = dev->data; const struct rx8130ce_config *cfg = dev->config; @@ -358,7 +358,7 @@ static int rx8130ce_alarm_set_time(const struct device *dev, uint16_t id, uint16 alarm_time.minute = bin2bcd(timeptr->tm_min); alarm_time.hour = bin2bcd(timeptr->tm_hour); alarm_time.day = bin2bcd(timeptr->tm_mday); - data->reg.extension &= ~EXT_WADA; + data->reg.extension |= EXT_WADA; if ((mask & RTC_ALARM_TIME_MASK_MINUTE) == 0U) { alarm_time.minute |= ALARM_DISABLE; @@ -426,15 +426,15 @@ static int rx8130ce_alarm_get_time(const struct device *dev, uint16_t id, uint16 *mask |= RTC_ALARM_TIME_MASK_HOUR; } if (data->reg.extension & EXT_WADA) { - timeptr->tm_wday = rtc2wday(alarm_time.wday & RX8130CE_WEEKDAYS_MASK); - if (!(alarm_time.wday & ALARM_DISABLE)) { - *mask |= RTC_ALARM_TIME_MASK_WEEKDAY; - } - } else { - timeptr->tm_mday = bcd2bin(alarm_time.day & RX8130CE_DAYS_MASK); + timeptr->tm_mday = bcd2bin(alarm_time.day); if (!(alarm_time.day & ALARM_DISABLE)) { *mask |= RTC_ALARM_TIME_MASK_MONTHDAY; } + } else { + timeptr->tm_wday = rtc2wday(alarm_time.wday); + if (!(alarm_time.wday & ALARM_DISABLE)) { + *mask |= RTC_ALARM_TIME_MASK_WEEKDAY; + } } error: k_sem_give(&data->lock);