Rev 2124 | Rev 2132 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2124 | Rev 2125 | ||
---|---|---|---|
Line 7... | Line 7... | ||
7 | 7 | ||
8 | #include "timer0.h" |
8 | #include "timer0.h" |
Line 9... | Line 9... | ||
9 | #include "output.h" |
9 | #include "output.h" |
- | 10 | ||
10 | 11 | #ifdef DO_PROFILE |
|
11 | #ifdef DO_PROFILE |
12 | volatile uint32_t global10kHzClock = 0; |
12 | uint32_t profileTimers[NUM_PROFILE_TIMERS]; |
13 | volatile int32_t profileTimers[NUM_PROFILE_TIMERS]; |
Line 13... | Line 14... | ||
13 | uint32_t runningProfileTimers[NUM_PROFILE_TIMERS]; |
14 | volatile int32_t runningProfileTimers[NUM_PROFILE_TIMERS]; |
14 | #endif |
15 | #endif |
15 | 16 | ||
Line 85... | Line 86... | ||
85 | /*****************************************************/ |
86 | /*****************************************************/ |
86 | ISR(TIMER0_OVF_vect) { // 9765.625 Hz |
87 | ISR(TIMER0_OVF_vect) { // 9765.625 Hz |
87 | static uint8_t cnt_1ms = 1, cnt = 0; |
88 | static uint8_t cnt_1ms = 1, cnt = 0; |
88 | uint8_t beeperOn = 0; |
89 | uint8_t beeperOn = 0; |
Line -... | Line 90... | ||
- | 90 | ||
- | 91 | #ifdef DO_PROFILE |
|
- | 92 | global10kHzClock++; |
|
- | 93 | #endif |
|
89 | 94 | ||
90 | if (!cnt--) { // every 10th run (9.765625kHz/10 = 976.5625Hz) |
95 | if (!cnt--) { // every 10th run (9.765625kHz/10 = 976.5625Hz) |
91 | cnt = 9; |
96 | cnt = 9; |
92 | cnt_1ms ^= 1; |
97 | cnt_1ms ^= 1; |
93 | if (!cnt_1ms) { |
98 | if (!cnt_1ms) { |
94 | runFlightControl = 1; // every 2nd run (976.5625 Hz/2 = 488.28125 Hz) |
99 | runFlightControl = 1; // every 2nd run (976.5625 Hz/2 = 488.28125 Hz) |
Line 164... | Line 169... | ||
164 | } |
169 | } |
165 | } |
170 | } |
Line 166... | Line 171... | ||
166 | 171 | ||
167 | #ifdef DO_PROFILE |
172 | #ifdef DO_PROFILE |
168 | void startProfileTimer(uint8_t timer) { |
173 | void startProfileTimer(uint8_t timer) { |
169 | runningProfileTimers[timer] = globalMillisClock; |
174 | runningProfileTimers[timer] = global10kHzClock++; |
Line 170... | Line 175... | ||
170 | } |
175 | } |
171 | 176 | ||
172 | void stopProfileTimer(uint8_t timer) { |
177 | void stopProfileTimer(uint8_t timer) { |
173 | int32_t t = globalMillisClock - runningProfileTimers[timer]; |
178 | int32_t t = global10kHzClock++ - runningProfileTimers[timer]; |
Line 174... | Line 179... | ||
174 | profileTimers[timer] += t; |
179 | profileTimers[timer] += t; |
175 | } |
180 | } |
176 | 181 | ||
177 | void debugProfileTimers(uint8_t index) { |
182 | void debugProfileTimers(uint8_t index) { |
178 | for (uint8_t i=0; i<NUM_PROFILE_TIMERS; i++) { |
183 | for (uint8_t i=0; i<NUM_PROFILE_TIMERS; i++) { |
179 | uint16_t tenths = profileTimers[i] / 10000L; |
184 | uint16_t tenths = profileTimers[i] / 1000L; |
180 | debugOut.analog[i+index] = tenths; |
185 | debugOut.analog[i+index] = tenths; |
181 | } |
186 | } |
182 | uint16_t tenths = globalMillisClock / 10000L; |
187 | uint16_t tenths = global10kHzClock / 1000L; |