AnsweredAssumed Answered

Bug in ST HAL CAN: pTxMsg, pRxMsg and pRx1Msg never initialized

Question asked by Micah Richert on Jul 4, 2017
Latest reply on Oct 12, 2017 by walker.dave
Branched to a new discussion

CanTxMsgTypeDef*  pTxMsg, pRxMsg and pRx1Msg in CAN_HandleTypeDef are never initialized.


I am convinced that they shouldn't be pointers and should just be defined as part of the structure directly, as in:

typedef struct
  CAN_TypeDef                 *Instance;  /*!< Register base address          */
  CAN_InitTypeDef             Init;       /*!< CAN required parameters        */
  CanTxMsgTypeDef             TxMsg;     /*!< Rransmit structure  */
  CanRxMsgTypeDef             RxMsg;     /*!< Reception structure for RX FIFO0 msg */
  CanRxMsgTypeDef             Rx1Msg;    /*!< Reception structure for RX FIFO1 msg */
  __IO HAL_CAN_StateTypeDef   State;      /*!< CAN communication state        */
  HAL_LockTypeDef             Lock;       /*!< CAN locking object             */
  __IO uint32_t               ErrorCode;  /*!< CAN Error code                 */


See attached diff file for the complete fix.  I am using STM32Cube_FW_F4_V1.16.0 but I am pretty sure this applies to many older versions.