summaryrefslogtreecommitdiff
path: root/nuttx/configs/sam4s-xplained-pro/src
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-04-22 09:38:46 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-04-22 09:38:46 -0600
commit3186036d92f495768edf903135ad737728e6a5b7 (patch)
treee3da765af16fa6d5c599ed16bd8c12e4679a78f2 /nuttx/configs/sam4s-xplained-pro/src
parent180c5eab363381c8feb8025409787fdefebd5a08 (diff)
downloadnuttx-3186036d92f495768edf903135ad737728e6a5b7.tar.gz
nuttx-3186036d92f495768edf903135ad737728e6a5b7.tar.bz2
nuttx-3186036d92f495768edf903135ad737728e6a5b7.zip
SAM4X Xplained Pro board configuration updated by Bob Doison
Diffstat (limited to 'nuttx/configs/sam4s-xplained-pro/src')
-rw-r--r--nuttx/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h8
-rw-r--r--nuttx/configs/sam4s-xplained-pro/src/sam_hsmci.c32
-rw-r--r--nuttx/configs/sam4s-xplained-pro/src/sam_nsh.c49
-rw-r--r--nuttx/configs/sam4s-xplained-pro/src/sam_wdt.c11
4 files changed, 62 insertions, 38 deletions
diff --git a/nuttx/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h b/nuttx/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h
index e4a6fc4ca..fbc939156 100644
--- a/nuttx/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h
+++ b/nuttx/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/nuttx/configs/sam4s-xplained-pro/src/sam_hsmci.c b/nuttx/configs/sam4s-xplained-pro/src/sam_hsmci.c
index 3d0e279d5..635bc22a9 100644
--- a/nuttx/configs/sam4s-xplained-pro/src/sam_hsmci.c
+++ b/nuttx/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/nuttx/configs/sam4s-xplained-pro/src/sam_nsh.c b/nuttx/configs/sam4s-xplained-pro/src/sam_nsh.c
index 60b1aee82..8802d7f76 100644
--- a/nuttx/configs/sam4s-xplained-pro/src/sam_nsh.c
+++ b/nuttx/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,31 +134,21 @@ 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;
- }
-#endif
-
-#ifdef HAVE_USBMONITOR
- /* Start the USB Monitor */
-
- message("Starting USB Monitor\n");
- ret = usbmonitor_start(0, NULL);
- if (ret != OK)
{
- message("nsh_archinitialize: Start USB monitor: %d\n", 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;
- }
+ {
+ 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. */
@@ -155,5 +156,17 @@ int nsh_archinitialize(void)
up_timerinitialize();
#endif
+#ifdef HAVE_USBMONITOR
+ /* Start the USB Monitor */
+
+ message("Starting USB Monitor\n");
+ ret = usbmonitor_start(0, NULL);
+ if (ret != OK)
+ {
+ message("nsh_archinitialize: Start USB monitor: %d\n", ret);
+ return ret;
+ }
+#endif
+
return OK;
}
diff --git a/nuttx/configs/sam4s-xplained-pro/src/sam_wdt.c b/nuttx/configs/sam4s-xplained-pro/src/sam_wdt.c
index e78a12023..a54d44701 100644
--- a/nuttx/configs/sam4s-xplained-pro/src/sam_wdt.c
+++ b/nuttx/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;