diff --git a/Documentation/README.html b/Documentation/README.html index 8b33f7bae7a..a56293cc6ad 100644 --- a/Documentation/README.html +++ b/Documentation/README.html @@ -8,7 +8,7 @@
Last Updated: November 13, 2017
+Last Updated: November 18, 2017
+ *
+ * Based on configs/lpc1720g-eval/src/lpc17_adc.c
+ *
+ * Copyright (C) 2012, 2014, 2016-2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+
+#include
+#include
+
+#include
+#include
+#include
+
+#include "chip.h"
+#include "up_arch.h"
+
+#include "lpc17_adc.h"
+#include "mcb1700.h"
+
+#ifdef CONFIG_ADC
+
+/************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Name: mcb1700_adc_setup
+ *
+ * Description:
+ * Initialize ADC and register the ADC driver.
+ *
+ ************************************************************************************/
+
+int mcb1700_adc_setup(void)
+{
+ static bool initialized = false;
+ struct adc_dev_s *adc;
+ int ret;
+
+ /* Check if we have already initialized */
+
+ if (!initialized)
+ {
+ /* Call lpc17_adcinitialize() to get an instance of the ADC interface */
+
+ adc = lpc17_adcinitialize();
+ if (adc == NULL)
+ {
+ aerr("ERROR: Failed to get ADC interface\n");
+ return -ENODEV;
+ }
+
+ /* Register the ADC driver at "/dev/adc0" */
+
+ ret = adc_register("/dev/adc0", adc);
+ if (ret < 0)
+ {
+ aerr("ERROR: adc_register failed: %d\n", ret);
+ return ret;
+ }
+
+ /* Now we are initialized */
+
+ initialized = true;
+ }
+
+ return OK;
+}
+
+#endif /* CONFIG_ADC */
diff --git a/configs/mcb1700/src/lpc17_appinit.c b/configs/mcb1700/src/lpc17_appinit.c
new file mode 100644
index 00000000000..527f447b783
--- /dev/null
+++ b/configs/mcb1700/src/lpc17_appinit.c
@@ -0,0 +1,94 @@
+/****************************************************************************
+ * config/mcb1700/src/lpc17_appinit.c
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+
+#include "mcb1700.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef OK
+# define OK 0
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_app_initialize
+ *
+ * Description:
+ * Perform application specific initialization. This function is never
+ * called directly from application code, but only indirectly via the
+ * (non-standard) boardctl() interface using the command BOARDIOC_INIT.
+ *
+ * Input Parameters:
+ * arg - The boardctl() argument is passed to the board_app_initialize()
+ * implementation without modification. The argument has no
+ * meaning to NuttX; the meaning of the argument is a contract
+ * between the board-specific initalization logic and the
+ * matching application logic. The value cold be such things as a
+ * mode enumeration value, a set of DIP switch switch settings, a
+ * pointer to configuration data read from a file or serial FLASH,
+ * or whatever you would like to do with it. Every implementation
+ * should accept zero/NULL as a default configuration.
+ *
+ * Returned Value:
+ * Zero (OK) is returned on success; a negated errno value is returned on
+ * any failure to indicate the nature of the failure.
+ *
+ ****************************************************************************/
+
+int board_app_initialize(uintptr_t arg)
+{
+#ifdef CONFIG_BOARD_INITIALIZE
+ /* Board initialization already performed by board_initialize() */
+
+ return OK;
+#else
+ /* Perform board-specific initialization */
+
+ return mcb1700_bringup();
+#endif
+}
diff --git a/configs/mcb1700/src/lpc17_boot.c b/configs/mcb1700/src/lpc17_boot.c
new file mode 100644
index 00000000000..3e3f9396043
--- /dev/null
+++ b/configs/mcb1700/src/lpc17_boot.c
@@ -0,0 +1,95 @@
+/************************************************************************************
+ * configs/mcb1700/src/lpc17_boot.c
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+
+#include
+
+#include
+#include
+
+#include "up_arch.h"
+#include "up_internal.h"
+
+#include "mcb1700.h"
+
+/************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Name: lpc17_boardinitialize
+ *
+ * Description:
+ * All LPC17xx architectures must provide the following entry point. This entry point
+ * is called early in the intitialization -- after all memory has been configured
+ * and mapped but before any devices have been initialized.
+ *
+ ************************************************************************************/
+
+void lpc17_boardinitialize(void)
+{
+#ifdef CONFIG_ARCH_LEDS
+ /* Configure on-board LEDs if LED support has been selected. */
+
+ board_autoled_initialize();
+#endif
+}
+
+/****************************************************************************
+ * Name: board_initialize
+ *
+ * Description:
+ * If CONFIG_BOARD_INITIALIZE is selected, then an additional
+ * initialization call will be performed in the boot-up sequence to a
+ * function called board_initialize(). board_initialize() will be
+ * called immediately after up_initialize() is called and just before the
+ * initial application is started. This additional initialization phase
+ * may be used, for example, to initialize board-specific device drivers.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_BOARD_INITIALIZE
+void board_initialize(void)
+{
+ /* Perform board-specific initialization */
+
+ (void)mcb1700_bringup();
+}
+#endif
diff --git a/configs/mcb1700/src/lpc17_bringup.c b/configs/mcb1700/src/lpc17_bringup.c
new file mode 100644
index 00000000000..6b5da0d75ee
--- /dev/null
+++ b/configs/mcb1700/src/lpc17_bringup.c
@@ -0,0 +1,375 @@
+/****************************************************************************
+ * config/mcb1700/src/lpc17_bringup.c
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+#include "lpc17_ssp.h"
+#include "lpc17_gpio.h"
+#include "lpc17_usbhost.h"
+
+#include "mcb1700.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Configuration ************************************************************/
+
+#define HAVE_MMCSD 1
+#define HAVE_USBHOST 1
+
+/* MMC/SD is on SSP port 1. There is only a single slot, slot 0 */
+
+#ifdef CONFIG_NSH_ARCHINIT
+# if !defined(CONFIG_NSH_MMCSDSPIPORTNO) || CONFIG_NSH_MMCSDSPIPORTNO != 1
+# undef CONFIG_NSH_MMCSDSPIPORTNO
+# define CONFIG_NSH_MMCSDSPIPORTNO 1
+# endif
+
+# if !defined(CONFIG_NSH_MMCSDSLOTNO) || CONFIG_NSH_MMCSDSLOTNO != 0
+# undef CONFIG_NSH_MMCSDSLOTNO
+# define CONFIG_NSH_MMCSDSLOTNO 0
+# endif
+
+# ifndef CONFIG_NSH_MMCSDMINOR
+# define CONFIG_NSH_MMCSDMINOR 0
+# endif
+
+#else
+# undef CONFIG_NSH_MMCSDSPIPORTNO
+# define CONFIG_NSH_MMCSDSPIPORTNO 1
+# undef CONFIG_NSH_MMCSDSLOTNO
+# define CONFIG_NSH_MMCSDSLOTNO 0
+# undef CONFIG_NSH_MMCSDMINOR
+# define CONFIG_NSH_MMCSDMINOR 0
+#endif
+
+/* Can't support MMC/SD is SSP1 is not enabled */
+
+#ifndef CONFIG_LPC17_SSP1
+# undef HAVE_MMCSD
+#endif
+
+/* Can't support MMC/SD features if mountpoints are disabled */
+
+#if defined(CONFIG_DISABLE_MOUNTPOINT)
+# undef HAVE_MMCSD
+#endif
+
+/* USB Host */
+
+#ifdef CONFIG_USBHOST
+# ifndef CONFIG_LPC17_USBHOST
+# error "CONFIG_LPC17_USBHOST is not selected"
+# endif
+#endif
+
+#ifdef CONFIG_LPC17_USBHOST
+# ifndef CONFIG_USBHOST
+# warning "CONFIG_USBHOST is not selected"
+# endif
+#endif
+
+#if !defined(CONFIG_USBHOST) || !defined(CONFIG_LPC17_USBHOST)
+# undef HAVE_USBHOST
+#endif
+
+#ifdef HAVE_USBHOST
+# ifndef CONFIG_MCB1700_USBHOST_PRIO
+# define CONFIG_MCB1700_USBHOST_PRIO 50
+# endif
+# ifndef CONFIG_MCB1700_USBHOST_STACKSIZE
+# define CONFIG_MCB1700_USBHOST_STACKSIZE 1024
+# endif
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+#ifdef HAVE_USBHOST
+static struct usbhost_connection_s *g_usbconn;
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nsh_waiter
+ *
+ * Description:
+ * Wait for USB devices to be connected.
+ *
+ ****************************************************************************/
+
+#ifdef HAVE_USBHOST
+static int nsh_waiter(int argc, char *argv[])
+{
+ struct usbhost_hubport_s *hport;
+
+ syslog(LOG_INFO, "nsh_waiter: Running\n");
+ for (;;)
+ {
+ /* Wait for the device to change state */
+
+ DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
+ syslog(LOG_INFO, "nsh_waiter: %s\n", hport->connected ? "connected" : "disconnected");
+
+ /* Did we just become connected? */
+
+ if (hport->connected)
+ {
+ /* Yes.. enumerate the newly connected device */
+
+ (void)CONN_ENUMERATE(g_usbconn, hport);
+ }
+ }
+
+ /* Keep the compiler from complaining */
+
+ return 0;
+}
+#endif
+
+/****************************************************************************
+ * Name: nsh_sdinitialize
+ *
+ * Description:
+ * Initialize SPI-based microSD.
+ *
+ ****************************************************************************/
+
+#ifdef HAVE_MMCSD
+static int nsh_sdinitialize(void)
+{
+ FAR struct spi_dev_s *ssp;
+ int ret;
+
+ /* Enable power to the SD/MMC via a GPIO. LOW enables SD/MMC. */
+
+ lpc17_gpiowrite(MCB1700_MMC_PWR, false);
+
+ /* Get the SSP port. MMC/SD is on SSP port 1. */
+
+ ssp = lpc17_sspbus_initialize(CONFIG_NSH_MMCSDSPIPORTNO);
+ if (!ssp)
+ {
+ syslog(LOG_ERR, "ERROR: Failed to initialize SSP port %d\n",
+ CONFIG_NSH_MMCSDSPIPORTNO);
+ ret = -ENODEV;
+ goto errout;
+ }
+
+ syslog(LOG_INFO, "Successfully initialized SSP port %d\n",
+ CONFIG_NSH_MMCSDSPIPORTNO);
+
+ /* Bind the SSP port to the slot */
+
+ ret = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR,
+ CONFIG_NSH_MMCSDSLOTNO, ssp);
+ if (ret < 0)
+ {
+ syslog(LOG_ERR,
+ "ERROR: Failed to bind SSP port %d to MMC/SD slot %d: %d\n",
+ CONFIG_NSH_MMCSDSPIPORTNO,
+ CONFIG_NSH_MMCSDSLOTNO, ret);
+ goto errout;
+ }
+
+ syslog(LOG_INFO, "Successfully bound SSP port %d to MMC/SD slot %d\n",
+ CONFIG_NSH_MMCSDSPIPORTNO,
+ CONFIG_NSH_MMCSDSLOTNO);
+ return OK;
+
+ /* Disable power to the SD/MMC via a GPIO. HIGH disables SD/MMC. */
+
+errout:
+ lpc17_gpiowrite(MCB1700_MMC_PWR, true);
+ return ret;
+}
+#else
+# define nsh_sdinitialize() (OK)
+#endif
+
+/****************************************************************************
+ * Name: nsh_usbhostinitialize
+ *
+ * Description:
+ * Initialize SPI-based microSD.
+ *
+ ****************************************************************************/
+
+#ifdef HAVE_USBHOST
+static int nsh_usbhostinitialize(void)
+{
+ int pid;
+ int ret;
+
+ /* First, register all of the class drivers needed to support the drivers
+ * that we care about:
+ */
+
+ syslog(LOG_INFO, "Register class drivers\n");
+
+#ifdef CONFIG_USBHOST_HUB
+ /* Initialize USB hub support */
+
+ ret = usbhost_hub_initialize();
+ if (ret < 0)
+ {
+ syslog(LOG_ERR, "ERROR: usbhost_hub_initialize failed: %d\n", ret);
+ }
+#endif
+
+#ifdef CONFIG_USBHOST_MSC
+ /* Initialize mass storage support */
+
+ ret = usbhost_msc_initialize();
+ if (ret != OK)
+ {
+ syslog(LOG_ERR, "ERROR: Failed to register the mass storage class: %d\n", ret);
+ }
+#endif
+
+#ifdef CONFIG_USBHOST_CDCACM
+ /* Register the CDC/ACM serial class */
+
+ ret = usbhost_cdcacm_initialize();
+ if (ret != OK)
+ {
+ syslog(LOG_ERR, "ERROR: Failed to register the CDC/ACM serial class: %d\n", ret);
+ }
+#endif
+
+ UNUSED(ret);
+
+ /* Then get an instance of the USB host interface */
+
+ syslog(LOG_INFO, "Initialize USB host\n");
+ g_usbconn = lpc17_usbhost_initialize(0);
+ if (g_usbconn)
+ {
+ /* Start a thread to handle device connection. */
+
+ syslog(LOG_ERR, "ERROR: Start nsh_waiter\n");
+
+ pid = task_create("usbhost", CONFIG_MCB1700_USBHOST_PRIO,
+ CONFIG_MCB1700_USBHOST_STACKSIZE,
+ (main_t)nsh_waiter, (FAR char * const *)NULL);
+ return pid < 0 ? -ENOEXEC : OK;
+ }
+
+ return -ENODEV;
+}
+#else
+# define nsh_usbhostinitialize() (OK)
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: mcb1700_bringup
+ *
+ * Description:
+ * Perform architecture-specific initialization
+ *
+ * CONFIG_BOARD_INITIALIZE=y :
+ * Called from board_initialize().
+ *
+ * CONFIG_BOARD_INITIALIZE=y && CONFIG_LIB_BOARDCTL=y :
+ * Called from the NSH library
+ *
+ ****************************************************************************/
+
+int mcb1700_bringup(void)
+{
+ int ret;
+
+ /* Initialize SPI-based microSD */
+
+ ret = nsh_sdinitialize();
+ if (ret < 0)
+ {
+ syslog(LOG_ERR, "ERROR: Failed to initialize SPI-based SD card: %d\n", ret);
+ }
+
+ /* Initialize USB host */
+
+ ret = nsh_usbhostinitialize();
+ if (ret < 0)
+ {
+ syslog(LOG_ERR, "ERROR: Failed to initialize USB host: %d\n", ret);
+ }
+
+#ifdef CONFIG_CAN
+ /* Initialize CAN and register the CAN driver. */
+
+ ret = lpc1766stk_can_setup();
+ if (ret < 0)
+ {
+ syslog(LOG_ERR, "ERROR: lpc1766stk_can_setup failed: %d\n", ret);
+ }
+#endif
+
+#ifdef CONFIG_FS_PROCFS
+ /* Mount the procfs file system */
+
+ ret = mount(NULL, "/proc", "procfs", 0, NULL);
+ if (ret < 0)
+ {
+ syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
+ }
+#endif
+
+ return ret;
+}
diff --git a/configs/mcb1700/src/lpc17_dac.c b/configs/mcb1700/src/lpc17_dac.c
new file mode 100644
index 00000000000..f64abe1ab9c
--- /dev/null
+++ b/configs/mcb1700/src/lpc17_dac.c
@@ -0,0 +1,101 @@
+/************************************************************************************
+ * configs/mcb1700/src/lpc17_dac.c
+ *
+ * Based on configs/zkit-arm-1769/src/lpc17_dac.c
+ *
+ * Copyright (C) 2013 Zilogic Systems. All rights reserved.
+ * Author: Kannan
+ *
+ * Based on configs/stm3220g-eval/src/stm32_dac.c
+ *
+ * Copyright (C) 2012, 2014, 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+
+#include
+#include
+
+#include
+#include
+
+#include "up_arch.h"
+#include "up_internal.h"
+
+#include "lpc17_dac.h"
+
+#ifdef CONFIG_DAC
+
+/************************************************************************************
+ * Name: dac_devinit
+ *
+ * Description:
+ * All LPC17xx architectures must provide the following interface to work with
+ * examples/diag.
+ *
+ ************************************************************************************/
+
+int dac_devinit(void)
+{
+ static bool initialized = false;
+ struct dac_dev_s *dac;
+ int ret;
+
+ if (!initialized)
+ {
+ /* Call lpc17_dacinitialize() to get an instance of the dac interface */
+
+ dac = lpc17_dacinitialize();
+ if (dac == NULL)
+ {
+ aerr("ERROR: Failed to get dac interface\n");
+ return -ENODEV;
+ }
+
+ ret = dac_register("/dev/dac0", dac);
+ if (ret < 0)
+ {
+ aerr("ERROR: dac_register failed: %d\n", ret);
+ return ret;
+ }
+
+ initialized = true;
+ }
+
+ return OK;
+}
+
+#endif /* CONFIG_DAC */
diff --git a/configs/mcb1700/src/lpc17_leds.c b/configs/mcb1700/src/lpc17_leds.c
new file mode 100644
index 00000000000..ac4075e7db2
--- /dev/null
+++ b/configs/mcb1700/src/lpc17_leds.c
@@ -0,0 +1,200 @@
+/****************************************************************************
+ * configs/mcb1700/src/lpc17_leds.c
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include
+
+#include
+#include
+
+#include "chip.h"
+#include "up_arch.h"
+#include "up_internal.h"
+
+#include "lpc17_gpio.h"
+
+#include "mcb1700.h"
+
+#ifdef CONFIG_ARCH_LEDS
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Dump GPIO registers */
+
+#ifdef CONFIG_DEBUG_LEDS_INFO
+# define led_dumpgpio(m) lpc17_dumpgpio(MCB1700_LED3, m)
+#else
+# define led_dumpgpio(m)
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* LED definitions **********************************************************/
+/* The MCB1700 has 4 LEDs along the bottom of the board. Blue or off.
+ * If CONFIG_ARCH_LEDS is defined, the LEDs will be controlled as follows
+ * for NuttX debug functionality (where NC means "No Change").
+ *
+ * During the boot phases. LED1 and LED2 will show boot status. LED3/4 Not
+ * used.
+ *
+ * LED1 LED2
+ * STARTED OFF OFF
+ * HEAPALLOCATE BLUE OFF
+ * IRQSENABLED OFF BLUE
+ * STACKCREATED OFF OFF
+ *
+ * After the system is booted, this logic will no longer use LEDs 1 & 2.
+ * They are available together with LED3 for use the application software
+ * using lpc17_led (prototyped below)
+ */
+
+static bool g_initialized;
+static int g_nestcount;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_autoled_initialize
+ ****************************************************************************/
+
+void board_autoled_initialize(void)
+{
+ /* Configure all LED GPIO lines */
+
+ led_dumpgpio("board_autoled_initialize() Entry)");
+
+ lpc17_configgpio(MCB1700_LED1);
+ lpc17_configgpio(MCB1700_LED2);
+ lpc17_configgpio(MCB1700_LED3);
+ lpc17_configgpio(MCB1700_LED4);
+
+ led_dumpgpio("board_autoled_initialize() Exit");
+}
+
+/****************************************************************************
+ * Name: board_autoled_on
+ ****************************************************************************/
+
+void board_autoled_on(int led)
+{
+ /* We will control LED1 and LED2 not yet completed the boot sequence. */
+
+ if (!g_initialized)
+ {
+ int led1 = 0;
+ int led2 = 0;
+
+ switch (led)
+ {
+ case LED_STACKCREATED:
+ g_initialized = true;
+ case LED_STARTED:
+ default:
+ break;
+
+ case LED_HEAPALLOCATE:
+ led1 = 1;
+ break;
+
+ case LED_IRQSENABLED:
+ led2 = 1;
+ }
+
+ lpc17_led(MCB1700_LED1,led1);
+ lpc17_led(MCB1700_LED2,led2);
+ }
+
+ /* We will always control the HB LED */
+
+ switch (led)
+ {
+ case LED_INIRQ:
+ case LED_SIGNAL:
+ case LED_ASSERTION:
+ case LED_PANIC:
+ lpc17_gpiowrite(MCB1700_HEARTBEAT, false);
+ g_nestcount++;
+
+ default:
+ break;
+ }
+}
+
+/****************************************************************************
+ * Name: board_autoled_off
+ ****************************************************************************/
+
+void board_autoled_off(int led)
+{
+ /* In all states, OFF can only mean turning off the HB LED */
+
+ if (g_nestcount <= 1)
+ {
+ lpc17_led(MCB1700_HEARTBEAT, true);
+ g_nestcount = 0;
+ }
+ else
+ {
+ g_nestcount--;
+ }
+}
+
+/************************************************************************************
+ * Name: lpc17_led
+ *
+ * Description:
+ * Once the system has booted, these functions can be used to control the LEDs
+ *
+ ************************************************************************************/
+
+void lpc17_led(int lednum, int state)
+
+{
+ lpc17_gpiowrite(lednum, state);
+}
+#endif /* CONFIG_ARCH_LEDS */
diff --git a/configs/mcb1700/src/lpc17_pwm.c b/configs/mcb1700/src/lpc17_pwm.c
new file mode 100644
index 00000000000..f7e241c20ab
--- /dev/null
+++ b/configs/mcb1700/src/lpc17_pwm.c
@@ -0,0 +1,151 @@
+/************************************************************************************
+ * configs/mcb1700/lpc17_pwm.c
+ *
+ * Based on configs/lpcexpresso-lpc1768/lpc17_pwm.c
+ *
+ * Copyright (C) 2014-2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+
+#include "chip.h"
+#include "up_arch.h"
+#include "lpc17_pwm.h"
+#include "lpc17_timer.h"
+#include "mcb1700.h"
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+#ifdef CONFIG_PWM
+
+FAR struct pwm_lowerhalf_s *lpc17_pwminitialize(int timer);
+FAR struct pwm_lowerhalf_s *lpc17_mcpwminitialize(int timer);
+FAR struct pwm_lowerhalf_s *lpc17_timerinitialize(int timer);
+
+/************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Name: mcb1700_pwm_setup
+ *
+ * Description:
+ * Initialize PWM and register the PWM device.
+ *
+ ************************************************************************************/
+
+int mcb1700_pwm_setup(void)
+{
+ static bool initialized = false;
+ struct pwm_lowerhalf_s *pwm;
+ struct pwm_lowerhalf_s *mcpwm;
+ struct pwm_lowerhalf_s *timer;
+ int ret;
+
+ /* Have we already initialized? */
+
+ if (!initialized)
+ {
+ /* Call lpc17_pwminitialize() to get an instance of the PWM interface */
+
+ pwm = lpc17_pwminitialize(0);
+ if (!pwm)
+ {
+ aerr("ERROR: Failed to get the LPC17XX PWM lower half\n");
+ return -ENODEV;
+ }
+
+ /* Register the PWM driver at "/dev/pwm0" */
+
+ ret = pwm_register("/dev/pwm0", pwm);
+ if (ret < 0)
+ {
+ aerr("ERROR: pwm_register failed: %d\n", ret);
+ return ret;
+ }
+
+ mcpwm = lpc17_mcpwminitialize(0);
+ if (!mcpwm)
+ {
+ aerr("ERROR: Failed to get the LPC17XX MOTOR PWM lower half\n");
+ return -ENODEV;
+ }
+
+ /* Register the MOTOR CONTROL PWM driver at "/dev/mcpwm0" */
+
+ ret = pwm_register("/dev/mcpwm0", mcpwm);
+ if (ret < 0)
+ {
+ aerr("ERROR: mcpwm_register failed: %d\n", ret);
+ return ret;
+ }
+
+ timer = lpc17_timerinitialize(0);
+ if (!timer)
+ {
+ aerr("ERROR: Failed to get the LPC17XX TIMER lower half\n");
+ return -ENODEV;
+ }
+
+ /* Register the PWM driver at "/dev/timer0" */
+
+ ret = pwm_register("/dev/timer0", timer);
+ if (ret < 0)
+ {
+ aerr("ERROR: timer_register failed: %d\n", ret);
+ return ret;
+ }
+
+ /* Now we are initialized */
+
+ initialized = true;
+ }
+
+ return OK;
+}
+
+#endif /* CONFIG_PWM */
diff --git a/configs/mcb1700/src/mcb1700.h b/configs/mcb1700/src/mcb1700.h
new file mode 100644
index 00000000000..481cbbc5e88
--- /dev/null
+++ b/configs/mcb1700/src/mcb1700.h
@@ -0,0 +1,125 @@
+/************************************************************************************
+ * configs/mcb1700/src/mcb1700.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+#ifndef _CONFIGS_MCB1700_SRC_MCB1700_H
+#define _CONFIGS_MCB1700_SRC_MCB1700_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+#include
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+/* MCB1700 GPIO Pin Definitions *****************************************************/
+
+#define MCB1700_LED1 (GPIO_OUTPUT | GPIO_PORT1 | GPIO_PIN18)
+#define MCB1700_LED1_OFF MCB1700_LED1
+#define MCB1700_LED1_ON (MCB1700_LED1 | GPIO_VALUE_ONE)
+#define MCB1700_LED2 (GPIO_OUTPUT | GPIO_PORT1 | GPIO_PIN20)
+#define MCB1700_LED2_OFF MCB1700_LED2
+#define MCB1700_LED2_ON (MCB1700_LED2 | GPIO_VALUE_ONE)
+#define MCB1700_LED3 (GPIO_OUTPUT | GPIO_PORT1 | GPIO_PIN21)
+#define MCB1700_LED3_OFF MCB1700_LED3
+#define MCB1700_LED3_ON (MCB1700_LED3 | GPIO_VALUE_ONE)
+#define MCB1700_LED4 (GPIO_OUTPUT | GPIO_PORT1 | GPIO_PIN23)
+#define MCB1700_LED4_OFF MCB1700_LED4
+#define MCB1700_LED4_ON (MCB1700_LED 4| GPIO_VALUE_ONE)
+
+#define MCB1700_HEARTBEAT MCB1700_LED4
+
+#ifndef __ASSEMBLY__
+
+/************************************************************************************
+ * Public Function Prototypes
+ ************************************************************************************/
+
+/****************************************************************************
+ * Name: mcb1700_bringup
+ *
+ * Description:
+ * Perform architecture-specific initialization
+ *
+ * CONFIG_BOARD_INITIALIZE=y :
+ * Called from board_initialize().
+ *
+ * CONFIG_BOARD_INITIALIZE=y && CONFIG_LIB_BOARDCTL=y :
+ * Called from the NSH library
+ *
+ ****************************************************************************/
+
+int mcb1700_bringup(void);
+
+/************************************************************************************
+ * Name: mcb1700_sspdev_initialize
+ *
+ * Description:
+ * Called to configure SPI chip select GPIO pins for the NUCLEUS-2G board.
+ *
+ ************************************************************************************/
+
+void weak_function mcb1700_sspdev_initialize(void);
+
+/************************************************************************************
+ * Name: mcb1700_pwm_setup
+ *
+ * Description:
+ * Initialize PWM and register the PWM device.
+ *
+ ************************************************************************************/
+
+#ifdef CONFIG_PWM
+int mcb1700_pwm_setup(void);
+#endif
+
+/************************************************************************************
+ * Name: mcb1700_adc_setup
+ *
+ * Description:
+ * Initialize ADC and register the ADC driver.
+ *
+ ************************************************************************************/
+
+#ifdef CONFIG_ADC
+int mcb1700_adc_setup(void);
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* _CONFIGS_MCB1700_SRC_MCB1700_H */
+