]> cloudbase.mooo.com Git - z180-stamp.git/commitdiff
move sys timer setup from main to timer.c
authorLeo C <erbl259-lmu@yahoo.de>
Sat, 8 Sep 2018 18:29:11 +0000 (20:29 +0200)
committerLeo C <erbl259-lmu@yahoo.de>
Sat, 8 Sep 2018 18:29:11 +0000 (20:29 +0200)
avr/main.c
avr/timer.c
include/timer.h

index 1fba3cbfcea8031a6b16e034f800aa6f5b44eec4..0a49a1fb7cd901283be6eb9ba01f902cab73a440 100644 (file)
@@ -110,7 +110,7 @@ void setup_avr(void)
                _BV(PRUSART3) | _BV(PRUSART2) | _BV(PRUSART1);
 
 
-       /* disable analog comparator */
+       /* Disable analog comparator */
        ACSR = _BV(ACD);
        /* Ports */
 
@@ -118,11 +118,8 @@ void setup_avr(void)
        CLKPR = _BV(CLKPCE);
        CLKPR = 0;
 
-       /* Timer */
-       PRR1 &= ~_BV(PRTIM4);
-       OCR4A = F_CPU / 1000 - 1;       /* Timer4: 1000Hz interval */
-       TCCR4B = (0b00<<WGM42)|(0b001<<CS40); /* Normal Mode, Prescaler 1 */
-       TIMSK4 = _BV(OCIE4A);           /* Enable Output Compare A interrupt */
+       /* System timer */
+       setup_timer();
 
        /* INT5, INT6: falling edge */
        EICRB = (EICRB & ~((0b11 << ISC50) | (0b11 << ISC60))) |
index 1b1598540f82090c3dbe56e7610e33280342734e..03c86c82235053196418980ff6fb818a7206dada 100644 (file)
@@ -47,6 +47,15 @@ ISR(TIMER4_COMPA_vect)
        tick_10ms = i;
 }
 
+/*--------------------------------------------------------------------------*/
+
+void setup_timer(void)
+{
+       PRR1 &= ~_BV(PRTIM4);
+       OCR4A = F_CPU / 1000 - 1;       /* Timer4: 1000Hz interval */
+       TCCR4B = (0b00<<WGM42)|(0b001<<CS40); /* Normal Mode, Prescaler 1 */
+       TIMSK4 = _BV(OCIE4A);           /* Enable Output Compare A interrupt */
+}
 
 /*--------------------------------------------------------------------------*/
 
index 83bc3298ed834eb6ef8caf4c1a582f5f2b358c5a..d6040087b8501d6eed6bff6137cddd084c61c67a 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ * (C) Copyright 2014,2018 Leo C. <erbl259-lmu@yahoo.de>
  *
- * SPDX-License-Identifier:    GPL-2.0+
+ * SPDX-License-Identifier:    GPL-2.0
  */
 
 #ifndef TIMER_H
@@ -9,6 +9,8 @@
 
 #include "common.h"
 
+void setup_timer(void);
+
 uint32_t get_timer(uint32_t);
 
 #endif /* TIMER_H */