Lines Matching +full:alarms +full:- +full:count
4 * SPDX-License-Identifier: Apache-2.0
93 struct counter_gecko_data *const dev_data = dev->data; in counter_gecko_set_top_value()
99 const struct counter_gecko_config *const dev_cfg = dev->config; in counter_gecko_set_top_value()
101 if (dev_cfg->prescaler != 1) { in counter_gecko_set_top_value()
103 return -EINVAL; in counter_gecko_set_top_value()
107 /* Counter top value can only be changed when all alarms are disabled */ in counter_gecko_set_top_value()
109 if (dev_data->alarm[i].callback) { in counter_gecko_set_top_value()
110 return -EBUSY; in counter_gecko_set_top_value()
116 dev_data->top_callback = cfg->callback; in counter_gecko_set_top_value()
117 dev_data->top_user_data = cfg->user_data; in counter_gecko_set_top_value()
118 ticks = cfg->ticks; in counter_gecko_set_top_value()
119 flags = cfg->flags; in counter_gecko_set_top_value()
131 err = -ETIME; in counter_gecko_set_top_value()
153 uint32_t count = RTCC_CounterGet(); in counter_gecko_set_alarm() local
154 struct counter_gecko_data *const dev_data = dev->data; in counter_gecko_set_alarm()
158 if ((top_value != 0) && (alarm_cfg->ticks > top_value)) { in counter_gecko_set_alarm()
159 return -EINVAL; in counter_gecko_set_alarm()
161 if (dev_data->alarm[chan_id].callback != NULL) { in counter_gecko_set_alarm()
162 return -EBUSY; in counter_gecko_set_alarm()
165 if ((alarm_cfg->flags & COUNTER_ALARM_CFG_ABSOLUTE) != 0) { in counter_gecko_set_alarm()
166 ccv = alarm_cfg->ticks; in counter_gecko_set_alarm()
169 ccv = count + alarm_cfg->ticks; in counter_gecko_set_alarm()
171 uint64_t ccv64 = count + alarm_cfg->ticks; in counter_gecko_set_alarm()
181 dev_data->alarm[chan_id].callback = alarm_cfg->callback; in counter_gecko_set_alarm()
182 dev_data->alarm[chan_id].user_data = alarm_cfg->user_data; in counter_gecko_set_alarm()
186 LOG_DBG("set alarm: channel %u, count %u", chan_id, ccv); in counter_gecko_set_alarm()
197 struct counter_gecko_data *const dev_data = dev->data; in counter_gecko_cancel_alarm()
205 dev_data->alarm[chan_id].callback = NULL; in counter_gecko_cancel_alarm()
206 dev_data->alarm[chan_id].user_data = NULL; in counter_gecko_cancel_alarm()
224 const struct counter_gecko_config *const dev_cfg = dev->config; in counter_gecko_init()
232 (RTCC_CntPresc_TypeDef)(31UL - __CLZ(dev_cfg->prescaler)), in counter_gecko_init()
234 (RTCC_CntPresc_TypeDef)CMU_DivToLog2(dev_cfg->prescaler), in counter_gecko_init()
236 rtccCntTickPresc, /* Count according to prescaler value */ in counter_gecko_init()
298 RTCC->CNT = 0; in counter_gecko_init()
301 dev_cfg->irq_config(); in counter_gecko_init()
303 LOG_INF("Device %s initialized", dev->name); in counter_gecko_init()
324 struct counter_gecko_data *const dev_data = dev->data; in ISR_DIRECT_DECLARE()
326 uint32_t count = RTCC_CounterGet(); in ISR_DIRECT_DECLARE() local
332 if (dev_data->top_callback) { in ISR_DIRECT_DECLARE()
333 dev_data->top_callback(dev, dev_data->top_user_data); in ISR_DIRECT_DECLARE()
340 if (dev_data->alarm[i].callback) { in ISR_DIRECT_DECLARE()
341 alarm_callback = dev_data->alarm[i].callback; in ISR_DIRECT_DECLARE()
342 dev_data->alarm[i].callback = NULL; in ISR_DIRECT_DECLARE()
343 alarm_callback(dev, i, count, in ISR_DIRECT_DECLARE()
344 dev_data->alarm[i].user_data); in ISR_DIRECT_DECLARE()