您的位置:首页 > 其它

USB分析(一):中断函数分析

2018-01-29 21:57 344 查看

USB中断函数分析:

__usb_device_interrupt_handler()

首先看下寄存器:

Common Device Host Registers



Device Registers - Endpoint



1、读取中断端口寄存器:

ep_inst = _usb_instances->hw->DEVICE.EPINTSMRY.reg;




2、首先IF判断如果是端点0程序如下:



器件端点中断标志:



代码分析:

1、首先中断标志寄存器赋值

2、回调函数的调用

中断标志如下:



在udd_attach中注册了如下几个回调函数,其他没有注册的指向NULL。



3、其次else为其它端口:

首先读取:Device EndPoint Interrupt Flag



判断EndPoint Interrupt Flag 标志:

1、USB_DEVICE_EPINTFLAG_STALL_Msk(Transmit Stall 0 Interrupt Flag 令牌中断&发送中断标志位0)

udd_ep_transfer_process


2、USB_DEVICE_EPINTFLAG_RXSTP ( Received Setup Interrupt Flag 接收建立中断)

_usb_ep0_on_setup


3、USB_DEVICE_EPINTFLAG_TRCPT_Msk ( Transfer Fail 0 Interrupt Flag 传输完成中断0)

_usb_ep0_on_tansfer_ok


4、USB_DEVICE_EPINTFLAG_TRFAIL_Msk( Transfer Fail 0 Interrupt Flag 传输失败中断0)

_usb_ep0_on_tansfer_fail


现在分析下回调函数的注册

第一处:



第二处:

配置端口信息中:

bool udd_ep_alloc(udd_ep_id_t ep, uint8_t bmAttributes, uint16_t MaxEndpointSize)




第三处:



Array to store device related callback functions

usb_host_callback_t host_callback[USB_HOST_CALLBACK_N];
usb_host_pipe_callback_t host_pipe_callback[USB_PIPE_NUM][USB_HOST_PIPE_CALLBACK_N];


现在分析register函数和enable函数:

register:







enable:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: