mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cpu/atmega_common: move clock init to common code
This code should not be in the realm of the board config, but in common arch code.
This commit is contained in:
parent
de768b5d23
commit
87f7e5a963
@ -20,20 +20,11 @@
|
||||
|
||||
#include "board.h"
|
||||
#include "cpu.h"
|
||||
#include "periph/gpio.h"
|
||||
|
||||
#ifndef CPU_ATMEGA_CLK_SCALE_INIT
|
||||
#define CPU_ATMEGA_CLK_SCALE_INIT CPU_ATMEGA_CLK_SCALE_DIV1
|
||||
#endif
|
||||
|
||||
void led_init(void);
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
/* disable usb interrupt */
|
||||
PRR1 |= 1<<PRUSB;
|
||||
|
||||
atmega_set_prescaler(CPU_ATMEGA_CLK_SCALE_INIT);
|
||||
avr8_stdio_init();
|
||||
cpu_init();
|
||||
led_init();
|
||||
|
@ -22,21 +22,10 @@
|
||||
#include "cpu.h"
|
||||
#include "periph/gpio.h"
|
||||
|
||||
#ifndef CPU_ATMEGA_CLK_SCALE_INIT
|
||||
#define CPU_ATMEGA_CLK_SCALE_INIT CPU_ATMEGA_CLK_SCALE_DIV1
|
||||
#endif
|
||||
|
||||
void led_init(void);
|
||||
|
||||
void __attribute__((weak)) board_init(void)
|
||||
{
|
||||
#ifdef CPU_ATMEGA32U4
|
||||
/* disable usb interrupt on Atmega32U4 */
|
||||
PRR1 |= 1<<PRUSB;
|
||||
#endif
|
||||
|
||||
atmega_set_prescaler(CPU_ATMEGA_CLK_SCALE_INIT);
|
||||
|
||||
cpu_init();
|
||||
#ifdef LED0_ON
|
||||
led_init();
|
||||
|
@ -28,12 +28,17 @@
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#include "board.h"
|
||||
#include "cpu.h"
|
||||
#include "panic.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
#ifndef CPU_ATMEGA_CLK_SCALE_INIT
|
||||
#define CPU_ATMEGA_CLK_SCALE_INIT CPU_ATMEGA_CLK_SCALE_DIV1
|
||||
#endif
|
||||
|
||||
extern uint8_t mcusr_mirror;
|
||||
extern uint8_t soft_rst;
|
||||
|
||||
@ -62,6 +67,11 @@ void avr8_reset_cause(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void __attribute__((weak)) avr8_clk_init(void)
|
||||
{
|
||||
atmega_set_prescaler(CPU_ATMEGA_CLK_SCALE_INIT);
|
||||
}
|
||||
|
||||
/* This is a vector which is aliased to __vector_default,
|
||||
* the vector executed when an ISR fires with no accompanying
|
||||
* ISR handler. This may be used along with the ISR() macro to
|
||||
|
@ -63,11 +63,6 @@ extern "C" {
|
||||
*/
|
||||
#define IRQ_API_INLINED (1)
|
||||
|
||||
/**
|
||||
* @brief This arch require special clock initialization.
|
||||
*/
|
||||
#define CPU_AVR8_HAS_CLOCK_INIT 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -31,9 +31,7 @@
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#include "cpu.h"
|
||||
#ifdef CPU_AVR8_HAS_CLOCK_INIT
|
||||
#include "cpu_clock.h"
|
||||
#endif
|
||||
#include "board.h"
|
||||
#include "irq.h"
|
||||
#include "periph/init.h"
|
||||
@ -91,14 +89,17 @@ void get_mcusr(void)
|
||||
|
||||
void cpu_init(void)
|
||||
{
|
||||
#ifdef PRUSB
|
||||
/* disable usb interrupt */
|
||||
PRR1 |= 1<<PRUSB;
|
||||
#endif
|
||||
|
||||
avr8_reset_cause();
|
||||
|
||||
wdt_reset(); /* should not be nececessary as done in bootloader */
|
||||
wdt_disable(); /* but when used without bootloader this is needed */
|
||||
|
||||
#ifdef CPU_AVR8_HAS_CLOCK_INIT
|
||||
avr8_clk_init();
|
||||
#endif
|
||||
|
||||
/* Initialize stdio before periph_init() to allow use of DEBUG() there */
|
||||
#ifdef MODULE_AVR_LIBC_EXTRA
|
||||
|
Loading…
Reference in New Issue
Block a user