|
|
@@ -83,9 +83,9 @@
|
|
|
|
|
|
// For purposes of accessing the packet
|
|
|
#if ((PMA_LENGTH) == 512u)
|
|
|
-# define PMA_STRIDE (2u)
|
|
|
+const size_t PMA_STRIDE = 2u;
|
|
|
#elif ((PMA_LENGTH) == 1024u)
|
|
|
-# define PMA_STRIDE (1u)
|
|
|
+const size_t PMA_STRIDE = 1u;
|
|
|
#endif
|
|
|
|
|
|
// And for type-safety create a new macro for the volatile address of PMAADDR
|
|
|
@@ -93,32 +93,75 @@
|
|
|
// Volatile is also needed to prevent the optimizer from changing access to 32-bit (as 32-bit access is forbidden)
|
|
|
static __IO uint16_t * const pma = (__IO uint16_t*)USB_PMAADDR;
|
|
|
|
|
|
+// prototypes
|
|
|
+static inline __IO uint16_t* pcd_ep_rx_cnt_ptr(USB_TypeDef * USBx, unsigned int bEpNum);
|
|
|
+static inline __IO uint16_t* pcd_ep_tx_cnt_ptr(USB_TypeDef * USBx, unsigned int bEpNum);
|
|
|
+static inline void pcd_set_endpoint(USB_TypeDef * USBx, unsigned int bEpNum, unsigned int wRegValue);
|
|
|
+
|
|
|
+
|
|
|
/* SetENDPOINT */
|
|
|
-#define PCD_SET_ENDPOINT(USBx, bEpNum,wRegValue) (*((__IO uint16_t *)(((uint32_t)(&(USBx)->EP0R + (bEpNum) * 2U))))= (uint16_t)(wRegValue))
|
|
|
+static inline void pcd_set_endpoint(USB_TypeDef * USBx, unsigned int bEpNum, unsigned int wRegValue)
|
|
|
+{
|
|
|
+ __O uint16_t *reg = (__O uint16_t *)((&USBx->EP0R) + bEpNum*2u);
|
|
|
+ *reg = (uint16_t)wRegValue;
|
|
|
+}
|
|
|
+
|
|
|
/* GetENDPOINT */
|
|
|
-#define PCD_GET_ENDPOINT(USBx, bEpNum) (*((__IO uint16_t *)(((uint32_t)(&(USBx)->EP0R + (bEpNum) * 2U)))))
|
|
|
-#define PCD_SET_EPTYPE(USBx, bEpNum,wType) (PCD_SET_ENDPOINT((USBx), (bEpNum),\
|
|
|
- (((((uint32_t)(PCD_GET_ENDPOINT((USBx), (bEpNum)))) & ((uint32_t)(USB_EP_T_MASK))) | ((uint32_t)(wType))) | USB_EP_CTR_RX | USB_EP_CTR_TX)))
|
|
|
-#define PCD_GET_EPTYPE(USBx, bEpNum) (((uint16_t)(PCD_GET_ENDPOINT((USBx), (bEpNum)))) & USB_EP_T_FIELD)
|
|
|
+static inline uint16_t pcd_get_endpoint(USB_TypeDef * USBx, unsigned int bEpNum) {
|
|
|
+ __I uint16_t *reg = (__I uint16_t *)((&USBx->EP0R) + bEpNum*2u);
|
|
|
+ return *reg;
|
|
|
+}
|
|
|
+
|
|
|
+static inline void pcd_set_eptype(USB_TypeDef * USBx, unsigned int bEpNum, unsigned int wType)
|
|
|
+{
|
|
|
+ unsigned int regVal = pcd_get_endpoint(USBx, bEpNum);
|
|
|
+ regVal &= (uint32_t)USB_EP_T_MASK;
|
|
|
+ regVal |= wType;
|
|
|
+ regVal |= USB_EP_CTR_RX | USB_EP_CTR_TX; // These clear on write0, so must set high
|
|
|
+ pcd_set_endpoint(USBx, bEpNum, regVal);
|
|
|
+}
|
|
|
|
|
|
+static inline unsigned int pcd_get_eptype(USB_TypeDef * USBx, unsigned int bEpNum)
|
|
|
+{
|
|
|
+ unsigned int regVal = pcd_get_endpoint(USBx, bEpNum);
|
|
|
+ regVal &= USB_EP_T_FIELD;
|
|
|
+ return regVal;
|
|
|
+}
|
|
|
/**
|
|
|
* @brief Clears bit CTR_RX / CTR_TX in the endpoint register.
|
|
|
* @param USBx USB peripheral instance register address.
|
|
|
* @param bEpNum Endpoint Number.
|
|
|
* @retval None
|
|
|
*/
|
|
|
-#define PCD_CLEAR_RX_EP_CTR(USBx, bEpNum) (PCD_SET_ENDPOINT((USBx), (bEpNum),\
|
|
|
- PCD_GET_ENDPOINT((USBx), (bEpNum)) & 0x7FFFU & USB_EPREG_MASK))
|
|
|
-#define PCD_CLEAR_TX_EP_CTR(USBx, bEpNum) (PCD_SET_ENDPOINT((USBx), (bEpNum),\
|
|
|
- PCD_GET_ENDPOINT((USBx), (bEpNum)) & 0xFF7FU & USB_EPREG_MASK))
|
|
|
+static inline void pcd_clear_rx_ep_ctr(USB_TypeDef * USBx, unsigned int bEpNum)
|
|
|
+{
|
|
|
+ unsigned int regVal = pcd_get_endpoint(USBx, bEpNum);
|
|
|
+ regVal &= 0x7FFFu & USB_EPREG_MASK;
|
|
|
+ pcd_set_endpoint(USBx, bEpNum, regVal);
|
|
|
+}
|
|
|
+static inline void pcd_clear_tx_ep_ctr(USB_TypeDef * USBx, unsigned int bEpNum)
|
|
|
+{
|
|
|
+ unsigned int regVal = pcd_get_endpoint(USBx, bEpNum);
|
|
|
+ regVal &= regVal & 0xFF7FU & USB_EPREG_MASK;
|
|
|
+ pcd_set_endpoint(USBx, bEpNum,regVal);
|
|
|
+}
|
|
|
/**
|
|
|
* @brief gets counter of the tx buffer.
|
|
|
* @param USBx USB peripheral instance register address.
|
|
|
* @param bEpNum Endpoint Number.
|
|
|
* @retval Counter value
|
|
|
*/
|
|
|
-#define PCD_GET_EP_TX_CNT(USBx, bEpNum)((uint16_t)(*PCD_EP_TX_CNT_PTR((USBx), (bEpNum))) & 0x3ffU)
|
|
|
-#define PCD_GET_EP_RX_CNT(USBx, bEpNum)((uint16_t)(*PCD_EP_RX_CNT_PTR((USBx), (bEpNum))) & 0x3ffU)
|
|
|
+static inline unsigned int pcd_get_ep_tx_cnt(USB_TypeDef * USBx, unsigned int bEpNum)
|
|
|
+{
|
|
|
+ __I uint16_t *regPtr = pcd_ep_tx_cnt_ptr(USBx, bEpNum);
|
|
|
+ return *regPtr & 0x3ffU;
|
|
|
+}
|
|
|
+
|
|
|
+static inline unsigned int pcd_get_ep_rx_cnt(USB_TypeDef * USBx, unsigned int bEpNum)
|
|
|
+{
|
|
|
+ __I uint16_t *regPtr = pcd_ep_rx_cnt_ptr(USBx, bEpNum);
|
|
|
+ return *regPtr & 0x3ffU;
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
* @brief Sets counter of rx buffer with no. of blocks.
|
|
|
@@ -127,38 +170,30 @@ static __IO uint16_t * const pma = (__IO uint16_t*)USB_PMAADDR;
|
|
|
* @param wNBlocks no. of Blocks.
|
|
|
* @retval None
|
|
|
*/
|
|
|
-#define PCD_CALC_BLK32(dwReg,wCount,wNBlocks) {\
|
|
|
- (wNBlocks) = (uint32_t)((wCount) >> 5U);\
|
|
|
- if(((wCount) & 0x1fU) == 0U)\
|
|
|
- { \
|
|
|
- (wNBlocks)--;\
|
|
|
- } \
|
|
|
- *pdwReg = (uint16_t)((uint16_t)((wNBlocks) << 10U) | (uint16_t)0x8000U); \
|
|
|
- }/* PCD_CALC_BLK32 */
|
|
|
-
|
|
|
-
|
|
|
-#define PCD_CALC_BLK2(dwReg,wCount,wNBlocks) {\
|
|
|
- (wNBlocks) = (uint32_t)((wCount) >> 1U); \
|
|
|
- if(((wCount) & 0x1U) != 0U)\
|
|
|
- { \
|
|
|
- (wNBlocks)++;\
|
|
|
- } \
|
|
|
- *pdwReg = (uint16_t)((wNBlocks) << 10U);\
|
|
|
- }/* PCD_CALC_BLK2 */
|
|
|
-
|
|
|
-
|
|
|
-#define PCD_SET_EP_CNT_RX_REG(dwReg,wCount) {\
|
|
|
- uint32_t wNBlocks;\
|
|
|
- if((wCount) > 62U) \
|
|
|
- { \
|
|
|
- PCD_CALC_BLK32((dwReg),(wCount),wNBlocks) \
|
|
|
- } \
|
|
|
- else \
|
|
|
- { \
|
|
|
- PCD_CALC_BLK2((dwReg),(wCount),wNBlocks) \
|
|
|
- } \
|
|
|
- }/* PCD_SET_EP_CNT_RX_REG */
|
|
|
|
|
|
+static inline void pcd_set_ep_cnt_rx_reg(__O uint16_t * pdwReg, size_t wCount) {
|
|
|
+ unsigned int wNBlocks;
|
|
|
+ if(wCount > 62u)
|
|
|
+ {
|
|
|
+ wNBlocks = wCount >> 5u;
|
|
|
+ if((wCount & 0x1fU) == 0u)
|
|
|
+ {
|
|
|
+ wNBlocks--;
|
|
|
+ }
|
|
|
+ wNBlocks = wNBlocks << 10u;
|
|
|
+ wNBlocks |= 0x8000u; // Mark block size as 32byte
|
|
|
+ *pdwReg = (uint16_t)wNBlocks;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ wNBlocks = wCount >> 1u;
|
|
|
+ if((wCount & 0x1U) != 0u)
|
|
|
+ {
|
|
|
+ wNBlocks++;
|
|
|
+ }
|
|
|
+ *pdwReg = (uint16_t)((wNBlocks) << 10u);
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -168,23 +203,52 @@ static __IO uint16_t * const pma = (__IO uint16_t*)USB_PMAADDR;
|
|
|
* @param bAddr Address.
|
|
|
* @retval None
|
|
|
*/
|
|
|
-#define PCD_SET_EP_ADDRESS(USBx, bEpNum,bAddr) PCD_SET_ENDPOINT((USBx), (bEpNum),\
|
|
|
- USB_EP_CTR_RX|USB_EP_CTR_TX|(((uint32_t)(PCD_GET_ENDPOINT((USBx), (bEpNum)))) & USB_EPREG_MASK) | (bAddr))
|
|
|
+static inline void pcd_set_ep_address(USB_TypeDef * USBx, unsigned int bEpNum, unsigned int bAddr)
|
|
|
+{
|
|
|
+ unsigned int regVal = pcd_get_endpoint(USBx, bEpNum);
|
|
|
+ regVal &= USB_EPREG_MASK;
|
|
|
+ regVal |= bAddr;
|
|
|
+ regVal |= USB_EP_CTR_RX|USB_EP_CTR_TX;
|
|
|
+ pcd_set_endpoint(USBx, bEpNum,regVal);
|
|
|
+}
|
|
|
|
|
|
-#define PCD_BTABLE_WORD_PTR(USBx,x) (&(pma[PMA_STRIDE*((((USBx)->BTABLE)>>1) + x)]))
|
|
|
+static inline __IO uint16_t * pcd_btable_word_ptr(USB_TypeDef * USBx, size_t x)
|
|
|
+{
|
|
|
+ size_t total_word_offset = (((USBx)->BTABLE)>>1) + x;
|
|
|
+ total_word_offset *= PMA_STRIDE;
|
|
|
+ return &(pma[total_word_offset]);
|
|
|
+}
|
|
|
|
|
|
// Pointers to the PMA table entries (using the ARM address space)
|
|
|
-#define PCD_EP_TX_ADDRESS_PTR(USBx, bEpNum) (PCD_BTABLE_WORD_PTR(USBx,(bEpNum)*4u + 0u))
|
|
|
-#define PCD_EP_TX_CNT_PTR(USBx, bEpNum) (PCD_BTABLE_WORD_PTR(USBx,(bEpNum)*4u + 1u))
|
|
|
+static inline __IO uint16_t* pcd_ep_tx_address_ptr(USB_TypeDef * USBx, unsigned int bEpNum)
|
|
|
+{
|
|
|
+ return pcd_btable_word_ptr(USBx,(bEpNum)*4u + 0u);
|
|
|
+}
|
|
|
+static inline __IO uint16_t* pcd_ep_tx_cnt_ptr(USB_TypeDef * USBx, unsigned int bEpNum)
|
|
|
+{
|
|
|
+ return pcd_btable_word_ptr(USBx,(bEpNum)*4u + 1u);
|
|
|
+}
|
|
|
+
|
|
|
+static inline __IO uint16_t* pcd_ep_rx_address_ptr(USB_TypeDef * USBx, unsigned int bEpNum)
|
|
|
+{
|
|
|
+ return pcd_btable_word_ptr(USBx,(bEpNum)*4u + 2u);
|
|
|
+}
|
|
|
+
|
|
|
+static inline __IO uint16_t* pcd_ep_rx_cnt_ptr(USB_TypeDef * USBx, unsigned int bEpNum)
|
|
|
+{
|
|
|
+ return pcd_btable_word_ptr(USBx,(bEpNum)*4u + 3u);
|
|
|
+}
|
|
|
|
|
|
-#define PCD_EP_RX_ADDRESS_PTR(USBx, bEpNum) (PCD_BTABLE_WORD_PTR(USBx,(bEpNum)*4u + 2u))
|
|
|
-#define PCD_EP_RX_CNT_PTR(USBx, bEpNum) (PCD_BTABLE_WORD_PTR(USBx,(bEpNum)*4u + 3u))
|
|
|
+static inline void pcd_set_ep_tx_cnt(USB_TypeDef * USBx, unsigned int bEpNum, unsigned int wCount)
|
|
|
+{
|
|
|
+ *pcd_ep_tx_cnt_ptr(USBx, bEpNum) = (uint16_t)wCount;
|
|
|
+}
|
|
|
|
|
|
-#define PCD_SET_EP_TX_CNT(USBx, bEpNum,wCount) (*PCD_EP_TX_CNT_PTR((USBx), (bEpNum)) = (wCount))
|
|
|
-#define PCD_SET_EP_RX_CNT(USBx, bEpNum,wCount) do {\
|
|
|
- __IO uint16_t *pdwReg =PCD_EP_RX_CNT_PTR((USBx),(bEpNum)); \
|
|
|
- PCD_SET_EP_CNT_RX_REG((pdwReg), (wCount))\
|
|
|
- } while(0)
|
|
|
+static inline void pcd_set_ep_rx_cnt(USB_TypeDef * USBx, unsigned int bEpNum, unsigned int wCount)
|
|
|
+{
|
|
|
+ __IO uint16_t *pdwReg = pcd_ep_rx_cnt_ptr((USBx),(bEpNum));
|
|
|
+ pcd_set_ep_cnt_rx_reg(pdwReg, wCount);
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
* @brief sets the status for tx transfer (bits STAT_TX[1:0]).
|
|
|
@@ -193,21 +257,24 @@ static __IO uint16_t * const pma = (__IO uint16_t*)USB_PMAADDR;
|
|
|
* @param wState new state
|
|
|
* @retval None
|
|
|
*/
|
|
|
-#define PCD_SET_EP_TX_STATUS(USBx, bEpNum, wState) { register uint16_t _wRegVal;\
|
|
|
- \
|
|
|
- _wRegVal = (uint32_t) (((uint32_t)(PCD_GET_ENDPOINT((USBx), (bEpNum)))) & USB_EPTX_DTOGMASK);\
|
|
|
- /* toggle first bit ? */ \
|
|
|
- if((USB_EPTX_DTOG1 & (wState))!= 0U)\
|
|
|
- { \
|
|
|
- _wRegVal ^=(uint16_t) USB_EPTX_DTOG1; \
|
|
|
- } \
|
|
|
- /* toggle second bit ? */ \
|
|
|
- if((USB_EPTX_DTOG2 & ((uint32_t)(wState)))!= 0U) \
|
|
|
- { \
|
|
|
- _wRegVal ^=(uint16_t) USB_EPTX_DTOG2; \
|
|
|
- } \
|
|
|
- PCD_SET_ENDPOINT((USBx), (bEpNum), (((uint32_t)(_wRegVal)) | USB_EP_CTR_RX|USB_EP_CTR_TX));\
|
|
|
- } /* PCD_SET_EP_TX_STATUS */
|
|
|
+static inline void pcd_set_ep_tx_status(USB_TypeDef * USBx, unsigned int bEpNum, unsigned int wState)
|
|
|
+{
|
|
|
+ uint32_t regVal = pcd_get_endpoint(USBx, bEpNum);
|
|
|
+ regVal &= USB_EPTX_DTOGMASK;
|
|
|
+
|
|
|
+ /* toggle first bit ? */
|
|
|
+ if((USB_EPTX_DTOG1 & (wState))!= 0U)
|
|
|
+ {
|
|
|
+ regVal ^= USB_EPTX_DTOG1;
|
|
|
+ }
|
|
|
+ /* toggle second bit ? */
|
|
|
+ if((USB_EPTX_DTOG2 & ((uint32_t)(wState)))!= 0U)
|
|
|
+ {
|
|
|
+ regVal ^= USB_EPTX_DTOG2;
|
|
|
+ }
|
|
|
+ regVal |= USB_EP_CTR_RX|USB_EP_CTR_TX;
|
|
|
+ pcd_set_endpoint(USBx, bEpNum, regVal);
|
|
|
+} /* pcd_set_ep_tx_status */
|
|
|
|
|
|
/**
|
|
|
* @brief sets the status for rx transfer (bits STAT_TX[1:0])
|
|
|
@@ -216,22 +283,25 @@ static __IO uint16_t * const pma = (__IO uint16_t*)USB_PMAADDR;
|
|
|
* @param wState new state
|
|
|
* @retval None
|
|
|
*/
|
|
|
-#define PCD_SET_EP_RX_STATUS(USBx, bEpNum,wState) {\
|
|
|
- register uint16_t _wRegVal; \
|
|
|
- \
|
|
|
- _wRegVal = (uint32_t) (((uint32_t)(PCD_GET_ENDPOINT((USBx), (bEpNum)))) & USB_EPRX_DTOGMASK);\
|
|
|
- /* toggle first bit ? */ \
|
|
|
- if((USB_EPRX_DTOG1 & (wState))!= 0U) \
|
|
|
- { \
|
|
|
- _wRegVal ^= (uint16_t) USB_EPRX_DTOG1; \
|
|
|
- } \
|
|
|
- /* toggle second bit ? */ \
|
|
|
- if((USB_EPRX_DTOG2 & ((uint32_t)(wState)))!= 0U) \
|
|
|
- { \
|
|
|
- _wRegVal ^= (uint16_t) USB_EPRX_DTOG2; \
|
|
|
- } \
|
|
|
- PCD_SET_ENDPOINT((USBx), (bEpNum), (((uint32_t)(_wRegVal)) | USB_EP_CTR_RX|USB_EP_CTR_TX)); \
|
|
|
- } /* PCD_SET_EP_RX_STATUS */
|
|
|
+
|
|
|
+static inline void pcd_set_ep_rx_status(USB_TypeDef * USBx, unsigned int bEpNum, unsigned int wState)
|
|
|
+{
|
|
|
+ uint32_t regVal = pcd_get_endpoint(USBx, bEpNum);
|
|
|
+ regVal &= USB_EPRX_DTOGMASK;
|
|
|
+
|
|
|
+ /* toggle first bit ? */
|
|
|
+ if((USB_EPRX_DTOG1 & wState)!= 0U)
|
|
|
+ {
|
|
|
+ regVal ^= USB_EPRX_DTOG1;
|
|
|
+ }
|
|
|
+ /* toggle second bit ? */
|
|
|
+ if((USB_EPRX_DTOG2 & wState)!= 0U)
|
|
|
+ {
|
|
|
+ regVal ^= USB_EPRX_DTOG2;
|
|
|
+ }
|
|
|
+ regVal |= USB_EP_CTR_RX|USB_EP_CTR_TX;
|
|
|
+ pcd_set_endpoint(USBx, bEpNum, regVal);
|
|
|
+} /* pcd_set_ep_rx_status */
|
|
|
|
|
|
/**
|
|
|
* @brief Toggles DTOG_RX / DTOG_TX bit in the endpoint register.
|
|
|
@@ -239,10 +309,21 @@ static __IO uint16_t * const pma = (__IO uint16_t*)USB_PMAADDR;
|
|
|
* @param bEpNum Endpoint Number.
|
|
|
* @retval None
|
|
|
*/
|
|
|
-#define PCD_RX_DTOG(USBx, bEpNum) (PCD_SET_ENDPOINT((USBx), (bEpNum), \
|
|
|
- USB_EP_CTR_RX|USB_EP_CTR_TX|USB_EP_DTOG_RX | (((uint32_t)(PCD_GET_ENDPOINT((USBx), (bEpNum)))) & USB_EPREG_MASK)))
|
|
|
-#define PCD_TX_DTOG(USBx, bEpNum) (PCD_SET_ENDPOINT((USBx), (bEpNum), \
|
|
|
- USB_EP_CTR_RX|USB_EP_CTR_TX|USB_EP_DTOG_TX | (((uint32_t)(PCD_GET_ENDPOINT((USBx), (bEpNum)))) & USB_EPREG_MASK)))
|
|
|
+static inline void pcd_rx_dtog(USB_TypeDef * USBx, unsigned int bEpNum)
|
|
|
+{
|
|
|
+ unsigned int regVal = pcd_get_endpoint(USBx, bEpNum);
|
|
|
+ regVal &= USB_EPREG_MASK;
|
|
|
+ regVal |= USB_EP_CTR_RX|USB_EP_CTR_TX|USB_EP_DTOG_RX;
|
|
|
+ pcd_set_endpoint(USBx, bEpNum, regVal);
|
|
|
+}
|
|
|
+
|
|
|
+static inline void pcd_tx_dtog(USB_TypeDef * USBx, unsigned int bEpNum)
|
|
|
+{
|
|
|
+ unsigned int regVal = pcd_get_endpoint(USBx, bEpNum);
|
|
|
+ regVal &= USB_EPREG_MASK;
|
|
|
+ regVal |= USB_EP_CTR_RX|USB_EP_CTR_TX|USB_EP_DTOG_TX;
|
|
|
+ pcd_set_endpoint(USBx, bEpNum, regVal);
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
* @brief Clears DTOG_RX / DTOG_TX bit in the endpoint register.
|
|
|
@@ -250,14 +331,24 @@ static __IO uint16_t * const pma = (__IO uint16_t*)USB_PMAADDR;
|
|
|
* @param bEpNum Endpoint Number.
|
|
|
* @retval None
|
|
|
*/
|
|
|
-#define PCD_CLEAR_RX_DTOG(USBx, bEpNum) if((((uint32_t)(PCD_GET_ENDPOINT((USBx), (bEpNum)))) & USB_EP_DTOG_RX) != 0)\
|
|
|
- { \
|
|
|
- PCD_RX_DTOG((USBx),(bEpNum));\
|
|
|
- }
|
|
|
-#define PCD_CLEAR_TX_DTOG(USBx, bEpNum) if((((uint32_t)(PCD_GET_ENDPOINT((USBx), (bEpNum)))) & USB_EP_DTOG_TX) != 0)\
|
|
|
- {\
|
|
|
- PCD_TX_DTOG((USBx),(bEpNum));\
|
|
|
- }
|
|
|
+
|
|
|
+static inline void pcd_clear_rx_dtog(USB_TypeDef * USBx, unsigned int bEpNum)
|
|
|
+{
|
|
|
+ unsigned int regVal = pcd_get_endpoint(USBx, bEpNum);
|
|
|
+ if((regVal & USB_EP_DTOG_RX) != 0)
|
|
|
+ {
|
|
|
+ pcd_rx_dtog(USBx,bEpNum);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static inline void pcd_clear_tx_dtog(USB_TypeDef * USBx, unsigned int bEpNum)
|
|
|
+{
|
|
|
+ unsigned int regVal = pcd_get_endpoint(USBx, bEpNum);
|
|
|
+ if((regVal & USB_EP_DTOG_TX) != 0)
|
|
|
+ {
|
|
|
+ pcd_tx_dtog(USBx,bEpNum);
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
* @brief set & clear EP_KIND bit.
|
|
|
@@ -265,11 +356,22 @@ static __IO uint16_t * const pma = (__IO uint16_t*)USB_PMAADDR;
|
|
|
* @param bEpNum Endpoint Number.
|
|
|
* @retval None
|
|
|
*/
|
|
|
-#define PCD_SET_EP_KIND(USBx, bEpNum) (PCD_SET_ENDPOINT((USBx), (bEpNum), \
|
|
|
- (USB_EP_CTR_RX|USB_EP_CTR_TX|((((uint32_t)(PCD_GET_ENDPOINT((USBx), (bEpNum)))) | USB_EP_KIND) & USB_EPREG_MASK))))
|
|
|
|
|
|
-#define PCD_CLEAR_EP_KIND(USBx, bEpNum) (PCD_SET_ENDPOINT((USBx), (bEpNum), \
|
|
|
- (USB_EP_CTR_RX|USB_EP_CTR_TX|((((uint32_t)(PCD_GET_ENDPOINT((USBx), (bEpNum)))) & USB_EPKIND_MASK)))))
|
|
|
+static inline void pcd_set_ep_kind(USB_TypeDef * USBx, unsigned int bEpNum)
|
|
|
+{
|
|
|
+ unsigned int regVal = pcd_get_endpoint(USBx, bEpNum);
|
|
|
+ regVal |= USB_EP_KIND;
|
|
|
+ regVal &= USB_EPREG_MASK;
|
|
|
+ regVal |= USB_EP_CTR_RX|USB_EP_CTR_TX;
|
|
|
+ pcd_set_endpoint(USBx, bEpNum, regVal);
|
|
|
+}
|
|
|
+static inline void pcd_clear_ep_kind(USB_TypeDef * USBx, unsigned int bEpNum)
|
|
|
+{
|
|
|
+ unsigned int regVal = pcd_get_endpoint(USBx, bEpNum);
|
|
|
+ regVal &= USB_EPKIND_MASK;
|
|
|
+ regVal |= USB_EP_CTR_RX|USB_EP_CTR_TX;
|
|
|
+ pcd_set_endpoint(USBx, bEpNum, regVal);
|
|
|
+}
|
|
|
|
|
|
// This checks if the device has "LPM"
|
|
|
#if defined(USB_ISTR_L1REQ)
|
|
|
@@ -282,6 +384,6 @@ static __IO uint16_t * const pma = (__IO uint16_t*)USB_PMAADDR;
|
|
|
USB_ISTR_RESET | USB_ISTR_SOF | USB_ISTR_ESOF | USB_ISTR_L1REQ_FORCED )
|
|
|
|
|
|
// Number of endpoints in hardware
|
|
|
-#define STFSDEV_EP_COUNT (8)
|
|
|
+#define STFSDEV_EP_COUNT (8u)
|
|
|
|
|
|
#endif /* PORTABLE_ST_STM32F0_DCD_STM32F0_FSDEV_PVT_ST_H_ */
|