GD32F10x USB-Device: USB_Operation_Macros

GD32F103 Firmware

GD32F10x USB-Device  V1.0.0
GD32F10x USB-Device

Macros

#define _SetEPType(EpID, Type)   (_SetEPxCSR(EpID, ((_GetEPxCSR(EpID) & EP_CTL_MASK) | Type)))
 Endpoint type setting and getting(bits EP_CTL[1:0] in endpoint control and status register) More...
 
#define _GetEPType(EpID)   (_GetEPxCSR(EpID) & EP_CTL)
 
#define _SetEPTxStatus(EpID, State)
 Tx transfer status setting and getting (bits EPTX_STA[1:0]) More...
 
#define _GetEPTxStatus(EpID)   ((uint16_t)_GetEPxCSR(EpID) & EPTX_STA)
 
#define _SetEPRxStatus(EpID, State)
 Rx transfer status setting and getting (bits EPRX_STA[1:0]) More...
 
#define _GetEPRxStatus(EpID)   ((uint16_t)_GetEPxCSR(EpID) & EPRX_STA)
 
#define _SetEPRxTxStatus(EpID, StateRx, StateTx)
 Rx and Tx transfer status setting (bits EPRX_STA[1:0] & EPTX_STA[1:0]) More...
 
#define _SetEP_KIND(EpID)   (_SetEPxCSR(EpID, ((_GetEPxCSR(EpID) | EP_KCTL) & EPCSR_MASK)))
 Set and Clear endpoint kind (bit EP_KCTL). More...
 
#define _ClearEP_KIND(EpID)   (_SetEPxCSR(EpID, (_GetEPxCSR(EpID) & EPKCTL_MASK)))
 
#define _Set_Status_Out(EpID)   _SetEP_KIND(EpID)
 Set and Clear directly STATUS_OUT state of endpoint. More...
 
#define _Clear_Status_Out(EpID)   _ClearEP_KIND(EpID)
 
#define _SetEPDoubleBuff(EpID)   _SetEP_KIND(EpID)
 Set and Clear directly double buffered feature of endpoint. More...
 
#define _ClearEPDoubleBuff(EpID)   _ClearEP_KIND(EpID)
 
#define _ClearEPRX_ST(EpID)   (_SetEPxCSR(EpID, _GetEPxCSR(EpID) & 0x7FFF & EPCSR_MASK))
 Clear bit EPRX_ST / EPTX_ST in the endpoint control and status register. More...
 
#define _ClearEPTX_ST(EpID)   (_SetEPxCSR(EpID, _GetEPxCSR(EpID) & 0xFF7F & EPCSR_MASK))
 
#define _ToggleDTG_RX(EpID)   (_SetEPxCSR(EpID, EPRX_DTG | (_GetEPxCSR(EpID) & EPCSR_MASK)))
 Toggle and Clear EPRX_DTG bit in the endpoint control and status register. More...
 
#define _ClearDTG_RX(EpID)   if((_GetEPxCSR(EpID) & EPRX_DTG) != 0) _ToggleDTG_RX(EpID)
 
#define _ToggleDTG_TX(EpID)   (_SetEPxCSR(EpID, EPTX_DTG | (_GetEPxCSR(EpID) & EPCSR_MASK)))
 Toggle and Clear EPTX_DTG bit in the endpoint control and status register. More...
 
#define _ClearDTG_TX(EpID)   if((_GetEPxCSR(EpID) & EPTX_DTG) != 0) _ToggleDTG_TX(EpID)
 
#define _ToggleSWBUF_TX(EpID)   _ToggleDTG_RX(EpID)
 Toggle SW_BUF bit in the double buffered endpoint. More...
 
#define _ToggleSWBUF_RX(EpID)   _ToggleDTG_TX(EpID)
 
#define _SetEPAddress(EpID, Addr)   _SetEPxCSR(EpID, (_GetEPxCSR(EpID) & EPCSR_MASK) | Addr)
 Set and Get endpoint address. More...
 
#define _GetEPAddress(EpID)   ((uint8_t)(_GetEPxCSR(EpID) & EP_AR))
 
#define _GetEPTXARn(EpID)   ((uint32_t *)((_GetBAR() + EpID * 8) * 2 + PBA_ADDR))
 Get endpoint transmission buffer address. More...
 
#define _GetEPTXCNTx(EpID)   ((uint32_t *)((_GetBAR() + EpID * 8 + 2) * 2 + PBA_ADDR))
 Get endpoint transmission byte count. More...
 
