From ba1bea5d536d232cd5e535ff33ac372f7dd9a575 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 22 Mar 2019 22:06:48 +0700 Subject: simplify board API, adding stm32f3 discovery - remove board header since it is not used --- src/portable/st/stm32f4/dcd_stm32f4.c | 2 +- src/tusb_option.h | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/portable/st/stm32f4/dcd_stm32f4.c b/src/portable/st/stm32f4/dcd_stm32f4.c index 472a63f32..d99e455ed 100644 --- a/src/portable/st/stm32f4/dcd_stm32f4.c +++ b/src/portable/st/stm32f4/dcd_stm32f4.c @@ -26,7 +26,7 @@ #include "tusb_option.h" -#if TUSB_OPT_DEVICE_ENABLED && CFG_TUSB_MCU == OPT_MCU_STM32F4 +#if TUSB_OPT_DEVICE_ENABLED && (CFG_TUSB_MCU == OPT_MCU_STM32F4 || CFG_TUSB_MCU == OPT_MCU_STM32F3) #include "device/dcd.h" #include "stm32f4xx.h" diff --git a/src/tusb_option.h b/src/tusb_option.h index 40705bc00..46d2186a0 100644 --- a/src/tusb_option.h +++ b/src/tusb_option.h @@ -36,21 +36,21 @@ /** \defgroup group_mcu Supported MCU * \ref CFG_TUSB_MCU must be defined to one of these * @{ */ -#define OPT_MCU_LPC11UXX 1 ///< NXP LPC11Uxx +#define OPT_MCU_LPC11UXX 1 ///< NXP LPC11Uxx +#define OPT_MCU_LPC13XX 3 ///< NXP LPC13xx +#define OPT_MCU_LPC175X_6X 4 ///< NXP LPC175x, LPC176x +#define OPT_MCU_LPC177X_8X 5 ///< NXP LPC177x, LPC178x +#define OPT_MCU_LPC18XX 6 ///< NXP LPC18xx +#define OPT_MCU_LPC40XX 7 ///< NXP LPC40xx +#define OPT_MCU_LPC43XX 8 ///< NXP LPC43xx -#define OPT_MCU_LPC13XX 3 ///< NXP LPC13xx -#define OPT_MCU_LPC175X_6X 4 ///< NXP LPC175x, LPC176x -#define OPT_MCU_LPC177X_8X 5 ///< NXP LPC177x, LPC178x -#define OPT_MCU_LPC18XX 6 ///< NXP LPC18xx -#define OPT_MCU_LPC40XX 7 ///< NXP LPC40xx -#define OPT_MCU_LPC43XX 8 ///< NXP LPC43xx - -#define OPT_MCU_NRF5X 100 ///< Nordic nRF5x series +#define OPT_MCU_NRF5X 100 ///< Nordic nRF5x series #define OPT_MCU_SAMD21 200 ///< MicroChip SAMD21 #define OPT_MCU_SAMD51 201 ///< MicroChip SAMD51 #define OPT_MCU_STM32F4 300 ///< ST STM32F4 +#define OPT_MCU_STM32F3 301 ///< ST STM32F3 /** @} */ -- cgit v1.3.1 From 43eb1a8b1631ed4b460db123717a7226c10c701f Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 22 Mar 2019 23:57:14 +0700 Subject: added stub for dcd_stm32f3 --- hw/bsp/stm32f303disc/board.mk | 12 +- hw/bsp/stm32f303disc/board_stm32f303disc.c | 71 ++++--- hw/bsp/stm32f303disc/stm32f3xx_hal_conf.h | 312 +++++++++++++++++++++++++++++ src/device/dcd.h | 30 +-- src/portable/readme.md | 4 - src/portable/st/stm32f3/dcd_stm32f3.c | 82 ++++++++ src/portable/st/stm32f4/dcd_stm32f4.c | 2 +- 7 files changed, 457 insertions(+), 56 deletions(-) create mode 100644 hw/bsp/stm32f303disc/stm32f3xx_hal_conf.h delete mode 100644 src/portable/readme.md create mode 100644 src/portable/st/stm32f3/dcd_stm32f3.c (limited to 'src') diff --git a/hw/bsp/stm32f303disc/board.mk b/hw/bsp/stm32f303disc/board.mk index 5b558c1ec..c81717c49 100644 --- a/hw/bsp/stm32f303disc/board.mk +++ b/hw/bsp/stm32f303disc/board.mk @@ -15,17 +15,23 @@ LD_FILE = hw/bsp/stm32f303disc/STM32F303VCTx_FLASH.ld LDFLAGS += -mthumb -mcpu=cortex-m4 SRC_C += \ - hw/mcu/st/system-init/system_stm32f3xx.c + hw/mcu/st/system-init/system_stm32f3xx.c \ + hw/mcu/st/stm32lib/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal.c \ + hw/mcu/st/stm32lib/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_cortex.c \ + hw/mcu/st/stm32lib/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_rcc.c \ + hw/mcu/st/stm32lib/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_gpio.c SRC_S += \ hw/mcu/st/startup/stm32f3/startup_stm32f303xc.s INC += \ + -I$(TOP)/hw/bsp/stm32f303disc \ + -I$(TOP)/hw/mcu/st/cmsis \ -I$(TOP)/hw/mcu/st/stm32lib/CMSIS/STM32F3xx/Include \ - -I$(TOP)/hw/mcu/st/cmsis + -I$(TOP)/hw/mcu/st/stm32lib/STM32F3xx_HAL_Driver/Inc VENDOR = st -CHIP_FAMILY = stm32f4 +CHIP_FAMILY = stm32f3 JLINK_DEVICE = stm32f303vc diff --git a/hw/bsp/stm32f303disc/board_stm32f303disc.c b/hw/bsp/stm32f303disc/board_stm32f303disc.c index 99419b310..00740acca 100644 --- a/hw/bsp/stm32f303disc/board_stm32f303disc.c +++ b/hw/bsp/stm32f303disc/board_stm32f303disc.c @@ -25,37 +25,33 @@ */ #include "../board.h" -#include "stm32f3xx.h" - #include "tusb_option.h" +#include "stm32f3xx.h" +#include "stm32f3xx_hal_conf.h" + void board_init(void) { - // Init the LED on PD14 - RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN; - GPIOD->MODER |= GPIO_MODER_MODE14_0; - - // USB Clock init - // PLL input- 8 MHz (External oscillator clock; HSI clock tolerance isn't - // tight enough- 1%, need 0.25%) - // VCO input- 1 to 2 MHz (2 MHz, M = 4) - // VCO output- 100 to 432 MHz (144 MHz, N = 72) - // Main PLL out- <= 180 MHz (18 MHz, P = 3- divides by 8) - // USB PLL out- 48 MHz (Q = 3) - RCC->PLLCFGR = RCC_PLLCFGR_PLLSRC_HSE | (3 << RCC_PLLCFGR_PLLQ_Pos) | \ - (3 << RCC_PLLCFGR_PLLP_Pos) | (72 << RCC_PLLCFGR_PLLN_Pos) | \ - (4 << RCC_PLLCFGR_PLLM_Pos); - - // Wait for external clock to become ready - RCC->CR |= RCC_CR_HSEON; - while(!(RCC->CR & RCC_CR_HSERDY_Msk)); - - // Wait for PLL to become ready - RCC->CR |= RCC_CR_PLLON; - while(!(RCC->CR & RCC_CR_PLLRDY_Msk)); - - // Switch clocks! - RCC->CFGR |= RCC_CFGR_SW_1; + RCC_ClkInitTypeDef RCC_ClkInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct; + + /* Enable HSE Oscillator and activate PLL with HSE as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; + HAL_RCC_OscConfig(&RCC_OscInitStruct); + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + (void) HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2); // Notify runtime of frequency change. SystemCoreClockUpdate(); @@ -64,6 +60,19 @@ void board_init(void) SysTick_Config(SystemCoreClock / 1000); #endif + /* -1- Enable GPIOE Clock (to be able to program the configuration registers) */ + __HAL_RCC_GPIOE_CLK_ENABLE(); + + /* -2- Configure PE.8 to PE.15 IOs in output push-pull mode to drive external LEDs */ + static GPIO_InitTypeDef GPIO_InitStruct; + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; + + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + +#if 0 RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; // USB Pin Init @@ -79,19 +88,15 @@ void board_init(void) // Pullup required on ID, despite the manual claiming there's an // internal pullup already (page 1245, Rev 17) GPIOA->PUPDR |= GPIO_PUPDR_PUPD10_0; +#endif } void board_led_control(bool state) { - if (!state) { - GPIOD->BSRR = GPIO_BSRR_BR14; - } else { - GPIOD->BSRR = GPIO_BSRR_BS14; - } + HAL_GPIO_WritePin(GPIOE, GPIO_PIN_9, state); } - /*------------------------------------------------------------------*/ /* TUSB HAL MILLISECOND *------------------------------------------------------------------*/ diff --git a/hw/bsp/stm32f303disc/stm32f3xx_hal_conf.h b/hw/bsp/stm32f303disc/stm32f3xx_hal_conf.h new file mode 100644 index 000000000..38e7a4327 --- /dev/null +++ b/hw/bsp/stm32f303disc/stm32f3xx_hal_conf.h @@ -0,0 +1,312 @@ +/** + ****************************************************************************** + * @file GPIO/GPIO_IOToggle/Inc/stm32f3xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT(c) 2016 STMicroelectronics

+ * + * 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 of STMicroelectronics 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 HOLDER 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. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F3xx_HAL_CONF_H +#define __STM32F3xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +//#define HAL_ADC_MODULE_ENABLED +//#define HAL_CAN_MODULE_ENABLED +//#define HAL_CAN_LEGACY_MODULE_ENABLED +//#define HAL_CEC_MODULE_ENABLED +//#define HAL_COMP_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +//#define HAL_DAC_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +//#define HAL_HRTIM_MODULE_ENABLED +//#define HAL_I2C_MODULE_ENABLED +//#define HAL_I2S_MODULE_ENABLED +//#define HAL_IRDA_MODULE_ENABLED +//#define HAL_IWDG_MODULE_ENABLED +//#define HAL_OPAMP_MODULE_ENABLED +//#define HAL_PWR_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +//#define HAL_RTC_MODULE_ENABLED +//#define HAL_SDADC_MODULE_ENABLED +//#define HAL_SMARTCARD_MODULE_ENABLED +//#define HAL_SPI_MODULE_ENABLED +//#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +//#define HAL_WWDG_MODULE_ENABLED +//#define HAL_PPP_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE (8000000U) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +/** + * @brief In the following line adjust the External High Speed oscillator (HSE) Startup + * Timeout value + */ +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT (100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE (8000000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief In the following line adjust the Internal High Speed oscillator (HSI) Startup + * Timeout value + */ +#if !defined (HSI_STARTUP_TIMEOUT) + #define HSI_STARTUP_TIMEOUT (5000U) /*!< Time out for HSI start up */ +#endif /* HSI_STARTUP_TIMEOUT */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE (40000U) +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE (32768U) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +/** + * @brief Time out for LSE start up value in ms. + */ +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT (5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + * - External clock generated through external PLL component on EVAL 303 (based on MCO or crystal) + * - External clock not generated on EVAL 373 + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE (8000000U) /*!< Value of the External oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE (3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)(1U<<__NVIC_PRIO_BITS) - 1U) /*!< tick interrupt priority (lowest by default) */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 0U +#define DATA_CACHE_ENABLE 0U +#define USE_SPI_CRC 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/*#define USE_FULL_ASSERT 1*/ + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f3xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f3xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f3xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f3xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f3xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f3xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "stm32f3xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f3xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED + #include "stm32f3xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f3xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f3xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f3xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_HRTIM_MODULE_ENABLED + #include "stm32f3xx_hal_hrtim.h" +#endif /* HAL_HRTIM_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f3xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f3xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f3xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f3xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_OPAMP_MODULE_ENABLED + #include "stm32f3xx_hal_opamp.h" +#endif /* HAL_OPAMP_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f3xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f3xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SDADC_MODULE_ENABLED + #include "stm32f3xx_hal_sdadc.h" +#endif /* HAL_SDADC_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f3xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f3xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f3xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_TSC_MODULE_ENABLED + #include "stm32f3xx_hal_tsc.h" +#endif /* HAL_TSC_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f3xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f3xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f3xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((char *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(char* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F3xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/device/dcd.h b/src/device/dcd.h index 95a187298..e73f24277 100644 --- a/src/device/dcd.h +++ b/src/device/dcd.h @@ -97,21 +97,6 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num); // Get current frame number uint32_t dcd_get_frame_number(uint8_t rhport); -/*------------------------------------------------------------------*/ -/* Event Function - * Called by DCD to notify USBD - *------------------------------------------------------------------*/ -void dcd_event_handler(dcd_event_t const * event, bool in_isr); - -// helper to send bus signal event -void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr); - -// helper to send setup received -void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr); - -// helper to send transfer complete event -void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr); - /*------------------------------------------------------------------*/ /* Endpoint API * - open : Configure endpoint's registers @@ -130,6 +115,21 @@ void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr); void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr); bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr); +/*------------------------------------------------------------------*/ +/* Event Function + * Called by DCD to notify USBD + *------------------------------------------------------------------*/ +void dcd_event_handler(dcd_event_t const * event, bool in_isr); + +// helper to send bus signal event +void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr); + +// helper to send setup received +void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr); + +// helper to send transfer complete event +void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr); + #ifdef __cplusplus } #endif diff --git a/src/portable/readme.md b/src/portable/readme.md deleted file mode 100644 index a3e8557dc..000000000 --- a/src/portable/readme.md +++ /dev/null @@ -1,4 +0,0 @@ -To port tinyusb to support new MCU you need to implement all API in the -- tusb_hal.h (mandatory for both device and host stack) -- device/dcd.h for device stack -- host/hcd.h for host stack diff --git a/src/portable/st/stm32f3/dcd_stm32f3.c b/src/portable/st/stm32f3/dcd_stm32f3.c new file mode 100644 index 000000000..20dd92fc5 --- /dev/null +++ b/src/portable/st/stm32f3/dcd_stm32f3.c @@ -0,0 +1,82 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2018, hathach (tinyusb.org) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * This file is part of the TinyUSB stack. + */ + +#include "tusb_option.h" + +#if TUSB_OPT_DEVICE_ENABLED && CFG_TUSB_MCU == OPT_MCU_STM32F3 + +#include "device/dcd.h" +#include "stm32f3xx.h" + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM DECLARATION +//--------------------------------------------------------------------+ + + +bool dcd_init (uint8_t rhport) +{ + return true; +} + +// Enable device interrupt +void dcd_int_enable (uint8_t rhport) +{} + +// Disable device interrupt +void dcd_int_disable(uint8_t rhport) +{} + +// Receive Set Address request, mcu port must also include status IN response +void dcd_set_address(uint8_t rhport, uint8_t dev_addr) +{} + +// Receive Set Config request +void dcd_set_config (uint8_t rhport, uint8_t config_num) +{} + +// Get current frame number +uint32_t dcd_get_frame_number(uint8_t rhport) +{ return 0; } + +bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc) +{ + return false; +} +bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes) +{ return false;} +bool dcd_edpt_busy (uint8_t rhport, uint8_t ep_addr) +{ return false;} + +void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) +{} +void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr) +{} +bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) +{ + return false;} + +#endif + diff --git a/src/portable/st/stm32f4/dcd_stm32f4.c b/src/portable/st/stm32f4/dcd_stm32f4.c index d99e455ed..472a63f32 100644 --- a/src/portable/st/stm32f4/dcd_stm32f4.c +++ b/src/portable/st/stm32f4/dcd_stm32f4.c @@ -26,7 +26,7 @@ #include "tusb_option.h" -#if TUSB_OPT_DEVICE_ENABLED && (CFG_TUSB_MCU == OPT_MCU_STM32F4 || CFG_TUSB_MCU == OPT_MCU_STM32F3) +#if TUSB_OPT_DEVICE_ENABLED && CFG_TUSB_MCU == OPT_MCU_STM32F4 #include "device/dcd.h" #include "stm32f4xx.h" -- cgit v1.3.1 From df1aac44b839f65bf8b5961d4d184c515ad18f5c Mon Sep 17 00:00:00 2001 From: hathach Date: Sat, 23 Mar 2019 16:51:07 +0700 Subject: add board_noos_millis() for blinky --- examples/device/cdc_msc_hid/src/main.c | 7 ++++--- hw/bsp/board.h | 3 +++ hw/bsp/ea4088qs/board_ea4088qs.c | 8 +++++++- hw/bsp/ea4357/board_ea4357.c | 8 +++++++- hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c | 11 ++++++++++- hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c | 13 +++++++++++++ hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c | 8 +++++++- hw/bsp/mcb1800/board_mcb1800.c | 8 +++++++- hw/bsp/metro_m0_express/board_metro_m0_express.c | 11 +++++++++-- hw/bsp/metro_m4_express/board_metro_m4_express.c | 10 +++++++--- hw/bsp/pca10056/board_pca10056.c | 8 +++++++- hw/bsp/stm32f303disc/board_stm32f303disc.c | 10 ++++++++-- hw/bsp/stm32f407g_disc1/board_stm32f407g_disc1.c | 10 ++++++++-- src/common/tusb_timeout.h | 4 ++-- tools/build_all.py | 11 +++++++++++ 15 files changed, 110 insertions(+), 20 deletions(-) create mode 100644 tools/build_all.py (limited to 'src') diff --git a/examples/device/cdc_msc_hid/src/main.c b/examples/device/cdc_msc_hid/src/main.c index b2a902835..be0b14933 100644 --- a/examples/device/cdc_msc_hid/src/main.c +++ b/examples/device/cdc_msc_hid/src/main.c @@ -193,11 +193,12 @@ void tud_umount_cb(void) //--------------------------------------------------------------------+ void led_blinking_task(void) { - static tu_timeout_t tm = { .start = 0, .interval = 1000 }; // Blink every 1000 ms + static uint32_t start_ms = 0; static bool led_state = false; - if ( !tu_timeout_expired(&tm) ) return; // not enough time - tu_timeout_reset(&tm); + // Blink every 1000 ms + if ( board_noos_millis() < start_ms + 1000) return; // not enough time + start_ms += 1000; board_led_control(led_state); led_state = 1 - led_state; // toggle diff --git a/hw/bsp/board.h b/hw/bsp/board.h index ec0b1311a..44dba7ecf 100644 --- a/hw/bsp/board.h +++ b/hw/bsp/board.h @@ -64,6 +64,9 @@ int board_uart_read(uint8_t* buf, int len); // Send characters to UART int board_uart_write(void const * buf, int len); +// Get current milliseconds with no rtos configure (TUSB_CFG_OS = OPT_OS_NONE) +uint32_t board_noos_millis(void); + //--------------------------------------------------------------------+ // Helper functions //--------------------------------------------------------------------+ diff --git a/hw/bsp/ea4088qs/board_ea4088qs.c b/hw/bsp/ea4088qs/board_ea4088qs.c index d8ab2973d..e4b006c74 100644 --- a/hw/bsp/ea4088qs/board_ea4088qs.c +++ b/hw/bsp/ea4088qs/board_ea4088qs.c @@ -81,7 +81,8 @@ void board_init(void) SystemCoreClockUpdate(); #if CFG_TUSB_OS == OPT_OS_NONE - SysTick_Config(SystemCoreClock / BOARD_TICKS_HZ); + // 1ms tick timer + SysTick_Config(SystemCoreClock / 1000); #elif CFG_TUSB_OS == OPT_OS_FREERTOS // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); @@ -174,6 +175,11 @@ uint32_t tusb_hal_millis(void) return board_tick2ms(system_ticks); } +uint32_t board_noos_millis(void) +{ + return system_ticks; +} + #endif #endif diff --git a/hw/bsp/ea4357/board_ea4357.c b/hw/bsp/ea4357/board_ea4357.c index a9af16633..3bb846cc1 100644 --- a/hw/bsp/ea4357/board_ea4357.c +++ b/hw/bsp/ea4357/board_ea4357.c @@ -74,6 +74,11 @@ uint32_t tusb_hal_millis(void) return board_tick2ms(system_ticks); } +uint32_t board_noos_millis(void) +{ + return system_ticks; +} + #endif /*------------------------------------------------------------------*/ @@ -126,7 +131,8 @@ void board_init(void) SystemCoreClockUpdate(); #if CFG_TUSB_OS == OPT_OS_NONE - SysTick_Config( SystemCoreClock / BOARD_TICKS_HZ ); + // 1ms tick timer + SysTick_Config(SystemCoreClock / 1000); #endif Chip_GPIO_Init(LPC_GPIO_PORT); diff --git a/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c b/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c index 472204d66..ca7e699c0 100644 --- a/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c +++ b/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c @@ -71,7 +71,11 @@ void board_init(void) SystemCoreClockUpdate(); #if CFG_TUSB_OS == OPT_OS_NONE - SysTick_Config(SystemCoreClock / BOARD_TICKS_HZ); // 1 msec tick timer + // 1ms tick timer + SysTick_Config(SystemCoreClock / 1000); +#elif CFG_TUSB_OS == OPT_OS_FREERTOS + // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) + NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); #endif Chip_GPIO_Init(LPC_GPIO); @@ -106,6 +110,11 @@ uint32_t tusb_hal_millis(void) return board_tick2ms(system_ticks); } +uint32_t board_noos_millis(void) +{ + return system_ticks; +} + #endif //--------------------------------------------------------------------+ diff --git a/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c b/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c index e7ed229a5..18853c5fb 100644 --- a/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c +++ b/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c @@ -87,6 +87,14 @@ void board_init(void) SysTick_Config(SystemCoreClock / BOARD_TICKS_HZ); // 1 msec tick timer #endif +#if CFG_TUSB_OS == OPT_OS_NONE + // 1ms tick timer + SysTick_Config(SystemCoreClock / 1000); +#elif CFG_TUSB_OS == OPT_OS_FREERTOS + // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) + NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); +#endif + Chip_GPIO_Init(LPC_GPIO_PORT); //------------- LED -------------// @@ -119,6 +127,11 @@ uint32_t tusb_hal_millis(void) return board_tick2ms(system_ticks); } +uint32_t board_noos_millis(void) +{ + return system_ticks; +} + #endif //--------------------------------------------------------------------+ diff --git a/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c b/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c index 32273aa75..5578ae5d6 100644 --- a/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c +++ b/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c @@ -85,7 +85,8 @@ void board_init(void) SystemCoreClockUpdate(); #if CFG_TUSB_OS == OPT_OS_NONE - SysTick_Config(SystemCoreClock / BOARD_TICKS_HZ); + // 1ms tick timer + SysTick_Config(SystemCoreClock / 1000); #elif CFG_TUSB_OS == OPT_OS_FREERTOS // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); @@ -162,6 +163,11 @@ uint32_t tusb_hal_millis(void) return board_tick2ms(system_ticks); } +uint32_t board_noos_millis(void) +{ + return system_ticks; +} + #endif //--------------------------------------------------------------------+ diff --git a/hw/bsp/mcb1800/board_mcb1800.c b/hw/bsp/mcb1800/board_mcb1800.c index b7ddf46eb..d6b45090d 100644 --- a/hw/bsp/mcb1800/board_mcb1800.c +++ b/hw/bsp/mcb1800/board_mcb1800.c @@ -95,7 +95,8 @@ void board_init(void) SystemCoreClockUpdate(); #if CFG_TUSB_OS == OPT_OS_NONE - SysTick_Config( SystemCoreClock / BOARD_TICKS_HZ ); + // 1ms tick timer + SysTick_Config(SystemCoreClock / 1000); #endif Chip_GPIO_Init(LPC_GPIO_PORT); @@ -240,6 +241,11 @@ uint32_t tusb_hal_millis(void) return board_tick2ms(system_ticks); } +uint32_t board_noos_millis(void) +{ + return system_ticks; +} + #endif #endif diff --git a/hw/bsp/metro_m0_express/board_metro_m0_express.c b/hw/bsp/metro_m0_express/board_metro_m0_express.c index 8bca69a30..06d8407ab 100644 --- a/hw/bsp/metro_m0_express/board_metro_m0_express.c +++ b/hw/bsp/metro_m0_express/board_metro_m0_express.c @@ -66,8 +66,8 @@ void board_init(void) gpio_set_pin_level(LED_PIN, 0); #if CFG_TUSB_OS == OPT_OS_NONE - // Tick init, samd SystemCoreClock may not correct - SysTick_Config(CONF_CPU_FREQUENCY/1000); + // 1ms tick timer (samd SystemCoreClock may not correct) + SysTick_Config(CONF_CPU_FREQUENCY / 1000); #endif /* USB Clock init @@ -119,4 +119,11 @@ uint32_t tusb_hal_millis(void) { return board_tick2ms(system_ticks); } + +uint32_t board_noos_millis(void) +{ + return system_ticks; +} + + #endif diff --git a/hw/bsp/metro_m4_express/board_metro_m4_express.c b/hw/bsp/metro_m4_express/board_metro_m4_express.c index b14ce31d6..d20a04537 100644 --- a/hw/bsp/metro_m4_express/board_metro_m4_express.c +++ b/hw/bsp/metro_m4_express/board_metro_m4_express.c @@ -63,10 +63,9 @@ void board_init(void) gpio_set_pin_direction(LED_PIN, GPIO_DIRECTION_OUT); gpio_set_pin_level(LED_PIN, 0); - // Systick init #if CFG_TUSB_OS == OPT_OS_NONE - // Tick init, samd SystemCoreClock may not correct - SysTick_Config(SystemCoreClock / 1000); + // 1ms tick timer (samd SystemCoreClock may not correct) + SysTick_Config(CONF_CPU_FREQUENCY / 1000); #endif /* USB Clock init @@ -109,4 +108,9 @@ uint32_t tusb_hal_millis(void) { return board_tick2ms(system_ticks); } + +uint32_t board_noos_millis(void) +{ + return system_ticks; +} #endif diff --git a/hw/bsp/pca10056/board_pca10056.c b/hw/bsp/pca10056/board_pca10056.c index c82b1544f..179b22dcc 100644 --- a/hw/bsp/pca10056/board_pca10056.c +++ b/hw/bsp/pca10056/board_pca10056.c @@ -65,6 +65,12 @@ uint32_t tusb_hal_millis(void) { return board_tick2ms(system_ticks); } + +uint32_t board_noos_millis(void) +{ + return system_ticks; +} + #endif /*------------------------------------------------------------------*/ @@ -89,7 +95,7 @@ void board_init(void) for(uint8_t i=0; iAHB2ENR |= RCC_AHB2ENR_OTGFSEN; @@ -108,6 +109,11 @@ uint32_t tusb_hal_millis(void) { return board_tick2ms(system_ticks); } + +uint32_t board_noos_millis(void) +{ + return system_ticks; +} #endif void HardFault_Handler (void) diff --git a/src/common/tusb_timeout.h b/src/common/tusb_timeout.h index 556b8d4a3..bdade6b42 100644 --- a/src/common/tusb_timeout.h +++ b/src/common/tusb_timeout.h @@ -28,11 +28,11 @@ * \defgroup Group_TimeoutTimer timeout timer * @{ */ - #ifndef _TUSB_TIMEOUT_H_ #define _TUSB_TIMEOUT_H_ -#include "tusb_compiler.h" +#include +#include #ifdef __cplusplus extern "C" { diff --git a/tools/build_all.py b/tools/build_all.py new file mode 100644 index 000000000..4b6fa5775 --- /dev/null +++ b/tools/build_all.py @@ -0,0 +1,11 @@ +import os +import shutil +import sys +import subprocess +import time + +all_boards = ["metro_m0_express", "metro_m4_express", "pca10056", "stm32f407g_disc1"] + +for board in all_boards: + subprocess.run("make -j2 -C examples/device/cdc_msc_hid BOARD={} clean".format(board), shell=True) + subprocess.run("make -j2 -C examples/device/cdc_msc_hid BOARD={} all".format(board), shell=True) -- cgit v1.3.1 From d866999bf0f41b0d3db0354c599d014c66dc6870 Mon Sep 17 00:00:00 2001 From: hathach Date: Sat, 23 Mar 2019 17:15:00 +0700 Subject: remove idle rate enforcement, should be done in application level --- examples/device/cdc_msc_hid/src/main.c | 13 +++++---- src/class/hid/hid_device.c | 53 +++++++--------------------------- 2 files changed, 19 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/examples/device/cdc_msc_hid/src/main.c b/examples/device/cdc_msc_hid/src/main.c index be0b14933..06a99711f 100644 --- a/examples/device/cdc_msc_hid/src/main.c +++ b/examples/device/cdc_msc_hid/src/main.c @@ -121,10 +121,11 @@ void tud_cdc_rx_cb(uint8_t itf) void usb_hid_task(void) { // Poll every 10ms - static tu_timeout_t tm = { .start = 0, .interval = 10 }; + const uint32_t interval_ms = 10; + static uint32_t start_ms = 0; - if ( !tu_timeout_expired(&tm) ) return; // not enough time - tu_timeout_reset(&tm); + if ( board_noos_millis() < start_ms + interval_ms) return; // not enough time + start_ms += interval_ms; uint32_t const btn = board_buttons(); @@ -193,12 +194,14 @@ void tud_umount_cb(void) //--------------------------------------------------------------------+ void led_blinking_task(void) { + const uint32_t interval_ms = 1000; static uint32_t start_ms = 0; + static bool led_state = false; // Blink every 1000 ms - if ( board_noos_millis() < start_ms + 1000) return; // not enough time - start_ms += 1000; + if ( board_noos_millis() < start_ms + interval_ms) return; // not enough time + start_ms += interval_ms; board_led_control(led_state); led_state = 1 - led_state; // toggle diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index 73af0c9a2..fd7602251 100644 --- a/src/class/hid/hid_device.c +++ b/src/class/hid/hid_device.c @@ -43,7 +43,6 @@ // Max report len is keyboard's one with 8 byte + 1 byte report id #define REPORT_BUFSIZE 12 - #define ITF_IDX_BOOT_KBD 0 #define ITF_IDX_BOOT_MSE ( ITF_IDX_BOOT_KBD + (CFG_TUD_HID_KEYBOARD && CFG_TUD_HID_KEYBOARD_BOOT) ) #define ITF_IDX_GENERIC ( ITF_IDX_BOOT_MSE + (CFG_TUD_HID_MOUSE && CFG_TUD_HID_MOUSE_BOOT) ) @@ -70,8 +69,10 @@ typedef struct typedef struct { - uint8_t usage; // HID_USAGE_* - uint8_t idle_rate; // in unit of 4 ms + uint8_t usage; // HID_USAGE_* + uint8_t idle_rate; // Idle Rate = 0 : only send report if there is changes, i.e skip duplication + // Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms). + // If idle time is less than interrupt polling then use the polling. uint8_t report_id; uint8_t report_len; @@ -91,7 +92,6 @@ static hidd_report_t _mse_rpt; #endif /*------------- Helpers -------------*/ - static inline hidd_interface_t* get_interface_by_itfnum(uint8_t itf_num) { for (uint8_t i=0; i < ITF_COUNT; i++ ) @@ -151,19 +151,14 @@ static bool hidd_kbd_report(hid_keyboard_report_t const *p_report) hidd_interface_t * p_hid = _kbd_rpt.itf; - // Idle Rate = 0 : only send report if there is changes, i.e skip duplication - // Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms). - // If idle time is less than interrupt polling then use the polling. - static tu_timeout_t idle_tm = { 0, 0 }; - - if ( (_kbd_rpt.idle_rate == 0) || !tu_timeout_expired(&idle_tm) ) - { - if ( 0 == memcmp(p_hid->report_buf, p_report, sizeof(hid_keyboard_report_t)) ) return true; - } - - tu_timeout_set(&idle_tm, _kbd_rpt.idle_rate * 4); + // only send report if there is changes, i.e skip duplication +// if ( _kbd_rpt.idle_rate == 0 ) +// { +// if ( 0 == memcmp(p_hid->report_buf, p_report, sizeof(hid_keyboard_report_t)) ) return true; +// } memcpy(p_hid->report_buf, p_report, sizeof(hid_keyboard_report_t)); + return dcd_edpt_xfer(TUD_OPT_RHPORT, p_hid->ep_in, p_hid->report_buf, sizeof(hid_keyboard_report_t)); } @@ -195,33 +190,6 @@ bool tud_hid_keyboard_key_press(char ch) return tud_hid_keyboard_keycode(modifier, keycode); } -#if 0 // should be at application -bool tud_hid_keyboard_key_sequence(const char* str, uint32_t interval_ms) -{ - // Send each key in string - char ch; - while( (ch = *str++) != 0 ) - { - char lookahead = *str; - - tud_hid_keyboard_key_press(ch); - - // Blocking delay - tu_timeout_wait(interval_ms); - - /* Only need to empty report if the next character is NULL or the same with - * the current one, else no need to send */ - if ( lookahead == ch || lookahead == 0 ) - { - tud_hid_keyboard_key_release(); - tu_timeout_wait(interval_ms); - } - } - - return true; -} -#endif - #endif // CFG_TUD_HID_ASCII_TO_KEYCODE_LOOKUP #endif // CFG_TUD_HID_KEYBOARD @@ -246,6 +214,7 @@ static bool hidd_mouse_report(hid_mouse_report_t const *p_report) TU_VERIFY( tud_hid_mouse_ready() ); hidd_interface_t * p_hid = _mse_rpt.itf; +// only send report if there is changes, i.e skip duplication memcpy(p_hid->report_buf, p_report, sizeof(hid_mouse_report_t)); return dcd_edpt_xfer(TUD_OPT_RHPORT, p_hid->ep_in, p_hid->report_buf, sizeof(hid_mouse_report_t)); -- cgit v1.3.1 From 18f248b142a477b2134d23a2902d8d7de6e4c195 Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 24 Mar 2019 01:19:32 +0700 Subject: remove tusb_hal_millis() usage, less work for porting --- docs/porting.md | 6 --- .../cdc_msc_hid/ses/lpc13xx/lpc13xx.emProject | 1 - .../ses/lpc175x_6x/lpc175x_6x.emProject | 59 +++++++++++----------- .../cdc_msc_hid/ses/lpc18xx/lpc18xx.emProject | 1 - .../cdc_msc_hid/ses/lpc40xx/lpc40xx.emProject | 1 - .../cdc_msc_hid/ses/lpc43xx/lpc43xx.emProject | 1 - .../device/cdc_msc_hid/ses/nrf5x/nrf5x.emProject | 1 - .../device/cdc_msc_hid/ses/samd21/samd21.emProject | 1 - .../device/cdc_msc_hid/ses/samd51/samd51.emProject | 1 - .../cdc_msc_hid/ses/stm32f4/stm32f4.emProject | 1 - .../ses/lpc175x_6x/FreeRTOSConfig.h | 2 +- .../ses/lpc175x_6x/lpc175x_6x.emProject | 34 ++++++------- .../cdc_msc_hid_freertos/ses/nrf5x/nrf5x.emProject | 8 +-- .../ses/samd21/samd21.emProject | 2 - .../ses/samd51/samd51.emProject | 2 - examples/host/cdc_msc_hid/src/main.c | 9 ++-- hw/bsp/board.h | 4 ++ hw/bsp/ea4088qs/board_ea4088qs.c | 5 -- hw/bsp/ea4357/board_ea4357.c | 5 -- hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c | 5 -- hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c | 5 -- hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c | 5 -- hw/bsp/mcb1800/board_mcb1800.c | 5 -- hw/bsp/metro_m0_express/board_metro_m0_express.c | 5 -- hw/bsp/metro_m4_express/board_metro_m4_express.c | 5 -- hw/bsp/pca10056/board_pca10056.c | 11 +--- hw/bsp/stm32f303disc/board_stm32f303disc.c | 5 -- hw/bsp/stm32f407g_disc1/board_stm32f407g_disc1.c | 5 -- src/common/tusb_timeout.h | 4 ++ src/osal/osal.c | 48 ------------------ src/osal/osal.h | 2 - src/osal/osal_none.h | 9 ++-- src/portable/nordic/nrf5x/hal_nrf5x.c | 2 - src/portable/nxp/lpc18_43/dcd_lpc18_43.c | 2 - src/tusb.h | 1 - src/tusb_hal.h | 52 ------------------- 36 files changed, 71 insertions(+), 244 deletions(-) delete mode 100644 src/osal/osal.c delete mode 100644 src/tusb_hal.h (limited to 'src') diff --git a/docs/porting.md b/docs/porting.md index f5af82800..70c9f25aa 100644 --- a/docs/porting.md +++ b/docs/porting.md @@ -53,12 +53,6 @@ The OS Abstraction Layer is responsible for providing basic data structures for The code is almost entirely agnostic of MCU and lives in `src/osal`. -#### tusb_hal_millis - -The OPT_OS_NONE option is the only option which requires an MCU specific function. It needs `tusb_hal_millis` to measure the passage of time. On ARM this is commonly done with SysTick. The function returns the elapsed number of milliseconds since startup. - -`tusb_hal_millis` is also provided in `hw/bsp//board_.c` because it may vary with MCU use. - ### Device API After the USB device is setup, the USB device code works by processing events on the main thread (by calling `tud_task`). These events are queued by the USB interrupt handler. So, there are three parts to the device low-level API: device setup, endpoint setup and interrupt processing. diff --git a/examples/device/cdc_msc_hid/ses/lpc13xx/lpc13xx.emProject b/examples/device/cdc_msc_hid/ses/lpc13xx/lpc13xx.emProject index 9654a951e..a3a59af71 100644 --- a/examples/device/cdc_msc_hid/ses/lpc13xx/lpc13xx.emProject +++ b/examples/device/cdc_msc_hid/ses/lpc13xx/lpc13xx.emProject @@ -54,7 +54,6 @@ - diff --git a/examples/device/cdc_msc_hid/ses/lpc175x_6x/lpc175x_6x.emProject b/examples/device/cdc_msc_hid/ses/lpc175x_6x/lpc175x_6x.emProject index aff0bf3e6..d0b065370 100644 --- a/examples/device/cdc_msc_hid/ses/lpc175x_6x/lpc175x_6x.emProject +++ b/examples/device/cdc_msc_hid/ses/lpc175x_6x/lpc175x_6x.emProject @@ -47,39 +47,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/device/cdc_msc_hid/ses/lpc18xx/lpc18xx.emProject b/examples/device/cdc_msc_hid/ses/lpc18xx/lpc18xx.emProject index 286e76e3a..e7ce7a02a 100644 --- a/examples/device/cdc_msc_hid/ses/lpc18xx/lpc18xx.emProject +++ b/examples/device/cdc_msc_hid/ses/lpc18xx/lpc18xx.emProject @@ -54,7 +54,6 @@ - diff --git a/examples/device/cdc_msc_hid/ses/lpc40xx/lpc40xx.emProject b/examples/device/cdc_msc_hid/ses/lpc40xx/lpc40xx.emProject index 90718a51b..5a1cbe52b 100644 --- a/examples/device/cdc_msc_hid/ses/lpc40xx/lpc40xx.emProject +++ b/examples/device/cdc_msc_hid/ses/lpc40xx/lpc40xx.emProject @@ -56,7 +56,6 @@ - diff --git a/examples/device/cdc_msc_hid/ses/lpc43xx/lpc43xx.emProject b/examples/device/cdc_msc_hid/ses/lpc43xx/lpc43xx.emProject index d67cd3ce4..26444c469 100644 --- a/examples/device/cdc_msc_hid/ses/lpc43xx/lpc43xx.emProject +++ b/examples/device/cdc_msc_hid/ses/lpc43xx/lpc43xx.emProject @@ -47,7 +47,6 @@ - diff --git a/examples/device/cdc_msc_hid/ses/nrf5x/nrf5x.emProject b/examples/device/cdc_msc_hid/ses/nrf5x/nrf5x.emProject index f95b43318..6f5614f27 100644 --- a/examples/device/cdc_msc_hid/ses/nrf5x/nrf5x.emProject +++ b/examples/device/cdc_msc_hid/ses/nrf5x/nrf5x.emProject @@ -44,7 +44,6 @@ - diff --git a/examples/device/cdc_msc_hid/ses/samd21/samd21.emProject b/examples/device/cdc_msc_hid/ses/samd21/samd21.emProject index 6aa73d1e4..e65873008 100644 --- a/examples/device/cdc_msc_hid/ses/samd21/samd21.emProject +++ b/examples/device/cdc_msc_hid/ses/samd21/samd21.emProject @@ -46,7 +46,6 @@ - diff --git a/examples/device/cdc_msc_hid/ses/samd51/samd51.emProject b/examples/device/cdc_msc_hid/ses/samd51/samd51.emProject index e175873ee..280afdcd1 100644 --- a/examples/device/cdc_msc_hid/ses/samd51/samd51.emProject +++ b/examples/device/cdc_msc_hid/ses/samd51/samd51.emProject @@ -47,7 +47,6 @@ - diff --git a/examples/device/cdc_msc_hid/ses/stm32f4/stm32f4.emProject b/examples/device/cdc_msc_hid/ses/stm32f4/stm32f4.emProject index 4067e4c10..83067fd09 100644 --- a/examples/device/cdc_msc_hid/ses/stm32f4/stm32f4.emProject +++ b/examples/device/cdc_msc_hid/ses/stm32f4/stm32f4.emProject @@ -63,7 +63,6 @@ - diff --git a/examples/device/cdc_msc_hid_freertos/ses/lpc175x_6x/FreeRTOSConfig.h b/examples/device/cdc_msc_hid_freertos/ses/lpc175x_6x/FreeRTOSConfig.h index 0fad1dc89..5d3ba479e 100644 --- a/examples/device/cdc_msc_hid_freertos/ses/lpc175x_6x/FreeRTOSConfig.h +++ b/examples/device/cdc_msc_hid_freertos/ses/lpc175x_6x/FreeRTOSConfig.h @@ -4,7 +4,7 @@ //--------------------------------------------------------------------+ // See http://www.freertos.org/a00110.html. //--------------------------------------------------------------------+ -#include "LPC17xx.h" +#include "chip.h" #define configCPU_CLOCK_HZ SystemCoreClock diff --git a/examples/device/cdc_msc_hid_freertos/ses/lpc175x_6x/lpc175x_6x.emProject b/examples/device/cdc_msc_hid_freertos/ses/lpc175x_6x/lpc175x_6x.emProject index 893d6b507..5493af626 100644 --- a/examples/device/cdc_msc_hid_freertos/ses/lpc175x_6x/lpc175x_6x.emProject +++ b/examples/device/cdc_msc_hid_freertos/ses/lpc175x_6x/lpc175x_6x.emProject @@ -19,8 +19,8 @@ arm_target_device_name="LPC1769" arm_target_interface_type="SWD" build_treat_warnings_as_errors="No" - c_preprocessor_definitions="LPC175x_6x;__LPC1700_FAMILY;__LPC176x_SUBFAMILY;ARM_MATH_CM3;FLASH_PLACEMENT=1;BOARD_LPCXPRESSO1769;CFG_TUSB_MCU=OPT_MCU_LPC175X_6X" - c_user_include_directories=".;../../src;$(rootDir)/hw;$(rootDir)/src;$(lpcDir)/CMSIS_CORE_LPC17xx/inc;$(lpcDir)/LPC17xx_DriverLib/include;$(freertosDir)/Source/include;$(freertosDir)/Source/portable/GCC/ARM_CM3" + c_preprocessor_definitions="LPC175x_6x;__LPC1700_FAMILY;__LPC176x_SUBFAMILY;ARM_MATH_CM3;FLASH_PLACEMENT=1;CORE_M3;CFG_TUSB_MCU=OPT_MCU_LPC175X_6X" + c_user_include_directories=".;../../src;$(rootDir)/hw;$(rootDir)/src;$(rootDir)/hw/mcu/nxp/lpcopen/lpc_chip_175x_6x/inc;$(rootDir)/lib/FreeRTOS/Source/include;$(rootDir)/lib/FreeRTOS/Source/portable/GCC/ARM_CM3" debug_register_definition_file="LPC176x5x_Registers.xml" debug_target_connection="J-Link" gcc_enable_all_warnings="Yes" @@ -29,7 +29,7 @@ linker_memory_map_file="LPC1769_MemoryMap.xml" linker_section_placement_file="flash_placement.xml" linker_section_placements_segments="FLASH RX 0x00000000 0x00080000;RAM RWX 0x10000000 0x00008000" - macros="DeviceFamily=LPC1700;DeviceSubFamily=LPC176x;Target=LPC1769;Placement=Flash;rootDir=../../../../..;lpcDir=../../../../../hw/mcu/nxp/lpc175x_6x;freertosDir=../../../../../lib/FreeRTOS" + macros="DeviceFamily=LPC1700;DeviceSubFamily=LPC176x;Target=LPC1769;Placement=Flash;rootDir=../../../../.." project_directory="" project_type="Executable" target_reset_script="Reset();" @@ -43,30 +43,23 @@ recurse="Yes" /> - - - - - - - - + + - - - - - - - - + + + + + + + @@ -136,6 +129,9 @@ + diff --git a/examples/device/cdc_msc_hid_freertos/ses/nrf5x/nrf5x.emProject b/examples/device/cdc_msc_hid_freertos/ses/nrf5x/nrf5x.emProject index ea4950682..ad236ae66 100644 --- a/examples/device/cdc_msc_hid_freertos/ses/nrf5x/nrf5x.emProject +++ b/examples/device/cdc_msc_hid_freertos/ses/nrf5x/nrf5x.emProject @@ -19,7 +19,7 @@ arm_target_device_name="nRF52840_xxAA" arm_target_interface_type="SWD" build_treat_warnings_as_errors="No" - c_preprocessor_definitions="NRF52840_XXAA;__nRF_FAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;BOARD_PCA10056;CFG_TUSB_MCU=OPT_MCU_NRF5X" + c_preprocessor_definitions="NRF52840_XXAA;__nRF_FAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;CFG_TUSB_MCU=OPT_MCU_NRF5X" c_user_include_directories="./;../../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(nrfxDir)/..;$(nrfxDir);$(nrfxDir)/mdk;$(nrfxDir)/hal;$(nrfxDir)/drivers/include;$(freertosDir)/Source/include;$(freertosDir)/Source/portable/GCC/ARM_CM4F" debug_register_definition_file="nrf52840_Registers.xml" debug_target_connection="J-Link" @@ -44,9 +44,7 @@ - - @@ -143,10 +141,12 @@ - + diff --git a/examples/device/cdc_msc_hid_freertos/ses/samd21/samd21.emProject b/examples/device/cdc_msc_hid_freertos/ses/samd21/samd21.emProject index 07e902645..18291fbfd 100644 --- a/examples/device/cdc_msc_hid_freertos/ses/samd21/samd21.emProject +++ b/examples/device/cdc_msc_hid_freertos/ses/samd21/samd21.emProject @@ -41,11 +41,9 @@ recurse="Yes" /> - - diff --git a/examples/device/cdc_msc_hid_freertos/ses/samd51/samd51.emProject b/examples/device/cdc_msc_hid_freertos/ses/samd51/samd51.emProject index 81758d177..c18aad2eb 100644 --- a/examples/device/cdc_msc_hid_freertos/ses/samd51/samd51.emProject +++ b/examples/device/cdc_msc_hid_freertos/ses/samd51/samd51.emProject @@ -42,11 +42,9 @@ recurse="Yes" /> - - diff --git a/examples/host/cdc_msc_hid/src/main.c b/examples/host/cdc_msc_hid/src/main.c index b38e44017..86ddb55e1 100644 --- a/examples/host/cdc_msc_hid/src/main.c +++ b/examples/host/cdc_msc_hid/src/main.c @@ -164,11 +164,14 @@ void tuh_hid_mouse_isr(uint8_t dev_addr, xfer_result_t event) //--------------------------------------------------------------------+ void led_blinking_task(void) { - static tu_timeout_t tm = { .start = 0, .interval = 1000 }; // Blink every 1000 ms + const uint32_t interval_ms = 1000; + static uint32_t start_ms = 0; + static bool led_state = false; - if ( !tu_timeout_expired(&tm) ) return; // not enough time - tu_timeout_reset(&tm); + // Blink every 1000 ms + if ( board_millis() < start_ms + interval_ms) return; // not enough time + start_ms += interval_ms; board_led_control(led_state); led_state = 1 - led_state; // toggle diff --git a/hw/bsp/board.h b/hw/bsp/board.h index ea0f3152c..2a46c976b 100644 --- a/hw/bsp/board.h +++ b/hw/bsp/board.h @@ -86,6 +86,10 @@ static inline uint32_t board_millis(void) return os_time_ticks_to_ms32( os_time_get() ); } +#elif + +#error "Need to implement board_millis() for this OS" + #endif //--------------------------------------------------------------------+ diff --git a/hw/bsp/ea4088qs/board_ea4088qs.c b/hw/bsp/ea4088qs/board_ea4088qs.c index 11b3a7eb8..4f4e19ee0 100644 --- a/hw/bsp/ea4088qs/board_ea4088qs.c +++ b/hw/bsp/ea4088qs/board_ea4088qs.c @@ -166,11 +166,6 @@ void SysTick_Handler (void) system_ticks++; } -uint32_t tusb_hal_millis(void) -{ - return board_tick2ms(system_ticks); -} - uint32_t board_millis(void) { return system_ticks; diff --git a/hw/bsp/ea4357/board_ea4357.c b/hw/bsp/ea4357/board_ea4357.c index e5e93033d..6d7d936db 100644 --- a/hw/bsp/ea4357/board_ea4357.c +++ b/hw/bsp/ea4357/board_ea4357.c @@ -65,11 +65,6 @@ void SysTick_Handler (void) system_ticks++; } -uint32_t tusb_hal_millis(void) -{ - return board_tick2ms(system_ticks); -} - uint32_t board_millis(void) { return system_ticks; diff --git a/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c b/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c index d3883be54..fa0966831 100644 --- a/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c +++ b/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c @@ -103,11 +103,6 @@ void SysTick_Handler (void) system_ticks++; } -uint32_t tusb_hal_millis(void) -{ - return board_tick2ms(system_ticks); -} - uint32_t board_millis(void) { return system_ticks; diff --git a/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c b/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c index 20b82cd62..4f7909b12 100644 --- a/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c +++ b/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c @@ -116,11 +116,6 @@ void SysTick_Handler (void) system_ticks++; } -uint32_t tusb_hal_millis(void) -{ - return board_tick2ms(system_ticks); -} - uint32_t board_millis(void) { return system_ticks; diff --git a/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c b/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c index 0b7e7a1bd..420c90e60 100644 --- a/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c +++ b/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c @@ -154,11 +154,6 @@ void SysTick_Handler (void) system_ticks++; } -uint32_t tusb_hal_millis(void) -{ - return board_tick2ms(system_ticks); -} - uint32_t board_millis(void) { return system_ticks; diff --git a/hw/bsp/mcb1800/board_mcb1800.c b/hw/bsp/mcb1800/board_mcb1800.c index 7ace1a0ee..b81ecaad2 100644 --- a/hw/bsp/mcb1800/board_mcb1800.c +++ b/hw/bsp/mcb1800/board_mcb1800.c @@ -232,11 +232,6 @@ void SysTick_Handler (void) system_ticks++; } -uint32_t tusb_hal_millis(void) -{ - return board_tick2ms(system_ticks); -} - uint32_t board_millis(void) { return system_ticks; diff --git a/hw/bsp/metro_m0_express/board_metro_m0_express.c b/hw/bsp/metro_m0_express/board_metro_m0_express.c index 48b8a15ef..11bb16c3c 100644 --- a/hw/bsp/metro_m0_express/board_metro_m0_express.c +++ b/hw/bsp/metro_m0_express/board_metro_m0_express.c @@ -113,11 +113,6 @@ void SysTick_Handler (void) system_ticks++; } -uint32_t tusb_hal_millis(void) -{ - return board_tick2ms(system_ticks); -} - uint32_t board_millis(void) { return system_ticks; diff --git a/hw/bsp/metro_m4_express/board_metro_m4_express.c b/hw/bsp/metro_m4_express/board_metro_m4_express.c index ad86b54d7..6a134f807 100644 --- a/hw/bsp/metro_m4_express/board_metro_m4_express.c +++ b/hw/bsp/metro_m4_express/board_metro_m4_express.c @@ -102,11 +102,6 @@ void SysTick_Handler (void) system_ticks++; } -uint32_t tusb_hal_millis(void) -{ - return board_tick2ms(system_ticks); -} - uint32_t board_millis(void) { return system_ticks; diff --git a/hw/bsp/pca10056/board_pca10056.c b/hw/bsp/pca10056/board_pca10056.c index 70662d9dd..923721fd7 100644 --- a/hw/bsp/pca10056/board_pca10056.c +++ b/hw/bsp/pca10056/board_pca10056.c @@ -36,8 +36,6 @@ #include "nrf_soc.h" #endif -#include "tusb.h" - /*------------------------------------------------------------------*/ /* MACRO TYPEDEF CONSTANT ENUM *------------------------------------------------------------------*/ @@ -52,7 +50,7 @@ uint8_t _button_pins[] = { 11, 12, 24, 25 }; /*------------------------------------------------------------------*/ /* TUSB HAL MILLISECOND *------------------------------------------------------------------*/ -#if CFG_TUSB_OS == OPT_OS_NONE +#if CFG_TUSB_OS == OPT_OS_NONE volatile uint32_t system_ticks = 0; void SysTick_Handler (void) @@ -60,11 +58,6 @@ void SysTick_Handler (void) system_ticks++; } -uint32_t tusb_hal_millis(void) -{ - return board_tick2ms(system_ticks); -} - uint32_t board_millis(void) { return system_ticks; @@ -93,7 +86,7 @@ void board_init(void) // Button for(uint8_t i=0; istart = tusb_hal_millis(); } +#endif + #ifdef __cplusplus } #endif diff --git a/src/osal/osal.c b/src/osal/osal.c deleted file mode 100644 index b1ffa3942..000000000 --- a/src/osal/osal.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2018, hathach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#include "tusb_option.h" -#include "osal.h" - -//--------------------------------------------------------------------+ -// TICK API -//--------------------------------------------------------------------+ -#if CFG_TUSB_OS == OPT_OS_FREERTOS - -uint32_t tusb_hal_millis(void) -{ - return ( ( ((uint64_t) xTaskGetTickCount()) * 1000) / configTICK_RATE_HZ ); -} - -#elif CFG_TUSB_OS == OPT_OS_MYNEWT - -uint32_t tusb_hal_millis(void) -{ - return os_time_ticks_to_ms32( os_time_get() ); -} - -#endif - diff --git a/src/osal/osal.h b/src/osal/osal.h index 413189b4e..7ceb22125 100644 --- a/src/osal/osal.h +++ b/src/osal/osal.h @@ -52,8 +52,6 @@ typedef void (*osal_task_func_t)( void * ); #include "osal_none.h" #else /* RTOS Porting API - * - * uint32_t tusb_hal_millis(void) * * Task * void osal_task_delay(uint32_t msec) diff --git a/src/osal/osal_none.h b/src/osal/osal_none.h index 17a802ed8..6144f3e5c 100644 --- a/src/osal/osal_none.h +++ b/src/osal/osal_none.h @@ -27,8 +27,6 @@ #ifndef _TUSB_OSAL_NONE_H_ #define _TUSB_OSAL_NONE_H_ -#include "tusb_hal.h" - #ifdef __cplusplus extern "C" { #endif @@ -38,8 +36,11 @@ //--------------------------------------------------------------------+ static inline void osal_task_delay(uint32_t msec) { - uint32_t start = tusb_hal_millis(); - while ( ( tusb_hal_millis() - start ) < msec ) {} + (void) msec; + // TODO only used by Host stack, will implement using SOF + +// uint32_t start = tusb_hal_millis(); +// while ( ( tusb_hal_millis() - start ) < msec ) {} } //--------------------------------------------------------------------+ diff --git a/src/portable/nordic/nrf5x/hal_nrf5x.c b/src/portable/nordic/nrf5x/hal_nrf5x.c index 1d149eb8c..8477a56cd 100644 --- a/src/portable/nordic/nrf5x/hal_nrf5x.c +++ b/src/portable/nordic/nrf5x/hal_nrf5x.c @@ -40,8 +40,6 @@ #endif #include "nrfx_power.h" - -#include "tusb_hal.h" #include "device/dcd.h" /*------------------------------------------------------------------*/ diff --git a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c index ec3ac188b..df82f70b9 100644 --- a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c +++ b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c @@ -32,8 +32,6 @@ // INCLUDE //--------------------------------------------------------------------+ #include "common/tusb_common.h" -#include "tusb_hal.h" - #include "device/dcd.h" #include "dcd_lpc18_43.h" diff --git a/src/tusb.h b/src/tusb.h index c6d572436..122851b45 100644 --- a/src/tusb.h +++ b/src/tusb.h @@ -35,7 +35,6 @@ // INCLUDE //--------------------------------------------------------------------+ #include "common/tusb_common.h" -#include "tusb_hal.h" #include "osal/osal.h" #include "common/tusb_fifo.h" diff --git a/src/tusb_hal.h b/src/tusb_hal.h deleted file mode 100644 index 2dcafa77f..000000000 --- a/src/tusb_hal.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2018, hathach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#ifndef _TUSB_HAL_H_ -#define _TUSB_HAL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -//--------------------------------------------------------------------+ -// INCLUDES -//--------------------------------------------------------------------+ -#include "common/tusb_common.h" - -//--------------------------------------------------------------------+ -// HAL API -//--------------------------------------------------------------------+ - -// Only required to implement if using No RTOS (osal_none) -// TODO could be remove -uint32_t tusb_hal_millis(void); - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_HAL_H_ */ - -- cgit v1.3.1 From 472237665479961a714b6775e7fc9289e5e6c9ee Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 27 Mar 2019 01:01:48 +0700 Subject: remove dcd_get_frame_number() --- src/device/dcd.h | 3 --- src/portable/microchip/samd21/dcd_samd21.c | 6 ------ src/portable/microchip/samd51/dcd_samd51.c | 6 ------ src/portable/nordic/nrf5x/dcd_nrf5x.c | 6 ------ src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c | 7 ------- src/portable/nxp/lpc17_40/dcd_lpc17_40.c | 6 ------ src/portable/nxp/lpc18_43/dcd_lpc18_43.c | 5 ----- src/portable/st/stm32f3/dcd_stm32f3.c | 4 ---- src/portable/st/stm32f4/dcd_stm32f4.c | 9 --------- 9 files changed, 52 deletions(-) (limited to 'src') diff --git a/src/device/dcd.h b/src/device/dcd.h index e73f24277..588839ccb 100644 --- a/src/device/dcd.h +++ b/src/device/dcd.h @@ -94,9 +94,6 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr); // Receive Set Config request void dcd_set_config (uint8_t rhport, uint8_t config_num); -// Get current frame number -uint32_t dcd_get_frame_number(uint8_t rhport); - /*------------------------------------------------------------------*/ /* Endpoint API * - open : Configure endpoint's registers diff --git a/src/portable/microchip/samd21/dcd_samd21.c b/src/portable/microchip/samd21/dcd_samd21.c index 706a62ed9..e7e5f01b8 100644 --- a/src/portable/microchip/samd21/dcd_samd21.c +++ b/src/portable/microchip/samd21/dcd_samd21.c @@ -114,12 +114,6 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num) // Nothing to do } -uint32_t dcd_get_frame_number(uint8_t rhport) -{ - (void) rhport; - return USB->DEVICE.FNUM.bit.FNUM; -} - /*------------------------------------------------------------------*/ /* DCD Endpoint port *------------------------------------------------------------------*/ diff --git a/src/portable/microchip/samd51/dcd_samd51.c b/src/portable/microchip/samd51/dcd_samd51.c index 9773ad71e..c4c4b3bec 100644 --- a/src/portable/microchip/samd51/dcd_samd51.c +++ b/src/portable/microchip/samd51/dcd_samd51.c @@ -119,12 +119,6 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num) // Nothing to do } -uint32_t dcd_get_frame_number(uint8_t rhport) -{ - (void) rhport; - return USB->DEVICE.FNUM.bit.FNUM; -} - /*------------------------------------------------------------------*/ /* DCD Endpoint port *------------------------------------------------------------------*/ diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c index a65087173..1afe4faca 100644 --- a/src/portable/nordic/nrf5x/dcd_nrf5x.c +++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c @@ -209,12 +209,6 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num) // Nothing to do } -uint32_t dcd_get_frame_number(uint8_t rhport) -{ - (void) rhport; - return NRF_USBD->FRAMECNTR; -} - //--------------------------------------------------------------------+ // Endpoint API //--------------------------------------------------------------------+ diff --git a/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c b/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c index c1a6f4a8b..79e681035 100644 --- a/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c +++ b/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c @@ -153,13 +153,6 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr) LPC_USB->DEVCMDSTAT |= dev_addr; } -uint32_t dcd_get_frame_number(uint8_t rhport) -{ - (void) rhport; - - return LPC_USB->INFO & (TU_BIT(11) - 1); -} - bool dcd_init(uint8_t rhport) { (void) rhport; diff --git a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c index ba6a66d84..8da1cebff 100644 --- a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c +++ b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c @@ -217,12 +217,6 @@ void dcd_set_config(uint8_t rhport, uint8_t config_num) sie_write(SIE_CMDCODE_CONFIGURE_DEVICE, 1, 1); } -uint32_t dcd_get_frame_number(uint8_t rhport) -{ - (void) rhport; - return (uint32_t) sie_read(SIE_CMDCODE_READ_FRAME_NUMBER); -} - //--------------------------------------------------------------------+ // CONTROL HELPER //--------------------------------------------------------------------+ diff --git a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c index df82f70b9..35465f91f 100644 --- a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c +++ b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c @@ -163,11 +163,6 @@ void dcd_set_config(uint8_t rhport, uint8_t config_num) // nothing to do } -uint32_t dcd_get_frame_number(uint8_t rhport) -{ - return LPC_USB[rhport]->FRINDEX_D >> 3; -} - //--------------------------------------------------------------------+ // HELPER //--------------------------------------------------------------------+ diff --git a/src/portable/st/stm32f3/dcd_stm32f3.c b/src/portable/st/stm32f3/dcd_stm32f3.c index 20dd92fc5..3b3dc418c 100644 --- a/src/portable/st/stm32f3/dcd_stm32f3.c +++ b/src/portable/st/stm32f3/dcd_stm32f3.c @@ -57,10 +57,6 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr) void dcd_set_config (uint8_t rhport, uint8_t config_num) {} -// Get current frame number -uint32_t dcd_get_frame_number(uint8_t rhport) -{ return 0; } - bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc) { return false; diff --git a/src/portable/st/stm32f4/dcd_stm32f4.c b/src/portable/st/stm32f4/dcd_stm32f4.c index 472a63f32..850b7b1b3 100644 --- a/src/portable/st/stm32f4/dcd_stm32f4.c +++ b/src/portable/st/stm32f4/dcd_stm32f4.c @@ -196,15 +196,6 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num) // Nothing to do } -uint32_t dcd_get_frame_number(uint8_t rhport) -{ - (void) rhport; - - USB_OTG_DeviceTypeDef * dev = DEVICE_BASE; - - return (dev->DSTS & USB_OTG_DSTS_FNSOF_Msk) >> USB_OTG_DSTS_FNSOF_Pos; -} - /*------------------------------------------------------------------*/ /* DCD Endpoint port *------------------------------------------------------------------*/ -- cgit v1.3.1 From 1e9848d917550b0af2115bc629d5e7e4743f23c7 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 27 Mar 2019 16:09:49 +0700 Subject: replace dcd_edpt_(clear)stall by usbd_edpt_(clear)stall - remove dcd_edpt_stalled() from dcd porting --- docs/porting.md | 4 +-- src/class/msc/msc_device.c | 8 ++--- src/device/dcd.h | 2 -- src/device/usbd.c | 41 +++++++++++++++++++++++--- src/device/usbd.h | 1 - src/device/usbd_pvt.h | 5 ++++ src/portable/microchip/samd21/dcd_samd21.c | 14 --------- src/portable/microchip/samd51/dcd_samd51.c | 14 --------- src/portable/nordic/nrf5x/dcd_nrf5x.c | 11 ------- src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c | 8 ----- src/portable/nxp/lpc17_40/dcd_lpc17_40.c | 8 ----- src/portable/nxp/lpc18_43/dcd_lpc18_43.c | 8 ----- src/portable/st/stm32f3/dcd_stm32f3.c | 3 -- src/portable/st/stm32f4/dcd_stm32f4.c | 24 --------------- tools/top.mk | 4 +-- 15 files changed, 50 insertions(+), 105 deletions(-) (limited to 'src') diff --git a/docs/porting.md b/docs/porting.md index 70c9f25aa..5f1df0d7a 100644 --- a/docs/porting.md +++ b/docs/porting.md @@ -147,9 +147,9 @@ The arguments are: * the result of the transfer. Failure isn't handled yet. * `true` to note the call is from an interrupt handler. -##### dcd_edpt_stall / dcd_edpt_stalled / dcd_edpt_clear_stall +##### dcd_edpt_stall / dcd_edpt_clear_stall -Stalling is one way an endpoint can indicate failure such as when an unsupported command is transmitted. The trio of `dcd_edpt_stall`, `dcd_edpt_stalled`, `dcd_edpt_clear_stall` help manage the stall state of all endpoints. +Stalling is one way an endpoint can indicate failure such as when an unsupported command is transmitted. The pair of `dcd_edpt_stall`, `dcd_edpt_clear_stall` help manage the stall state of all endpoints. ## Woohoo! diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c index 728f4d363..4585d520a 100644 --- a/src/class/msc/msc_device.c +++ b/src/class/msc/msc_device.c @@ -412,7 +412,7 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t p_msc->stage = MSC_STAGE_STATUS; tud_msc_set_sense(p_cbw->lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00); // Sense = Invalid Command Operation - dcd_edpt_stall(rhport, p_msc->ep_in); + usbd_edpt_stall(rhport, p_msc->ep_in); } } } @@ -512,7 +512,7 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t if ( p_msc->stage == MSC_STAGE_STATUS ) { // Either endpoints is stalled, need to wait until it is cleared by host - if ( dcd_edpt_stalled(rhport, p_msc->ep_in) || dcd_edpt_stalled(rhport, p_msc->ep_out) ) + if ( usbd_edpt_stalled(rhport, p_msc->ep_in) || usbd_edpt_stalled(rhport, p_msc->ep_out) ) { // simulate an transfer complete with adjusted parameters --> this driver callback will fired again dcd_event_xfer_complete(rhport, p_msc->ep_out, 0, XFER_RESULT_SUCCESS, false); @@ -573,7 +573,7 @@ static void proc_read10_cmd(uint8_t rhport, mscd_interface_t* p_msc) p_csw->status = MSC_CSW_STATUS_FAILED; tud_msc_set_sense(p_cbw->lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00); // Sense = Invalid Command Operation - dcd_edpt_stall(rhport, p_msc->ep_in); + usbd_edpt_stall(rhport, p_msc->ep_in); } else if ( nbytes == 0 ) { @@ -599,7 +599,7 @@ static void proc_write10_cmd(uint8_t rhport, mscd_interface_t* p_msc) p_csw->status = MSC_CSW_STATUS_FAILED; tud_msc_set_sense(p_cbw->lun, SCSI_SENSE_DATA_PROTECT, 0x27, 0x00); // Sense = Write protected - dcd_edpt_stall(rhport, p_msc->ep_out); + usbd_edpt_stall(rhport, p_msc->ep_out); return; } diff --git a/src/device/dcd.h b/src/device/dcd.h index 588839ccb..186c4af0c 100644 --- a/src/device/dcd.h +++ b/src/device/dcd.h @@ -102,7 +102,6 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num); * - busy : Check if endpoint transferring is complete (TODO remove) * - stall : stall endpoint * - clear_stall : clear stall - * - stalled : check if stalled ( TODO remove ) *------------------------------------------------------------------*/ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc); bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes); @@ -110,7 +109,6 @@ bool dcd_edpt_busy (uint8_t rhport, uint8_t ep_addr); void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr); void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr); -bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr); /*------------------------------------------------------------------*/ /* Event Function diff --git a/src/device/usbd.c b/src/device/usbd.c index 877837fae..b79ccae2b 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -44,9 +44,11 @@ typedef struct { uint8_t config_num; - uint8_t itf2drv[16]; // map interface number to driver (0xff is invalid) - uint8_t ep2drv[8][2]; // map endpoint to driver ( 0xff is invalid ) + uint8_t itf2drv[16]; // map interface number to driver (0xff is invalid) + uint8_t ep2drv[8][2]; // map endpoint to driver ( 0xff is invalid ) + uint8_t ep_busy_mask[2]; // bit mask for busy endpoint + uint8_t ep_stall_mask[2]; // bit mask for stalled endpoint }usbd_device_t; static usbd_device_t _usbd_dev = { 0 }; @@ -379,7 +381,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const { case TUSB_REQ_GET_STATUS: { - uint16_t status = dcd_edpt_stalled(rhport, tu_u16_low(p_request->wIndex)) ? 0x0001 : 0x0000; + uint16_t status = usbd_edpt_stalled(rhport, tu_u16_low(p_request->wIndex)) ? 0x0001 : 0x0000; usbd_control_xfer(rhport, p_request, &status, 2); } break; @@ -392,7 +394,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const case TUSB_REQ_SET_FEATURE: // only endpoint feature is halted/stalled - dcd_edpt_stall(rhport, tu_u16_low(p_request->wIndex)); + usbd_edpt_stall(rhport, tu_u16_low(p_request->wIndex)); usbd_control_status(rhport, p_request); break; @@ -650,4 +652,35 @@ void usbd_defer_func(osal_task_func_t func, void* param, bool in_isr) dcd_event_handler(&event, in_isr); } +//--------------------------------------------------------------------+ +// USBD Endpoint API +//--------------------------------------------------------------------+ +void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr) +{ + uint8_t const epnum = tu_edpt_number(ep_addr); + uint8_t const dir = tu_edpt_dir(ep_addr); + + dcd_edpt_stall(rhport, ep_addr); + _usbd_dev.ep_stall_mask[dir] = tu_bit_set(_usbd_dev.ep_stall_mask[dir], epnum); +} + +void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) +{ + uint8_t const epnum = tu_edpt_number(ep_addr); + uint8_t const dir = tu_edpt_dir(ep_addr); + + dcd_edpt_clear_stall(rhport, ep_addr); + _usbd_dev.ep_stall_mask[dir] = tu_bit_clear(_usbd_dev.ep_stall_mask[dir], epnum); +} + +bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr) +{ + (void) rhport; + + uint8_t const epnum = tu_edpt_number(ep_addr); + uint8_t const dir = tu_edpt_dir(ep_addr); + + return tu_bit_test(_usbd_dev.ep_stall_mask[dir], epnum); +} + #endif diff --git a/src/device/usbd.h b/src/device/usbd.h index 11ef63887..e8f3f2bc8 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -38,7 +38,6 @@ // INCLUDE //--------------------------------------------------------------------+ #include -#include "osal/osal.h" #include "device/dcd.h" //--------------------------------------------------------------------+ diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h index d2562d298..dee194f0f 100644 --- a/src/device/usbd_pvt.h +++ b/src/device/usbd_pvt.h @@ -52,6 +52,11 @@ bool usbd_control_status(uint8_t rhport, tusb_control_request_t const * request) // Stall control endpoint (both IN and OUT) until new setup packet arrived void usbd_control_stall(uint8_t rhport); + +void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr); +void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr); +bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr); + /*------------------------------------------------------------------*/ /* Helper *------------------------------------------------------------------*/ diff --git a/src/portable/microchip/samd21/dcd_samd21.c b/src/portable/microchip/samd21/dcd_samd21.c index e7e5f01b8..723bd6c3a 100644 --- a/src/portable/microchip/samd21/dcd_samd21.c +++ b/src/portable/microchip/samd21/dcd_samd21.c @@ -189,20 +189,6 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t return true; } -bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) -{ - (void) rhport; - - // control is never got halted - if ( ep_addr == 0 ) { - return false; - } - - uint8_t const epnum = tu_edpt_number(ep_addr); - UsbDeviceEndpoint* ep = &USB->DEVICE.DeviceEndpoint[epnum]; - return (tu_edpt_dir(ep_addr) == TUSB_DIR_IN ) ? ep->EPINTFLAG.bit.STALL1 : ep->EPINTFLAG.bit.STALL0; -} - void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) { (void) rhport; diff --git a/src/portable/microchip/samd51/dcd_samd51.c b/src/portable/microchip/samd51/dcd_samd51.c index c4c4b3bec..9869956c7 100644 --- a/src/portable/microchip/samd51/dcd_samd51.c +++ b/src/portable/microchip/samd51/dcd_samd51.c @@ -193,20 +193,6 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t return true; } -bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) -{ - (void) rhport; - - // control is never got halted - if ( ep_addr == 0 ) { - return false; - } - - uint8_t const epnum = tu_edpt_number(ep_addr); - UsbDeviceEndpoint* ep = &USB->DEVICE.DeviceEndpoint[epnum]; - return (tu_edpt_dir(ep_addr) == TUSB_DIR_IN ) ? ep->EPINTFLAG.bit.STALL1 : ep->EPINTFLAG.bit.STALL0; -} - void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) { (void) rhport; diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c index 1afe4faca..3c2b6d45b 100644 --- a/src/portable/nordic/nrf5x/dcd_nrf5x.c +++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c @@ -279,17 +279,6 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t return true; } -bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) -{ - (void) rhport; - - // control is never got halted - if ( ep_addr == 0 ) return false; - - uint8_t const epnum = tu_edpt_number(ep_addr); - return (tu_edpt_dir(ep_addr) == TUSB_DIR_IN ) ? NRF_USBD->HALTED.EPIN[epnum] : NRF_USBD->HALTED.EPOUT[epnum]; -} - void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) { (void) rhport; diff --git a/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c b/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c index 79e681035..65b345957 100644 --- a/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c +++ b/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c @@ -182,14 +182,6 @@ void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr) _dcd.ep[ep_id][0].stall = 1; } -bool dcd_edpt_stalled(uint8_t rhport, uint8_t ep_addr) -{ - (void) rhport; - - uint8_t const ep_id = ep_addr2id(ep_addr); - return _dcd.ep[ep_id][0].stall; -} - void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) { (void) rhport; diff --git a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c index 8da1cebff..f18a91b1c 100644 --- a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c +++ b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c @@ -344,14 +344,6 @@ void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) sie_write(SIE_CMDCODE_ENDPOINT_SET_STATUS+ep_id, 1, 0); } -bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) -{ - (void) rhport; - - uint8_t const ep_state = sie_read(SIE_CMDCODE_ENDPOINT_SELECT + ep_addr2idx(ep_addr)); - return (ep_state & SIE_SELECT_ENDPOINT_STALL_MASK) ? true : false; -} - static bool control_xact(uint8_t rhport, uint8_t dir, uint8_t * buffer, uint8_t len) { (void) rhport; diff --git a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c index 35465f91f..a92a1c7b1 100644 --- a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c +++ b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c @@ -201,14 +201,6 @@ void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr) LPC_USB[rhport]->ENDPTCTRL[epnum] |= ENDPTCTRL_MASK_STALL << (dir ? 16 : 0); } -bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) -{ - uint8_t const epnum = tu_edpt_number(ep_addr); - uint8_t const dir = tu_edpt_dir(ep_addr); - - return LPC_USB[rhport]->ENDPTCTRL[epnum] & (ENDPTCTRL_MASK_STALL << (dir ? 16 : 0)); -} - void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) { uint8_t const epnum = tu_edpt_number(ep_addr); diff --git a/src/portable/st/stm32f3/dcd_stm32f3.c b/src/portable/st/stm32f3/dcd_stm32f3.c index 3b3dc418c..138c454a7 100644 --- a/src/portable/st/stm32f3/dcd_stm32f3.c +++ b/src/portable/st/stm32f3/dcd_stm32f3.c @@ -70,9 +70,6 @@ void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) {} void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr) {} -bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) -{ - return false;} #endif diff --git a/src/portable/st/stm32f4/dcd_stm32f4.c b/src/portable/st/stm32f4/dcd_stm32f4.c index 850b7b1b3..db72f92d3 100644 --- a/src/portable/st/stm32f4/dcd_stm32f4.c +++ b/src/portable/st/stm32f4/dcd_stm32f4.c @@ -299,30 +299,6 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t return true; } -bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) -{ - (void) rhport; - USB_OTG_OUTEndpointTypeDef * out_ep = OUT_EP_BASE; - USB_OTG_INEndpointTypeDef * in_ep = IN_EP_BASE; - - // control is never got halted - if(ep_addr == 0) { - return false; - } - - uint8_t const epnum = tu_edpt_number(ep_addr); - uint8_t const dir = tu_edpt_dir(ep_addr); - bool stalled = false; - - if(dir == TUSB_DIR_IN) { - stalled = (in_ep[epnum].DIEPCTL & USB_OTG_DIEPCTL_STALL_Msk); - } else { - stalled = (out_ep[epnum].DOEPCTL & USB_OTG_DOEPCTL_STALL_Msk); - } - - return stalled; -} - // TODO: The logic for STALLing and disabling an endpoint is very similar // (send STALL versus NAK handshakes back). Refactor into resuable function. void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) diff --git a/tools/top.mk b/tools/top.mk index 991f9b16a..be51b3f4f 100644 --- a/tools/top.mk +++ b/tools/top.mk @@ -11,7 +11,7 @@ TOP := $(patsubst %/tools/top.mk,%,$(THIS_MAKEFILE)) TOP := $(shell realpath $(TOP)) -$(info Top directory is $(TOP)) +#$(info Top directory is $(TOP)) CURRENT_PATH := $(shell realpath --relative-to=$(TOP) `pwd`) -$(info Path from top is $(CURRENT_PATH)) +#$(info Path from top is $(CURRENT_PATH)) -- cgit v1.3.1 From f26fbaf404c772c0ce4e48d36d94c2743f3a8aee Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 27 Mar 2019 16:26:52 +0700 Subject: clean up remove usbd_control_stall() --- src/device/usbd.c | 7 ++++--- src/device/usbd.h | 4 ++-- src/device/usbd_control.c | 12 +++--------- src/device/usbd_pvt.h | 4 ---- 4 files changed, 9 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/device/usbd.c b/src/device/usbd.c index b79ccae2b..17914fb6c 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -104,7 +104,6 @@ static usbd_class_driver_t const usbd_class_drivers[] = }, #endif - #if CFG_TUD_HID { .class_code = TUSB_CLASS_HID, @@ -243,10 +242,12 @@ void tud_task (void) switch ( event.event_id ) { case DCD_EVENT_SETUP_RECEIVED: - // Process control request, if failed control endpoint is stalled + // Process control request if ( !process_control_request(event.rhport, &event.setup_received) ) { - usbd_control_stall(event.rhport); + // Failed -> stall both control endpoint IN and OUT + dcd_edpt_stall(event.rhport, 0); + dcd_edpt_stall(event.rhport, 0 | TUSB_DIR_IN_MASK); } break; diff --git a/src/device/usbd.h b/src/device/usbd.h index e8f3f2bc8..614b4f311 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -74,10 +74,10 @@ void tud_task (void); // APPLICATION CALLBACK (WEAK is optional) //--------------------------------------------------------------------+ -/** Callback invoked when device is mounted (configured) */ +// Callback invoked when device is mounted (configured) ATTR_WEAK void tud_mount_cb(void); -/** Callback invoked when device is unmounted (bus reset/unplugged) */ +// Callback invoked when device is unmounted (bus reset/unplugged) ATTR_WEAK void tud_umount_cb(void); //void tud_device_suspended_cb(void); diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c index 094d2fb44..d907aca3b 100644 --- a/src/device/usbd_control.c +++ b/src/device/usbd_control.c @@ -60,13 +60,6 @@ void usbd_control_reset (uint8_t rhport) tu_varclr(&_control_state); } -void usbd_control_stall(uint8_t rhport) -{ - // when stalling control endpoint both IN and OUt will be stalled - dcd_edpt_stall(rhport, EDPT_CTRL_OUT); - dcd_edpt_stall(rhport, EDPT_CTRL_IN); -} - bool usbd_control_status(uint8_t rhport, tusb_control_request_t const * request) { // status direction is reversed to one in the setup packet @@ -147,8 +140,9 @@ bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result TU_ASSERT( usbd_control_status(rhport, &_control_state.request) ); }else { - // stall due to callback - usbd_control_stall(rhport); + // Stall both IN and OUT control endpoint + dcd_edpt_stall(rhport, EDPT_CTRL_OUT); + dcd_edpt_stall(rhport, EDPT_CTRL_IN); } } else diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h index dee194f0f..dab67581f 100644 --- a/src/device/usbd_pvt.h +++ b/src/device/usbd_pvt.h @@ -49,10 +49,6 @@ bool usbd_control_xfer(uint8_t rhport, tusb_control_request_t const * request, v // Send STATUS (zero length) packet bool usbd_control_status(uint8_t rhport, tusb_control_request_t const * request); -// Stall control endpoint (both IN and OUT) until new setup packet arrived -void usbd_control_stall(uint8_t rhport); - - void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr); void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr); bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr); -- cgit v1.3.1 From da452d4ba6127b2b3b83832ba142bece911e2490 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 27 Mar 2019 17:48:42 +0700 Subject: cleanup, remove the use of _TINY_USB_SOURCE_FILE_ --- src/class/cdc/cdc_device.c | 2 -- src/class/cdc/cdc_device.h | 7 ++----- src/class/cdc/cdc_host.c | 2 -- src/class/cdc/cdc_host.h | 6 +----- src/class/cdc/cdc_rndis_host.c | 2 -- src/class/cdc/cdc_rndis_host.h | 6 +----- src/class/custom/custom_device.c | 2 -- src/class/custom/custom_device.h | 6 +----- src/class/custom/custom_host.c | 2 -- src/class/custom/custom_host.h | 7 +++---- src/class/hid/hid_device.c | 1 - src/class/hid/hid_device.h | 4 ---- src/class/hid/hid_host.c | 4 ---- src/class/hid/hid_host.h | 6 +----- src/class/midi/midi_device.c | 1 - src/class/midi/midi_device.h | 10 +++------- src/class/msc/msc_device.c | 5 ----- src/class/msc/msc_device.h | 6 +----- src/class/msc/msc_host.c | 2 -- src/class/msc/msc_host.h | 6 +----- src/device/usbd.c | 2 -- src/device/usbd_control.c | 2 -- src/host/hub.c | 2 -- src/host/hub.h | 6 +----- src/host/usbh.c | 2 -- src/host/usbh.h | 3 --- src/tusb.c | 1 - 27 files changed, 15 insertions(+), 90 deletions(-) (limited to 'src') diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c index 48e94a6e1..2ac8d471c 100644 --- a/src/class/cdc/cdc_device.c +++ b/src/class/cdc/cdc_device.c @@ -28,8 +28,6 @@ #if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_CDC) -#define _TINY_USB_SOURCE_FILE_ - #include "cdc_device.h" #include "device/usbd_pvt.h" diff --git a/src/class/cdc/cdc_device.h b/src/class/cdc/cdc_device.h index 3375fc98d..468edef45 100644 --- a/src/class/cdc/cdc_device.h +++ b/src/class/cdc/cdc_device.h @@ -96,10 +96,9 @@ ATTR_WEAK void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts); ATTR_WEAK void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding); //--------------------------------------------------------------------+ -// USBD-CLASS DRIVER API -//--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ +// INTERNAL USBD-CLASS DRIVER API +//--------------------------------------------------------------------+ void cdcd_init (void); bool cdcd_open (uint8_t rhport, tusb_desc_interface_t const * p_interface_desc, uint16_t *p_length); bool cdcd_control_request (uint8_t rhport, tusb_control_request_t const * p_request); @@ -107,8 +106,6 @@ bool cdcd_control_request_complete (uint8_t rhport, tusb_control_request_t const bool cdcd_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes); void cdcd_reset (uint8_t rhport); -#endif - #ifdef __cplusplus } #endif diff --git a/src/class/cdc/cdc_host.c b/src/class/cdc/cdc_host.c index 4932a61ac..75c805152 100644 --- a/src/class/cdc/cdc_host.c +++ b/src/class/cdc/cdc_host.c @@ -28,8 +28,6 @@ #if (TUSB_OPT_HOST_ENABLED && CFG_TUH_CDC) -#define _TINY_USB_SOURCE_FILE_ - #include "common/tusb_common.h" #include "cdc_host.h" diff --git a/src/class/cdc/cdc_host.h b/src/class/cdc/cdc_host.h index 716203b96..7a302eb0f 100644 --- a/src/class/cdc/cdc_host.h +++ b/src/class/cdc/cdc_host.h @@ -109,17 +109,13 @@ void tuh_cdc_xfer_isr(uint8_t dev_addr, xfer_result_t event, cdc_pipeid_t pipe_i /// @} //--------------------------------------------------------------------+ -// USBH-CLASS API +// Internal Class Driver API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - void cdch_init(void); bool cdch_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *itf_desc, uint16_t *p_length); void cdch_isr(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); void cdch_close(uint8_t dev_addr); -#endif - #ifdef __cplusplus } #endif diff --git a/src/class/cdc/cdc_rndis_host.c b/src/class/cdc/cdc_rndis_host.c index d377ddca3..587e9ddc8 100644 --- a/src/class/cdc/cdc_rndis_host.c +++ b/src/class/cdc/cdc_rndis_host.c @@ -28,8 +28,6 @@ #if (TUSB_OPT_HOST_ENABLED && CFG_TUH_CDC && CFG_TUH_CDC_RNDIS) -#define _TINY_USB_SOURCE_FILE_ - //--------------------------------------------------------------------+ // INCLUDE //--------------------------------------------------------------------+ diff --git a/src/class/cdc/cdc_rndis_host.h b/src/class/cdc/cdc_rndis_host.h index 377ae64ba..24becee07 100644 --- a/src/class/cdc/cdc_rndis_host.h +++ b/src/class/cdc/cdc_rndis_host.h @@ -40,10 +40,8 @@ #endif //--------------------------------------------------------------------+ -// RNDIS-CDC Driver API +// INTERNAL RNDIS-CDC Driver API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - typedef struct { OSAL_SEM_DEF(semaphore_notification); osal_semaphore_handle_t sem_notification_hdl; // used to wait on notification pipe @@ -56,8 +54,6 @@ tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc); void rndish_xfer_isr(cdch_data_t *p_cdc, pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes); void rndish_close(uint8_t dev_addr); -#endif - #ifdef __cplusplus } #endif diff --git a/src/class/custom/custom_device.c b/src/class/custom/custom_device.c index bc2f98c1b..04921259f 100644 --- a/src/class/custom/custom_device.c +++ b/src/class/custom/custom_device.c @@ -28,8 +28,6 @@ #if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_CUSTOM_CLASS) -#define _TINY_USB_SOURCE_FILE_ - #include "common/tusb_common.h" #include "custom_device.h" #include "device/usbd_pvt.h" diff --git a/src/class/custom/custom_device.h b/src/class/custom/custom_device.h index a1dc09430..704ecb23a 100644 --- a/src/class/custom/custom_device.h +++ b/src/class/custom/custom_device.h @@ -46,17 +46,13 @@ //--------------------------------------------------------------------+ //--------------------------------------------------------------------+ -// USBD-CLASS DRIVER API +// Internal Class Driver API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - void cusd_init(void); bool cusd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length); bool cusd_control_request_st(uint8_t rhport, tusb_control_request_t const * p_request); bool cusd_control_request_complete (uint8_t rhport, tusb_control_request_t const * p_request); bool cusd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); void cusd_reset(uint8_t rhport); -#endif - #endif /* _TUSB_CUSTOM_DEVICE_H_ */ diff --git a/src/class/custom/custom_host.c b/src/class/custom/custom_host.c index 3ac12a688..488e26b20 100644 --- a/src/class/custom/custom_host.c +++ b/src/class/custom/custom_host.c @@ -28,8 +28,6 @@ #if (TUSB_OPT_HOST_ENABLED && CFG_TUSB_HOST_CUSTOM_CLASS) -#define _TINY_USB_SOURCE_FILE_ - //--------------------------------------------------------------------+ // INCLUDE //--------------------------------------------------------------------+ diff --git a/src/class/custom/custom_host.h b/src/class/custom/custom_host.h index 2ba288e1f..cf612a40b 100644 --- a/src/class/custom/custom_host.h +++ b/src/class/custom/custom_host.h @@ -57,15 +57,14 @@ static inline bool tusbh_custom_is_mounted(uint8_t dev_addr, uint16_t vendor_id, tusb_error_t tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void * p_buffer, uint16_t length); tusb_error_t tusbh_custom_write(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void const * p_data, uint16_t length); -#ifdef _TINY_USB_SOURCE_FILE_ - +//--------------------------------------------------------------------+ +// Internal Class Driver API +//--------------------------------------------------------------------+ void cush_init(void); tusb_error_t cush_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length); void cush_isr(pipe_handle_t pipe_hdl, xfer_result_t event); void cush_close(uint8_t dev_addr); -#endif - #ifdef __cplusplus } #endif diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index fd7602251..3a20a9cc8 100644 --- a/src/class/hid/hid_device.c +++ b/src/class/hid/hid_device.c @@ -28,7 +28,6 @@ #if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_HID) -#define _TINY_USB_SOURCE_FILE_ //--------------------------------------------------------------------+ // INCLUDE //--------------------------------------------------------------------+ diff --git a/src/class/hid/hid_device.h b/src/class/hid/hid_device.h index e0d8907de..096daad18 100644 --- a/src/class/hid/hid_device.h +++ b/src/class/hid/hid_device.h @@ -361,8 +361,6 @@ ATTR_WEAK void tud_hid_mouse_set_report_cb(uint8_t report_id, hid_report_type_t //--------------------------------------------------------------------+ // INTERNAL API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - void hidd_init(void); bool hidd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length); bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * p_request); @@ -370,8 +368,6 @@ bool hidd_control_request_complete (uint8_t rhport, tusb_control_request_t const bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); void hidd_reset(uint8_t rhport); -#endif - #ifdef __cplusplus } #endif diff --git a/src/class/hid/hid_host.c b/src/class/hid/hid_host.c index a52cf64b3..5aabbc01f 100644 --- a/src/class/hid/hid_host.c +++ b/src/class/hid/hid_host.c @@ -28,10 +28,6 @@ #if (TUSB_OPT_HOST_ENABLED && HOST_CLASS_HID) -#define _TINY_USB_SOURCE_FILE_ -//--------------------------------------------------------------------+ -// INCLUDE -//--------------------------------------------------------------------+ #include "common/tusb_common.h" #include "hid_host.h" diff --git a/src/class/hid/hid_host.h b/src/class/hid/hid_host.h index 0e5e48c64..8fa974c92 100644 --- a/src/class/hid/hid_host.h +++ b/src/class/hid/hid_host.h @@ -193,10 +193,8 @@ void tuh_hid_generic_isr(uint8_t dev_addr, xfer_result_t event); /** @} */ // ClassDriver_HID_Generic //--------------------------------------------------------------------+ -// USBH-CLASS DRIVER API +// Internal Class Driver API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - typedef struct { pipe_handle_t pipe_hdl; uint16_t report_size; @@ -208,8 +206,6 @@ bool hidh_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interfac void hidh_isr(pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes); void hidh_close(uint8_t dev_addr); -#endif - #ifdef __cplusplus } #endif diff --git a/src/class/midi/midi_device.c b/src/class/midi/midi_device.c index 53c7575f4..5ba111a22 100644 --- a/src/class/midi/midi_device.c +++ b/src/class/midi/midi_device.c @@ -28,7 +28,6 @@ #if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_MIDI) -#define _TINY_USB_SOURCE_FILE_ //--------------------------------------------------------------------+ // INCLUDE //--------------------------------------------------------------------+ diff --git a/src/class/midi/midi_device.h b/src/class/midi/midi_device.h index 7cbad6e22..a43514044 100644 --- a/src/class/midi/midi_device.h +++ b/src/class/midi/midi_device.h @@ -85,18 +85,14 @@ static inline bool tud_midi_write_flush (void) ATTR_WEAK void tud_midi_rx_cb(uint8_t itf); //--------------------------------------------------------------------+ -// USBD-CLASS DRIVER API +// Internal Class Driver API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - -void midid_init (void); +void midid_init (void); bool midid_open (uint8_t rhport, tusb_desc_interface_t const * p_interface_desc, uint16_t *p_length); bool midid_control_request (uint8_t rhport, tusb_control_request_t const * p_request); bool midid_control_request_complete (uint8_t rhport, tusb_control_request_t const * p_request); bool midid_xfer_cb (uint8_t rhport, uint8_t edpt_addr, xfer_result_t result, uint32_t xferred_bytes); -void midid_reset (uint8_t rhport); - -#endif +void midid_reset (uint8_t rhport); #ifdef __cplusplus } diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c index 4585d520a..04a3178a3 100644 --- a/src/class/msc/msc_device.c +++ b/src/class/msc/msc_device.c @@ -28,11 +28,6 @@ #if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_MSC) -//--------------------------------------------------------------------+ -// INCLUDE -//--------------------------------------------------------------------+ -#define _TINY_USB_SOURCE_FILE_ - #include "common/tusb_common.h" #include "msc_device.h" #include "device/usbd_pvt.h" diff --git a/src/class/msc/msc_device.h b/src/class/msc/msc_device.h index c97f6d111..e030951be 100644 --- a/src/class/msc/msc_device.h +++ b/src/class/msc/msc_device.h @@ -154,10 +154,8 @@ ATTR_WEAK bool tud_msc_is_writable_cb(uint8_t lun); /** @} */ //--------------------------------------------------------------------+ -// USBD-CLASS DRIVER API +// Internal Class Driver API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - void mscd_init(void); bool mscd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length); bool mscd_control_request(uint8_t rhport, tusb_control_request_t const * p_request); @@ -165,8 +163,6 @@ bool mscd_control_request_complete (uint8_t rhport, tusb_control_request_t const bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); void mscd_reset(uint8_t rhport); -#endif - #ifdef __cplusplus } #endif diff --git a/src/class/msc/msc_host.c b/src/class/msc/msc_host.c index 4e438a787..bb12c52d7 100644 --- a/src/class/msc/msc_host.c +++ b/src/class/msc/msc_host.c @@ -28,8 +28,6 @@ #if TUSB_OPT_HOST_ENABLED & CFG_TUH_MSC -#define _TINY_USB_SOURCE_FILE_ - //--------------------------------------------------------------------+ // INCLUDE //--------------------------------------------------------------------+ diff --git a/src/class/msc/msc_host.h b/src/class/msc/msc_host.h index dea090a94..1edce82c5 100644 --- a/src/class/msc/msc_host.h +++ b/src/class/msc/msc_host.h @@ -171,10 +171,8 @@ void tuh_msc_isr(uint8_t dev_addr, xfer_result_t event, uint32_t xferred_bytes); //--------------------------------------------------------------------+ -// USBH-CLASS DRIVER API +// Internal Class Driver API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - typedef struct { uint8_t itf_numr; @@ -198,8 +196,6 @@ bool msch_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *it void msch_isr(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); void msch_close(uint8_t dev_addr); -#endif - #ifdef __cplusplus } #endif diff --git a/src/device/usbd.c b/src/device/usbd.c index 17914fb6c..604f35bc5 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -28,8 +28,6 @@ #if TUSB_OPT_DEVICE_ENABLED -#define _TINY_USB_SOURCE_FILE_ - #include "tusb.h" #include "usbd.h" #include "device/usbd_pvt.h" diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c index d907aca3b..24234f4d2 100644 --- a/src/device/usbd_control.c +++ b/src/device/usbd_control.c @@ -28,8 +28,6 @@ #if TUSB_OPT_DEVICE_ENABLED -#define _TINY_USB_SOURCE_FILE_ - #include "tusb.h" #include "device/usbd_pvt.h" diff --git a/src/host/hub.c b/src/host/hub.c index d54032299..157a77937 100644 --- a/src/host/hub.c +++ b/src/host/hub.c @@ -28,8 +28,6 @@ #if (TUSB_OPT_HOST_ENABLED && CFG_TUH_HUB) -#define _TINY_USB_SOURCE_FILE_ - //--------------------------------------------------------------------+ // INCLUDE //--------------------------------------------------------------------+ diff --git a/src/host/hub.h b/src/host/hub.h index c3a02af5e..5a4a5eb7f 100644 --- a/src/host/hub.h +++ b/src/host/hub.h @@ -178,17 +178,13 @@ tusb_speed_t hub_port_get_speed(void); bool hub_status_pipe_queue(uint8_t dev_addr); //--------------------------------------------------------------------+ -// USBH-CLASS DRIVER API +// Internal Class Driver API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - void hub_init(void); bool hub_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *itf_desc, uint16_t *p_length); void hub_isr(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); void hub_close(uint8_t dev_addr); -#endif - #ifdef __cplusplus } #endif diff --git a/src/host/usbh.c b/src/host/usbh.c index 640bbfc8d..60d7afa76 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -28,8 +28,6 @@ #if TUSB_OPT_HOST_ENABLED -#define _TINY_USB_SOURCE_FILE_ - #ifndef CFG_TUH_TASK_QUEUE_SZ #define CFG_TUH_TASK_QUEUE_SZ 16 #endif diff --git a/src/host/usbh.h b/src/host/usbh.h index a7e053626..84d0f0ec6 100644 --- a/src/host/usbh.h +++ b/src/host/usbh.h @@ -88,10 +88,7 @@ ATTR_WEAK void tuh_umount_cb(uint8_t dev_addr); //--------------------------------------------------------------------+ // CLASS-USBH & INTERNAL API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - bool usbh_init(void); - bool usbh_control_xfer (uint8_t dev_addr, tusb_control_request_t* request, uint8_t* data); #endif diff --git a/src/tusb.c b/src/tusb.c index ec8f328b0..825aa988c 100644 --- a/src/tusb.c +++ b/src/tusb.c @@ -27,7 +27,6 @@ #include "tusb_option.h" #if TUSB_OPT_HOST_ENABLED || TUSB_OPT_DEVICE_ENABLED -#define _TINY_USB_SOURCE_FILE_ #include "tusb.h" -- cgit v1.3.1 From 801f3c9d8d295fe3ac9e40203eba4628ce638cba Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 27 Mar 2019 21:00:15 +0700 Subject: more clean up --- src/host/usbh.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/host/usbh.h b/src/host/usbh.h index 84d0f0ec6..b8d15305f 100644 --- a/src/host/usbh.h +++ b/src/host/usbh.h @@ -91,8 +91,6 @@ ATTR_WEAK void tuh_umount_cb(uint8_t dev_addr); bool usbh_init(void); bool usbh_control_xfer (uint8_t dev_addr, tusb_control_request_t* request, uint8_t* data); -#endif - #ifdef __cplusplus } #endif -- cgit v1.3.1