From da99e878a65f6ab84e51bdf4c9029c3906431b03 Mon Sep 17 00:00:00 2001 From: lottaviano Date: Tue, 21 Sep 2010 08:35:58 +0000 Subject: [PATCH] Fix serial driver for ATMega32. Also enable ATMega32 serial driver in the Wizard. This patch should also have fixed serial support for ATMega8, but the timer is still broken so I'm not enabling ATMega8 serial support in the Wizard. Signed-off-by: Gilles Signed-off-by: Luca Ottaviano git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4251 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cpu/avr/drv/ser_avr.c | 15 ++++++++++++--- bertos/cpu/avr/drv/ser_avr.h | 3 ++- bertos/drv/ser.h | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/bertos/cpu/avr/drv/ser_avr.c b/bertos/cpu/avr/drv/ser_avr.c index ee6c6ab1..a4328f41 100644 --- a/bertos/cpu/avr/drv/ser_avr.c +++ b/bertos/cpu/avr/drv/ser_avr.c @@ -355,6 +355,13 @@ #define SPI_SCK_BIT PB5 #define SPI_MOSI_BIT PB3 #define SPI_MISO_BIT PB4 +#elif CPU_AVR_ATMEGA32 + #define SPI_PORT PORTB + #define SPI_DDR DDRB + #define SPI_SS_BIT PB4 + #define SPI_SCK_BIT PB7 + #define SPI_MOSI_BIT PB5 + #define SPI_MISO_BIT PB6 #else #error Unknown architecture #endif @@ -375,7 +382,7 @@ #define USART0_UDRE_vect USART_UDRE_vect #define USART0_RX_vect USART_RX_vect #define USART0_TX_vect USART_TX_vect -#elif CPU_AVR_ATMEGA8 +#elif CPU_AVR_ATMEGA8 || CPU_AVR_ATMEGA32 #define AVR_HAS_UART1 0 #define AVR_HAS_UART2 0 #define AVR_HAS_UART3 0 @@ -385,9 +392,11 @@ #define UDR0 UDR #define UBRR0L UBRRL #define UBRR0H UBRRH + #define UPM01 UPM1 + #define UPM00 UPM0 #define USART0_UDRE_vect USART_UDRE_vect - #define USART0_RX_vect USART_RX_vect - #define USART0_TX_vect USART_TX_vect + #define USART0_RX_vect USART_RXC_vect + #define USART0_TX_vect USART_TXC_vect #elif CPU_AVR_ATMEGA103 #define AVR_HAS_UART1 0 #define AVR_HAS_UART2 0 diff --git a/bertos/cpu/avr/drv/ser_avr.h b/bertos/cpu/avr/drv/ser_avr.h index 5f3c9fb8..36d3a6f8 100644 --- a/bertos/cpu/avr/drv/ser_avr.h +++ b/bertos/cpu/avr/drv/ser_avr.h @@ -96,7 +96,8 @@ enum SER_UART0, SER_UART1, SER_SPI, -#elif CPU_AVR_ATMEGA103 || CPU_AVR_ATMEGA8 || CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P +#elif CPU_AVR_ATMEGA103 || CPU_AVR_ATMEGA8 || CPU_AVR_ATMEGA32 || CPU_AVR_ATMEGA168 \ + || CPU_AVR_ATMEGA328P SER_UART0, SER_SPI, #else diff --git a/bertos/drv/ser.h b/bertos/drv/ser.h index 0f89d932..861fdf19 100644 --- a/bertos/drv/ser.h +++ b/bertos/drv/ser.h @@ -39,7 +39,7 @@ * $WIZ$ module_depends = "kfile", "timer" * $WIZ$ module_configuration = "bertos/cfg/cfg_ser.h" * $WIZ$ module_hw = "bertos/hw/hw_ser.h" - * $WIZ$ module_supports = "not atmega103 and not atmega32 and not atmega8" + * $WIZ$ module_supports = "not atmega103 and not atmega8" */ #ifndef DRV_SER_H -- 2.25.1