Lines Matching +full:timer +full:- +full:triggered
3 * SPDX-License-Identifier: Apache-2.0
9 #include <zephyr/drivers/timer/system_timer.h>
10 #include <zephyr/dt-bindings/interrupt-controller/ite-intc.h>
17 LOG_MODULE_REGISTER(timer, LOG_LEVEL_ERR);
19 #define COUNT_1US (EC_FREQ / USEC_PER_SEC - 1)
22 "ITE RTOS timer HW frequency is fixed at 32768Hz");
24 /* Event timer configurations */
28 /* Event timer max count is 512 sec (base on clock source 32768Hz) */
31 /* Busy wait low timer configurations */
36 /* Busy wait high timer configurations */
40 /* Busy wait high timer max count is 71.58min (base on clock source 1MHz) */
44 const int32_t z_sys_timer_irq_for_test = DT_IRQ_BY_IDX(DT_NODELABEL(timer), 5, irq);
49 * One shot timer configurations
63 * One system (kernel) tick is as how much HW timer counts
65 * NOTE: Event and free run timer individually select the same clock source
72 /* Event timer max count is as how much system (kernel) tick */
110 * so disabled one shot timer interrupt. in timer_5ms_one_shot_isr()
116 * This timer is used to wake up chip from sleep mode to complete
124 /* Initialize interrupt handler of one shot timer */ in timer_5ms_one_shot()
128 /* Set rising edge triggered of one shot timer */ in timer_5ms_one_shot()
131 /* Clear interrupt status of one shot timer */ in timer_5ms_one_shot()
134 /* Set clock source of one shot timer */ in timer_5ms_one_shot()
135 timer2_reg->ET2PSR = EXT_PSR_32P768K; in timer_5ms_one_shot()
138 * Set count of one shot timer, in timer_5ms_one_shot()
139 * and after write ET2CNTLLR timer will start in timer_5ms_one_shot()
142 timer2_reg->ET2CNTLH2R = (uint8_t)((hw_cnt >> 16) & 0xff); in timer_5ms_one_shot()
143 timer2_reg->ET2CNTLHR = (uint8_t)((hw_cnt >> 8) & 0xff); in timer_5ms_one_shot()
144 timer2_reg->ET2CNTLLR = (uint8_t)(hw_cnt & 0xff); in timer_5ms_one_shot()
160 usec_to_wait--; in arch_busy_wait()
163 if ((IT8XXX2_EXT_CNTOX(BUSY_WAIT_H_TIMER) - start) >= usec_to_wait) { in arch_busy_wait()
172 /* Enable and re-start event timer */ in evt_timer_enable()
181 /* Disable event timer */ in evt_timer_isr()
183 /* W/C event timer interrupt status */ in evt_timer_isr()
191 uint32_t dticks = (~(IT8XXX2_EXT_CNTOX(FREE_RUN_TIMER)) - in evt_timer_isr()
199 /* enable event timer */ in evt_timer_isr()
214 * TODO: to increment 32-bit "top half" here for software 64-bit in free_run_timer_overflow_isr()
215 * timer emulation. in free_run_timer_overflow_isr()
226 /* Always return for non-tickless kernel system */ in sys_clock_set_timeout()
233 /* Disable event timer */ in sys_clock_set_timeout()
239 * 1.CONFIG_SYSTEM_CLOCK_SLOPPY_IDLE = y (no future timer interrupts in sys_clock_set_timeout()
256 * in the future. So set event timer count to 1 HW tick. in sys_clock_set_timeout()
265 dcycles = next_cycs - now; in sys_clock_set_timeout()
270 /* Set event timer 24-bit count */ in sys_clock_set_timeout()
273 /* W/C event timer interrupt status */ in sys_clock_set_timeout()
276 /* enable event timer */ in sys_clock_set_timeout()
287 /* Always return 0 for non-tickless kernel system */ in sys_clock_elapsed()
297 uint32_t dticks = (~(IT8XXX2_EXT_CNTOX(FREE_RUN_TIMER)) - in sys_clock_elapsed()
311 * NOTE: Timer is counting down from 0xffffffff. In not combined in sys_clock_cycle_get_32()
346 LOG_ERR("Timer %d clock source error !", ext_timer); in timer_init()
347 return -1; in timer_init()
352 LOG_ERR("Timer %d count shouldn't be 0 !", ext_timer); in timer_init()
353 return -1; in timer_init()
357 /* Enable and re-start external timer x */ in timer_init()
360 /* Disable external timer x */ in timer_init()
364 /* Set rising edge triggered of external timer x */ in timer_init()
367 /* Clear interrupt status of external timer x */ in timer_init()
370 /* Set clock source of external timer x */ in timer_init()
373 /* Set count of external timer x */ in timer_init()
376 /* Disable external timer x */ in timer_init()
379 /* Enable and re-start external timer x */ in timer_init()
398 /* Enable 32-bit free run timer overflow interrupt */ in sys_clock_driver_init()
401 /* Set 32-bit timer4 for free run*/ in sys_clock_driver_init()
407 LOG_ERR("Init free run timer failed"); in sys_clock_driver_init()
411 /* Set 24-bit timer3 for timeout event */ in sys_clock_driver_init()
419 /* Start a event timer in one system tick */ in sys_clock_driver_init()
427 LOG_ERR("Init event timer failed"); in sys_clock_driver_init()
435 /* Set 32-bit timer6 to count-- every 1us */ in sys_clock_driver_init()
441 LOG_ERR("Init busy wait high timer failed"); in sys_clock_driver_init()
446 * Set 24-bit timer5 to overflow every 1us in sys_clock_driver_init()
449 * and timer5 will automatically re-start counting down in sys_clock_driver_init()
459 LOG_ERR("Init busy wait low timer failed"); in sys_clock_driver_init()