diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-03-25 14:34:07 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-03-25 14:34:07 -0600 |
commit | c3ea6bd31639784c4dc140b8c30b7aa83dfb7b0f (patch) | |
tree | 4d153efa2e625cede4b4e24afeb1521840d63b25 | |
parent | aa0fec3cd5a0c94b037ef9c15019a865a2ff2d0b (diff) | |
download | px4-nuttx-c3ea6bd31639784c4dc140b8c30b7aa83dfb7b0f.tar.gz px4-nuttx-c3ea6bd31639784c4dc140b8c30b7aa83dfb7b0f.tar.bz2 px4-nuttx-c3ea6bd31639784c4dc140b8c30b7aa83dfb7b0f.zip |
backport a serial console fix from the sam4e to the sama5d3
-rw-r--r-- | nuttx/arch/arm/src/sam34/sam_lowputc.c | 6 | ||||
-rw-r--r-- | nuttx/arch/arm/src/sama5/sam_lowputc.c | 56 | ||||
-rw-r--r-- | nuttx/arch/arm/src/sama5/sam_serial.c | 86 | ||||
-rw-r--r-- | nuttx/configs/sam4e-ek/README.txt | 18 |
4 files changed, 70 insertions, 96 deletions
diff --git a/nuttx/arch/arm/src/sam34/sam_lowputc.c b/nuttx/arch/arm/src/sam34/sam_lowputc.c index d669fdd4a..b5f1aa4e6 100644 --- a/nuttx/arch/arm/src/sam34/sam_lowputc.c +++ b/nuttx/arch/arm/src/sam34/sam_lowputc.c @@ -285,14 +285,16 @@ void up_lowputc(char ch) { /* Wait for the transmitter to be available */ - while ((getreg32(SAM_CONSOLE_BASE + SAM_UART_SR_OFFSET) & UART_INT_TXEMPTY) == 0); + while ((getreg32(SAM_CONSOLE_BASE + SAM_UART_SR_OFFSET) & + UART_INT_TXEMPTY) == 0); /* Disable interrupts so that the test and the transmission are * atomic. */ flags = irqsave(); - if ((getreg32(SAM_CONSOLE_BASE + SAM_UART_SR_OFFSET) & UART_INT_TXEMPTY) != 0) + if ((getreg32(SAM_CONSOLE_BASE + SAM_UART_SR_OFFSET) & + UART_INT_TXEMPTY) != 0) { /* Send the character */ diff --git a/nuttx/arch/arm/src/sama5/sam_lowputc.c b/nuttx/arch/arm/src/sama5/sam_lowputc.c index 3154fa80c..ea8a3b070 100644 --- a/nuttx/arch/arm/src/sama5/sam_lowputc.c +++ b/nuttx/arch/arm/src/sama5/sam_lowputc.c @@ -247,13 +247,59 @@ void up_lowputc(char ch) { - /* Wait for the transmitter to be available */ +#ifdef HAVE_CONSOLE + irqstate_t flags; - while ((getreg32(SAM_CONSOLE_VBASE + SAM_UART_SR_OFFSET) & UART_INT_TXEMPTY) == 0); + for (;;) + { + /* Wait for the transmitter to be available */ - /* Send the character */ + while (((getreg32(SAM_CONSOLE_VBASE + SAM_UART_SR_OFFSET) & + UART_INT_TXEMPTY) == 0); - putreg32((uint32_t)ch, SAM_CONSOLE_VBASE + SAM_UART_THR_OFFSET); + /* Disable interrupts so that the test and the transmission are + * atomic. + */ + + flags = irqsave(); + if ((getreg32(SAM_CONSOLE_VBASE + SAM_UART_SR_OFFSET) & + UART_INT_TXEMPTY) != 0) + { + /* Send the character */ + + putreg32((uint32_t)ch, SAM_CONSOLE_VBASE + SAM_UART_THR_OFFSET); + irqrestore(flags); + return; + } + + irqrestore(flags); + } +#endif +} + +/**************************************************************************** + * Name: up_putc + * + * Description: + * Provide priority, low-level access to support OS debug writes + * + ****************************************************************************/ + +int up_putc(int ch) +{ +#ifdef HAVE_CONSOLE + /* Check for LF */ + + if (ch == '\n') + { + /* Add CR */ + + up_lowputc('\r'); + } + + up_lowputc(ch); +#endif + return ch; } /************************************************************************** @@ -373,5 +419,3 @@ void sam_lowsetup(void) SAM_CONSOLE_VBASE + SAM_UART_CR_OFFSET); #endif } - - diff --git a/nuttx/arch/arm/src/sama5/sam_serial.c b/nuttx/arch/arm/src/sama5/sam_serial.c index 541dc01d3..0cd1ac681 100644 --- a/nuttx/arch/arm/src/sama5/sam_serial.c +++ b/nuttx/arch/arm/src/sama5/sam_serial.c @@ -1189,90 +1189,4 @@ void up_serialinit(void) #endif } -/**************************************************************************** - * Name: up_putc - * - * Description: - * Provide priority, low-level access to support OS debug writes. This - * function is intended only to support early boot-up logic and serial - * debug output from interrupt handlers. It is invasive and will effect - * your realtime performance! - * - ****************************************************************************/ - -int up_putc(int ch) -{ -#ifdef HAVE_CONSOLE - /* This logic does not work. Apparently re-entrancy problems cause the - * loss of serial interrupts (a bad, zero IMR gets set). My attempts to - * make this function fully re-entrant have not been successful but the - * following brute force approach works just fine. - */ - -#if 0 - struct up_dev_s *priv = (struct up_dev_s*)CONSOLE_DEV.priv; - uint32_t imr; - - /* Disable serial interrupts */ - - up_disableallints(priv, &imr); -#else - irqstate_t flags; - - /* Disable all interrupts */ - - flags = irqsave(); -#endif - - /* Check for LF */ - - if (ch == '\n') - { - /* Add CR */ - - up_lowputc('\r'); - } - - up_lowputc(ch); - -#if 0 /* See comments above */ - /* Restore serial interrupts */ - - up_restoreusartint(priv, imr); -#else - /* Restore all interrupts */ - - irqrestore(flags); -#endif -#endif - return ch; -} - -#else /* USE_SERIALDRIVER */ - -/**************************************************************************** - * Name: up_putc - * - * Description: - * Provide priority, low-level access to support OS debug writes - * - ****************************************************************************/ - -int up_putc(int ch) -{ -#ifdef HAVE_CONSOLE - /* Check for LF */ - - if (ch == '\n') - { - /* Add CR */ - - up_lowputc('\r'); - } - - up_lowputc(ch); -#endif - return ch; -} - #endif /* USE_SERIALDRIVER */ diff --git a/nuttx/configs/sam4e-ek/README.txt b/nuttx/configs/sam4e-ek/README.txt index 720566adf..25438c6ef 100644 --- a/nuttx/configs/sam4e-ek/README.txt +++ b/nuttx/configs/sam4e-ek/README.txt @@ -660,7 +660,8 @@ USB Full-Speed Device b. If you change the value CONFIG_SYSTEM_USBMSC_DEVPATH1, then you can export other file systems: - "/dev/mmcsd0" would export the HSMCI SD slot + "/dev/mmcsd0" would export the HSMCI SD slot (not currently available, + see the "HSMCI" section). "/dev/ram0" could even be used to export a RAM disk. But you would first have to use mkrd to create the RAM disk and mkfatfs to put @@ -781,6 +782,14 @@ HSMCI The SD card contents will then be available under /mnt/sdcard. + NOTES: + + 1. DMA is not currently functional and without DMA, there may not be + reliable data transfers at high speeds due to data overrun problems. + The current HSMCI driver supports DMA via the DMAC. However, the data + sheet only discusses PDC-based HSMCI DMA (although there is a DMA + channel interface definition for HSMCI). + Touchscreen =========== @@ -1171,7 +1180,12 @@ Configurations instructions provided above in the paragraph entitled "HSMCI." STATUS: - 2014-3-21: The HSMCI SD card slot has not yet been tested. + 2014-3-24: DMA is not currently functional and without DMA, there + may not be reliable data transfers at high speeds due + to data overrun problems. The current HSMCI driver + supports DMA via the DMAC. However, the data sheet + only discusses PDC-based HSMCI DMA (although there is + a DMA channel interface definition for HSMCI). usbnsh: |