📄 usbin.c
字号:
/*********************************************************************************************
* File: usbin.c
* Author: embest
* Desc: usb bulk-IN operation
* History:
* R.X.Huang, March 12, 2005
* Programming modify, style of the program: nomenclature, commentary
* Y.J.Guo, April 28, 2005
* Modifying and reusing of S3C2410X u24xmon
*********************************************************************************************/
/*------------------------------------------------------------------------------------------*/
/* include files */
/*------------------------------------------------------------------------------------------*/
#include <string.h>
#include "2410lib.h"
#include "2410usb.h"
#include "usbmain.h"
#include "usb.h"
#include "usblib.h"
#include "usbsetup.h"
#include "usbin.h"
/*------------------------------------------------------------------------------------------*/
/* constants define */
/*------------------------------------------------------------------------------------------*/
// 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 )
#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) )
/*------------------------------------------------------------------------------------------*/
/* global variables */
/*------------------------------------------------------------------------------------------*/
static void PrintEpiPkt(UINT8T *pt,int cnt);
// Prepare the code for the packit size constraint!!!
// EP1 = IN end point.
UINT8T ep1Buf[EP1_PKT_SIZE];
int transferIndex=0;
/*********************************************************************************************
* name: PrepareEp1Fifo
* func: PrepareEp1Fifo
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void PrepareEp1Fifo(void)
{
int i;
UINT8T in_csr1;
rINDEX_REG=1;
in_csr1=rIN_CSR1_REG;
for(i=0;i<EP1_PKT_SIZE;i++)ep1Buf[i]=(UINT8T)(transferIndex+i);
WrPktEp1(ep1Buf,EP1_PKT_SIZE);
SET_EP1_IN_PKT_READY();
}
/*********************************************************************************************
* name: Ep1Handler
* func: Ep1Handler
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void Ep1Handler(void)
{
UINT8T in_csr1;
// int i;
rINDEX_REG=1;
in_csr1=rIN_CSR1_REG;
// uart_printf(" <1:%x]",in_csr1); //by lht
//I think that EPI_SENT_STALL will not be set to 1.
if(in_csr1 & EPI_SENT_STALL)
{
// uart_printf(" [STALL]");
CLR_EP1_SENT_STALL();
return;
}
//IN_PKT_READY is cleared
//The data transfered was ep1Buf[] which was already configured
//PrintEpiPkt(ep1Buf,EP1_PKT_SIZE); //by lht
transferIndex++;
PrepareEp1Fifo();
//IN_PKT_READY is set
//This packit will be used for next IN packit.
return;
}
/*********************************************************************************************
* name: PrintEpiPkt
* func: PrintEpiPkt
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void PrintEpiPkt(UINT8T *pt,int cnt)
{
int i;
uart_printf(" [B_IN:%d:",cnt); //by lht
for(i=0;i<cnt;i++)
uart_printf(" %x,",pt[i]);
uart_printf(" ]");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -