修改上传所有文件
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* uC/USB-Device
|
||||
* The Embedded USB Device Stack
|
||||
*
|
||||
* Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com
|
||||
*
|
||||
* SPDX-License-Identifier: APACHE-2.0
|
||||
*
|
||||
* This software is subject to an open source license and is distributed by
|
||||
* Silicon Laboratories Inc. pursuant to the terms of the Apache License,
|
||||
* Version 2.0 available at www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* NOTICE
|
||||
*
|
||||
* Semidrive modified this file to adapt it for ssdk platform.
|
||||
* The modifications are only intended for use with Semidrive chips.
|
||||
* Copyright of all the modifications belongs to Semidrive Semiconductor.
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* USB DEVICE DRIVER
|
||||
*
|
||||
* RENESAS HIGH-SPEED USB IP
|
||||
*
|
||||
* Filename : usbd_drv_renesas_usbhs.h
|
||||
* Version : V4.06.01
|
||||
*********************************************************************************************************
|
||||
* Note(s) : (1) You can find specific information about this driver at:
|
||||
* https://doc.micrium.com/display/USBDDRV/RENESAS_USBHS
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* MODULE
|
||||
*
|
||||
* Note(s) : (1) This USB device driver function header file is protected from multiple pre-processor
|
||||
* inclusion through use of the USB device driver module present pre-processor macro
|
||||
* definition.
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef USBD_DRV_RENESAS_USBHS_MODULE_PRESENT /* See Note #1. */
|
||||
#define USBD_DRV_RENESAS_USBHS_MODULE_PRESENT
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* INCLUDE FILES
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
#include "../../Source/usbd_core.h"
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* FUNCTION PROTOTYPES
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* USB DEVICE DRIVER
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
extern USBD_DRV_API USBD_DrvAPI_RenesasRZ_DMA;
|
||||
extern USBD_DRV_API USBD_DrvAPI_RenesasRZ_FIFO;
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* MODULE END
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
#endif
|
||||
284
e3_176_ref/middleware/usb/uC-USBD/Drivers/drv_lib/usbd_drv_lib.c
Normal file
284
e3_176_ref/middleware/usb/uC-USBD/Drivers/drv_lib/usbd_drv_lib.c
Normal file
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* uC/USB-Device
|
||||
* The Embedded USB Device Stack
|
||||
*
|
||||
* Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com
|
||||
*
|
||||
* SPDX-License-Identifier: APACHE-2.0
|
||||
*
|
||||
* This software is subject to an open source license and is distributed by
|
||||
* Silicon Laboratories Inc. pursuant to the terms of the Apache License,
|
||||
* Version 2.0 available at www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* USB DEVICE DRIVER
|
||||
*
|
||||
* Common library
|
||||
*
|
||||
* Filename : usbd_drv_lib.c
|
||||
* Version : V4.06.01
|
||||
*********************************************************************************************************
|
||||
* Note(s) : (1) This library offers some functions useful to some drivers.
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* INCLUDE FILES
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
#include "../../Source/usbd_core.h"
|
||||
#include "usbd_drv_lib.h"
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* LOCAL MACROS
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* LOCAL DATA TYPES
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* LOCAL FUNCTION PROTOTYPES
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
static void USBD_DrvLib_SetupPktQSend (USBD_DRV_LIB_SETUP_PKT_Q *p_setup_pkt_q,
|
||||
USBD_DRV *p_drv);
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* LOCAL CONFIGURATION ERRORS
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*********************************************************************************************************
|
||||
* GLOBAL FUNCTIONS
|
||||
*********************************************************************************************************
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* USBD_DrvLib_SetupPktQInit()
|
||||
*
|
||||
* Description : Initializes structure used to handle the setup packet Q-ing.
|
||||
*
|
||||
* Argument(s) : p_setup_pkt_q Pointer to setup packet queue structure.
|
||||
*
|
||||
* q_size Number of setup packet that the queue contains.
|
||||
*
|
||||
* p_err Pointer to variable that will receive the error code from this function:
|
||||
*
|
||||
* USBD_ERR_NONE Operation was successful.
|
||||
* USBD_ERR_ALLOC Cannot allocate setup packet queue.
|
||||
*
|
||||
* Return(s) : None.
|
||||
*
|
||||
* Note(s) : (1) This function must be called from the init() function of the driver to create a
|
||||
* setup packet queue.
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
void USBD_DrvLib_SetupPktQInit (USBD_DRV_LIB_SETUP_PKT_Q *p_setup_pkt_q,
|
||||
CPU_INT08U q_size,
|
||||
USBD_ERR *p_err)
|
||||
{
|
||||
LIB_ERR err_lib;
|
||||
|
||||
|
||||
p_setup_pkt_q->SetupPktTblPtr = (USBD_DRV_LIB_SETUP_PKT *)Mem_HeapAlloc( (q_size * sizeof(USBD_DRV_LIB_SETUP_PKT)),
|
||||
sizeof(CPU_INT32U),
|
||||
(CPU_SIZE_T *)0,
|
||||
&err_lib);
|
||||
if (err_lib != LIB_MEM_ERR_NONE) {
|
||||
*p_err = USBD_ERR_ALLOC;
|
||||
return;
|
||||
}
|
||||
|
||||
p_setup_pkt_q->TblLen = q_size;
|
||||
|
||||
*p_err = USBD_ERR_NONE;
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* USBD_DrvLib_SetupPktQClr()
|
||||
*
|
||||
* Description : Clears the setup packet queue control structure.
|
||||
*
|
||||
* Argument(s) : p_setup_pkt_q Pointer to setup packet queue structure.
|
||||
*
|
||||
* Return(s) : none.
|
||||
*
|
||||
* Note(s) : (1) This function must be called each time the USB device controller is reset (on reset
|
||||
* event coming from the bus).
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
void USBD_DrvLib_SetupPktQClr (USBD_DRV_LIB_SETUP_PKT_Q *p_setup_pkt_q)
|
||||
{
|
||||
p_setup_pkt_q->Nbr = 0u; /* Clr internal data and ix. */
|
||||
p_setup_pkt_q->IxIn = 0u;
|
||||
p_setup_pkt_q->IxOut = 0u;
|
||||
|
||||
Mem_Clr((void *)p_setup_pkt_q->SetupPktTblPtr, /* Clr every buf's content. */
|
||||
(p_setup_pkt_q->TblLen * sizeof(USBD_DRV_LIB_SETUP_PKT)));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* USBD_DrvLib_SetupPktQAdd()
|
||||
*
|
||||
* Description : Enqueues a setup packet in the circular buffer.
|
||||
*
|
||||
* Argument(s) : p_setup_pkt_q Pointer to setup packet queue structure.
|
||||
*
|
||||
* p_drv Pointer to device driver structure.
|
||||
*
|
||||
* p_setup_pkt_buf Pointer to buffer that contains the setup packet to add to the Q.
|
||||
* ---- Must be aligned on a 32 bit boundary. ----
|
||||
*
|
||||
* Return(s) : None.
|
||||
*
|
||||
* Note(s) : (1) This function must be called each time either a real or "dummy" setup packet must be
|
||||
* submitted to the core.
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
void USBD_DrvLib_SetupPktQAdd (USBD_DRV_LIB_SETUP_PKT_Q *p_setup_pkt_q,
|
||||
USBD_DRV *p_drv,
|
||||
CPU_INT32U *p_setup_pkt_buf)
|
||||
{
|
||||
CPU_INT32U *p_dest_buf;
|
||||
CPU_SR_ALLOC();
|
||||
|
||||
|
||||
CPU_CRITICAL_ENTER();
|
||||
if (p_setup_pkt_q->Nbr >= p_setup_pkt_q->TblLen) {
|
||||
CPU_CRITICAL_EXIT();
|
||||
return;
|
||||
}
|
||||
/* Get next avail buf from circular buf. */
|
||||
p_dest_buf = p_setup_pkt_q->SetupPktTblPtr[p_setup_pkt_q->IxIn].SetupPkt;
|
||||
|
||||
/* Store setup pkt in obtained buf. */
|
||||
p_dest_buf[0u] = p_setup_pkt_buf[0u];
|
||||
p_dest_buf[1u] = p_setup_pkt_buf[1u];
|
||||
|
||||
/* Adjust ix and internal data. */
|
||||
p_setup_pkt_q->IxIn++;
|
||||
if (p_setup_pkt_q->IxIn >= p_setup_pkt_q->TblLen) {
|
||||
p_setup_pkt_q->IxIn = 0u;
|
||||
}
|
||||
p_setup_pkt_q->Nbr++;
|
||||
|
||||
if (p_setup_pkt_q->Nbr == 1u) {
|
||||
USBD_DrvLib_SetupPktQSend(p_setup_pkt_q, p_drv);
|
||||
}
|
||||
CPU_CRITICAL_EXIT();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* USBD_DrvLib_SetupPktQSubmitNext()
|
||||
*
|
||||
* Description : Dequeues last setup packet buffer and submit a new one if any.
|
||||
*
|
||||
* Argument(s) : p_setup_pkt_q Pointer to setup packet queue structure.
|
||||
*
|
||||
* p_drv Pointer to device driver structure.
|
||||
*
|
||||
* Return(s) : None.
|
||||
*
|
||||
* Note(s) : (1) This function must be called each time the core has completed a setup packet
|
||||
* processing. This will occur when it stalls the control endpoint or when it requests
|
||||
* to send or receive the status phase (ZLP).
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
void USBD_DrvLib_SetupPktQSubmitNext (USBD_DRV_LIB_SETUP_PKT_Q *p_setup_pkt_q,
|
||||
USBD_DRV *p_drv)
|
||||
{
|
||||
CPU_SR_ALLOC();
|
||||
|
||||
|
||||
CPU_CRITICAL_ENTER(); /* Dequeue prev setup pkt. */
|
||||
p_setup_pkt_q->IxOut++;
|
||||
if (p_setup_pkt_q->IxOut >= p_setup_pkt_q->TblLen) {
|
||||
p_setup_pkt_q->IxOut = 0u;
|
||||
}
|
||||
p_setup_pkt_q->Nbr--;
|
||||
|
||||
USBD_DrvLib_SetupPktQSend(p_setup_pkt_q, p_drv); /* Submit next setup pkt if any. */
|
||||
CPU_CRITICAL_EXIT();
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*********************************************************************************************************
|
||||
* LOCAL FUNCTIONS
|
||||
*********************************************************************************************************
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* USBD_DrvLib_SetupPktQSend()
|
||||
*
|
||||
* Description : Submits a setup packet to the core if any available in the queue.
|
||||
*
|
||||
* Argument(s) : p_setup_pkt_q Pointer to setup packet queue structure.
|
||||
*
|
||||
* p_drv Pointer to device driver structure.
|
||||
*
|
||||
* Return(s) : None.
|
||||
*
|
||||
* Note(s) : None.
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
static void USBD_DrvLib_SetupPktQSend (USBD_DRV_LIB_SETUP_PKT_Q *p_setup_pkt_q,
|
||||
USBD_DRV *p_drv)
|
||||
{
|
||||
USBD_DRV_LIB_SETUP_PKT *p_setup_pkt;
|
||||
|
||||
|
||||
if (p_setup_pkt_q->Nbr == 0u) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_setup_pkt = &p_setup_pkt_q->SetupPktTblPtr[p_setup_pkt_q->IxOut];
|
||||
|
||||
USBD_EventSetup( p_drv,
|
||||
(void *)&p_setup_pkt->SetupPkt[0u]);
|
||||
}
|
||||
129
e3_176_ref/middleware/usb/uC-USBD/Drivers/drv_lib/usbd_drv_lib.h
Normal file
129
e3_176_ref/middleware/usb/uC-USBD/Drivers/drv_lib/usbd_drv_lib.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* uC/USB-Device
|
||||
* The Embedded USB Device Stack
|
||||
*
|
||||
* Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com
|
||||
*
|
||||
* SPDX-License-Identifier: APACHE-2.0
|
||||
*
|
||||
* This software is subject to an open source license and is distributed by
|
||||
* Silicon Laboratories Inc. pursuant to the terms of the Apache License,
|
||||
* Version 2.0 available at www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* USB DEVICE DRIVER
|
||||
*
|
||||
* Common library
|
||||
*
|
||||
* Filename : usbd_drv_lib.h
|
||||
* Version : V4.06.01
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* MODULE
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef USBD_DRV_LIB_MODULE_PRESENT
|
||||
#define USBD_DRV_LIB_MODULE_PRESENT
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* INCLUDE FILES
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* EXTERNS
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef USBD_DRV_LIB_MODULE
|
||||
#define USBD_DRV_LIB_EXT
|
||||
#else
|
||||
#define USBD_DRV_LIB_EXT extern
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* DEFINES
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* DATA TYPES
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
/* ------------------- SETUP PACKET ------------------- */
|
||||
typedef struct usbd_drv_lib_setup_pkt {
|
||||
CPU_INT32U SetupPkt[2u]; /* Setup req buf: |Request|Value|Index|Length| */
|
||||
} USBD_DRV_LIB_SETUP_PKT;
|
||||
|
||||
|
||||
/* ---------------- SETUP PACKET QUEUE ---------------- */
|
||||
typedef struct usbd_drv_lib_setup_pkt_q {
|
||||
USBD_DRV_LIB_SETUP_PKT *SetupPktTblPtr; /* Ptr to table that contains the Q'd setup pkt. */
|
||||
|
||||
CPU_INT08U IxIn; /* Ix where to put the next rxd setup pkt. */
|
||||
CPU_INT08U IxOut; /* Ix where to get the next setup pkt to give to core. */
|
||||
CPU_INT08U Nbr; /* Actual nbr of pkts in the buf. */
|
||||
CPU_INT08U TblLen; /* Len of setup pkt tbl. */
|
||||
} USBD_DRV_LIB_SETUP_PKT_Q;
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* MACROS
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* CONFIGURATION ERRORS
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
void USBD_DrvLib_SetupPktQInit (USBD_DRV_LIB_SETUP_PKT_Q *p_setup_pkt_q,
|
||||
CPU_INT08U q_size,
|
||||
USBD_ERR *p_err);
|
||||
|
||||
void USBD_DrvLib_SetupPktQClr (USBD_DRV_LIB_SETUP_PKT_Q *p_setup_pkt_q);
|
||||
|
||||
void USBD_DrvLib_SetupPktQAdd (USBD_DRV_LIB_SETUP_PKT_Q *p_setup_pkt_q,
|
||||
USBD_DRV *p_drv,
|
||||
CPU_INT32U *p_setup_pkt_buf);
|
||||
|
||||
void USBD_DrvLib_SetupPktQSubmitNext(USBD_DRV_LIB_SETUP_PKT_Q *p_setup_pkt_q,
|
||||
USBD_DRV *p_drv);
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* MODULE END
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user