#define _GetEPRXARn(EpID)   ((uint32_t *)((_GetBAR() + EpID * 8 + 4) * 2 + PBA_ADDR))
 Get endpoint reception buffer address. More...
 
#define _GetEPRXCNTx(EpID)   ((uint32_t *)((_GetBAR() + EpID * 8 + 6) * 2 + PBA_ADDR))
 Get endpoint reception byte count. More...
 
#define _SetEPTxAddr(EpID, Addr)   (*_GetEPTXARn(EpID) = (Addr & ~((uint16_t)1)))
 Set Tx/Rx buffer address. More...
 
#define _SetEPRxAddr(EpID, Addr)   (*_GetEPRXARn(EpID) = (Addr & ~((uint16_t)1)))
 
#define _GetEPTxAddr(EpID)   ((uint16_t)*_GetEPTXARn(EpID))
 Get Tx/Rx buffer address. More...
 
#define _GetEPRxAddr(EpID)   ((uint16_t)*_GetEPRXARn(EpID))
 
#define _BlocksOf32(pdwReg, Count)
 Set the reception buffer byte count register when 1 block is 32 bytes. More...
 
#define _BlocksOf2(pdwReg, Count)
 Set the reception buffer byte count register when 1 block is 2 bytes. More...
 
#define _SetEPRxDblBuf0Count(EpID, Count)
 Set buffer0 reception byte count when use double buffer. More...
 
#define _SetEPTxCount(EpID, Count)   (*_GetEPTXCNTx(EpID) = Count)
 Set Tx/Rx buffer byte count. More...
 
#define _SetEPRxCount(EpID, Count)
 
#define _GetEPTxCount(EpID)   ((uint16_t) (*_GetEPTXCNTx(EpID)) & EPTXCNTR_CNT)
 Get Tx/Rx buffer byte count. More...
 
#define _GetEPRxCount(EpID)   ((uint16_t) (*_GetEPRXCNTx(EpID)) & EPRXCNTR_CNT)
 
#define _SetEPDblBuf0Addr(EpID, Buf0Addr)   {_SetEPTxAddr(EpID, Buf0Addr);}
 Sets buffer 0/1 address when use double buffer. More...
 
#define _SetEPDblBuf1Addr(EpID, Buf1Addr)   {_SetEPRxAddr(EpID, Buf1Addr);}
 
#define _SetEPDblBufAddr(EpID, Buf0Addr, Buf1Addr)
 Sets a double buffer endpoint addresses. More...
 
#define _GetEPDblBuf0Addr(EpID)   (_GetEPTxAddr(EpID))
 Get a double buffer endpoint buffer 0/1 address. More...
 
#define _GetEPDblBuf1Addr(EpID)   (_GetEPRxAddr(EpID))
 
#define _SetEPDblBuf0Count(EpID, Dir, Count)
 Set buffer 0/1 byte count register in a double buffer endpoint. More...
 
#define _SetEPDblBuf1Count(EpID, Dir, Count)
 
#define _SetEPDblBuffCount(EpID, Dir, Count)
 
#define _GetEPDblBuf0Count(EpID)   (_GetEPTxCount(EpID))
 Get buffer 0/1 byte count. More...
 
#define _GetEPDblBuf1Count(EpID)   (_GetEPRxCount(EpID))
 
#define _SetDouBleBuffEPStall(EpID, Dir)
 Set double buffer endpoint status to STALL. More...
 

Detailed Description

Macro Definition Documentation

#define _BlocksOf2 (   pdwReg,
  Count 
)
Value:
{\
register uint16_t BlockNum = Count >> BLKSIZE2_OFFSETMASK;\
if((Count & BLKSIZE2_MASK) != 0)\
BlockNum++;\
*pdwReg = (uint32_t)(BlockNum << RXCNT_OFFSET);\
}

Set the reception buffer byte count register when 1 block is 2 bytes.

Parameters
pdwRegreception buffer byte count register
Countbyte count value
Return values
None

Definition at line 510 of file usb_regs.h.

#define _BlocksOf32 (   pdwReg,
  Count 
)
Value:
{\
register uint16_t BlockNum = Count >> BLKSIZE32_OFFSETMASK;\
if((Count & BLKSIZE32_MASK) == 0)\
BlockNum--;\
*pdwReg = (uint32_t)((BlockNum << RXCNT_OFFSET) | EPRXCNTR_BLKSIZ);\
}
#define EPRXCNTR_BLKSIZ
Endpoint receive/transmission counter register bit definitions.
Definition: usb_regs.h:247

