2017-02-02 20:01:11 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
|
|
|
|
* 2016 Laurent Navet <laurent.navet@gmail.com>
|
2017-02-15 21:28:10 +01:00
|
|
|
* 2017 HAW Hamburg, Dimitri Nahm
|
2017-02-02 20:01:11 +01:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2017-11-30 23:34:07 +01:00
|
|
|
* @ingroup boards_common_arduino-atmega
|
2017-02-02 20:01:11 +01:00
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
2017-04-18 11:18:26 +02:00
|
|
|
* @brief Common configuration of MCU periphery for Arduino Atmega boards
|
2017-02-02 20:01:11 +01:00
|
|
|
*
|
|
|
|
* @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
|
|
|
|
* @author Laurent Navet <laurent.navet@gmail.com>
|
|
|
|
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
2017-02-15 21:28:10 +01:00
|
|
|
* @author Dimitri Nahm <dimitri.nahm@haw-hamburg.de>
|
2017-02-02 20:01:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PERIPH_CONF_H
|
|
|
|
#define PERIPH_CONF_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2017-04-10 19:04:32 +02:00
|
|
|
* @name Clock configuration
|
2017-02-02 20:01:11 +01:00
|
|
|
* @{
|
|
|
|
*/
|
make: fix sign-compare errors
cpu, nrf5x_common: fix sign-compare in periph/flashpage
drivers, periph_common: fix sign-compare in flashpage
cpu, sam0_common: fix sign-compare error in periph/gpio
cpu, cc2538: fix sign-compare in periph/timer
cpu, sam3: fix sign-compare in periph/gpio
cpu, stm32_common: fix sign-compare in periph/pwm
cpu, stm32_common: fix sign-compare in periph/timer
cpu, stm32_common: fix sign-compare in periph/flashpage
cpu, nrf5x_common: fix sign-compare in radio/nrfmin
cpu, samd21: fix sign-compare in periph/pwm
cpu, ezr32wg: fix sign-compare in periph/gpio
cpu, ezr32wg: fix sign-compare in periph/timer
drivers, ethos: fix sign-compare
sys, net: fix sign-compare
cpu, atmega_common: fix sign-compare error
cpu, msp430fxyz: fix sign-compare in periph/gpio
boards, msb-430-common: fix sign-compare in board_init
driver, cc2420: fix sign-compared
sys/net: fix sign-compare in gnrc_tftp
driver, pcd8544: fix sign-compare
driver, pn532: fix sign-compare
driver, sdcard_spi: fix sign-compare
tests: fix sign_compare
sys/net, lwmac: fix sign_compare
pkg, lwip: fix sign-compare
boards, waspmote: make CORECLOCK unsigned long to fix sign_compare error
tests, sock_ip: fix sign compare
tests, msg_avail: fix sign compare
tests, sock_udp: fix sign compare
boards: fix sign-compare for calliope and microbit matrix
2017-10-31 11:57:40 +01:00
|
|
|
#define CLOCK_CORECLOCK (16000000UL)
|
2017-02-02 20:01:11 +01:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
2017-04-10 19:04:32 +02:00
|
|
|
* @name Timer configuration
|
2017-02-02 20:01:11 +01:00
|
|
|
*
|
|
|
|
* arduino uno and arduino duemilanove:
|
|
|
|
* The timer driver only supports the 16-bit timer (Timer1)
|
|
|
|
* so this is the only one we can use here.
|
|
|
|
*
|
|
|
|
* arduino mega2560:
|
|
|
|
* The timer driver only supports the four 16-bit timers (Timer1, Timer3,
|
|
|
|
* Timer4, Timer5), so those are the only onces we can use here.
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#ifdef CPU_ATMEGA328P
|
|
|
|
#define TIMER_NUMOF (2U)
|
|
|
|
|
|
|
|
#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
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CPU_ATMEGA2560
|
|
|
|
#define TIMER_NUMOF (2U)
|
|
|
|
|
|
|
|
#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
|
|
|
|
#define TIMER_0_ISRC TIMER1_COMPC_vect
|
|
|
|
|
|
|
|
#define TIMER_1 MEGA_TIMER4
|
|
|
|
#define TIMER_1_MASK &TIMSK4
|
|
|
|
#define TIMER_1_FLAG &TIFR4
|
|
|
|
#define TIMER_1_ISRA TIMER4_COMPA_vect
|
|
|
|
#define TIMER_1_ISRB TIMER4_COMPB_vect
|
|
|
|
#define TIMER_1_ISRC TIMER4_COMPC_vect
|
|
|
|
#endif
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
2017-04-10 19:04:32 +02:00
|
|
|
* @name UART configuration
|
2017-02-02 20:01:11 +01:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#ifdef CPU_ATMEGA328P
|
|
|
|
#define UART_NUMOF (1U)
|
|
|
|
|
|
|
|
#define UART_0 MEGA_UART0
|
|
|
|
#define UART_0_ISR USART_RX_vect
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CPU_ATMEGA2560
|
|
|
|
#define UART_NUMOF (4U)
|
|
|
|
|
|
|
|
#define UART_0 MEGA_UART0
|
|
|
|
#define UART_0_ISR USART0_RX_vect
|
|
|
|
|
|
|
|
#define UART_1 MEGA_UART1
|
|
|
|
#define UART_1_ISR USART1_RX_vect
|
|
|
|
|
|
|
|
#define UART_2 MEGA_UART2
|
|
|
|
#define UART_2_ISR USART2_RX_vect
|
|
|
|
|
|
|
|
#define UART_3 MEGA_UART3
|
|
|
|
#define UART_3_ISR USART3_RX_vect
|
|
|
|
#endif
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
2017-04-10 19:04:32 +02:00
|
|
|
* @name SPI configuration
|
2017-02-02 20:01:11 +01:00
|
|
|
*
|
2017-06-21 16:10:24 +02:00
|
|
|
* The atmega2560/atmega1281/atmega328p has only one hardware SPI with fixed pin
|
|
|
|
* configuration, so all we can do here, is to enable or disable it...
|
2017-02-02 20:01:11 +01:00
|
|
|
*
|
2017-06-21 16:10:24 +02:00
|
|
|
* The fixed pins for arduino uno and duemilanove (atmega328p) are:
|
2017-02-02 20:01:11 +01:00
|
|
|
* MOSI - PB3 (Arduino pin 11)
|
|
|
|
* MISO - PB4 (Arduino pin 12)
|
|
|
|
* SCK - PB5 (Arduino pin 13)
|
|
|
|
* SS - PB2 (Arduino pin 10) -> this pin is configured as output, but not used
|
|
|
|
*
|
2017-06-21 16:10:24 +02:00
|
|
|
* The fixed pins for arduino-mega2560 and atmega1281 are:
|
2017-02-02 20:01:11 +01:00
|
|
|
* MOSI - PB2 (Arduino pin 51)
|
|
|
|
* MISO - PB3 (Arduino pin 50)
|
|
|
|
* SCK - PB1 (Arduino pin 52)
|
|
|
|
* SS - PB0 (Arduino pin 53) -> this pin is configured as output, but not used
|
|
|
|
*
|
2017-06-21 16:10:24 +02:00
|
|
|
* The SS pin must be configured as output for the SPI device to work as
|
|
|
|
* master correctly, though we do not use it for now (as we handle the chip
|
|
|
|
* select externally for now)
|
|
|
|
*
|
2017-02-02 20:01:11 +01:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#define SPI_NUMOF 1 /* set to 0 to disable SPI */
|
|
|
|
/** @} */
|
|
|
|
|
2017-06-21 09:15:49 +02:00
|
|
|
/**
|
2017-02-15 21:28:10 +01:00
|
|
|
* @name I2C configuration
|
|
|
|
* @{
|
2017-06-21 09:15:49 +02:00
|
|
|
*/
|
2018-07-03 11:04:16 +02:00
|
|
|
#define I2C_BUS_SPEED I2C_SPEED_FAST
|
2017-06-21 09:15:49 +02:00
|
|
|
#define I2C_NUMOF 1
|
2017-02-15 21:28:10 +01:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name ADC configuration
|
|
|
|
*
|
|
|
|
* The number of ADC channels of the atmega328p depends on the package:
|
|
|
|
* - 6-channel 10-bit ADC in PDIP package
|
|
|
|
* - 8-channel 10-bit ADC in TQFP and QFN/MLF package
|
|
|
|
* Arduino UNO / Duemilanove has thereby 6 channels. But only 5 channels can be
|
|
|
|
* used for ADC, because the pin of ADC5 emulate a software triggered interrupt.
|
|
|
|
* -> boards -> arduino-atmega-common -> include -> board_common.h
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#if defined (CPU_ATMEGA328P) || defined (CPU_ATMEGA1281)
|
|
|
|
#define ADC_NUMOF (8U)
|
|
|
|
#elif defined (CPU_ATMEGA2560)
|
|
|
|
#define ADC_NUMOF (16U)
|
|
|
|
#endif
|
|
|
|
/** @} */
|
2017-06-21 09:15:49 +02:00
|
|
|
|
2017-02-02 20:01:11 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* PERIPH_CONF_H */
|