STM32F439xx HAL User Manual
Functions
Control functions
CAN Exported Functions

Control functions. More...

Functions

HAL_StatusTypeDef HAL_CAN_Start (CAN_HandleTypeDef *hcan)
 Start the CAN module.
HAL_StatusTypeDef HAL_CAN_Stop (CAN_HandleTypeDef *hcan)
 Stop the CAN module and enable access to configuration registers.
HAL_StatusTypeDef HAL_CAN_RequestSleep (CAN_HandleTypeDef *hcan)
 Request the sleep mode (low power) entry.
HAL_StatusTypeDef HAL_CAN_WakeUp (CAN_HandleTypeDef *hcan)
 Wake up from sleep mode.
uint32_t HAL_CAN_IsSleepActive (CAN_HandleTypeDef *hcan)
 Check is sleep mode is active.
HAL_StatusTypeDef HAL_CAN_AddTxMessage (CAN_HandleTypeDef *hcan, CAN_TxHeaderTypeDef *pHeader, uint8_t aData[], uint32_t *pTxMailbox)
 Add a message to the first free Tx mailbox and activate the corresponding transmission request.
HAL_StatusTypeDef HAL_CAN_AbortTxRequest (CAN_HandleTypeDef *hcan, uint32_t TxMailboxes)
 Abort transmission requests.
uint32_t HAL_CAN_GetTxMailboxesFreeLevel (CAN_HandleTypeDef *hcan)
 Return Tx Mailboxes free level: number of free Tx Mailboxes.
uint32_t HAL_CAN_IsTxMessagePending (CAN_HandleTypeDef *hcan, uint32_t TxMailboxes)
 Check if a transmission request is pending on the selected Tx Mailboxes.
uint32_t HAL_CAN_GetTxTimestamp (CAN_HandleTypeDef *hcan, uint32_t TxMailbox)
 Return timestamp of Tx message sent, if time triggered communication mode is enabled.
HAL_StatusTypeDef HAL_CAN_GetRxMessage (CAN_HandleTypeDef *hcan, uint32_t RxFifo, CAN_RxHeaderTypeDef *pHeader, uint8_t aData[])
 Get an CAN frame from the Rx FIFO zone into the message RAM.
uint32_t HAL_CAN_GetRxFifoFillLevel (CAN_HandleTypeDef *hcan, uint32_t RxFifo)
 Return Rx FIFO fill level.

Detailed Description

Control functions.

  ==============================================================================
                      ##### Control functions #####
  ==============================================================================
    [..]  This section provides functions allowing to:
      (+) HAL_CAN_Start                    : Start the CAN module
      (+) HAL_CAN_Stop                     : Stop the CAN module
      (+) HAL_CAN_RequestSleep             : Request sleep mode entry.
      (+) HAL_CAN_WakeUp                   : Wake up from sleep mode.
      (+) HAL_CAN_IsSleepActive            : Check is sleep mode is active.
      (+) HAL_CAN_AddTxMessage             : Add a message to the Tx mailboxes
                                             and activate the corresponding
                                             transmission request
      (+) HAL_CAN_AbortTxRequest           : Abort transmission request
      (+) HAL_CAN_GetTxMailboxesFreeLevel  : Return Tx mailboxes free level
      (+) HAL_CAN_IsTxMessagePending       : Check if a transmission request is
                                             pending on the selected Tx mailbox
      (+) HAL_CAN_GetRxMessage             : Get a CAN frame from the Rx FIFO
      (+) HAL_CAN_GetRxFifoFillLevel       : Return Rx FIFO fill level


Function Documentation

HAL_StatusTypeDef HAL_CAN_AbortTxRequest ( CAN_HandleTypeDef hcan,
uint32_t  TxMailboxes 
)

Abort transmission requests.

Parameters:
hcanpointer to an CAN_HandleTypeDef structure that contains the configuration information for the specified CAN.
TxMailboxesList of the Tx Mailboxes to abort. This parameter can be any combination of
  • CAN_Tx_Mailboxes.
Return values:
HALstatus

Definition at line 969 of file stm32f4xx_hal_can.c.

References assert_param, CAN_TX_MAILBOX0, CAN_TX_MAILBOX1, CAN_TX_MAILBOX2, __CAN_HandleTypeDef::ErrorCode, HAL_CAN_ERROR_NOT_INITIALIZED, HAL_CAN_STATE_LISTENING, HAL_CAN_STATE_READY, __CAN_HandleTypeDef::Instance, IS_CAN_TX_MAILBOX_LIST, and __CAN_HandleTypeDef::State.

HAL_StatusTypeDef HAL_CAN_AddTxMessage ( CAN_HandleTypeDef hcan,
CAN_TxHeaderTypeDef pHeader,
uint8_t  aData[],
uint32_t *  pTxMailbox 
)

Add a message to the first free Tx mailbox and activate the corresponding transmission request.

Parameters:
hcanpointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN.
pHeaderpointer to a CAN_TxHeaderTypeDef structure.
aDataarray containing the payload of the Tx frame.
pTxMailboxpointer to a variable where the function will return the TxMailbox used to store the Tx message. This parameter can be a value of
  • CAN_Tx_Mailboxes.
Return values:
HALstatus

Definition at line 872 of file stm32f4xx_hal_can.c.

References assert_param, CAN_ID_STD, CAN_TxHeaderTypeDef::DLC, __CAN_HandleTypeDef::ErrorCode, CAN_TxHeaderTypeDef::ExtId, HAL_CAN_ERROR_NOT_INITIALIZED, HAL_CAN_ERROR_PARAM, HAL_CAN_STATE_LISTENING, HAL_CAN_STATE_READY, CAN_TxHeaderTypeDef::IDE, __CAN_HandleTypeDef::Instance, IS_CAN_DLC, IS_CAN_EXTID, IS_CAN_IDTYPE, IS_CAN_RTR, IS_CAN_STDID, CAN_TxHeaderTypeDef::RTR, __CAN_HandleTypeDef::State, CAN_TxHeaderTypeDef::StdId, and CAN_TxHeaderTypeDef::TransmitGlobalTime.

uint32_t HAL_CAN_GetRxFifoFillLevel ( CAN_HandleTypeDef hcan,
uint32_t  RxFifo 
)

Return Rx FIFO fill level.

Parameters:
hcanpointer to an CAN_HandleTypeDef structure that contains the configuration information for the specified CAN.
RxFifoRx FIFO. This parameter can be a value of
  • CAN_receive_FIFO_number.
Return values:
Numberof messages available in Rx FIFO.

Definition at line 1210 of file stm32f4xx_hal_can.c.

References assert_param, CAN_RX_FIFO0, HAL_CAN_STATE_LISTENING, HAL_CAN_STATE_READY, __CAN_HandleTypeDef::Instance, IS_CAN_RX_FIFO, and __CAN_HandleTypeDef::State.

HAL_StatusTypeDef HAL_CAN_GetRxMessage ( CAN_HandleTypeDef hcan,
uint32_t  RxFifo,
CAN_RxHeaderTypeDef pHeader,
uint8_t  aData[] 
)

Get an CAN frame from the Rx FIFO zone into the message RAM.

Parameters:
hcanpointer to an CAN_HandleTypeDef structure that contains the configuration information for the specified CAN.
RxFifoFifo number of the received message to be read. This parameter can be a value of
  • CAN_receive_FIFO_number.
pHeaderpointer to a CAN_RxHeaderTypeDef structure where the header of the Rx frame will be stored.
aDataarray where the payload of the Rx frame will be stored.
Return values:
HALstatus

Definition at line 1122 of file stm32f4xx_hal_can.c.

References assert_param, CAN_ID_STD, CAN_RX_FIFO0, CAN_RX_FIFO1, CAN_RxHeaderTypeDef::DLC, __CAN_HandleTypeDef::ErrorCode, CAN_RxHeaderTypeDef::ExtId, CAN_RxHeaderTypeDef::FilterMatchIndex, HAL_CAN_ERROR_NOT_INITIALIZED, HAL_CAN_ERROR_PARAM, HAL_CAN_STATE_LISTENING, HAL_CAN_STATE_READY, CAN_RxHeaderTypeDef::IDE, __CAN_HandleTypeDef::Instance, IS_CAN_RX_FIFO, CAN_RxHeaderTypeDef::RTR, __CAN_HandleTypeDef::State, CAN_RxHeaderTypeDef::StdId, and CAN_RxHeaderTypeDef::Timestamp.

Return Tx Mailboxes free level: number of free Tx Mailboxes.

Parameters:
hcanpointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN.
Return values:
Numberof free Tx Mailboxes.

Definition at line 1016 of file stm32f4xx_hal_can.c.

References HAL_CAN_STATE_LISTENING, HAL_CAN_STATE_READY, __CAN_HandleTypeDef::Instance, and __CAN_HandleTypeDef::State.

uint32_t HAL_CAN_GetTxTimestamp ( CAN_HandleTypeDef hcan,
uint32_t  TxMailbox 
)

Return timestamp of Tx message sent, if time triggered communication mode is enabled.

Parameters:
hcanpointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN.
TxMailboxTx Mailbox where the timestamp of message sent will be read. This parameter can be one value of
  • CAN_Tx_Mailboxes.
Return values:
Timestampof message sent from Tx Mailbox.

Definition at line 1089 of file stm32f4xx_hal_can.c.

References assert_param, HAL_CAN_STATE_LISTENING, HAL_CAN_STATE_READY, __CAN_HandleTypeDef::Instance, IS_CAN_TX_MAILBOX, and __CAN_HandleTypeDef::State.

Check is sleep mode is active.

Parameters:
hcanpointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN.
Return values:
Status
  • 0 : Sleep mode is not active.
  • 1 : Sleep mode is active.

Definition at line 842 of file stm32f4xx_hal_can.c.

References HAL_CAN_STATE_LISTENING, HAL_CAN_STATE_READY, __CAN_HandleTypeDef::Instance, and __CAN_HandleTypeDef::State.

uint32_t HAL_CAN_IsTxMessagePending ( CAN_HandleTypeDef hcan,
uint32_t  TxMailboxes 
)

Check if a transmission request is pending on the selected Tx Mailboxes.

Parameters:
hcanpointer to an CAN_HandleTypeDef structure that contains the configuration information for the specified CAN.
TxMailboxesList of Tx Mailboxes to check. This parameter can be any combination of
  • CAN_Tx_Mailboxes.
Return values:
Status
  • 0 : No pending transmission request on any selected Tx Mailboxes.
  • 1 : Pending transmission request on at least one of the selected Tx Mailbox.

Definition at line 1058 of file stm32f4xx_hal_can.c.

References assert_param, HAL_CAN_STATE_LISTENING, HAL_CAN_STATE_READY, __CAN_HandleTypeDef::Instance, IS_CAN_TX_MAILBOX_LIST, and __CAN_HandleTypeDef::State.

HAL_StatusTypeDef HAL_CAN_RequestSleep ( CAN_HandleTypeDef hcan)

Request the sleep mode (low power) entry.

When returning from this function, Sleep mode will be entered as soon as the current CAN activity (transmission or reception of a CAN frame) has been completed.

Parameters:
hcanpointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN.
Return values:
HALstatus.

Definition at line 768 of file stm32f4xx_hal_can.c.

References __CAN_HandleTypeDef::ErrorCode, HAL_CAN_ERROR_NOT_INITIALIZED, HAL_CAN_STATE_LISTENING, HAL_CAN_STATE_READY, __CAN_HandleTypeDef::Instance, and __CAN_HandleTypeDef::State.

HAL_StatusTypeDef HAL_CAN_Start ( CAN_HandleTypeDef hcan)

Start the CAN module.

Parameters:
hcanpointer to an CAN_HandleTypeDef structure that contains the configuration information for the specified CAN.
Return values:
HALstatus

Definition at line 661 of file stm32f4xx_hal_can.c.

References CAN_TIMEOUT_VALUE, __CAN_HandleTypeDef::ErrorCode, HAL_CAN_ERROR_NONE, HAL_CAN_ERROR_NOT_READY, HAL_CAN_ERROR_TIMEOUT, HAL_CAN_STATE_ERROR, HAL_CAN_STATE_LISTENING, HAL_CAN_STATE_READY, HAL_GetTick(), __CAN_HandleTypeDef::Instance, and __CAN_HandleTypeDef::State.

HAL_StatusTypeDef HAL_CAN_Stop ( CAN_HandleTypeDef hcan)

Stop the CAN module and enable access to configuration registers.

Parameters:
hcanpointer to an CAN_HandleTypeDef structure that contains the configuration information for the specified CAN.
Return values:
HALstatus

Definition at line 713 of file stm32f4xx_hal_can.c.

References CAN_TIMEOUT_VALUE, __CAN_HandleTypeDef::ErrorCode, HAL_CAN_ERROR_NOT_STARTED, HAL_CAN_ERROR_TIMEOUT, HAL_CAN_STATE_ERROR, HAL_CAN_STATE_LISTENING, HAL_CAN_STATE_READY, HAL_GetTick(), __CAN_HandleTypeDef::Instance, and __CAN_HandleTypeDef::State.

Referenced by HAL_CAN_DeInit().

HAL_StatusTypeDef HAL_CAN_WakeUp ( CAN_HandleTypeDef hcan)

Wake up from sleep mode.

When returning with HAL_OK status from this function, Sleep mode is exited.

Parameters:
hcanpointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN.
Return values:
HALstatus.

Definition at line 797 of file stm32f4xx_hal_can.c.

References __CAN_HandleTypeDef::ErrorCode, HAL_CAN_ERROR_NOT_INITIALIZED, HAL_CAN_ERROR_TIMEOUT, HAL_CAN_STATE_LISTENING, HAL_CAN_STATE_READY, __CAN_HandleTypeDef::Instance, and __CAN_HandleTypeDef::State.