Lines Matching +full:timestamp +full:- +full:prescaler
6 * SPDX-License-Identifier: Apache-2.0
36 /* Seconds from 1970-01-01T00:00:00 to 2000-01-01T00:00:00 */
81 #define RTC_ASYNCPRE (RTCCLK_FREQ - 1)
84 /* Adjust the second sync prescaler to get 1Hz on ck_spre */
85 #define RTC_SYNCPRE ((RTCCLK_FREQ / (1 + RTC_ASYNCPRE)) - 1)
190 const struct rtc_stm32_config *cfg = dev->config; in rtc_stm32_start()
193 if (clock_control_on(clk, (clock_control_subsys_t) &cfg->pclken[0]) != 0) { in rtc_stm32_start()
195 return -EIO; in rtc_stm32_start()
213 const struct rtc_stm32_config *cfg = dev->config; in rtc_stm32_stop()
216 if (clock_control_off(clk, (clock_control_subsys_t) &cfg->pclken[0]) != 0) { in rtc_stm32_stop()
218 return -EIO; in rtc_stm32_stop()
266 /* Convert calendar datetime to UNIX timestamp */ in rtc_stm32_read()
271 /* tm_mon allowed values are 0-11 */ in rtc_stm32_read()
272 now.tm_mon = __LL_RTC_CONVERT_BCD2BIN(__LL_RTC_GET_MONTH(rtc_date)) - 1; in rtc_stm32_read()
282 ts -= T_TIME_OFFSET; in rtc_stm32_read()
289 * down starting from the sync prescaler value. Add already counted in rtc_stm32_read()
292 ticks += RTC_SYNCPRE - rtc_subseconds; in rtc_stm32_read()
352 struct rtc_stm32_data *data = dev->data; in rtc_stm32_set_alarm()
355 tick_t ticks = alarm_cfg->ticks; in rtc_stm32_set_alarm()
357 if (data->callback != NULL) { in rtc_stm32_set_alarm()
359 return -EBUSY; in rtc_stm32_set_alarm()
363 data->callback = alarm_cfg->callback; in rtc_stm32_set_alarm()
364 data->user_data = alarm_cfg->user_data; in rtc_stm32_set_alarm()
367 if ((alarm_cfg->flags & COUNTER_ALARM_CFG_ABSOLUTE) == 0) { in rtc_stm32_set_alarm()
383 if ((alarm_cfg->flags & COUNTER_ALARM_CFG_ABSOLUTE) == 0) { in rtc_stm32_set_alarm()
390 * not when the counter matches, so set -1 in rtc_stm32_set_alarm()
392 remain--; in rtc_stm32_set_alarm()
415 remain -= rtc_alarm.AlarmTime.Hours * 3600; in rtc_stm32_set_alarm()
417 remain -= rtc_alarm.AlarmTime.Minutes * 60; in rtc_stm32_set_alarm()
426 return -EIO; in rtc_stm32_set_alarm()
433 LL_RTC_ALMA_SetSubSecond(RTC, RTC_SYNCPRE - alarm_val_ss); in rtc_stm32_set_alarm()
452 if ((ticks - now < 2) || (now > ticks)) { in rtc_stm32_set_alarm()
453 data->irq_on_late = 1; in rtc_stm32_set_alarm()
464 struct rtc_stm32_data *data = dev->data; in rtc_stm32_cancel_alarm()
472 data->callback = NULL; in rtc_stm32_cancel_alarm()
486 const struct counter_config_info *info = dev->config; in rtc_stm32_get_top_value()
488 return info->max_top_value; in rtc_stm32_get_top_value()
495 const struct counter_config_info *info = dev->config; in rtc_stm32_set_top_value()
497 if ((cfg->ticks != info->max_top_value) || in rtc_stm32_set_top_value()
498 !(cfg->flags & COUNTER_TOP_CFG_DONT_RESET)) { in rtc_stm32_set_top_value()
499 return -ENOTSUP; in rtc_stm32_set_top_value()
509 struct rtc_stm32_data *data = dev->data; in rtc_stm32_isr()
510 counter_alarm_callback_t alarm_callback = data->callback; in rtc_stm32_isr()
516 || (data->irq_on_late && ll_func_isenabled_interrupt_alarm(RTC)) in rtc_stm32_isr()
526 data->irq_on_late = 0; in rtc_stm32_isr()
530 data->callback = NULL; in rtc_stm32_isr()
531 alarm_callback(dev, 0, now, data->user_data); in rtc_stm32_isr()
553 const struct rtc_stm32_config *cfg = dev->config; in rtc_stm32_init()
554 struct rtc_stm32_data *data = dev->data; in rtc_stm32_init()
556 data->callback = NULL; in rtc_stm32_init()
560 return -ENODEV; in rtc_stm32_init()
564 if (clock_control_on(clk, (clock_control_subsys_t) &cfg->pclken[0]) != 0) { in rtc_stm32_init()
566 return -EIO; in rtc_stm32_init()
578 (clock_control_subsys_t) &cfg->pclken[1], in rtc_stm32_init()
581 return -EIO; in rtc_stm32_init()
592 return -EIO; in rtc_stm32_init()
597 &cfg->ll_rtc_config)) != SUCCESS) { in rtc_stm32_init()
598 return -EIO; in rtc_stm32_init()
655 const struct rtc_stm32_config *cfg = dev->config; in rtc_stm32_pm_action()
660 if (clock_control_on(clk, (clock_control_subsys_t) &cfg->pclken[0]) != 0) { in rtc_stm32_pm_action()
662 return -EIO; in rtc_stm32_pm_action()
668 return -ENOTSUP; in rtc_stm32_pm_action()