26 #include "in_compile.h" 27 #include "./hal/hal_clk.h" 34 #define TMR_SMEM_EMIT_EMPTY 0x1 35 #define TMR_SMEM_CAP_FULL 0x2 36 #define TMR_SMEM_EMIT_FIFO_UNDERFLOW 0x4 37 #define TMR_SMEM_EMIT_FIFO_OVERFLOW 0x8 38 #define TMR_SMEM_EMIT_REG_FIFO_UNDERFLOW 0x10 39 #define TMR_SMEM_EMIT_REG_FIFO_OVERFLOW 0x20 40 #define TMR_SMEM_CAP_FIFO_UNDERFLOW 0x40 41 #define TMR_SMEM_CAP_FIFO_OVERFLOW 0x80 42 #define TMR_SMEM_CAP_REG_FIFO_UNDERFLOW 0x100 43 #define TMR_SMEM_CAP_REG_FIFO_OVERFLOW 0x200 84 typedef struct tmr_emit_option_s{
89 uint8_t toggle_default;
105 #define SLP_TMR_MAX_64 0xFFFFFFFFFFFFFFFF 106 #define SLP_TMR_MAX_32 0xFFFFFFFF 117 AON_TMR_STS_EN = 0x1,
118 AON_TMR_STS_TOUCH = 0x2,
119 AON_TMR_STS_IRQ_CLR = 0x4,
120 AON_TMR_STS_MANU_MODE = 0x8,
121 AON_TMR_STS_MANU_TICK = 0x10,
136 enum aon_int_status_bit {
155 TMR_ERR_INVALID_PARAM = -1,
157 TMR_ERR_BAD_STATE = -3,
158 TMR_ERR_INVALID_ID = -4,
159 TMR_ERR_NOT_READY = -5,
160 TMR_ERR_TIMEOUT = -6,
168 static FORCEINLINE
void aon_tmr_init_tick(uint32_t addr, uint32_t tick)
173 static FORCEINLINE uint32_t aon_tmr_init_tick_sts(uint32_t addr)
175 return (RD_WORD(addr));
178 static FORCEINLINE
void aon_tmr0_init_tick(uint32_t tick)
180 WR_WORD(GLOBAL2_REG_AON_TIMER_0_INIT_VAL, tick);
183 static FORCEINLINE uint32_t aon_tmr0_init_tick_sts(
void)
185 return RD_WORD(GLOBAL2_REG_AON_TIMER_0_INIT_VAL_STS);
188 static FORCEINLINE
void aon_tmr1_init_tick(uint32_t tick)
190 WR_WORD(GLOBAL2_REG_AON_TIMER_1_INIT_VAL, tick);
193 static FORCEINLINE uint32_t aon_tmr1_init_tick_sts(
void)
195 return RD_WORD(GLOBAL2_REG_AON_TIMER_1_INIT_VAL_STS);
198 static FORCEINLINE
void aon_tmr2_init_tick(uint32_t tick)
200 WR_WORD(GLOBAL2_REG_AON_TIMER_2_INIT_VAL, tick);
203 static FORCEINLINE uint32_t aon_tmr2_init_tick_sts(
void)
205 return RD_WORD(GLOBAL2_REG_AON_TIMER_2_INIT_VAL_STS);
208 static FORCEINLINE
void aon_tmr3_init_tick(uint64_t tick)
210 WR_WORD(GLOBAL2_REG_AON_TIMER_3_INIT_VAL_LO, (uint32_t)tick);
211 WR_WORD(GLOBAL2_REG_AON_TIMER_3_INIT_VAL_HI, (uint32_t)(tick >> 32));
214 static FORCEINLINE uint64_t aon_tmr3_init_tick_sts(
void)
216 return (RD_WORD(GLOBAL2_REG_AON_TIMER_3_INIT_VAL_LO_STS) | ((uint64_t)RD_WORD(GLOBAL2_REG_AON_TIMER_3_INIT_VAL_HI_STS) << 32)) ;
219 static FORCEINLINE
void aon_tmr_snap_tick(
int id)
221 WR_WORD(GLOBAL2_REG_SNAPSHOT_CTRL, (1 << 20 <<
id));
222 RD_WORD(GLOBAL2_REG_SNAPSHOT_CTRL);
225 static FORCEINLINE uint32_t aon_tmr_read_tick(uint32_t addr)
227 return RD_WORD(addr);
230 static FORCEINLINE
void aon_tmr0_snap_tick(
void)
232 WR_WORD(GLOBAL2_REG_SNAPSHOT_CTRL, GLOBAL2_REG_SNAPSHOT_CTRL_CTL_AON_TIMER_0_TAKE_SNAPSHOT);
233 RD_WORD(GLOBAL2_REG_SNAPSHOT_CTRL);
236 static FORCEINLINE uint32_t aon_tmr0_read_tick(
int id)
238 return RD_WORD(GLOBAL2_REG_AON_TIMER_0_SNAPSHOT_VAL);
241 static FORCEINLINE
void aon_tmr1_snap_tick(
void)
243 WR_WORD(GLOBAL2_REG_SNAPSHOT_CTRL, GLOBAL2_REG_SNAPSHOT_CTRL_CTL_AON_TIMER_1_TAKE_SNAPSHOT);
244 RD_WORD(GLOBAL2_REG_SNAPSHOT_CTRL);
247 static FORCEINLINE uint32_t aon_tmr1_read_tick(
int id)
249 return RD_WORD(GLOBAL2_REG_AON_TIMER_1_SNAPSHOT_VAL);
252 static FORCEINLINE
void aon_tmr2_snap_tick(
void)
254 WR_WORD(GLOBAL2_REG_SNAPSHOT_CTRL, GLOBAL2_REG_SNAPSHOT_CTRL_CTL_AON_TIMER_2_TAKE_SNAPSHOT);
255 RD_WORD(GLOBAL2_REG_SNAPSHOT_CTRL);
258 static FORCEINLINE uint32_t aon_tmr2_read_tick(
int id)
260 return RD_WORD(GLOBAL2_REG_AON_TIMER_2_SNAPSHOT_VAL);
263 static FORCEINLINE
void aon_tmr3_snap_tick(
void)
265 WR_WORD(GLOBAL2_REG_SNAPSHOT_CTRL, GLOBAL2_REG_SNAPSHOT_CTRL_CTL_AON_TIMER_3_TAKE_SNAPSHOT);
266 RD_WORD(GLOBAL2_REG_SNAPSHOT_CTRL);
269 static FORCEINLINE uint64_t aon_tmr3_read_tick(
void)
271 return (RD_WORD(GLOBAL2_REG_AON_TIMER_3_SNAPSHOT_VAL_LO)|((uint64_t)RD_WORD(GLOBAL2_REG_AON_TIMER_3_SNAPSHOT_VAL_HI) << 32));
274 static FORCEINLINE
void aon_tmr_clk_en(
int id)
276 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)|(1 <<
id)));
279 static FORCEINLINE
void aon_tmr_clk_dis(
int id)
281 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)&~(1 <<
id)));
284 static FORCEINLINE
void aon_tmr0_clk_en(
void)
286 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)|AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER0_CLK_EN));
289 static FORCEINLINE
void aon_tmr0_clk_dis(
void)
291 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)&~AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER0_CLK_EN));
294 static FORCEINLINE
void aon_tmr1_clk_en(
void)
296 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)|AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER1_CLK_EN));
299 static FORCEINLINE
void aon_tmr1_clk_dis(
void)
301 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)&~AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER1_CLK_EN));
304 static FORCEINLINE
void aon_tmr2_clk_en(
void)
306 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)|AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER2_CLK_EN));
309 static FORCEINLINE
void aon_tmr2_clk_dis(
void)
311 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)&~AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER2_CLK_EN));
314 static FORCEINLINE
void aon_tmr3_clk_en(
void)
316 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)|AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER3_CLK_EN));
319 static FORCEINLINE
void aon_tmr3_clk_dis(
void)
321 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)&~AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER3_CLK_EN));
324 static FORCEINLINE
void aon_tmr_reload_en(
int id)
326 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)|(1 << 8 <<
id)));
329 static FORCEINLINE
void aon_tmr_reload_dis(
int id)
331 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)&~(1 << 8 <<
id)));
334 static FORCEINLINE
void aon_tmr0_reload_en(
void)
336 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)|AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER0_AUTO_RELOAD_EN));
339 static FORCEINLINE
void aon_tmr0_reload_dis(
void)
341 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)&~AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER0_AUTO_RELOAD_EN));
344 static FORCEINLINE
void aon_tmr1_reload_en(
void)
346 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)|AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER1_AUTO_RELOAD_EN));
349 static FORCEINLINE
void aon_tmr1_reload_dis(
void)
351 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)&~AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER1_AUTO_RELOAD_EN));
354 static FORCEINLINE
void aon_tmr2_reload_en(
void)
356 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)|AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER2_AUTO_RELOAD_EN));
359 static FORCEINLINE
void aon_tmr2_reload_dis(
void)
361 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)&~AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER2_AUTO_RELOAD_EN));
364 static FORCEINLINE
void aon_tmr3_reload_en(
void)
366 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)|AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER3_AUTO_RELOAD_EN));
369 static FORCEINLINE
void aon_tmr3_reload_dis(
void)
371 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)&~AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER3_AUTO_RELOAD_EN));
374 static FORCEINLINE
void aon_tmr_en(uint32_t addr)
376 WR_WORD(addr, (RD_WORD(addr)|Bit0));
379 static FORCEINLINE
int aon_tmr_en_sts(uint32_t addr)
381 return (RD_WORD(addr) & Bit0);
384 static FORCEINLINE
void aon_tmr0_en(
void)
386 WR_WORD(GLOBAL2_REG_AON_TIMER_0_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_0_CTL)|Bit0));
389 static FORCEINLINE
int aon_tmr0_en_sts(
void)
391 return (RD_WORD(GLOBAL2_REG_AON_TIMER_0_STS) & Bit0);
394 static FORCEINLINE
void aon_tmr1_en(
void)
396 WR_WORD(GLOBAL2_REG_AON_TIMER_1_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_1_CTL)|Bit0));
399 static FORCEINLINE
int aon_tmr1_en_sts(
void)
401 return (RD_WORD(GLOBAL2_REG_AON_TIMER_1_STS) & Bit0);
404 static FORCEINLINE
void aon_tmr2_en(
void)
406 WR_WORD(GLOBAL2_REG_AON_TIMER_2_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_2_CTL)|Bit0));
409 static FORCEINLINE
int aon_tmr2_en_sts(
void)
411 return (RD_WORD(GLOBAL2_REG_AON_TIMER_2_STS) & Bit0);
414 static FORCEINLINE
void aon_tmr3_en(
void)
416 WR_WORD(GLOBAL2_REG_AON_TIMER_3_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_3_CTL)|Bit0));
419 static FORCEINLINE
int aon_tmr3_en_sts(
void)
421 return (RD_WORD(GLOBAL2_REG_AON_TIMER_3_STS) & Bit0);
424 static FORCEINLINE
void aon_tmr_dis(uint32_t addr)
426 WR_WORD(addr, (RD_WORD(addr)&~Bit0));
429 static FORCEINLINE
int aon_tmr_dis_sts(uint32_t addr)
431 return ((RD_WORD(addr) & Bit0) ? 0 : 1);
434 static FORCEINLINE
void aon_tmr0_dis(
void)
436 WR_WORD(GLOBAL2_REG_AON_TIMER_0_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_0_CTL)&~Bit0));
439 static FORCEINLINE
int aon_tmr0_dis_sts(
void)
441 return ((RD_WORD(GLOBAL2_REG_AON_TIMER_0_STS) & Bit0) ? 0 : 1);
444 static FORCEINLINE
void aon_tmr1_dis(
void)
446 WR_WORD(GLOBAL2_REG_AON_TIMER_1_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_1_CTL)&~Bit0));
449 static FORCEINLINE
int aon_tmr1_dis_sts(
void)
451 return ((RD_WORD(GLOBAL2_REG_AON_TIMER_1_STS) & Bit0) ? 0 : 1);
454 static FORCEINLINE
void aon_tmr2_dis(
void)
456 WR_WORD(GLOBAL2_REG_AON_TIMER_2_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_2_CTL)&~Bit0));
459 static FORCEINLINE
int aon_tmr2_dis_sts(
void)
461 return ((RD_WORD(GLOBAL2_REG_AON_TIMER_2_STS) & Bit0) ? 0 : 1);
464 static FORCEINLINE
void aon_tmr3_dis(
void)
466 WR_WORD(GLOBAL2_REG_AON_TIMER_3_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_3_CTL)&~Bit0));
469 static FORCEINLINE
int aon_tmr3_dis_sts(
void)
471 return ((RD_WORD(GLOBAL2_REG_AON_TIMER_3_STS) & Bit0) ? 0 : 1);
474 static FORCEINLINE
void aon_tmr_touch(uint32_t addr)
476 WR_WORD(addr, (RD_WORD(addr) | Bit1));
479 static FORCEINLINE
int aon_tmr_touch_sts(uint32_t addr)
481 return (RD_WORD(addr) & Bit1);
484 static FORCEINLINE
void aon_tmr0_touch(
void)
486 WR_WORD(GLOBAL2_REG_AON_TIMER_0_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_0_CTL)|Bit1));
489 static FORCEINLINE
int aon_tmr0_touch_sts(
void)
491 return (((RD_WORD(GLOBAL2_REG_AON_TIMER_0_STS) & Bit1) >> 1) & 1);
494 static FORCEINLINE
void aon_tmr1_touch(
int toggle)
496 WR_WORD(GLOBAL2_REG_AON_TIMER_1_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_1_CTL)|Bit1));
499 static FORCEINLINE
int aon_tmr1_touch_sts(
void)
501 return (((RD_WORD(GLOBAL2_REG_AON_TIMER_1_STS) & Bit1) >> 1) & 1);
504 static FORCEINLINE
void aon_tmr2_touch(
int toggle)
506 WR_WORD(GLOBAL2_REG_AON_TIMER_2_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_2_CTL)|Bit1));
509 static FORCEINLINE
int aon_tmr2_touch_sts(
void)
511 return (((RD_WORD(GLOBAL2_REG_AON_TIMER_2_STS) & Bit1) >> 1) & 1);
514 static FORCEINLINE
void aon_tmr3_touch(
int toggle)
516 WR_WORD(GLOBAL2_REG_AON_TIMER_3_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_3_CTL)|Bit1));
519 static FORCEINLINE
int aon_tmr3_touch_sts(
void)
521 return (((RD_WORD(GLOBAL2_REG_AON_TIMER_3_STS) & Bit1) >> 1) & 1);
524 static FORCEINLINE
void aon_tmr_irq_clr(uint32_t addr, uint32_t sts_addr)
526 WR_WORD(addr, Bit7 |Bit2 | RD_WORD(sts_addr));
529 static FORCEINLINE
int aon_tmr_irq_clr_sts(uint32_t addr)
531 return (((RD_WORD(addr) & Bit2) >> 2) & 1);
534 static FORCEINLINE
void aon_tmr0_irq_clr(
void)
536 WR_WORD(GLOBAL2_REG_AON_TIMER_0_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_0_CTL)|Bit2));
539 static FORCEINLINE
int aon_tmr0_irq_clr_sts(
void)
541 return (((RD_WORD(GLOBAL2_REG_AON_TIMER_0_STS) & Bit2) >> 2) & 1);
544 static FORCEINLINE
void aon_tmr1_irq_clr(
void)
546 WR_WORD(GLOBAL2_REG_AON_TIMER_1_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_1_CTL)|Bit2));
549 static FORCEINLINE
int aon_tmr1_irq_clr_sts(
void)
551 return (((RD_WORD(GLOBAL2_REG_AON_TIMER_1_STS) & Bit2) >> 2) & 1);
554 static FORCEINLINE
void aon_tmr2_irq_clr(
void)
556 WR_WORD(GLOBAL2_REG_AON_TIMER_2_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_2_CTL)|Bit2));
559 static FORCEINLINE
int aon_tmr2_irq_clr_sts(
void)
561 return (((RD_WORD(GLOBAL2_REG_AON_TIMER_2_STS) & Bit2) >> 2) & 1);
564 static FORCEINLINE
void aon_tmr3_irq_clr(
void)
566 WR_WORD(GLOBAL2_REG_AON_TIMER_3_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_3_CTL)|Bit2));
569 static FORCEINLINE
int aon_tmr3_irq_clr_sts(
void)
571 return (((RD_WORD(GLOBAL2_REG_AON_TIMER_3_STS) & Bit2) >> 2) & 1);
574 static FORCEINLINE
void aon_tmr_manual_en(uint32_t addr)
576 WR_WORD(addr, (RD_WORD(addr) | Bit3));
579 static FORCEINLINE
int aon_tmr_manual_en_sts(uint32_t addr)
581 return ((RD_WORD(addr) & Bit3) >> 3);
584 static FORCEINLINE
void aon_tmr_manual_dis(uint32_t addr)
586 WR_WORD(addr, (RD_WORD(addr) & ~Bit3));
589 static FORCEINLINE
int aon_tmr_manual_dis_sts(uint32_t addr)
591 return ((RD_WORD(addr) & Bit3) >> 3);
594 static FORCEINLINE
void aon_tmr_manual_tick_en(uint32_t addr)
596 WR_WORD(addr, (RD_WORD(addr) | Bit4));
599 static FORCEINLINE
int aon_tmr_manual_tick_en_sts(uint32_t addr)
601 return (((RD_WORD(addr) & Bit4) >> 4) & 1);
604 static FORCEINLINE
void aon_tmr_manual_tick_dis(uint32_t addr)
606 WR_WORD(addr, (RD_WORD(addr) & ~Bit4));
609 static FORCEINLINE
int aon_tmr_manual_tick_dis_sts(uint32_t addr)
611 return (((RD_WORD(addr) & Bit4) >> 4) & 1);
614 static FORCEINLINE
void aon_tmr_wup_en(
int id)
616 WR_WORD(AON_REG_AON_TIMER_WAKE_UP_SEL, (RD_WORD(AON_REG_AON_TIMER_WAKE_UP_SEL)|(1<<
id)));
619 static FORCEINLINE
void aon_tmr_wup_dis(
int id)
621 WR_WORD(AON_REG_AON_TIMER_WAKE_UP_SEL, (RD_WORD(AON_REG_AON_TIMER_WAKE_UP_SEL)&~(1<<
id)));
624 static FORCEINLINE
void aon_tmr_int_clk_en(
void)
626 WR_WORD(GLOBAL_REG_CLK_ENABLE_1, (RD_WORD(GLOBAL_REG_CLK_ENABLE_1)|GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_AON_TIMER_INTR_CLK));
629 static FORCEINLINE
void aon_tmr_int_clk_dis(
void)
631 WR_WORD(GLOBAL_REG_CLK_ENABLE_1, (RD_WORD(GLOBAL_REG_CLK_ENABLE_1)&~GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_AON_TIMER_INTR_CLK));
634 static FORCEINLINE uint32_t aon_tmr_int_status(
void)
636 return (RD_WORD(GLOBAL2_REG_AON_TIMER_INTR_STATUS));
639 static FORCEINLINE uint32_t aon_tmr_int_mask_status(
void)
641 return (RD_WORD(GLOBAL2_REG_AON_TIMER_INTR_MASK_STATUS));
644 static FORCEINLINE
void aon_tmr_int_clear(uint32_t status)
646 WR_WORD(GLOBAL2_REG_AON_TIMER_INTR_CLEAR, status);
649 static FORCEINLINE
void aon_tmr_int_set(
int idx)
652 WR_WORD(GLOBAL2_REG_AON_TIMER_INTR_SET, (1 << idx));
655 static FORCEINLINE
void aon_tmr_int_mask_set(
int idx)
657 WR_WORD(GLOBAL2_REG_AON_TIMER_INTR_MASK_SET, (1 << idx));
660 static FORCEINLINE
void aon_tmr_cap_int_mask_set(
int idx)
662 WR_WORD(GLOBAL2_REG_AON_TIMER_INTR_MASK_SET, (1 << AON_TMR2_INT_CAP0 << idx));
665 static FORCEINLINE
void aon_tmr_emit_int_mask_set(
int idx)
667 WR_WORD(GLOBAL2_REG_AON_TIMER_INTR_MASK_SET, (1 << AON_TMR2_INT_EMIT0 << idx));
670 static FORCEINLINE
void aon_tmr_int_mask_clear(
int idx)
672 WR_WORD(GLOBAL2_REG_AON_TIMER_INTR_MASK_CLEAR, (1 << idx));
675 static FORCEINLINE
void aon_tmr_cap_int_mask_clear(
int idx)
677 WR_WORD(GLOBAL2_REG_AON_TIMER_INTR_MASK_CLEAR, (1 << AON_TMR2_INT_CAP0 << idx));
680 static FORCEINLINE
void aon_tmr_emit_int_mask_clear(
int idx)
682 WR_WORD(GLOBAL2_REG_AON_TIMER_INTR_MASK_CLEAR, (1 << AON_TMR2_INT_EMIT0 << idx));
685 static FORCEINLINE
void aon_tmr_cap_clk_en(
void)
687 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)|AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER2_CAP_CLK_EN));
690 static FORCEINLINE
void aon_tmr_cap_clk_dis(
void)
692 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL)&~AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER2_CAP_CLK_EN));
695 static FORCEINLINE
void aon_tmr_cap_rise_en(
int idx)
697 WR_WORD(AON_REG_AON_TIMER2_MISC_CTRL, (RD_WORD(AON_REG_AON_TIMER2_MISC_CTRL)|(1 << AON_REG_AON_TIMER2_MISC_CTRL_CTL_AON_TIMER2_CAP_SIG_REDGE_EN_SHIFT << idx)));
700 static FORCEINLINE
void aon_tmr_cap_rise_dis(
int idx)
702 WR_WORD(AON_REG_AON_TIMER2_MISC_CTRL, (RD_WORD(AON_REG_AON_TIMER2_MISC_CTRL)&~(1 << AON_REG_AON_TIMER2_MISC_CTRL_CTL_AON_TIMER2_CAP_SIG_REDGE_EN_SHIFT << idx)));
705 static FORCEINLINE
void aon_tmr_cap_fall_en(
int idx)
707 WR_WORD(AON_REG_AON_TIMER2_MISC_CTRL, (RD_WORD(AON_REG_AON_TIMER2_MISC_CTRL)|(1 << AON_REG_AON_TIMER2_MISC_CTRL_CTL_AON_TIMER2_CAP_SIG_FEDGE_EN_SHIFT << idx)));
710 static FORCEINLINE
void aon_tmr_cap_fall_dis(
int idx)
712 WR_WORD(AON_REG_AON_TIMER2_MISC_CTRL, (RD_WORD(AON_REG_AON_TIMER2_MISC_CTRL)&~(1 << AON_REG_AON_TIMER2_MISC_CTRL_CTL_AON_TIMER2_CAP_SIG_FEDGE_EN_SHIFT << idx)));
715 static FORCEINLINE
void aon_tmr_cap_sig(
int idx,
int hw_id)
717 WR_WORD(AON_REG_AON_TIMER2_MISC_CTRL, ((RD_WORD(AON_REG_AON_TIMER2_MISC_CTRL) & ~(0xFF << (16 + (idx << 3)))) | ((hw_id &0xFF) << (16 + (idx << 3)))));
720 static FORCEINLINE uint32_t aon_tmr_cap_read_tick(
int idx)
722 return (RD_WORD(GLOBAL_REG_AON_TIMER2_CAP_VAL_0 + (idx << 2)));
725 static FORCEINLINE
void aon_tmr_emit_clk_en(
void)
727 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL) |AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER2_EMIT_CLK_EN));
730 static FORCEINLINE
void aon_tmr_emit_clk_dis(
void)
732 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, (RD_WORD(AON_REG_AON_TIMER_CLK_CTRL) &~AON_REG_AON_TIMER_CLK_CTRL_CTL_AON_TIMER2_EMIT_CLK_EN));
735 static FORCEINLINE
void aon_tmr_emit_en(
int idx)
737 WR_WORD(AON_REG_AON_TIMER2_MISC_CTRL, (RD_WORD(AON_REG_AON_TIMER2_MISC_CTRL)|(1 << AON_REG_AON_TIMER2_MISC_CTRL_CTL_AON_TIMER2_EMIT_EN_SHIFT << idx)));
740 static FORCEINLINE
void aon_tmr_emit_dis(
int idx)
742 WR_WORD(AON_REG_AON_TIMER2_MISC_CTRL, (RD_WORD(AON_REG_AON_TIMER2_MISC_CTRL)&~(1 << AON_REG_AON_TIMER2_MISC_CTRL_CTL_AON_TIMER2_EMIT_EN_SHIFT << idx)));
745 static FORCEINLINE
void aon_tmr_emit_auto_clr_en(
int idx)
747 WR_WORD(AON_REG_AON_TIMER2_MISC_CTRL, (RD_WORD(AON_REG_AON_TIMER2_MISC_CTRL)|(1 << AON_REG_AON_TIMER2_MISC_CTRL_CTL_AON_TIMER2_EMIT_AUTO_CLR_SHIFT << idx)));
750 static FORCEINLINE
void aon_tmr_emit_auto_clr_dis(
int idx)
752 WR_WORD(AON_REG_AON_TIMER2_MISC_CTRL, (RD_WORD(AON_REG_AON_TIMER2_MISC_CTRL)&~(1 << AON_REG_AON_TIMER2_MISC_CTRL_CTL_AON_TIMER2_EMIT_AUTO_CLR_SHIFT << idx)));
755 static FORCEINLINE
void aon_tmr_emit_touch_clr_en(
int idx)
757 WR_WORD(AON_REG_AON_TIMER2_MISC_CTRL, (RD_WORD(AON_REG_AON_TIMER2_MISC_CTRL)|
758 (1 << AON_REG_AON_TIMER2_MISC_CTRL_CTL_AON_TIMER2_EMIT_TOUCH_CLR_EMIT_SHIFT << idx)));
761 static FORCEINLINE
void aon_tmr_emit_touch_clr_dis(
int idx)
763 WR_WORD(AON_REG_AON_TIMER2_MISC_CTRL, (RD_WORD(AON_REG_AON_TIMER2_MISC_CTRL)&
764 ~(1 << AON_REG_AON_TIMER2_MISC_CTRL_CTL_AON_TIMER2_EMIT_TOUCH_CLR_EMIT_SHIFT << idx)));
767 static FORCEINLINE
void aon_tmr_emit_set_tick(
int idx, uint32_t tick)
769 WR_WORD((AON_REG_AON_TIMER2_EMIT_VAL_0 + (idx << 2)), tick);
772 static FORCEINLINE
void aon_tmr_emit_wup_en(
int idx)
774 WR_WORD(AON_REG_AON_TIMER_WAKE_UP_SEL, (RD_WORD(AON_REG_AON_TIMER_WAKE_UP_SEL)|(1 << 4 << idx)));
777 static FORCEINLINE
void aon_tmr_emit_wup_dis(
int idx)
779 WR_WORD(AON_REG_AON_TIMER_WAKE_UP_SEL, (RD_WORD(AON_REG_AON_TIMER_WAKE_UP_SEL)&~(1 << 4 << idx)));
782 static FORCEINLINE
void aon_tmr_emit_man_clr(
int idx)
784 WR_WORD(GLOBAL2_REG_AON_TIMER_2_CTL, (RD_WORD(GLOBAL2_REG_AON_TIMER_2_CTL)|(1 << 16 << idx)));
790 static FORCEINLINE
void tmr_all_enable(
void)
792 WR_WORD(TIMERS_REGS_TIMERS_MISC_CTRL, (RD_WORD(TIMERS_REGS_TIMERS_MISC_CTRL) | Bit0));
795 static FORCEINLINE
void tmr_intr_reset(
int en)
797 uint32_t reg = RD_WORD(TIMERS_REGS_TIMERS_MISC_CTRL);
803 WR_WORD(TIMERS_REGS_TIMERS_MISC_CTRL, reg);
806 static FORCEINLINE
void tmr_add_all_enable(
void)
808 WR_WORD(TIMERS_ADD_REGS_TIMERS_MISC_CTRL, (RD_WORD(TIMERS_ADD_REGS_TIMERS_MISC_CTRL) | Bit0));
811 static FORCEINLINE
void tmr_add_intr_reset(
int en)
813 uint32_t reg = RD_WORD(TIMERS_ADD_REGS_TIMERS_MISC_CTRL);
819 WR_WORD(TIMERS_ADD_REGS_TIMERS_MISC_CTRL, reg);
822 static FORCEINLINE
void tmr_manual_en(
int id)
825 WR_WORD(TIMERS_REGS_TIMERS_MISC_CTRL, (RD_WORD(TIMERS_REGS_TIMERS_MISC_CTRL) | (1 << 16 <<
id)));
827 WR_WORD(TIMERS_ADD_REGS_TIMERS_MISC_CTRL, (RD_WORD(TIMERS_ADD_REGS_TIMERS_MISC_CTRL) | (1 << (16 +
id - 6))));
830 static FORCEINLINE
void tmr_manual_dis(
int id)
833 WR_WORD(TIMERS_REGS_TIMERS_MISC_CTRL, (RD_WORD(TIMERS_REGS_TIMERS_MISC_CTRL) & ~(1 << 16 <<
id)));
835 WR_WORD(TIMERS_ADD_REGS_TIMERS_MISC_CTRL, (RD_WORD(TIMERS_ADD_REGS_TIMERS_MISC_CTRL) & ~(1 << (16 +
id - 6))));
838 static FORCEINLINE
void tmr_manual_tick(
int id)
841 WR_WORD(TIMERS_REGS_MANUAL_TICK, (1 <<
id));
843 WR_WORD(TIMERS_REGS_MANUAL_TICK, (1 << (8 +
id -6)));
846 static FORCEINLINE
void tmr_reload_en(
int id)
849 WR_WORD(TIMERS_REGS_TIMERS_MISC_CTRL, (RD_WORD(TIMERS_REGS_TIMERS_MISC_CTRL) | (1 << 24 <<
id)));
851 WR_WORD(TIMERS_ADD_REGS_TIMERS_MISC_CTRL, (RD_WORD(TIMERS_ADD_REGS_TIMERS_MISC_CTRL) | (1 << (24 +
id - 6))));
854 static FORCEINLINE
void tmr_reload_dis(
int id)
857 WR_WORD(TIMERS_REGS_TIMERS_MISC_CTRL, (RD_WORD(TIMERS_REGS_TIMERS_MISC_CTRL) & ~(1 << 24 <<
id)));
859 WR_WORD(TIMERS_ADD_REGS_TIMERS_MISC_CTRL, (RD_WORD(TIMERS_ADD_REGS_TIMERS_MISC_CTRL) & ~(1 << (24 +
id - 6))));
862 static FORCEINLINE
void tmr_touch(
int id)
865 WR_WORD(TIMERS_REGS_TOUCH, (1 <<
id));
867 WR_WORD(TIMERS_REGS_TOUCH, (1 << (8 +
id -6)));
870 static FORCEINLINE
void tmr_enable(uint32_t addr)
872 WR_WORD(addr, (RD_WORD(addr) | Bit0));
875 static FORCEINLINE
void tmr0_enable(
void)
877 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL) | Bit0));
880 static FORCEINLINE
void tmr1_enable(
void)
882 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL) | Bit0));
885 static FORCEINLINE
void tmr2_enable(
void)
887 WR_WORD(TIMERS_REGS_BASIC_TIMER_2_CTRL, (RD_WORD(TIMERS_REGS_BASIC_TIMER_2_CTRL) | Bit0));
890 static FORCEINLINE
void tmr3_enable(
void)
892 WR_WORD(TIMERS_REGS_BASIC_TIMER_3_CTRL, (RD_WORD(TIMERS_REGS_BASIC_TIMER_3_CTRL) | Bit0));
895 static FORCEINLINE
void tmr4_enable(
void)
897 WR_WORD(TIMERS_REGS_BASIC_TIMER_4_CTRL, (RD_WORD(TIMERS_REGS_BASIC_TIMER_4_CTRL) | Bit0));
900 static FORCEINLINE
void tmr5_enable(
void)
902 WR_WORD(TIMERS_REGS_BASIC_TIMER_5_CTRL, (RD_WORD(TIMERS_REGS_BASIC_TIMER_5_CTRL) | Bit0));
905 static FORCEINLINE
void tmr_disable(uint32_t addr)
907 WR_WORD(addr, (RD_WORD(addr) & ~Bit0));
910 static FORCEINLINE
void tmr0_disable(
void)
912 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL) & ~Bit0));
915 static FORCEINLINE
void tmr1_disable(
void)
917 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL) & ~Bit0));
920 static FORCEINLINE
void tmr2_disable(
void)
922 WR_WORD(TIMERS_REGS_BASIC_TIMER_2_CTRL, (RD_WORD(TIMERS_REGS_BASIC_TIMER_2_CTRL) & ~Bit0));
925 static FORCEINLINE
void tmr3_disable(
void)
927 WR_WORD(TIMERS_REGS_BASIC_TIMER_3_CTRL, (RD_WORD(TIMERS_REGS_BASIC_TIMER_3_CTRL) & ~Bit0));
930 static FORCEINLINE
void tmr4_disable(
void)
932 WR_WORD(TIMERS_REGS_BASIC_TIMER_4_CTRL, (RD_WORD(TIMERS_REGS_BASIC_TIMER_4_CTRL) & ~Bit0));
935 static FORCEINLINE
void tmr5_disable(
void)
937 WR_WORD(TIMERS_REGS_BASIC_TIMER_5_CTRL, (RD_WORD(TIMERS_REGS_BASIC_TIMER_5_CTRL) & ~Bit0));
940 static FORCEINLINE
void tmr_init_tick(uint32_t addr, uint32_t tick)
945 static FORCEINLINE uint32_t tmr_read_init_tick(uint32_t addr)
947 return RD_WORD(addr);
950 static FORCEINLINE
void tmr0_init_tick(uint32_t tick)
952 WR_WORD(TIMERS_REGS_ADV_TIMER_0_INIT_VAL, tick);
955 static FORCEINLINE uint32_t tmr0_read_init_tick(
void)
957 return RD_WORD(TIMERS_REGS_ADV_TIMER_0_INIT_VAL);
960 static FORCEINLINE
void tmr1_init_tick(uint32_t tick)
962 WR_WORD(TIMERS_REGS_ADV_TIMER_1_INIT_VAL, tick);
965 static FORCEINLINE uint32_t tmr1_read_init_tick(
void)
967 return RD_WORD(TIMERS_REGS_ADV_TIMER_1_INIT_VAL);
970 static FORCEINLINE
void tmr2_init_tick(uint32_t tick)
972 WR_WORD(TIMERS_REGS_BASIC_TIMER_2_INIT_VAL, tick);
975 static FORCEINLINE uint32_t tmr2_read_init_tick(
void)
977 return RD_WORD(TIMERS_REGS_BASIC_TIMER_2_INIT_VAL);
980 static FORCEINLINE
void tmr3_init_tick(uint32_t tick)
982 WR_WORD(TIMERS_REGS_BASIC_TIMER_3_INIT_VAL, tick);
985 static FORCEINLINE uint32_t tmr3_read_init_tick(
void)
987 return RD_WORD(TIMERS_REGS_BASIC_TIMER_3_INIT_VAL);
990 static FORCEINLINE
void tmr4_init_tick(uint32_t tick)
992 WR_WORD(TIMERS_REGS_BASIC_TIMER_4_INIT_VAL, tick);
995 static FORCEINLINE uint32_t tmr4_read_init_tick(
void)
997 return RD_WORD(TIMERS_REGS_BASIC_TIMER_4_INIT_VAL);
1000 static FORCEINLINE
void tmr5_init_tick(uint32_t tick)
1002 WR_WORD(TIMERS_REGS_BASIC_TIMER_5_INIT_VAL, tick);
1005 static FORCEINLINE uint32_t tmr5_read_init_tick(
void)
1007 return RD_WORD(TIMERS_REGS_BASIC_TIMER_5_INIT_VAL);
1010 static FORCEINLINE uint32_t tmr_read_tick(uint32_t addr)
1012 return RD_WORD(addr);
1015 static FORCEINLINE uint32_t tmr0_read_tick(
void)
1017 return RD_WORD(TIMERS_REGS_ADV_TIMER_0_CURR_VAL);
1020 static FORCEINLINE uint32_t tmr1_read_tick(
void)
1022 return RD_WORD(TIMERS_REGS_ADV_TIMER_1_CURR_VAL);
1025 static FORCEINLINE uint32_t tmr2_read_tick(
void)
1027 return RD_WORD(TIMERS_REGS_BASIC_TIMER_2_CURR_VAL);
1030 static FORCEINLINE uint32_t tmr3_read_tick(
void)
1032 return RD_WORD(TIMERS_REGS_BASIC_TIMER_3_CURR_VAL);
1035 static FORCEINLINE uint32_t tmr4_read_tick(
void)
1037 return RD_WORD(TIMERS_REGS_BASIC_TIMER_4_CURR_VAL);
1040 static FORCEINLINE uint32_t tmr5_read_tick(
void)
1042 return RD_WORD(TIMERS_REGS_BASIC_TIMER_5_CURR_VAL);
1045 static FORCEINLINE
void tmr_int_clear(
int id)
1048 WR_WORD(TIMERS_REGS_TIMEOUT_IRQ_CLR, (1 <<
id));
1050 WR_WORD(TIMERS_REGS_TIMEOUT_IRQ_CLR, (1 << (8 +
id - 6)));
1054 static INLINE
void tmr_systick_enable(uint32_t init_count)
1056 uint32_t reg = RD_WORD(TIMERS_REGS_SYSTICK_MISC_CTRL);
1057 reg &= ~(TIMERS_REGS_SYSTICK_MISC_CTRL_CTL_SYSTICK_FINECNT_LMT);
1058 reg |= (init_count & TIMERS_REGS_SYSTICK_MISC_CTRL_CTL_SYSTICK_FINECNT_LMT_MASK) << TIMERS_REGS_SYSTICK_MISC_CTRL_CTL_SYSTICK_FINECNT_LMT_SHIFT;
1059 reg |= TIMERS_REGS_SYSTICK_MISC_CTRL_CTL_SYSTICK_EN;
1060 WR_WORD(TIMERS_REGS_SYSTICK_MISC_CTRL, reg);
1062 reg = RD_WORD(AON_REG_SYSTICK_AON_CTRL);
1063 reg |= AON_REG_SYSTICK_AON_CTRL_CTL_SYSTICK_AON_EN;
1064 WR_WORD(AON_REG_SYSTICK_AON_CTRL, reg);
1067 static INLINE
void tmr_systick_disable(
void)
1069 uint32_t reg = RD_WORD(TIMERS_REGS_SYSTICK_MISC_CTRL);
1070 reg &= ~(TIMERS_REGS_SYSTICK_MISC_CTRL_CTL_SYSTICK_EN);
1071 WR_WORD(TIMERS_REGS_SYSTICK_MISC_CTRL, reg);
1074 static FORCEINLINE uint32_t tmr_systick_coarse_count(
void)
1076 return RD_WORD(TIMERS_REGS_SYSTICK_CURR_COARSECNT);
1079 static FORCEINLINE uint32_t tmr_systick_fine_count(
void)
1081 return RD_WORD(TIMERS_REGS_SYSTICK_CURR_FINECNT);
1084 static INLINE
void tmr_systick_sleep(
void)
1086 uint32_t reg = RD_WORD(TIMERS_REGS_SYSTICK_MISC_CTRL);
1087 reg |= TIMERS_REGS_SYSTICK_MISC_CTRL_CTL_SYSTICK_GO_TO_SLEEP;
1088 reg &= ~TIMERS_REGS_SYSTICK_MISC_CTRL_CTL_SYSTICK_WAKEUP;
1089 WR_WORD(TIMERS_REGS_SYSTICK_MISC_CTRL, reg);
1091 while (!(RD_WORD(TIMERS_REGS_SYSTICK_INTR_STATUS) & 0x2));
1093 WR_WORD(TIMERS_REGS_SYSTICK_INTR_CLEAR, 0x2);
1097 static INLINE
void tmr_systick_wup(
void)
1099 uint32_t reg = RD_WORD(TIMERS_REGS_SYSTICK_MISC_CTRL);
1100 reg &= ~TIMERS_REGS_SYSTICK_MISC_CTRL_CTL_SYSTICK_GO_TO_SLEEP;
1101 reg |= TIMERS_REGS_SYSTICK_MISC_CTRL_CTL_SYSTICK_WAKEUP;
1102 WR_WORD(TIMERS_REGS_SYSTICK_MISC_CTRL, reg);
1104 while (!(RD_WORD(TIMERS_REGS_SYSTICK_INTR_STATUS) & 0x1));
1106 WR_WORD(TIMERS_REGS_SYSTICK_INTR_CLEAR, 0x1);
1110 static INLINE
void tmr_systick_reset(
void)
1112 uint32_t reg = RD_WORD(TIMERS_REGS_SYSTICK_MISC_CTRL);
1113 reg |= TIMERS_REGS_SYSTICK_MISC_CTRL_CTL_SYSTICK_RESET;
1114 WR_WORD(TIMERS_REGS_SYSTICK_MISC_CTRL, reg);
1115 reg &= ~TIMERS_REGS_SYSTICK_MISC_CTRL_CTL_SYSTICK_RESET;
1116 WR_WORD(TIMERS_REGS_SYSTICK_MISC_CTRL, reg);
1119 static INLINE
void tmr_systick_clk_ratio(uint32_t frac, uint32_t integer)
1121 uint32_t reg = (frac & TIMERS_REGS_SYSTICK_CLK_RATIO_CTL_FRAC_SYSCLK_IN_SLPCLK_MASK);
1122 reg |= (integer & TIMERS_REGS_SYSTICK_CLK_RATIO_CTL_INT_SYSCLK_IN_SLPCLK_MASK) << TIMERS_REGS_SYSTICK_CLK_RATIO_CTL_INT_SYSCLK_IN_SLPCLK_SHIFT;
1123 WR_WORD(TIMERS_REGS_SYSTICK_CLK_RATIO, reg);
1126 static FORCEINLINE
void tmr_systick_clk_ratio_set(uint32_t ratio)
1128 WR_WORD(TIMERS_REGS_SYSTICK_CLK_RATIO, ratio);
1131 static FORCEINLINE uint32_t tmr_systick_clk_ratio_get(
void)
1133 return RD_WORD(TIMERS_REGS_SYSTICK_CLK_RATIO);
1137 static FORCEINLINE uint32_t tmr_systick_slp_clk_count(
void)
1139 return RD_WORD(TIMERS_REGS_SYSTICK_SLP_CLK_CNT);
1142 static FORCEINLINE uint32_t tmr_systick_slp_fine_count(
void)
1144 return RD_WORD(TIMERS_REGS_SYSTICK_SLP_FINE_CNT);
1147 static FORCEINLINE uint32_t tmr_systick_slp_coarse_count(
void)
1149 return RD_WORD(TIMERS_REGS_SYSTICK_SLP_COARSE_CNT);
1152 static FORCEINLINE uint32_t tmr_systick_store_coarse_count(
void)
1154 return RD_WORD(TIMERS_REGS_SYSTICK_STORED_COARSE_CNT);
1157 static FORCEINLINE uint32_t tmr_systick_store_fine_count(
void)
1159 return RD_WORD(TIMERS_REGS_SYSTICK_STORED_FINE_CNT);
1162 static FORCEINLINE uint32_t tmr_adv_int_status(uint32_t addr)
1164 return RD_WORD(addr);
1167 static FORCEINLINE uint32_t tmr0_adv_int_status(
void)
1169 return RD_WORD(TIMERS_REGS_TIMER0_MISC_INTR_STATUS);
1172 static FORCEINLINE uint32_t tmr1_adv_int_status(
void)
1174 return RD_WORD(TIMERS_REGS_TIMER1_MISC_INTR_STATUS);
1177 static FORCEINLINE uint32_t tmr_adv_int_mask_status(uint32_t addr)
1179 return RD_WORD(addr);
1182 static FORCEINLINE uint32_t tmr0_adv_int_mask_status(
void)
1184 return RD_WORD(TIMERS_REGS_TIMER0_MISC_INTR_MASK_STATUS);
1187 static FORCEINLINE uint32_t tmr1_adv_int_mask_status(
void)
1189 return RD_WORD(TIMERS_REGS_TIMER1_MISC_INTR_MASK_STATUS);
1192 static FORCEINLINE
void tmr_adv_int_clr_all(uint32_t addr)
1194 WR_WORD(addr, 0x3FFF);
1197 static FORCEINLINE
void tmr0_adv_int_clr_all(
void)
1199 WR_WORD(TIMERS_REGS_TIMER0_MISC_INTR_CLEAR, 0x3FFF);
1202 static FORCEINLINE
void tmr1_adv_int_clr_all(
void)
1204 WR_WORD(TIMERS_REGS_TIMER1_MISC_INTR_CLEAR, 0x3FFF);
1207 static FORCEINLINE
void tmr_adv_int_clr(uint32_t addr, uint32_t mask)
1209 WR_WORD(addr, mask);
1212 static FORCEINLINE
void tmr0_adv_int_clr(uint32_t mask)
1214 WR_WORD(TIMERS_REGS_TIMER0_MISC_INTR_CLEAR, mask);
1217 static FORCEINLINE
void tmr1_adv_int_clr(uint32_t mask)
1219 WR_WORD(TIMERS_REGS_TIMER1_MISC_INTR_CLEAR, mask);
1222 static FORCEINLINE
void tmr_adv_int_mask(uint32_t addr, uint32_t bit)
1224 WR_WORD(addr, (1 << bit));
1227 static FORCEINLINE
void tmr0_adv_int_mask(uint32_t bit)
1229 WR_WORD(TIMERS_REGS_TIMER0_MISC_INTR_MASK_SET, (1 << bit));
1232 static FORCEINLINE
void tmr1_adv_int_mask(uint32_t bit)
1234 WR_WORD(TIMERS_REGS_TIMER1_MISC_INTR_MASK_SET, (1 << bit));
1237 static FORCEINLINE
void tmr_adv_int_mask_all(uint32_t addr)
1239 WR_WORD(addr, 0x3FFF);
1242 static FORCEINLINE
void tmr0_adv_int_mask_all(
void)
1244 WR_WORD(TIMERS_REGS_TIMER0_MISC_INTR_MASK_SET, 0x3FFF);
1247 static FORCEINLINE
void tmr1_adv_int_mask_all(
void)
1249 WR_WORD(TIMERS_REGS_TIMER1_MISC_INTR_MASK_SET, 0x3FFF);
1252 static FORCEINLINE
void tmr_adv_int_unmask(uint32_t addr, uint32_t bit)
1254 WR_WORD(addr, (1 << bit));
1257 static FORCEINLINE
void tmr0_adv_int_unmask(uint32_t bit)
1259 WR_WORD(TIMERS_REGS_TIMER0_MISC_INTR_MASK_CLEAR, (1 << bit));
1262 static FORCEINLINE
void tmr1_adv_int_unmask(uint32_t bit)
1264 WR_WORD(TIMERS_REGS_TIMER1_MISC_INTR_MASK_CLEAR, (1 << bit));
1267 static FORCEINLINE
void tmr_adv_cap_rise_en(uint32_t addr,
int idx)
1269 WR_WORD(addr, (RD_WORD(addr) | (1 << TIMERS_REGS_ADV_TIMER_0_CTRL_CAP_REDGE_ENABLE_SHIFT << idx)));
1272 static FORCEINLINE
void tmr0_adv_cap_rise_en(
int idx)
1274 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL) | (1 << TIMERS_REGS_ADV_TIMER_0_CTRL_CAP_REDGE_ENABLE_SHIFT << idx)));
1277 static FORCEINLINE
void tmr1_adv_cap_rise_en(
int idx)
1279 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL) | (1 << TIMERS_REGS_ADV_TIMER_0_CTRL_CAP_REDGE_ENABLE_SHIFT << idx)));
1282 static FORCEINLINE
void tmr_adv_cap_rise_dis(uint32_t addr,
int idx)
1284 WR_WORD(addr, (RD_WORD(addr) & ~(1 << TIMERS_REGS_ADV_TIMER_0_CTRL_CAP_REDGE_ENABLE_SHIFT << idx)));
1287 static FORCEINLINE
void tmr0_adv_cap_rise_dis(uint32_t addr,
int idx)
1289 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL) & ~(1 << TIMERS_REGS_ADV_TIMER_0_CTRL_CAP_REDGE_ENABLE_SHIFT << idx)));
1292 static FORCEINLINE
void tmr1_adv_cap_rise_dis(uint32_t addr,
int idx)
1294 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL) & ~(1 << TIMERS_REGS_ADV_TIMER_0_CTRL_CAP_REDGE_ENABLE_SHIFT << idx)));
1297 static FORCEINLINE
void tmr_adv_cap_fall_en(uint32_t addr,
int idx)
1299 WR_WORD(addr, (RD_WORD(addr) | (1 << TIMERS_REGS_ADV_TIMER_0_CTRL_CAP_FEDGE_ENABLE_SHIFT << idx)));
1302 static FORCEINLINE
void tmr0_adv_cap_fall_en(uint32_t addr,
int idx)
1304 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL) | (1 << TIMERS_REGS_ADV_TIMER_0_CTRL_CAP_FEDGE_ENABLE_SHIFT << idx)));
1307 static FORCEINLINE
void tmr1_adv_cap_fall_en(uint32_t addr,
int idx)
1309 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL) | (1 << TIMERS_REGS_ADV_TIMER_0_CTRL_CAP_FEDGE_ENABLE_SHIFT << idx)));
1312 static FORCEINLINE
void tmr_adv_cap_fall_dis(uint32_t addr,
int idx)
1314 WR_WORD(addr, (RD_WORD(addr) & ~(1 << TIMERS_REGS_ADV_TIMER_0_CTRL_CAP_FEDGE_ENABLE_SHIFT << idx)));
1317 static FORCEINLINE
void tmr0_adv_cap_fall_dis(uint32_t addr,
int idx)
1319 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL) & ~(1 << TIMERS_REGS_ADV_TIMER_0_CTRL_CAP_FEDGE_ENABLE_SHIFT << idx)));
1322 static FORCEINLINE
void tmr1_adv_cap_fall_dis(uint32_t addr,
int idx)
1324 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL) & ~(1 << TIMERS_REGS_ADV_TIMER_0_CTRL_CAP_FEDGE_ENABLE_SHIFT << idx)));
1327 static FORCEINLINE
void tmr_adv_cap_sig(uint32_t addr,
int idx, uint8_t sig_id)
1329 WR_WORD(addr, ((RD_WORD(addr) & ~(0xFF << (idx << 3))) | (((sig_id & 0xFF) << (idx << 3)))));
1332 static FORCEINLINE
void tmr0_adv_cap_sig(
int idx, uint8_t sig_id)
1334 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CAP_SIG_SEL, ((RD_WORD(TIMERS_REGS_ADV_TIMER_0_CAP_SIG_SEL) & ~(0xFF << (idx << 3))) | (((sig_id & 0xFF) << (idx << 3)))));
1337 static FORCEINLINE
void tmr1_adv_cap_sig(
int idx, uint8_t sig_id)
1339 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CAP_SIG_SEL, ((RD_WORD(TIMERS_REGS_ADV_TIMER_1_CAP_SIG_SEL) & ~(0xFF << (idx << 3))) | (((sig_id & 0xFF) << (idx << 3)))));
1342 static FORCEINLINE uint32_t tmr_adv_cap_tick(uint32_t addr,
int idx)
1344 return RD_WORD(addr + (idx * 4));
1347 static FORCEINLINE uint32_t tmr0_adv_cap_tick(
int idx)
1349 return RD_WORD(TIMERS_REGS_ADV_TIMER_0_CAP_VAL_0 + (idx * 4));
1352 static FORCEINLINE uint32_t tmr1_adv_cap_tick(
int idx)
1354 return RD_WORD(TIMERS_REGS_ADV_TIMER_1_CAP_VAL_0 + (idx * 4));
1357 static FORCEINLINE
void tmr_adv_emit_en(uint32_t addr,
int idx)
1360 if ((idx == 8) || (idx == 9)) {
1361 WR_WORD(addr, (RD_WORD(addr) | (1 << (TIMERS_REGS_ADV_TIMER_0_CTRL_EMIT_ENABLE2_SHIFT + idx - 8))));
1363 WR_WORD(addr, (RD_WORD(addr) | (1 << (TIMERS_REGS_ADV_TIMER_0_CTRL_EMIT_ENABLE_SHIFT + idx))));
1367 static FORCEINLINE
void tmr0_adv_emit_en(
int idx)
1369 if ((idx == 8) || (idx == 9)) {
1370 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL) | (1 << (TIMERS_REGS_ADV_TIMER_0_CTRL_EMIT_ENABLE2_SHIFT + idx - 8))));
1372 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL) | (1 << (TIMERS_REGS_ADV_TIMER_0_CTRL_EMIT_ENABLE_SHIFT + idx))));
1377 static FORCEINLINE
void tmr1_adv_emit_en(
int idx)
1379 if ((idx == 8) || (idx == 9)) {
1380 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL) | (1 << (TIMERS_REGS_ADV_TIMER_1_CTRL_EMIT_ENABLE2_SHIFT + idx - 8))));
1382 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL) | (1 << (TIMERS_REGS_ADV_TIMER_1_CTRL_EMIT_ENABLE_SHIFT + idx))));
1386 static FORCEINLINE
void tmr_adv_emit_dis(uint32_t addr,
int idx)
1388 if ((idx == 8) || (idx == 9)) {
1389 WR_WORD(addr, (RD_WORD(addr) & ~(1 << (TIMERS_REGS_ADV_TIMER_0_CTRL_EMIT_ENABLE2_SHIFT + idx - 8))));
1391 WR_WORD(addr, (RD_WORD(addr) & ~(1 << (TIMERS_REGS_ADV_TIMER_0_CTRL_EMIT_ENABLE_SHIFT + idx))));
1395 static FORCEINLINE
void tmr0_adv_emit_dis(
int idx)
1398 if ((idx == 8) || (idx == 9)) {
1399 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL) & ~(1 << (TIMERS_REGS_ADV_TIMER_0_CTRL_EMIT_ENABLE2_SHIFT + idx - 8))));
1401 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL) & ~(1 << (TIMERS_REGS_ADV_TIMER_0_CTRL_EMIT_ENABLE_SHIFT + idx))));
1405 static FORCEINLINE
void tmr1_adv_emit_dis(
int idx)
1407 if ((idx == 8) || (idx == 9)) {
1408 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL) & ~(1 << (TIMERS_REGS_ADV_TIMER_1_CTRL_EMIT_ENABLE2_SHIFT + idx - 8))));
1410 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL) & ~(1 << (TIMERS_REGS_ADV_TIMER_1_CTRL_EMIT_ENABLE_SHIFT + idx))));
1414 static FORCEINLINE
void tmr_adv_emit_touch_clr_en(uint32_t addr,
int idx)
1416 if ((idx == 8) || (idx == 9)) {
1417 WR_WORD(addr, (RD_WORD(addr) | (1 << (TIMERS_REGS_ADV_TIMER_0_CTRL_TOUCH_CLR_EMIT2_SHIFT + idx - 8))));
1419 WR_WORD(addr, (RD_WORD(addr) | (1 << TIMERS_REGS_ADV_TIMER_0_CTRL_TOUCH_CLR_EMIT_SHIFT << idx)));
1423 static FORCEINLINE
void tmr0_adv_emit_touch_clr_en(
int idx)
1425 if ((idx == 8) || (idx == 9)) {
1426 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL) | (1 << (TIMERS_REGS_ADV_TIMER_0_CTRL_TOUCH_CLR_EMIT2_SHIFT + idx - 8))));
1428 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL) | (1 << TIMERS_REGS_ADV_TIMER_0_CTRL_TOUCH_CLR_EMIT_SHIFT << idx)));
1432 static FORCEINLINE
void tmr1_adv_emit_touch_clr_en(
int idx)
1434 if ((idx == 8) || (idx == 9)) {
1435 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL) | (1 << (TIMERS_REGS_ADV_TIMER_1_CTRL_TOUCH_CLR_EMIT2_SHIFT + idx - 8))));
1437 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL) | (1 << TIMERS_REGS_ADV_TIMER_1_CTRL_TOUCH_CLR_EMIT_SHIFT << idx)));
1442 static FORCEINLINE
void tmr_adv_emit_touch_clr_dis(uint32_t addr,
int idx)
1444 if ((idx == 8) || (idx == 9)) {
1445 WR_WORD(addr, (RD_WORD(addr) & ~(1 << (TIMERS_REGS_ADV_TIMER_0_CTRL_TOUCH_CLR_EMIT2_SHIFT + idx - 8))));
1447 WR_WORD(addr, (RD_WORD(addr) & ~(1 << TIMERS_REGS_ADV_TIMER_0_CTRL_TOUCH_CLR_EMIT_SHIFT << idx)));
1451 static FORCEINLINE
void tmr0_adv_emit_touch_clr_dis(
int idx)
1453 if ((idx == 8) || (idx == 9)) {
1454 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL) & ~(1 << (TIMERS_REGS_ADV_TIMER_0_CTRL_TOUCH_CLR_EMIT_SHIFT + idx - 8))));
1456 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL) & ~(1 << TIMERS_REGS_ADV_TIMER_0_CTRL_TOUCH_CLR_EMIT_SHIFT << idx)));
1460 static FORCEINLINE
void tmr1_adv_emit_touch_clr_dis(
int idx)
1462 if ((idx == 8) || (idx == 9)) {
1463 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL) & ~(1 << (TIMERS_REGS_ADV_TIMER_1_CTRL_TOUCH_CLR_EMIT_SHIFT + idx - 8))));
1465 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL, (RD_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL) & ~(1 << TIMERS_REGS_ADV_TIMER_1_CTRL_TOUCH_CLR_EMIT_SHIFT << idx)));
1469 static FORCEINLINE
void tmr_adv_emit_auto_clr_en(uint32_t addr,
int idx)
1471 WR_WORD(addr, (RD_WORD(addr) | (1 << idx)));
1474 static FORCEINLINE
void tmr0_adv_emit_auto_clr_en(
int idx)
1476 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL1, (RD_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL1) | (1 << idx)));
1479 static FORCEINLINE
void tmr1_adv_emit_auto_clr_en(
int idx)
1481 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL1, (RD_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL1) | (1 << idx)));
1484 static FORCEINLINE
void tmr_adv_emit_auto_clr_dis(uint32_t addr,
int idx)
1486 WR_WORD(addr, (RD_WORD(addr) & ~(1 << idx)));
1489 static FORCEINLINE
void tmr0_adv_emit_auto_clr_dis(
int idx)
1491 WR_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL1, (RD_WORD(TIMERS_REGS_ADV_TIMER_0_CTRL1) & ~(1 << idx)));
1494 static FORCEINLINE
void tmr1_adv_emit_auto_clr_dis(
int idx)
1496 WR_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL1, (RD_WORD(TIMERS_REGS_ADV_TIMER_1_CTRL1) & ~(1 << idx)));
1499 static FORCEINLINE
void tmr_adv_emit_manual_clr(uint32_t addr,
int idx)
1501 WR_WORD(addr, (1 << idx));
1504 static FORCEINLINE
void tmr0_adv_emit_manual_clr(
int idx)
1506 WR_WORD(TIMERS_REGS_ADV_TIMER_0_EMIT_CLR, (1 << idx));
1509 static FORCEINLINE
void tmr1_adv_emit_manual_clr(
int idx)
1511 WR_WORD(TIMERS_REGS_ADV_TIMER_1_EMIT_CLR, (1 << idx));
1514 static FORCEINLINE
int tmr_adv_emit_status(uint32_t addr,
int idx)
1516 return ((RD_WORD(addr) >> idx) & 1);
1519 static FORCEINLINE
int tmr0_adv_emit_status(
int idx)
1521 return ((RD_WORD(TIMERS_REGS_ADV_TIMER_0_EMIT_SIG_STATUS) >> idx) & 1);
1524 static FORCEINLINE
int tmr1_adv_emit_status(
int idx)
1526 return ((RD_WORD(TIMERS_REGS_ADV_TIMER_1_EMIT_SIG_STATUS) >> idx) & 1);
1529 static FORCEINLINE
void tmr_adv_emit_set_tick(uint32_t addr,
int idx, uint32_t tick)
1531 if ((idx == 8) || (idx == 9)) {
1532 WR_WORD((addr + (idx *4) + 8), tick);
1534 WR_WORD((addr + (idx *4)), tick);
1539 static FORCEINLINE
void tmr0_adv_emit_set_tick(
int idx, uint32_t tick)
1541 if ((idx == 8) || (idx == 9)) {
1542 WR_WORD((TIMERS_REGS_ADV_TIMER_0_EMIT_0 + (idx *4) + 8), tick);
1544 WR_WORD((TIMERS_REGS_ADV_TIMER_0_EMIT_0 + (idx *4)), tick);
1549 static FORCEINLINE
void tmr1_adv_emit_set_tick(
int idx, uint32_t tick)
1551 if ((idx == 8) || (idx == 9)) {
1552 WR_WORD((TIMERS_REGS_ADV_TIMER_1_EMIT_0 + (idx *4) + 8), tick);
1554 WR_WORD((TIMERS_REGS_ADV_TIMER_1_EMIT_0 + (idx *4)), tick);
1558 static FORCEINLINE
void tmr_adv_emit_toggle_default(uint32_t addr,
int idx,
int val)
1560 uint32_t reg = RD_WORD(addr);
1562 reg |= 1 << (10 + idx);
1564 reg &= ~(1 << (10 + idx));
1569 static FORCEINLINE
void tmr_adv_emit_toggle_pol(uint32_t addr,
int idx,
int val)
1571 uint32_t reg = RD_WORD(addr);
1573 reg |= 1 << (15 + idx);
1575 reg &= ~(1 << (15 + idx));
1580 static FORCEINLINE
void tmr_adv_emit_sig_toggle(uint32_t addr,
int idx,
int val)
1582 uint32_t reg = RD_WORD(addr);
1584 reg |= 1 << (20 + idx);
1586 reg &= ~(1 << (20 + idx));
1591 static FORCEINLINE
void tmr_adv_emit_sig_default(uint32_t addr,
int idx,
int val)
1593 uint32_t reg = RD_WORD(addr);
1602 static FORCEINLINE
void tmr_smem_emit_en(uint32_t addr)
1604 WR_WORD(addr, RD_WORD(addr) | TIMERS_REGS_EMIT_SHM_IF_CTRL_CTL_EMIT_SHM_IF_EN);
1607 static FORCEINLINE
void tmr_smem_emit_rst(uint32_t addr)
1609 uint32_t reg = RD_WORD(addr);
1610 WR_WORD(addr, reg | TIMERS_REGS_EMIT_SHM_IF_CTRL_CTL_EMIT_SHM_IF_RESET);
1611 WR_WORD(addr, reg & ~TIMERS_REGS_EMIT_SHM_IF_CTRL_CTL_EMIT_SHM_IF_RESET);
1615 static FORCEINLINE
void tmr_smem_emit_dis(uint32_t addr)
1617 WR_WORD(addr, RD_WORD(addr) & ~TIMERS_REGS_EMIT_SHM_IF_CTRL_CTL_EMIT_SHM_IF_EN);
1620 static FORCEINLINE
void tmr_smem_emit_set_max_num(uint32_t addr, uint32_t num)
1622 WR_WORD(addr, (RD_WORD(addr) & ~TIMERS_REGS_EMIT_SHM_IF_CTRL_CTL_EMIT_SHM_IF_NUM_ENTRIES_M1)
1623 | ((num & TIMERS_REGS_EMIT_SHM_IF_CTRL_CTL_EMIT_SHM_IF_NUM_ENTRIES_M1_MASK) << TIMERS_REGS_EMIT_SHM_IF_CTRL_CTL_EMIT_SHM_IF_NUM_ENTRIES_M1_SHIFT));
1625 static FORCEINLINE uint32_t tmr_smem_emit_get_max_num(uint32_t addr)
1627 return (RD_WORD(addr) & TIMERS_REGS_EMIT_SHM_IF_CTRL_CTL_EMIT_SHM_IF_NUM_ENTRIES_M1) >> TIMERS_REGS_EMIT_SHM_IF_CTRL_CTL_EMIT_SHM_IF_NUM_ENTRIES_M1_SHIFT;
1629 static FORCEINLINE
void tmr_smem_emit_empty_th(uint32_t addr, uint32_t num)
1631 WR_WORD(addr, (RD_WORD(addr) & ~TIMERS_REGS_EMIT_SHM_IF_CTRL_CTL_EMIT_SHM_IF_ALMOST_EMPTY_TH)
1632 | ((num & TIMERS_REGS_EMIT_SHM_IF_CTRL_CTL_EMIT_SHM_IF_ALMOST_EMPTY_TH_MASK) << TIMERS_REGS_EMIT_SHM_IF_CTRL_CTL_EMIT_SHM_IF_ALMOST_EMPTY_TH_SHIFT));
1635 static FORCEINLINE
void tmr_smem_emit_set_tick(uint32_t addr, uint32_t val)
1641 static FORCEINLINE uint32_t tmr_smem_emit_data_num(uint32_t addr)
1643 uint32_t reg = RD_WORD(addr);
1644 uint32_t smem = (reg & TIMERS_REGS_EMIT_SHM_NUM_VAL_STS_EMIT_SHM_IF_NUM_DATA_IN_SHM)>>TIMERS_REGS_EMIT_SHM_NUM_VAL_STS_EMIT_SHM_IF_NUM_DATA_IN_SHM_SHIFT;
1645 uint32_t reg_fifo = (reg & TIMERS_REGS_EMIT_SHM_NUM_VAL_STS_EMIT_SHM_IF_NUM_DATA_IN_REG_FIFO)>>TIMERS_REGS_EMIT_SHM_NUM_VAL_STS_EMIT_SHM_IF_NUM_DATA_IN_REG_FIFO_SHIFT;
1646 uint32_t fifo = (reg & TIMERS_REGS_EMIT_SHM_NUM_VAL_STS_EMIT_SHM_IF_NUM_DATA_IN_FIFO)>>TIMERS_REGS_EMIT_SHM_NUM_VAL_STS_EMIT_SHM_IF_NUM_DATA_IN_FIFO_SHIFT;
1647 return smem + reg_fifo + fifo;
1650 static FORCEINLINE
void tmr_smem_cap_en(uint32_t addr)
1652 WR_WORD(addr, RD_WORD(addr) | TIMERS_REGS_CAP_SHM_IF_CTRL_CTL_CAP_SHM_IF_EN);
1655 static FORCEINLINE
void tmr_smem_cap_dis(uint32_t addr)
1657 WR_WORD(addr, RD_WORD(addr) & ~TIMERS_REGS_CAP_SHM_IF_CTRL_CTL_CAP_SHM_IF_EN);
1660 static FORCEINLINE
void tmr_smem_cap_set_max_num(uint32_t addr, uint32_t num)
1662 WR_WORD(addr, (RD_WORD(addr) & ~TIMERS_REGS_CAP_SHM_IF_CTRL_CTL_CAP_SHM_IF_NUM_ENTRIES_M1)
1663 | ((num & TIMERS_REGS_CAP_SHM_IF_CTRL_CTL_CAP_SHM_IF_NUM_ENTRIES_M1_MASK) << TIMERS_REGS_CAP_SHM_IF_CTRL_CTL_CAP_SHM_IF_NUM_ENTRIES_M1_SHIFT));
1666 static FORCEINLINE uint32_t tmr_smem_cap_get_max_num(uint32_t addr)
1668 return (RD_WORD(addr) & TIMERS_REGS_CAP_SHM_IF_CTRL_CTL_CAP_SHM_IF_NUM_ENTRIES_M1) >> TIMERS_REGS_CAP_SHM_IF_CTRL_CTL_CAP_SHM_IF_NUM_ENTRIES_M1_SHIFT;
1671 static FORCEINLINE
void tmr_smem_cap_full_th(uint32_t addr, uint32_t num)
1673 WR_WORD(addr, (RD_WORD(addr) & ~TIMERS_REGS_CAP_SHM_IF_CTRL_CTL_CAP_SHM_IF_ALMOST_FULL_TH)
1674 | ((num & TIMERS_REGS_CAP_SHM_IF_CTRL_CTL_CAP_SHM_IF_ALMOST_FULL_TH_MASK) << TIMERS_REGS_CAP_SHM_IF_CTRL_CTL_CAP_SHM_IF_ALMOST_FULL_TH_SHIFT));
1677 static FORCEINLINE uint32_t tmr_smem_cap_tick(uint32_t addr)
1679 return RD_WORD(addr);
1682 static FORCEINLINE uint32_t tmr_smem_intr_status(uint32_t addr)
1684 return RD_WORD(addr);
1687 static FORCEINLINE uint32_t tmr_smem_intr_mask_status(
void)
1689 return RD_WORD(TIMERS_REGS_SHM_IF_INTR_MASK_STATUS);
1692 static FORCEINLINE
void tmr_smem_intr_clr(uint32_t addr, uint32_t val)
1697 static FORCEINLINE
void tmr_smem_intr_mask(uint32_t val)
1699 WR_WORD(TIMERS_REGS_SHM_IF_INTR_MASK_SET, val);
1702 static FORCEINLINE
void tmr_smem_intr_unmask(uint32_t val)
1704 WR_WORD(TIMERS_REGS_SHM_IF_INTR_MASK_CLEAR, val);
1707 static FORCEINLINE uint32_t tmr_smem_cap_data_ready(uint32_t addr)
1709 return ((RD_WORD(addr)&TIMERS_REGS_CAP_SHM_NUM_VAL_STS_CAP_SHM_IF_DATA_RDY) ? 1 : 0);
1711 static FORCEINLINE uint32_t tmr_smem_cap_data_num(uint32_t addr)
1713 uint32_t reg = RD_WORD(addr);
1714 uint32_t smem = (reg & TIMERS_REGS_CAP_SHM_NUM_VAL_STS_CAP_SHM_IF_NUM_DATA_IN_SHM)>>TIMERS_REGS_CAP_SHM_NUM_VAL_STS_CAP_SHM_IF_NUM_DATA_IN_SHM_SHIFT;
1715 uint32_t reg_fifo = (reg & TIMERS_REGS_CAP_SHM_NUM_VAL_STS_CAP_SHM_IF_NUM_DATA_IN_REG_FIFO)>>TIMERS_REGS_CAP_SHM_NUM_VAL_STS_CAP_SHM_IF_NUM_DATA_IN_REG_FIFO_SHIFT;
1716 uint32_t fifo = (reg & TIMERS_REGS_CAP_SHM_NUM_VAL_STS_CAP_SHM_IF_NUM_DATA_IN_FIFO)>>TIMERS_REGS_CAP_SHM_NUM_VAL_STS_CAP_SHM_IF_NUM_DATA_IN_FIFO_SHIFT;
1717 return smem + reg_fifo + fifo;
1719 static FORCEINLINE uint32_t tmr_smem_cap_data(uint32_t addr)
1721 return RD_WORD(addr);
1815 uint32_t hal_timer_get_tick_us(
int tim_id);
1853 uint32_t hal_timer_us_to_tick(
int tmr_id, uint32_t us);
1856 int hal_timer_capture_set_callback(
int tmr_id,
int prio,
void *arg,
void (*callback)(
void *,
int, uint32_t));
1894 int hal_timer_smem_capture_set_callback(
int prio,
void *arg,
void (*callback)(
void *parg, uint32_t sts, uint32_t cap_num));
1895 int hal_timer_smem_capture_signal_add(
int tmr_id, uint8_t sig_id,
int rise,
int fall, uint16_t max_num, uint16_t full_threshold);
1896 int hal_timer_smem_capture_signal_rem(
int tmr_id);
1897 int hal_timer_smem_capture_data_read(
int tmr_id, uint32_t *buffer,
int len);
1898 uint32_t hal_timer_smem_capture_get_data_num(
int tmr_id);
1950 int hal_timer_smem_emit_set_callback(
int tmr_id,
int prio,
void *arg,
void (*callback)(
void *parg, uint32_t sts));
1972 int hal_timer_smem_emit_rem(
int tmr_id);
1974 uint32_t hal_timer_smem_emit_update_tick(
int tmr_id, uint32_t *tick_buf, uint32_t buf_len);
1990 int hal_aon_timer_open(
int id,
int wup_en,
int reload,
int prio,
void *arg,
void (*isr_cb)(
void *arg));
2060 void hal_aon_timer_resume(
void);
2124 #endif // HAL_TIMER_H tmr_err
(Aon) Timer error code
Definition: hal_timer.h:153
int hal_aon_timer_start(int id, uint64_t time_us)
Start sleep timer.
emit_id
Timer Emit Id.
Definition: hal_timer.h:70
int hal_aon_timer_stop(int id)
Stop sleep timer.
int hal_timer_start_tick(int tim_id)
start timer profile function
int hal_timer_emit_add(int tmr_id, int idx, uint32_t tick, tmr_emit_option_t *option)
Add HW trigger to the timer's trigger list.
int hal_timer_smem_emit_add(int tmr_id, uint32_t *ticks, uint32_t size, uint16_t empty_threshold, tmr_emit_option_t *option)
Add HW trigger to the timer's trigger list.
uint32_t hal_timer_get_systick(void)
Return the OS tick.
cap_id
Timer Signal Capture Id.
Definition: hal_timer.h:61
int hal_timer_emit_rem(int tmr_id, int idx)
Remove HW trigger from the timer's trigger list.
int hal_timer_end_tick(int tim_id)
timer tick stop function.
tmr_id
Timer Id.
Definition: hal_timer.h:46
int hal_timer_busy(void)
Check if any timer is active.
int hal_timer_emit_set_callback(int tmr_id, int prio, void *arg, void(*callback)(void *parg, int emit_idx))
Set emit IRQ handler callback for the timer's emit.
int hal_aon_timer_open(int id, int wup_en, int reload, int prio, void *arg, void(*isr_cb)(void *arg))
Open sleep timer.
uint32_t hal_timer_get_tick(int tim_id)
timer get current tick function.
int hal_timer_capture_signal_rem(int tmr_id, int idx)
Remove HW signal from the timer's capture list.
int hal_timer_capture_signal_add(int tmr_id, int idx, uint8_t sig_id, int rise, int fall)
Add HW signal to the timer's capture list.
int hal_aon_timer_emit_rem(int emit_id)
Remove HW trigger from the AON timer2's trigger list.
uint64_t hal_aon_timer_get_time(int id)
Get the current sleep timer time in microsecond.
int hal_timer_set_tmo_callback(int tmr_id, int prio, void *arg, void(*tmr_cb)(void *))
rigster Timer timeout callback function
int hal_timer_delay_us(int tim_id, uint32_t usec)
timer delaye function
uint64_t hal_aon_timer_get_tick(int id)
Get the current sleep timer tick.
int hal_aon_timer_emit_add(int emit_id, int auto_clr, int touch_clr, uint32_t time_us, int prio, void *arg, void(*callback)(void *))
Add HW trigger to the AON timer2's trigger list.
int hal_aon_timer_capture_add(int cap_id, uint8_t sig_id, int rise, int fall, int prio, void *arg, void(*callback)(void *, int, uint32_t))
Add HW trigger to the AON timer2's trigger list.
int hal_aon_timer_close(int id)
Close sleep timer.
int hal_timer_start(int tmr_id, int reload, int manual, uint32_t tick)
Run Timer periodic function.
int hal_aon_timer_capture_rem(int cap_id)
Remove HW trigger from the AON timer2's trigger list.
int hal_timer_stop(int tim_id)
Stop Timer periodic function.