Skip to content

Commit 467e15d

Browse files
Mattemagikernkartben
authored andcommitted
drivers: rtc: rx8130ce: day alarm fix
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 <[email protected]>
1 parent 95c1c85 commit 467e15d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/rtc/rtc_rx8130ce.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ static int rx8130ce_alarm_set_time(const struct device *dev, uint16_t id, uint16
316316
const struct rtc_time *timeptr)
317317
{
318318
int rc = 0;
319-
bool alarm_enabled;
319+
bool alarm_enabled = false;
320320
struct rx8130ce_alarm alarm_time;
321321
struct rx8130ce_data *data = dev->data;
322322
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
358358
alarm_time.minute = bin2bcd(timeptr->tm_min);
359359
alarm_time.hour = bin2bcd(timeptr->tm_hour);
360360
alarm_time.day = bin2bcd(timeptr->tm_mday);
361-
data->reg.extension &= ~EXT_WADA;
361+
data->reg.extension |= EXT_WADA;
362362

363363
if ((mask & RTC_ALARM_TIME_MASK_MINUTE) == 0U) {
364364
alarm_time.minute |= ALARM_DISABLE;
@@ -426,15 +426,15 @@ static int rx8130ce_alarm_get_time(const struct device *dev, uint16_t id, uint16
426426
*mask |= RTC_ALARM_TIME_MASK_HOUR;
427427
}
428428
if (data->reg.extension & EXT_WADA) {
429-
timeptr->tm_wday = rtc2wday(alarm_time.wday & RX8130CE_WEEKDAYS_MASK);
430-
if (!(alarm_time.wday & ALARM_DISABLE)) {
431-
*mask |= RTC_ALARM_TIME_MASK_WEEKDAY;
432-
}
433-
} else {
434-
timeptr->tm_mday = bcd2bin(alarm_time.day & RX8130CE_DAYS_MASK);
429+
timeptr->tm_mday = bcd2bin(alarm_time.day);
435430
if (!(alarm_time.day & ALARM_DISABLE)) {
436431
*mask |= RTC_ALARM_TIME_MASK_MONTHDAY;
437432
}
433+
} else {
434+
timeptr->tm_wday = rtc2wday(alarm_time.wday);
435+
if (!(alarm_time.wday & ALARM_DISABLE)) {
436+
*mask |= RTC_ALARM_TIME_MASK_WEEKDAY;
437+
}
438438
}
439439
error:
440440
k_sem_give(&data->lock);

0 commit comments

Comments
 (0)