diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-12-10 15:56:49 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-12-10 15:56:49 -0600 |
commit | 31b57cd207575e3cfb872d287c0dd1cbd483c6b5 (patch) | |
tree | c0cfb994466bdee8137d1cafb32f50c86a16555f /nuttx/configs/tm4c123g-launchpad | |
parent | 428e4d0f62d5bc8becce4f695f30d6f6f7f14dc0 (diff) | |
download | nuttx-31b57cd207575e3cfb872d287c0dd1cbd483c6b5.tar.gz nuttx-31b57cd207575e3cfb872d287c0dd1cbd483c6b5.tar.bz2 nuttx-31b57cd207575e3cfb872d287c0dd1cbd483c6b5.zip |
TM4C123G LaunchPad: Add initialization logic for an external AT24 EEPROM. This is intended only to suppport testing of the Tiva I2C driver
Diffstat (limited to 'nuttx/configs/tm4c123g-launchpad')
-rw-r--r-- | nuttx/configs/tm4c123g-launchpad/Kconfig | 39 | ||||
-rw-r--r-- | nuttx/configs/tm4c123g-launchpad/README.txt | 148 | ||||
-rw-r--r-- | nuttx/configs/tm4c123g-launchpad/src/Makefile | 32 | ||||
-rw-r--r-- | nuttx/configs/tm4c123g-launchpad/src/tm4c123g-launchpad.h | 75 | ||||
-rw-r--r-- | nuttx/configs/tm4c123g-launchpad/src/tm4c_at24.c | 156 | ||||
-rw-r--r-- | nuttx/configs/tm4c123g-launchpad/src/tm4c_boot.c | 24 | ||||
-rw-r--r-- | nuttx/configs/tm4c123g-launchpad/src/tm4c_bringup.c | 80 | ||||
-rw-r--r-- | nuttx/configs/tm4c123g-launchpad/src/tm4c_nsh.c | 22 |
8 files changed, 549 insertions, 27 deletions
diff --git a/nuttx/configs/tm4c123g-launchpad/Kconfig b/nuttx/configs/tm4c123g-launchpad/Kconfig index beca73b10..5c1f6ce9c 100644 --- a/nuttx/configs/tm4c123g-launchpad/Kconfig +++ b/nuttx/configs/tm4c123g-launchpad/Kconfig @@ -4,4 +4,43 @@ # if ARCH_BOARD_TM4C123G_LAUNCHPAD + +config TM4C123G_LAUNCHPAD_AT24_BLOCKMOUNT + bool "AT24 Serial EEPROM auto-mount" + default n + depends on NSH_ARCHINIT && TIVA_I2C0 && MTD_AT24XX + ---help--- + Automatically initialize the AT24 SPI EEPROM driver when NSH starts. + + The Serial EEPROM was mounted on an external adaptor board and + connected to the LaunchPad thusly: + + - VCC -- VCC + - GND -- GND + - PB2 -- SCL + - PB3 -- SDA + +choice + prompt "AT24 serial EPPROM configuration" + default TM4C123G_LAUNCHPAD_AT24_FTL + depends on TM4C123G_LAUNCHPAD_AT24_BLOCKMOUNT + +config TM4C123G_LAUNCHPAD_AT24_FTL + bool "Create AT24 block driver" + ---help--- + Create the MTD driver for the AT24 and "wrap" the AT24 as a standard + block driver that could then, for example, be mounted using FAT or + any other file system. Any file system may be used, but there will + be no wear-leveling. + +config TM4C123G_LAUNCHPAD_AT24_NXFFS + bool "Create AT24 NXFFS file system" + depends on FS_NXFFS + ---help--- + Create the MTD driver for the AT24 and mount the AT24 device as + a wear-leveling, NuttX FLASH file system (NXFFS). The downside of + NXFFS is that it can be very slow. + +endchoice # AT24 serial EPPROM configuration + endif diff --git a/nuttx/configs/tm4c123g-launchpad/README.txt b/nuttx/configs/tm4c123g-launchpad/README.txt index 619131803..4de583574 100644 --- a/nuttx/configs/tm4c123g-launchpad/README.txt +++ b/nuttx/configs/tm4c123g-launchpad/README.txt @@ -18,6 +18,8 @@ Contents LEDs Serial Console USB Device Controller Functions + AT24 Serial EEPROM + I2C Tool Using OpenOCD and GDB with an FT2232 JTAG emulator TM4C123G LaunchPad Configuration Options Configurations @@ -79,6 +81,152 @@ PIN SIGNAL(S) LanchPad Function 31 PF3/CAN0TX/SSI1FSS/T1CCP1/TRCLK LED_G, GPIO, J4 pin 2 05 PF4/T2CCP0 USR_SW1 (Low when pressed), GPIO, J4 pin 10 +AT24 Serial EEPROM +^^^^^^^^^^^^^^^^^^ + + AT24 Connections + ---------------- + + A AT24C512 Serial EEPPROM was used for tested I2C. There are no I2C + devices on-board the Launchpad, but an external serial EEPROM module + module was used. + + The Serial EEPROM was mounted on an external adaptor board and connected + to the LaunchPad thusly: + + - VCC -- VCC + - GND -- GND + - PB2 -- SCL + - PB3 -- SDA + + Configuration Settings + ---------------------- + + The following configuration settings were used: + + System Type -> Tiva/Stellaris Peripheral Support + CONFIG_TIVA_I2C0=y : Enable I2C + + System Type -> I2C device driver options + TIVA_I2C_FREQUENCY=100000 : Select an I2C frequency + + Device Drivers -> I2C Driver Support + CONFIG_I2C=y : Enable I2C support + CONFIG_I2C_TRANSFER=y : Driver supports the transfer() method + CONFIG_I2C_WRITEREAD=y : Driver supports the writeread() method + + Device Drivers -> Memory Technology Device (MTD) Support + CONFIG_MTD=y : Enable MTD support + CONFIG_MTD_AT24XX=y : Enable the AT24 driver + CONFIG_AT24XX_SIZE=512 : Specifies the AT 24C512 part + CONFIG_AT24XX_ADDR=0x53 : AT24 I2C address + + Application Configuration -> NSH Library + CONFIG_NSH_ARCHINIT=y : NSH board-initialization + + File systems + CONFIG_NXFFS=y : Enables the NXFFS file system + CONFIG_NXFFS_PREALLOCATED=y : Required + : Other defaults are probably OK + + Board Selection + CONFIG_TM4C123G_LAUNCHPAD_AT24_BLOCKMOUNT=y : Mounts AT24 for NSH + CONFIG_TM4C123G_LAUNCHPAD_AT24_NXFFS=y : Mount the AT24 using NXFFS + + You can then format the AT24 EEPROM for a FAT file system and mount the + file system at /mnt/at24 using these NSH commands: + + nsh> mkfatfs /dev/mtdblock0 + nsh> mount -t vfat /dev/mtdblock0 /mnt/at24 + + Then you an use the FLASH as a normal FAT file system: + + nsh> echo "This is a test" >/mnt/at24/atest.txt + nsh> ls -l /mnt/at24 + /mnt/at24: + -rw-rw-rw- 16 atest.txt + nsh> cat /mnt/at24/atest.txt + This is a test + +I2C Tool +======== + + I2C Tool. NuttX supports an I2C tool at apps/system/i2c that can be used + to peek and poke I2C devices. That tool can be enabled by setting the + following: + + System Type -> TIVA Peripheral Support + CONFIG_TIVA_I2C0=y : Enable I2C0 + CONFIG_TIVA_I2C1=y : Enable I2C1 + CONFIG_TIVA_I2C2=y : Enable I2C2 + ... + + System Type -> I2C device driver options + CONFIG_TIVA_I2C0_FREQUENCY=100000 : Select an I2C0 frequency + CONFIG_TIVA_I2C1_FREQUENCY=100000 : Select an I2C1 frequency + CONFIG_TIVA_I2C2_FREQUENCY=100000 : Select an I2C2 frequency + ... + + Device Drivers -> I2C Driver Support + CONFIG_I2C=y : Enable I2C support + CONFIG_I2C_TRANSFER=y : Driver supports the transfer() method + CONFIG_I2C_WRITEREAD=y : Driver supports the writeread() method + + Application Configuration -> NSH Library + CONFIG_SYSTEM_I2CTOOL=y : Enable the I2C tool + CONFIG_I2CTOOL_MINBUS=0 : I2C0 has the minimum bus number 0 + CONFIG_I2CTOOL_MAXBUS=2 : I2C2 has the maximum bus number 2 + CONFIG_I2CTOOL_DEFFREQ=100000 : Pick a consistent frequency + + The I2C tool has extensive help that can be accessed as follows: + + nsh> i2c help + Usage: i2c <cmd> [arguments] + Where <cmd> is one of: + + Show help : ? + List busses : bus + List devices : dev [OPTIONS] <first> <last> + Read register : get [OPTIONS] [<repititions>] + Show help : help + Write register: set [OPTIONS] <value> [<repititions>] + Verify access : verf [OPTIONS] [<value>] [<repititions>] + + Where common "sticky" OPTIONS include: + [-a addr] is the I2C device address (hex). Default: 03 Current: 03 + [-b bus] is the I2C bus number (decimal). Default: 0 Current: 0 + [-r regaddr] is the I2C device register address (hex). Default: 00 Current: 00 + [-w width] is the data width (8 or 16 decimal). Default: 8 Current: 8 + [-s|n], send/don't send start between command and data. Default: -n Current: -n + [-i|j], Auto increment|don't increment regaddr on repititions. Default: NO Current: NO + [-f freq] I2C frequency. Default: 100000 Current: 100000 + + NOTES: + o Arguments are "sticky". For example, once the I2C address is + specified, that address will be re-used until it is changed. + + WARNING: + o The I2C dev command may have bad side effects on your I2C devices. + Use only at your own risk. + + As an example, the I2C dev command can be used to list all devices + responding on I2C0 (the default) like this: + + nsh> i2c dev 0x03 0x77 + 0 1 2 3 4 5 6 7 8 9 a b c d e f + 00: -- -- -- -- -- -- -- -- -- -- -- -- -- + 10: -- -- -- -- -- -- -- -- -- -- 1a -- -- -- -- -- + 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + 30: -- -- -- -- -- -- -- -- -- 39 -- -- -- 3d -- -- + 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + 60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + 70: -- -- -- -- -- -- -- -- + nsh> + + NOTE: This is output from a different board and shows I2C + devices responding at addresses 0x1a, 0x39, 0x3d, and 0x60. + Using OpenOCD and GDB with an FT2232 JTAG emulator ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/nuttx/configs/tm4c123g-launchpad/src/Makefile b/nuttx/configs/tm4c123g-launchpad/src/Makefile index eef968947..4ff1d8e0b 100644 --- a/nuttx/configs/tm4c123g-launchpad/src/Makefile +++ b/nuttx/configs/tm4c123g-launchpad/src/Makefile @@ -35,32 +35,38 @@ -include $(TOPDIR)/Make.defs -CFLAGS += -I$(TOPDIR)/sched +CFLAGS += -I$(TOPDIR)/sched -ASRCS = -AOBJS = $(ASRCS:.S=$(OBJEXT)) -CSRCS = tm4c_boot.c tm4c_ssi.c +ASRCS = +AOBJS = $(ASRCS:.S=$(OBJEXT)) +CSRCS = tm4c_boot.c tm4c_bringup.c tm4c_ssi.c ifeq ($(CONFIG_ARCH_LEDS),y) -CSRCS += tm4c_autoleds.c +CSRCS += tm4c_autoleds.c endif ifeq ($(CONFIG_NSH_ARCHINIT),y) -CSRCS += tm4c_nsh.c +CSRCS += tm4c_nsh.c endif -COBJS = $(CSRCS:.c=$(OBJEXT)) +ifeq ($(CONFIG_MTD_AT24XX),y) +ifeq ($(CONFIG_TIVA_I2C0),y) +CSRCS += tm4c_at24.c +endif +endif + +COBJS = $(CSRCS:.c=$(OBJEXT)) -SRCS = $(ASRCS) $(CSRCS) -OBJS = $(AOBJS) $(COBJS) +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src ifeq ($(WINTOOL),y) - CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}" \ - -I "${shell cygpath -w $(ARCH_SRCDIR)/common}" \ - -I "${shell cygpath -w $(ARCH_SRCDIR)/armv7-m}" + CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}" \ + -I "${shell cygpath -w $(ARCH_SRCDIR)/common}" \ + -I "${shell cygpath -w $(ARCH_SRCDIR)/armv7-m}" else - CFLAGS += -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common -I$(ARCH_SRCDIR)/armv7-m + CFLAGS += -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common -I$(ARCH_SRCDIR)/armv7-m endif all: libboard$(LIBEXT) diff --git a/nuttx/configs/tm4c123g-launchpad/src/tm4c123g-launchpad.h b/nuttx/configs/tm4c123g-launchpad/src/tm4c123g-launchpad.h index 25edac0aa..7d8a9d379 100644 --- a/nuttx/configs/tm4c123g-launchpad/src/tm4c123g-launchpad.h +++ b/nuttx/configs/tm4c123g-launchpad/src/tm4c123g-launchpad.h @@ -49,6 +49,9 @@ /************************************************************************************ * Definitions ************************************************************************************/ +/* Configuration ********************************************************************/ + +#define HAVE_AT24 1 /* How many SSI modules does this chip support? */ @@ -62,6 +65,57 @@ # define CONFIG_SSI1_DISABLE 1 #endif +/* AT24 Serial EEPROM + * + * A AT24C512 Serial EEPPROM was used for tested I2C. There are no I2C + * devices on-board the Launchpad, but an external serial EEPROM module + * module was used. + * + * The Serial EEPROM was mounted on an external adaptor board and connected + * to the LaunchPad thusly: + * + * - VCC -- VCC + * - GND -- GND + * - PB2 -- SCL + * - PB3 -- SDA + */ + +#define AT24_BUS 0 +#define AT24_MINOR 0 + +#if !defined(CONFIG_MTD_AT24XX) || !defined(CONFIG_TIVA_I2C0) +# undef HAVE_AT24 +#endif + +/* Can't support AT25 features if mountpoints are disabled or if we were not + * asked to mount the AT25 part + */ + +#if defined(CONFIG_DISABLE_MOUNTPOINT) || \ + !defined(CONFIG_TM4C123G_LAUNCHPAD_AT24_BLOCKMOUNT) +# undef HAVE_AT24 +#endif + +/* If we are going to mount the AT25, then they user must also have told + * us what to do with it by setting one of these. + */ + +#ifndef CONFIG_FS_NXFFS +# undef CONFIG_TM4C123G_LAUNCHPAD_AT24_NXFFS +#endif + +#if !defined(CONFIG_TM4C123G_LAUNCHPAD_AT24_FTL) && \ + !defined(CONFIG_TM4C123G_LAUNCHPAD_AT24_NXFFS) +# undef HAVE_AT24 +#endif + +#if defined(CONFIG_TM4C123G_LAUNCHPAD_AT24_FTL) && \ + defined(CONFIG_TM4C123G_LAUNCHPAD_AT24_NXFFS) +# warning Both CONFIG_TM4C123G_LAUNCHPAD_AT24_FTL and CONFIG_TM4C123G_LAUNCHPAD_AT24_NXFFS are set +# warning Ignoring CONFIG_TM4C123G_LAUNCHPAD_AT24_NXFFS +# undef CONFIG_TM4C123G_LAUNCHPAD_AT24_NXFFS +#endif + /* TM4C123G LaunchPad ***************************************************************/ /* The TM4C123G 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 @@ -147,6 +201,27 @@ void weak_function tm4c_ssiinitialize(void); void tm4c_ledinit(void); #endif +/**************************************************************************** + * Name: tm4c_bringup + * + * Description: + * Bring up board features + * + ****************************************************************************/ + +int tm4c_bringup(void); + +/**************************************************************************** + * Name: tm4c_at24_automount + * + * Description: + * Initialize and configure the AT24 serial EEPROM + * + ****************************************************************************/ + +#ifdef HAVE_AT24 +int tm4c_at24_automount(int minor); +#endif #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_TM4C123G_LAUNCHPAD_TM4C123G_LAUNCHPAD_H */ diff --git a/nuttx/configs/tm4c123g-launchpad/src/tm4c_at24.c b/nuttx/configs/tm4c123g-launchpad/src/tm4c_at24.c new file mode 100644 index 000000000..cec31e034 --- /dev/null +++ b/nuttx/configs/tm4c123g-launchpad/src/tm4c_at24.c @@ -0,0 +1,156 @@ +/**************************************************************************** + * config/sama5d3x-ek/src/tm4c_at24.c + * + * Copyright (C) 2014 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. + * + ****************************************************************************/ + +/* AT24 Serial EEPROM + * + * A AT24C512 Serial EEPPROM was used for tested I2C. There are no I2C + * devices on-board the Launchpad, but an external serial EEPROM module + * module was used. + * + * The Serial EEPROM was mounted on an external adaptor board and connected + * to the LaunchPad thusly: + * + * - VCC -- VCC + * - GND -- GND + * - PB2 -- SCL + * - PB3 -- SDA + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <sys/mount.h> + +#include <stdbool.h> +#include <stdio.h> +#include <errno.h> +#include <debug.h> + +#include <nuttx/i2c.h> +#include <nuttx/mtd/mtd.h> +#include <nuttx/fs/nxffs.h> + +#include "tm4c123g-launchpad.h" + +#ifdef HAVE_AT24 + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tm4c_at24_automount + * + * Description: + * Initialize and configure the AT24 serial EEPROM + * + ****************************************************************************/ + +int tm4c_at24_automount(int minor) +{ + FAR struct i2c_dev_s *i2c; + FAR struct mtd_dev_s *mtd; + static bool initialized = false; + int ret; + + /* Have we already initialized? */ + + if (!initialized) + { + /* No.. Get the I2C bus driver */ + + i2c = up_i2cinitialize(AT24_BUS); + if (!i2c) + { + syslog(LOG_ERR, "ERROR: Failed to initialize SPI%d\n", AT24_BUS); + return -ENODEV; + } + + /* Now bind the I2C interface to the AT24 I2C EEPROM driver */ + + mtd = at24c_initialize(i2c); + if (!mtd) + { + syslog(LOG_ERR, + "ERROR: Failed to bind SPI%d to the AT24 EEPROM driver\n", + AT24_BUS); + return -ENODEV; + } + +#if defined(CONFIG_TM4C123G_LAUNCHPAD_AT24_FTL) + /* And finally, use the FTL layer to wrap the MTD driver as a block driver */ + + ret = ftl_initialize(AT24_MINOR, mtd); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n", ret); + return ret; + } + +#elif defined(CONFIG_TM4C123G_LAUNCHPAD_AT24_NXFFS) + /* Initialize to provide NXFFS on the MTD interface */ + + ret = nxffs_initialize(mtd); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: NXFFS initialization failed: %d\n", ret); + return ret; + } + + /* Mount the file system at /mnt/at24 */ + + ret = mount(NULL, "/mnt/at24", "nxffs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount the NXFFS volume: %d\n", errno); + return ret; + } +#endif + /* Now we are initialized */ + + initialized = true; + } + + return OK; +} + +#endif /* HAVE_AT24 */ diff --git a/nuttx/configs/tm4c123g-launchpad/src/tm4c_boot.c b/nuttx/configs/tm4c123g-launchpad/src/tm4c_boot.c index 067c133bf..e30d62449 100644 --- a/nuttx/configs/tm4c123g-launchpad/src/tm4c_boot.c +++ b/nuttx/configs/tm4c123g-launchpad/src/tm4c_boot.c @@ -64,7 +64,7 @@ * * Description: * All Tiva architectures must provide the following entry point. This entry - * point is called early in the intitialization -- after all memory has been + * point is called early in the initialization -- after all memory has been * configured and mapped but before any devices have been initialized. * ************************************************************************************/ @@ -90,3 +90,25 @@ void tiva_boardinitialize(void) tm4c_ledinit(); #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_intiialize() 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 initialization */ + + (void)tm4c_bringup(); +} +#endif /* CONFIG_BOARD_INITIALIZE */ diff --git a/nuttx/configs/tm4c123g-launchpad/src/tm4c_bringup.c b/nuttx/configs/tm4c123g-launchpad/src/tm4c_bringup.c new file mode 100644 index 000000000..504c2450e --- /dev/null +++ b/nuttx/configs/tm4c123g-launchpad/src/tm4c_bringup.c @@ -0,0 +1,80 @@ +/**************************************************************************** + * config/tm4c123g-launchpad/src/tm4c_bringup.c + * + * Copyright (C) 2014 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 <syslog.h> + +#include "tm4c123g-launchpad.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tm4c_bringup + * + * Description: + * Bring up board features + * + ****************************************************************************/ + +int tm4c_bringup(void) +{ +#ifdef HAVE_AT24 + int ret; + + /* Initialize the AT24 driver */ + + ret = tm4c_at24_automount(AT24_MINOR); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: tm4c_at24_automount failed: %d\n", ret); + } + + return ret; +#else + return OK; +#endif /* HAVE_AT24 */ +} diff --git a/nuttx/configs/tm4c123g-launchpad/src/tm4c_nsh.c b/nuttx/configs/tm4c123g-launchpad/src/tm4c_nsh.c index 54fe013d3..405373017 100644 --- a/nuttx/configs/tm4c123g-launchpad/src/tm4c_nsh.c +++ b/nuttx/configs/tm4c123g-launchpad/src/tm4c_nsh.c @@ -39,24 +39,12 @@ #include <nuttx/config.h> -#include <stdio.h> -#include <syslog.h> -#include <errno.h> - -#include <nuttx/spi/spi.h> -#include <nuttx/mmcsd.h> +#include "tm4c123g-launchpad.h" /**************************************************************************** * Pre-Processor Definitions ****************************************************************************/ -/* Configuration ************************************************************/ - -/* Can't support USB features if USB is not enabled */ - -#ifndef CONFIG_USBDEV -# undef NSH_HAVEUSBDEV -#endif /**************************************************************************** * Public Functions @@ -72,5 +60,13 @@ int nsh_archinitialize(void) { + /* If CONFIG_BOARD_INITIALIZE is selected then board initialization was + * already performed in board_initialize. + */ + +#ifndef CONFIG_BOARD_INITIALIZE + return tm4c_bringup(); +#else return OK; +#endif } |