mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
Basic serial console now works
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3064 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -93,7 +93,7 @@
|
|||||||
#define GPIO_PULLUP (1 << 11) /* Bit 11: Pull-up enable */
|
#define GPIO_PULLUP (1 << 11) /* Bit 11: Pull-up enable */
|
||||||
|
|
||||||
/* Output value (Valid only if GPIO_ENABLE and GPIO_OUTPUT)
|
/* Output value (Valid only if GPIO_ENABLE and GPIO_OUTPUT)
|
||||||
* .... .V... .... ....
|
* .... .V.. .... ....
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define GPIO_VALUE (1 << 10) /* Bit 10: Output value */
|
#define GPIO_VALUE (1 << 10) /* Bit 10: Output value */
|
||||||
|
|||||||
@@ -49,6 +49,7 @@
|
|||||||
#include "up_arch.h"
|
#include "up_arch.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
#include "at32uc3_internal.h"
|
#include "at32uc3_internal.h"
|
||||||
|
#include "at32uc3_pm.h"
|
||||||
#include "at32uc3_usart.h"
|
#include "at32uc3_usart.h"
|
||||||
#include "at32uc3_pinmux.h"
|
#include "at32uc3_pinmux.h"
|
||||||
|
|
||||||
@@ -240,10 +241,6 @@ void usart_configure(uintptr_t usart_base, uint32_t baud, unsigned int parity,
|
|||||||
|
|
||||||
usart_reset(usart_base);
|
usart_reset(usart_base);
|
||||||
|
|
||||||
/* Set the baud rate generation register */
|
|
||||||
|
|
||||||
usart_setbaudrate(usart_base, baud);
|
|
||||||
|
|
||||||
/* Configure STOP bits */
|
/* Configure STOP bits */
|
||||||
|
|
||||||
regval = USART_MR_MODE_NORMAL|USART_MR_CHMODE_NORMAL; /* Normal RS-232 mode */
|
regval = USART_MR_MODE_NORMAL|USART_MR_CHMODE_NORMAL; /* Normal RS-232 mode */
|
||||||
@@ -281,6 +278,10 @@ void usart_configure(uintptr_t usart_base, uint32_t baud, unsigned int parity,
|
|||||||
|
|
||||||
usart_putreg(usart_base, AVR32_USART_MR_OFFSET, regval);
|
usart_putreg(usart_base, AVR32_USART_MR_OFFSET, regval);
|
||||||
|
|
||||||
|
/* Set the baud rate generation register */
|
||||||
|
|
||||||
|
usart_setbaudrate(usart_base, baud);
|
||||||
|
|
||||||
/* Enable RX and TX */
|
/* Enable RX and TX */
|
||||||
|
|
||||||
regval = usart_getreg(usart_base, AVR32_USART_CR_OFFSET);
|
regval = usart_getreg(usart_base, AVR32_USART_CR_OFFSET);
|
||||||
@@ -302,12 +303,10 @@ void usart_configure(uintptr_t usart_base, uint32_t baud, unsigned int parity,
|
|||||||
#ifndef CONFIG_USE_EARLYSERIALINIT
|
#ifndef CONFIG_USE_EARLYSERIALINIT
|
||||||
void up_consoleinit(void)
|
void up_consoleinit(void)
|
||||||
{
|
{
|
||||||
/* Enable clocking for the enabled USART modules. Hmmm... It looks like the
|
uint32_t pbamask = 0;
|
||||||
* default state for CLK_USART0, USART1 CLK_USART1, and USART2 CLK_USART2 is
|
uint32_t regval;
|
||||||
* "enabled" in the PM's PBAMASK register.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Setup GPIO pins for each configured USART/UART */
|
/* Setup GPIO pins fand enable module clocking or each configured USART/UART */
|
||||||
|
|
||||||
#ifdef CONFIG_AVR32_USART0_RS232
|
#ifdef CONFIG_AVR32_USART0_RS232
|
||||||
/* PINMUX_USART0_RXD and PINMUX_USART0_TXD must be defined in board.h. It
|
/* PINMUX_USART0_RXD and PINMUX_USART0_TXD must be defined in board.h. It
|
||||||
@@ -318,6 +317,10 @@ void up_consoleinit(void)
|
|||||||
at32uc3_configgpio(PINMUX_USART0_RXD);
|
at32uc3_configgpio(PINMUX_USART0_RXD);
|
||||||
at32uc3_configgpio(PINMUX_USART0_TXD);
|
at32uc3_configgpio(PINMUX_USART0_TXD);
|
||||||
|
|
||||||
|
/* Enable clocking to USART0 (This should be the default state after reset) */
|
||||||
|
|
||||||
|
pbamask |= PM_PBAMASK_USART0;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_AVR32_USART1_RS232
|
#ifdef CONFIG_AVR32_USART1_RS232
|
||||||
/* PINMUX_USART1_RXD and PINMUX_USART1_TXD must be defined in board.h. It
|
/* PINMUX_USART1_RXD and PINMUX_USART1_TXD must be defined in board.h. It
|
||||||
@@ -329,6 +332,10 @@ void up_consoleinit(void)
|
|||||||
at32uc3_configgpio(PINMUX_USART1_RXD);
|
at32uc3_configgpio(PINMUX_USART1_RXD);
|
||||||
at32uc3_configgpio(PINMUX_USART1_TXD);
|
at32uc3_configgpio(PINMUX_USART1_TXD);
|
||||||
|
|
||||||
|
/* Enable clocking to USART1 (This should be the default state after reset) */
|
||||||
|
|
||||||
|
pbamask |= PM_PBAMASK_USART1;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_AVR32_USART2_RS232
|
#ifdef CONFIG_AVR32_USART2_RS232
|
||||||
/* PINMUX_USART2_RXD and PINMUX_USART2_TXD must be defined in board.h. It
|
/* PINMUX_USART2_RXD and PINMUX_USART2_TXD must be defined in board.h. It
|
||||||
@@ -338,8 +345,20 @@ void up_consoleinit(void)
|
|||||||
|
|
||||||
at32uc3_configgpio(PINMUX_USART2_RXD);
|
at32uc3_configgpio(PINMUX_USART2_RXD);
|
||||||
at32uc3_configgpio(PINMUX_USART2_TXD);
|
at32uc3_configgpio(PINMUX_USART2_TXD);
|
||||||
|
|
||||||
|
/* Enable clocking to USART2 (This should be the default state after reset) */
|
||||||
|
|
||||||
|
pbamask |= PM_PBAMASK_USART2;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Enable selected clocks (and disabled unselected clocks) */
|
||||||
|
|
||||||
|
regval = getreg32(AVR32_PM_PBAMASK);
|
||||||
|
regval &= ~(PM_PBAMASK_USART0|PM_PBAMASK_USART1|PM_PBAMASK_USART2);
|
||||||
|
regval |= pbamask;
|
||||||
|
putreg32(regval, AVR32_PM_PBAMASK);
|
||||||
|
|
||||||
/* Then configure the console here (if it is not going to be configured
|
/* Then configure the console here (if it is not going to be configured
|
||||||
* by up_earlyserialinit()).
|
* by up_earlyserialinit()).
|
||||||
*/
|
*/
|
||||||
@@ -364,7 +383,7 @@ void up_lowputc(char ch)
|
|||||||
#ifdef HAVE_SERIAL_CONSOLE
|
#ifdef HAVE_SERIAL_CONSOLE
|
||||||
/* Wait until the TX to become ready */
|
/* Wait until the TX to become ready */
|
||||||
|
|
||||||
while (usart_getreg(AVR32_CONSOLE_BASE, USART_CSR_TXRDY) == 0);
|
while ((usart_getreg(AVR32_CONSOLE_BASE, AVR32_USART_CSR_OFFSET) & USART_CSR_TXRDY) == 0);
|
||||||
|
|
||||||
/* Then send the character */
|
/* Then send the character */
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ CONFIG_ARCH_CHIP_AT32UC3B0256=y
|
|||||||
CONFIG_ENDIAN_BIG=y
|
CONFIG_ENDIAN_BIG=y
|
||||||
CONFIG_ARCH_BOARD=avr32dev1
|
CONFIG_ARCH_BOARD=avr32dev1
|
||||||
CONFIG_ARCH_BOARD_AVR32DEV1=y
|
CONFIG_ARCH_BOARD_AVR32DEV1=y
|
||||||
CONFIG_BOARD_LOOPSPERMSEC=7982
|
CONFIG_BOARD_LOOPSPERMSEC=1140
|
||||||
CONFIG_DRAM_SIZE=(32*1024)
|
CONFIG_DRAM_SIZE=(32*1024)
|
||||||
CONFIG_DRAM_START=0x10000000
|
CONFIG_DRAM_START=0x10000000
|
||||||
CONFIG_DRAM_END=(CONFIG_DRAM_START+CONFIG_DRAM_SIZE)
|
CONFIG_DRAM_END=(CONFIG_DRAM_START+CONFIG_DRAM_SIZE)
|
||||||
|
|||||||
Reference in New Issue
Block a user