From 3458ee74a4a35ae27569e5a5301b6af138ee5701 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 9 Feb 2013 15:03:49 +0000 Subject: [PATCH] Removed stm32_internal.h; Changes for clean compile of STM32F3Discovery configuration with SPI and USB git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5630 42af7a65-404d-4744-a932-0658087f49c3 --- arch/arm/src/stm32/Kconfig | 15 ++ arch/arm/src/stm32/chip/stm32_usbdev.h | 6 +- .../src/stm32/chip/stm32f10xxx_memorymap.h | 5 +- .../src/stm32/chip/stm32f30xxx_memorymap.h | 2 +- arch/arm/src/stm32/chip/stm32f30xxx_syscfg.h | 4 +- arch/arm/src/stm32/stm32_adc.c | 2 +- arch/arm/src/stm32/stm32_can.c | 2 +- arch/arm/src/stm32/stm32_dac.c | 2 +- arch/arm/src/stm32/stm32_internal.h | 45 ----- arch/arm/src/stm32/stm32_irq.c | 2 +- arch/arm/src/stm32/stm32_lowputc.c | 6 +- arch/arm/src/stm32/stm32_pwm.c | 2 +- arch/arm/src/stm32/stm32_qencoder.c | 2 +- arch/arm/src/stm32/stm32_rcc.c | 2 +- arch/arm/src/stm32/stm32_sdio.c | 2 +- arch/arm/src/stm32/stm32_serial.c | 78 +++++++- arch/arm/src/stm32/stm32_spi.c | 4 +- arch/arm/src/stm32/stm32_start.c | 2 +- arch/arm/src/stm32/stm32_tim.c | 2 +- arch/arm/src/stm32/stm32_timerisr.c | 2 +- arch/arm/src/stm32/stm32_usbdev.c | 35 +++- arch/arm/src/stm32/stm32f10xxx_dma.c | 2 +- arch/arm/src/stm32/stm32f20xxx_dma.c | 2 +- arch/arm/src/stm32/stm32f40xxx_dma.c | 2 +- configs/cloudctrl/include/board.h | 2 +- configs/cloudctrl/src/up_autoleds.c | 2 +- configs/cloudctrl/src/up_nsh.c | 2 +- configs/cloudctrl/src/up_spi.c | 2 +- configs/cloudctrl/src/up_usb.c | 2 +- configs/cloudctrl/src/up_usbmsc.c | 2 +- configs/cloudctrl/src/up_userleds.c | 2 +- configs/fire-stm32v2/include/board.h | 2 +- configs/fire-stm32v2/src/up_autoleds.c | 2 +- configs/fire-stm32v2/src/up_nsh.c | 2 +- configs/fire-stm32v2/src/up_selectlcd.c | 2 +- configs/fire-stm32v2/src/up_spi.c | 2 +- configs/fire-stm32v2/src/up_usbdev.c | 2 +- configs/fire-stm32v2/src/up_usbmsc.c | 2 +- configs/fire-stm32v2/src/up_userleds.c | 2 +- configs/hymini-stm32v/include/board.h | 2 +- configs/hymini-stm32v/src/ssd1289.c | 1 - configs/hymini-stm32v/src/up_leds.c | 2 +- configs/hymini-stm32v/src/up_nsh.c | 2 +- configs/hymini-stm32v/src/up_spi.c | 2 +- configs/hymini-stm32v/src/up_ts.c | 1 - configs/hymini-stm32v/src/up_usbdev.c | 2 +- configs/hymini-stm32v/src/up_usbmsc.c | 2 +- configs/olimex-stm32-p107/include/board.h | 2 +- configs/shenzhou/include/board.h | 2 +- configs/shenzhou/src/up_autoleds.c | 2 +- configs/shenzhou/src/up_ili93xx.c | 1 - configs/shenzhou/src/up_nsh.c | 2 +- configs/shenzhou/src/up_spi.c | 2 +- configs/shenzhou/src/up_ssd1289.c | 1 - configs/shenzhou/src/up_touchscreen.c | 2 +- configs/shenzhou/src/up_usb.c | 2 +- configs/shenzhou/src/up_usbmsc.c | 2 +- configs/shenzhou/src/up_userleds.c | 2 +- configs/stm3210e-eval/include/board.h | 2 +- configs/stm3210e-eval/src/up_composite.c | 2 +- configs/stm3210e-eval/src/up_extmem.c | 2 +- configs/stm3210e-eval/src/up_lcd.c | 1 - configs/stm3210e-eval/src/up_leds.c | 2 +- configs/stm3210e-eval/src/up_nsh.c | 2 +- configs/stm3210e-eval/src/up_spi.c | 2 +- configs/stm3210e-eval/src/up_usbdev.c | 2 +- configs/stm3210e-eval/src/up_usbmsc.c | 2 +- configs/stm3220g-eval/include/board.h | 2 +- configs/stm3220g-eval/src/up_autoleds.c | 2 +- configs/stm3220g-eval/src/up_extmem.c | 2 +- configs/stm3220g-eval/src/up_lcd.c | 1 - configs/stm3220g-eval/src/up_nsh.c | 2 +- configs/stm3220g-eval/src/up_spi.c | 2 +- configs/stm3220g-eval/src/up_stmpe811.c | 2 +- configs/stm3220g-eval/src/up_usb.c | 2 +- configs/stm3220g-eval/src/up_userleds.c | 2 +- configs/stm3240g-eval/include/board.h | 2 +- configs/stm3240g-eval/src/up_autoleds.c | 2 +- configs/stm3240g-eval/src/up_extmem.c | 2 +- configs/stm3240g-eval/src/up_lcd.c | 1 - configs/stm3240g-eval/src/up_nsh.c | 2 +- configs/stm3240g-eval/src/up_spi.c | 2 +- configs/stm3240g-eval/src/up_stmpe811.c | 2 +- configs/stm3240g-eval/src/up_usb.c | 2 +- configs/stm3240g-eval/src/up_userleds.c | 2 +- configs/stm32f100rc_generic/include/board.h | 2 +- configs/stm32f100rc_generic/src/up_leds.c | 2 +- configs/stm32f3discovery/include/board.h | 2 +- configs/stm32f3discovery/src/Makefile | 2 +- .../src/stm32f3discovery-internal.h | 15 +- configs/stm32f3discovery/src/up_boot.c | 7 +- configs/stm32f3discovery/src/up_nsh.c | 2 +- configs/stm32f3discovery/src/up_spi.c | 2 +- configs/stm32f3discovery/src/up_usb.c | 188 ++---------------- configs/stm32f4discovery/include/board.h | 2 +- configs/stm32f4discovery/src/up_autoleds.c | 2 +- configs/stm32f4discovery/src/up_boot.c | 4 +- configs/stm32f4discovery/src/up_extmem.c | 2 +- configs/stm32f4discovery/src/up_nsh.c | 2 +- configs/stm32f4discovery/src/up_spi.c | 2 +- configs/stm32f4discovery/src/up_ssd1289.c | 1 - configs/stm32f4discovery/src/up_usb.c | 2 +- configs/stm32f4discovery/src/up_userleds.c | 2 +- configs/vsn/include/board.h | 2 +- configs/vsn/src/spi.c | 2 +- configs/vsn/src/usbdev.c | 2 +- 106 files changed, 235 insertions(+), 355 deletions(-) delete mode 100644 arch/arm/src/stm32/stm32_internal.h diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index ae19e5996c..29ffa1ff4a 100644 --- a/arch/arm/src/stm32/Kconfig +++ b/arch/arm/src/stm32/Kconfig @@ -2420,3 +2420,18 @@ config STM32_USBHOST_PKTDUMP Dump all incoming and outgoing USB packets. Depends on DEBUG. endmenu + +menu "USB Device Configuration" + +config STM32_USB_ITRMP + bool "Re-map USB interrupt" + default n if !STM32_CAN1 + default y if STM32_CAN1 + depends on STM32_USB && STM32_STM32F30XX + ---help--- + The legacy USB in the F1 series shared interrupt lines with USB + device and CAN1. In the F3 series, a hardware options was added to + either retain the legacy F1 behavior or to map the USB interupts to + there own dedicated vectors. The option is available only for the + F3 family and selects the use of the dedicated USB interrupts. + diff --git a/arch/arm/src/stm32/chip/stm32_usbdev.h b/arch/arm/src/stm32/chip/stm32_usbdev.h index daa9a926e0..55ab9a93d6 100644 --- a/arch/arm/src/stm32/chip/stm32_usbdev.h +++ b/arch/arm/src/stm32/chip/stm32_usbdev.h @@ -43,7 +43,7 @@ #include #include -#ifdef CONFIG_STM32_STM32F10XX +#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) /************************************************************************************ * Definitions @@ -108,7 +108,7 @@ /* Buffer Descriptor Table (Relatative to BTABLE address) */ -#define STM32_USB_BTABLE_ADDR(ep,o) (STM32_USBCANRAM_BASE+STM32_USB_BTABLE_RADDR(ep,o)) +#define STM32_USB_BTABLE_ADDR(ep,o) (STM32_USBRAM_BASE+STM32_USB_BTABLE_RADDR(ep,o)) #define STM32_USB_ADDR_TX(ep) STM32_USB_BTABLE_ADDR(ep,STM32_USB_ADDR_TX_WOFFSET) #define STM32_USB_COUNT_TX(ep) STM32_USB_BTABLE_ADDR(ep,STM32_USB_COUNT_TX_WOFFSET) #define STM32_USB_ADDR_RX(ep) STM32_USB_BTABLE_ADDR(ep,STM32_USB_ADDR_RX_WOFFSET) @@ -231,6 +231,6 @@ #define USB_COUNT_RX_SHIFT (0) /* Bits 9-0: Reception Byte Count */ #define USB_COUNT_RX_MASK (0x03ff << USB_COUNT_RX_SHIFT) -#endif /* CONFIG_STM32_STM32F10XX */ +#endif /* CONFIG_STM32_STM32F10XX || CONFIG_STM32_STM32F10XX */ #endif /* __ARCH_ARM_SRC_STM32_CHIP_STM32_USBDEV_H */ diff --git a/arch/arm/src/stm32/chip/stm32f10xxx_memorymap.h b/arch/arm/src/stm32/chip/stm32f10xxx_memorymap.h index a1d2e26d30..c405a6dead 100644 --- a/arch/arm/src/stm32/chip/stm32f10xxx_memorymap.h +++ b/arch/arm/src/stm32/chip/stm32f10xxx_memorymap.h @@ -1,7 +1,7 @@ /************************************************************************************ * arch/arm/src/stm32/chip/stm32f10xxx_memorymap.h * - * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2011, 3013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -79,7 +79,8 @@ #define STM32_I2C1_BASE 0x40005400 /* 0x40005400 - 0x400057ff: I2C1 */ #define STM32_I2C2_BASE 0x40005800 /* 0x40005800 - 0x40005Bff: I2C2 */ #define STM32_USB_BASE 0x40005c00 /* 0x40005c00 - 0x40005fff: USB device FS registers */ -#define STM32_USBCANRAM_BASE 0x40006000 /* 0x40006000 - 0x400063ff: Shared USB/CAN SRAM 512 bytes */ +#define STM32_USBRAM_BASE 0x40006000 /* 0x40006000 - 0x400063ff: Shared USB/CAN SRAM 512 bytes */ +#define STM32_CANRAM_BASE 0x40006000 /* 0x40006000 - 0x400063ff: Shared USB/CAN SRAM 512 bytes */ #define STM32_CAN1_BASE 0x40006400 /* 0x40006400 - 0x400067ff: bxCAN1 */ #define STM32_CAN2_BASE 0x40006800 /* 0x40006800 - 0x40006bff: bxCAN2 */ #define STM32_BKP_BASE 0x40006c00 /* 0x40006c00 - 0x40006fff: Backup registers (BKP) */ diff --git a/arch/arm/src/stm32/chip/stm32f30xxx_memorymap.h b/arch/arm/src/stm32/chip/stm32f30xxx_memorymap.h index 88fe693f10..5fd8288bbb 100644 --- a/arch/arm/src/stm32/chip/stm32f30xxx_memorymap.h +++ b/arch/arm/src/stm32/chip/stm32f30xxx_memorymap.h @@ -99,7 +99,7 @@ #define STM32_I2C1_BASE 0x40005400 /* 0x40005400-0x400057ff I2C1 */ #define STM32_I2C2_BASE 0x40005800 /* 0x40005800-0x40005bff I2C2 */ #define STM32_USB_BASE 0x40005c00 /* 0x40005c00-0x40005fff USB device FS */ -#define STM32_USBSRAM_BASE 0x40006000 /* 0x40006000-0x400063ff USB SRAM 512B */ +#define STM32_USBRAM_BASE 0x40006000 /* 0x40006000-0x400063ff USB SRAM 512B */ #define STM32_CAN1_BASE 0x40006400 /* 0x40006400-0x400067ff bxCAN */ #define STM32_PWR_BASE 0x40007000 /* 0x40007000-0x400073ff PWR */ #define STM32_DAC_BASE 0x40007400 /* 0x40007400-0x400077ff DAC (dual) */ diff --git a/arch/arm/src/stm32/chip/stm32f30xxx_syscfg.h b/arch/arm/src/stm32/chip/stm32f30xxx_syscfg.h index 81ba2eaa4f..391f875316 100644 --- a/arch/arm/src/stm32/chip/stm32f30xxx_syscfg.h +++ b/arch/arm/src/stm32/chip/stm32f30xxx_syscfg.h @@ -92,8 +92,8 @@ #define SYSCFG_CFGR1_TIM17_DMARMP (1 << 12) /* Bit 12: TIM17 DMA request remapping bit */ #define SYSCFG_CFGR1_TIM6_DMARMP (1 << 13) /* Bit 13: TIM6 DMA remap, or */ #define SYSCFG_CFGR1_DAC1_DMARMP (1 << 13) /* Bit 13: DAC channel DMA remap */ -#define SYSCFG_CFGR1_TIM7_DMARMP (1 << 14) /* Bit 14: : TIM7 DMA remap */ -#define SYSCFG_CFGR1_DAC2_DMARMP (1 << 14) /* Bit 14: : DAC channel2 DMA remap */ +#define SYSCFG_CFGR1_TIM7_DMARMP (1 << 14) /* Bit 14: TIM7 DMA remap */ +#define SYSCFG_CFGR1_DAC2_DMARMP (1 << 14) /* Bit 14: DAC channel2 DMA remap */ #define SYSCFG_CFGR1_I2C_PBXFMP_SHIFT (0) /* Bits 16-19: Fast Mode Plus (FM+) driving capability */ #define SYSCFG_CFGR1_I2C_PBXFMP_MASK (15 << SYSCFG_CFGR1_I2C_PBXFMP_SHIFT) #define SYSCFG_CFGR1_I2C1_FMP (1 << 20) /* Bit 20: I2C1 fast mode Plus driving capability */ diff --git a/arch/arm/src/stm32/stm32_adc.c b/arch/arm/src/stm32/stm32_adc.c index b5033b0576..f580834689 100644 --- a/arch/arm/src/stm32/stm32_adc.c +++ b/arch/arm/src/stm32/stm32_adc.c @@ -60,7 +60,7 @@ #include "up_arch.h" #include "chip.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32_adc.h" #ifdef CONFIG_ADC diff --git a/arch/arm/src/stm32/stm32_can.c b/arch/arm/src/stm32/stm32_can.c index 0b014b26bd..86a53dab09 100644 --- a/arch/arm/src/stm32/stm32_can.c +++ b/arch/arm/src/stm32/stm32_can.c @@ -57,7 +57,7 @@ #include "os_internal.h" #include "chip.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32_can.h" #if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2)) diff --git a/arch/arm/src/stm32/stm32_dac.c b/arch/arm/src/stm32/stm32_dac.c index b92da7b717..916ce331be 100644 --- a/arch/arm/src/stm32/stm32_dac.c +++ b/arch/arm/src/stm32/stm32_dac.c @@ -55,7 +55,7 @@ #include "up_arch.h" #include "chip.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32_dac.h" #ifdef CONFIG_DAC diff --git a/arch/arm/src/stm32/stm32_internal.h b/arch/arm/src/stm32/stm32_internal.h deleted file mode 100644 index 8db936786e..0000000000 --- a/arch/arm/src/stm32/stm32_internal.h +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************************************ - * arch/arm/src/stm32/stm32_internal.h - * - * Copyright (C) 2009-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ************************************************************************************/ - -#ifndef __ARCH_ARM_SRC_STM32_STM32_INTERNAL_H -#define __ARCH_ARM_SRC_STM32_STM32_INTERNAL_H - -/************************************************************************************ - * Included Files - ************************************************************************************/ - -#include "stm32.h" - -#endif /* __ARCH_ARM_SRC_STM32_STM32_INTERNAL_H */ diff --git a/arch/arm/src/stm32/stm32_irq.c b/arch/arm/src/stm32/stm32_irq.c index a952c2486c..92117e9830 100644 --- a/arch/arm/src/stm32/stm32_irq.c +++ b/arch/arm/src/stm32/stm32_irq.c @@ -51,7 +51,7 @@ #include "up_arch.h" #include "os_internal.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" /**************************************************************************** * Definitions diff --git a/arch/arm/src/stm32/stm32_lowputc.c b/arch/arm/src/stm32/stm32_lowputc.c index 1ba29a573f..4cd29845aa 100644 --- a/arch/arm/src/stm32/stm32_lowputc.c +++ b/arch/arm/src/stm32/stm32_lowputc.c @@ -48,10 +48,10 @@ #include "chip.h" +#include "stm32.h" #include "stm32_rcc.h" #include "stm32_gpio.h" #include "stm32_uart.h" -#include "stm32_internal.h" /************************************************************************** * Private Definitions @@ -255,14 +255,14 @@ # define STM32_USARTDIV16 \ ((STM32_APBCLOCK + (STM32_CONSOLE_BAUD >> 1)) / STM32_CONSOLE_BAUD) - /* Use oversamply by 8 only if the divisor is small */ + /* Use oversamply by 8 only if the divisor is small. But what is small? */ # if STM32_USARTDIV8 > 100 # define STM32_BRR_VALUE STM32_USARTDIV16 # else # define USE_OVER8 1 # define STM32_BRR_VALUE \ - ((STM32_USARTDIV8 && 0xfff0) | ((STM32_USARTDIV8 & 0x000f) >> 1) + ((STM32_USARTDIV8 & 0xfff0) | ((STM32_USARTDIV8 & 0x000f) >> 1)) # endif #else diff --git a/arch/arm/src/stm32/stm32_pwm.c b/arch/arm/src/stm32/stm32_pwm.c index a3ef23e57a..c1279435e3 100644 --- a/arch/arm/src/stm32/stm32_pwm.c +++ b/arch/arm/src/stm32/stm32_pwm.c @@ -54,7 +54,7 @@ #include "chip.h" #include "stm32_pwm.h" -#include "stm32_internal.h" +#include "stm32.h" /* This module then only compiles if there is at least one enabled timer * intended for use with the PWM upper half driver. diff --git a/arch/arm/src/stm32/stm32_qencoder.c b/arch/arm/src/stm32/stm32_qencoder.c index d37614c03c..5e99b05a85 100644 --- a/arch/arm/src/stm32/stm32_qencoder.c +++ b/arch/arm/src/stm32/stm32_qencoder.c @@ -55,7 +55,7 @@ #include "up_internal.h" #include "up_arch.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32_gpio.h" #include "stm32_tim.h" #include "stm32_qencoder.h" diff --git a/arch/arm/src/stm32/stm32_rcc.c b/arch/arm/src/stm32/stm32_rcc.c index ce045e75fe..6b98a56643 100644 --- a/arch/arm/src/stm32/stm32_rcc.c +++ b/arch/arm/src/stm32/stm32_rcc.c @@ -52,7 +52,7 @@ #include "chip.h" #include "stm32_rcc.h" #include "stm32_flash.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32_waste.h" /**************************************************************************** diff --git a/arch/arm/src/stm32/stm32_sdio.c b/arch/arm/src/stm32/stm32_sdio.c index a8bcae3070..800f1fe6bd 100644 --- a/arch/arm/src/stm32/stm32_sdio.c +++ b/arch/arm/src/stm32/stm32_sdio.c @@ -60,7 +60,7 @@ #include "chip.h" #include "up_arch.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32_dma.h" #include "stm32_sdio.h" diff --git a/arch/arm/src/stm32/stm32_serial.c b/arch/arm/src/stm32/stm32_serial.c index 12da1ee105..30cc4f0566 100644 --- a/arch/arm/src/stm32/stm32_serial.c +++ b/arch/arm/src/stm32/stm32_serial.c @@ -939,6 +939,66 @@ static int up_dma_nextrx(struct up_dev_s *priv) #ifndef CONFIG_SUPPRESS_UART_CONFIG static void up_setspeed(struct uart_dev_s *dev) { +#ifdef CONFIG_STM32_STM32F30XX + + /* This first implementation is for U[S]ARTs that support oversampling + * by 8 in additional to the standard oversampling by 16. + */ + + struct up_dev_s *priv = (struct up_dev_s*)dev->priv; + uint32_t usartdiv8; + uint32_t cr1; + uint32_t brr; + + /* In case of oversampling by 8, the equation is: + * + * baud = 2 * fCK / usartdiv8 + * usartdiv8 = 2 * fCK / baud + */ + + usartdiv8 = ((priv->apbclock << 1) + (priv->baud >> 1)) / priv->baud; + + /* Baud rate for standard USART (SPI mode included): + * + * In case of oversampling by 16, the equation is: + * baud = fCK / usartdiv16 + * usartdiv16 = fCK / baud + * = 2 * usartdiv8 + */ + + /* Use oversamply by 8 only if the divisor is small. But what is small? */ + + cr1 = up_serialin(priv, STM32_USART_CR1_OFFSET); + if (usartdiv8 > 100) + { + /* Use usartdiv16 */ + + brr = (usartdiv8 + 1) >> 1; + + /* Clear oversampling by 8 to enable oversampling by 16 */ + + cr1 &= ~USART_CR1_OVER8; + } + else + { + /* Perform mysterious operations on bits 0-3 */ + + brr = ((usartdiv8 & 0xfff0) | ((usartdiv8 & 0x000f) >> 1)); + + /* Set oversampling by 8 */ + + cr1 |= USART_CR1_OVER8; + } + + up_serialout(priv, STM32_USART_CR1_OFFSET, cr1); + up_serialout(priv, STM32_USART_BRR_OFFSET, brr); + +#else + + /* This second implementation is for U[S]ARTs that support fractional + * dividers. + */ + struct up_dev_s *priv = (struct up_dev_s*)dev->priv; uint32_t usartdiv32; uint32_t mantissa; @@ -973,6 +1033,8 @@ static void up_setspeed(struct uart_dev_s *dev) fraction = (usartdiv32 - (mantissa << 5) + 1) >> 1; brr |= fraction << USART_BRR_FRAC_SHIFT; up_serialout(priv, STM32_USART_BRR_OFFSET, brr); + +#endif } #endif @@ -1031,6 +1093,7 @@ static int up_setup(struct uart_dev_s *dev) { regval |= USART_CR2_STOP2; } + up_serialout(priv, STM32_USART_CR2_OFFSET, regval); /* Configure CR1 */ @@ -1077,6 +1140,7 @@ static int up_setup(struct uart_dev_s *dev) regval = up_serialin(priv, STM32_USART_CR1_OFFSET); regval |= (USART_CR1_UE|USART_CR1_TE|USART_CR1_RE); up_serialout(priv, STM32_USART_CR1_OFFSET, regval); + #endif /* Set up the cached interrupt enables value */ @@ -1119,7 +1183,7 @@ static int up_dma_setup(struct uart_dev_s *dev) /* Configure for circular DMA reception into the RX fifo */ stm32_dmasetup(priv->rxdma, - priv->usartbase + STM32_USART_DR_OFFSET, + priv->usartbase + STM32_USART_RDR_OFFSET, (uint32_t)priv->rxfifo, RXDMA_BUFFER_SIZE, SERIAL_DMA_CONTROL_WORD); @@ -1351,7 +1415,7 @@ static int up_interrupt_common(struct up_dev_s *priv) * good byte will be lost. */ - (void)up_serialin(priv, STM32_USART_DR_OFFSET); + (void)up_serialin(priv, STM32_USART_RDR_OFFSET); } /* Handle outgoing, transmit bytes */ @@ -1510,20 +1574,20 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) static int up_receive(struct uart_dev_s *dev, uint32_t *status) { struct up_dev_s *priv = (struct up_dev_s*)dev->priv; - uint32_t dr; + uint32_t rdr; /* Get the Rx byte */ - dr = up_serialin(priv, STM32_USART_DR_OFFSET); + rdr = up_serialin(priv, STM32_USART_RDR_OFFSET); /* Get the Rx byte plux error information. Return those in status */ - *status = priv->sr << 16 | dr; + *status = priv->sr << 16 | rdr; priv->sr = 0; /* Then return the actual received byte */ - return dr & 0xff; + return rdr & 0xff; } #endif @@ -1693,7 +1757,7 @@ static void up_send(struct uart_dev_s *dev, int ch) if (priv->rs485_dir_gpio != 0) stm32_gpiowrite(priv->rs485_dir_gpio, priv->rs485_dir_polarity); #endif - up_serialout(priv, STM32_USART_DR_OFFSET, (uint32_t)ch); + up_serialout(priv, STM32_USART_TDR_OFFSET, (uint32_t)ch); } /**************************************************************************** diff --git a/arch/arm/src/stm32/stm32_spi.c b/arch/arm/src/stm32/stm32_spi.c index 7119247f74..09c4c72aa5 100644 --- a/arch/arm/src/stm32/stm32_spi.c +++ b/arch/arm/src/stm32/stm32_spi.c @@ -77,7 +77,7 @@ #include "up_arch.h" #include "chip.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32_gpio.h" #include "stm32_dma.h" #include "stm32_spi.h" @@ -130,7 +130,7 @@ /* DMA channel configuration */ -#if defined(CONFIG_STM32_STM32F10XX) +#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) # define SPI_RXDMA16_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_16BITS|DMA_CCR_PSIZE_16BITS|DMA_CCR_MINC ) # define SPI_RXDMA8_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_8BITS |DMA_CCR_MINC ) # define SPI_RXDMA16NULL_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_16BITS ) diff --git a/arch/arm/src/stm32/stm32_start.c b/arch/arm/src/stm32/stm32_start.c index 3f2f45b6bb..c6a176e5f6 100644 --- a/arch/arm/src/stm32/stm32_start.c +++ b/arch/arm/src/stm32/stm32_start.c @@ -46,7 +46,7 @@ #include "up_arch.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32_gpio.h" #ifdef CONFIG_ARCH_FPU diff --git a/arch/arm/src/stm32/stm32_tim.c b/arch/arm/src/stm32/stm32_tim.c index d19c69c032..4a94f00159 100644 --- a/arch/arm/src/stm32/stm32_tim.c +++ b/arch/arm/src/stm32/stm32_tim.c @@ -59,7 +59,7 @@ #include "up_internal.h" #include "up_arch.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32_gpio.h" #include "stm32_tim.h" diff --git a/arch/arm/src/stm32/stm32_timerisr.c b/arch/arm/src/stm32/stm32_timerisr.c index ea64561907..baa8522733 100644 --- a/arch/arm/src/stm32/stm32_timerisr.c +++ b/arch/arm/src/stm32/stm32_timerisr.c @@ -51,7 +51,7 @@ #include "up_arch.h" #include "chip.h" -#include "stm32_internal.h" +#include "stm32.h" /**************************************************************************** * Definitions diff --git a/arch/arm/src/stm32/stm32_usbdev.c b/arch/arm/src/stm32/stm32_usbdev.c index 0ec46cebe4..dc05a7ebb7 100644 --- a/arch/arm/src/stm32/stm32_usbdev.c +++ b/arch/arm/src/stm32/stm32_usbdev.c @@ -59,7 +59,8 @@ #include #include "up_arch.h" -#include "stm32_internal.h" +#include "stm32.h" +#include "stm32_syscfg.h" #include "stm32_usbdev.h" #if defined(CONFIG_USBDEV) && defined(CONFIG_STM32_USB) @@ -78,6 +79,20 @@ # define CONFIG_USB_PRI NVIC_SYSH_PRIORITY_DEFAULT #endif +/* USB Interrupts. Should be re-mapped if CAN is used. */ + +#ifdef CONFIG_STM32_STM32F30XX +# ifdef CONFIG_STM32_USB_ITRMP +# define STM32_IRQ_USBHP STM32_IRQ_USBHP_1 +# define STM32_IRQ_USBLP STM32_IRQ_USBLP_1 +# define STM32_IRQ_USBWKUP STM32_IRQ_USBWKUP_1 +# else +# define STM32_IRQ_USBHP STM32_IRQ_USBHP_2 +# define STM32_IRQ_USBLP STM32_IRQ_USBLP_2 +# define STM32_IRQ_USBWKUP STM32_IRQ_USBWKUP_2 +# endif +#endif + /* Extremely detailed register debug that you would normally never want * enabled. */ @@ -1014,7 +1029,7 @@ static void stm32_copytopma(const uint8_t *buffer, uint16_t pma, uint16_t nbytes /* Copy loop. Source=user buffer, Dest=packet memory */ - dest = (uint16_t*)(STM32_USBCANRAM_BASE + ((uint32_t)pma << 1)); + dest = (uint16_t*)(STM32_USBRAM_BASE + ((uint32_t)pma << 1)); for (i = nwords; i != 0; i--) { /* Read two bytes and pack into on 16-bit word */ @@ -1044,7 +1059,7 @@ stm32_copyfrompma(uint8_t *buffer, uint16_t pma, uint16_t nbytes) /* Copy loop. Source=packet memory, Dest=user buffer */ - src = (uint32_t*)(STM32_USBCANRAM_BASE + ((uint32_t)pma << 1)); + src = (uint32_t*)(STM32_USBRAM_BASE + ((uint32_t)pma << 1)); for (i = nwords; i != 0; i--) { /* Copy 16-bits from packet memory to user buffer. */ @@ -3470,6 +3485,20 @@ void up_usbinitialize(void) stm32_hwsetup(priv); + /* Remap the USB interrupt as needed (Only supported by the STM32 F3 family) */ + +#ifdef CONFIG_STM32_STM32F30XX +# ifdef CONFIG_STM32_USB_ITRMP + /* Clear the ITRMP bit to use the legacy, shared USB/CAN interrupts */ + + modifyreg32(STM32_RCC_APB1ENR, SYSCFG_CFGR1_USB_ITRMP, 0); +# else + /* Set the ITRMP bit to use the STM32 F3's dedicated USB interrupts */ + + modifyreg32(STM32_RCC_APB1ENR, 0, SYSCFG_CFGR1_USB_ITRMP); +# endif +#endif + /* Attach USB controller interrupt handlers. The hardware will not be * initialized and interrupts will not be enabled until the class device * driver is bound. Getting the IRQs here only makes sure that we have diff --git a/arch/arm/src/stm32/stm32f10xxx_dma.c b/arch/arm/src/stm32/stm32f10xxx_dma.c index 13324b8ac0..80408e58b8 100644 --- a/arch/arm/src/stm32/stm32f10xxx_dma.c +++ b/arch/arm/src/stm32/stm32f10xxx_dma.c @@ -54,7 +54,7 @@ #include "os_internal.h" #include "chip.h" #include "stm32_dma.h" -#include "stm32_internal.h" +#include "stm32.h" /* Only for the STM32F10xx family for now */ diff --git a/arch/arm/src/stm32/stm32f20xxx_dma.c b/arch/arm/src/stm32/stm32f20xxx_dma.c index 55aab352f1..97ff283416 100644 --- a/arch/arm/src/stm32/stm32f20xxx_dma.c +++ b/arch/arm/src/stm32/stm32f20xxx_dma.c @@ -54,7 +54,7 @@ #include "os_internal.h" #include "chip.h" #include "stm32_dma.h" -#include "stm32_internal.h" +#include "stm32.h" /* This file supports only the STM32 F2 family (although it is identical to * the corresponding F4 file). diff --git a/arch/arm/src/stm32/stm32f40xxx_dma.c b/arch/arm/src/stm32/stm32f40xxx_dma.c index 40fce8cb54..ae489a9961 100644 --- a/arch/arm/src/stm32/stm32f40xxx_dma.c +++ b/arch/arm/src/stm32/stm32f40xxx_dma.c @@ -54,7 +54,7 @@ #include "os_internal.h" #include "chip.h" #include "stm32_dma.h" -#include "stm32_internal.h" +#include "stm32.h" /* This file supports only the STM32 F4 family (an probably the F2 family * as well?) diff --git a/configs/cloudctrl/include/board.h b/configs/cloudctrl/include/board.h index 3afdb9cb83..b5ae3d4f55 100644 --- a/configs/cloudctrl/include/board.h +++ b/configs/cloudctrl/include/board.h @@ -48,7 +48,7 @@ #endif #include "stm32_rcc.h" #include "stm32_sdio.h" -#include "stm32_internal.h" +#include "stm32.h" #include diff --git a/configs/cloudctrl/src/up_autoleds.c b/configs/cloudctrl/src/up_autoleds.c index 83df13510f..83e0b9e684 100644 --- a/configs/cloudctrl/src/up_autoleds.c +++ b/configs/cloudctrl/src/up_autoleds.c @@ -51,7 +51,7 @@ #include "chip.h" #include "up_arch.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" #include "cloudctrl-internal.h" /**************************************************************************** diff --git a/configs/cloudctrl/src/up_nsh.c b/configs/cloudctrl/src/up_nsh.c index 6baeeeab8e..a43b98d47e 100644 --- a/configs/cloudctrl/src/up_nsh.c +++ b/configs/cloudctrl/src/up_nsh.c @@ -46,7 +46,7 @@ #include #include -#include "stm32_internal.h" +#include "stm32.h" #include "cloudctrl-internal.h" /**************************************************************************** diff --git a/configs/cloudctrl/src/up_spi.c b/configs/cloudctrl/src/up_spi.c index 47ade8488a..84bf855958 100644 --- a/configs/cloudctrl/src/up_spi.c +++ b/configs/cloudctrl/src/up_spi.c @@ -50,7 +50,7 @@ #include "up_arch.h" #include "chip.h" -#include "stm32_internal.h" +#include "stm32.h" #include "cloudctrl-internal.h" #if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI3) diff --git a/configs/cloudctrl/src/up_usb.c b/configs/cloudctrl/src/up_usb.c index a5560be85f..51167bcb2e 100644 --- a/configs/cloudctrl/src/up_usb.c +++ b/configs/cloudctrl/src/up_usb.c @@ -53,7 +53,7 @@ #include #include "up_arch.h" -#include "stm32_internal.h" +#include "stm32.h" #include "cloudctrl-internal.h" #ifdef CONFIG_STM32_OTGFS diff --git a/configs/cloudctrl/src/up_usbmsc.c b/configs/cloudctrl/src/up_usbmsc.c index 95fc0189a3..04f35efea4 100644 --- a/configs/cloudctrl/src/up_usbmsc.c +++ b/configs/cloudctrl/src/up_usbmsc.c @@ -46,7 +46,7 @@ #include #include -#include "stm32_internal.h" +#include "stm32.h" /**************************************************************************** * Pre-Processor Definitions diff --git a/configs/cloudctrl/src/up_userleds.c b/configs/cloudctrl/src/up_userleds.c index bbb7cc62c4..6c39b1442c 100644 --- a/configs/cloudctrl/src/up_userleds.c +++ b/configs/cloudctrl/src/up_userleds.c @@ -50,7 +50,7 @@ #include "chip.h" #include "up_arch.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" #include "cloudctrl-internal.h" #ifndef CONFIG_ARCH_LEDS diff --git a/configs/fire-stm32v2/include/board.h b/configs/fire-stm32v2/include/board.h index acd70933a2..efdf07ec55 100644 --- a/configs/fire-stm32v2/include/board.h +++ b/configs/fire-stm32v2/include/board.h @@ -47,7 +47,7 @@ #endif #include "stm32_rcc.h" #include "stm32_sdio.h" -#include "stm32_internal.h" +#include "stm32.h" /************************************************************************************ * Definitions diff --git a/configs/fire-stm32v2/src/up_autoleds.c b/configs/fire-stm32v2/src/up_autoleds.c index 5ecef46c0e..dcc3d8708c 100644 --- a/configs/fire-stm32v2/src/up_autoleds.c +++ b/configs/fire-stm32v2/src/up_autoleds.c @@ -50,7 +50,7 @@ #include "chip.h" #include "up_arch.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" #include "fire-internal.h" /**************************************************************************** diff --git a/configs/fire-stm32v2/src/up_nsh.c b/configs/fire-stm32v2/src/up_nsh.c index fa261f5618..7c0b3dc387 100644 --- a/configs/fire-stm32v2/src/up_nsh.c +++ b/configs/fire-stm32v2/src/up_nsh.c @@ -45,7 +45,7 @@ #include #include -#include "stm32_internal.h" +#include "stm32.h" #include "fire-internal.h" /**************************************************************************** diff --git a/configs/fire-stm32v2/src/up_selectlcd.c b/configs/fire-stm32v2/src/up_selectlcd.c index 99d18cd277..060d755211 100644 --- a/configs/fire-stm32v2/src/up_selectlcd.c +++ b/configs/fire-stm32v2/src/up_selectlcd.c @@ -51,7 +51,7 @@ #include "stm32_fsmc.h" #include "stm32_gpio.h" -#include "stm32_internal.h" +#include "stm32.h" #include "fire-internal.h" #ifdef CONFIG_STM32_FSMC diff --git a/configs/fire-stm32v2/src/up_spi.c b/configs/fire-stm32v2/src/up_spi.c index b2ef301b67..78a3bc2550 100644 --- a/configs/fire-stm32v2/src/up_spi.c +++ b/configs/fire-stm32v2/src/up_spi.c @@ -49,7 +49,7 @@ #include "up_arch.h" #include "chip.h" -#include "stm32_internal.h" +#include "stm32.h" #include "fire-internal.h" #if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) diff --git a/configs/fire-stm32v2/src/up_usbdev.c b/configs/fire-stm32v2/src/up_usbdev.c index e335edd432..b1ca36cb7c 100644 --- a/configs/fire-stm32v2/src/up_usbdev.c +++ b/configs/fire-stm32v2/src/up_usbdev.c @@ -49,7 +49,7 @@ #include #include "up_arch.h" -#include "stm32_internal.h" +#include "stm32.h" #include "fire-internal.h" /************************************************************************************ diff --git a/configs/fire-stm32v2/src/up_usbmsc.c b/configs/fire-stm32v2/src/up_usbmsc.c index f1f6ee69c2..98c06336f3 100644 --- a/configs/fire-stm32v2/src/up_usbmsc.c +++ b/configs/fire-stm32v2/src/up_usbmsc.c @@ -45,7 +45,7 @@ #include #include -#include "stm32_internal.h" +#include "stm32.h" /**************************************************************************** * Pre-Processor Definitions diff --git a/configs/fire-stm32v2/src/up_userleds.c b/configs/fire-stm32v2/src/up_userleds.c index 3dd1843ee9..574c2c5b3d 100644 --- a/configs/fire-stm32v2/src/up_userleds.c +++ b/configs/fire-stm32v2/src/up_userleds.c @@ -49,7 +49,7 @@ #include "chip.h" #include "up_arch.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" #include "fire-internal.h" #ifndef CONFIG_ARCH_LEDS diff --git a/configs/hymini-stm32v/include/board.h b/configs/hymini-stm32v/include/board.h index 333f83b897..7751946e79 100644 --- a/configs/hymini-stm32v/include/board.h +++ b/configs/hymini-stm32v/include/board.h @@ -52,7 +52,7 @@ #endif #include "stm32_rcc.h" #include "stm32_sdio.h" -#include "stm32_internal.h" +#include "stm32.h" /************************************************************************************ * Definitions diff --git a/configs/hymini-stm32v/src/ssd1289.c b/configs/hymini-stm32v/src/ssd1289.c index 0ebf822747..b9930f33c5 100644 --- a/configs/hymini-stm32v/src/ssd1289.c +++ b/configs/hymini-stm32v/src/ssd1289.c @@ -51,7 +51,6 @@ #include "up_arch.h" #include "stm32.h" -#include "stm32_internal.h" #include "hymini_stm32v-internal.h" #include "ssd1289.h" diff --git a/configs/hymini-stm32v/src/up_leds.c b/configs/hymini-stm32v/src/up_leds.c index 3cd0d44bde..5eac5a0453 100644 --- a/configs/hymini-stm32v/src/up_leds.c +++ b/configs/hymini-stm32v/src/up_leds.c @@ -50,7 +50,7 @@ #include "chip.h" #include "up_arch.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" #include "hymini_stm32v-internal.h" /**************************************************************************** diff --git a/configs/hymini-stm32v/src/up_nsh.c b/configs/hymini-stm32v/src/up_nsh.c index 5b823012d9..e8cdd4a8b9 100644 --- a/configs/hymini-stm32v/src/up_nsh.c +++ b/configs/hymini-stm32v/src/up_nsh.c @@ -55,7 +55,7 @@ # include #endif -#include "stm32_internal.h" +#include "stm32.h" #include "hymini_stm32v-internal.h" /**************************************************************************** diff --git a/configs/hymini-stm32v/src/up_spi.c b/configs/hymini-stm32v/src/up_spi.c index 631c70ce9a..db0bb61bc5 100644 --- a/configs/hymini-stm32v/src/up_spi.c +++ b/configs/hymini-stm32v/src/up_spi.c @@ -50,7 +50,7 @@ #include "up_arch.h" #include "chip.h" -#include "stm32_internal.h" +#include "stm32.h" #include "hymini_stm32v-internal.h" #if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) diff --git a/configs/hymini-stm32v/src/up_ts.c b/configs/hymini-stm32v/src/up_ts.c index e5a7796052..46765e0aad 100644 --- a/configs/hymini-stm32v/src/up_ts.c +++ b/configs/hymini-stm32v/src/up_ts.c @@ -43,7 +43,6 @@ #include #include "stm32.h" -#include "stm32_internal.h" #include "hymini_stm32v-internal.h" #include diff --git a/configs/hymini-stm32v/src/up_usbdev.c b/configs/hymini-stm32v/src/up_usbdev.c index 061ed9234e..fad29f7d1b 100644 --- a/configs/hymini-stm32v/src/up_usbdev.c +++ b/configs/hymini-stm32v/src/up_usbdev.c @@ -49,7 +49,7 @@ #include #include "up_arch.h" -#include "stm32_internal.h" +#include "stm32.h" #include "hymini_stm32v-internal.h" /************************************************************************************ diff --git a/configs/hymini-stm32v/src/up_usbmsc.c b/configs/hymini-stm32v/src/up_usbmsc.c index da8f025338..c5abaa9110 100644 --- a/configs/hymini-stm32v/src/up_usbmsc.c +++ b/configs/hymini-stm32v/src/up_usbmsc.c @@ -48,7 +48,7 @@ #include #include -#include "stm32_internal.h" +#include "stm32.h" /* There is nothing to do here if SDIO support is not selected. */ diff --git a/configs/olimex-stm32-p107/include/board.h b/configs/olimex-stm32-p107/include/board.h index 96051e25c2..d01c7dfcd7 100644 --- a/configs/olimex-stm32-p107/include/board.h +++ b/configs/olimex-stm32-p107/include/board.h @@ -47,7 +47,7 @@ #endif #include "stm32_rcc.h" #include "stm32_sdio.h" -#include "stm32_internal.h" +#include "stm32.h" /************************************************************************************ * Pre-processor Definitions diff --git a/configs/shenzhou/include/board.h b/configs/shenzhou/include/board.h index 7c4d983a14..3e10a32e77 100644 --- a/configs/shenzhou/include/board.h +++ b/configs/shenzhou/include/board.h @@ -47,7 +47,7 @@ #endif #include "stm32_rcc.h" #include "stm32_sdio.h" -#include "stm32_internal.h" +#include "stm32.h" #include diff --git a/configs/shenzhou/src/up_autoleds.c b/configs/shenzhou/src/up_autoleds.c index 3c467c8ad7..1ce25e80e9 100644 --- a/configs/shenzhou/src/up_autoleds.c +++ b/configs/shenzhou/src/up_autoleds.c @@ -50,7 +50,7 @@ #include "chip.h" #include "up_arch.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" #include "shenzhou-internal.h" /**************************************************************************** diff --git a/configs/shenzhou/src/up_ili93xx.c b/configs/shenzhou/src/up_ili93xx.c index 1a099f8209..f090ced62b 100644 --- a/configs/shenzhou/src/up_ili93xx.c +++ b/configs/shenzhou/src/up_ili93xx.c @@ -128,7 +128,6 @@ #include "up_arch.h" #include "stm32.h" -#include "stm32_internal.h" #include "shenzhou-internal.h" /************************************************************************************ diff --git a/configs/shenzhou/src/up_nsh.c b/configs/shenzhou/src/up_nsh.c index d68a734e0a..0b98025810 100644 --- a/configs/shenzhou/src/up_nsh.c +++ b/configs/shenzhou/src/up_nsh.c @@ -45,7 +45,7 @@ #include #include -#include "stm32_internal.h" +#include "stm32.h" #include "shenzhou-internal.h" /**************************************************************************** diff --git a/configs/shenzhou/src/up_spi.c b/configs/shenzhou/src/up_spi.c index 28c5470866..08c7969485 100644 --- a/configs/shenzhou/src/up_spi.c +++ b/configs/shenzhou/src/up_spi.c @@ -49,7 +49,7 @@ #include "up_arch.h" #include "chip.h" -#include "stm32_internal.h" +#include "stm32.h" #include "shenzhou-internal.h" #if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI3) diff --git a/configs/shenzhou/src/up_ssd1289.c b/configs/shenzhou/src/up_ssd1289.c index 50a99bddf7..8320a6c4e2 100644 --- a/configs/shenzhou/src/up_ssd1289.c +++ b/configs/shenzhou/src/up_ssd1289.c @@ -59,7 +59,6 @@ #include "up_arch.h" #include "stm32.h" -#include "stm32_internal.h" #include "shenzhou-internal.h" #ifdef CONFIG_LCD_SSD1289 diff --git a/configs/shenzhou/src/up_touchscreen.c b/configs/shenzhou/src/up_touchscreen.c index 4740f60a50..63602f1345 100644 --- a/configs/shenzhou/src/up_touchscreen.c +++ b/configs/shenzhou/src/up_touchscreen.c @@ -51,7 +51,7 @@ #include #include -#include "stm32_internal.h" +#include "stm32.h" #include "shenzhou-internal.h" /**************************************************************************** diff --git a/configs/shenzhou/src/up_usb.c b/configs/shenzhou/src/up_usb.c index 6c4d15d4b9..86af406cfa 100644 --- a/configs/shenzhou/src/up_usb.c +++ b/configs/shenzhou/src/up_usb.c @@ -52,7 +52,7 @@ #include #include "up_arch.h" -#include "stm32_internal.h" +#include "stm32.h" #include "shenshou-internal.h" #ifdef CONFIG_STM32_OTGFS diff --git a/configs/shenzhou/src/up_usbmsc.c b/configs/shenzhou/src/up_usbmsc.c index eaecfb4969..d957b76da7 100644 --- a/configs/shenzhou/src/up_usbmsc.c +++ b/configs/shenzhou/src/up_usbmsc.c @@ -45,7 +45,7 @@ #include #include -#include "stm32_internal.h" +#include "stm32.h" /**************************************************************************** * Pre-Processor Definitions diff --git a/configs/shenzhou/src/up_userleds.c b/configs/shenzhou/src/up_userleds.c index 4e1493a8da..0e690e8254 100644 --- a/configs/shenzhou/src/up_userleds.c +++ b/configs/shenzhou/src/up_userleds.c @@ -49,7 +49,7 @@ #include "chip.h" #include "up_arch.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" #include "shenzhou-internal.h" #ifndef CONFIG_ARCH_LEDS diff --git a/configs/stm3210e-eval/include/board.h b/configs/stm3210e-eval/include/board.h index 8a479a7e54..1f0898441c 100644 --- a/configs/stm3210e-eval/include/board.h +++ b/configs/stm3210e-eval/include/board.h @@ -47,7 +47,7 @@ #endif #include "stm32_rcc.h" #include "stm32_sdio.h" -#include "stm32_internal.h" +#include "stm32.h" /************************************************************************************ * Definitions diff --git a/configs/stm3210e-eval/src/up_composite.c b/configs/stm3210e-eval/src/up_composite.c index de5759c788..5102da9cc3 100644 --- a/configs/stm3210e-eval/src/up_composite.c +++ b/configs/stm3210e-eval/src/up_composite.c @@ -49,7 +49,7 @@ #include #include -#include "stm32_internal.h" +#include "stm32.h" /* There is nothing to do here if SDIO support is not selected. */ diff --git a/configs/stm3210e-eval/src/up_extmem.c b/configs/stm3210e-eval/src/up_extmem.c index a47d0fe12a..d76114abee 100644 --- a/configs/stm3210e-eval/src/up_extmem.c +++ b/configs/stm3210e-eval/src/up_extmem.c @@ -51,7 +51,7 @@ #include "stm32_fsmc.h" #include "stm32_gpio.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm3210e-internal.h" /************************************************************************************ diff --git a/configs/stm3210e-eval/src/up_lcd.c b/configs/stm3210e-eval/src/up_lcd.c index 81cc3f20a4..33eef2b302 100644 --- a/configs/stm3210e-eval/src/up_lcd.c +++ b/configs/stm3210e-eval/src/up_lcd.c @@ -76,7 +76,6 @@ #include "up_arch.h" #include "stm32.h" -#include "stm32_internal.h" #include "stm3210e-internal.h" /************************************************************************************** diff --git a/configs/stm3210e-eval/src/up_leds.c b/configs/stm3210e-eval/src/up_leds.c index 5a02588ab2..45a24684b3 100644 --- a/configs/stm3210e-eval/src/up_leds.c +++ b/configs/stm3210e-eval/src/up_leds.c @@ -50,7 +50,7 @@ #include "chip.h" #include "up_arch.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm3210e-internal.h" /**************************************************************************** diff --git a/configs/stm3210e-eval/src/up_nsh.c b/configs/stm3210e-eval/src/up_nsh.c index 544a0e75e4..28996d2fdc 100644 --- a/configs/stm3210e-eval/src/up_nsh.c +++ b/configs/stm3210e-eval/src/up_nsh.c @@ -55,7 +55,7 @@ # include #endif -#include "stm32_internal.h" +#include "stm32.h" /**************************************************************************** * Pre-Processor Definitions diff --git a/configs/stm3210e-eval/src/up_spi.c b/configs/stm3210e-eval/src/up_spi.c index ea8670b183..03fb715c9e 100644 --- a/configs/stm3210e-eval/src/up_spi.c +++ b/configs/stm3210e-eval/src/up_spi.c @@ -49,7 +49,7 @@ #include "up_arch.h" #include "chip.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm3210e-internal.h" #if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) diff --git a/configs/stm3210e-eval/src/up_usbdev.c b/configs/stm3210e-eval/src/up_usbdev.c index 2ac9e50f49..fb472d18f2 100644 --- a/configs/stm3210e-eval/src/up_usbdev.c +++ b/configs/stm3210e-eval/src/up_usbdev.c @@ -49,7 +49,7 @@ #include #include "up_arch.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm3210e-internal.h" /************************************************************************************ diff --git a/configs/stm3210e-eval/src/up_usbmsc.c b/configs/stm3210e-eval/src/up_usbmsc.c index d1727174e0..185f50bb04 100644 --- a/configs/stm3210e-eval/src/up_usbmsc.c +++ b/configs/stm3210e-eval/src/up_usbmsc.c @@ -48,7 +48,7 @@ #include #include -#include "stm32_internal.h" +#include "stm32.h" /* There is nothing to do here if SDIO support is not selected. */ diff --git a/configs/stm3220g-eval/include/board.h b/configs/stm3220g-eval/include/board.h index c70946000e..c8dccf390a 100644 --- a/configs/stm3220g-eval/include/board.h +++ b/configs/stm3220g-eval/include/board.h @@ -49,7 +49,7 @@ #include "stm32_rcc.h" #include "stm32_sdio.h" -#include "stm32_internal.h" +#include "stm32.h" /************************************************************************************ * Definitions diff --git a/configs/stm3220g-eval/src/up_autoleds.c b/configs/stm3220g-eval/src/up_autoleds.c index f77f1d08a4..068c07ab49 100644 --- a/configs/stm3220g-eval/src/up_autoleds.c +++ b/configs/stm3220g-eval/src/up_autoleds.c @@ -49,7 +49,7 @@ #include "chip.h" #include "up_arch.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm3220g-internal.h" #ifdef CONFIG_ARCH_LEDS diff --git a/configs/stm3220g-eval/src/up_extmem.c b/configs/stm3220g-eval/src/up_extmem.c index 179d28f11b..d5984f35af 100644 --- a/configs/stm3220g-eval/src/up_extmem.c +++ b/configs/stm3220g-eval/src/up_extmem.c @@ -51,7 +51,7 @@ #include "stm32_fsmc.h" #include "stm32_gpio.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm3220g-internal.h" /************************************************************************************ diff --git a/configs/stm3220g-eval/src/up_lcd.c b/configs/stm3220g-eval/src/up_lcd.c index 4a1ce09532..ce406ce3d8 100644 --- a/configs/stm3220g-eval/src/up_lcd.c +++ b/configs/stm3220g-eval/src/up_lcd.c @@ -61,7 +61,6 @@ #include "up_arch.h" #include "stm32.h" -#include "stm32_internal.h" #include "stm3220g-internal.h" #if !defined(CONFIG_STM32_ILI9320_DISABLE) || !defined(CONFIG_STM32_ILI9325_DISABLE) diff --git a/configs/stm3220g-eval/src/up_nsh.c b/configs/stm3220g-eval/src/up_nsh.c index 068deb1a64..2387348ae7 100644 --- a/configs/stm3220g-eval/src/up_nsh.c +++ b/configs/stm3220g-eval/src/up_nsh.c @@ -59,7 +59,7 @@ # include "stm32_usbhost.h" #endif -#include "stm32_internal.h" +#include "stm32.h" #include "stm3220g-internal.h" /**************************************************************************** diff --git a/configs/stm3220g-eval/src/up_spi.c b/configs/stm3220g-eval/src/up_spi.c index 47ed8d2300..eb4ba6bc68 100644 --- a/configs/stm3220g-eval/src/up_spi.c +++ b/configs/stm3220g-eval/src/up_spi.c @@ -49,7 +49,7 @@ #include "up_arch.h" #include "chip.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm3220g-internal.h" #if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3) diff --git a/configs/stm3220g-eval/src/up_stmpe811.c b/configs/stm3220g-eval/src/up_stmpe811.c index a15e695067..a64c869588 100644 --- a/configs/stm3220g-eval/src/up_stmpe811.c +++ b/configs/stm3220g-eval/src/up_stmpe811.c @@ -51,7 +51,7 @@ #include -#include "stm32_internal.h" +#include "stm32.h" #include "stm3220g-internal.h" /**************************************************************************** diff --git a/configs/stm3220g-eval/src/up_usb.c b/configs/stm3220g-eval/src/up_usb.c index 2ca9b31cb7..7ac062fb52 100644 --- a/configs/stm3220g-eval/src/up_usb.c +++ b/configs/stm3220g-eval/src/up_usb.c @@ -52,7 +52,7 @@ #include #include "up_arch.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm3220g-internal.h" #ifdef CONFIG_STM32_OTGFS diff --git a/configs/stm3220g-eval/src/up_userleds.c b/configs/stm3220g-eval/src/up_userleds.c index 84510c7037..cc29349e97 100644 --- a/configs/stm3220g-eval/src/up_userleds.c +++ b/configs/stm3220g-eval/src/up_userleds.c @@ -49,7 +49,7 @@ #include "chip.h" #include "up_arch.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm3220g-internal.h" #ifndef CONFIG_ARCH_LEDS diff --git a/configs/stm3240g-eval/include/board.h b/configs/stm3240g-eval/include/board.h index 8fa7d0dd42..f9c8a437cd 100644 --- a/configs/stm3240g-eval/include/board.h +++ b/configs/stm3240g-eval/include/board.h @@ -47,7 +47,7 @@ #endif #include "stm32_rcc.h" #include "stm32_sdio.h" -#include "stm32_internal.h" +#include "stm32.h" /************************************************************************************ * Definitions diff --git a/configs/stm3240g-eval/src/up_autoleds.c b/configs/stm3240g-eval/src/up_autoleds.c index 6c2cba4555..8e7f40da30 100644 --- a/configs/stm3240g-eval/src/up_autoleds.c +++ b/configs/stm3240g-eval/src/up_autoleds.c @@ -49,7 +49,7 @@ #include "chip.h" #include "up_arch.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm3240g-internal.h" #ifdef CONFIG_ARCH_LEDS diff --git a/configs/stm3240g-eval/src/up_extmem.c b/configs/stm3240g-eval/src/up_extmem.c index a87c077413..e6ccfade29 100644 --- a/configs/stm3240g-eval/src/up_extmem.c +++ b/configs/stm3240g-eval/src/up_extmem.c @@ -51,7 +51,7 @@ #include "stm32_fsmc.h" #include "stm32_gpio.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm3240g-internal.h" /************************************************************************************ diff --git a/configs/stm3240g-eval/src/up_lcd.c b/configs/stm3240g-eval/src/up_lcd.c index 74088dc5e3..ff8c174df8 100644 --- a/configs/stm3240g-eval/src/up_lcd.c +++ b/configs/stm3240g-eval/src/up_lcd.c @@ -61,7 +61,6 @@ #include "up_arch.h" #include "stm32.h" -#include "stm32_internal.h" #include "stm3240g-internal.h" #if !defined(CONFIG_STM32_ILI9320_DISABLE) || !defined(CONFIG_STM32_ILI9325_DISABLE) diff --git a/configs/stm3240g-eval/src/up_nsh.c b/configs/stm3240g-eval/src/up_nsh.c index 596f902db0..49d8332970 100644 --- a/configs/stm3240g-eval/src/up_nsh.c +++ b/configs/stm3240g-eval/src/up_nsh.c @@ -59,7 +59,7 @@ # include "stm32_usbhost.h" #endif -#include "stm32_internal.h" +#include "stm32.h" #include "stm3240g-internal.h" /**************************************************************************** diff --git a/configs/stm3240g-eval/src/up_spi.c b/configs/stm3240g-eval/src/up_spi.c index 3ce9d7e295..e7e8684c18 100644 --- a/configs/stm3240g-eval/src/up_spi.c +++ b/configs/stm3240g-eval/src/up_spi.c @@ -49,7 +49,7 @@ #include "up_arch.h" #include "chip.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm3240g-internal.h" #if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3) diff --git a/configs/stm3240g-eval/src/up_stmpe811.c b/configs/stm3240g-eval/src/up_stmpe811.c index 257c886b90..f7f7adf054 100644 --- a/configs/stm3240g-eval/src/up_stmpe811.c +++ b/configs/stm3240g-eval/src/up_stmpe811.c @@ -51,7 +51,7 @@ #include -#include "stm32_internal.h" +#include "stm32.h" #include "stm3240g-internal.h" /**************************************************************************** diff --git a/configs/stm3240g-eval/src/up_usb.c b/configs/stm3240g-eval/src/up_usb.c index bc315a527d..776d71a382 100644 --- a/configs/stm3240g-eval/src/up_usb.c +++ b/configs/stm3240g-eval/src/up_usb.c @@ -52,7 +52,7 @@ #include #include "up_arch.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm3240g-internal.h" #ifdef CONFIG_STM32_OTGFS diff --git a/configs/stm3240g-eval/src/up_userleds.c b/configs/stm3240g-eval/src/up_userleds.c index 01c4b36d6c..4faf0dfd2f 100644 --- a/configs/stm3240g-eval/src/up_userleds.c +++ b/configs/stm3240g-eval/src/up_userleds.c @@ -49,7 +49,7 @@ #include "chip.h" #include "up_arch.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm3240g-internal.h" #ifndef CONFIG_ARCH_LEDS diff --git a/configs/stm32f100rc_generic/include/board.h b/configs/stm32f100rc_generic/include/board.h index 74fcd7daf3..b5bc69259f 100644 --- a/configs/stm32f100rc_generic/include/board.h +++ b/configs/stm32f100rc_generic/include/board.h @@ -46,7 +46,7 @@ # include #endif #include "stm32_rcc.h" -#include "stm32_internal.h" +#include "stm32.h" /************************************************************************************ * Definitions diff --git a/configs/stm32f100rc_generic/src/up_leds.c b/configs/stm32f100rc_generic/src/up_leds.c index 152c104c48..c7cf27d865 100644 --- a/configs/stm32f100rc_generic/src/up_leds.c +++ b/configs/stm32f100rc_generic/src/up_leds.c @@ -50,7 +50,7 @@ #include "chip.h" #include "up_arch.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32f100rc_internal.h" /**************************************************************************** diff --git a/configs/stm32f3discovery/include/board.h b/configs/stm32f3discovery/include/board.h index fb3406499e..f4aedccdf6 100644 --- a/configs/stm32f3discovery/include/board.h +++ b/configs/stm32f3discovery/include/board.h @@ -49,7 +49,7 @@ #include "stm32_rcc.h" #include "stm32_sdio.h" -#include "stm32_internal.h" +#include "stm32.h" /************************************************************************************ * Definitions diff --git a/configs/stm32f3discovery/src/Makefile b/configs/stm32f3discovery/src/Makefile index 56c053559a..d47389e49f 100644 --- a/configs/stm32f3discovery/src/Makefile +++ b/configs/stm32f3discovery/src/Makefile @@ -56,7 +56,7 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y) CSRCS += up_buttons.c endif -ifeq ($(CONFIG_STM32_OTGFS),y) +ifeq ($(CONFIG_STM32_USB),y) CSRCS += up_usb.c endif diff --git a/configs/stm32f3discovery/src/stm32f3discovery-internal.h b/configs/stm32f3discovery/src/stm32f3discovery-internal.h index 83223e0324..4dcc17010b 100644 --- a/configs/stm32f3discovery/src/stm32f3discovery-internal.h +++ b/configs/stm32f3discovery/src/stm32f3discovery-internal.h @@ -158,23 +158,10 @@ void weak_function stm32_spiinitialize(void); * ****************************************************************************************************/ -#ifdef CONFIG_STM32_OTGFS +#ifdef CONFIG_STM32_USB void weak_function stm32_usbinitialize(void); #endif -/**************************************************************************************************** - * Name: stm32_usbhost_initialize - * - * Description: - * Called at application startup time to initialize the USB host functionality. This function will - * start a thread that will monitor for device connection/disconnection events. - * - ****************************************************************************************************/ - -#if defined(CONFIG_STM32_OTGFS) && defined(CONFIG_USBHOST) -int stm32_usbhost_initialize(void); -#endif - #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_STM32F3DISCOVERY_SRC_STM32F3DISCOVERY_INTERNAL_H */ diff --git a/configs/stm32f3discovery/src/up_boot.c b/configs/stm32f3discovery/src/up_boot.c index 09849cb825..8055c38108 100644 --- a/configs/stm32f3discovery/src/up_boot.c +++ b/configs/stm32f3discovery/src/up_boot.c @@ -82,13 +82,12 @@ void stm32_boardinitialize(void) } #endif - /* Initialize USB if the 1) OTG FS controller is in the configuration and 2) + /* 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 - * the weak function stm32_usbinitialize() has been brought into the build. - * Presumeably either CONFIG_USBDEV or CONFIG_USBHOST is also selected. + * into the build. Presumeably either CONFIG_USBDEV is also selected. */ -#ifdef CONFIG_STM32_OTGFS +#ifdef CONFIG_STM32_USB if (stm32_usbinitialize) { stm32_usbinitialize(); diff --git a/configs/stm32f3discovery/src/up_nsh.c b/configs/stm32f3discovery/src/up_nsh.c index e5321731ec..a7d2013580 100644 --- a/configs/stm32f3discovery/src/up_nsh.c +++ b/configs/stm32f3discovery/src/up_nsh.c @@ -58,7 +58,7 @@ # include "stm32_usbhost.h" #endif -#include "stm32_internal.h" +#include "stm32.h" #include "stm32f3discovery-internal.h" /**************************************************************************** diff --git a/configs/stm32f3discovery/src/up_spi.c b/configs/stm32f3discovery/src/up_spi.c index c5eb9779ee..1a7a07354b 100644 --- a/configs/stm32f3discovery/src/up_spi.c +++ b/configs/stm32f3discovery/src/up_spi.c @@ -50,7 +50,7 @@ #include "up_arch.h" #include "chip.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32f3discovery-internal.h" #if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3) diff --git a/configs/stm32f3discovery/src/up_usb.c b/configs/stm32f3discovery/src/up_usb.c index a06508b630..9b735eed9f 100644 --- a/configs/stm32f3discovery/src/up_usb.c +++ b/configs/stm32f3discovery/src/up_usb.c @@ -52,83 +52,30 @@ #include #include "up_arch.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32f3discovery-internal.h" -#ifdef CONFIG_STM32_OTGFS +#ifdef CONFIG_STM32_USB /************************************************************************************ * Pre-processor Definitions ************************************************************************************/ -#if defined(CONFIG_USBDEV) || defined(CONFIG_USBHOST) +#ifdef CONFIG_USBDEV # define HAVE_USB 1 #else -# warning "CONFIG_STM32_OTGFS is enabled but neither CONFIG_USBDEV nor CONFIG_USBHOST" +# warning "CONFIG_STM32_USB is enabled but CONFIG_USBDEV is not" # undef HAVE_USB #endif -#ifndef CONFIG_USBHOST_DEFPRIO -# define CONFIG_USBHOST_DEFPRIO 50 -#endif - -#ifndef CONFIG_USBHOST_STACKSIZE -# define CONFIG_USBHOST_STACKSIZE 1024 -#endif - /************************************************************************************ * Private Data ************************************************************************************/ -#ifdef CONFIG_USBHOST -static struct usbhost_driver_s *g_drvr; -#endif - /************************************************************************************ * Private Functions ************************************************************************************/ -/************************************************************************************ - * Name: usbhost_waiter - * - * Description: - * Wait for USB devices to be connected. - * - ************************************************************************************/ - -#ifdef CONFIG_USBHOST -static int usbhost_waiter(int argc, char *argv[]) -{ - bool connected = false; - int ret; - - uvdbg("Running\n"); - for (;;) - { - /* Wait for the device to change state */ - - ret = DRVR_WAIT(g_drvr, connected); - DEBUGASSERT(ret == OK); - - connected = !connected; - uvdbg("%s\n", connected ? "connected" : "disconnected"); - - /* Did we just become connected? */ - - if (connected) - { - /* Yes.. enumerate the newly connected device */ - - (void)DRVR_ENUMERATE(g_drvr); - } - } - - /* Keep the compiler from complaining */ - - return 0; -} -#endif - /************************************************************************************ * Public Functions ************************************************************************************/ @@ -144,131 +91,24 @@ static int usbhost_waiter(int argc, char *argv[]) void stm32_usbinitialize(void) { - /* The OTG FS has an internal soft pull-up. No GPIO configuration is required */ - - /* Configure the OTG FS VBUS sensing GPIO, Power On, and Overcurrent GPIOs */ - -#ifdef CONFIG_STM32_OTGFS - stm32_configgpio(GPIO_OTGFS_VBUS); - stm32_configgpio(GPIO_OTGFS_PWRON); - stm32_configgpio(GPIO_OTGFS_OVER); -#endif + /* Does the STM32 F3 hava an external soft pull-up? */ } -/*********************************************************************************** - * Name: stm32_usbhost_initialize - * - * Description: - * Called at application startup time to initialize the USB host functionality. - * This function will start a thread that will monitor for device - * connection/disconnection events. - * - ***********************************************************************************/ - -#ifdef CONFIG_USBHOST -int stm32_usbhost_initialize(void) -{ - int pid; - int ret; - - /* First, register all of the class drivers needed to support the drivers - * that we care about: - */ - - uvdbg("Register class drivers\n"); - ret = usbhost_storageinit(); - if (ret != OK) - { - udbg("Failed to register the mass storage class\n"); - } - - /* Then get an instance of the USB host interface */ - - uvdbg("Initialize USB host\n"); - g_drvr = usbhost_initialize(0); - if (g_drvr) - { - /* Start a thread to handle device connection. */ - - uvdbg("Start usbhost_waiter\n"); - - pid = TASK_CREATE("usbhost", CONFIG_USBHOST_DEFPRIO, - CONFIG_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; - } - - return -ENODEV; -} -#endif - -/*********************************************************************************** - * Name: stm32_usbhost_vbusdrive - * - * Description: - * Enable/disable driving of VBUS 5V output. This function must be provided be - * each platform that implements the STM32 OTG FS host interface - * - * "On-chip 5 V VBUS generation is not supported. For this reason, a charge pump - * or, if 5 V are available on the application board, a basic power switch, must - * be added externally to drive the 5 V VBUS line. The external charge pump can - * be driven by any GPIO output. When the application decides to power on VBUS - * using the chosen GPIO, it must also set the port power bit in the host port - * control and status register (PPWR bit in OTG_FS_HPRT). - * - * "The application uses this field to control power to this port, and the core - * clears this bit on an overcurrent condition." - * - * Input Parameters: - * iface - For future growth to handle multiple USB host interface. Should be zero. - * enable - true: enable VBUS power; false: disable VBUS power - * - * Returned Value: - * None - * - ***********************************************************************************/ - -#ifdef CONFIG_USBHOST -void stm32_usbhost_vbusdrive(int iface, bool enable) -{ - DEBUGASSERT(iface == 0); - - if (enable) - { - /* Enable the Power Switch by driving the enable pin low */ - - stm32_gpiowrite(GPIO_OTGFS_PWRON, false); - } - else - { - /* Disable the Power Switch by driving the enable pin high */ - - stm32_gpiowrite(GPIO_OTGFS_PWRON, true); - } -} -#endif - /************************************************************************************ - * Name: stm32_setup_overcurrent + * Name: stm32_usbpullup * * Description: - * Setup to receive an interrupt-level callback if an overcurrent condition is - * detected. - * - * Input paramter: - * handler - New overcurrent interrupt handler - * - * Returned value: - * Old overcurrent interrupt handler + * 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. * ************************************************************************************/ -#ifdef CONFIG_USBHOST -xcpt_t stm32_setup_overcurrent(xcpt_t handler) +int stm32_usbpullup(FAR struct usbdev_s *dev, bool enable) { - return stm32_gpiosetevent(GPIO_OTGFS_OVER, true, true, true, handler); + usbtrace(TRACE_DEVPULLUP, (uint16_t)enable); + return OK; } -#endif /************************************************************************************ * Name: stm32_usbsuspend @@ -281,14 +121,12 @@ xcpt_t stm32_setup_overcurrent(xcpt_t handler) * ************************************************************************************/ -#ifdef CONFIG_USBDEV void stm32_usbsuspend(FAR struct usbdev_s *dev, bool resume) { ulldbg("resume: %d\n", resume); } -#endif -#endif /* CONFIG_STM32_OTGFS */ +#endif /* CONFIG_STM32_USB */ diff --git a/configs/stm32f4discovery/include/board.h b/configs/stm32f4discovery/include/board.h index 6171c3e403..793592b0b0 100644 --- a/configs/stm32f4discovery/include/board.h +++ b/configs/stm32f4discovery/include/board.h @@ -49,7 +49,7 @@ #include "stm32_rcc.h" #include "stm32_sdio.h" -#include "stm32_internal.h" +#include "stm32.h" /************************************************************************************ * Definitions diff --git a/configs/stm32f4discovery/src/up_autoleds.c b/configs/stm32f4discovery/src/up_autoleds.c index e38d2f3b12..c72a54a026 100644 --- a/configs/stm32f4discovery/src/up_autoleds.c +++ b/configs/stm32f4discovery/src/up_autoleds.c @@ -49,7 +49,7 @@ #include "chip.h" #include "up_arch.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32f4discovery-internal.h" #ifdef CONFIG_ARCH_LEDS diff --git a/configs/stm32f4discovery/src/up_boot.c b/configs/stm32f4discovery/src/up_boot.c index 3e9b7242d9..51ec4b9770 100644 --- a/configs/stm32f4discovery/src/up_boot.c +++ b/configs/stm32f4discovery/src/up_boot.c @@ -84,8 +84,8 @@ void stm32_boardinitialize(void) /* Initialize USB if the 1) OTG FS controller is in the configuration and 2) * disabled, and 3) the weak function stm32_usbinitialize() has been brought - * the weak function stm32_usbinitialize() has been brought into the build. - * Presumeably either CONFIG_USBDEV or CONFIG_USBHOST is also selected. + * into the build. Presumeably either CONFIG_USBDEV or CONFIG_USBHOST is also + * selected. */ #ifdef CONFIG_STM32_OTGFS diff --git a/configs/stm32f4discovery/src/up_extmem.c b/configs/stm32f4discovery/src/up_extmem.c index 0833215784..f58d567e25 100644 --- a/configs/stm32f4discovery/src/up_extmem.c +++ b/configs/stm32f4discovery/src/up_extmem.c @@ -51,7 +51,7 @@ #include "stm32_fsmc.h" #include "stm32_gpio.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32f4discovery-internal.h" /************************************************************************************ diff --git a/configs/stm32f4discovery/src/up_nsh.c b/configs/stm32f4discovery/src/up_nsh.c index 565aac724d..2e78a58d8f 100644 --- a/configs/stm32f4discovery/src/up_nsh.c +++ b/configs/stm32f4discovery/src/up_nsh.c @@ -58,7 +58,7 @@ # include "stm32_usbhost.h" #endif -#include "stm32_internal.h" +#include "stm32.h" #include "stm32f4discovery-internal.h" /**************************************************************************** diff --git a/configs/stm32f4discovery/src/up_spi.c b/configs/stm32f4discovery/src/up_spi.c index 5b812d50c5..d51a6d3d4f 100644 --- a/configs/stm32f4discovery/src/up_spi.c +++ b/configs/stm32f4discovery/src/up_spi.c @@ -50,7 +50,7 @@ #include "up_arch.h" #include "chip.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32f4discovery-internal.h" #if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3) diff --git a/configs/stm32f4discovery/src/up_ssd1289.c b/configs/stm32f4discovery/src/up_ssd1289.c index 4d5a4ab7a0..6eab054d3f 100644 --- a/configs/stm32f4discovery/src/up_ssd1289.c +++ b/configs/stm32f4discovery/src/up_ssd1289.c @@ -59,7 +59,6 @@ #include "up_arch.h" #include "stm32.h" -#include "stm32_internal.h" #include "stm32f4discovery-internal.h" #ifdef CONFIG_LCD_SSD1289 diff --git a/configs/stm32f4discovery/src/up_usb.c b/configs/stm32f4discovery/src/up_usb.c index 653dd9a885..b06f587f3d 100644 --- a/configs/stm32f4discovery/src/up_usb.c +++ b/configs/stm32f4discovery/src/up_usb.c @@ -52,7 +52,7 @@ #include #include "up_arch.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32f4discovery-internal.h" #ifdef CONFIG_STM32_OTGFS diff --git a/configs/stm32f4discovery/src/up_userleds.c b/configs/stm32f4discovery/src/up_userleds.c index 173c126968..5981a12e6a 100644 --- a/configs/stm32f4discovery/src/up_userleds.c +++ b/configs/stm32f4discovery/src/up_userleds.c @@ -50,7 +50,7 @@ #include "chip.h" #include "up_arch.h" #include "up_internal.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32f4discovery-internal.h" #ifndef CONFIG_ARCH_LEDS diff --git a/configs/vsn/include/board.h b/configs/vsn/include/board.h index dbed25c191..85cd96bd7b 100644 --- a/configs/vsn/include/board.h +++ b/configs/vsn/include/board.h @@ -51,7 +51,7 @@ #endif #include "stm32_rcc.h" #include "stm32_sdio.h" -#include "stm32_internal.h" +#include "stm32.h" #include "muxbus.h" diff --git a/configs/vsn/src/spi.c b/configs/vsn/src/spi.c index e8e15e54b8..7c028a9209 100644 --- a/configs/vsn/src/spi.c +++ b/configs/vsn/src/spi.c @@ -57,7 +57,7 @@ #include "up_arch.h" #include "chip.h" #include "stm32_gpio.h" -#include "stm32_internal.h" +#include "stm32.h" #include "stm32_waste.h" #include "vsn.h" diff --git a/configs/vsn/src/usbdev.c b/configs/vsn/src/usbdev.c index deb1e9b2d6..3781aa8e63 100644 --- a/configs/vsn/src/usbdev.c +++ b/configs/vsn/src/usbdev.c @@ -52,7 +52,7 @@ #include #include "up_arch.h" -#include "stm32_internal.h" +#include "stm32.h" #include "vsn.h" /************************************************************************************