Improved const correctness of rtc functions (#1460)

This commit is contained in:
Joseph Bellahcen 2024-05-18 20:42:51 -04:00 committed by GitHub
parent ac8f277e5a
commit 5941969380
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -54,7 +54,7 @@ void rtc_init(void);
* \param t Pointer to a \ref datetime_t structure contains time to set
* \return true if set, false if the passed in datetime was invalid.
*/
bool rtc_set_datetime(datetime_t *t);
bool rtc_set_datetime(const datetime_t *t);
/*! \brief Get the current time from the RTC
* \ingroup hardware_rtc
@ -76,7 +76,7 @@ bool rtc_running(void);
* \param t Pointer to a \ref datetime_t structure containing a time in the future to fire the alarm. Any values set to -1 will not be matched on.
* \param user_callback pointer to a \ref rtc_callback_t to call when the alarm fires
*/
void rtc_set_alarm(datetime_t *t, rtc_callback_t user_callback);
void rtc_set_alarm(const datetime_t *t, rtc_callback_t user_callback);
/*! \brief Enable the RTC alarm (if inactive)
* \ingroup hardware_rtc

View File

@ -39,7 +39,7 @@ void rtc_init(void) {
rtc_hw->clkdiv_m1 = rtc_freq;
}
static bool valid_datetime(datetime_t *t) {
static bool valid_datetime(const datetime_t *t) {
// Valid ranges taken from RTC doc. Note when setting an RTC alarm
// these values are allowed to be -1 to say "don't match this value"
if (!(t->year >= 0 && t->year <= 4095)) return false;
@ -52,7 +52,7 @@ static bool valid_datetime(datetime_t *t) {
return true;
}
bool rtc_set_datetime(datetime_t *t) {
bool rtc_set_datetime(const datetime_t *t) {
if (!valid_datetime(t)) {
return false;
}
@ -131,7 +131,7 @@ static void rtc_irq_handler(void) {
}
}
static bool rtc_alarm_repeats(datetime_t *t) {
static bool rtc_alarm_repeats(const datetime_t *t) {
// If any value is set to -1 then we don't match on that value
// hence the alarm will eventually repeat
if (t->year < 0) return true;
@ -144,7 +144,7 @@ static bool rtc_alarm_repeats(datetime_t *t) {
return false;
}
void rtc_set_alarm(datetime_t *t, rtc_callback_t user_callback) {
void rtc_set_alarm(const datetime_t *t, rtc_callback_t user_callback) {
rtc_disable_alarm();
// Only add to setup if it isn't -1