From 33d348c288514bb2c949944e06cf45fc6751929f Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 2 Mar 2018 22:46:36 +0700 Subject: [PATCH] rename dcd_init to hal_dcd_init() --- hw/mcu/nxp/lpc43xx/tusb_port/dcd_lpc43xx.c | 19 ++-------- tinyusb/device/dcd.c | 44 ---------------------- tinyusb/device/dcd.h | 11 +++--- tinyusb/device/dcd_lpc175x_6x.c | 4 +- tinyusb/device/dcd_lpc_11uxx_13uxx.c | 6 ++- tinyusb/device/usbd.c | 9 ++++- 6 files changed, 25 insertions(+), 68 deletions(-) delete mode 100644 tinyusb/device/dcd.c diff --git a/hw/mcu/nxp/lpc43xx/tusb_port/dcd_lpc43xx.c b/hw/mcu/nxp/lpc43xx/tusb_port/dcd_lpc43xx.c index f72949868..93ec04d91 100644 --- a/hw/mcu/nxp/lpc43xx/tusb_port/dcd_lpc43xx.c +++ b/hw/mcu/nxp/lpc43xx/tusb_port/dcd_lpc43xx.c @@ -49,8 +49,8 @@ #include "osal/osal.h" #include "common/timeout_timer.h" -#include "dcd.h" -#include "usbd_dcd.h" +#include "device/dcd.h" +#include "device/usbd_dcd.h" #include "dcd_lpc43xx.h" //--------------------------------------------------------------------+ @@ -245,7 +245,7 @@ static void bus_reset(uint8_t coreid) } -static void lpc43xx_controller_init(uint8_t coreid) +bool hal_dcd_init(uint8_t coreid) { LPC_USB0_Type* const lpc_usb = LPC_USB[coreid]; dcd_data_t* p_dcd = dcd_data_ptr[coreid]; @@ -258,19 +258,8 @@ static void lpc43xx_controller_init(uint8_t coreid) lpc_usb->USBCMD_D &= ~0x00FF0000; // Interrupt Threshold Interval = 0 lpc_usb->USBCMD_D |= BIT_(0); // connect -} -tusb_error_t dcd_init(void) -{ - #if (TUSB_CFG_CONTROLLER_0_MODE & TUSB_MODE_DEVICE) - lpc43xx_controller_init(0); - #endif - - #if (TUSB_CFG_CONTROLLER_1_MODE & TUSB_MODE_DEVICE) - lpc43xx_controller_init(1); - #endif - - return TUSB_ERROR_NONE; + return true; } //--------------------------------------------------------------------+ diff --git a/tinyusb/device/dcd.c b/tinyusb/device/dcd.c deleted file mode 100644 index 441c8970e..000000000 --- a/tinyusb/device/dcd.c +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************/ -/*! - @file dcd.c - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - 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 the copyright holders 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 ''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 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. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -#include "dcd.h" - -#if MODE_DEVICE_SUPPORTED - - -#endif diff --git a/tinyusb/device/dcd.h b/tinyusb/device/dcd.h index 144f5a1aa..acbcd4957 100644 --- a/tinyusb/device/dcd.h +++ b/tinyusb/device/dcd.h @@ -68,7 +68,7 @@ static inline bool endpointhandle_is_equal(endpoint_handle_t x, endpoint_handle_ return (x.coreid == y.coreid) && (x.index == y.index) && (x.class_code == y.class_code); } -tusb_error_t dcd_init(void) ATTR_WARN_UNUSED_RESULT; +bool hal_dcd_init(uint8_t coreid); void dcd_isr(uint8_t coreid); @@ -82,11 +82,12 @@ void dcd_controller_set_configuration (uint8_t coreid); tusb_error_t dcd_pipe_control_xfer(uint8_t coreid, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete); void dcd_pipe_control_stall(uint8_t coreid); -endpoint_handle_t dcd_pipe_open(uint8_t coreid, tusb_descriptor_endpoint_t const * p_endpoint_desc, uint8_t class_code) ATTR_WARN_UNUSED_RESULT; -tusb_error_t dcd_pipe_queue_xfer(endpoint_handle_t edpt_hdl, uint8_t * buffer, uint16_t total_bytes) ATTR_WARN_UNUSED_RESULT; // only queue, not transferring yet -tusb_error_t dcd_pipe_xfer(endpoint_handle_t edpt_hdl, uint8_t * buffer, uint16_t total_bytes, bool int_on_complete) ATTR_WARN_UNUSED_RESULT; +endpoint_handle_t dcd_pipe_open(uint8_t coreid, tusb_descriptor_endpoint_t const * p_endpoint_desc, uint8_t class_code); +tusb_error_t dcd_pipe_queue_xfer(endpoint_handle_t edpt_hdl, uint8_t * buffer, uint16_t total_bytes); // only queue, not transferring yet +tusb_error_t dcd_pipe_xfer(endpoint_handle_t edpt_hdl, uint8_t * buffer, uint16_t total_bytes, bool int_on_complete); tusb_error_t dcd_pipe_stall(endpoint_handle_t edpt_hdl); -bool dcd_pipe_is_busy(endpoint_handle_t edpt_hdl) ATTR_WARN_UNUSED_RESULT ; + +bool dcd_pipe_is_busy(endpoint_handle_t edpt_hdl); // TODO coreid + endpoint address are part of endpoint handle, not endpoint handle, data toggle also need to be reset tusb_error_t dcd_pipe_clear_stall(uint8_t coreid, uint8_t edpt_addr); diff --git a/tinyusb/device/dcd_lpc175x_6x.c b/tinyusb/device/dcd_lpc175x_6x.c index 0644f92ab..935b1cc39 100644 --- a/tinyusb/device/dcd_lpc175x_6x.c +++ b/tinyusb/device/dcd_lpc175x_6x.c @@ -122,8 +122,10 @@ static void bus_reset(void) memclr_(&dcd_data, sizeof(dcd_data_t)); } -tusb_error_t dcd_init(void) +bool hal_dcd_init(uint8_t coreid) { + (void) coreid; + //------------- user manual 11.13 usb device controller initialization -------------// LPC_USB->USBEpInd = 0; // step 6 : set up control endpoint edpt_set_max_packet_size(0, TUSB_CFG_DEVICE_CONTROL_ENDOINT_SIZE); diff --git a/tinyusb/device/dcd_lpc_11uxx_13uxx.c b/tinyusb/device/dcd_lpc_11uxx_13uxx.c index 1c128b62e..baafc936f 100644 --- a/tinyusb/device/dcd_lpc_11uxx_13uxx.c +++ b/tinyusb/device/dcd_lpc_11uxx_13uxx.c @@ -183,8 +183,10 @@ void dcd_controller_set_address(uint8_t coreid, uint8_t dev_addr) LPC_USB->DEVCMDSTAT |= dev_addr; } -tusb_error_t dcd_init(void) +bool hal_dcd_init(uint8_t coreid) { + (void) coreid; + LPC_USB->EPLISTSTART = (uint32_t) dcd_data.qhd; LPC_USB->DATABUFSTART = 0x20000000; // only SRAM1 & USB RAM can be used for transfer @@ -193,7 +195,7 @@ tusb_error_t dcd_init(void) LPC_USB->DEVCMDSTAT |= CMDSTAT_DEVICE_ENABLE_MASK | CMDSTAT_DEVICE_CONNECT_MASK | CMDSTAT_RESET_CHANGE_MASK | CMDSTAT_CONNECT_CHANGE_MASK | CMDSTAT_SUSPEND_CHANGE_MASK; - return TUSB_ERROR_NONE; + return true; } static void bus_reset(void) diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c index 0f7931f93..318446fa5 100644 --- a/tinyusb/device/usbd.c +++ b/tinyusb/device/usbd.c @@ -159,7 +159,14 @@ static tusb_error_t usbd_body_subtask(void); tusb_error_t usbd_init (void) { - ASSERT_STATUS ( dcd_init() ); + #if (TUSB_CFG_CONTROLLER_0_MODE & TUSB_MODE_DEVICE) + hal_dcd_init(0); + #endif + + #if (TUSB_CFG_CONTROLLER_1_MODE & TUSB_MODE_DEVICE) + hal_dcd_init(1); + #endif + //------------- Task init -------------// usbd_queue_hdl = osal_queue_create(USBD_TASK_QUEUE_DEPTH, sizeof(usbd_task_event_t));