⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usb_regs1.h

📁 意法半導體STR710,USB範例程式,模擬U盤
💻 H
📖 第 1 页 / 共 2 页
字号:
//----------------------------------------------------------------
void ClearEP_KIND(BYTE);
#define _ClearEP_KIND(bEpNum)  (_SetENDPOINT(bEpNum, \
						         (_GetENDPOINT(bEpNum) & EPKIND_MASK)))
//----------------------------------------------------------------
// Set_Status_Out
// Clear_Status_Out
// sets/clears directly STATUS_OUT bit in the endpoint register 
// to be used only during control transfers
// IN : bEpNum = endpoint number
// OUT: none
//----------------------------------------------------------------
void Set_Status_Out(BYTE);
#define _Set_Status_Out(bEpNum)	   _SetEP_KIND(bEpNum)

void Clear_Status_Out(BYTE);
#define _Clear_Status_Out(bEpNum)  _ClearEP_KIND(bEpNum)

//----------------------------------------------------------------
// SetEPDoubleBuff
// ClearEPDoubleBuff
// sets/clears directly EP_KIND bit in the endpoint register 
// IN : bEpNum = endpoint number
// OUT: none
//----------------------------------------------------------------
void SetEPDoubleBuff(BYTE);
#define _SetEPDoubleBuff(bEpNum)   _SetEP_KIND(bEpNum)

void ClearEPDoubleBuff(BYTE);
#define _ClearEPDoubleBuff(bEpNum) _ClearEP_KIND(bEpNum)

//----------------------------------------------------------------
// ClearEP_CTR_RX
// ClearEP_CTR_TX
// clears bit CTR_RX / CTR_RX in the endpoint register
// IN : bEpNum = endpoint number
// OUT: none
//----------------------------------------------------------------
void ClearEP_CTR_RX(BYTE);
#define _ClearEP_CTR_RX(bEpNum)   (_SetENDPOINT(bEpNum,\
						   _GetENDPOINT(bEpNum) & 0x7FFF & EPREG_MASK))
void ClearEP_CTR_TX(BYTE);
#define _ClearEP_CTR_TX(bEpNum)   (_SetENDPOINT(bEpNum,\
						   _GetENDPOINT(bEpNum) & 0xFF7F & EPREG_MASK))	
//----------------------------------------------------------------
// ToggleDTOG_RX
// ToggleDTOG_TX
// toggles DTOG_RX / DTOG_TX bit in the endpoint register
// IN : bEpNum  = endpoint number
// OUT: none
//----------------------------------------------------------------
void ToggleDTOG_RX(BYTE);
#define _ToggleDTOG_RX(bEpNum)    (_SetENDPOINT(bEpNum, \
					   EP_DTOG_RX | _GetENDPOINT(bEpNum) & EPREG_MASK))
void ToggleDTOG_TX(BYTE);
#define _ToggleDTOG_TX(bEpNum)    (_SetENDPOINT(bEpNum, \
					   EP_DTOG_TX | _GetENDPOINT(bEpNum) & EPREG_MASK))

//----------------------------------------------------------------
// ClearDTOG_RX
// ClearDTOG_TX
// IN : bEpNum  = endpoint number
// OUT: none
//----------------------------------------------------------------
void ClearDTOG_RX(BYTE);
#define _ClearDTOG_RX(bEpNum)  if((_GetENDPOINT(bEpNum) & EP_DTOG_RX) != 0)\
			 							_ToggleDTOG_RX(bEpNum)
void ClearDTOG_TX(BYTE);
#define _ClearDTOG_TX(bEpNum)  if((_GetENDPOINT(bEpNum) & EP_DTOG_TX) != 0)\
			 							_ToggleDTOG_TX(bEpNum)
//----------------------------------------------------------------
// SetEPAddress
// sets address in an endpoint register
// IN : bEpNum  = endpoint number
// 		bAddr   = address
// OUT: none
//----------------------------------------------------------------
void SetEPAddress(BYTE,BYTE);
#define _SetEPAddress(bEpNum,bAddr) _SetENDPOINT(bEpNum,\
						_GetENDPOINT(bEpNum) & EPREG_MASK | bAddr)
//----------------------------------------------------------------
// GetEPAddress
// IN : bEpNum  = endpoint number
// OUT: none
//----------------------------------------------------------------
BYTE GetEPAddress(BYTE);
#define _GetEPAddress(bEpNum) ((BYTE)(_GetENDPOINT(bEpNum) & EPADDR_FIELD))

//----------------------------------------------------------------
#define _pEPTxAddr(bEpNum)	((DWORD *)((_GetBTABLE()+bEpNum*8  )*2 + PMAAddr))
#define _pEPTxCount(bEpNum)	((DWORD *)((_GetBTABLE()+bEpNum*8+2)*2 + PMAAddr)) 
#define _pEPRxAddr(bEpNum)	((DWORD *)((_GetBTABLE()+bEpNum*8+4)*2 + PMAAddr)) 
#define _pEPRxCount(bEpNum)	((DWORD *)((_GetBTABLE()+bEpNum*8+6)*2 + PMAAddr)) 

//----------------------------------------------------------------
// SetEPTxAddr
// sets address of the tx buffer
// IN : bEpNum = endpoint number
//      wAddr  = address to be set 
// OUT: none
//----------------------------------------------------------------
void SetEPTxAddr(BYTE,WORD);
#define _SetEPTxAddr(bEpNum,wAddr) (*_pEPTxAddr(bEpNum) = wAddr)

//----------------------------------------------------------------
// SetEPRxAddr
// sets address of the rx buffer
// IN : bEpNum = endpoint number
// OUT: none
//----------------------------------------------------------------
void SetEPRxAddr(BYTE,WORD);
#define _SetEPRxAddr(bEpNum,wAddr) (*_pEPRxAddr(bEpNum) = wAddr)

//----------------------------------------------------------------
// GetEPTxAddr
// gets address of the tx buffer
// IN : bEpNum = endpoint number
// IN :
// OUT: address of the buffer
//----------------------------------------------------------------
WORD GetEPTxAddr(BYTE);
#define _GetEPTxAddr(bEpNum) ((WORD)*_pEPTxAddr(bEpNum))

//----------------------------------------------------------------
// GetEPRxAddr
// gets address of the rx buffer
// IN : bEpNum = endpoint number
// OUT: address of the buffer
//----------------------------------------------------------------
WORD GetEPRxAddr(BYTE);
#define _GetEPRxAddr(bEpNum) ((WORD)*_pEPRxAddr(bEpNum))

//----------------------------------------------------------------
// SetEPTxCount
// sets counter for the tx buffer
// IN : bEpNum = endpoint number
//		wCount = counter value
// OUT: none
//----------------------------------------------------------------
void SetEPTxCount(BYTE,WORD);
#define _SetEPTxCount(bEpNum,wCount) (*_pEPTxCount(bEpNum) = wCount)

//----------------------------------------------------------------
// SetEPRxCount
// sets counter for the rx buffer
// IN : bEpNum = endpoint number
//		wCount = counter value    
// OUT: none
//----------------------------------------------------------------
void SetEPRxCount(BYTE,WORD);
//ERRATO #define _SetEPRxCount(bEpNum,wCount) (*_pEPRxCount(bEpNum) = wCount)

//----------------------------------------------------------------
// GetEPTxCount
// gets counter of the tx buffer
// IN : bEpNum = endpoint number
// OUT: counter value
//----------------------------------------------------------------
WORD GetEPTxCount(BYTE);
#define _GetEPTxCount(bEpNum)((WORD)(*_pEPTxCount(bEpNum)) & 0x3ff)

//----------------------------------------------------------------
// GetEPRxCount
// gets counter of the rx buffer
// IN : bEpNum = endpoint number
// OUT: counter value
//----------------------------------------------------------------
WORD GetEPRxCount(BYTE);
#define _GetEPRxCount(bEpNum)((WORD)(*_pEPRxCount(bEpNum)) & 0x3ff)
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
//----------------------------------------------------------------
// SetEPDblBufAddr
// sets addresses in a double buffer endpoint
// IN : bEpNum = endpoint number
//      wBuf0Addr = buffer 0 address 
//      wBuf1Addr = buffer 1 address 
// OUT: none
//----------------------------------------------------------------
void SetEPDblBufAddr(BYTE,WORD,WORD);
#define _SetEPDblBufAddr(bEpNum,wBuf0Addr,wBuf1Addr) { 	\
					_SetEPTxAddr(bEpNum, wBuf0Addr);	\
					_SetEPRxAddr(bEpNum, wBuf1Addr);	\
} // _SetEPDblBufAddr
//----------------------------------------------------------------
// SetEPDblBuf0Addr
// sets buffer 0 address in a double buffer endpoint
// IN : bEpNum = endpoint number
//      wBuf0Addr = buffer 0 address 
// OUT: none
//----------------------------------------------------------------
void SetEPDblBuf0Addr(BYTE,WORD);
#define _SetEPDblBuf0Addr(bEpNum,wBuf0Addr) (_SetEPTxAddr(bEpNum, wBuf0Addr))
//----------------------------------------------------------------
// SetEPDblBuf1Addr
// sets buffer 1 address in a double buffer endpoint
// IN : bEpNum = endpoint number
//      wBuf1Addr = buffer 0 address 
// OUT: none
//----------------------------------------------------------------
void SetEPDblBuf1Addr(BYTE,WORD);
#define _SetEPDblBuf1Addr(bEpNum,wBuf1Addr) (_SetEPRxAddr(bEpNum, wBuf1Addr))
//----------------------------------------------------------------
// GetEPDblBuf0Addr
// gets buffer 0 address of a double buffer endpoint
// IN : bEpNum = endpoint number
// OUT: none
//----------------------------------------------------------------
WORD GetEPDblBuf0Addr(BYTE);
#define _GetEPDblBuf0Addr(bEpNum) (_GetEPTxAddr(bEpNum))
//----------------------------------------------------------------
// GetEPDblBuf1Addr
// gets buffer 1 address of a double buffer endpoint
// IN : bEpNum = endpoint number
// OUT: none
//----------------------------------------------------------------
WORD GetEPDblBuf1Addr(BYTE);
#define _GetEPDblBuf1Addr(bEpNum) (_GetEPRxAddr(bEpNum))
//----------------------------------------------------------------
// SetEPDblBuf0Count
// sets buffer 0 counter for double buffering
// IN : bEpNum  = endpoint number
//		bDir    = endpoint dir  EP_DBUF_OUT = OUT 
//								EP_DBUF_IN  = IN
//		wCount  = counter value    
// OUT: none
//----------------------------------------------------------------
void SetEPDblBuf0Count(BYTE, BYTE, WORD); 
#define _SetEPDblBuf0Count(bEpNum, bDir, wCount)  { \
		 if(bDir == EP_DBUF_OUT)				\
		     /* OUT endpoint */					\
