I2C Tool: Now that the I2C tool uses a character driver, the I2C character drivers must be initialized in board bring-up logic

This commit is contained in:
Gregory Nutt 2016-02-02 14:22:54 -06:00
parent a135df609f
commit d5cbcc1293
43 changed files with 1006 additions and 165 deletions

View File

@ -57,7 +57,7 @@ CSRCS += tm4c_timer.c
endif
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += tm4c_nsh.c
CSRCS += tm4c_appinit.c
endif
ifeq ($(CONFIG_I2C_LM75),y)

View File

@ -60,6 +60,13 @@
# undef CONFIG_TIVA_SSI0
#endif
/* Do we need to register I2C drivers on behalf of the I2C tool? */
#define HAVE_I2CTOOL 1
#if !defined(CONFIG_SYSTEM_I2CTOOL) || !defined(CONFIG_I2C_DRIVER)
# undef HAVE_I2CTOOL
#endif
/* LED definitions ******************************************************************/
/* The TMC4C123G LaunchPad has a single RGB LED. There is only one visible LED which
* will vary in color. But, from the standpoint of the firmware, this appears as

View File

@ -1,5 +1,5 @@
/****************************************************************************
* config/dk-tm4c129x/src/tm4c_nsh.c
* config/dk-tm4c129x/src/tm4c_appinit.c
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -43,10 +43,6 @@
#include "dk-tm4c129x.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View File

@ -1,7 +1,7 @@
/****************************************************************************
* config/dk-tm4c129x/src/tm4c_bringup.c
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -41,8 +41,10 @@
#include <debug.h>
#include <nuttx/i2c/i2c_master.h>
#include <arch/board/board.h>
#include "tiva_i2c.h"
#include "dk-tm4c129x.h"
/****************************************************************************
@ -63,6 +65,87 @@
# define TMP100_DEVNAME "/dev/temp"
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: tm4c_i2c_register
*
* Description:
* Register one I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void tm4c_i2c_register(int bus)
{
FAR struct i2c_master_s *i2c;
int ret;
i2c = tiva_i2cbus_initialize(bus);
if (i2c == NULL)
{
dbg("ERROR: Failed to get I2C%d interface\n", bus);
}
else
{
ret = i2c_register(i2c, bus);
if (ret < 0)
{
dbg("ERROR: Failed to register I2C%d driver: %d\n", bus, ret);
tiva_i2cbus_uninitialize(i2c);
}
}
}
#endif
/****************************************************************************
* Name: tm4c_i2ctool
*
* Description:
* Register I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void tm4c_i2ctool(void)
{
#ifdef CONFIG_TIVA_I2C0
tm4c_i2c_register(0);
#endif
#ifdef CONFIG_TIVA_I2C1
tm4c_i2c_register(1);
#endif
#ifdef CONFIG_TIVA_I2C2
tm4c_i2c_register(2);
#endif
#ifdef CONFIG_TIVA_I2C3
tm4c_i2c_register(3);
#endif
#ifdef CONFIG_TIVA_I2C4
tm4c_i2c_register(4);
#endif
#ifdef CONFIG_TIVA_I2C5
tm4c_i2c_register(5);
#endif
#ifdef CONFIG_TIVA_I2C6
tm4c_i2c_register(6);
#endif
#ifdef CONFIG_TIVA_I2C7
tm4c_i2c_register(7);
#endif
#ifdef CONFIG_TIVA_I2C8
tm4c_i2c_register(8);
#endif
#ifdef CONFIG_TIVA_I2C9
tm4c_i2c_register(9);
#endif
}
#else
# define tm4c_i2ctool()
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -81,6 +164,10 @@ int tm4c_bringup(void)
int ret;
#endif
/* Register I2C drivers on behalf of the I2C tool */
tm4c_i2ctool();
#ifdef HAVE_TMP100
/* Initialize and register the TMP-100 Temperature Sensor driver. */

View File

@ -53,7 +53,7 @@ CSRCS += stm32_buttons.c
endif
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += stm32_nsh.c
CSRCS += stm32_appinit.c
endif
ifeq ($(CONFIG_ENC28J60),y)

View File

@ -66,6 +66,13 @@
# warning "The M3 Wildfire only supports CAN1"
#endif
/* Do we need to register I2C drivers on behalf of the I2C tool? */
#define HAVE_I2CTOOL 1
#if !defined(CONFIG_SYSTEM_I2CTOOL) || !defined(CONFIG_I2C_DRIVER)
# undef HAVE_I2CTOOL
#endif
/* M3 Wildfire GPIOs ****************************************************************/
/* Camera
*

View File

@ -1,5 +1,5 @@
/****************************************************************************
* config/fire-stm32v2/src/stm32_nsh.c
* config/fire-stm32v2/src/stm32_appinit.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -45,8 +45,10 @@
#include <errno.h>
#include <nuttx/board.h>
#include <nuttx/i2c/i2c_master.h>
#include "stm32.h"
#include "stm32_i2c.h"
#include "fire-stm32v2.h"
/****************************************************************************
@ -124,6 +126,66 @@
# undef HAVE_USBDEV
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: stm32_i2c_register
*
* Description:
* Register one I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void stm32_i2c_register(int bus)
{
FAR struct i2c_master_s *i2c;
int ret;
i2c = stm32_i2cbus_initialize(bus);
if (i2c == NULL)
{
dbg("ERROR: Failed to get I2C%d interface\n", bus);
}
else
{
ret = i2c_register(i2c, bus);
if (ret < 0)
{
dbg("ERROR: Failed to register I2C%d driver: %d\n", bus, ret);
stm32_i2cbus_uninitialize(i2c);
}
}
}
#endif
/****************************************************************************
* Name: stm32_i2ctool
*
* Description:
* Register I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void stm32_i2ctool(void)
{
#ifdef CONFIG_STM32_I2C1
stm32_i2c_register(1);
#endif
#ifdef CONFIG_STM32_I2C2
stm32_i2c_register(2);
#endif
#ifdef CONFIG_STM32_I2C3
stm32_i2c_register(3);
#endif
}
#else
# define stm32_i2ctool()
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -142,9 +204,13 @@ int board_app_initialize(void)
int ret;
#endif
/* Initialize and register the W25 FLASH file system. */
/* Register I2C drivers on behalf of the I2C tool */
stm32_i2ctool();
#ifdef HAVE_W25
/* Initialize and register the W25 FLASH file system. */
ret = stm32_w25initialize(CONFIG_NSH_W25MINOR);
if (ret < 0)
{
@ -154,9 +220,9 @@ int board_app_initialize(void)
}
#endif
#ifdef HAVE_MMCSD
/* Initialize the SDIO-based MMC/SD slot */
#ifdef HAVE_MMCSD
ret = stm32_sdinitialize(CONFIG_NSH_MMCSDMINOR);
if (ret < 0)
{
@ -165,5 +231,6 @@ int board_app_initialize(void)
return ret;
}
#endif
return OK;
}

View File

