Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions boards/common/inga/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MODULE = boards_common_inga

include $(RIOTBASE)/Makefile.base
13 changes: 13 additions & 0 deletions boards/common/inga/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_gpio
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_i2c

#FEATURES_PROVIDED += adxl345

# The board MPU family (used for grouping by the CI system)
FEATURES_MCU_GROUP = avr8

include $(RIOTCPU)/atmega1284p/Makefile.features
11 changes: 11 additions & 0 deletions boards/common/inga/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## the cpu to build for
export CPU = atmega1284p

# flash tool configuration
export OFLAGS = -j .text -j .data -O ihex

# set default port depending on operating system
PORT_LINUX ?= $(firstword $(sort $(wildcard /dev/ttyUSB*)))
# setup serial terminal
export BAUD ?= 19200
include $(RIOTMAKE)/tools/serial.inc.mk
77 changes: 77 additions & 0 deletions boards/common/inga/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (C) 2017 Robert Hartung <hartung@ibr.cs.tu-bs.de>
*
* 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_inga_common
* @{
*
* @file
* @brief Common implementations for the INGA boards
*
* @author Robert Hartung <hartung@ibr.cs.tu-bs.de>
*
* @}
*/

#include "cpu.h"
#include "board.h"
#include "uart_stdio.h"
#include "avr/io.h"

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);

/**
* @brief Initialize the system, initialize the button
*/
void board_init(void)
{
/* initialize the CPU */
cpu_init();

/* initialize STDIO over UART */
uart_stdio_init();
stdout = &uart_stdout;
stdin = &uart_stdin;
puts("\f");

/* Disable JTAG to be able to use PCINTs on PD5, PD6, PD7 */
MCUCR=(1<<JTD);

/* Button */
#ifdef BTN0_PIN
gpio_init(BTN0_PIN, GPIO_IN);
#endif

#ifdef LED1_PIN
gpio_init(LED1_PIN, GPIO_OUT);
#endif
#ifdef LED2_PIN
gpio_init(LED2_PIN, GPIO_OUT);
#endif

irq_enable();
}

static int uart_putchar(char c, FILE *stream)
{
(void) stream;
uart_stdio_write(&c, 1);
return 0;
}

static int uart_getchar(FILE *stream)
{
(void) stream;
char c;
uart_stdio_read(&c, 1);
return (int)c;
}
73 changes: 73 additions & 0 deletions boards/common/inga/include/board_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (C) 2017 Robert Hartung <hartung@ibr.cs.tu-bs.de>
*
* 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_inga_common
* @{
*
* @file
* @brief Common board definitions for the INGA boards
*
* @author Robert Hartung <hartung@ibr.cs.tu-bs.de>
*
* @}
*/

#ifndef INGA_COMMON_BOARD_COMMON_H_
#define INGA_COMMON_BOARD_COMMON_H_

#ifdef __cplusplus
extern "C" {
#endif

#ifndef UART_STDIO_BAUDRATE
#define UART_STDIO_BAUDRATE (19200)
#endif

/**
* Context swap defines
* Setup to use PA0 which is pin change interrupt 0 (PCINT0)
* This emulates a software triggered interrupt
*/
#define AVR_CONTEXT_SWAP_INIT do { \
DDRA |= (1 << DDA0); \
PCICR |= (1 << PCIE0); \
PCMSK0 |= (1 << PCINT0); \
} while (0)
#define AVR_CONTEXT_SWAP_INTERRUPT_VECT PCINT0_vect
#define AVR_CONTEXT_SWAP_INTERRUPT_VECT_NUM PCINT0_vect_num
#define AVR_CONTEXT_SWAP_TRIGGER PORTA ^= (1 << PA0)

/**
* @name at86rf233 configuration
* @{
*/
#define AT86RF2XX_PARAMS_BOARD {.spi = SPI_DEV(0), \
.spi_clk = SPI_CLK_5MHZ, \
.cs_pin = GPIO_PIN(PORT_B, 4),\
.int_pin = GPIO_PIN(PORT_D, 6),\
.sleep_pin = GPIO_PIN(PORT_B, 3),\
.reset_pin = GPIO_PIN(PORT_B, 1)}
/** @} */

/**
* @name xtimer configuration values
* @{
*/
#define XTIMER_WIDTH (16)
#define XTIMER_BACKOFF (40)
#define XTIMER_DEV (0)
#define XTIMER_CHAN (0)
/** @} */

#ifdef __cplusplus
}
#endif

/** @} */
#endif /* INGA_COMMON_BOARD_COMMON_H_ */
105 changes: 105 additions & 0 deletions boards/common/inga/include/periph_conf_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright (C) 2016 Robert Hartung <hartung@ibr.cs.tu-bs.de>
*
* 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.
*/

#ifndef INGA_COMMON_PERIPH_CONF_COMMON_H_
#define INGA_COMMON_PERIPH_CONF_COMMON_H_

#ifdef __cplusplus
extern "C" {
#endif


/**
* @brief Clock configuration
* @{
*/
#define CLOCK_CORECLOCK (8000000UL)
/** @} */

/**
* @brief Timer configuration
*
* The timer driver only supports the four 16-bit timers (Timer1, Timer3,
* Timer4, Timer5), so those are the only onces we can use here.
*
* @{
*/
#define TIMER_NUMOF (1U)

#define TIMER_0 MEGA_TIMER1
#define TIMER_0_MASK &TIMSK1
#define TIMER_0_FLAG &TIFR1
#define TIMER_0_ISRA TIMER1_COMPA_vect
#define TIMER_0_ISRB TIMER1_COMPB_vect
/** @} */

/**
* @brief UART configuration
*
* The UART devices have fixed pin mappings, so all we need to do, is to specify
* which devices we would like to use and their corresponding RX interrupts. See
* the reference manual for the fixed pin mapping.
*
* @{
*/
#define UART_NUMOF (1U)

#define UART_0 MEGA_UART0
#define UART_0_ISR USART0_RX_vect
/** @} */

/**
* The INGA has exactly 1 I2C interface
* @{
*/
#define I2C_NUMOF (1U)

#define I2C_0_EN (1)
#define I2C_0_SCL GPIO_PIN(PORT_C, 0)
#define I2C_0_SDA GPIO_PIN(PORT_C, 1)
/** @} */

/**
* INGA ADXL345 configuration
* @{
*/
#define ADXL345_PARAM_ADDR ADXL345_ADDR_53 /* (0xA6>>1) */
#define ADXL345_PARAM_I2C (0)
#define ADXL345_PARAMS { .offset = ADXL345_PARAM_OFFSET, \
.range = ADXL345_RANGE_2G, \
.rate = ADXL345_RATE_100HZ, \
.full_res = ADXL345_PARAM_FULL_RES }
/** @} */

/**
* Pin Change Interrupt configuration
* @{
*/
#define AVR_USE_PCINT (1)
/** @} */

/**
* INGA L3G4200D adress
* @{
*/
#define L3G4200D_PARAM_ADDR (0x69) /* 0xD2>>1 */
/** @} */

/**
* The INGA has exactly 1 SPI interface
* @{
*/
#define SPI_NUMOF (1U)
/** @} */

#ifdef __cplusplus
}
#endif

/** @} */
#endif /* INGA_COMMON_PERIPH_CONF_COMMON_H_ */
3 changes: 3 additions & 0 deletions boards/inga_blue/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MODULE = board
DIRS = $(RIOTBOARD)/common/inga
include $(RIOTBASE)/Makefile.base
3 changes: 3 additions & 0 deletions boards/inga_blue/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ifneq (,$(filter netdev_default gnrc_netdev_default,$(USEMODULE)))
USEMODULE += at86rf233
endif
2 changes: 2 additions & 0 deletions boards/inga_blue/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include $(RIOTBOARD)/common/inga/Makefile.features
FEATURES_PROVIDED += periph_rtt
12 changes: 12 additions & 0 deletions boards/inga_blue/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
USEMODULE += boards_common_inga

export FLASHER = avrdude
# JTAG ICE mkII
export FFLAGS = -c jtag2isp -p m1284p -P usb -u -U flash:w:$(HEXFILE)

export INCLUDES += -I$(RIOTBOARD)/common/inga/include/

# setup the boards dependencies
include $(RIOTBOARD)/$(BOARD)/Makefile.dep

include $(RIOTBOARD)/common/inga/Makefile.include
28 changes: 28 additions & 0 deletions boards/inga_blue/include/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2016 Robert Hartung <hartung@ibr.cs.tu-bs.de>
*
* 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.
*/

#ifndef INGA_COMMON_BOARD_H_
#define INGA_COMMON_BOARD_H_

#include "cpu.h"
#include "periph_conf.h"
#include "periph/gpio.h"
#include "board_common.h"

#ifdef __cplusplus
extern "C" {
#endif

/* the blue inga does not have any LEDs or buttons */

#ifdef __cplusplus
}
#endif

/** @} */
#endif /* INGA_COMMON_BOARD_H_ */
36 changes: 36 additions & 0 deletions boards/inga_blue/include/periph_conf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (C) 2017 TU Braunschweig, IBR
*
* 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_inga_red
* @{
*
* @file
* @brief Peripheral MCU configuration for the INGA red board
*
* @author Robert Hartung <hartung@ibr.cs.tu-bs.de>
*/

#ifndef PERIPH_CONF_H_
#define PERIPH_CONF_H_

#include "periph_conf_common.h"

#ifdef __cplusplus
extern "C" {
#endif

#define RTT_NUMOF 1
#define RTT_FREQUENCY (32)
#define RTT_MAX_VALUE (0xFF)

#ifdef __cplusplus
}
#endif

#endif /* PERIPH_CONF_H_ */
3 changes: 3 additions & 0 deletions boards/inga_green/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MODULE = board
DIRS = $(RIOTBOARD)/common/inga
include $(RIOTBASE)/Makefile.base
3 changes: 3 additions & 0 deletions boards/inga_green/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ifneq (,$(filter netdev_default gnrc_netdev_default,$(USEMODULE)))
USEMODULE += at86rf231
endif
1 change: 1 addition & 0 deletions boards/inga_green/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(RIOTBOARD)/common/inga/Makefile.features
11 changes: 11 additions & 0 deletions boards/inga_green/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
USEMODULE += boards_common_inga

# inga_tool for flashing
include $(RIOTMAKE)/tools/inga_tool.inc.mk

export INCLUDES += -I$(RIOTBOARD)/common/inga/include/

# setup the boards dependencies
include $(RIOTBOARD)/$(BOARD)/Makefile.dep

include $(RIOTBOARD)/common/inga/Makefile.include
Loading