Lines Matching +full:zephyr +full:- +full:base

5  * SPDX-License-Identifier: Apache-2.0
10 #include <zephyr/drivers/counter.h>
11 #include <zephyr/irq.h>
12 #include <zephyr/kernel.h>
13 #include <zephyr/sys_clock.h>
15 #include <zephyr/logging/log.h>
28 RTC_Type *base; member
34 const struct counter_config_info *info = dev->config; in mcux_rtc_start()
38 RTC_StartTimer(config->base); in mcux_rtc_start()
39 RTC_EnableInterrupts(config->base, in mcux_rtc_start()
49 const struct counter_config_info *info = dev->config; in mcux_rtc_stop()
53 RTC_DisableInterrupts(config->base, in mcux_rtc_stop()
57 RTC_StopTimer(config->base); in mcux_rtc_stop()
60 config->base->TAR = 0; in mcux_rtc_stop()
67 const struct counter_config_info *info = dev->config; in mcux_rtc_read()
71 uint32_t ticks = config->base->TSR; in mcux_rtc_read()
78 if (config->base->TSR == ticks) { in mcux_rtc_read()
82 ticks = config->base->TSR; in mcux_rtc_read()
96 const struct counter_config_info *info = dev->config; in mcux_rtc_set_alarm()
99 struct mcux_rtc_data *data = dev->data; in mcux_rtc_set_alarm()
101 uint32_t ticks = alarm_cfg->ticks; in mcux_rtc_set_alarm()
108 return -EINVAL; in mcux_rtc_set_alarm()
111 if (data->alarm_callback != NULL) { in mcux_rtc_set_alarm()
112 return -EBUSY; in mcux_rtc_set_alarm()
115 if ((alarm_cfg->flags & COUNTER_ALARM_CFG_ABSOLUTE) == 0) { in mcux_rtc_set_alarm()
121 return -EINVAL; in mcux_rtc_set_alarm()
124 data->alarm_callback = alarm_cfg->callback; in mcux_rtc_set_alarm()
125 data->alarm_user_data = alarm_cfg->user_data; in mcux_rtc_set_alarm()
127 config->base->TAR = ticks; in mcux_rtc_set_alarm()
135 struct mcux_rtc_data *data = dev->data; in mcux_rtc_cancel_alarm()
139 return -EINVAL; in mcux_rtc_cancel_alarm()
142 data->alarm_callback = NULL; in mcux_rtc_cancel_alarm()
150 const struct counter_config_info *info = dev->config; in mcux_rtc_set_top_value()
153 struct mcux_rtc_data *data = dev->data; in mcux_rtc_set_top_value()
155 if (cfg->ticks != info->max_top_value) { in mcux_rtc_set_top_value()
156 LOG_ERR("Wrap can only be set to 0x%x.", info->max_top_value); in mcux_rtc_set_top_value()
157 return -ENOTSUP; in mcux_rtc_set_top_value()
160 if (!(cfg->flags & COUNTER_TOP_CFG_DONT_RESET)) { in mcux_rtc_set_top_value()
161 RTC_StopTimer(config->base); in mcux_rtc_set_top_value()
162 config->base->TSR = 0; in mcux_rtc_set_top_value()
163 RTC_StartTimer(config->base); in mcux_rtc_set_top_value()
166 data->top_callback = cfg->callback; in mcux_rtc_set_top_value()
167 data->top_user_data = cfg->user_data; in mcux_rtc_set_top_value()
174 const struct counter_config_info *info = dev->config; in mcux_rtc_get_pending_int()
178 return RTC_GetStatusFlags(config->base) & RTC_SR_TAF_MASK; in mcux_rtc_get_pending_int()
183 const struct counter_config_info *info = dev->config; in mcux_rtc_get_top_value()
185 return info->max_top_value; in mcux_rtc_get_top_value()
190 const struct counter_config_info *info = dev->config; in mcux_rtc_isr()
193 struct mcux_rtc_data *data = dev->data; in mcux_rtc_isr()
200 if ((RTC_GetStatusFlags(config->base) & RTC_SR_TAF_MASK) && in mcux_rtc_isr()
201 (data->alarm_callback)) { in mcux_rtc_isr()
202 cb = data->alarm_callback; in mcux_rtc_isr()
203 data->alarm_callback = NULL; in mcux_rtc_isr()
204 cb(dev, 0, current, data->alarm_user_data); in mcux_rtc_isr()
207 if ((RTC_GetStatusFlags(config->base) & RTC_SR_TOF_MASK) && in mcux_rtc_isr()
208 (data->top_callback)) { in mcux_rtc_isr()
209 data->top_callback(dev, data->top_user_data); in mcux_rtc_isr()
218 RTC_StopTimer(config->base); in mcux_rtc_isr()
219 if (RTC_GetStatusFlags(config->base) & RTC_SR_TAF_MASK) { in mcux_rtc_isr()
220 RTC_ClearStatusFlags(config->base, kRTC_AlarmFlag); in mcux_rtc_isr()
221 } else if (RTC_GetStatusFlags(config->base) & RTC_SR_TIF_MASK) { in mcux_rtc_isr()
222 RTC_ClearStatusFlags(config->base, kRTC_TimeInvalidFlag); in mcux_rtc_isr()
223 } else if (RTC_GetStatusFlags(config->base) & RTC_SR_TOF_MASK) { in mcux_rtc_isr()
224 RTC_ClearStatusFlags(config->base, kRTC_TimeOverflowFlag); in mcux_rtc_isr()
226 RTC_StartTimer(config->base); in mcux_rtc_isr()
231 const struct counter_config_info *info = dev->config; in mcux_rtc_init()
237 RTC_Init(config->base, &rtc_config); in mcux_rtc_init()
251 RTC_EnableLPOClock(config->base, DT_INST_ENUM_IDX(0, clock_source)); in mcux_rtc_init()
256 RTC_SetClockSource(config->base); in mcux_rtc_init()
260 config->irq_config_func(dev); in mcux_rtc_init()
281 .base = (RTC_Type *)DT_INST_REG_ADDR(0),