diff --git a/configs/sam4s-xplained-pro/nsh/defconfig b/configs/sam4s-xplained-pro/nsh/defconfig index e25f354db1..a9a10ce49a 100644 --- a/configs/sam4s-xplained-pro/nsh/defconfig +++ b/configs/sam4s-xplained-pro/nsh/defconfig @@ -50,6 +50,7 @@ CONFIG_ARCH_HAVE_STACKCHECK=y # # CONFIG_DEBUG_MM is not set # CONFIG_DEBUG_SCHED is not set +# CONFIG_DEBUG_USB is not set # CONFIG_DEBUG_FS is not set # CONFIG_DEBUG_LIB is not set # CONFIG_DEBUG_BINFMT is not set @@ -67,6 +68,7 @@ CONFIG_DEBUG_STACK=y # CONFIG_DEBUG_DMA is not set # CONFIG_DEBUG_RTC is not set # CONFIG_DEBUG_WATCHDOG is not set +# CONFIG_DEBUG_TIMER is not set # CONFIG_DEBUG_AUDIO is not set CONFIG_DEBUG_SYMBOLS=y CONFIG_ARCH_HAVE_CUSTOMOPT=y @@ -209,7 +211,7 @@ CONFIG_SAM34_RTC=y CONFIG_SAM34_SMC=y # CONFIG_SAM34_SPI0 is not set # CONFIG_SAM34_SSC is not set -# CONFIG_SAM34_TC0 is not set +CONFIG_SAM34_TC0=y # CONFIG_SAM34_TC1 is not set # CONFIG_SAM34_TC2 is not set # CONFIG_SAM34_TC3 is not set @@ -221,7 +223,7 @@ CONFIG_SAM34_SMC=y # CONFIG_SAM34_TWIS1 is not set CONFIG_SAM34_UART0=y CONFIG_SAM34_UART1=y -# CONFIG_SAM34_UDP is not set +CONFIG_SAM34_UDP=y # CONFIG_SAM34_USART0 is not set CONFIG_SAM34_USART1=y CONFIG_SAM34_WDT=y @@ -246,20 +248,25 @@ CONFIG_SAM34_GPIOC_IRQ=y # # AT91SAM3/4 HSMCI device driver options # -CONFIG_SAM34_HSMCI_RDPROOF=y -CONFIG_SAM34_HSMCI_WRPROOF=y +# CONFIG_SAM34_HSMCI_RDPROOF is not set +# CONFIG_SAM34_HSMCI_WRPROOF is not set + +# +# AT91SAM3/4 USB Full Speed Device Controller driver (DCD) options +# +# CONFIG_SAM34_UDP_REGDEBUG is not set # # AT91SAM3/4 Watchdog Configuration # CONFIG_WDT_ENABLED_ON_RESET=y # CONFIG_WDT_DISABLE_ON_RESET is not set -CONFIG_WDT_TIMEOUT=4000 -CONFIG_WDT_MINTIME=2000 +CONFIG_WDT_TIMEOUT=5000 +CONFIG_WDT_MINTIME=2500 CONFIG_WDT_THREAD=y CONFIG_WDT_THREAD_NAME="wdog" -CONFIG_WDT_THREAD_INTERVAL=2000 -CONFIG_WDT_THREAD_PRIORITY=220 +CONFIG_WDT_THREAD_INTERVAL=2500 +CONFIG_WDT_THREAD_PRIORITY=200 CONFIG_WDT_THREAD_STACKSIZE=512 # @@ -431,7 +438,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=4096 # # Device Drivers # -# CONFIG_DISABLE_POLL is not set +CONFIG_DISABLE_POLL=y CONFIG_DEV_NULL=y CONFIG_DEV_ZERO=y # CONFIG_LOOP is not set @@ -448,6 +455,7 @@ CONFIG_RTC_DATETIME=y CONFIG_RTC_ALARM=y CONFIG_WATCHDOG=y CONFIG_WATCHDOG_DEVPATH="/dev/watchdog0" +CONFIG_TIMER=y # CONFIG_ANALOG is not set # CONFIG_AUDIO_DEVICES is not set # CONFIG_VIDEO_DEVICES is not set @@ -473,6 +481,7 @@ CONFIG_PIPES=y # CONFIG_SERCOMM_CONSOLE is not set CONFIG_SERIAL=y # CONFIG_DEV_LOWCONSOLE is not set +CONFIG_SERIAL_REMOVABLE=y # CONFIG_16550_UART is not set # CONFIG_ARCH_HAVE_UART is not set CONFIG_ARCH_HAVE_UART0=y @@ -502,7 +511,6 @@ CONFIG_ARCH_HAVE_USART1=y CONFIG_USART1_ISUART=y CONFIG_MCU_SERIAL=y CONFIG_STANDARD_SERIAL=y -CONFIG_SERIAL_NPOLLWAITERS=2 # CONFIG_SERIAL_TIOCSERGSTRUCT is not set CONFIG_UART0_SERIAL_CONSOLE=y # CONFIG_UART1_SERIAL_CONSOLE is not set @@ -546,7 +554,48 @@ CONFIG_USART1_2STOP=0 # CONFIG_USART1_OFLOWCONTROL is not set # CONFIG_SERIAL_IFLOWCONTROL is not set # CONFIG_SERIAL_OFLOWCONTROL is not set -# CONFIG_USBDEV is not set +CONFIG_USBDEV=y + +# +# USB Device Controller Driver Options +# +# CONFIG_USBDEV_ISOCHRONOUS is not set +# CONFIG_USBDEV_DUALSPEED is not set +CONFIG_USBDEV_SELFPOWERED=y +# CONFIG_USBDEV_BUSPOWERED is not set +CONFIG_USBDEV_MAXPOWER=100 +# CONFIG_USBDEV_DMA is not set +CONFIG_ARCH_USBDEV_STALLQUEUE=y +# CONFIG_USBDEV_TRACE is not set + +# +# USB Device Class Driver Options +# +# CONFIG_USBDEV_COMPOSITE is not set +# CONFIG_PL2303 is not set +CONFIG_CDCACM=y +CONFIG_CDCACM_DEVMINOR=0 +# CONFIG_CDCACM_CONSOLE is not set +CONFIG_CDCACM_EP0MAXPACKET=64 +CONFIG_CDCACM_EPINTIN=1 +CONFIG_CDCACM_EPINTIN_FSSIZE=64 +CONFIG_CDCACM_EPINTIN_HSSIZE=64 +CONFIG_CDCACM_EPBULKOUT=3 +CONFIG_CDCACM_EPBULKOUT_FSSIZE=64 +CONFIG_CDCACM_EPBULKOUT_HSSIZE=512 +CONFIG_CDCACM_EPBULKIN=2 +CONFIG_CDCACM_EPBULKIN_FSSIZE=64 +CONFIG_CDCACM_EPBULKIN_HSSIZE=512 +CONFIG_CDCACM_NWRREQS=4 +CONFIG_CDCACM_NRDREQS=4 +CONFIG_CDCACM_BULKIN_REQLEN=250 +CONFIG_CDCACM_RXBUFSIZE=1024 +CONFIG_CDCACM_TXBUFSIZE=1024 +CONFIG_CDCACM_VENDORID=0x0525 +CONFIG_CDCACM_PRODUCTID=0xa4a7 +CONFIG_CDCACM_VENDORSTR="NuttX" +CONFIG_CDCACM_PRODUCTSTR="CDC/ACM Serial" +# CONFIG_USBMSC is not set # CONFIG_USBHOST is not set # CONFIG_WIRELESS is not set @@ -639,8 +688,8 @@ CONFIG_BUILTIN=y # # Standard C Library Options # -CONFIG_STDIO_BUFFER_SIZE=0 -# CONFIG_STDIO_LINEBUFFER is not set +CONFIG_STDIO_BUFFER_SIZE=256 +CONFIG_STDIO_LINEBUFFER=y CONFIG_NUNGET_CHARS=2 # CONFIG_LIBM is not set # CONFIG_NOPRINTF_FIELDWIDTH is not set @@ -733,6 +782,7 @@ CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y # CONFIG_EXAMPLES_ROMFS is not set # CONFIG_EXAMPLES_SENDMAIL is not set CONFIG_EXAMPLES_SERIALBLASTER=y +CONFIG_EXAMPLES_SERIALRX=y # CONFIG_EXAMPLES_SERLOOP is not set # CONFIG_EXAMPLES_SLCD is not set # CONFIG_EXAMPLES_SMART_TEST is not set @@ -856,10 +906,12 @@ CONFIG_NSH_NESTDEPTH=3 # CONFIG_NSH_DISABLE_LOOPS is not set # CONFIG_NSH_DISABLEBG is not set CONFIG_NSH_CONSOLE=y +# CONFIG_NSH_USBCONSOLE is not set # # USB Trace Support # +# CONFIG_NSH_USBDEV_TRACE is not set CONFIG_NSH_CONDEV="/dev/console" CONFIG_NSH_ARCHINIT=y @@ -933,7 +985,7 @@ CONFIG_READLINE_ECHO=y # # SD Card # -CONFIG_SYSTEM_SDCARD=y +# CONFIG_SYSTEM_SDCARD is not set # # Sysinfo @@ -957,6 +1009,7 @@ CONFIG_SYSTEM_STACKMONITOR_INTERVAL=2 # # USB CDC/ACM Device Commands # +# CONFIG_SYSTEM_CDCACM is not set # # USB Composite Device Commands diff --git a/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h b/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h index e4a6fc4ca1..fbc9391565 100644 --- a/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h +++ b/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h @@ -57,7 +57,7 @@ #define HAVE_HSMCI 1 #define HAVE_PROC 1 -#define HAVE_USBDEV 0 +#define HAVE_USBDEV 1 #undef HAVE_USBMONITOR /* HSMCI */ @@ -95,7 +95,7 @@ * device. */ -#if !defined(CONFIG_SAM34_UDP) || !defined(CONFIG_USBDEV) +#if !defined(CONFIG_SAM34_UDP) || !defined(CONFIG_USBDEV) ||!defined(CONFIG_CDCACM) # undef HAVE_USBDEV #endif @@ -207,10 +207,8 @@ int sam_hsmci_initialize(void); * ************************************************************************************/ -#ifdef HAVE_HSMCI +#if defined(HAVE_HSMCI) && defined(CONFIG_MMCSD_HAVECARDDETECT) bool sam_cardinserted(int slotno); -#else -# define sam_cardinserted(slotno) (false) #endif /************************************************************************************ diff --git a/configs/sam4s-xplained-pro/src/sam_hsmci.c b/configs/sam4s-xplained-pro/src/sam_hsmci.c index 3d0e279d59..635bc22a90 100644 --- a/configs/sam4s-xplained-pro/src/sam_hsmci.c +++ b/configs/sam4s-xplained-pro/src/sam_hsmci.c @@ -83,14 +83,18 @@ static struct sam_hsmci_state_s g_hsmci; ****************************************************************************/ /**************************************************************************** - * Name: sam_hsmci_cardetect + * Name: sam_hsmci_cardetect_int * * Description: * Card detect interrupt handler * + * TODO: Any way to automatically moun/unmount filesystem based on card + * detect status? Yes... send a message or signal to an application. + * ****************************************************************************/ -static int sam_hsmci_cardetect(int irq, void *regs) +#ifdef CONFIG_MMCSD_HAVECARDDETECT +static int sam_hsmci_cardetect_int(int irq, void *regs) { bool inserted; @@ -100,7 +104,7 @@ static int sam_hsmci_cardetect(int irq, void *regs) /* Has the card detect state changed? */ - if (inserted == g_hsmci.inserted) + if (inserted != g_hsmci.inserted) { /* Yes... remember that new state and inform the HSMCI driver */ @@ -113,6 +117,7 @@ static int sam_hsmci_cardetect(int irq, void *regs) return OK; } +#endif /**************************************************************************** * Public Functions @@ -135,10 +140,6 @@ int sam_hsmci_initialize(void) if (!g_hsmci.initialized) { - /* Initialize card-detect GPIO. There is no write-protection GPIO. */ - - sam_configgpio(GPIO_MCI_CD); - /* Mount the SDIO-based MMC/SD block driver */ /* First, get an instance of the SDIO interface */ @@ -158,14 +159,21 @@ int sam_hsmci_initialize(void) return ret; } +#ifdef CONFIG_MMCSD_HAVECARDDETECT + /* Initialize card-detect GPIO. There is no write-protection GPIO. */ + + sam_configgpio(GPIO_MCI_CD); + /* Configure card detect interrupts */ sam_gpioirq(GPIO_MCI_CD); - (void)irq_attach(MCI_CD_IRQ, sam_hsmci_cardetect); - + (void)irq_attach(MCI_CD_IRQ, sam_hsmci_cardetect_int); + g_hsmci.inserted = sam_cardinserted(0); +#else + g_hsmci.inserted = true; /* An assumption? */ +#endif /* Then inform the HSMCI driver if there is or is not a card in the slot. */ - g_hsmci.inserted = sam_cardinserted(0); sdio_mediachange(g_hsmci.hsmci, g_hsmci.inserted); /* Now we are initialized */ @@ -174,7 +182,9 @@ int sam_hsmci_initialize(void) /* Enable card detect interrupts */ +#ifdef CONFIG_MMCSD_HAVECARDDETECT sam_gpioirqenable(MCI_CD_IRQ); +#endif } return OK; @@ -188,6 +198,7 @@ int sam_hsmci_initialize(void) * ****************************************************************************/ +#ifdef CONFIG_MMCSD_HAVECARDDETECT bool sam_cardinserted(int slotno) { bool removed; @@ -199,6 +210,7 @@ bool sam_cardinserted(int slotno) return !removed; } +#endif /**************************************************************************** * Name: sam_writeprotected diff --git a/configs/sam4s-xplained-pro/src/sam_nsh.c b/configs/sam4s-xplained-pro/src/sam_nsh.c index 60b1aee82e..8802d7f76d 100644 --- a/configs/sam4s-xplained-pro/src/sam_nsh.c +++ b/configs/sam4s-xplained-pro/src/sam_nsh.c @@ -101,10 +101,21 @@ int nsh_archinitialize(void) { -#if defined(HAVE_HSMCI) || defined (HAVE_PROC) || defined(HAVE_USBMONITOR) +#if defined (HAVE_USBDEV) || defined(HAVE_HSMCI) || defined (HAVE_PROC) || \ + defined(HAVE_USBMONITOR) int ret; #endif +#ifdef HAVE_USBDEV + message("Registering CDC/ACM serial driver\n"); + ret = cdcacm_initialize(CONFIG_CDCACM_DEVMINOR, NULL); + if (ret < 0) + { + message("ERROR: Failed to create the CDC/ACM serial device: %d\n", errno); + return ret; + } +#endif + #ifdef HAVE_HSMCI /* Initialize the HSMCI driver */ @@ -123,10 +134,26 @@ int nsh_archinitialize(void) message("Mounting procfs to /proc\n"); ret = mount(NULL, "/proc", "procfs", 0, NULL); if (ret < 0) - { - message("ERROR: Failed to mount the PROC filesystem: %d\n", errno); - return ret; - } + { + message("ERROR: Failed to mount the PROC filesystem: %d\n", errno); + return ret; + } +#endif + +#if HAVE_HSMCI + message("Mounting /dev/mmcsd0 to /fat\n"); + ret = mount("/dev/mmcsd0", "/fat", "vfat", 0, NULL); + if (ret < 0) + { + message("ERROR: Failed to mount the FAT filesystem: %d\n", errno); + return ret; + } +#endif + +#ifdef CONFIG_TIMER + /* Registers the timer driver and starts an async interrupt. */ + + up_timerinitialize(); #endif #ifdef HAVE_USBMONITOR @@ -141,19 +168,5 @@ int nsh_archinitialize(void) } #endif - message("Mounting /dev/mmcsd0 to /fat\n"); - ret = mount("/dev/mmcsd0", "/fat", "vfat", 0, NULL); - if (ret < 0) - { - message("ERROR: Failed to mount the FAT filesystem: %d\n", errno); - return ret; - } - -#ifdef CONFIG_TIMER - /* Registers the timer driver and starts an async interrupt. */ - - up_timerinitialize(); -#endif - return OK; } diff --git a/configs/sam4s-xplained-pro/src/sam_wdt.c b/configs/sam4s-xplained-pro/src/sam_wdt.c index e78a12023f..a54d447010 100644 --- a/configs/sam4s-xplained-pro/src/sam_wdt.c +++ b/configs/sam4s-xplained-pro/src/sam_wdt.c @@ -61,7 +61,7 @@ * Definitions ************************************************************************************/ /* Configuration *******************************************************************/ -/* Wathdog hardware should be enabled */ +/* Watchdog hardware should be enabled */ #if !defined(CONFIG_SAM34_WDT) # warning "CONFIG_SAM34_WDT must be defined" @@ -77,6 +77,10 @@ # endif #endif +#if (CONFIG_WDT_THREAD_INTERVAL < CONFIG_WDT_MINTIME) +# error "WDT_THREAD_INTERVAL must be greater than or equal to WDT_MINTIME" +#endif + /* Debug ***************************************************************************/ /* Non-standard debug that may be enabled just for testing the watchdog timer */ @@ -109,10 +113,8 @@ * Public Functions ************************************************************************************/ +/* Watchdog kicker task */ -/* -Watchdog kicker task -*/ #if defined(CONFIG_WDT_THREAD) static int wdog_daemon(int argc, char *argv[]) { @@ -172,7 +174,6 @@ errout: int up_wdginitialize(void) { - #if (defined(CONFIG_SAM34_WDT) && !defined(CONFIG_WDT_DISABLE_ON_RESET)) int fd; int ret;