CAN_Exported_Functions
[CAN]

Functions

void CAN_CancelTransmit (CAN_TypeDef *CANx, uint8_t Mailbox)
 Cancels a transmit request.
void CAN_ClearFlag (CAN_TypeDef *CANx, uint32_t CAN_FLAG)
 Clears the CAN's pending flags.
void CAN_ClearITPendingBit (CAN_TypeDef *CANx, uint32_t CAN_IT)
 Clears the CANx’s interrupt pending bits.
void CAN_DBGFreeze (CAN_TypeDef *CANx, FunctionalState NewState)
 Enables or disables the DBG Freeze for CAN.
void CAN_DeInit (CAN_TypeDef *CANx)
 Deinitializes the CAN peripheral registers to their default reset values.
void CAN_FIFORelease (CAN_TypeDef *CANx, uint8_t FIFONumber)
 Releases a FIFO.
void CAN_FilterInit (CAN_FilterInitTypeDef *CAN_FilterInitStruct)
 Initializes the CAN peripheral according to the specified parameters in the CAN_FilterInitStruct.
FlagStatus CAN_GetFlagStatus (CAN_TypeDef *CANx, uint32_t CAN_FLAG)
 Checks whether the specified CAN flag is set or not.
ITStatus CAN_GetITStatus (CAN_TypeDef *CANx, uint32_t CAN_IT)
 Checks whether the specified CANx interrupt has occurred or not.
uint8_t CAN_Init (CAN_TypeDef *CANx, CAN_InitTypeDef *CAN_InitStruct)
 Initializes the CAN peripheral according to the specified parameters in the CAN_InitStruct.
void CAN_ITConfig (CAN_TypeDef *CANx, uint32_t CAN_IT, FunctionalState NewState)
 Enables or disables the specified CANx interrupts.
uint8_t CAN_MessagePending (CAN_TypeDef *CANx, uint8_t FIFONumber)
 Returns the number of pending messages.
void CAN_Receive (CAN_TypeDef *CANx, uint8_t FIFONumber, CanRxMsg *RxMessage)
 Receives a message.
void CAN_SlaveStartBank (uint8_t CAN_BankNumber)
 Select the start bank filter for slave CAN.
uint8_t CAN_Sleep (CAN_TypeDef *CANx)
 Enters the low power mode.
void CAN_StructInit (CAN_InitTypeDef *CAN_InitStruct)
 Fills each CAN_InitStruct member with its default value.
uint8_t CAN_Transmit (CAN_TypeDef *CANx, CanTxMsg *TxMessage)
 Initiates the transmission of a message.
uint8_t CAN_TransmitStatus (CAN_TypeDef *CANx, uint8_t TransmitMailbox)
 Checks the transmission of a message.
uint8_t CAN_WakeUp (CAN_TypeDef *CANx)
 Wakes the CAN up.

Function Documentation

void CAN_CancelTransmit ( CAN_TypeDef CANx,
uint8_t  Mailbox 
)

Cancels a transmit request.

Parameters:
CANx,: where x can be 1 or 2 to to select the CAN peripheral.
Mailbox,: Mailbox number.
Return values:
None. 

Definition at line 585 of file stm32f10x_can.c.

References assert_param, CAN_TSR_ABRQ0, CAN_TSR_ABRQ1, CAN_TSR_ABRQ2, IS_CAN_ALL_PERIPH, IS_CAN_TRANSMITMAILBOX, and CAN_TypeDef::TSR.

void CAN_ClearFlag ( CAN_TypeDef CANx,
uint32_t  CAN_FLAG 
)

Clears the CAN's pending flags.

Parameters:
CANx,: where x can be 1 or 2 to to select the CAN peripheral.
CAN_FLAG,: specifies the flag to clear. This parameter can be one of the following flags:

  • CAN_FLAG_RQCP0
  • CAN_FLAG_RQCP1
  • CAN_FLAG_RQCP2
  • CAN_FLAG_FF1
  • CAN_FLAG_FOV1
  • CAN_FLAG_FF0
  • CAN_FLAG_FOV0
  • CAN_FLAG_WKU
  • CAN_FLAG_SLAK
  • CAN_FLAG_LEC
Return values:
None. 

Definition at line 898 of file stm32f10x_can.c.