/*sb macro! ->*/			 SetEPCountRxReg(_pEPTxCount(bEpNum), wCount); \
		 else if(bDir == EP_DBUF_IN)			\
		     /* IN endpoint */					\
			 *_pEPTxCount(bEpNum) = (DWORD)wCount;  \
} // SetEPDblBuf0Count

//----------------------------------------------------------------
// SetEPDblBuf1Count
// sets buffer 1 counter for double buffering
// IN : bEpNum  = endpoint number
//		bDir    = endpoint dir  EP_DBUF_OUT = OUT 
//								EP_DBUF_IN  = IN
//		wCount  = counter value    
// OUT: none
//----------------------------------------------------------------
void SetEPDblBuf1Count(BYTE, BYTE, WORD);
#define _SetEPDblBuf1Count(bEpNum, bDir, wCount)  { \
		 if(bDir == EP_DBUF_OUT)   					\
		     /* OUT endpoint */					\
/*sb macro! ->*/			 SetEPCountRxReg(_pEPRxCount(bEpNum), wCount); \
		 else if(bDir == EP_DBUF_IN)			\
		     /* IN endpoint */					\
			 *_pEPRxCount(bEpNum) = (DWORD)wCount;  \
} // SetEPDblBuf1Count
//----------------------------------------------------------------
// SetEPDblBuffCount
// sets counter for double buffering
// IN : bEpNum  = endpoint number
//		bDir    = endpoint dir  EP_DBUF_OUT = OUT 
//								EP_DBUF_IN  = IN
//		wCount  = counter value    
// OUT: none
//----------------------------------------------------------------
void SetEPDblBuffCount(BYTE, BYTE, WORD);
#define _SetEPDblBuffCount(bEpNum, bDir, wCount) {\
			_SetEPDblBuf0Count(bEpNum, bDir, wCount); \
	 		_SetEPDblBuf1Count(bEpNum, bDir, wCount); \
} // _SetEPDblBuffCount	 		

//----------------------------------------------------------------
// GetEPDblBuf0Count
// gets buffer 0 rx/tx counter for double buffering
// IN : bEpNum  = endpoint number
// OUT: none
//----------------------------------------------------------------
WORD GetEPDblBuf0Count(BYTE);
//#define _GetEPDblBuf0Count(bEpNum) (_GetEPTxCount(bEpNum)); rigth version but wrong hardware 
#define _GetEPDblBuf0Count(bEpNum)	 (_GetEPRxCount(bEpNum))
//----------------------------------------------------------------
// GetEPDblBuf1Count
// gets buffer 1 rx/tx counter for double buffering
// IN : bEpNum  = endpoint number
// OUT: none
//----------------------------------------------------------------
WORD GetEPDblBuf1Count(BYTE);
//#define _GetEPDblBuf1Count(bEpNum) (_GetEPRxCount(bEpNum)); rigth version but wrong hardware 
#define _GetEPDblBuf1Count(bEpNum)	 (_GetEPTxCount(bEpNum))

//----------------------------------------------------------------
// GetEPDblBufDir
// gets direction of the double buffered endpoint
// IN : bEpNum  = endpoint number
// OUT: EP_DBUF_OUT, EP_DBUF_IN, 
//      EP_DBUF_ERR if the endpoint counter not yet programmed
//----------------------------------------------------------------
EP_DBUF_DIR GetEPDblBufDir(BYTE bEpNum);

//----------------------------------------------------------------
// FreeUserBuffer
// free buffer used from the application realising it to the line
// toggles bit SW_BUF in the double buffered endpoint register 
// IN : bEpNum = endpoint number
// OUT: none
//----------------------------------------------------------------
void FreeUserBuffer(BYTE);

WORD ToWord(BYTE,BYTE);
WORD ByteSwap(WORD);
  	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -