Lines Matching refs:t

42 static bool valid_datetime(datetime_t *t) {  in valid_datetime()  argument
45 if (!(t->year >= 0 && t->year <= 4095)) return false; in valid_datetime()
46 if (!(t->month >= 1 && t->month <= 12)) return false; in valid_datetime()
47 if (!(t->day >= 1 && t->day <= 31)) return false; in valid_datetime()
48 if (!(t->dotw >= 0 && t->dotw <= 6)) return false; in valid_datetime()
49 if (!(t->hour >= 0 && t->hour <= 23)) return false; in valid_datetime()
50 if (!(t->min >= 0 && t->min <= 59)) return false; in valid_datetime()
51 if (!(t->sec >= 0 && t->sec <= 59)) return false; in valid_datetime()
55 bool rtc_set_datetime(datetime_t *t) { in rtc_set_datetime() argument
56 if (!valid_datetime(t)) { in rtc_set_datetime()
68 rtc_hw->setup_0 = (((uint32_t)t->year) << RTC_SETUP_0_YEAR_LSB ) | in rtc_set_datetime()
69 (((uint32_t)t->month) << RTC_SETUP_0_MONTH_LSB) | in rtc_set_datetime()
70 (((uint32_t)t->day) << RTC_SETUP_0_DAY_LSB); in rtc_set_datetime()
71 rtc_hw->setup_1 = (((uint32_t)t->dotw) << RTC_SETUP_1_DOTW_LSB) | in rtc_set_datetime()
72 (((uint32_t)t->hour) << RTC_SETUP_1_HOUR_LSB) | in rtc_set_datetime()
73 (((uint32_t)t->min) << RTC_SETUP_1_MIN_LSB) | in rtc_set_datetime()
74 (((uint32_t)t->sec) << RTC_SETUP_1_SEC_LSB); in rtc_set_datetime()
88 bool rtc_get_datetime(datetime_t *t) { in rtc_get_datetime() argument
98 t->dotw = (int8_t) ((rtc_0 & RTC_RTC_0_DOTW_BITS ) >> RTC_RTC_0_DOTW_LSB); in rtc_get_datetime()
99 t->hour = (int8_t) ((rtc_0 & RTC_RTC_0_HOUR_BITS ) >> RTC_RTC_0_HOUR_LSB); in rtc_get_datetime()
100 t->min = (int8_t) ((rtc_0 & RTC_RTC_0_MIN_BITS ) >> RTC_RTC_0_MIN_LSB); in rtc_get_datetime()
101 t->sec = (int8_t) ((rtc_0 & RTC_RTC_0_SEC_BITS ) >> RTC_RTC_0_SEC_LSB); in rtc_get_datetime()
102 t->year = (int16_t) ((rtc_1 & RTC_RTC_1_YEAR_BITS ) >> RTC_RTC_1_YEAR_LSB); in rtc_get_datetime()
103 t->month = (int8_t) ((rtc_1 & RTC_RTC_1_MONTH_BITS) >> RTC_RTC_1_MONTH_LSB); in rtc_get_datetime()
104 t->day = (int8_t) ((rtc_1 & RTC_RTC_1_DAY_BITS ) >> RTC_RTC_1_DAY_LSB); in rtc_get_datetime()
134 static bool rtc_alarm_repeats(datetime_t *t) { in rtc_alarm_repeats() argument
137 if (t->year < 0) return true; in rtc_alarm_repeats()
138 if (t->month < 0) return true; in rtc_alarm_repeats()
139 if (t->day < 0) return true; in rtc_alarm_repeats()
140 if (t->dotw < 0) return true; in rtc_alarm_repeats()
141 if (t->hour < 0) return true; in rtc_alarm_repeats()
142 if (t->min < 0) return true; in rtc_alarm_repeats()
143 if (t->sec < 0) return true; in rtc_alarm_repeats()
147 void rtc_set_alarm(datetime_t *t, rtc_callback_t user_callback) { in rtc_set_alarm() argument
151 … rtc_hw->irq_setup_0 = ((t->year < 0) ? 0 : (((uint32_t)t->year) << RTC_IRQ_SETUP_0_YEAR_LSB )) | in rtc_set_alarm()
152 … ((t->month < 0) ? 0 : (((uint32_t)t->month) << RTC_IRQ_SETUP_0_MONTH_LSB)) | in rtc_set_alarm()
153 … ((t->day < 0) ? 0 : (((uint32_t)t->day) << RTC_IRQ_SETUP_0_DAY_LSB )); in rtc_set_alarm()
154 … rtc_hw->irq_setup_1 = ((t->dotw < 0) ? 0 : (((uint32_t)t->dotw) << RTC_IRQ_SETUP_1_DOTW_LSB)) | in rtc_set_alarm()
155 … ((t->hour < 0) ? 0 : (((uint32_t)t->hour) << RTC_IRQ_SETUP_1_HOUR_LSB)) | in rtc_set_alarm()
156 … ((t->min < 0) ? 0 : (((uint32_t)t->min) << RTC_IRQ_SETUP_1_MIN_LSB )) | in rtc_set_alarm()
157 ((t->sec < 0) ? 0 : (((uint32_t)t->sec) << RTC_IRQ_SETUP_1_SEC_LSB )); in rtc_set_alarm()
160 if (t->year >= 0) hw_set_bits(&rtc_hw->irq_setup_0, RTC_IRQ_SETUP_0_YEAR_ENA_BITS); in rtc_set_alarm()
161 if (t->month >= 0) hw_set_bits(&rtc_hw->irq_setup_0, RTC_IRQ_SETUP_0_MONTH_ENA_BITS); in rtc_set_alarm()
162 if (t->day >= 0) hw_set_bits(&rtc_hw->irq_setup_0, RTC_IRQ_SETUP_0_DAY_ENA_BITS); in rtc_set_alarm()
163 if (t->dotw >= 0) hw_set_bits(&rtc_hw->irq_setup_1, RTC_IRQ_SETUP_1_DOTW_ENA_BITS); in rtc_set_alarm()
164 if (t->hour >= 0) hw_set_bits(&rtc_hw->irq_setup_1, RTC_IRQ_SETUP_1_HOUR_ENA_BITS); in rtc_set_alarm()
165 if (t->min >= 0) hw_set_bits(&rtc_hw->irq_setup_1, RTC_IRQ_SETUP_1_MIN_ENA_BITS); in rtc_set_alarm()
166 if (t->sec >= 0) hw_set_bits(&rtc_hw->irq_setup_1, RTC_IRQ_SETUP_1_SEC_ENA_BITS); in rtc_set_alarm()
169 _alarm_repeats = rtc_alarm_repeats(t); in rtc_set_alarm()