5 #ifdef PCD_TIMER_USE_PIT
7 static void PCD_TIMER_ISR(pointer p
)
9 _pcd_clear_int(PCD_TIMER_INT
);
12 /* Enable PIT interrupt neeed due to errata on Kinetis PIT */
13 _pcd_timer_unmask_int(PCD_TIMER_INT
);
16 static void pcd_timer_init(void)
18 if(_int_install_isr(PCD_TIMER_INT
, PCD_TIMER_ISR
, NULL
) == NULL
) {
21 _bsp_int_init(AUDIO_INT
, 2, 0, TRUE
);
25 void Delay1us(uint32_t delay
)
27 #ifdef PCD_TIMER_USE_PIT
28 uint32_t savedTime
= PIT_CVAL(TIMER_FOR_PCD
);
29 uint32_t currentTime
= savedTime
;
30 uint32_t endTime
= savedTime
+ (delay
* (PCD_TIMER_FREQUENCY
/ 1000000));
32 while (currentTime
<= savedTime
){
33 savedTime
= currentTime
;
34 currentTime
= PIT_CVAL(TIMER_FOR_PCD
);
37 while ((currentTime
> endTime
) && (currentTime
<= savedTime
)) {
38 savedTime
= currentTime
;
39 currentTime
= PIT_CVAL(TIMER_FOR_PCD
);
43 MQX_TICK_STRUCT cur_tick
,last_tick
;
44 _time_get_elapsed_ticks_fast(&cur_tick
);
47 _time_get_elapsed_ticks_fast(&last_tick
);
48 } while( _time_diff_milliseconds(&last_tick
,&cur_tick
,&ovfl
) >= delay
);
53 void Delay256us(uint8_t delay
)
59 for(i
= 0; i
< 134; i
++);
63 void Delay256P2us(uint8_t delay
)
67 for(i
= 0; i
< delay
; i
++) {
73 void Delay256P3us(uint8_t delay
)
77 for(i
= 0; i
< delay
; i
++)
84 void Delay1ms(uint32 delay
)
86 OS_Time_delay(delay
+ 2);
89 void Delay1s(uint8_t delay
)
92 for(i
= 0; i
< delay
; i
++) {
97 void SetTimer100us(uint16_t timeOut
)
99 set_pn51x_timer(timeOut
);