@ -70,7 +70,7 @@
int composite_archinitialize(void)
{
/* If system/composite is built as an NSH command, then SD slot should
* already have been initialized in board_app_initialize() (see stm32_nsh.c).
* already have been initialized in board_app_initialize() (see stm32_appinit.c).
* In this case, there is nothing further to be done here.
*
* NOTE: CONFIG_NSH_BUILTIN_APPS is not a fool-proof indication that NSH

View File

@ -71,7 +71,7 @@
int usbmsc_archinitialize(void)
{
/* If system/usbmsc is built as an NSH command, then SD slot should
* already have been initialized in board_app_initialize() (see stm32_nsh.c).
* already have been initialized in board_app_initialize() (see stm32_appinit.c).
* In this case, there is nothing further to be done here.
*/

View File

@ -39,7 +39,7 @@ ASRCS =
CSRCS = lpc43_boot.c
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += lpc43_nsh.c
CSRCS += lpc43_appinit.c
endif
ifeq ($(CONFIG_LPC43_ADC0),y)

View File

@ -46,6 +46,17 @@
#include "lpc43_pinconfig.h"
#include "lpc43_gpio.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Do we need to register I2C drivers on behalf of the I2C tool? */
#define HAVE_I2CTOOL 1
#if !defined(CONFIG_SYSTEM_I2CTOOL) || !defined(CONFIG_I2C_DRIVER)
# undef HAVE_I2CTOOL
#endif
/****************************************************************************
* Public data
****************************************************************************/

View File

@ -0,0 +1,127 @@
/****************************************************************************
* configs/lpc4337-ws/src/lpc43_appinit.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/board.h>
#include <nuttx/i2c/i2c_master.h>
#include "lpc43_i2c.h"
#include "chip.h"
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: lpc43_i2c_register
*
* Description:
* Register one I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void lpc43_i2c_register(int bus)
{
FAR struct i2c_master_s *i2c;
int ret;
i2c = lpc43_i2cbus_initialize(bus);
if (i2c == NULL)
{
dbg("ERROR: Failed to get I2C%d interface\n", bus);
}
else
{
ret = i2c_register(i2c, bus);
if (ret < 0)
{
dbg("ERROR: Failed to register I2C%d driver: %d\n", bus, ret);
lpc43_i2cbus_uninitialize(i2c);
}
}
}
#endif
/****************************************************************************
* Name: lpc43_i2ctool
*
* Description:
* Register I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void lpc43_i2ctool(void)
{
#ifdef CONFIG_LPC43_I2C0
lpc43_i2c_register(0);
#endif
#ifdef CONFIG_STM32_I2C1
lpc43_i2c_register(1);
#endif
}
#else
# define lpc43_i2ctool()
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_app_initialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int board_app_initialize(void)
{
/* Register I2C drivers on behalf of the I2C tool */
lpc43_i2ctool();
return OK;
}

View File

@ -1,65 +0,0 @@
/****************************************************************************
* configs/lpc4337-ws/src/lpc43-nsh.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/board.h>
#include "chip.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_app_initialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int board_app_initialize(void)
{
return OK;
}

View File

@ -39,7 +39,7 @@ ASRCS =
CSRCS = lpc43_boot.c
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += lpc43_nsh.c
CSRCS += lpc43_appinit.c
endif
ifeq ($(CONFIG_ARCH_FPU),y)

View File

@ -50,6 +50,13 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Do we need to register I2C drivers on behalf of the I2C tool? */
#define HAVE_I2CTOOL 1
#if !defined(CONFIG_SYSTEM_I2CTOOL) || !defined(CONFIG_I2C_DRIVER)
# undef HAVE_I2CTOOL
#endif
/* LED definitions **********************************************************/
/* The LPC4370-LINK2 has one user-controllable LED labelled D6 controlled by
* the signal LED_3V3:

View File

@ -0,0 +1,127 @@
/****************************************************************************
* config/lpc4370-link2/src/lpc43_appinit.c
*
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/board.h>
#include <nuttx/i2c/i2c_master.h>
#include "lpc43_i2c.h"
#include "chip.h"
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: lpc43_i2c_register
*
* Description:
* Register one I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void lpc43_i2c_register(int bus)
{
FAR struct i2c_master_s *i2c;
int ret;
i2c = lpc43_i2cbus_initialize(bus);
if (i2c == NULL)
{
dbg("ERROR: Failed to get I2C%d interface\n", bus);
}
else
{
ret = i2c_register(i2c, bus);
if (ret < 0)
{
dbg("ERROR: Failed to register I2C%d driver: %d\n", bus, ret);
lpc43_i2cbus_uninitialize(i2c);
}
}
}
#endif
/****************************************************************************
* Name: lpc43_i2ctool
*
* Description:
* Register I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void lpc43_i2ctool(void)
{
#ifdef CONFIG_LPC43_I2C0
lpc43_i2c_register(0);
#endif
#ifdef CONFIG_STM32_I2C1
lpc43_i2c_register(1);
#endif
}
#else
# define lpc43_i2ctool()
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_app_initialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int board_app_initialize(void)
{
/* Register I2C drivers on behalf of the I2C tool */
lpc43_i2ctool();
return OK;
}

View File

