diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-06-11 14:53:56 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-06-11 14:53:56 +0000 |
commit | c0cf3ce4b3306a6ea08d579f84247900b7e9611e (patch) | |
tree | f957ffd23905edecc82b8403ddcc3a076a134fe6 /nuttx/arch/avr | |
parent | 6824157a582c0ba02a97f460be9fd3bd94c1e485 (diff) | |
download | px4-nuttx-c0cf3ce4b3306a6ea08d579f84247900b7e9611e.tar.gz px4-nuttx-c0cf3ce4b3306a6ea08d579f84247900b7e9611e.tar.bz2 px4-nuttx-c0cf3ce4b3306a6ea08d579f84247900b7e9611e.zip |
Add ATMega128 configuration
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3695 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/avr')
-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 648f193df..eb93dc5e2 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 2cb483160..866680f0e 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 c4fea31da..0bba35cc3 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 b318dd608..e3277b98b 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 402add3d3..d724bf6f8 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 11beee8e5..1e0072427 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> |