From: lottaviano Date: Thu, 23 Dec 2010 18:50:44 +0000 (+0000) Subject: Add support for ATmega2560. X-Git-Tag: 2.7.0~311 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=111bf6c8f1d9ef14df24586fa67500fdc997163c;p=bertos.git Add support for ATmega2560. Signed-off-by: Brian Fiegel Reviewed-by: Luca Ottaviano git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4655 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cpu/attr.h b/bertos/cpu/attr.h index 8b1fa4c7..c8090f95 100644 --- a/bertos/cpu/attr.h +++ b/bertos/cpu/attr.h @@ -239,7 +239,7 @@ #define CPU_RAM_START 0x60 #elif CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P #define CPU_RAM_START 0x100 - #elif CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 + #elif CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA2560 #define CPU_RAM_START 0x200 #else #warning Fix CPU_RAM_START address for your AVR, default value set to 0x100 diff --git a/bertos/cpu/avr/drv/adc_avr.c b/bertos/cpu/avr/drv/adc_avr.c index c42f8e3b..51c81cac 100644 --- a/bertos/cpu/avr/drv/adc_avr.c +++ b/bertos/cpu/avr/drv/adc_avr.c @@ -102,9 +102,9 @@ void adc_hw_select_ch(uint8_t ch) #if CPU_AVR_ATMEGA8 || CPU_AVR_ATMEGA328P || CPU_AVR_ATMEGA168 ADMUX &= ~(BV(MUX3) | BV(MUX2) | BV(MUX1) | BV(MUX0)); #elif CPU_AVR_ATMEGA32 || CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA1281 \ - || CPU_AVR_ATMEGA1280 + || CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA2560 ADMUX &= ~(BV(MUX4) | BV(MUX3) | BV(MUX2) | BV(MUX1) | BV(MUX0)); - #if CPU_AVR_ATMEGA1280 + #if CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA2560 ADCSRB &= ~(BV(MUX5)); #endif #else @@ -114,7 +114,7 @@ void adc_hw_select_ch(uint8_t ch) /* Select channel, only first 8 channel modes are supported */ ADMUX |= (ch & 0x07); - #if CPU_AVR_ATMEGA1280 + #if CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA2560 /* Select channel, all 16 channels are supported */ if (ch > 0x07) ADCSRB |= BV(MUX5); diff --git a/bertos/cpu/avr/drv/adc_avr.h b/bertos/cpu/avr/drv/adc_avr.h index c42cf324..6c77ca3d 100644 --- a/bertos/cpu/avr/drv/adc_avr.h +++ b/bertos/cpu/avr/drv/adc_avr.h @@ -39,7 +39,7 @@ #include -#if CPU_AVR_ATMEGA1280 +#if CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA2560 /* 16 channels aivailable */ #define ADC_MUX_MAXCH 15 #else diff --git a/bertos/cpu/avr/drv/i2c_avr.c b/bertos/cpu/avr/drv/i2c_avr.c index 918d2758..eb8b8da9 100644 --- a/bertos/cpu/avr/drv/i2c_avr.c +++ b/bertos/cpu/avr/drv/i2c_avr.c @@ -384,7 +384,7 @@ void i2c_hw_init(I2c *i2c, int dev, uint32_t clock) * probably due to some unwanted interaction between the * port pin and the TWI lines. */ - #if CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 + #if CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA2560 PORTD |= BV(PD0) | BV(PD1); DDRD |= BV(PD0) | BV(PD1); #elif CPU_AVR_ATMEGA8 diff --git a/bertos/cpu/avr/drv/kdebug_avr.c b/bertos/cpu/avr/drv/kdebug_avr.c index 5a8d2f31..8fa1a4bf 100644 --- a/bertos/cpu/avr/drv/kdebug_avr.c +++ b/bertos/cpu/avr/drv/kdebug_avr.c @@ -73,7 +73,7 @@ #endif #if CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 \ - || CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P + || CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P || CPU_AVR_ATMEGA2560 #define UCR UCSR0B #define UDR UDR0 #define USR UCSR0A @@ -330,7 +330,7 @@ INLINE void kdbg_hw_init(void) #error CONFIG_KDEBUG_PORT must be either 0 or 1 #endif - #elif CPU_AVR_ATMEGA1280 + #elif CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA2560 #if CONFIG_KDEBUG_PORT == 0 UBRR0H = (uint8_t)(period>>8); UBRR0L = (uint8_t)period; diff --git a/bertos/cpu/avr/drv/ser_avr.c b/bertos/cpu/avr/drv/ser_avr.c index a4328f41..7f8cf932 100644 --- a/bertos/cpu/avr/drv/ser_avr.c +++ b/bertos/cpu/avr/drv/ser_avr.c @@ -74,7 +74,7 @@ /*\}*/ #endif -#if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 +#if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA2560 #define BIT_RXCIE0 RXCIE0 #define BIT_RXEN0 RXEN0 #define BIT_TXEN0 TXEN0 @@ -84,7 +84,7 @@ #define BIT_RXEN1 RXEN1 #define BIT_TXEN1 TXEN1 #define BIT_UDRIE1 UDRIE1 - #if CPU_AVR_ATMEGA1280 + #if CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA2560 #define BIT_RXCIE2 RXCIE2 #define BIT_RXEN2 RXEN2 #define BIT_TXEN2 TXEN2 @@ -332,7 +332,7 @@ /* SPI port and pin configuration */ #if CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA103 || CPU_AVR_ATMEGA1281 \ - || CPU_AVR_ATMEGA1280 + || CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA2560 #define SPI_PORT PORTB #define SPI_DDR DDRB #define SPI_SS_BIT PB0 @@ -367,7 +367,7 @@ #endif /* USART register definitions */ -#if CPU_AVR_ATMEGA1280 +#if CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA2560 #define AVR_HAS_UART1 1 #define AVR_HAS_UART2 1 #define AVR_HAS_UART3 1 diff --git a/bertos/cpu/avr/drv/ser_avr.h b/bertos/cpu/avr/drv/ser_avr.h index 36d3a6f8..68d5e508 100644 --- a/bertos/cpu/avr/drv/ser_avr.h +++ b/bertos/cpu/avr/drv/ser_avr.h @@ -86,7 +86,7 @@ typedef uint8_t serstatus_t; */ enum { -#if CPU_AVR_ATMEGA1280 +#if CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA2560 SER_UART0, SER_UART1, SER_UART2, diff --git a/bertos/cpu/avr/drv/timer_avr.c b/bertos/cpu/avr/drv/timer_avr.c index 5decb048..ee63e76f 100644 --- a/bertos/cpu/avr/drv/timer_avr.c +++ b/bertos/cpu/avr/drv/timer_avr.c @@ -49,18 +49,18 @@ #include -#if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P +#if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P || CPU_AVR_ATMEGA2560 #define REG_TIFR0 TIFR0 #define REG_TIFR1 TIFR1 #define REG_TIFR2 TIFR2 - #if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 + #if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA2560 #define REG_TIFR3 TIFR3 #endif #define REG_TIMSK0 TIMSK0 #define REG_TIMSK1 TIMSK1 #define REG_TIMSK2 TIMSK2 - #if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 + #if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA2560 #define REG_TIMSK3 TIMSK3 #endif diff --git a/bertos/cpu/avr/drv/timer_avr.h b/bertos/cpu/avr/drv/timer_avr.h index e497c919..2146620c 100644 --- a/bertos/cpu/avr/drv/timer_avr.h +++ b/bertos/cpu/avr/drv/timer_avr.h @@ -72,7 +72,7 @@ #define TIMER_PRESCALER 64 #define TIMER_HW_BITS 8 - #if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P + #if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P || CPU_AVR_ATMEGA2560 #define DEFINE_TIMER_ISR DECLARE_ISR_CONTEXT_SWITCH(TIMER0_COMPA_vect) #else #define DEFINE_TIMER_ISR DECLARE_ISR_CONTEXT_SWITCH(TIMER0_COMP_vect) @@ -111,7 +111,7 @@ #define TIMER_PRESCALER 64 #define TIMER_HW_BITS 8 - #if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P + #if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P || CPU_AVR_ATMEGA2560 #define DEFINE_TIMER_ISR DECLARE_ISR_CONTEXT_SWITCH(TIMER2_COMPA_vect) #else #define DEFINE_TIMER_ISR DECLARE_ISR_CONTEXT_SWITCH(TIMER2_COMP_vect) diff --git a/bertos/cpu/detect.h b/bertos/cpu/detect.h index ce462b2e..e14ca222 100644 --- a/bertos/cpu/detect.h +++ b/bertos/cpu/detect.h @@ -432,9 +432,16 @@ #define CPU_AVR_ATMEGA1280 0 #endif + #if defined(__AVR_ATmega2560__) + #define CPU_AVR_ATMEGA2560 1 + #define CPU_NAME "ATmega2560" + #else + #define CPU_AVR_ATMEGA2560 0 + #endif + #if CPU_AVR_ATMEGA32 + CPU_AVR_ATMEGA64 + CPU_AVR_ATMEGA103 + CPU_AVR_ATMEGA128 \ + CPU_AVR_ATMEGA8 + CPU_AVR_ATMEGA168 + CPU_AVR_ATMEGA328P + CPU_AVR_ATMEGA1281 \ - + CPU_AVR_ATMEGA1280 != 1 + + CPU_AVR_ATMEGA1280 + CPU_AVR_ATMEGA2560 != 1 #error AVR CPU configuration error #endif #else @@ -448,6 +455,7 @@ #define CPU_AVR_ATMEGA128 0 #define CPU_AVR_ATMEGA1281 0 #define CPU_AVR_ATMEGA1280 0 + #define CPU_AVR_ATMEGA2560 0 #endif #if defined (__MSP430__)