@ -1,65 +0,0 @@
/****************************************************************************
* config/lpc4370-link2/src/lpc43_nsh.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/board.h>
#include "chip.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_app_initialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int board_app_initialize(void)
{
return OK;
}

View File

@ -113,7 +113,7 @@ CSRCS += sam_maxtouch.c
endif
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += sam_nsh.c sam_bringup.c
CSRCS += sam_appinit.c sam_bringup.c
else
ifeq ($(CONFIG_BOARD_INITIALIZE),y)
CSRCS += sam_bringup.c

View File

@ -1,5 +1,5 @@
/****************************************************************************
* config/sama5d4-ek/src/sam_nsh.c
* config/sama5d4-ek/src/sam_appinit.c
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>

View File

@ -52,7 +52,9 @@
#include <nuttx/fs/ramdisk.h>
#include <nuttx/binfmt/elf.h>
#include <nuttx/i2c/i2c_master.h>
#include "sam_twi.h"
#include "sama5d4-ek.h"
#ifdef HAVE_ROMFS
@ -75,6 +77,69 @@
# define SYSLOG dbg
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: sam_i2c_register
*
* Description:
* Register one I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void sam_i2c_register(int bus)
{
FAR struct i2c_master_s *i2c;
int ret;
i2c = sam_i2cbus_initialize(bus);
if (i2c == NULL)
{
dbg("ERROR: Failed to get I2C%d interface\n", bus);
}
else
{
ret = i2c_register(i2c, bus);
if (ret < 0)
{
dbg("ERROR: Failed to register I2C%d driver: %d\n", bus, ret);
sam_i2cbus_uninitialize(i2c);
}
}
}
#endif
/****************************************************************************
* Name: sam_i2ctool
*
* Description:
* Register I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void sam_i2ctool(void)
{
#ifdef CONFIG_SAMA5_TWI0
sam_i2c_register(0);
#endif
#ifdef CONFIG_SAMA5_TWI1
sam_i2c_register(1);
#endif
#ifdef CONFIG_SAMA5_TWI2
sam_i2c_register(2);
#endif
#ifdef CONFIG_SAMA5_TWI3
sam_i2c_register(3);
#endif
}
#else
# define sam_i2ctool()
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -96,6 +161,10 @@ int sam_bringup(void)
int ret;
#endif
/* Register I2C drivers on behalf of the I2C tool */
sam_i2ctool();
#ifdef HAVE_NAND
/* Initialize the NAND driver */

View File

@ -1,7 +1,7 @@
/************************************************************************************
* configs/sama5d4-ek/src/sama5d4-ek.h
*
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -71,6 +71,7 @@
#define HAVE_PMIC 1
#define HAVE_ELF 1
#define HAVE_ROMFS 1
#define HAVE_I2CTOOL 1
/* HSMCI */
/* Can't support MMC/SD if the card interface(s) are not enable */
@ -478,6 +479,12 @@
# undef HAVE_ROMFS
#endif
/* Do we need to register I2C drivers on behalf of the I2C tool? */
#if !defined(CONFIG_SYSTEM_I2CTOOL) || !defined(CONFIG_I2C_DRIVER)
# undef HAVE_I2CTOOL
#endif
/* procfs File System */
#ifdef CONFIG_FS_PROCFS

View File

@ -43,7 +43,7 @@ CSRCS += sam_sdram.c
endif
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += sam_nsh.c sam_bringup.c
CSRCS += sam_appinit.c sam_bringup.c
else ifeq ($(CONFIG_BOARD_INITIALIZE),y)
CSRCS += sam_bringup.c
endif

View File