Set the reception buffer byte count register when 1 block is 32 bytes.

Parameters
pdwRegreception buffer byte count register
Countbyte count value
Return values
None

Definition at line 497 of file usb_regs.h.

#define _ClearEPRX_ST (   EpID)    (_SetEPxCSR(EpID, _GetEPxCSR(EpID) & 0x7FFF & EPCSR_MASK))

Clear bit EPRX_ST / EPTX_ST in the endpoint control and status register.

Parameters
EpIDendpoint identifier
Return values
None

Definition at line 405 of file usb_regs.h.

#define _GetEPDblBuf0Addr (   EpID)    (_GetEPTxAddr(EpID))

Get a double buffer endpoint buffer 0/1 address.

Parameters
EpIDendpoint identifier
Return values
None

Definition at line 577 of file usb_regs.h.

#define _GetEPDblBuf0Count (   EpID)    (_GetEPTxCount(EpID))

Get buffer 0/1 byte count.

Parameters
EpIDendpoint identifier
Return values
None

Definition at line 613 of file usb_regs.h.

#define _GetEPRXARn (   EpID)    ((uint32_t *)((_GetBAR() + EpID * 8 + 4) * 2 + PBA_ADDR))

Get endpoint reception buffer address.

Parameters
EpIDendpoint identifier
Return values
None

Definition at line 465 of file usb_regs.h.

#define _GetEPRXCNTx (   EpID)    ((uint32_t *)((_GetBAR() + EpID * 8 + 6) * 2 + PBA_ADDR))

Get endpoint reception byte count.

Parameters
EpIDendpoint identifier
Return values
None

Definition at line 472 of file usb_regs.h.

#define _GetEPTxAddr (   EpID)    ((uint16_t)*_GetEPTXARn(EpID))

Get Tx/Rx buffer address.

Parameters
EpIDendpoint identifier
Return values
Addressof the buffer

Definition at line 488 of file usb_regs.h.

#define _GetEPTXARn (   EpID)    ((uint32_t *)((_GetBAR() + EpID * 8) * 2 + PBA_ADDR))

Get endpoint transmission buffer address.

Parameters
EpIDendpoint identifier
Return values
None

Definition at line 451 of file usb_regs.h.

#define _GetEPTXCNTx (   EpID)    ((uint32_t *)((_GetBAR() + EpID * 8 + 2) * 2 + PBA_ADDR))

Get endpoint transmission byte count.

Parameters
EpIDendpoint identifier
Return values
None

Definition at line 458 of file usb_regs.h.

#define _GetEPTxCount (   EpID)    ((uint16_t) (*_GetEPTXCNTx(EpID)) & EPTXCNTR_CNT)

Get Tx/Rx buffer byte count.

Parameters
EpIDendpoint identifier
Return values
Bytecount value

Definition at line 547 of file usb_regs.h.

#define _Set_Status_Out (   EpID)    _SetEP_KIND(EpID)

Set and Clear directly STATUS_OUT state of endpoint.

Parameters
EpIDendpoint identifier
Return values
None

Definition at line 387 of file usb_regs.h.

#define _SetDouBleBuffEPStall (   EpID,
  Dir 
)
Value:
{\
if (Dir == DBUF_EP_OUT) \
{ \
_SetEPxCSR(EpID, _GetEPxCSR(EpID) & ~EPRX_STALL); \
} \
else if (Dir == DBUF_EP_IN) \
{ \
_SetEPxCSR(EpID, _GetEPxCSR(EpID) & ~EPTX_STALL); \
} \
}
#define EPTX_STALL
Definition: usb_regs.h:230
#define EPRX_STALL
Definition: usb_regs.h:239

Set double buffer endpoint status to STALL.

Parameters
EpIDendpoint identifier
Direndpoint direction
Return values
None

Definition at line 622 of file usb_regs.h.

#define _SetEP_KIND (   EpID)    (_SetEPxCSR(EpID, ((_GetEPxCSR(EpID) | EP_KCTL) & EPCSR_MASK)))

Set and Clear endpoint kind (bit EP_KCTL).

Parameters
EpIDendpoint identifier
Return values
None

Definition at line 378 of file usb_regs.h.

