Lines Matching refs:counter
63 struct btmr_regs *counter = COUNTER_XEC_REG_BASE(dev); in counter_xec_start() local
65 if (counter->CTRL & MCHP_BTMR_CTRL_ENABLE) { in counter_xec_start()
69 counter->CTRL |= (MCHP_BTMR_CTRL_ENABLE | MCHP_BTMR_CTRL_START); in counter_xec_start()
78 struct btmr_regs *counter = COUNTER_XEC_REG_BASE(dev); in counter_xec_stop() local
81 if (!(counter->CTRL & MCHP_BTMR_CTRL_ENABLE)) { in counter_xec_stop()
86 reg = counter->CTRL; in counter_xec_stop()
92 counter->CTRL = reg; in counter_xec_stop()
94 counter->IEN = MCHP_BTMR_INTDIS; in counter_xec_stop()
95 counter->CNT = counter->PRLD; in counter_xec_stop()
104 struct btmr_regs *counter = COUNTER_XEC_REG_BASE(dev); in counter_xec_get_value() local
106 *ticks = counter->CNT; in counter_xec_get_value()
113 struct btmr_regs *counter = COUNTER_XEC_REG_BASE(dev); in counter_xec_set_alarm() local
136 if (alarm_cfg->ticks > counter->PRLD) { in counter_xec_set_alarm()
140 counter->CNT = alarm_cfg->ticks; in counter_xec_set_alarm()
145 counter->IEN = MCHP_BTMR_INTEN; in counter_xec_set_alarm()
149 counter->CTRL |= MCHP_BTMR_CTRL_START; in counter_xec_set_alarm()
157 struct btmr_regs *counter = COUNTER_XEC_REG_BASE(dev); in counter_xec_cancel_alarm() local
165 counter->CTRL &= ~MCHP_BTMR_CTRL_START; in counter_xec_cancel_alarm()
166 counter->IEN = MCHP_BTMR_INTDIS; in counter_xec_cancel_alarm()
178 struct btmr_regs *counter = COUNTER_XEC_REG_BASE(dev); in counter_xec_get_pending_int() local
180 return counter->STS; in counter_xec_get_pending_int()
185 struct btmr_regs *counter = COUNTER_XEC_REG_BASE(dev); in counter_xec_get_top_value() local
187 return counter->PRLD; in counter_xec_get_top_value()
193 struct btmr_regs *counter = COUNTER_XEC_REG_BASE(dev); in counter_xec_set_top_value() local
207 restart = ((counter->CTRL & MCHP_BTMR_CTRL_START) != 0U); in counter_xec_set_top_value()
209 counter->CTRL &= ~MCHP_BTMR_CTRL_START; in counter_xec_set_top_value()
212 if (counter->CNT > cfg->ticks) { in counter_xec_set_top_value()
216 counter->CNT = cfg->ticks; in counter_xec_set_top_value()
220 counter->CNT = cfg->ticks; in counter_xec_set_top_value()
223 counter->PRLD = cfg->ticks; in counter_xec_set_top_value()
229 counter->IEN = MCHP_BTMR_INTEN; in counter_xec_set_top_value()
230 counter->CTRL |= MCHP_BTMR_CTRL_AUTO_RESTART; in counter_xec_set_top_value()
232 counter->IEN = MCHP_BTMR_INTDIS; in counter_xec_set_top_value()
233 counter->CTRL &= ~MCHP_BTMR_CTRL_AUTO_RESTART; in counter_xec_set_top_value()
239 counter->CTRL |= MCHP_BTMR_CTRL_START; in counter_xec_set_top_value()
247 struct btmr_regs *counter = COUNTER_XEC_REG_BASE(dev); in counter_xec_isr() local
253 counter->STS = MCHP_BTMR_STS_ACTIVE; in counter_xec_isr()
265 counter->IEN = MCHP_BTMR_INTDIS; in counter_xec_isr()
271 alarm_cb(dev, 0, counter->CNT, user_data); in counter_xec_isr()
277 static DEVICE_API(counter, counter_xec_api) = {
290 struct btmr_regs *counter = COUNTER_XEC_REG_BASE(dev); in counter_xec_init() local
295 counter->CTRL &= ~MCHP_BTMR_CTRL_COUNT_UP; in counter_xec_init()
296 counter->CTRL |= (counter_cfg->prescaler << MCHP_BTMR_CTRL_PRESCALE_POS) & in counter_xec_init()
300 counter->PRLD = counter_cfg->info.max_top_value; in counter_xec_init()
301 counter->CNT = counter_cfg->info.max_top_value; in counter_xec_init()