📄 usbin.c
字号:
/****************************************************************
NAME: usbin.c
DESC: usb bulk-IN operation
HISTORY:
Mar.25.2002:purnnamu: ported for S3C2410X.
****************************************************************/
#include <string.h>
#include "option.h"
#include "2410addr.h"
#include "2410lib.h"
#include "def.h"
#include "2410usb.h"
#include "usbmain.h"
#include "usb.h"
#include "usblib.h"
#include "usbsetup.h"
#include "usbin.h"
//static void PrintEpiPkt(U8 *pt,int cnt);
// ===================================================================
// All following commands will operate in case
// - in_csr1 is valid.
// ===================================================================
#define SET_EP1_IN_PKT_READY() rIN_CSR1_REG= ( in_csr1 &(~ EPI_WR_BITS)\
| EPI_IN_PKT_READY ) //IN_CSR1_REG=0x01
#define SET_EP1_SEND_STALL() rIN_CSR1_REG= ( in_csr1 & (~EPI_WR_BITS)\
| EPI_SEND_STALL) )
#define CLR_EP1_SENT_STALL() rIN_CSR1_REG= ( in_csr1 & (~EPI_WR_BITS)\
&(~EPI_SENT_STALL) )
#define FLUSH_EP1_FIFO() rIN_CSR1_REG= ( in_csr1 & (~EPI_WR_BITS)\
| EPI_FIFO_FLUSH) )
// ***************************
// *** VERY IMPORTANT NOTE ***
// ***************************
// Prepare the code for the packit size constraint!!!
// EP1 = IN end point.
U8 ep1Buf[EP1_PKT_SIZE];
int transferIndex=0;
#ifdef _FOR_UDISK_
extern U8 CBW_flg;
void PrepareEp1Fifo_1(U8 * buffer,U8 len)
{
U8 length=len;
U8 in_csr1 = 0;
rINDEX_REG=1;
if(length>EP1_PKT_SIZE)
length = EP1_PKT_SIZE;
WrPktEp1(buffer,length);
if(length<EP1_PKT_SIZE)
{
SET_EP1_IN_PKT_READY();//IN_CSR1_REG=0x01
}
}
#endif
void PrepareEp1Fifo(void)
{
int i;
U8 in_csr1;
rINDEX_REG=1;
in_csr1=rIN_CSR1_REG;
for(i=0;i<EP1_PKT_SIZE;i++)ep1Buf[i]=(U8)(transferIndex+i);
WrPktEp1(ep1Buf,EP1_PKT_SIZE);//Write data (byte) to EP1 FIFO from ep1Buf[]
SET_EP1_IN_PKT_READY();//IN_CSR1_REG=0x01
}
void Ep1Handler(void)
{
U8 in_csr1;
int i;
rINDEX_REG=1;
in_csr1=rIN_CSR1_REG;
//I think that EPI_SENT_STALL will not be set to 1.
if(in_csr1 & EPI_SENT_STALL)
{
Uart_Printf("EP1 IN SENT STALL!\n");
CLR_EP1_SENT_STALL();
return;
}
#ifdef _FOR_UDISK_
if(USBD_flg==0)
{
transferIndex++;
PrepareEp1Fifo();
}
else if(USBD_flg==1)
{
CBW_flg = 3;
Mass_acces();
}
#else
//IN_PKT_READY is cleared
//The data transfered was ep1Buf[] which was already configured
//PrintEpiPkt(ep1Buf,EP1_PKT_SIZE);
transferIndex++;
PrepareEp1Fifo();
//IN_PKT_READY is set
//This packit will be used for next IN packit.
#endif
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -