📄 iusbprocessdatatohost.c
字号:
// This routine is called by the interrupt handler (triggered by end of frame interrupt
// of the IN endpoint, when sending data to host.
#include "usb_pptt.h"
#include "usb_pdef.h"
#include "usb_pvar.h"
void _iUsbProcessDataToHost()
{
U8 i;
// if no data to host, simply exit
if (!_gUsbDataToHost)
{
return;
}
// if the current sector of data (512 bytes = 8 packets) has not yet been all sent
if (_gUsbPacketCount < 8)
{
// copy a packet of data to IN endpoint's FIFO
for (i=0; i<31; i++)
{
_reg_USB_EP4_FDAT = *(_gpUsbBufPtr++);
}
_reg_USB_EP4_FCTRL |= 0x20000000; // next write is last one in packet
_reg_USB_EP4_FDAT = *(_gpUsbBufPtr++);
_gUsbPacketCount++;
}
else // let's handle the next sector
{
// more sector to send ?
if (_gUsbNumSector > 0)
{
_iUsbReadSector(); // read the next sector
// copy a packet of data to IN endpoint's FIFO
for (i=0; i<31; i++)
{
_reg_USB_EP4_FDAT = *(_gpUsbBufPtr++);
}
_reg_USB_EP4_FCTRL |= 0x20000000; // next write is last one in packet
_reg_USB_EP4_FDAT = *(_gpUsbBufPtr++);
_gUsbPacketCount = 1;
}
else // no more sector to send
{
_gUsbDataToHost = FALSE;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -