Naze32 clone with Frysky receiver
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

timer.c 488B

1234567891011121314151617181920212223242526
  1. /*
  2. * Time-Keeping helper
  3. */
  4. #include <avr/io.h>
  5. #include <avr/interrupt.h>
  6. #include "timer.h"
  7. volatile time_t systemTime = 0;
  8. void timerInit(void) {
  9. TCCR1 |= (1 << CTC1); // CTC Mode
  10. TCCR1 |= (1 << CS12) | (1 << CS11) | (1 << CS10); // Prescaler: 64
  11. OCR1A = 250; // Count to 250
  12. TIMSK |= (1 << OCIE1A); // Enable compare match interrupt
  13. }
  14. ISR(TIMER1_COMPA_vect) {
  15. systemTime++; // one millisecond has passed
  16. }
  17. time_t timerGet(void) {
  18. return systemTime;
  19. }