From 86abd5b97ebd9132d0d62b59374be037f98771ae Mon Sep 17 00:00:00 2001 From: lottaviano Date: Fri, 26 Mar 2010 19:19:22 +0000 Subject: [PATCH] Initial support for ATmega328P (Arduino Duemilanove). Added cdef file for wizard, added cpu detection macros, serial debug is now working. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3281 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cpu/attr.h | 2 +- bertos/cpu/avr/drv/kdebug_avr.c | 4 +-- bertos/cpu/avr/info/ATmega328P.cdef | 55 +++++++++++++++++++++++++++++ bertos/cpu/detect.h | 9 ++++- 4 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 bertos/cpu/avr/info/ATmega328P.cdef diff --git a/bertos/cpu/attr.h b/bertos/cpu/attr.h index f54e6b06..dae231ff 100644 --- a/bertos/cpu/attr.h +++ b/bertos/cpu/attr.h @@ -212,7 +212,7 @@ /// Valid pointers should be >= than this value (used for debug) #if CPU_AVR_ATMEGA8 || CPU_AVR_ATMEGA32 || CPU_AVR_ATMEGA103 #define CPU_RAM_START 0x60 - #elif CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA168 + #elif CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P #define CPU_RAM_START 0x100 #elif CPU_AVR_ATMEGA1281 #define CPU_RAM_START 0x200 diff --git a/bertos/cpu/avr/drv/kdebug_avr.c b/bertos/cpu/avr/drv/kdebug_avr.c index 0d2c7306..4cdaf94e 100644 --- a/bertos/cpu/avr/drv/kdebug_avr.c +++ b/bertos/cpu/avr/drv/kdebug_avr.c @@ -73,7 +73,7 @@ #define KDBG_UART0_BUS_TX do {} while (0) #endif - #if CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA168 + #if CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P #define UCR UCSR0B #define UDR UDR0 #define USR UCSR0A @@ -245,7 +245,7 @@ INLINE void kdbg_hw_init(void) #error CONFIG_KDEBUG_PORT must be either 0 or 1 #endif - #elif CPU_AVR_ATMEGA168 + #elif CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P UBRR0H = (uint8_t)(period>>8); UBRR0L = (uint8_t)period; KDBG_UART0_BUS_INIT; diff --git a/bertos/cpu/avr/info/ATmega328P.cdef b/bertos/cpu/avr/info/ATmega328P.cdef new file mode 100644 index 00000000..a6d61055 --- /dev/null +++ b/bertos/cpu/avr/info/ATmega328P.cdef @@ -0,0 +1,55 @@ +# +#-*- coding: utf-8 -*- +# +# \file +# +# +# Cpu info of the ATMega328P. +# +# This file contain all info for the BeRTOS wizard. +# +# \author Luca Ottaviano +# +# + +# Import the common settings for the path. +include("avr.common") + +# Short description of the cpu. +CPU_DESC += [ "Arduino Duemilanove", + "32 Kbyte in-System Programmable Flash", + "2 Kbytes internal SRAM memory", + "1 Kbyte EEPROM memory" ] + +# If we use the GCC compiler we should pass some flags. +CORE_CPU = "atmega328p" + +include("avr_post.common") diff --git a/bertos/cpu/detect.h b/bertos/cpu/detect.h index 6c0d8f6e..c6de054b 100644 --- a/bertos/cpu/detect.h +++ b/bertos/cpu/detect.h @@ -265,6 +265,12 @@ #define CPU_AVR_ATMEGA168 0 #endif + #if defined(__AVR_ATmega328P__) + #define CPU_AVR_ATMEGA328P 1 + #else + #define CPU_AVR_ATMEGA328P 0 + #endif + #if defined(__AVR_ATmega1281__) #define CPU_AVR_ATMEGA1281 1 #else @@ -272,13 +278,14 @@ #endif #if CPU_AVR_ATMEGA32 + CPU_AVR_ATMEGA64 + CPU_AVR_ATMEGA103 + CPU_AVR_ATMEGA128 \ - + CPU_AVR_ATMEGA8 + CPU_AVR_ATMEGA168 + CPU_AVR_ATMEGA1281 != 1 + + CPU_AVR_ATMEGA8 + CPU_AVR_ATMEGA168 + CPU_AVR_ATMEGA328P + CPU_AVR_ATMEGA1281 != 1 #error AVR CPU configuration error #endif #else #define CPU_AVR 0 #define CPU_AVR_ATMEGA8 0 #define CPU_AVR_ATMEGA168 0 + #define CPU_AVR_ATMEGA328P 0 #define CPU_AVR_ATMEGA32 0 #define CPU_AVR_ATMEGA64 0 #define CPU_AVR_ATMEGA103 0 -- 2.25.1