@ -1,5 +1,5 @@
/****************************************************************************
* config/same70-xplained/src/sam_nsh.c
* config/same70-xplained/src/sam_appinit.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>

View File

@ -1,7 +1,7 @@
/****************************************************************************
* config/same70-xplained/src/sam_bringup.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2015, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -54,7 +54,9 @@
#include <nuttx/fs/ramdisk.h>
#include <nuttx/fs/nxffs.h>
#include <nuttx/binfmt/elf.h>
#include <nuttx/i2c/i2c_master.h>
#include "sam_twihs.h"
#include "same70-xplained.h"
#ifdef HAVE_PROGMEM_CHARDEV
@ -82,6 +84,66 @@
# define SYSLOG dbg
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: sam_i2c_register
*
* Description:
* Register one I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void sam_i2c_register(int bus)
{
FAR struct i2c_master_s *i2c;
int ret;
i2c = sam_i2cbus_initialize(bus);
if (i2c == NULL)
{
dbg("ERROR: Failed to get I2C%d interface\n", bus);
}
else
{
ret = i2c_register(i2c, bus);
if (ret < 0)
{
dbg("ERROR: Failed to register I2C%d driver: %d\n", bus, ret);
sam_i2cbus_uninitialize(i2c);
}
}
}
#endif
/****************************************************************************
* Name: sam_i2ctool
*
* Description:
* Register I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void sam_i2ctool(void)
{
#ifdef CONFIG_SAMV7_TWIHS0
sam_i2c_register(0);
#endif
#ifdef CONFIG_SAMV7_TWIHS1
sam_i2c_register(1);
#endif
#ifdef CONFIG_SAMV7_TWIHS2
sam_i2c_register(2);
#endif
}
#else
# define sam_i2ctool()
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -103,6 +165,10 @@ int sam_bringup(void)
#endif
int ret;
/* Register I2C drivers on behalf of the I2C tool */
sam_i2ctool();
#ifdef HAVE_MACADDR
/* Read the Ethernet MAC address from the AT24 FLASH and configure the
* Ethernet driver with that address.

View File

@ -62,6 +62,7 @@
#define HAVE_MACADDR 1
#define HAVE_MTDCONFIG 1
#define HAVE_PROGMEM_CHARDEV 1
#define HAVE_I2CTOOL 1
/* HSMCI */
/* Can't support MMC/SD if the card interface is not enabled */
@ -190,6 +191,12 @@
#define PROGMEM_MTD_MINOR 0
/* Do we need to register I2C drivers on behalf of the I2C tool? */
#if !defined(CONFIG_SYSTEM_I2CTOOL) || !defined(CONFIG_I2C_DRIVER)
# undef HAVE_I2CTOOL
#endif
/* procfs File System */
#ifdef CONFIG_FS_PROCFS

View File

@ -43,7 +43,7 @@ CSRCS += sam_sdram.c
endif
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += sam_nsh.c sam_bringup.c
CSRCS += sam_appinit.c sam_bringup.c
else ifeq ($(CONFIG_BOARD_INITIALIZE),y)
CSRCS += sam_bringup.c
endif

View File

@ -1,5 +1,5 @@
/****************************************************************************
* config/samv71-xult/src/sam_nsh.c
* config/samv71-xult/src/sam_appinit.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>

View File

@ -54,7 +54,9 @@
#include <nuttx/fs/ramdisk.h>
#include <nuttx/fs/nxffs.h>
#include <nuttx/binfmt/elf.h>
#include <nuttx/i2c/i2c_master.h>
#include "sam_twihs.h"
#include "samv71-xult.h"
#if defined(HAVE_S25FL1) || defined(HAVE_PROGMEM_CHARDEV)
@ -101,6 +103,66 @@
# define SYSLOG dbg
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: sam_i2c_register
*
* Description:
* Register one I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void sam_i2c_register(int bus)
{
FAR struct i2c_master_s *i2c;
int ret;
i2c = sam_i2cbus_initialize(bus);
if (i2c == NULL)
{
dbg("ERROR: Failed to get I2C%d interface\n", bus);
}
else
{
ret = i2c_register(i2c, bus);
if (ret < 0)
{
dbg("ERROR: Failed to register I2C%d driver: %d\n", bus, ret);
sam_i2cbus_uninitialize(i2c);
}
}
}
#endif
/****************************************************************************
* Name: sam_i2ctool
*
* Description:
* Register I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void sam_i2ctool(void)
{
#ifdef CONFIG_SAMV7_TWIHS0
sam_i2c_register(0);
#endif
#ifdef CONFIG_SAMV7_TWIHS1
sam_i2c_register(1);
#endif
#ifdef CONFIG_SAMV7_TWIHS2
sam_i2c_register(2);
#endif
}
#else
# define sam_i2ctool()
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -130,6 +192,10 @@ int sam_bringup(void)
#endif
int ret;
/* Register I2C drivers on behalf of the I2C tool */
sam_i2ctool();
#if defined(HAVE_RTC_PCF85263)
/* Get an instance of the TWIHS0 I2C interface */

View File

@ -70,6 +70,7 @@
#define HAVE_AUDIO_NULL 1
#define HAVE_RTC_DSXXXX 1
#define HAVE_RTC_PCF85263 1
#define HAVE_I2CTOOL 1
/* HSMCI */
/* Can't support MMC/SD if the card interface is not enabled */
@ -352,6 +353,12 @@
# define PCF85263_I2C_ADDRESS 0x51
#endif
/* Do we need to register I2C drivers on behalf of the I2C tool? */
#if !defined(CONFIG_SYSTEM_I2CTOOL) || !defined(CONFIG_I2C_DRIVER)
# undef HAVE_I2CTOOL
#endif
/* SAMV71-XULT GPIO Pin Definitions *************************************************/
/* Ethernet MAC.

View File

@ -45,7 +45,7 @@ CSRCS += stm32_selectlcd.c stm32_deselectlcd.c
endif
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += stm32_nsh.c
CSRCS += stm32_appinit.c
endif
ifeq ($(CONFIG_ADC),y)

View File

@ -65,6 +65,13 @@
# warning "The STM3210E-EVAL only supports CAN1"
#endif
/* Do we need to register I2C drivers on behalf of the I2C tool? */
#define HAVE_I2CTOOL 1
#if !defined(CONFIG_SYSTEM_I2CTOOL) || !defined(CONFIG_I2C_DRIVER)
# undef HAVE_I2CTOOL
#endif
/* STM3210E-EVAL GPIOs **************************************************************/
/* LEDs */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* config/stm3210e_eval/src/stm32_nsh.c
* config/stm3210e_eval/src/stm32_appinit.c
*
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2009, 2011, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -45,6 +45,7 @@
#include <errno.h>
#include <nuttx/board.h>
#include <nuttx/i2c/i2c_master.h>
#ifdef CONFIG_STM32_SPI1
# include <nuttx/spi/spi.h>
@ -57,6 +58,7 @@
#endif
#include "stm32.h"
#include "stm32_i2c.h"
#include "stm3210e-eval.h"
/****************************************************************************
@ -106,6 +108,66 @@
# define CONFIG_NSH_MMCSDMINOR 0
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: stm32_i2c_register
*
* Description:
* Register one I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void stm32_i2c_register(int bus)
{
FAR struct i2c_master_s *i2c;
int ret;
i2c = stm32_i2cbus_initialize(bus);
if (i2c == NULL)
{
dbg("ERROR: Failed to get I2C%d interface\n", bus);
}
else
{
ret = i2c_register(i2c, bus);
if (ret < 0)
{
dbg("ERROR: Failed to register I2C%d driver: %d\n", bus, ret);
stm32_i2cbus_uninitialize(i2c);
}
}
}
#endif
/****************************************************************************
* Name: stm32_i2ctool
*
* Description:
* Register I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void stm32_i2ctool(void)
{
#ifdef CONFIG_STM32_I2C1
stm32_i2c_register(1);
#endif
#ifdef CONFIG_STM32_I2C2
stm32_i2c_register(2);
#endif
#ifdef CONFIG_STM32_I2C3
stm32_i2c_register(3);
#endif
}
#else
# define stm32_i2ctool()
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -131,6 +193,10 @@ int board_app_initialize(void)
int ret;
#endif
/* Register I2C drivers on behalf of the I2C tool */
stm32_i2ctool();
/* Configure SPI-based devices */
#ifdef CONFIG_STM32_SPI1

View File

@ -91,7 +91,7 @@ int composite_archinitialize(void)
{
/* If system/composite is built as an NSH command, then SD slot should
* already have been initialized in board_app_initialize() (see
* stm32_nsh.c). In this case, there is nothing further to be done here.
* stm32_appinit.c). In this case, there is nothing further to be done here.
*
* NOTE: CONFIG_NSH_BUILTIN_APPS is not a fool-proof indication that NSH
* was built.

View File

@ -69,7 +69,7 @@ CSRCS += stm32_can.c
endif
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += stm32_nsh.c
CSRCS += stm32_appinit.c
endif
ifeq ($(CONFIG_WATCHDOG),y)

View File

@ -87,6 +87,13 @@
# warning "The STM3250G-EVAL will only support one of CAN2 and USB OTG HS"
#endif
/* Do we need to register I2C drivers on behalf of the I2C tool? */
#define HAVE_I2CTOOL 1
#if !defined(CONFIG_SYSTEM_I2CTOOL) || !defined(CONFIG_I2C_DRIVER)
# undef HAVE_I2CTOOL
#endif
/* STM3220G-EVAL GPIOs ******************************************************************************/
/* LEDs */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* config/stm3220g_eval/src/stm32_nsh.c
* config/stm3220g_eval/src/stm32_appinit.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -45,6 +45,7 @@
#include <errno.h>
#include <nuttx/board.h>
#include <nuttx/i2c/i2c_master.h>
#ifdef CONFIG_STM32_SPI1
# include <nuttx/spi/spi.h>
@ -61,6 +62,7 @@
#endif
#include "stm32.h"
#include "stm32_i2c.h"
#include "stm3220g-eval.h"
/****************************************************************************
@ -119,6 +121,66 @@
# undef HAVE_USBHOST
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: stm32_i2c_register
*
* Description:
* Register one I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void stm32_i2c_register(int bus)
{
FAR struct i2c_master_s *i2c;
int ret;
i2c = stm32_i2cbus_initialize(bus);
if (i2c == NULL)
{
dbg("ERROR: Failed to get I2C%d interface\n", bus);
}
else
{
ret = i2c_register(i2c, bus);
if (ret < 0)
{
dbg("ERROR: Failed to register I2C%d driver: %d\n", bus, ret);
stm32_i2cbus_uninitialize(i2c);
}
}
}
#endif
/****************************************************************************
* Name: stm32_i2ctool
*
* Description:
* Register I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void stm32_i2ctool(void)
{
#ifdef CONFIG_STM32_I2C1
stm32_i2c_register(1);
#endif
#ifdef CONFIG_STM32_I2C2
stm32_i2c_register(2);
#endif
#ifdef CONFIG_STM32_I2C3
stm32_i2c_register(3);
#endif
}
#else
# define stm32_i2ctool()
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -144,6 +206,10 @@ int board_app_initialize(void)
int ret;
#endif
/* Register I2C drivers on behalf of the I2C tool */
stm32_i2ctool();
/* Configure SPI-based devices */
#ifdef CONFIG_STM32_SPI1

View File

@ -70,7 +70,7 @@ CSRCS += stm32_can.c
endif
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += stm32_nsh.c
CSRCS += stm32_appinit.c
endif
ifeq ($(CONFIG_ARCH_FPU),y)

View File

@ -88,6 +88,13 @@
# warning "The STM3250G-EVAL will only support one of CAN2 and USB OTG HS"
#endif
/* Do we need to register I2C drivers on behalf of the I2C tool? */
#define HAVE_I2CTOOL 1
#if !defined(CONFIG_SYSTEM_I2CTOOL) || !defined(CONFIG_I2C_DRIVER)
# undef HAVE_I2CTOOL
#endif
/* STM3240G-EVAL GPIOs ******************************************************************************/
/* LEDs */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* config/stm3240g_eval/src/stm32_nsh.c
* config/stm3240g_eval/src/stm32_appinit.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -45,6 +45,7 @@
#include <errno.h>
#include <nuttx/board.h>
#include <nuttx/i2c/i2c_master.h>
#ifdef CONFIG_STM32_SPI1
# include <nuttx/spi/spi.h>
@ -61,6 +62,7 @@
#endif
#include "stm32.h"
#include "stm32_i2c.h"
#include "stm3240g-eval.h"
/****************************************************************************
@ -125,6 +127,66 @@
# undef HAVE_USBHOST
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: stm32_i2c_register
*
* Description:
* Register one I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void stm32_i2c_register(int bus)
{
FAR struct i2c_master_s *i2c;
int ret;
i2c = stm32_i2cbus_initialize(bus);
if (i2c == NULL)
{
dbg("ERROR: Failed to get I2C%d interface\n", bus);
}
else
{
ret = i2c_register(i2c, bus);
if (ret < 0)
{
dbg("ERROR: Failed to register I2C%d driver: %d\n", bus, ret);
stm32_i2cbus_uninitialize(i2c);
}
}
}
#endif
/****************************************************************************
* Name: stm32_i2ctool
*
* Description:
* Register I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void stm32_i2ctool(void)
{
#ifdef CONFIG_STM32_I2C1
stm32_i2c_register(1);
#endif
#ifdef CONFIG_STM32_I2C2
stm32_i2c_register(2);
#endif
#ifdef CONFIG_STM32_I2C3
stm32_i2c_register(3);
#endif
}
#else
# define stm32_i2ctool()
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -150,6 +212,10 @@ int board_app_initialize(void)
int ret;
#endif
/* Register I2C drivers on behalf of the I2C tool */
stm32_i2ctool();
/* Configure SPI-based devices */
#ifdef CONFIG_STM32_SPI1

View File

@ -57,7 +57,7 @@ CSRCS += tm4c_timer.c
endif
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += tm4c_nsh.c
CSRCS += tm4c_appinit.c
endif
include $(TOPDIR)/configs/Board.mk

View File

@ -60,6 +60,13 @@
# undef CONFIG_TIVA_SSI0
#endif
/* Do we need to register I2C drivers on behalf of the I2C tool? */
#define HAVE_I2CTOOL 1
#if !defined(CONFIG_SYSTEM_I2CTOOL) || !defined(CONFIG_I2C_DRIVER)
# undef HAVE_I2CTOOL
#endif
/* LED definitions ******************************************************************/
/* The EK-TM4C1294XL has a four green LEDs.
*

View File

@ -1,5 +1,5 @@
/****************************************************************************
* config/tm4c1294-launchpad/src/tm4c_nsh.c
* config/tm4c1294-launchpad/src/tm4c_appinit.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>

View File

@ -41,8 +41,10 @@
#include <debug.h>
#include <nuttx/i2c/i2c_master.h>
#include <arch/board/board.h>
#include "tiva_i2c.h"
#include "tm4c1294-launchpad.h"
/****************************************************************************
@ -53,6 +55,87 @@
# define HAVE_TIMER
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: tm4c_i2c_register
*
* Description:
* Register one I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void tm4c_i2c_register(int bus)
{
FAR struct i2c_master_s *i2c;
int ret;
i2c = tiva_i2cbus_initialize(bus);
if (i2c == NULL)
{
dbg("ERROR: Failed to get I2C%d interface\n", bus);
}
else
{
ret = i2c_register(i2c, bus);
if (ret < 0)
{
dbg("ERROR: Failed to register I2C%d driver: %d\n", bus, ret);
tiva_i2cbus_uninitialize(i2c);
}
}
}
#endif
/****************************************************************************
* Name: tm4c_i2ctool
*
* Description:
* Register I2C drivers for the I2C tool.
*
****************************************************************************/
#ifdef HAVE_I2CTOOL
static void tm4c_i2ctool(void)
{
#ifdef CONFIG_TIVA_I2C0
tm4c_i2c_register(0);
#endif
#ifdef CONFIG_TIVA_I2C1
tm4c_i2c_register(1);
#endif
#ifdef CONFIG_TIVA_I2C2
tm4c_i2c_register(2);
#endif
#ifdef CONFIG_TIVA_I2C3
tm4c_i2c_register(3);
#endif
#ifdef CONFIG_TIVA_I2C4
tm4c_i2c_register(4);
#endif
#ifdef CONFIG_TIVA_I2C5
tm4c_i2c_register(5);
#endif
#ifdef CONFIG_TIVA_I2C6
tm4c_i2c_register(6);
#endif
#ifdef CONFIG_TIVA_I2C7
tm4c_i2c_register(7);
#endif
#ifdef CONFIG_TIVA_I2C8
tm4c_i2c_register(8);
#endif
#ifdef CONFIG_TIVA_I2C9
tm4c_i2c_register(9);
#endif
}
#else
# define tm4c_i2ctool()
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -71,6 +154,10 @@ int tm4c_bringup(void)
int ret;
#endif
/* Register I2C drivers on behalf of the I2C tool */
tm4c_i2ctool();
#ifdef HAVE_TIMER
/* Initialize the timer driver */