diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-05-24 10:00:54 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-05-24 10:00:54 -0600 |
commit | d890cd67c3ef9e702a71bb5ed2f8a5e9e6d4cfac (patch) | |
tree | fddaba58cf98713c67b49be42e2936fa4ffe69a3 | |
parent | 4ed66f6618f4d13276d3135e9e2bfc6f8b5a2c3e (diff) | |
download | px4-nuttx-d890cd67c3ef9e702a71bb5ed2f8a5e9e6d4cfac.tar.gz px4-nuttx-d890cd67c3ef9e702a71bb5ed2f8a5e9e6d4cfac.tar.bz2 px4-nuttx-d890cd67c3ef9e702a71bb5ed2f8a5e9e6d4cfac.zip |
Add apps/examples/slcd, Remove USB from STM32L-Discovery, LSE support for the STM32 L family, some STM32L-Discovery LCD debug changes
-rw-r--r-- | apps/ChangeLog.txt | 3 | ||||
-rw-r--r-- | apps/examples/Kconfig | 1 | ||||
-rw-r--r-- | apps/examples/Make.defs | 4 | ||||
-rw-r--r-- | apps/examples/Makefile | 4 | ||||
-rw-r--r-- | apps/examples/README.txt | 8 | ||||
-rw-r--r-- | apps/examples/slcd/.gitignore | 13 | ||||
-rw-r--r-- | apps/examples/slcd/Kconfig | 26 | ||||
-rw-r--r-- | apps/examples/slcd/Makefile | 109 | ||||
-rw-r--r-- | apps/examples/slcd/slcd_main.c | 226 | ||||
-rw-r--r-- | nuttx/ChangeLog | 6 | ||||
-rw-r--r-- | nuttx/arch/arm/src/stm32/stm32_lse.c | 69 | ||||
-rw-r--r-- | nuttx/arch/arm/src/stm32/stm32_rcc.h | 3 | ||||
-rw-r--r-- | nuttx/configs/stm32ldiscovery/README.txt | 49 | ||||
-rw-r--r-- | nuttx/configs/stm32ldiscovery/src/Makefile | 12 | ||||
-rw-r--r-- | nuttx/configs/stm32ldiscovery/src/stm32_boot.c | 12 | ||||
-rw-r--r-- | nuttx/configs/stm32ldiscovery/src/stm32_lcd.c | 144 | ||||
-rw-r--r-- | nuttx/configs/stm32ldiscovery/src/stm32_nsh.c | 47 | ||||
-rw-r--r-- | nuttx/configs/stm32ldiscovery/src/stm32_usb.c | 131 | ||||
-rw-r--r-- | nuttx/configs/stm32ldiscovery/src/stm32ldiscovery.h | 13 |
19 files changed, 643 insertions, 237 deletions
diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 474c1fd63..f064a61f6 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -560,3 +560,6 @@ * apps/examples/tcpecho: Added a simple single threaded, poll based TCP echo server based on W. Richard Stevens UNIX Network Programming Book. Contributed by Max Holtberg (2013-5-22). + * apps/examples/slcd: Add an example for testing alphanumeric, + segment LCDs (2013-5-24). + diff --git a/apps/examples/Kconfig b/apps/examples/Kconfig index 97e6ce140..57671ac4c 100644 --- a/apps/examples/Kconfig +++ b/apps/examples/Kconfig @@ -47,6 +47,7 @@ source "$APPSDIR/examples/rgmp/Kconfig" source "$APPSDIR/examples/romfs/Kconfig" source "$APPSDIR/examples/sendmail/Kconfig" source "$APPSDIR/examples/serloop/Kconfig" +source "$APPSDIR/examples/slcd/Kconfig" source "$APPSDIR/examples/flash_test/Kconfig" source "$APPSDIR/examples/smart_test/Kconfig" source "$APPSDIR/examples/smart/Kconfig" diff --git a/apps/examples/Make.defs b/apps/examples/Make.defs index 28399192b..bb411d4f8 100644 --- a/apps/examples/Make.defs +++ b/apps/examples/Make.defs @@ -214,6 +214,10 @@ ifeq ($(CONFIG_EXAMPLES_SERLOOP),y) CONFIGURED_APPS += examples/serloop endif +ifeq ($(CONFIG_EXAMPLES_SLCD),y) +CONFIGURED_APPS += examples/slcd +endif + ifeq ($(CONFIG_EXAMPLES_FLASH_TEST),y) CONFIGURED_APPS += examples/flash_test endif diff --git a/apps/examples/Makefile b/apps/examples/Makefile index 2ffe131c6..906e479ac 100644 --- a/apps/examples/Makefile +++ b/apps/examples/Makefile @@ -41,7 +41,7 @@ SUBDIRS = adc buttons can cdcacm composite cxxtest dhcpd discover elf SUBDIRS += flash_test ftpc ftpd hello helloxx hidkbd igmp json keypadtest SUBDIRS += lcdrw mm modbus mount mtdpart nettest nsh null nx nxconsole nxffs SUBDIRS += nxflat nxhello nximage nxlines nxtext ostest pashello pipe poll -SUBDIRS += posix_spawn pwm qencoder relays rgmp romfs sendmail serloop +SUBDIRS += posix_spawn pwm qencoder relays rgmp romfs sendmail serloop slcd SUBDIRS += smart smart_test tcpecho telnetd thttpd tiff touchscreen udp uip SUBDIRS += usbserial usbstorage usbterm watchdog wget wgetjson xmlrpc @@ -60,7 +60,7 @@ CNTXTDIRS = pwm ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) CNTXTDIRS += adc can cdcacm composite cxxtest dhcpd discover flash_test ftpd CNTXTDIRS += hello helloxx json keypadtestmodbus mtdpart nettest nxlines relays -CNTXTDIRS += qencoder smart_test tcpecho telnetd watchdog wgetjson +CNTXTDIRS += qencoder slcd smart_test tcpecho telnetd watchdog wgetjson endif ifeq ($(CONFIG_EXAMPLES_LCDRW_BUILTIN),y) diff --git a/apps/examples/README.txt b/apps/examples/README.txt index ac922a703..2e1454b3f 100644 --- a/apps/examples/README.txt +++ b/apps/examples/README.txt @@ -1469,13 +1469,19 @@ examples/serloop Use C buffered I/O (getchar/putchar) vs. raw console I/O (read/read). +examples/slcd +^^^^^^^^^^^^^ + A simple test of alphanumeric, segment LCDs (SLCDs). + + * CONFIG_EXAMPLES_SLCD - Enable the SLCD test + examples/smart ^^^^^^^^^^^^^^ This is a test of the SMART file systemt that derives from examples/nxffs. - * CONFIG_EXAMPLES_SMART: -Enable the SMART file system example + * CONFIG_EXAMPLES_SMART: - Enable the SMART file system example * CONFIG_EXAMPLES_SMART_ARCHINIT: The default is to use the RAM MTD device at drivers/mtd/rammtd.c. But an architecture-specific MTD driver can be used instead by defining CONFIG_EXAMPLES_SMART_ARCHINIT. In diff --git a/apps/examples/slcd/.gitignore b/apps/examples/slcd/.gitignore new file mode 100644 index 000000000..4480560f5 --- /dev/null +++ b/apps/examples/slcd/.gitignore @@ -0,0 +1,13 @@ +Make.dep +.depend +.built +*.swp +*.asm +*.rel +*.lst +*.sym +*.adb +*.lib +*.src + + diff --git a/apps/examples/slcd/Kconfig b/apps/examples/slcd/Kconfig new file mode 100644 index 000000000..5f56827fc --- /dev/null +++ b/apps/examples/slcd/Kconfig @@ -0,0 +1,26 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# + +config EXAMPLES_SLCD + bool "Segment LCD test" + default n + ---help--- + Enables a simple test of an alphanumer, segment LCD + +if EXAMPLES_SLCD + +config EXAMPLES_SLCD_DEVNAME + string "SLCD device path" + default "/dev/slcd" + ---help--- + The full path to the SLCD device to be tested + +config EXAMPLES_SLCD_BUFSIZE + int "I/O buffer size" + default 64 + ---help--- + The size of the I/O buffer to use in the test (not a critical setting) + +endif diff --git a/apps/examples/slcd/Makefile b/apps/examples/slcd/Makefile new file mode 100644 index 000000000..c7ac96950 --- /dev/null +++ b/apps/examples/slcd/Makefile @@ -0,0 +1,109 @@ +############################################################################ +# apps/examples/slcd/Makefile +# +# Copyright (C) 2013 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. +# +############################################################################ + +-include $(TOPDIR)/.config +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +# Hello, World! built-in application info + +APPNAME = slcd +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 2048 + +# Hello, World! Example + +ASRCS = +CSRCS = slcd_main.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else +ifeq ($(WINTOOL),y) + BIN = ..\\..\\libapps$(LIBEXT) +else + BIN = ../../libapps$(LIBEXT) +endif +endif + +ROOTDEPPATH = --dep-path . + +# Common build + +VPATH = + +all: .built +.PHONY: clean depend distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + $(call ARCHIVE, $(BIN), $(OBJS)) + @touch .built + +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile + $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) + +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif + +.depend: Makefile $(SRCS) + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + $(call DELFILE, .built) + $(call CLEAN) + +distclean: clean + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + +-include Make.dep diff --git a/apps/examples/slcd/slcd_main.c b/apps/examples/slcd/slcd_main.c new file mode 100644 index 000000000..8cc88c6fc --- /dev/null +++ b/apps/examples/slcd/slcd_main.c @@ -0,0 +1,226 @@ +/**************************************************************************** + * examples/clcd/slcd_main.c + * + * Copyright (C) 2013 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 <sys/ioctl.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <fcntl.h> +#include <errno.h> + +#include <nuttx/lcd/slcd_codec.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef EXAMPLES_SLCD_DEVNAME +# define EXAMPLES_SLCD_DEVNAME "/dev/slcd" +#endif + +/**************************************************************************** + * Private Typs + ****************************************************************************/ +/* All state information for this test is kept within the following structure + * in order create a namespace and to minimize the possibility of name + * collisions. + */ + +struct slcd_test_s +{ + struct lib_outstream_s stream; /* Stream to use for all output */ + struct slcd_geometry_s geo; /* Size of the SLCD (rows x columns) */ + int fd; /* File descriptor or the open SLCD device */ + + /* The I/O buffer */ + + char buffer[CONFIG_EXAMPLES_SLCD_BUFSIZE]; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct slcd_test_s g_slcdtest; +static const char g_slcdhello[] = "hello"; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: slcd_putc + ****************************************************************************/ + +static int slcd_flush(FAR struct lib_outstream_s *stream) +{ + FAR struct slcd_test_s *priv = (FAR struct slcd_test_s *)stream; + ssize_t nwritten; + ssize_t remaining; + + /* Loop until all bytes were written (handling both partial and interrupted + * writes). + */ + + remaining = stream->nput; + while (remaining > 0); + { + nwritten = write(priv->fd, priv->buffer, remaining); + if (nwritten < 0) + { + int errcode = errno; + printf("write failed: %d\n", errcode); + + if (errcode != EINTR) + { + exit(EXIT_FAILURE); + } + } + else + { + remaining -= nwritten; + } + } + + /* Reset the stream */ + + stream->nput = 0; + return OK; +} + +/**************************************************************************** + * Name: slcd_putc + ****************************************************************************/ + +static void slcd_putc(FAR struct lib_outstream_s *stream, int ch) +{ + FAR struct slcd_test_s *priv = (FAR struct slcd_test_s *)stream; + + /* Write the character to the buffer */ + + priv->buffer[stream->nput] = ch; + stream->nput++; + priv->buffer[stream->nput] = '\0'; + + /* If the buffer is full, flush it */ + + if (stream->nput >=- CONFIG_EXAMPLES_SLCD_BUFSIZE) + { + (void)slcd_flush(stream); + } +} + +/**************************************************************************** + * Name: slcd_puts + ****************************************************************************/ + +static void slcd_puts(FAR struct lib_outstream_s *outstream, + FAR const char *str) +{ + for (; *str; str++) + { + slcd_put((int)*str, outstream); + } +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * slcd_main + ****************************************************************************/ + +int slcd_main(int argc, char *argv[]) +{ + FAR struct slcd_test_s *priv = &g_slcdtest; + int ret; + + /* Initialize the output stream */ + + memset(priv, 0, sizeof(struct slcd_test_s)); + priv->stream.put = slcd_putc; +#ifdef CONFIG_STDIO_LINEBUFFER + priv->stream.flush = lib_noflush; +#endif + + /* Open the SLCD device */ + + printf("Opening %s for read/write access\n", EXAMPLES_SLCD_DEVNAME); + + priv->fd = open(EXAMPLES_SLCD_DEVNAME, O_RDWR); + if (priv->fd < 0) + { + printf("Failed to open %s: %d\n", EXAMPLES_SLCD_DEVNAME, errno); + goto errout; + } + + /* Get the geometry of the SCLD device */ + + ret = ioctl(priv->fd, SLCDIOC_GEOMETRY, (unsigned long)&priv->geo); + if (ret < 0) + { + printf("Failed to open %s: %d\n", EXAMPLES_SLCD_DEVNAME, errno); + goto errout_with_fd; + } + + printf("Geometry rows: %d columns: %d\n", + priv->geo.nrows, priv->geo.ncolumns); + + /* Home the cursor and clear the display */ + + slcd_encode(SLCDCODE_CLEAR, 0, &priv->stream); + + /* Say hello */ + + slcd_puts(&priv->stream, g_slcdhello); + + /* Normal exit */ + + close(priv->fd); + return 0; + +errout_with_fd: + close(priv->fd); +errout: + exit(EXIT_FAILURE); +} diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 0c53a1133..9936b1ed8 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -4785,3 +4785,9 @@ * include/nuttx/fs/ioctl.h, include/nuttx/lcd/slcd_codec.h, and configs/stm32ldiscovery/src/stm32_lcd.c: Add SLCD ioctl commands to get SLCD geometry, set bars, and manage contrast (2013-5-23). + * configs/stm32ldiscovery/src/stm32_usb.c: This file and all references + to USB removed for the STM32L-Discovery. While the chip supports a + USB device, the board does not (2013-5-24). + * arch/arm/src/stm32/stm32_lse.c: Add support for the STM32L CSR register + and for the LSE LCD clock source (2013-5-24). + diff --git a/nuttx/arch/arm/src/stm32/stm32_lse.c b/nuttx/arch/arm/src/stm32/stm32_lse.c index 8f2a52287..1080b4b20 100644 --- a/nuttx/arch/arm/src/stm32/stm32_lse.c +++ b/nuttx/arch/arm/src/stm32/stm32_lse.c @@ -47,18 +47,6 @@ /**************************************************************************** * Definitions ****************************************************************************/ -/* The STM32L15XX family has no BDSR register. The equivalent settings are - * in the CSR register for those chips. - */ - -#ifdef CONFIG_STM32_STM32L15XX -# define STM32_RCC_BDCR STM32_RCC_CSR -# define RCC_BDCR_LSEON RCC_CSR_LSEON -# define RCC_BDCR_LSERDY RCC_CSR_LSERDY -# define RCC_BDCR_RTCSEL_MASK RCC_CSR_RTCSEL_MASK -# define RCC_BDCR_RTCSEL_LSE RCC_CSR_RTCSEL_LSE -# define RCC_BDCR_RTCEN RCC_CSR_RTCEN -#endif /**************************************************************************** * Private Data @@ -76,17 +64,58 @@ * Name: stm32_rcc_enablelse * * Description: - * Enable the External Low-Speed (LSE) Oscillator and, if the RTC is + * Enable the External Low-Speed (LSE) oscillator and, if the RTC is * configured, setup the LSE as the RTC clock source, and enable the RTC. * + * For the STM32L15X family, this will also select the LSE as the clock + * source of the LCD. + * * Todo: * Check for LSE good timeout and return with -1, * ****************************************************************************/ +#ifdef CONFIG_STM32_STM32L15XX +void stm32_rcc_enablelse(void) +{ + /* Enable the External Low-Speed (LSE) oscillator by setting the LSEON bit + * the RCC CSR register. + */ + + modifyreg32(STM32_RCC_CSR, 0, RCC_CSR_LSEON); + + /* Wait for the LSE clock to be ready */ + + while ((getreg32(STM32_RCC_CSR) & RCC_CSR_LSERDY) == 0) + { + up_waste(); + } + + /* The primariy purpose of the LSE clock is to drive the RTC with an accurate + * clock source. In the STM32L family, the RTC and the LCD are coupled so + * that must use the same clock source. Calling this function will select + * the LSE will be used to drive the LCD as well. + */ + +#if defined(CONFIG_STM32_LCD) || defined(CONFIG_RTC) + /* Select LSE as RTC/LCD Clock Source by setting the RTCSEL field of the RCC + * CSR register. + */ + + modifyreg32(STM32_RCC_CSR, RCC_CSR_RTCSEL_MASK, RCC_CSR_RTCSEL_LSE); + +#if defined(CONFIG_RTC) + /* Enable the RTC Clock by setting the RTCEN bit in the RCC CSR register */ + + modifyreg32(STM32_RCC_CSR, 0, RCC_CSR_RTCEN); +#endif +#endif +} +#else + void stm32_rcc_enablelse(void) { - /* Enable the External Low-Speed (LSE) Oscillator by setting the LSEON bit + /* Enable the External Low-Speed (LSE) oscillator by setting the LSEON bit * the RCC BDCR register. */ @@ -98,20 +127,22 @@ void stm32_rcc_enablelse(void) { up_waste(); } - + /* The primariy purpose of the LSE clock is to drive the RTC. The RTC could * also be driven by the LSI (but that would be very inaccurate) or by the * HSE (but that would prohibit low-power operation) - * - * Select LSE as RTC Clock Source by setting the RTCSEL field of the RCC BDCR - * register. */ #ifdef CONFIG_RTC + /* Select LSE as RTC Clock Source by setting the RTCSEL field of the RCC + * BDCR register. + */ + modifyreg16(STM32_RCC_BDCR, RCC_BDCR_RTCSEL_MASK, RCC_BDCR_RTCSEL_LSE); /* Enable the RTC Clock by setting the RTCEN bit in the RCC BDCR register */ - modifyreg16(STM32_RCC_BDCR, 0, RCC_BDCR_RTCEN); + modifyreg16(STM32_RCC_BDCR, 0, RCC_BDCR_RTCEN); #endif } +#endif diff --git a/nuttx/arch/arm/src/stm32/stm32_rcc.h b/nuttx/arch/arm/src/stm32/stm32_rcc.h index 9859be61b..4f96f21da 100644 --- a/nuttx/arch/arm/src/stm32/stm32_rcc.h +++ b/nuttx/arch/arm/src/stm32/stm32_rcc.h @@ -262,6 +262,9 @@ void stm32_clockenable(void); * Enable the External Low-Speed (LSE) Oscillator and, if the RTC is * configured, setup the LSE as the RTC clock source, and enable the RTC. * + * For the STM32L15X family, this will also select the LSE as the clock source of + * the LCD. + * * Input Parameters: * None * diff --git a/nuttx/configs/stm32ldiscovery/README.txt b/nuttx/configs/stm32ldiscovery/README.txt index 308dec381..73a5c54f6 100644 --- a/nuttx/configs/stm32ldiscovery/README.txt +++ b/nuttx/configs/stm32ldiscovery/README.txt @@ -743,12 +743,49 @@ Configurations for Windows and builds under Cygwin (or probably MSYS). That can easily be reconfigured, of course. - CONFIG_HOST_WINDOWS=y : Builds under Windows - CONFIG_WINDOWS_CYGWIN=y : Using Cygwin - CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y : CodeSourcery for Windows + Build Setup: + CONFIG_HOST_WINDOWS=y : Builds under Windows + CONFIG_WINDOWS_CYGWIN=y : Using Cygwin + + System Type: + CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y : CodeSourcery for Windows 5. To enable SLCD support: - CONFIG_ARCH_LEDS=y : Disable LED support - CONFIG_LIB_SLCDCODEC=y : Enable the SLCD CODEC - CONFIG_STM32_LCD=y : Enable the SLCD + Board Selection: + CONFIG_ARCH_LEDS=y : Disable LED support + + Library Routines: + CONFIG_LIB_SLCDCODEC=y : Enable the SLCD CODEC + + System Type: + CONFIG_STM32_LCD=y : Enable the SLCD + + When the LCD is enabled and the LEDs are disabled, the USART1 + serial console will automaticall move to PB6 and PB7 (you will get + a compilation error if you forget to disable the LEDs). + + SIGNAL FUNCTION LED CONNECTION + ------ ---------- ---------- ----------- + PB6 USART1_TX LED Blue P2, pin 8 + PB7 USART1_RX LED Green P2, pin 7 + + To enable apps/examples/slcd to test the SLCD: + + Binary Formats: + CONFIG_BINFMT_DISABLE=n : Don't disable binary support + CONFIG_BUILTIN=y : Enable support for built-in binaries + + Application Configuration: + CONFIG_NSH_BUILTIN_APPS=y : Enable builtin apps in NSH + CONFIG_NSH_ARCHINIT=y : Needed to initialize the SLCD + CONFIG_EXAMPLES_SLCD=y : Enable apps/examples/slcd + + To enable LCD debug output: + + Device Drivers: + CONFIG_LCD=y : (Needed to enable LCD debug) + + Build Setup: + CONFIG_DEBUG=y : Enable debug features + CONFIG_DEBUG_VERBOSE=y : Enable LCD debug diff --git a/nuttx/configs/stm32ldiscovery/src/Makefile b/nuttx/configs/stm32ldiscovery/src/Makefile index 1e0bd225c..d3e0f5d3e 100644 --- a/nuttx/configs/stm32ldiscovery/src/Makefile +++ b/nuttx/configs/stm32ldiscovery/src/Makefile @@ -60,6 +60,18 @@ ifeq ($(CONFIG_STM32_LCD),y) CSRCS += stm32_lcd.c endif +ifeq ($(CONFIG_PWM),y) +CSRCS += up_pwm.c +endif + +ifeq ($(CONFIG_QENCODER),y) +CSRCS += up_qencoder.c +endif + +ifeq ($(CONFIG_WATCHDOG),y) +CSRCS += up_watchdog.c +endif + ifeq ($(CONFIG_NSH_ARCHINIT),y) CSRCS += stm32_nsh.c endif diff --git a/nuttx/configs/stm32ldiscovery/src/stm32_boot.c b/nuttx/configs/stm32ldiscovery/src/stm32_boot.c index b45f57204..db515e458 100644 --- a/nuttx/configs/stm32ldiscovery/src/stm32_boot.c +++ b/nuttx/configs/stm32ldiscovery/src/stm32_boot.c @@ -82,18 +82,6 @@ void stm32_boardinitialize(void) } #endif - /* Initialize USB if the 1) USB device controller is in the configuration and 2) - * disabled, and 3) the weak function stm32_usbinitialize() has been brought - * into the build. Presumeably either CONFIG_USBDEV is also selected. - */ - -#ifdef CONFIG_STM32_USB - if (stm32_usbinitialize) - { - stm32_usbinitialize(); - } -#endif - /* Configure on-board LEDs if LED support has been selected. */ #ifdef CONFIG_ARCH_LEDS diff --git a/nuttx/configs/stm32ldiscovery/src/stm32_lcd.c b/nuttx/configs/stm32ldiscovery/src/stm32_lcd.c index 4f19285b3..c94eeea09 100644 --- a/nuttx/configs/stm32ldiscovery/src/stm32_lcd.c +++ b/nuttx/configs/stm32ldiscovery/src/stm32_lcd.c @@ -63,6 +63,7 @@ #include "up_arch.h" #include "stm32_gpio.h" +#include "stm32_rcc.h" #include "chip/stm32_lcd.h" #include "stm32ldiscovery.h" @@ -291,6 +292,16 @@ struct stm32_slcdstate_s /**************************************************************************** * Private Function Protototypes ****************************************************************************/ +/* Debug */ + +#if defined(CONFIG_DEBUG_LCD) && defined(CONFIG_DEBUG_VERBOSE) +static void slcd_dumpstate(FAR const char *msg); +static void slcd_dumpslcd(FAR const char *msg); +#else +# define slcd_dumpstate(msg) +# define slcd_dumpslcd(msg) +#endif + /* Internal utilities */ static void slcd_clear(void); @@ -299,7 +310,7 @@ static uint8_t slcd_getcontrast(void); static int slcd_setcontrast(uint8_t contrast); static void slcd_writebar(void); static inline uint16_t slcd_mapch(uint8_t ch); -static inline void slcd_writemem(uint16_t bitset, int curpos); +static inline void slcd_writemem(uint16_t segset, int curpos); static void slcd_writech(uint8_t ch, uint8_t curpos, uint8_t options); static inline void slcd_appendch(uint8_t ch, uint8_t options); static inline void slcd_action(enum slcdcode_e code, uint8_t count); @@ -422,6 +433,44 @@ static uint32_t g_slcdgpio[BOARD_SLCD_NGPIOS] = ****************************************************************************/ /**************************************************************************** + * Name: slcd_dumpstate + ****************************************************************************/ + +#if defined(CONFIG_DEBUG_LCD) && defined(CONFIG_DEBUG_VERBOSE) +static void slcd_dumpstate(FAR const char *msg) +{ + lcdvdbg("%s:\n", msg); + lcdvdbg(" curpos: %d\n", + g_slcdstate.curpos); + lcdvdbg(" Display: [%c%c%c%c%c%c]\n", + g_slcdstate.buffer[0], g_slcdstate.buffer[1], g_slcdstate.buffer[2], + g_slcdstate.buffer[3], g_slcdstate.buffer[4], g_slcdstate.buffer[5]); + lcdvdbg(" Options: [%d%d%d%d%d%d]\n", + g_slcdstate.options[0], g_slcdstate.options[1], g_slcdstate.options[2], + g_slcdstate.options[3], g_slcdstate.options[4], g_slcdstate.options[5]); + lcdvdbg(" Bar: %02x %02x\n", + g_slcdstate.bar[0], g_slcdstate.bar[1]); +} +#endif + +/**************************************************************************** + * Name: slcd_dumpslcd + ****************************************************************************/ + +#if defined(CONFIG_DEBUG_LCD) && defined(CONFIG_DEBUG_VERBOSE) +static void slcd_dumpslcd(FAR const char *msg) +{ + lcdvdbg("%s:\n", msg); + lcdvdbg(" CR: %08x FCR: %08x SR: %08x CLR: %08x:\n", + getreg32(STM32_LCD_CR), getreg32(STM32_LCD_FCR), + getreg32(STM32_LCD_SR), getreg32(STM32_LCD_CLR)); + lcdvdbg(" RAM0L: %08x RAM0L: %08x RAM0L: %08x RAM0L: %08x\n", + getreg32(STM32_LCD_RAM0L), getreg32(STM32_LCD_RAM1L), + getreg32(STM32_LCD_RAM2L), getreg32(STM32_LCD_RAM3L)); +} +#endif + +/**************************************************************************** * Name: slcd_clear ****************************************************************************/ @@ -429,6 +478,8 @@ static void slcd_clear(void) { uint32_t regaddr; + lvdbg("Clearing\n"); + /* Make sure that any previous transfer is complete. The firmware sets * the UDR each it modifies the LCD_RAM. The UDR bit stays set until the * end of the update. During this time the LCD_RAM is write protected. @@ -509,6 +560,10 @@ static int slcd_setcontrast(uint8_t contrast) regval &= !LCD_FCR_CC_MASK; regval |= contrast << LCD_FCR_CC_SHIFT; putreg32(regval, STM32_LCD_FCR); + + lcdvdbg("contrast: %d FCR: %08x\n", + getreg32(STM32_LCD_FCR), contrast); + return ret; } @@ -520,6 +575,9 @@ static void slcd_writebar(void) { uint32_t regval; + lcdvdbg("bar: %02x %02x\n", g_slcdstate.bar[0], g_slcdstate.bar[1]); + slcd_dumpslcd("BEFORE WRITE"); + /* Make sure that any previous transfer is complete. The firmware sets * the UDR each it modifies the LCD_RAM. The UDR bit stays set until the * end of the update. During this time the LCD_RAM is write protected. @@ -544,6 +602,7 @@ static void slcd_writebar(void) */ putreg32(1, SLCD_SR_UDR_BB); + slcd_dumpslcd("AFTER WRITE"); } /**************************************************************************** @@ -622,7 +681,7 @@ static inline uint16_t slcd_mapch(uint8_t ch) * Name: slcd_writemem ****************************************************************************/ -static inline void slcd_writemem(uint16_t bitset, int curpos) +static inline void slcd_writemem(uint16_t segset, int curpos) { uint8_t segments[4]; uint32_t ram0; @@ -632,13 +691,19 @@ static inline void slcd_writemem(uint16_t bitset, int curpos) int i; int j; + lcdvdbg("segset: %04x curpos: %d\n", segset, curpos); + slcd_dumpslcd("BEFORE WRITE"); + /* Isolate the least significant bits */ for (i = 12, j = 0; j < 4; i -= 4, j++) { - segments[j] = (bitset >> i) & 0x0f; + segments[j] = (segset >> i) & 0x0f; } + lcdvdbg("segments: %02x %02x %02x %02x\n", + segments[0], segments[1], segments[2], segments[3]); + /* Make sure that any previous transfer is complete. The firmware sets * the UDR each it modifies the LCD_RAM. The UDR bit stays set until the * end of the update. During this time the LCD_RAM is write protected. @@ -755,6 +820,7 @@ static inline void slcd_writemem(uint16_t bitset, int curpos) */ putreg32(1, SLCD_SR_UDR_BB); + slcd_dumpslcd("AFTER WRITE"); } /**************************************************************************** @@ -763,31 +829,35 @@ static inline void slcd_writemem(uint16_t bitset, int curpos) static void slcd_writech(uint8_t ch, uint8_t curpos, uint8_t options) { - uint16_t bitset; + uint16_t segset; /* Map the character code to a 16-bit encoded value */ - bitset = slcd_mapch(ch); + segset = slcd_mapch(ch); /* Check if the character should be decorated with a decimal point or colon */ if ((options & SCLD_DP) != 0) { - bitset |= 0x0002; + segset |= 0x0002; } else if ((options & SCLD_DP) != 0) { - bitset |= 0x0020; + segset |= 0x0020; } + lcdvdbg("ch: [%c] options: %02x segset: %04x\n", ch, options, segset); + /* Decode the value and write it to the SLCD segment memory */ - slcd_writemem(bitset, curpos); + slcd_writemem(segset, curpos); /* Save these values in the state structure */ g_slcdstate.buffer[curpos] = ch; g_slcdstate.options[curpos] = options; + + slcd_dumpstate("AFTER WRITE"); } /**************************************************************************** @@ -796,6 +866,8 @@ static void slcd_writech(uint8_t ch, uint8_t curpos, uint8_t options) static void slcd_appendch(uint8_t ch, uint8_t options) { + lcdvdbg("ch: [%c] options: %02x\n", ch, options); + /* Write the character at the current cursor position */ slcd_writech(ch, g_slcdstate.curpos, options); @@ -803,6 +875,8 @@ static void slcd_appendch(uint8_t ch, uint8_t options) { g_slcdstate.curpos++; } + + slcd_dumpstate("AFTER APPEND"); } /**************************************************************************** @@ -811,6 +885,9 @@ static void slcd_appendch(uint8_t ch, uint8_t options) static void slcd_action(enum slcdcode_e code, uint8_t count) { + lcdvdbg("Action: %d count: %d\n", code, count); + slcd_dumpstate("BEFORE ACTION"); + switch (code) { /* Erasure */ @@ -885,7 +962,7 @@ static void slcd_action(enum slcdcode_e code, uint8_t count) { int i; - /* Erasecharacters after the current cursor position to the end of the line */ + /* Erase characters after the current cursor position to the end of the line */ for (i = g_slcdstate.curpos; i < SLCD_NCHARS; i++) { @@ -949,6 +1026,8 @@ static void slcd_action(enum slcdcode_e code, uint8_t count) case SLCDCODE_NORMAL: /* Not a special keycode */ break; } + + slcd_dumpstate("AFTER ACTION"); } /**************************************************************************** @@ -984,6 +1063,7 @@ static ssize_t slcd_read(FAR struct file *filp, FAR char *buffer, size_t len) } } + slcd_dumpstate("READ"); return ret; } @@ -1013,6 +1093,10 @@ static ssize_t slcd_write(FAR struct file *filp, memset(&state, 0, sizeof(struct slcdstate_s)); result = slcd_decode(&instream.stream, &state, &prev, &count); + + lcdvdbg("slcd_decode returned result=%d char=%d count=%d\n", + result, prev, count); + switch (result) { case SLCDRET_CHAR: @@ -1034,6 +1118,9 @@ static ssize_t slcd_write(FAR struct file *filp, while ((result = slcd_decode(&instream.stream, &state, &ch, &count)) != SLCDRET_EOF) { + lcdvdbg("slcd_decode returned result=%d char=%d count=%d\n", + result, ch, count); + if (result == SLCDRET_CHAR) /* A normal character was returned */ { /* Check for ASCII control characters */ @@ -1132,6 +1219,8 @@ static int slcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg) { FAR struct slcd_geometry_s *geo = (FAR struct slcd_geometry_s *)((uintptr_t)arg); + lcdvdbg("SLCDIOC_GEOMETRY: nrows=%d ncolumns=%d\n", SLCD_NROWS, SLCD_NCHARS); + if (!geo) { return -EINVAL; @@ -1149,6 +1238,8 @@ static int slcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg) case SLCDIOC_SETBAR: { + lcdvdbg("SLCDIOC_SETBAR: arg=0x%02lx\n", arg); + /* Format the bar */ g_slcdstate.bar[0] = 0; @@ -1195,6 +1286,7 @@ static int slcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg) } *contrast = (int)slcd_getcontrast(); + lcdvdbg("SLCDIOC_GETCONTRAST: contrast=%d\n", *contrast); } break; @@ -1207,6 +1299,9 @@ static int slcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg) case SLCDIOC_MAXCONTRAST: { FAR int *contrast = (FAR int *)((uintptr_t)arg); + + lcdvdbg("SLCDIOC_MAXCONTRAST: contrast=%d\n", SLCD_MAXCONTRAST); + if (!contrast) { return -EINVAL; @@ -1223,6 +1318,8 @@ static int slcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg) case SLCDIOC_SETCONTRAST: { + lcdvdbg("SLCDIOC_SETCONTRAST: arg=%ld\n", arg); + if (arg > SLCD_MAXCONTRAST) { return -ERANGE; @@ -1294,20 +1391,34 @@ int stm32_slcd_initialize(void) stm32_configgpio(g_slcdgpio[i]); } + /* Enable the External Low-Speed (LSE) oscillator and select it as the + * LCD clock source. + * + * NOTE: LCD clocking should already be enabled in the RCC APB1ENR register. + */ + + stm32_rcc_enablelse(); + + lcdvdbg("APB1ENR: %08x CSR: %08x\n", + getreg32(STM32_RCC_APB1ENR), getreg32(STM32_RCC_CSR)); + /* Set the LCD prescaler and divider values */ - regval = getreg32(STM32_LCD_FCR); + regval = getreg32(STM32_LCD_FCR); regval &= ~(LCD_FCR_DIV_MASK | LCD_FCR_PS_MASK); - regval |= ( LCD_FCR_PS_DIV1 | LCD_FCR_DIV(31)); + regval |= (LCD_FCR_PS_DIV1 | LCD_FCR_DIV(31)); putreg32(regval, STM32_LCD_FCR); /* Wait for the FCRSF flag to be set */ + lcdvdbg("Wait for FCRSF, FSR: %08x SR: %08x\n", + getreg32(STM32_LCD_FCR), getreg32(STM32_LCD_SR)); + while ((getreg32(STM32_LCD_SR) & LCD_SR_FCRSF) == 0); /* Set the duty (1/4), bias (1/3), and the internal voltage source (VSEL=0) */ - regval = getreg32(STM32_LCD_CR); + regval = getreg32(STM32_LCD_CR); regval &= ~(LCD_CR_BIAS_MASK | LCD_CR_DUTY_MASK | LCD_CR_VSEL); regval |= (LCD_CR_DUTY_1TO4 | LCD_CR_BIAS_1TO3); putreg32(regval, STM32_LCD_CR); @@ -1337,6 +1448,9 @@ int stm32_slcd_initialize(void) /* Wait Until the LCD FCR register is synchronized */ + lcdvdbg("Wait for FCRSF, FSR: %08x SR: %08x\n", + getreg32(STM32_LCD_FCR), getreg32(STM32_LCD_SR)); + while ((getreg32(STM32_LCD_SR) & LCD_SR_FCRSF) == 0); /* Enable LCD peripheral */ @@ -1345,6 +1459,9 @@ int stm32_slcd_initialize(void) /* Wait Until the LCD is enabled and the LCD booster is ready */ + lcdvdbg("Wait for LCD_SR_ENS and LCD_SR_RDY, CR: %08x SR: %08x\n", + getreg32(STM32_LCD_CR), getreg32(STM32_LCD_SR)); + while ((getreg32(STM32_LCD_SR) & (LCD_SR_ENS | LCD_SR_RDY)) != (LCD_SR_ENS | LCD_SR_RDY)); /* Disable blinking */ @@ -1354,6 +1471,8 @@ int stm32_slcd_initialize(void) regval |= (LCD_FCR_BLINK_DISABLE | LCD_FCR_BLINKF_DIV32); putreg32(regval, STM32_LCD_FCR); + slcd_dumpslcd("AFTER INITIALIZATION"); + /* Register the LCD device driver */ ret = register_driver("/dev/slcd", &g_slcdops, 0644, (FAR struct file_operations *)&g_slcdops); @@ -1362,6 +1481,7 @@ int stm32_slcd_initialize(void) /* Then clear the display */ slcd_clear(); + slcd_dumpstate("AFTER INITIALIZATION"); } return ret; diff --git a/nuttx/configs/stm32ldiscovery/src/stm32_nsh.c b/nuttx/configs/stm32ldiscovery/src/stm32_nsh.c index 7924b5dd0..63c29c5dc 100644 --- a/nuttx/configs/stm32ldiscovery/src/stm32_nsh.c +++ b/nuttx/configs/stm32ldiscovery/src/stm32_nsh.c @@ -40,16 +40,10 @@ #include <nuttx/config.h> -#include <stdbool.h> -#include <stdio.h> #include <debug.h> -#include <errno.h> -#ifdef CONFIG_SYSTEM_USBMONITOR -# include <apps/usbmonitor.h> -#endif +#include <arch/board/board.h> -#include "stm32.h" #include "stm32ldiscovery.h" /**************************************************************************** @@ -58,31 +52,6 @@ /* Configuration ************************************************************/ -#define HAVE_USBDEV 1 -#define HAVE_USBMONITOR 1 - -/* Can't support USB device features if the STM32 USB peripheral is not - * enabled. - */ - -#ifndef CONFIG_STM32_USB -# undef HAVE_USBDEV -# undef HAVE_USBMONITOR -#endif - -/* Can't support USB device is USB device is not enabled */ - -#ifndef CONFIG_USBDEV -# undef HAVE_USBDEV -# undef HAVE_USBMONITOR -#endif - -/* Check if we should enable the USB monitor before starting NSH */ - -#if !defined(CONFIG_USBDEV_TRACE) || !defined(CONFIG_SYSTEM_USBMONITOR) -# undef HAVE_USBMONITOR -#endif - /* Debug ********************************************************************/ #ifdef CONFIG_CPP_HAVE_VARARGS @@ -113,17 +82,13 @@ int nsh_archinitialize(void) { -#ifdef HAVE_USBMONITOR - int ret; + int ret = OK; - /* Start the USB Monitor */ + /* Initialize the SLCD and register the SLCD device as /dev/slcd */ - ret = usbmonitor_start(0, NULL); - if (ret != OK) - { - message("nsh_archinitialize: Start USB monitor: %d\n", ret); - } +#ifdef CONFIG_STM32_LCD + ret = stm32_slcd_initialize(); #endif - return OK; + return ret; } diff --git a/nuttx/configs/stm32ldiscovery/src/stm32_usb.c b/nuttx/configs/stm32ldiscovery/src/stm32_usb.c deleted file mode 100644 index 28ce91ad2..000000000 --- a/nuttx/configs/stm32ldiscovery/src/stm32_usb.c +++ /dev/null @@ -1,131 +0,0 @@ -/************************************************************************************ - * configs/stm32ldiscovery/src/up_usbdev.c - * arch/arm/src/board/up_boot.c - * - * Copyright (C) 2013 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 <sys/types.h> -#include <stdint.h> -#include <stdbool.h> -#include <sched.h> -#include <errno.h> -#include <debug.h> - -#include <nuttx/usb/usbdev.h> -#include <nuttx/usb/usbdev_trace.h> - -#include "up_arch.h" -#include "stm32.h" -#include "stm32ldiscovery.h" - -#ifdef CONFIG_STM32_USB - -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ - -#ifdef CONFIG_USBDEV -# define HAVE_USB 1 -#else -# warning "CONFIG_STM32_USB is enabled but CONFIG_USBDEV is not" -# undef HAVE_USB -#endif - -/************************************************************************************ - * Private Data - ************************************************************************************/ - -/************************************************************************************ - * Private Functions - ************************************************************************************/ - -/************************************************************************************ - * Public Functions - ************************************************************************************/ - -/************************************************************************************ - * Name: stm32_usbinitialize - * - * Description: - * Called from stm32_usbinitialize very early in inialization to setup USB-related - * GPIO pins for the STM32F3Discovery board. - * - ************************************************************************************/ - -void stm32_usbinitialize(void) -{ - /* Does the STM32 F3 hava an external soft pull-up? */ -} - -/************************************************************************************ - * Name: stm32_usbpullup - * - * Description: - * If USB is supported and the board supports a pullup via GPIO (for USB software - * connect and disconnect), then the board software must provide stm32_pullup. - * See include/nuttx/usb/usbdev.h for additional description of this method. - * - ************************************************************************************/ - -int stm32_usbpullup(FAR struct usbdev_s *dev, bool enable) -{ - usbtrace(TRACE_DEVPULLUP, (uint16_t)enable); - return OK; -} - -/************************************************************************************ - * Name: stm32_usbsuspend - * - * Description: - * Board logic must provide the stm32_usbsuspend logic if the USBDEV driver is - * used. This function is called whenever the USB enters or leaves suspend mode. - * This is an opportunity for the board logic to shutdown clocks, power, etc. - * while the USB is suspended. - * - ************************************************************************************/ - -void stm32_usbsuspend(FAR struct usbdev_s *dev, bool resume) -{ - ulldbg("resume: %d\n", resume); -} - -#endif /* CONFIG_STM32_USB */ - - - diff --git a/nuttx/configs/stm32ldiscovery/src/stm32ldiscovery.h b/nuttx/configs/stm32ldiscovery/src/stm32ldiscovery.h index 7d5c10988..76d1f418a 100644 --- a/nuttx/configs/stm32ldiscovery/src/stm32ldiscovery.h +++ b/nuttx/configs/stm32ldiscovery/src/stm32ldiscovery.h @@ -243,19 +243,6 @@ void weak_function stm32_spiinitialize(void); -/**************************************************************************************************** - * Name: stm32_usbinitialize - * - * Description: - * Called from stm32_usbinitialize very early in inialization to setup USB-related - * GPIO pins for the STM32L-Discovery board. - * - ****************************************************************************************************/ - -#ifdef CONFIG_STM32_USB -void weak_function stm32_usbinitialize(void); -#endif - #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_STM32F3DISCOVERY_SRC_STM32F3DISCOVERY_INTERNAL_H */ |