References assert_param, CAN_FLAG_LEC, CAN_FLAGS_RF0R, CAN_FLAGS_RF1R, CAN_FLAGS_TSR, CAN_TypeDef::ESR, IS_CAN_ALL_PERIPH, IS_CAN_CLEAR_FLAG, CAN_TypeDef::MSR, RESET, CAN_TypeDef::RF0R, CAN_TypeDef::RF1R, and CAN_TypeDef::TSR.

void CAN_ClearITPendingBit ( CAN_TypeDef CANx,
uint32_t  CAN_IT 
)

Clears the CANx’s interrupt pending bits.

Parameters:
CANx,: where x can be 1 or 2 to to select the CAN peripheral.
CAN_IT,: specifies the interrupt pending bit to clear.

  • CAN_IT_TME
  • CAN_IT_FF0
  • CAN_IT_FOV0
  • CAN_IT_FF1
  • CAN_IT_FOV1
  • CAN_IT_WKU
  • CAN_IT_SLK
  • CAN_IT_EWG
  • CAN_IT_EPV
  • CAN_IT_BOF
  • CAN_IT_LEC
  • CAN_IT_ERR
Return values:
None. 

Definition at line 1062 of file stm32f10x_can.c.

References assert_param, CAN_IT_BOF, CAN_IT_EPV, CAN_IT_ERR, CAN_IT_EWG, CAN_IT_FF0, CAN_IT_FF1, CAN_IT_FOV0, CAN_IT_FOV1, CAN_IT_LEC, CAN_IT_SLK, CAN_IT_TME, CAN_IT_WKU, CAN_MSR_ERRI, CAN_MSR_SLAKI, CAN_MSR_WKUI, CAN_RF0R_FOVR0, CAN_RF0R_FULL0, CAN_RF1R_FOVR1, CAN_RF1R_FULL1, CAN_TSR_RQCP0, CAN_TSR_RQCP1, CAN_TSR_RQCP2, CAN_TypeDef::ESR, IS_CAN_ALL_PERIPH, IS_CAN_CLEAR_IT, CAN_TypeDef::MSR, RESET, CAN_TypeDef::RF0R, CAN_TypeDef::RF1R, and CAN_TypeDef::TSR.

void CAN_DBGFreeze ( CAN_TypeDef CANx,
FunctionalState  NewState 
)

Enables or disables the DBG Freeze for CAN.

Parameters:
CANx,: where x can be 1 or 2 to to select the CAN peripheral.
NewState,: new state of the CAN peripheral. This parameter can be: ENABLE or DISABLE.
Return values:
None. 

Definition at line 703 of file stm32f10x_can.c.

References assert_param, DISABLE, IS_CAN_ALL_PERIPH, IS_FUNCTIONAL_STATE, CAN_TypeDef::MCR, and MCR_DBF.

void CAN_DeInit ( CAN_TypeDef CANx  ) 

Deinitializes the CAN peripheral registers to their default reset values.

Parameters:
CANx,: where x can be 1 or 2 to select the CAN peripheral.
Return values:
None. 

Definition at line 114 of file stm32f10x_can.c.

References assert_param, CAN1, DISABLE, ENABLE, IS_CAN_ALL_PERIPH, RCC_APB1Periph_CAN1, RCC_APB1Periph_CAN2, and RCC_APB1PeriphResetCmd().

Referenced by CAN_Config(), CAN_Interrupt(), and CAN_Polling().

void CAN_FIFORelease ( CAN_TypeDef CANx,
uint8_t  FIFONumber 
)

Releases a FIFO.

Parameters:
CANx,: where x can be 1 or 2 to to select the CAN peripheral.
FIFONumber,: FIFO to release, CAN_FIFO0 or CAN_FIFO1.
Return values:
None. 

Definition at line 610 of file stm32f10x_can.c.

References assert_param, CAN_FIFO0, CAN_RF0R_RFOM0, CAN_RF1R_RFOM1, IS_CAN_ALL_PERIPH, IS_CAN_FIFO, CAN_TypeDef::RF0R, and CAN_TypeDef::RF1R.

Referenced by CAN_Receive().

void CAN_FilterInit ( CAN_FilterInitTypeDef CAN_FilterInitStruct  ) 
FlagStatus CAN_GetFlagStatus ( CAN_TypeDef CANx,
uint32_t  CAN_FLAG 
)

Checks whether the specified CAN flag is set or not.

