rename dcd_init to hal_dcd_init()

This commit is contained in:
hathach 2018-03-02 22:46:36 +07:00
parent b0a6395a45
commit 33d348c288
6 changed files with 25 additions and 68 deletions

View File

@ -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;
}
//--------------------------------------------------------------------+

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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));