diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2011-06-11 14:53:56 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2011-06-11 14:53:56 +0000 |
commit | bb0e66429ffe10cc4d7346b3c27f5c37040713fa (patch) | |
tree | f957ffd23905edecc82b8403ddcc3a076a134fe6 /nuttx/arch/avr/src | |
parent | 0a355860ab23446d0d5efc04f36a178ef44d4111 (diff) |
Add ATMega128 configuration
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@3695 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/arch/avr/src')
-rw-r--r-- | nuttx/arch/avr/src/at90usb/at90usb_lowconsole.c | 28 | ||||
-rw-r--r-- | nuttx/arch/avr/src/atmega/atmega_config.h | 6 | ||||
-rwxr-xr-x | nuttx/arch/avr/src/atmega/atmega_exceptions.S | 2 | ||||
-rw-r--r-- | nuttx/arch/avr/src/atmega/atmega_lowconsole.c | 77 | ||||
-rw-r--r-- | nuttx/arch/avr/src/atmega/atmega_timerisr.c | 2 | ||||
-rw-r--r-- | nuttx/arch/avr/src/avr/up_irq.c | 1 |
6 files changed, 86 insertions, 30 deletions
diff --git a/nuttx/arch/avr/src/at90usb/at90usb_lowconsole.c b/nuttx/arch/avr/src/at90usb/at90usb_lowconsole.c index 648f193df9..eb93dc5e28 100644 --- a/nuttx/arch/avr/src/at90usb/at90usb_lowconsole.c +++ b/nuttx/arch/avr/src/at90usb/at90usb_lowconsole.c @@ -144,13 +144,19 @@ #ifdef HAVE_USART_DEVICE void usart1_reset(void) { + /* Clear USART configuration */ + UCSR1A = 0; UCSR1B = 0; UCSR1C = 0; - DDRD &= ~(1 << 3); + /* Unconfigure pins */ + + DDRD &= ~(1 << 3); PORTD &= ~(1 << 2); - + + /* Unconfigure BAUD divisor */ + UBRR1 = 0; } #endif @@ -214,10 +220,20 @@ void usart1_configure(void) UCSR1B = ucsr1b; UCSR1C = ucsr1c; - /* Configure pin */ - - DDRD |= (1 << 3); - PORTD |= (1 << 2); + /* Pin Configuration: None necessary, Port D bits 2&3 are automatically + * configured: + * + * Port D, Bit 2: RXD1, Receive Data (Data input pin for the USART1). When + * the USART1 receiver is enabled this pin is configured as an input + * regardless of the value of DDD2. When the USART forces this pin to + * be an input, the pull-up can still be controlled by the PORTD2 bit. + * Port D, Bit 3: TXD1, Transmit Data (Data output pin for the USART1). + * When the USART1 Transmitter is enabled, this pin is configured as + * an output regardless of the value of DDD3. + */ + + DDRD |= (1 << 3); /* Force Port D pin 3 to be an output */ + PORTD |= (1 << 2); /* Set pull-up on port D pin 2 */ /* Set the baud rate divisor */ diff --git a/nuttx/arch/avr/src/atmega/atmega_config.h b/nuttx/arch/avr/src/atmega/atmega_config.h index 2cb483160c..866680f0e8 100644 --- a/nuttx/arch/avr/src/atmega/atmega_config.h +++ b/nuttx/arch/avr/src/atmega/atmega_config.h @@ -33,8 +33,8 @@ * ************************************************************************************/ -#ifndef __ARCH_AVR_SRC_AT90USB_AT90USB_CONFIG_H -#define __ARCH_AVR_SRC_AT90USB_AT90USB_CONFIG_H +#ifndef __ARCH_AVR_SRC_ATMEGA_ATMEGA_CONFIG_H +#define __ARCH_AVR_SRC_ATMEGA_ATMEGA_CONFIG_H /************************************************************************************ * Included Files @@ -80,5 +80,5 @@ * Public Functions ************************************************************************************/ -#endif /* __ARCH_AVR_SRC_AT90USB_AT90USB_CONFIG_H */ +#endif /* __ARCH_AVR_SRC_ATMEGA_ATMEGA_CONFIG_H */ diff --git a/nuttx/arch/avr/src/atmega/atmega_exceptions.S b/nuttx/arch/avr/src/atmega/atmega_exceptions.S index c4fea31dab..0bba35cc30 100755 --- a/nuttx/arch/avr/src/atmega/atmega_exceptions.S +++ b/nuttx/arch/avr/src/atmega/atmega_exceptions.S @@ -49,7 +49,7 @@ .file "atmega_exceptions.S" .global up_doirq - .gloal up_fullcontextrestore + .global up_fullcontextrestore /******************************************************************************************** * Macros diff --git a/nuttx/arch/avr/src/atmega/atmega_lowconsole.c b/nuttx/arch/avr/src/atmega/atmega_lowconsole.c index b318dd608e..e3277b98bb 100644 --- a/nuttx/arch/avr/src/atmega/atmega_lowconsole.c +++ b/nuttx/arch/avr/src/atmega/atmega_lowconsole.c @@ -58,10 +58,10 @@ /* USART0 Baud rate settings for normal and double speed settings */ #define AVR_NORMAL_UBRR0 \ - ((((BOARD_CPU_CLOCK / 16) + (CONFIG_USART0_BAUD / 2)) / (CONFIG_USART0_BAUD)) - 1) + (((((BOARD_CPU_CLOCK / 16) + (CONFIG_USART0_BAUD / 2)) / (CONFIG_USART0_BAUD)) - 1) #define AVR_DBLSPEED_UBRR0 \ - ((((BOARD_CPU_CLOCK / 8) + (CONFIG_USART0_BAUD / 2)) / (CONFIG_USART0_BAUD)) - 1) + (((((BOARD_CPU_CLOCK / 8) + (CONFIG_USART0_BAUD / 2)) / (CONFIG_USART0_BAUD)) - 1) /* Select normal or double speed baud settings. This is a trade-off between the * sampling rate and the accuracy of the divisor for high baud rates. @@ -111,10 +111,10 @@ /* USART1 Baud rate settings for normal and double speed settings */ #define AVR_NORMAL_UBRR1 \ - (((BOARD_CPU_CLOCK / 16) + (CONFIG_USART1_BAUD / 2)) / (CONFIG_USART1_BAUD)) - 1) + ((((BOARD_CPU_CLOCK / 16) + (CONFIG_USART1_BAUD / 2)) / (CONFIG_USART1_BAUD)) - 1) #define AVR_DBLSPEED_UBRR1 \ - (((BOARD_CPU_CLOCK / 8) + (CONFIG_USART1_BAUD / 2)) / (CONFIG_USART1_BAUD)) - 1) + ((((BOARD_CPU_CLOCK / 8) + (CONFIG_USART1_BAUD / 2)) / (CONFIG_USART1_BAUD)) - 1) /* Select normal or double speed baud settings. This is a trade-off between the * sampling rate and the accuracy of the divisor for high baud rates. @@ -196,27 +196,42 @@ #ifdef CONFIG_ATMEGA_USART0 void usart0_reset(void) { + /* Clear USART configuration */ + UCSR0A = 0; UCSR0B = 0; UCSR0C = 0; -# warning "Missing logic" + /* Unconfigure pins (no action needed */ + + DDRE &= ~(1 << 1); + PORTE &= ~(1 << 0); + + /* Unconfigure BAUD divisor */ - UBRR0 = 0; + UBRR0H = 0; + UBRR0L = 0; } #endif #ifdef CONFIG_ATMEGA_USART1 void usart1_reset(void) { + /* Clear USART configuration */ + UCSR1A = 0; UCSR1B = 0; UCSR1C = 0; - DDRD &= ~(1 << 3); + /* Unconfigure pins */ + + DDRD &= ~(1 << 3); PORTD &= ~(1 << 2); - - UBRR1 = 0; + + /* Unconfigure BAUD divisor */ + + UBRR1H = 0; + UBRR1L = 0; } #endif @@ -279,13 +294,28 @@ void usart0_configure(void) UCSR0B = ucsr0b; UCSR0C = ucsr0c; - /* Configure pin */ - -#warning "Missing logic" + /* Pin Configuration: None necessary, Port E bits 0&1 are automatically + * configured: + * + * Port E, Bit 0: RXD0, USART0 Receive Pin. Receive Data (Data input pin + * for the USART0). When the USART0 receiver is enabled this pin is + * configured as an input regardless of the value of DDRE0. When the + * USART0 forces this pin to be an input, a logical one in PORTE0 will + * turn on the internal pull-up. + * + * Port E, Bit 1: TXD0, UART0 Transmit pin. + * + * REVISIT: According to table 41, TXD0 is also automatically configured. + * However, this is not explicitly stated in the text. + */ + + DDRE |= (1 << 1); /* Force Port E pin 1 to be an input */ + PORTE |= (1 << 0); /* Set pull-up on Port E pin 0 */ /* Set the baud rate divisor */ - UBRR0 = AVR_UBRR0; + UBRR0H = AVR_UBRR1 >> 8; + UBRR0L = AVR_UBRR1 & 0xff; } #endif @@ -340,14 +370,25 @@ void usart1_configure(void) UCSR1B = ucsr1b; UCSR1C = ucsr1c; - /* Configure pin */ - - DDRD |= (1 << 3); - PORTD |= (1 << 2); + /* Pin Configuration: None necessary, Port D bits 2&3 are automatically + * configured: + * + * Port D, Bit 2: RXD1, Receive Data (Data input pin for the USART1). When + * the USART1 receiver is enabled this pin is configured as an input + * regardless of the value of DDD2. When the USART forces this pin to + * be an input, the pull-up can still be controlled by the PORTD2 bit. + * Port D, Bit 3: TXD1, Transmit Data (Data output pin for the USART1). + * When the USART1 Transmitter is enabled, this pin is configured as + * an output regardless of the value of DDD3. + */ + + DDRD |= (1 << 3); /* Force Port D pin 3 to be an output */ + PORTD |= (1 << 2); /* Set pull-up on port D pin 2 */ /* Set the baud rate divisor */ - UBRR1 = AVR_UBRR1; + UBRR1H = AVR_UBRR1 >> 8; + UBRR1L = AVR_UBRR1 & 0xff; } #endif diff --git a/nuttx/arch/avr/src/atmega/atmega_timerisr.c b/nuttx/arch/avr/src/atmega/atmega_timerisr.c index 402add3d34..d724bf6f8a 100644 --- a/nuttx/arch/avr/src/atmega/atmega_timerisr.c +++ b/nuttx/arch/avr/src/atmega/atmega_timerisr.c @@ -177,5 +177,5 @@ void up_timerinit(void) /* Enable the interrupt on compare match A */ - TIMSK1 |= (1 << OCIE1A); + TIMSK |= (1 << OCIE1A); } diff --git a/nuttx/arch/avr/src/avr/up_irq.c b/nuttx/arch/avr/src/avr/up_irq.c index 11beee8e57..1e0072427b 100644 --- a/nuttx/arch/avr/src/avr/up_irq.c +++ b/nuttx/arch/avr/src/avr/up_irq.c @@ -38,7 +38,6 @@ ****************************************************************************/ #include <nuttx/config.h> -#include "at90usb_config.h" #include <stdint.h> #include <errno.h> |