#define _SetEPAddress (   EpID,
  Addr 
)    _SetEPxCSR(EpID, (_GetEPxCSR(EpID) & EPCSR_MASK) | Addr)

Set and Get endpoint address.

Parameters
EpIDendpoint identifier
Addrendpoint address
Return values
None

Definition at line 442 of file usb_regs.h.

#define _SetEPDblBuf0Addr (   EpID,
  Buf0Addr 
)    {_SetEPTxAddr(EpID, Buf0Addr);}

Sets buffer 0/1 address when use double buffer.

Parameters
EpIDendpoint identifier
Buf0Addrbuffer0 address
Buf1Addrbuffer1 address
Return values
None

Definition at line 557 of file usb_regs.h.

#define _SetEPDblBuf0Count (   EpID,
  Dir,
  Count 
)
Value:
{ \
if(Dir == DBUF_EP_OUT)\
{_SetEPRxDblBuf0Count(EpID, Count);} \
else if(Dir == DBUF_EP_IN)\
{*_GetEPTXCNTx(EpID) = (uint32_t)Count;} \
}
#define _GetEPTXCNTx(EpID)
Get endpoint transmission byte count.
Definition: usb_regs.h:458
#define _SetEPRxDblBuf0Count(EpID, Count)
Set buffer0 reception byte count when use double buffer.
Definition: usb_regs.h:523

Set buffer 0/1 byte count register in a double buffer endpoint.

Parameters
EpIDendpoint identifier
Direndpoint direction DBUF_EP_OUT = OUT DBUF_EP_IN = IN
Countbyte count value
Return values
None

Definition at line 589 of file usb_regs.h.

#define _SetEPDblBuf1Count (   EpID,
  Dir,
  Count 
)
Value:
{ \
if(Dir == DBUF_EP_OUT)\
{_SetEPRxCount(EpID, Count);}\
else if(Dir == DBUF_EP_IN)\
{*_GetEPRXCNTx(EpID) = (uint32_t)Count;} \
}
#define _GetEPRXCNTx(EpID)
Get endpoint reception byte count.
Definition: usb_regs.h:472

Definition at line 596 of file usb_regs.h.

#define _SetEPDblBufAddr (   EpID,
  Buf0Addr,
  Buf1Addr 
)
Value:
{ \
_SetEPDblBuf0Addr(EpID, Buf0Addr);\
_SetEPDblBuf1Addr(EpID, Buf1Addr);\
}
#define _SetEPDblBuf0Addr(EpID, Buf0Addr)
Sets buffer 0/1 address when use double buffer.
Definition: usb_regs.h:557

Sets a double buffer endpoint addresses.

Parameters
EpIDendpoint identifier
Buf0Addrbuffer0 address
Buf1Addrbuffer1 address
Return values
None

Definition at line 567 of file usb_regs.h.

#define _SetEPDblBuffCount (   EpID,
  Dir,
  Count 
)
Value:
{\
_SetEPDblBuf0Count(EpID, Dir, Count); \
_SetEPDblBuf1Count(EpID, Dir, Count); \
}
#define _SetEPDblBuf0Count(EpID, Dir, Count)
Set buffer 0/1 byte count register in a double buffer endpoint.
Definition: usb_regs.h:589

Definition at line 603 of file usb_regs.h.

#define _SetEPDoubleBuff (   EpID)    _SetEP_KIND(EpID)

Set and Clear directly double buffered feature of endpoint.

Parameters
EpIDendpoint identifier
Return values
None

Definition at line 396 of file usb_regs.h.

#define _SetEPRxCount (   EpID,
  Count 
)
Value:
{\
uint32_t *pdwReg = _GetEPRXCNTx(EpID); \
if(Count > 62) { _BlocksOf32(pdwReg, Count); } \
else { _BlocksOf2(pdwReg, Count); } \
}
#define _BlocksOf32(pdwReg, Count)
Set the reception buffer byte count register when 1 block is 32 bytes.
Definition: usb_regs.h:497
#define _BlocksOf2(pdwReg, Count)
Set the reception buffer byte count register when 1 block is 2 bytes.
Definition: usb_regs.h:510
#define _GetEPRXCNTx(EpID)
Get endpoint reception byte count.
Definition: usb_regs.h:472

Definition at line 536 of file usb_regs.h.

