AnsweredAssumed Answered

STM32L4 USB double buffer HAL bug

Question asked by Darius B on Mar 2, 2018
Latest reply on Mar 7, 2018 by Khouloud G

After some days investigation and debugging, I found bug at HAL definition.

Project was generated with CubeX v4.24, STM32L4 package version 1.11.0

 

 

@file    stm32l4xx_hal_pcd.h

 

#if 1 //darius
#define PCD_SET_EP_DBUF1_CNT(USBx, bEpNum, bDir, wCount)  { \
    if((bDir) == PCD_EP_DBUF_OUT)\
    {/* OUT endpoint */                                       \
      PCD_SET_EP_RX_CNT((USBx), (bEpNum),(wCount));           \
    }                                                         \
    else if((bDir) == PCD_EP_DBUF_IN)\
    {/* IN endpoint */                                        \
      *PCD_EP_RX_CNT((USBx), (bEpNum)) = (uint32_t)(wCount); \
    }                                                         \
  } /* SetEPDblBuf1Count */


#else// error her below
#define PCD_SET_EP_DBUF1_CNT(USBx, bEpNum, bDir, wCount)  { \
    if((bDir) == PCD_EP_DBUF_OUT)\
    {/* OUT endpoint */                                       \
      PCD_SET_EP_RX_CNT((USBx), (bEpNum),(wCount));           \
    }                                                         \
    else if((bDir) == PCD_EP_DBUF_IN)\
    {/* IN endpoint */                                        \
      *PCD_EP_TX_CNT((USBx), (bEpNum)) = (uint32_t)(wCount); \
    }                                                         \
  } /* SetEPDblBuf1Count */
#endif

 

 

Note:

Not found this bug at stm32L0 HAL  at file  stm32l0xx_hal_pcd.h ! Its Ok her and same like my correction.

 

 

#define PCD_SET_EP_DBUF1_CNT(USBx, bEpNum, bDir, wCount)  { \
    if(bDir == PCD_EP_DBUF_OUT)\
      /* OUT endpoint */ \
    {PCD_SET_EP_RX_CNT(USBx, bEpNum,wCount);}\
    else if(bDir == PCD_EP_DBUF_IN)\
      /* IN endpoint */\
      *PCD_EP_RX_CNT(USBx, bEpNum) = (uint32_t)wCount; \
  } /* SetEPDblBuf1Count */

 

I hope, then in next release this bug will be corrected in all packages.

 

BR

Darius Babrauskas

Outcomes