mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
boards/common/arduino-atmega: use common/atmega shared code
This commit is contained in:
parent
ae8822ff46
commit
60a55eb06d
@ -1,3 +1,5 @@
|
||||
MODULE = boards_common_arduino-atmega
|
||||
|
||||
DIRS = $(RIOTBOARD)/common/atmega
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
|
@ -1,3 +1,5 @@
|
||||
USEMODULE += boards_common_atmega
|
||||
|
||||
ifneq (,$(filter saul_default,$(USEMODULE)))
|
||||
USEMODULE += saul_gpio
|
||||
endif
|
||||
|
@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
|
||||
* 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* 2016 Laurent Navet <laurent.navet@gmail.com>
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup boards_common_arduino-atmega
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Common implementations for Arduino Atmega boards
|
||||
*
|
||||
* @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* @author Laurent Navet <laurent.navet@gmail.com>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
#include "board.h"
|
||||
#include "cpu.h"
|
||||
#include "uart_stdio.h"
|
||||
#include "periph/gpio.h"
|
||||
|
||||
void led_init(void);
|
||||
void SystemInit(void);
|
||||
static int uart_putchar(char c, FILE *stream);
|
||||
static int uart_getchar(FILE *stream);
|
||||
|
||||
static FILE uart_stdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE);
|
||||
static FILE uart_stdin = FDEV_SETUP_STREAM(NULL, uart_getchar, _FDEV_SETUP_READ);
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
/* initialize stdio via USART_0 */
|
||||
SystemInit();
|
||||
|
||||
/* initialize the CPU */
|
||||
cpu_init();
|
||||
|
||||
/* initialize the board LED */
|
||||
gpio_init(LED0_PIN, GPIO_OUT);
|
||||
LED0_OFF;
|
||||
|
||||
irq_enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the System, initialize IO via UART_0
|
||||
*/
|
||||
void SystemInit(void)
|
||||
{
|
||||
/* initialize UART_0 for use as stdout */
|
||||
uart_stdio_init();
|
||||
|
||||
stdout = &uart_stdout;
|
||||
stdin = &uart_stdin;
|
||||
|
||||
/* Flush stdout */
|
||||
puts("\f");
|
||||
}
|
||||
|
||||
static int uart_putchar(char c, FILE *stream)
|
||||
{
|
||||
(void) stream;
|
||||
uart_stdio_write(&c, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uart_getchar(FILE *stream)
|
||||
{
|
||||
(void) stream;
|
||||
char c;
|
||||
uart_stdio_read(&c, 1);
|
||||
return (int)c;
|
||||
}
|
34
boards/common/arduino-atmega/led_init.c
Normal file
34
boards/common/arduino-atmega/led_init.c
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
|
||||
* 2015-18 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* 2016 Laurent Navet <laurent.navet@gmail.com>
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup boards_common_arduino-atmega
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Common led initialization for Arduino Atmega boards
|
||||
*
|
||||
* @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* @author Laurent Navet <laurent.navet@gmail.com>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "cpu.h"
|
||||
#include "periph/gpio.h"
|
||||
|
||||
void led_init(void)
|
||||
{
|
||||
/* initialize the on-board LED */
|
||||
gpio_init(LED0_PIN, GPIO_OUT);
|
||||
LED0_OFF;
|
||||
}
|
Loading…
Reference in New Issue
Block a user