usb学习笔记414(三)

usb的请求包括标准请求、类请求和厂商请求
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
usb_core.h
typedef struct USB_OTG_handle
{
USB_OTG_CORE_CFGS cfg;
USB_OTG_CORE_REGS regs;
#ifdef USE_DEVICE_MODE
DCD_DEV dev; //device模块结构体
#endif
#ifdef USE_HOST_MODE
HCD_DEV host;
#endif
#ifdef USE_OTG_MODE
OTG_DEV otg;
#endif
}
USB_OTG_CORE_HANDLE

typedef struct _DCD //device模块结构体
{
uint8_t device_config;
uint8_t device_state;
uint8_t device_status;
uint8_t device_old_status;
uint8_t device_address;
uint8_t connection_status;
uint8_t test_mode;
uint32_t DevRemoteWakeup;
USB_OTG_EP in_ep [USB_OTG_MAX_TX_FIFOS];
USB_OTG_EP out_ep [USB_OTG_MAX_TX_FIFOS];
uint8_t setup_packet [8*3];
USBD_Class_cb_TypeDef *class_cb; //类回调函数
USBD_Usr_cb_TypeDef *usr_cb; //用户回调函数
USBD_DEVICE *usr_device; //给出描述符回调函数
uint8_t *pConfig_descriptor;
}
DCD_DEV , *DCD_PDEV;

usbd_usr.c
void OTG_FS_IRQHandler(void) //处理所有usb中断//调用usb_dcd_init.c中的USBD_OTG_ISR_Handler

USBD_Usr_cb_TypeDef USR_cb = //注册到device模块结构体中,被USBD_DCD_INT_cb_TypeDef 中的函数调用
{
USBD_USR_Init,
USBD_USR_DeviceReset,
USBD_USR_DeviceConfigured,
USBD_USR_DeviceSuspended,
USBD_USR_DeviceResumed,
USBD_USR_DeviceConnected,
USBD_USR_DeviceDisconnected,
};

usbd_msc_core.c
USBD_Class_cb_TypeDef USBD_MSC_cb = //注册到device模块结构体中,被USBD_DCD_INT_cb_TypeDef 中的函数调用
{
USBD_MSC_Init,
USBD_MSC_DeInit,
USBD_MSC_Setup,
NULL, /EP0_TxSent/
NULL, /EP0_RxReady/
USBD_MSC_DataIn,
USBD_MSC_DataOut,
NULL, /*SOF */
NULL,
NULL,
USBD_MSC_GetCfgDesc,
#ifdef USB_OTG_HS_CORE
USBD_MSC_GetOtherCfgDesc,
#endif
};

usbd_desc.c
USBD_DEVICE USR_desc = //提供获取各种描述符的方法
{
USBD_USR_DeviceDescriptor,
USBD_USR_LangIDStrDescriptor,
USBD_USR_ManufacturerStrDescriptor,
USBD_USR_ProductStrDescriptor,
USBD_USR_SerialStrDescriptor,
USBD_USR_ConfigStrDescriptor,
USBD_USR_InterfaceStrDescriptor,

};

usbd_req.c//完成对请求的处理//主要被usbd_core.c中处理setup阶段的函数调用
USBD_StdDevReq Handle standard usb device requests
USBD_StdItfReq Handle standard usb interface requests
USBD_StdEPReq Handle standard usb endpoint requests

usbd_ioreq.c//完成对控制通道的读写//主要被usbd_req.c中处理请求的函数调用,完成控制传输的数据阶段和状态阶段
USBD_CtlSendData send data on the ctl pipe
USBD_CtlContinueSendData continue sending data on the ctl pipe
USBD_CtlPrepareRx receive data on the ctl pipe
USBD_CtlContinueRx continue receive data on the ctl pipe
USBD_CtlSendStatus send zero lzngth packet on the ctl pipe
USBD_CtlReceiveStatus receive zero lzngth packet on the ctl pipe
USBD_GetRxCount returns the received data length

usbd_core.c
USBD_Init Initailizes the device stack and load the class driver
//调用USB_OTG_BSP_Init
//调用DCD_Init
//注册类回调函数 、用户回调和获取描述符回调
//调用USB_OTG_BSP_EnableInterrupt

USBD_DeInit Re-Initialize th device library
USBD_Reset

USBD_SetCfg

USBD_DCD_INT_cb_TypeDef USBD_DCD_INT_cb = //提供给usb_dcd_int.c中的中断函数调用的
{
USBD_DataOutStage, Handle data out stage
USBD_DataInStage, Handle data in stage
USBD_SetupStage, Handle the setup stage//在中断中被调用响应请求//这个函数中调用usbd_req.c请求的处理函数

USBD_SOF, Handle SOF event
USBD_Reset,
USBD_Suspend, Handle Suspend event
USBD_Resume, Handle Resume event
USBD_IsoINIncomplete, Handle iso in incomplete event//不知道
USBD_IsoOUTIncomplete, Handle iso out incomplete event//不知道
#ifdef VBUS_SENSING_ENABLED
USBD_DevConnected, Handle device disconnection event//在中断中被调用//这个函数中调用usr_cb的函数和class_cb的函数
USBD_DevDisconnected, Handle device connection event
#endif
};

usb_dcd_int.c//对外提供一个中断函数入口//其中各种中断服务依赖于usbd_core.c中实现的USBD_DCD_INT_cb_TypeDef中的各个函数

USBD_OTG_ISR_Handler //usb的中断入口

usb_dcd.c
DCD_Init //被device库中的初始化函数调用//然后又去调动usb_core.c中的USB_OTG_CoreInitDev
//根据配置信息初始化全局结构体中的ep信息
//USB_OTG_CoreInit
//USB_OTG_CoreInitDev
//USB_OTG_EnableGlobalInt

DCD_EP_Open Configure an EP
DCD_EP_Close called when an EP is disabled
DCD_EP_PrepareRx
DCD_EP_Tx
DCD_EP_Stall
DCD_EP_ClrStall
DCD_EP_Flush
DCD_EP_SetAddress
DCD_DevConnect
DCD_DevDisconnect
DCD_GetEPStatus
DCD_SetEPStatus //Set the EP Status
//调用USB_OTG_SetEPStatus
usb_core.c
USB_OTG_EnableCommonInt
USB_OTG_CoreReset
USB_OTG_WritePacket
USB_OTG_ReadPacket
USB_OTG_SelectCore
USB_OTG_CoreInit //Initializes the USB_OTG controller registers and prepares the core device mode or host mode operation.
USB_OTG_EnableGlobalInt
USB_OTG_DisableGlobalInt
USB_OTG_FlushTxFifo
USB_OTG_FlushRxFifo
USB_OTG_SetCurrentMode //USB_OTG_SetCurrentMode : Set ID line
USB_OTG_GetMode
USB_OTG_IsDeviceMode
USB_OTG_IsHostMode

USB_OTG_ReadCoreItr //USB_OTG_ReadCoreItr : returns the Core Interrupt register
USB_OTG_ReadOtgItr //USB_OTG_ReadOtgItr : returns the USB_OTG Interrupt register

USB_OTG_CoreInitHost //Initializes the USB_OTG controller registers for hostmode
USB_OTG_IsEvenFrame //This function returns the frame number for sof packet
USB_OTG_DriveVbus

USB_OTG_EnableHostInt //USB_OTG_EnableHostInt: Enables the Host mode interrupts
USB_OTG_InitFSLSPClkSel //USB_OTG_InitFSLSPClkSel : Initializes the FSLSPClkSel field of the HCFG register on the PHY type
USB_OTG_ReadHPRT0
USB_OTG_ReadHostAllChannels_intr

USB_OTG_ResetPort

USB_OTG_HC_Init //USB_OTG_HC_Init : Prepares a host channel for transferring packets
USB_OTG_HC_StartXfer //USB_OTG_HC_StartXfer : Start transfer
USB_OTG_HC_Halt
USB_OTG_HC_DoPing

USB_OTG_StopHost
USB_OTG_InitDevSpeed

USB_OTG_CoreInitDev //USB_OTG_CoreInitDev : Initializes the USB_OTG controller registers for device mode
USB_OTG_EnableDevInt
USB_OTG_GetDeviceSpeed
USB_OTG_EP0Activate
USB_OTG_EPActivate
USB_OTG_EPDeactivate
USB_OTG_EPStartXfer
USB_OTG_EP0StartXfer
USB_OTG_EPSetStall
USB_OTG_EPClearStall
USB_OTG_ReadDevAllOutEp_itr
USB_OTG_ReadDevAllInEPItr
USB_OTG_EP0_OutStart

USB_OTG_ActiveRemoteWakeup
USB_OTG_UngateClock
USB_OTG_StopDevice //Stop the device and clean up fifo’s
USB_OTG_GetEPStatus
USB_OTG_SetEPStatus

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值