Fix a16f serial bugs
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@568 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
c5d3ec31ab
commit
108b7be44f
@ -149,7 +149,7 @@ _z16f_reset:
|
|||||||
#endif
|
#endif
|
||||||
/* Perform VERY early UART initialization so that we can use it here */
|
/* Perform VERY early UART initialization so that we can use it here */
|
||||||
|
|
||||||
#if defined(CONFIG_ARCH_LOWPUTC) || defined(CONFIG_ARCH_LOWGETC)
|
#if defined(CONFIG_ARCH_LOWPUTC) || defined(CONFIG_ARCH_LOWGETC) || CONFIG_NFILE_DESCRIPTORS == 0
|
||||||
call _z16f_lowuartinit /* Initialize the UART for debugging */
|
call _z16f_lowuartinit /* Initialize the UART for debugging */
|
||||||
#endif
|
#endif
|
||||||
/* Initialize the hardware stack overflow register */
|
/* Initialize the hardware stack overflow register */
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include "chip/chip.h"
|
#include "chip/chip.h"
|
||||||
|
|
||||||
#if defined(CONFIG_ARCH_LOWPUTC) || defined(CONFIG_ARCH_LOWGETC)
|
#if defined(CONFIG_ARCH_LOWPUTC) || defined(CONFIG_ARCH_LOWGETC) || CONFIG_NFILE_DESCRIPTORS == 0
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* External References / External Definitions
|
* External References / External Definitions
|
||||||
@ -96,19 +96,6 @@ _z16f_lowuartinit:
|
|||||||
udiv r0, r3 /* BRG = (freq + baud * 8)/(baud * 16) */
|
udiv r0, r3 /* BRG = (freq + baud * 8)/(baud * 16) */
|
||||||
|
|
||||||
#ifdef CONFIG_UART0_SERIAL_CONSOLE
|
#ifdef CONFIG_UART0_SERIAL_CONSOLE
|
||||||
ld.w Z16F_UART0_BR, r0 /* Z16F_UART0_BR = BRG */
|
|
||||||
|
|
||||||
/* Set the GPIO Alternate Function Register Lo (AFL) register */
|
|
||||||
|
|
||||||
ld r0, #%30
|
|
||||||
or.b Z16F_GPIOA_AFL, r0 /* Z16F_GPIOA_AFL |= %30 */
|
|
||||||
|
|
||||||
/* Enable UART receive (REN) and transmit (TEN) */
|
|
||||||
|
|
||||||
clr.b Z16F_UART0_CTL1 /* Z16F_UART0_CTL1 = 0 */
|
|
||||||
ld r0, #(Z16F_UARTCTL0_TEN|Z16F_UARTCTL0_REN)
|
|
||||||
ld.b Z16F_UART0_CTL0, r0 /* Z16F_UART0_CTL0 = %c0 */
|
|
||||||
#else
|
|
||||||
ld.w Z16F_UART1_BR, r0 /* Z16F_UART1_BR = BRG */
|
ld.w Z16F_UART1_BR, r0 /* Z16F_UART1_BR = BRG */
|
||||||
|
|
||||||
/* Set the GPIO Alternate Function Register Lo (AFL) register */
|
/* Set the GPIO Alternate Function Register Lo (AFL) register */
|
||||||
@ -121,6 +108,19 @@ _z16f_lowuartinit:
|
|||||||
clr.b Z16F_UART1_CTL1 /* Z16F_UART1_CTL1 = 0 */
|
clr.b Z16F_UART1_CTL1 /* Z16F_UART1_CTL1 = 0 */
|
||||||
ld r0, #(Z16F_UARTCTL0_TEN|Z16F_UARTCTL0_REN)
|
ld r0, #(Z16F_UARTCTL0_TEN|Z16F_UARTCTL0_REN)
|
||||||
ld.b Z16F_UART1_CTL0, r0 /* Z16F_UART1_CTL0 = %c0 */
|
ld.b Z16F_UART1_CTL0, r0 /* Z16F_UART1_CTL0 = %c0 */
|
||||||
|
#else
|
||||||
|
ld.w Z16F_UART0_BR, r0 /* Z16F_UART0_BR = BRG */
|
||||||
|
|
||||||
|
/* Set the GPIO Alternate Function Register Lo (AFL) register */
|
||||||
|
|
||||||
|
ld r0, #%30
|
||||||
|
or.b Z16F_GPIOA_AFL, r0 /* Z16F_GPIOA_AFL |= %30 */
|
||||||
|
|
||||||
|
/* Enable UART receive (REN) and transmit (TEN) */
|
||||||
|
|
||||||
|
clr.b Z16F_UART0_CTL1 /* Z16F_UART0_CTL1 = 0 */
|
||||||
|
ld r0, #(Z16F_UARTCTL0_TEN|Z16F_UARTCTL0_REN)
|
||||||
|
ld.b Z16F_UART0_CTL0, r0 /* Z16F_UART0_CTL0 = %c0 */
|
||||||
#endif
|
#endif
|
||||||
popmlo <r0, r3> /* Restore registers */
|
popmlo <r0, r3> /* Restore registers */
|
||||||
ret /* Return */
|
ret /* Return */
|
||||||
|
@ -650,38 +650,34 @@ int up_putc(int ch)
|
|||||||
|
|
||||||
#ifdef CONFIG_UART1_SERIAL_CONSOLE
|
#ifdef CONFIG_UART1_SERIAL_CONSOLE
|
||||||
# define z16f_contrde() \
|
# define z16f_contrde() \
|
||||||
do { \
|
((getreg8(Z16F_UART1_STAT0) & Z16F_UARTSTAT0_TDRE) != 0)
|
||||||
int tmp; \
|
|
||||||
for (tmp = 1000 ; tmp > 0 ; tmp--) \
|
|
||||||
if ((getreg8(Z16F_UART1_STAT0) & Z16F_UARTSTAT0_TDRE) != 0) \
|
|
||||||
break; \
|
|
||||||
} while (0)
|
|
||||||
# define z16f_contxd(ch) \
|
# define z16f_contxd(ch) \
|
||||||
putreg8((ubyte)(ch), Z16F_UART1_STAT0)
|
putreg8((ubyte)(ch), Z16F_UART1_TXD)
|
||||||
#else
|
#else
|
||||||
# define z16f_contrde() \
|
# define z16f_contrde() \
|
||||||
do { \
|
((getreg8(Z16F_UART0_STAT0) & Z16F_UARTSTAT0_TDRE) != 0)
|
||||||
int tmp; \
|
|
||||||
for (tmp = 1000 ; tmp > 0 ; tmp--) \
|
|
||||||
if ((getreg8(Z16F_UART0_STAT0) & Z16F_UARTSTAT0_TDRE) != 0) \
|
|
||||||
break; \
|
|
||||||
} while (0)
|
|
||||||
# define z16f_contxd(ch) \
|
# define z16f_contxd(ch) \
|
||||||
putreg8((ubyte)(ch), Z16F_UART0_STAT0)
|
putreg8((ubyte)(ch), Z16F_UART0_TXD)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void _up_putc(int ch)
|
||||||
|
{
|
||||||
|
int tmp;
|
||||||
|
for (tmp = 1000 ; tmp > 0 && !z16f_contrde(); tmp--);
|
||||||
|
z16f_contxd(ch);
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int up_putc(int ch)
|
int up_putc(int ch)
|
||||||
{
|
{
|
||||||
z16f_contrde();
|
_up_putc(ch);
|
||||||
z16f_contxd(ch);
|
|
||||||
|
|
||||||
/* Check for LF */
|
/* Check for LF */
|
||||||
|
|
||||||
@ -689,8 +685,7 @@ int up_putc(int ch)
|
|||||||
{
|
{
|
||||||
/* Add CR */
|
/* Add CR */
|
||||||
|
|
||||||
z16f_contrde();
|
_up_putc('\r');
|
||||||
z16f_contxd('\r');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ch;
|
return ch;
|
||||||
|
Loading…
Reference in New Issue
Block a user