📄 usbhostint.c
字号:
/*****************************Copyright(c)****************************************************************
** Guangzhou ZHIYUAN electronics Co.,LTD.
**
** http://www.embedtools.com
**
**------File Info-----------------------------------------------------------------------------------------
** File Name: USBInt.c
** Latest modified Date: 2007-07-08
** Latest Version: V1.0
** Description: USB中断设置及处理
**
**--------------------------------------------------------------------------------------------------------
** Created By: 吴隆穗
** Created date: 2007-10-20
** Version: V1.0
** Descriptions: 初始版本
**
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Description:
**
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Description:
**
*********************************************************************************************************/
#include "USBHostConfig.h"
/*********************************************************************************************************
** Function name: __usbHostIntInit
** Descriptions: 初始化中断寄存器
** input parameters: None
** output parameters: None
** Returned value: None
*********************************************************************************************************/
void __usbHostIntInit (void)
{
__GpsOhciReg->uiHcInterruptDisable = 0x7F | (0x03U << 30); /* 禁止所有中断, 并禁止 MIE 位 */
__GpsOhciReg->uiHcInterruptStatus = 0xC000007F; /* 清除所有中断标志 */
OTGIntClr = OTGIntSt; /* 清除中断标志 */
OTGIntEn = 1U << 3; /* 使能主机中断 */
USBIntSt |= 1U << 31; /* 使能全局中断位 */
}
/*********************************************************************************************************
** Function name: usbHostException
** Descriptions: 主机中断服务程序
** input parameters: None
** output parameters: None
** Returned value: None
*********************************************************************************************************/
void usbHostException(void)
{
USB_INT32U uiIntSt = 0;
USB_INT8U i;
USB_INT32U uiTmp;
VICVectAddr = 0;
uiIntSt = __GpsOhciReg->uiHcInterruptStatus & __GpsOhciReg->uiHcInterruptEnable;
if ( uiIntSt & 0x01 ) { /* Scheduling overrun */
__GpsOhciReg->uiHcInterruptStatus |= 0x01;
uiTmp = __USB_SHED_SHEDOVERRUN << 24;
OSQPost(__GevtUsbMsgQeue, (void *)uiTmp); /* 发送消息给调度任务 */
USBDEBUG_SENDSTR("\r\nSched or\r\n");
}
if ( uiIntSt & 0x02 ) { /* Write back done */
uiTmp = *(USB_INT32U *)(__GpsOhciReg->uiHcHCCA + 0x84);
__GpsOhciReg->uiHcInterruptStatus |= 0x02;
uiTmp = (uiTmp >> 4) | (__USB_SHED_DONEHEAD << 24); /* bit27~bit24为传输完成链表的 */
/* 高28位,bit31~bit28为事件类型*/
OSQPost(__GevtUsbMsgQeue, (void *)uiTmp); /* 发送控制信息给调度任务 */
}
if ( uiIntSt & 0x04 ) { /* SOF packet */
__GpsOhciReg->uiHcInterruptStatus |= 0x04;
}
if ( uiIntSt & 0x08 ) { /* Resume detected */
__GpsOhciReg->uiHcInterruptStatus |= 0x08;
USBDEBUG_SENDSTR("\r\nResume det\r\n");
}
if ( uiIntSt & 0x10 ) { /* Unrecoverable error */
__GpsOhciReg->uiHcInterruptStatus |= 0x10;
uiTmp = __USB_SHED_UNRECERROR << 24;
OSQPost(__GevtUsbMsgQeue, (void *)uiTmp); /* 发送消息给调度任务 */
USBDEBUG_SENDSTR("\r\nUnrecov err\r\n");
}
if ( uiIntSt & 0x20 ) { /* Frame Number overflow */
__GpsOhciReg->uiHcInterruptStatus |= 0x20;
}
if ( uiIntSt & 0x40 ) { /* Root hub status change */
uiTmp = 0;
__GpsOhciReg->uiHcInterruptStatus |= 0x40;
for (i = 0; i < USB_MAX_PORTS; i++) { /* 依次判断哪个端口发生连接改变*/
if (__GpsOhciReg->uiHcRhPortStatus[i] & (1 << 16)) { /* 判断是否发生连接改变 */
uiTmp = (__USB_SHED_CONCHANGE << 24) | ((i + 1) << 8) |
(__GpsOhciReg->uiHcRhPortStatus[i] & 0x01);
OSQPost(__GevtUsbMsgQeue, (void *)uiTmp); /* 发送消息给调度任务 */
break;
}
}
__ohciDisEnInt(__USB_INT_RHSC); /* 禁止连接改变中断 */
USBDEBUG_SENDSTR("\r\nstat change\r\n");
}
if ( uiIntSt & 0x80 ) { /* Ownership change */
__GpsOhciReg->uiHcInterruptStatus |= 0x80;
USBDEBUG_SENDSTR("\r\nOwnership change\r\n");
}
}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -