_BV(PRUSART3) | _BV(PRUSART2) | _BV(PRUSART1);
- /* disable analog comparator */
+ /* Disable analog comparator */
ACSR = _BV(ACD);
/* Ports */
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))) |
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 */
+}
/*--------------------------------------------------------------------------*/
/*
- * (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
#include "common.h"
+void setup_timer(void);
+
uint32_t get_timer(uint32_t);
#endif /* TIMER_H */