📄 usb_ail.c
字号:
/**************** (c) 1998 STMicroelectronics **********************
PROJECT : USB - ST7
COMPILER : ST7 HICROSS C (HIWARE)
MODULE : usb_ail.c
VERSION : V 1.0
CREATION DATE : 25/05/98
AUTHOR : / MICROCONTROLLER DIVISION / ST Rousset
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
DESCRIPTION : ST7263 USB Application Interface Layer.
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
MODIFICATIONS :
******************************************************************************/
#include <hidef.h>
#include "usb_var.h"
#include "usr_var.h"
#include "lib_bits.h"
#include "define.h"
#include "usbrc.h"
#include "CondComp.h"
#include "usb_ail.h"
#include "descript.h"
/*-----------------------------------------------------------------------------
ROUTINE NAME : TransmitEP0
INPUT/OUTPUT : Endpoint#, data pointer, byte Length
DESCRIPTION : Write data in the RAM space of the USB DMA and send these data
-----------------------------------------------------------------------------*/
Bool TransmitEP0(Byte *Data, Byte DataLength)
{
int i;
if(!GetEP0TxValidStatus()) // The Endpoint is not valided, there is no data we can send
{
for (i=0; i<DataLength; i++)
Endpoint0.Tx[i] = *(Data + i);
SetEP0TxTbc(DataLength);
SetEP0TxStatus(VALID);
return(TRUE);
}
else // There is a data in the pipe
return(FALSE);
}
#ifdef USE_ENDPOINT1_IN
/*-----------------------------------------------------------------------------
ROUTINE NAME : TransmitEP1
INPUT/OUTPUT : Endpoint#, data pointer, byte Length
DESCRIPTION : Write data in the RAM space of the USB DMA and send these data
-----------------------------------------------------------------------------*/
Bool TransmitEP1(Byte *Data, Byte DataLength)
{
int i;
if(!GetEP1TxValidStatus()) // The Endpoint is not valided, there is no data
{
for (i=0; i<DataLength; i++)
Endpoint1[i] = *(Data + i);
SetEP1TxTbc(DataLength);
SetEP1TxStatus(VALID);
return(TRUE);
}
else // There is a data in the pipe
return(FALSE);
}
#endif
#ifdef USE_ENDPOINT2_IN
/*-----------------------------------------------------------------------------
ROUTINE NAME : TransmitEP2
INPUT/OUTPUT : Endpoint#, data pointer, byte Length
DESCRIPTION : Write data in the RAM space of the USB DMA and send these data
-----------------------------------------------------------------------------*/
Bool TransmitEP2(Byte *Data, Byte DataLength)
{
int i;
if(!GetEP2TxValidStatus()) // The Endpoint is not valided, there is no data
{
for (i=0; i<DataLength; i++)
Endpoint2[i] = *(Data + i);
SetEP2TxTbc(DataLength);
SetEP2TxStatus(VALID);
return(TRUE);
}
else // There is a data in the pipe
return(FALSE);
}
#endif
/*-----------------------------------------------------------------------------
ROUTINE NAME : ReceiveEP0
INPUT/OUTPUT : data pointer, byte number
DESCRIPTION : Read data in the RAM space of the USB DMA
-----------------------------------------------------------------------------*/
void ReceiveEP0(Byte *DataReceived)
{ int i;
Byte ByteNumber;
ByteNumber = GetEP0RxCNT();
for (i=0; i<ByteNumber; i++)
*(DataReceived+i) = Endpoint0.Rx[i];
}
/*-----------------------------------------------------------------------------
ROUTINE NAME : SetEndP0TxStatus
INPUT/OUTPUT : endpoint number and status values
DESCRIPTION : Write the status of Tx endpoint
-----------------------------------------------------------------------------*/
void SetEndP0TxStatus(Byte Status)
{
SetEP0TxStatus(Status);
}
/*-----------------------------------------------------------------------------
ROUTINE NAME : GetIdle
INPUT/OUTPUT : None
DESCRIPTION : Send an idle to the host
-----------------------------------------------------------------------------*/
void GetIdle(void)
{
TransmitEP0(&Idle, 1);
}
/*-----------------------------------------------------------------------------
ROUTINE NAME : SetIdle
INPUT/OUTPUT : None
DESCRIPTION : Set an idle received from the host
-----------------------------------------------------------------------------*/
void SetIdle(void)
{
Idle = UsbwValue[1];
}
/*-----------------------------------------------------------------------------
ROUTINE NAME : AdditionalString
INPUT/OUTPUT : None
DESCRIPTION : Get Additional String
-----------------------------------------------------------------------------*/
void AdditionalString(void)
{
if(UsbwValue[0] == INDEX_ADDSTRING0) // Get Additional String
CurrentUsbbLength = LENGTH_ADDSTRING0;
if(UsbwValue[0] == INDEX_ADDSTRING1) // Get Additional String
CurrentUsbbLength = LENGTH_ADDSTRING1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -