12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
-
- #include <stdlib.h>
- #include <stdint.h>
- #include <avr/io.h>
- #include <avr/interrupt.h>
- #include "time.h"
-
-
-
-
-
-
-
- volatile uint64_t systemTime = 0;
- volatile uint8_t isrCounter = 0;
-
- void initSystemTimer() {
- TCCR0 |= (1 << WGM01) | (1 << CS02);
- OCR0 = 208;
- TIMSK |= (1 << TOIE0);
- }
-
- ISR(TIMER0_OVF_vect) {
- if (isrCounter >= 2) {
- isrCounter = 0;
- systemTime++;
- } else {
- isrCounter++;
- }
- }
-
- uint64_t getSystemTime() {
- return systemTime;
- }
|