⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iusbprocessdatatohost.c

📁 How to control USB interface under SZ platform
💻 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 + -