usbout.c
资源名称:u241mon.zip [点击查看]
上传用户:hank9955
上传日期:2022-08-05
资源大小:14k
文件大小:2k
源码类别:
USB编程
开发平台:
C/C++
- /****************************************************************
- NAME: usbout.c
- DESC: USB bulk-OUT operation related functions
- HISTORY:
- Mar.25.2002:purnnamu: ported for S3C2410X.
- Mar.27.2002:purnnamu: DMA is enabled.
- ****************************************************************/
- #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 "usbout.h"
- #include "u241mon.h"
- static void PrintEpoPkt(U8 *pt,int cnt);
- // ===================================================================
- // All following commands will operate in case
- // - out_csr3 is valid.
- // ===================================================================
- #define CLR_EP3_OUT_PKT_READY() rOUT_CSR1_REG= ( out_csr3 &(~ EPO_WR_BITS)
- &(~EPO_OUT_PKT_READY) )
- #define SET_EP3_SEND_STALL() rOUT_CSR1_REG= ( out_csr3 & (~EPO_WR_BITS)
- | EPO_SEND_STALL) )
- #define CLR_EP3_SENT_STALL() rOUT_CSR1_REG= ( out_csr3 & (~EPO_WR_BITS)
- &(~EPO_SENT_STALL) )
- #define FLUSH_EP3_FIFO() rOUT_CSR1_REG= ( out_csr3 & (~EPO_WR_BITS)
- |EPO_FIFO_FLUSH) )
- U8 ep3Buf[EP3_PKT_SIZE];
- //这个只是一个测试函数,把收到的信息都打到调试串口,正式使用可能要开启一下环形缓冲区。
- void Ep3Handler(void)
- {
- U8 out_csr3;
- int fifoCnt;
- rINDEX_REG=3;
- out_csr3=rOUT_CSR1_REG;
- DbgPrintf("<3:%x]",out_csr3);
- if(out_csr3 & EPO_OUT_PKT_READY)
- {
- fifoCnt=rOUT_FIFO_CNT1_REG;
- RdPktEp3(ep3Buf,fifoCnt);
- PrintEpoPkt(ep3Buf,fifoCnt);
- CLR_EP3_OUT_PKT_READY();
- return;
- }
- //I think that EPO_SENT_STALL will not be set to 1.
- if(out_csr3 & EPO_SENT_STALL)
- {
- DbgPrintf("[STALL]");
- CLR_EP3_SENT_STALL();
- return;
- }
- }
- void PrintEpoPkt(U8 *pt,int cnt)
- {
- int i;
- DbgPrintf("[BOUT:%d:",cnt);
- for(i=0;i<cnt;i++)
- {
- DbgPrintf("%x,",pt[i]);
- Uart_Printf("%c",pt[i]);
- }
- DbgPrintf("]");
- }
- void ClearEp3OutPktReady(void)
- {
- U8 out_csr3;
- rINDEX_REG=3;
- out_csr3=rOUT_CSR1_REG;
- CLR_EP3_OUT_PKT_READY();
- }