Rev 537 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 537 | Rev 544 | ||
|---|---|---|---|
| Line 62... | Line 62... | ||
| 62 | 62 | ||
| 63 | /*----------------------------------------------------------------------------- |
63 | /*----------------------------------------------------------------------------- |
| 64 | * Public Functions |
64 | * Public Functions |
| 65 | *---------------------------------------------------------------------------*/ |
65 | *---------------------------------------------------------------------------*/ |
| 66 | 66 | ||
| 67 | void |
67 | void Timer_Init() |
| 68 | { |
68 | { |
| 69 | /* Do basic setup of the timer hw, including interrupts. */ |
69 | /* Do basic setup of the timer hw, including interrupts. */ |
| 70 | TIMER_INIT(); |
70 | TIMER_INIT(); |
| 71 | #if defined(TIMER_RELOAD) |
71 | #if defined(TIMER_RELOAD) |
| 72 | /* The hw timer does not support auto-reload so set the count manually. */ |
72 | /* The hw timer does not support auto-reload so set the count manually. */ |
| Line 80... | Line 80... | ||
| 80 | TIMER_SET_PRESCALER(); |
80 | TIMER_SET_PRESCALER(); |
| 81 | } |
81 | } |
| 82 | 82 | ||
| 83 | /*---------------------------------------------------------------------------*/ |
83 | /*---------------------------------------------------------------------------*/ |
| 84 | 84 | ||
| 85 | uint32_t |
85 | uint32_t Timer_GetTicks() |
| 86 | { |
86 | { |
| 87 | uint32_t res; |
87 | uint32_t res; |
| 88 | uint8_t sreg = SREG; |
88 | uint8_t sreg = SREG; |
| 89 | cli(); |
89 | cli(); |
| 90 | res = ticks; |
90 | res = ticks; |
| Line 92... | Line 92... | ||
| 92 | return res; |
92 | return res; |
| 93 | } |
93 | } |
| 94 | 94 | ||
| 95 | /*---------------------------------------------------------------------------*/ |
95 | /*---------------------------------------------------------------------------*/ |
| 96 | 96 | ||
| 97 | void |
97 | void Timer_SetTimeout(uint8_t timer, uint16_t timeout, uint8_t type, timerCallback_t callback) |
| 98 | { |
98 | { |
| 99 | if (timer<TIMER_NUM_TIMERS) |
99 | if (timer<TIMER_NUM_TIMERS) |
| 100 | { |
100 | { |
| 101 | uint8_t sreg = SREG; |
101 | uint8_t sreg = SREG; |
| 102 | cli(); |
102 | cli(); |
| Line 111... | Line 111... | ||
| 111 | } |
111 | } |
| 112 | } |
112 | } |
| 113 | 113 | ||
| 114 | /*---------------------------------------------------------------------------*/ |
114 | /*---------------------------------------------------------------------------*/ |
| 115 | 115 | ||
| 116 | uint8_t |
116 | uint8_t Timer_Expired(uint8_t timer) |
| 117 | { |
117 | { |
| 118 | if ((timer<TIMER_NUM_TIMERS) && (timers[timer].expired)) |
118 | if ((timer<TIMER_NUM_TIMERS) && (timers[timer].expired)) |
| 119 | { |
119 | { |
| 120 | timers[timer].expired = 0; |
120 | timers[timer].expired = 0; |
| 121 | return 1; |
121 | return 1; |