?? 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 */
}
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 + -