-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
drivers: rtc: Add Maxim DS1337 RTC driver #85015
base: main
Are you sure you want to change the base?
Conversation
9c87d36
to
0dd19f1
Compare
drivers/rtc/rtc_ds1337.c
Outdated
timeptr->tm_mday = bcd2bin(regs[2] & DS1337_ALARM_DATE_MASK); | ||
*mask |= RTC_ALARM_TIME_MASK_MONTHDAY; | ||
} else { | ||
timeptr->tm_wday = bcd2bin(regs[2] & DS1337_ALARM_DAY_MASK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
timeptr->tm_mday = bcd2bin(regs[2] & DS1337_ALARM_DATE_MASK); | |
*mask |= RTC_ALARM_TIME_MASK_MONTHDAY; | |
} else { | |
timeptr->tm_wday = bcd2bin(regs[2] & DS1337_ALARM_DAY_MASK); | |
timeptr->tm_mday = bcd2bin(regs[3] & DS1337_ALARM_DATE_MASK); | |
*mask |= RTC_ALARM_TIME_MASK_MONTHDAY; | |
} else { | |
timeptr->tm_wday = bcd2bin(regs[3] & DS1337_ALARM_DAY_MASK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
drivers/rtc/rtc_ds1337.c
Outdated
} else if (mask & RTC_ALARM_TIME_MASK_WEEKDAY) { | ||
regs[3] = bin2bcd(timeptr->tm_wday) & DS1337_ALARM_DAY_MASK; | ||
regs[3] |= DS1337_DY_DT_MASK; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to apply DS1337_DAY_OFFSET
?
} else if (mask & RTC_ALARM_TIME_MASK_WEEKDAY) { | |
regs[3] = bin2bcd(timeptr->tm_wday) & DS1337_ALARM_DAY_MASK; | |
regs[3] |= DS1337_DY_DT_MASK; | |
} else { | |
} else if (mask & RTC_ALARM_TIME_MASK_WEEKDAY) { | |
regs[3] = bin2bcd(timeptr->tm_wday - DS1337_DAY_OFFSET) & DS1337_ALARM_DAY_MASK; | |
regs[3] |= DS1337_DY_DT_MASK; | |
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! Fixed
drivers/rtc/rtc_ds1337.c
Outdated
if (reg_val & DS1337_A1F_MASK) { | ||
LOG_WRN("Alarm 0 might have been missed!"); | ||
} | ||
if (reg_val & DS1337_A2F_MASK) { | ||
LOG_WRN("Alarm 1 might have been missed!"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (reg_val & DS1337_A1F_MASK) { | |
LOG_WRN("Alarm 0 might have been missed!"); | |
} | |
if (reg_val & DS1337_A2F_MASK) { | |
LOG_WRN("Alarm 1 might have been missed!"); | |
} | |
if (reg_val & DS1337_A1F_MASK) { | |
LOG_WRN("Alarm 1 might have been missed!"); | |
} | |
if (reg_val & DS1337_A2F_MASK) { | |
LOG_WRN("Alarm 2 might have been missed!"); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not sure whether I should refer to the alarms by RTC numbering or by IDs passed to alarm API functions, corrected as per your suggestion
This PR adds support for Maxim Integrated DS1337 RTC chip. Supported functionalities: * Alarm interrupt (both alarms trigger INTA pin) * Time setting/reading * Both alarms setting/reading * SQW frequency configuration Tested on nRF52833-DK using rtc_api test set. Signed-off-by: Marcin Lyda <elektromarcin@gmail.com>
0dd19f1
to
6fd24cc
Compare
Btw @Lefucjusz since you mentioned you'd actually tested this, it would be good to see if there is anything that could be improved to have better coverage, or if there are tests that need to be fixed? |
This PR adds support for Maxim Integrated
DS1337 RTC chip.
Supported functionalities:
Tested on nRF52833-DK using rtc_api test set.