Parameters:
CANx,: where x can be 1 or 2 to to select the CAN peripheral.
CAN_FLAG,: specifies the flag to check. This parameter can be one of the following flags:

  • CAN_FLAG_EWG
  • CAN_FLAG_EPV
  • CAN_FLAG_BOF
  • CAN_FLAG_RQCP0
  • CAN_FLAG_RQCP1
  • CAN_FLAG_RQCP2
  • CAN_FLAG_FMP1
  • CAN_FLAG_FF1
  • CAN_FLAG_FOV1
  • CAN_FLAG_FMP0
  • CAN_FLAG_FF0
  • CAN_FLAG_FOV0
  • CAN_FLAG_WKU
  • CAN_FLAG_SLAK
  • CAN_FLAG_LEC
Return values:
The new state of CAN_FLAG (SET or RESET).

Definition at line 798 of file stm32f10x_can.c.

References assert_param, CAN_FLAGS_ESR, CAN_FLAGS_MSR, CAN_FLAGS_RF0R, CAN_FLAGS_TSR, CAN_TypeDef::ESR, IS_CAN_ALL_PERIPH, IS_CAN_GET_FLAG, CAN_TypeDef::MSR, RESET, CAN_TypeDef::RF0R, CAN_TypeDef::RF1R, SET, and CAN_TypeDef::TSR.

ITStatus CAN_GetITStatus ( CAN_TypeDef CANx,
uint32_t  CAN_IT 
)

Checks whether the specified CANx interrupt has occurred or not.

Parameters:
CANx,: where x can be 1 or 2 to to select the CAN peripheral.
CAN_IT,: specifies the CAN interrupt source to check. This parameter can be one of the following flags:

  • CAN_IT_TME
  • CAN_IT_FMP0
  • CAN_IT_FF0
  • CAN_IT_FOV0
  • CAN_IT_FMP1
  • CAN_IT_FF1
  • CAN_IT_FOV1
  • CAN_IT_WKU
  • CAN_IT_SLK
  • CAN_IT_EWG
  • CAN_IT_EPV
  • CAN_IT_BOF
  • CAN_IT_LEC
  • CAN_IT_ERR
Return values:
The current state of CAN_IT (SET or RESET).

Definition at line 958 of file stm32f10x_can.c.

References assert_param, CAN_ESR_BOFF, CAN_ESR_EPVF, CAN_ESR_EWGF, CAN_ESR_LEC, CAN_IT_BOF, CAN_IT_EPV, CAN_IT_ERR, CAN_IT_EWG, CAN_IT_FF0, CAN_IT_FF1, CAN_IT_FMP0, CAN_IT_FMP1, CAN_IT_FOV0, CAN_IT_FOV1, CAN_IT_LEC, CAN_IT_SLK, CAN_IT_TME, CAN_IT_WKU, CAN_MSR_ERRI, CAN_MSR_SLAKI, CAN_MSR_WKUI, CAN_RF0R_FMP0, CAN_RF0R_FOVR0, CAN_RF0R_FULL0, CAN_RF1R_FMP1, CAN_RF1R_FOVR1, CAN_RF1R_FULL1, CAN_TSR_RQCP0, CAN_TSR_RQCP1, CAN_TSR_RQCP2, CheckITStatus(), CAN_TypeDef::ESR, CAN_TypeDef::IER, IS_CAN_ALL_PERIPH, IS_CAN_IT, CAN_TypeDef::MSR, RESET, CAN_TypeDef::RF0R, CAN_TypeDef::RF1R, and CAN_TypeDef::TSR.

uint8_t CAN_Init ( CAN_TypeDef CANx,
CAN_InitTypeDef CAN_InitStruct 
)

Initializes the CAN peripheral according to the specified parameters in the CAN_InitStruct.

Parameters:
CANx,: where x can be 1 or 2 to to select the CAN peripheral.
CAN_InitStruct,: pointer to a CAN_InitTypeDef structure that contains the configuration information for the CAN peripheral.
Return values:
Constant indicates initialization succeed which will be CANINITFAILED or CANINITOK.

Definition at line 144 of file stm32f10x_can.c.

References assert_param, CAN_TypeDef::BTR, CAN_InitTypeDef::CAN_ABOM, CAN_InitTypeDef::CAN_AWUM, CAN_InitTypeDef::CAN_BS1, CAN_InitTypeDef::CAN_BS2, CAN_MCR_ABOM, CAN_MCR_AWUM, CAN_MCR_INRQ, CAN_MCR_NART, CAN_MCR_RFLM, CAN_MCR_SLEEP, CAN_MCR_TTCM, CAN_MCR_TXFP, CAN_InitTypeDef::CAN_Mode, CAN_MSR_INAK, CAN_InitTypeDef::CAN_NART, CAN_InitTypeDef::CAN_Prescaler, CAN_InitTypeDef::CAN_RFLM, CAN_InitTypeDef::CAN_SJW, CAN_InitTypeDef::CAN_TTCM, CAN_InitTypeDef::CAN_TXFP, CANINITFAILED, CANINITOK, ENABLE, INAK_TIMEOUT, IS_CAN_ALL_PERIPH, IS_CAN_BS1, IS_CAN_BS2, IS_CAN_MODE, IS_CAN_PRESCALER, IS_CAN_SJW, IS_FUNCTIONAL_STATE, CAN_TypeDef::MCR, and CAN_TypeDef::MSR.

Referenced by CAN_Config(), CAN_Interrupt(), and CAN_Polling().

void CAN_ITConfig ( CAN_TypeDef CANx,
uint32_t  CAN_IT,
FunctionalState  NewState 
)

Enables or disables the specified CANx interrupts.

Parameters:
CANx,: where x can be 1 or 2 to to select the CAN peripheral.
CAN_IT,: specifies the CAN interrupt sources to be enabled or disabled. This parameter can be: -CAN_IT_TME, -CAN_IT_FMP0, -CAN_IT_FF0, -CAN_IT_FOV0, -CAN_IT_FMP1, -CAN_IT_FF1, -CAN_IT_FOV1, -CAN_IT_EWG, -CAN_IT_EPV, -CAN_IT_LEC, -CAN_IT_ERR, -CAN_IT_WKU or -CAN_IT_SLK.
NewState,: new state of the CAN interrupts. This parameter can be: ENABLE or DISABLE.
Return values:
None. 

Definition at line 439 of file stm32f10x_can.c.

References assert_param, DISABLE, CAN_TypeDef::IER, IS_CAN_ALL_PERIPH, IS_CAN_IT, and IS_FUNCTIONAL_STATE.

Referenced by CAN_Interrupt(), and main().

uint8_t CAN_MessagePending ( CAN_TypeDef CANx,
uint8_t  FIFONumber 
)

Returns the number of pending messages.

Parameters:
CANx,: where x can be 1 or 2 to to select the CAN peripheral.
FIFONumber,: Receive FIFO number, CAN_FIFO0 or CAN_FIFO1.
Return values:
NbMessage which is the number of pending message.

Definition at line 633 of file stm32f10x_can.c.

References assert_param, CAN_FIFO0, CAN_FIFO1, IS_CAN_ALL_PERIPH, IS_CAN_FIFO, CAN_TypeDef::RF0R, and CAN_TypeDef::RF1R.

Referenced by CAN_Polling().

void CAN_Receive ( CAN_TypeDef CANx,
uint8_t  FIFONumber,
CanRxMsg RxMessage 
)

Receives a message.

Parameters:
CANx,: where x can be 1 or 2 to to select the CAN peripheral.
FIFONumber,: Receive FIFO number, CAN_FIFO0 or CAN_FIFO1.
RxMessage,: pointer to a structure receive message which contains CAN Id, CAN DLC, CAN datas and FMI number.
Return values:
None. 

Definition at line 662 of file stm32f10x_can.c.

References assert_param, CAN_FIFORelease(), CAN_ID_STD, CanRxMsg::Data, CanRxMsg::DLC, CanRxMsg::ExtId, CanRxMsg::FMI, CanRxMsg::IDE, IS_CAN_ALL_PERIPH, IS_CAN_FIFO, CAN_FIFOMailBox_TypeDef::RDHR, CAN_FIFOMailBox_TypeDef::RDLR, CAN_FIFOMailBox_TypeDef::RDTR, CAN_FIFOMailBox_TypeDef::RIR, CanRxMsg::RTR, CAN_TypeDef::sFIFOMailBox, and CanRxMsg::StdId.

Referenced by CAN1_RX0_IRQHandler(), CAN2_RX0_IRQHandler(), CAN_Polling(), and USB_LP_CAN1_RX0_IRQHandler().

void CAN_SlaveStartBank ( uint8_t  CAN_BankNumber  ) 

Select the start bank filter for slave CAN.

Note:
This function applies only to STM32 Connectivity line devices.
Parameters:
CAN_BankNumber,: Select the start slave bank filter from 1..27.
Return values:
None. 

Definition at line 404 of file stm32f10x_can.c.

References assert_param, CAN1, FMR_FINIT, and IS_CAN_BANKNUMBER.

uint8_t CAN_Sleep ( CAN_TypeDef CANx  ) 

Enters the low power mode.

Parameters:
CANx,: where x can be 1 or 2 to to select the CAN peripheral.
Return values:
CANSLEEPOK if sleep entered, CANSLEEPFAILED in an other case.

Definition at line 726 of file stm32f10x_can.c.

References assert_param, CAN_MCR_INRQ, CAN_MCR_SLEEP, CAN_MSR_INAK, CAN_MSR_SLAK, CANSLEEPFAILED, CANSLEEPOK, IS_CAN_ALL_PERIPH, CAN_TypeDef::MCR, and CAN_TypeDef::MSR.

void CAN_StructInit ( CAN_InitTypeDef CAN_InitStruct  ) 
uint8_t CAN_Transmit ( CAN_TypeDef CANx,
CanTxMsg TxMessage 
)

Initiates the transmission of a message.

Parameters:
CANx,: where x can be 1 or 2 to to select the CAN peripheral.
TxMessage,: pointer to a structure which contains CAN Id, CAN DLC and CAN datas.
Return values:
The number of the mailbox that is used for transmission or CAN_NO_MB if there is no empty mailbox.

Definition at line 466 of file stm32f10x_can.c.

References assert_param, CAN_ID_STD, CAN_NO_MB, CAN_TSR_TME0, CAN_TSR_TME1, CAN_TSR_TME2, CanTxMsg::Data, CanTxMsg::DLC, CanTxMsg::ExtId, CanTxMsg::IDE, IS_CAN_ALL_PERIPH, IS_CAN_DLC, IS_CAN_EXTID, IS_CAN_IDTYPE, IS_CAN_RTR, IS_CAN_STDID, CanTxMsg::RTR, CanTxMsg::StdId, CAN_TypeDef::sTxMailBox, CAN_TxMailBox_TypeDef::TDHR, CAN_TxMailBox_TypeDef::TDLR, CAN_TxMailBox_TypeDef::TDTR, CAN_TxMailBox_TypeDef::TIR, TMIDxR_TXRQ, and CAN_TypeDef::TSR.

Referenced by CAN_Interrupt(), CAN_Polling(), and main().

uint8_t CAN_TransmitStatus ( CAN_TypeDef CANx,
uint8_t  TransmitMailbox 
)

Checks the transmission of a message.

Parameters:
CANx,: where x can be 1 or 2 to to select the CAN peripheral.
TransmitMailbox,: the number of the mailbox that is used for transmission.
Return values:
CANTXOK if the CAN driver transmits the message, CANTXFAILED in an other case.

Definition at line 536 of file stm32f10x_can.c.

References assert_param, CAN_TSR_RQCP0, CAN_TSR_RQCP1, CAN_TSR_RQCP2, CAN_TSR_TME0, CAN_TSR_TME1, CAN_TSR_TME2, CAN_TSR_TXOK0, CAN_TSR_TXOK1, CAN_TSR_TXOK2, CANTXFAILED, CANTXOK, CANTXPENDING, IS_CAN_ALL_PERIPH, IS_CAN_TRANSMITMAILBOX, and CAN_TypeDef::TSR.

Referenced by CAN_Polling().

uint8_t CAN_WakeUp ( CAN_TypeDef CANx  ) 

Wakes the CAN up.

Parameters:
CANx,: where x can be 1 or 2 to to select the CAN peripheral.
Return values:
CANWAKEUPOK if sleep mode left, CANWAKEUPFAILED in an other case.

Definition at line 751 of file stm32f10x_can.c.

References assert_param, CAN_MCR_SLEEP, CAN_MSR_SLAK, CANWAKEUPFAILED, CANWAKEUPOK, IS_CAN_ALL_PERIPH, CAN_TypeDef::MCR, CAN_TypeDef::MSR, and SLAK_TIMEOUT.

STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32