72 lines
1.8 KiB
C
72 lines
1.8 KiB
C
|
|
/********************************************************************************
|
|||
|
|
* Copyright (c) 2016, Beijing Tongfang Microelectroics Co., Ltd.
|
|||
|
|
* All rights reserved.
|
|||
|
|
* Module: VSP Data processing
|
|||
|
|
* Author: Yang Song
|
|||
|
|
* Version: V1.0
|
|||
|
|
* History:
|
|||
|
|
* 2016-09-22 Original version
|
|||
|
|
********************************************************************************/
|
|||
|
|
|
|||
|
|
#include "global.h"
|
|||
|
|
|
|||
|
|
/***************************************************************************
|
|||
|
|
* Function: usbVspSendChars
|
|||
|
|
* Description: <EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
* Input: buf <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ַ
|
|||
|
|
* Input: len <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
* Output: NULL
|
|||
|
|
* Return: NULL
|
|||
|
|
* Other: NULL
|
|||
|
|
**************************************************************************/
|
|||
|
|
void usbVspSendChars(u8 *buf, u32 len)
|
|||
|
|
{
|
|||
|
|
u32 offset=0;
|
|||
|
|
u32 dly;
|
|||
|
|
if (len > 200*1024)
|
|||
|
|
{
|
|||
|
|
dly = 0;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
dly = 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
while(len >= VSPTXLEN){
|
|||
|
|
memcpy(g_abUsbEp2Buf, buf+offset, VSPTXLEN);
|
|||
|
|
usbEpnTxAll(2,g_abUsbEp2Buf,VSPTXLEN);
|
|||
|
|
TimerDelay(TIM2, dly);
|
|||
|
|
offset += VSPTXLEN;
|
|||
|
|
len -= VSPTXLEN;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
memcpy(g_abUsbEp2Buf, buf+offset, len);
|
|||
|
|
usbEpnTxAll(2,g_abUsbEp2Buf,len);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/***************************************************************************
|
|||
|
|
* Function: usbVspRecvChars
|
|||
|
|
* Description: <EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
* Input: <EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>buf
|
|||
|
|
* Input: bufSize buf<EFBFBD>Ĵ<EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹԽ<EFBFBD><EFBFBD>
|
|||
|
|
* Output: <EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
* Return: NULL
|
|||
|
|
* Other: NULL
|
|||
|
|
**************************************************************************/
|
|||
|
|
u32 usbVspRecvChars(u8 *buf, u32 bufSize)
|
|||
|
|
{
|
|||
|
|
u32 rcvlen = 0;
|
|||
|
|
|
|||
|
|
if (USBEP1STS & Bit19_En)
|
|||
|
|
{
|
|||
|
|
rcvlen = (USBEP1STS >> 8) & 0x000003FF;
|
|||
|
|
rcvlen = rcvlen > bufSize ? bufSize:rcvlen;
|
|||
|
|
memcpy(buf, g_abUsbEp1Buf, rcvlen);
|
|||
|
|
|
|||
|
|
USBEP1CON |= Bit9_En; // clear buf <20><><EFBFBD>ƶ˵<C6B6><CBB5><EFBFBD>bit10 <20><><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>bit9
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return rcvlen;
|
|||
|
|
}
|
|||
|
|
|