diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-11-20 20:32:33 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-11-20 20:32:33 +0000 |
commit | 78dd0de872d9bef518f3ef395b4913197e1b2077 (patch) | |
tree | 0af928d900e8e43c520f6b06248eb84177b6a56e /nuttx/arch/arm/src/dm320/dm320_serial.c | |
parent | 93c4e0321431ad4164eb37c26c532d187d0aa1ab (diff) | |
download | px4-nuttx-78dd0de872d9bef518f3ef395b4913197e1b2077.tar.gz px4-nuttx-78dd0de872d9bef518f3ef395b4913197e1b2077.tar.bz2 px4-nuttx-78dd0de872d9bef518f3ef395b4913197e1b2077.zip |
Several webserver bugs fixed
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@391 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/dm320/dm320_serial.c')
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_serial.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/nuttx/arch/arm/src/dm320/dm320_serial.c b/nuttx/arch/arm/src/dm320/dm320_serial.c index 8051393cf..c74264b8d 100644 --- a/nuttx/arch/arm/src/dm320/dm320_serial.c +++ b/nuttx/arch/arm/src/dm320/dm320_serial.c @@ -38,20 +38,25 @@ ************************************************************/ #include <nuttx/config.h> + #include <sys/types.h> #include <unistd.h> #include <semaphore.h> #include <string.h> #include <errno.h> #include <debug.h> + #include <nuttx/irq.h> #include <nuttx/arch.h> #include <nuttx/serial.h> #include <arch/serial.h> + #include "up_arch.h" #include "os_internal.h" #include "up_internal.h" +#if CONFIG_NFILE_DESCRIPTORS > 0 + /************************************************************ * Definitions ************************************************************/ @@ -723,3 +728,59 @@ int up_putc(int ch) return ch; } +#else /* CONFIG_NFILE_DESCRIPTORS > 0 */ + +/************************************************************ + * Definitions + ************************************************************/ + +# ifdef CONFIG_UART1_SERIAL_CONSOLE +# define DM320_REGISTER_BASE DM320_UART1_REGISTER_BASE +# else +# define DM320_REGISTER_BASE DM320_UART0_REGISTER_BASE +# endif + +/************************************************************ + * Private Functions + ************************************************************/ + +static inline void up_waittxfifonotfull(void) +{ + int tmp; + + for (tmp = 1000 ; tmp > 0 ; tmp--) + { + + if ((getreg16(DM320_REGISTER_BASE + UART_SR) & UART_SR_TFTI) != 0) + { + break; + } + } +} + +/************************************************************ + * Public Functions + ************************************************************/ + +int up_putc(int ch) +{ + up_waittxfifonotfull(); + putreg16((uint16)ch, DM320_REGISTER_BASE + UART_DTRR); + + /* Check for LF */ + + if (ch == '\n') + { + /* Add CR */ + + up_waittxfifonotfull(); + putreg16((uint16)'\r', DM320_REGISTER_BASE + UART_DTRR); + } + + up_waittxfifonotfull(); + return ch; +} + +#endif /* CONFIG_NFILE_DESCRIPTORS > 0 */ + + |