summaryrefslogtreecommitdiffstats
path: root/aliznayem/get_millis.c
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-02-09 17:55:18 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-02-09 17:55:18 +0800
commit27a890cdf09df58c624047927cb97fbe97728c9c (patch)
treef6b5da78ac54183d3dc726ed6f1adc73fcd0cc48 /aliznayem/get_millis.c
parent2d2310b58c34c13212568a2d01c3af7b03c91c48 (diff)
downloadsmart-home-27a890cdf09df58c624047927cb97fbe97728c9c.tar.gz
wip.
Diffstat (limited to 'aliznayem/get_millis.c')
-rw-r--r--aliznayem/get_millis.c45
1 files changed, 0 insertions, 45 deletions
diff --git a/aliznayem/get_millis.c b/aliznayem/get_millis.c
deleted file mode 100644
index c3a7cbd..0000000
--- a/aliznayem/get_millis.c
+++ /dev/null
@@ -1,45 +0,0 @@
-// Source: https://gist.github.com/adnbr/2439125#file-counting-millis-c
-
-#include "get_millis.h"
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <util/atomic.h>
-
-volatile unsigned long timer1_millis;
-
-void millis_init()
-{
- // CTC mode, Clock/8
- TCCR1B |= (1 << WGM12) | (1 << CS11);
-
- // Load the high byte, then the low byte
- // into the output compare
- OCR1AH = (CTC_MATCH_OVERFLOW >> 8);
- OCR1AL = CTC_MATCH_OVERFLOW;
- sei();
-
- // Enable the compare match interrupt
- #if defined (__AVR_ATmega328__) || defined (__AVR_ATmega328P__)
- TIMSK1 |= (1 << OCIE1A);
- #elif defined (__AVR_ATmega64__)
- TIMSK |= (1 << OCIE1A);
- #elif defined (__AVR_ATtiny84A__)
- TIMSK1 |= (1 << OCIE1A);
- #endif
-}
-
-unsigned long millis()
-{
- unsigned long millis_return;
- // ensure this cannnot be disrupted
- ATOMIC_BLOCK(ATOMIC_FORCEON)
- {
- millis_return = timer1_millis;
- }
- return millis_return;
-}
-
-ISR (TIMER1_COMPA_vect)
-{
- timer1_millis++;
-}