#define _SetEPRxDblBuf0Count (   EpID,
  Count 
)
Value:
{\
uint32_t *pdwReg = _GetEPTXCNTx(EpID); \
if(Count > 62) { _BlocksOf32(pdwReg, Count); } \
else { _BlocksOf32(pdwReg, Count); } \
}
#define _BlocksOf32(pdwReg, Count)
Set the reception buffer byte count register when 1 block is 32 bytes.
Definition: usb_regs.h:497
#define _GetEPTXCNTx(EpID)
Get endpoint transmission byte count.
Definition: usb_regs.h:458

Set buffer0 reception byte count when use double buffer.

Parameters
EpIDendpoint identifier
Countbyte count value
Return values
None

Definition at line 523 of file usb_regs.h.

#define _SetEPRxStatus (   EpID,
  State 
)
Value:
{\
register uint16_t _RegVal; \
_RegVal = _GetEPxCSR(EpID) & EPRX_DTGMASK;\
_SetEPxCSR(EpID, (_RegVal ^ State)); \
}

Rx transfer status setting and getting (bits EPRX_STA[1:0])

Parameters
EpIDendpoint identifier
Statenew state
Return values
None

Definition at line 352 of file usb_regs.h.

#define _SetEPRxTxStatus (   EpID,
  StateRx,
  StateTx 
)
Value:
{\
register uint16_t _RegVal; \
_RegVal = _GetEPxCSR(EpID) & (EPRX_DTGMASK | EPTX_STA) ;\
_SetEPxCSR(EpID, ((_RegVal ^ StateRx) ^ StateTx)); \
}
#define EPTX_STA
Definition: usb_regs.h:204

Rx and Tx transfer status setting (bits EPRX_STA[1:0] & EPTX_STA[1:0])

Parameters
EpIDendpoint identifier
StateRxnew Rx state
StateTxnew Tx state
Return values
None

Definition at line 367 of file usb_regs.h.

#define _SetEPTxAddr (   EpID,
  Addr 
)    (*_GetEPTXARn(EpID) = (Addr & ~((uint16_t)1)))

Set Tx/Rx buffer address.

Parameters
EpIDendpoint identifier
Addraddress to be set (must be word aligned)
Return values
None

Definition at line 480 of file usb_regs.h.

#define _SetEPTxCount (   EpID,
  Count 
)    (*_GetEPTXCNTx(EpID) = Count)

Set Tx/Rx buffer byte count.

Parameters
EpIDendpoint identifier
Countbyte count value
Return values
None

Definition at line 535 of file usb_regs.h.

#define _SetEPTxStatus (   EpID,
  State 
)
Value:
{\
register uint16_t _RegVal; \
_RegVal = _GetEPxCSR(EpID) & EPTX_DTGMASK;\
_SetEPxCSR(EpID, (_RegVal ^ State)); \
}

Tx transfer status setting and getting (bits EPTX_STA[1:0])

Parameters
EpIDendpoint identifier
Statenew state
Return values
None

Definition at line 338 of file usb_regs.h.

#define _SetEPType (   EpID,
  Type 
)    (_SetEPxCSR(EpID, ((_GetEPxCSR(EpID) & EP_CTL_MASK) | Type)))

Endpoint type setting and getting(bits EP_CTL[1:0] in endpoint control and status register)

Parameters
EpIDendpoint identifier
Typeendpoint type
Return values
None

Definition at line 327 of file usb_regs.h.

#define _ToggleDTG_RX (   EpID)    (_SetEPxCSR(EpID, EPRX_DTG | (_GetEPxCSR(EpID) & EPCSR_MASK)))

Toggle and Clear EPRX_DTG bit in the endpoint control and status register.

Parameters
EpIDendpoint identifier
Return values
None

Definition at line 414 of file usb_regs.h.

#define _ToggleDTG_TX (   EpID)    (_SetEPxCSR(EpID, EPTX_DTG | (_GetEPxCSR(EpID) & EPCSR_MASK)))

Toggle and Clear EPTX_DTG bit in the endpoint control and status register.

Parameters
EpIDendpoint identifier
Return values
None

Definition at line 423 of file usb_regs.h.

#define _ToggleSWBUF_TX (   EpID)    _ToggleDTG_RX(EpID)

Toggle SW_BUF bit in the double buffered endpoint.

Parameters
EpIDdouble buffered endpoint identifier
Return values
None

Definition at line 432 of file usb_regs.h.

Generated on Fri Feb 6 2015 14:56:36 for GD32F10x USB-Device by   doxygen 1.8.8