通过EP0发送一个长度为7字节的包
void usb_ep_in_commit_pkt_long(uint32_t epnum, const uint8_t *pbuf, uint8_t len, bool sendshortpkt)
{
bool first;
uint8_t curlen;
first = (epnum == 0x00); /* EP0IN packets always start with DATA1 PID, while EP1IN PID toggles between DATA0/1 */
curlen = 0;
while (len)
{
curlen = len;
if (curlen > 8)
{
curlen = 8;
}
while (!usb_ep_in_buf_empty(epnum)); /* wait until endpoint buffer is free */
usb_ep_in_commit_pkt(epnum, first, pbuf, curlen);
len -= curlen;
pbuf += curlen;
first = false;
}
if (!sendshortpkt)
{
return;
}
if ((curlen == 8) || (curlen == 0)) /* in case the last packet has 8 bytes a short packet needs to be sent to signalize the host, that this was the last packet*/
{
while (!usb_ep_in_buf_empty(epnum)); /* wait until endpoint buffer is free */
usb_ep_in_commit_pkt(epnum, false, pbuf, 0);
}
}
|