📄 usbdriver.c
字号:
{
if (usb_ints & USBINT_STATUS_HP)
Usb_HPService(); /* 高优先级中断处理 process High priority Interrupt */
if (usb_ints & USBINT_STATUS_LP)
Usb_LPService(); /* 低优先级中断处理 process Slow priority Interrupt */
#if DMA_ENGINE_EN
if (usb_ints & USBINT_STATUS_DMA)
USB_DMAService(); /* DMA中断处理 process DMA Interrupt */
#endif
}
USB_ISR_EXIT:
bEPPflags.bits.in_isr = 0; /* 标识程序退出中断 flag the program exit interrupt */
VICVectAddr = 0x00; /* 通知LPC214x中断结束 Inform LPC214x interrupt end */
}
/***************************************************************************************************************
** 函数名称 : Usb_HPService() Name : Usb_HPService()
** 功能描述 : USB 端点高速中断服务程序 Function : USB endpoint fast Interrupt Service Program
** 输 入 : 无 Input : NULL
** 输 出 : 无 Output : NULL
****************************************************************************************************************/
void Usb_HPService(void)
{
INT32U ep_st;
ep_st = USBEpIntSt; /* 读端点中断状态寄存器 read endpoint interrupt status register */
if(ep_st & USB_ENDP00)
ep0_rxdone(); /* 控制端点接收数据处理 process controll endpoint receive data */
if(ep_st & USB_ENDP01)
ep0_txdone(); /* 控制端点发送数据处理 process controll endpoint transmit data */
if(ep_st & USB_ENDP02)
ep1_rxdone(); /* 逻辑端点1接收数据处理 process logic endpoint 1 receive data */
if(ep_st & USB_ENDP03)
ep1_txdone(); /* 逻辑端点1发送数据处理 process logic endpoint 1 transmit data */
if(ep_st & USB_ENDP04)
ep2_rxdone(); /* 逻辑端点2接收数据处理 process logic endpoint 2 receive data */
if(ep_st & USB_ENDP05)
ep2_txdone(); /* 逻辑端点2发送数据处理 process logic endpoint 2 transmit data */
USBDevIntClr = FASTINTERRUPT;
}
/***************************************************************************************************************
** 函数名称 : Usb_LPService() Name : Usb_LPService()
** 功能描述 : USB 端点慢速中断服务程序 Function : USB endpoint slow Interrupt Service Program
** 输 入 : 无 Input : NULL
** 输 出 : 无 Output : NULL
****************************************************************************************************************/
void Usb_LPService(void)
{
INT32U ep_st;
ep_st = USBEpIntSt; /* 读端点中断状态寄存器 read endpoint interrupt status register */
if(ep_st & USB_ENDP00)
ep0_rxdone(); /* 控制端点接收数据处理 process controll endpoint receive data */
if(ep_st & USB_ENDP01)
ep0_txdone(); /* 控制端点发送数据处理 process controll endpoint transmit data */
if(ep_st & USB_ENDP02)
ep1_rxdone(); /* 端点1接收数据处理 process logic endpoint 1 receive data */
if(ep_st & USB_ENDP03)
ep1_txdone(); /* 端点1发送数据处理 process logic endpoint 1 transmit data */
if(ep_st & USB_ENDP04)
ep2_rxdone(); /* 端点2接收数据处理 process logic endpoint 2 receive data */
if(ep_st & USB_ENDP05)
ep2_txdone(); /* 端点2发送数据处理 process logic endpoint 2 transmit data */
USBDevIntClr = SLOWINTERRUPT;
}
/***************************************************************************************************************
** 函数名称 : ep1_txdone() Name : ep1_txdone()
** 功能描述 : 逻辑端点1发送数据处理 Function : logic endpoint 1 TX
** 输 入 : 无 Input : NULL
** 输 出 : 无 Output : NULL
****************************************************************************************************************/
void ep1_txdone(void)
{
USB_SelectClrIntEndpoint(3); /* 选择端点并清除中断 select endpoint/clear interrupt */
}
/***************************************************************************************************************
** 函数名称 : ep1_txdone() Name : ep1_txdone()
** 功能描述 : 逻辑端点1接收数据处理 Function : logic endpoint 1 RX
** 输 入 : 无 Input : NULL
** 输 出 : 无 Output : NULL
****************************************************************************************************************/
void ep1_rxdone(void)
{
INT8U len;
USB_SelectClrIntEndpoint(2); /* 选择端点并清除中断 select endpoint/clear interrupt */
len = USB_ReadEndpoint(2,sizeof(GenEpBuf),GenEpBuf); /* 从接收缓冲区中读出数据 read data from EP RAM */
if(len != 0)
bEPPflags.bits.ep1_rxdone = 1; /* 标识该端点收到数据 flag endpoint received data */
}
/***************************************************************************************************************
** 函数名称 : ep2_txdone() Name : ep2_txdone()
** 功能描述 : 逻辑端点2发送数据处理 Function : logic endpoint 2 TX
** 输 入 : 无 Input : NULL
** 输 出 : 无 Output : NULL
****************************************************************************************************************/
void ep2_txdone(void)
{
USB_SelectClrIntEndpoint(5); /* 选择端点并清除中断 select endpoint/clear interrupt */
}
/***************************************************************************************************************
** 函数名称 : ep2_rxdone() Name : ep2_rxdone()
** 功能描述 : 逻辑端点2接收数据处理 Function : logic endpoint 2 RX
** 输 入 : 无 Input : NULL
** 输 出 : 无 Output : NULL
****************************************************************************************************************/
void ep2_rxdone(void)
{
INT8U len;
USB_SelectClrIntEndpoint(4); /* 选择端点并清除中断 select endpoint/clear interrupt */
len = USB_ReadEndpoint(4,sizeof(EpBuf),EpBuf); /* 从接收缓冲区中读出数据 read data from EP RAM */
if (len != 0)
bEPPflags.bits.ep2_rxdone = 1; /* 标识该端点收到数据 flag endpoint received data */
}
/***************************************************************************************************************
** 函数名称 : USB_BusReset() Name : USB_BusReset()
** 功能描述 : USB 总线复位处理 Function : process USB bus reset
** 输 入 : 无 Input : NULL
** 输 出 : 无 Output : NULL
****************************************************************************************************************/
void USB_BusReset(void)
{
USB_USBDevIntConfig();
USB_ConfigEndpoint(); /* 重新配置所有端点最大包大小 */
}
/***************************************************************************************************************
** 函数名称 : USB_Suspend() Name : USB_Suspend()
** 功能描述 : USB 总线挂起改变 Function : process USB bus suspend change
** 输 入 : 无 Input : NULL
** 输 出 : 无 Output : NULL
****************************************************************************************************************/
void USB_SuspendChange(void)
{
}
/***************************************************************************************************************
** 函数名称 : USB_ConnectChange() Name : USB_ConnectChange()
** 功能描述 : USB 总线连接改变 Function : process USB bus connect change
** 输 入 : 无 Input : NULL
** 输 出 : 无 Output : NULL
****************************************************************************************************************/
void USB_ConnectChange(void)
{
}
/***************************************************************************************************************
** 函数名称 : Get_USB214x_FirmwareVer() Name : Get_USB214x_FirmwareVer()
** 功能描述 : 取得LPC214x USB固件版本号 Function : get the version of LPC214x USB firmware
** 输 入 : 无 Input : NULL
** 输 出 : 16位版本号 Output : 16bit Version Code
****************************************************************************************************************/
INT16U Get_USB214x_FirmwareVer(void)
{
return 0x0100; /* LPC214x USB 固件版本为 1.00 */
} /* LPC214x USB Firmware Version is 1.00 */
/*******************************************************************************************************
** End Of File
********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -