usbin.c
资源名称:u241mon.zip [点击查看]
上传用户:hank9955
上传日期:2022-08-05
资源大小:14k
文件大小:2k
源码类别:
USB编程
开发平台:
C/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"
- // ===================================================================
- // 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) )
- static U8 sent = 0;
- //这个只是一个测试程序,一次不能写大于EP1_PKT_SIZE字节的数据
- //同时,写周期不能大于USB主机读取的周期。
- //TODO: 增加一个环形缓冲区做缓冲。
- void PrepareEp1Fifo(char *Msg, U32 MsgLen)
- {
- U8 in_csr1;
- rINDEX_REG=1;
- in_csr1=rIN_CSR1_REG;
- if(sent == 1) return;
- WrPktEp1((U8*)Msg, MsgLen < EP1_PKT_SIZE ? MsgLen : EP1_PKT_SIZE);
- SET_EP1_IN_PKT_READY();
- }
- void Ep1Handler(void)
- {
- U8 in_csr1;
- 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)
- {
- DbgPrintf("[STALL]");
- CLR_EP1_SENT_STALL();
- return;
- }
- sent= 0;
- return;
- }