MG32F157 Standard Peripherals Firmware Library
Functions
CAN_Private_Functions

Functions

void CAN_DeInit (CAN_TypeDef *CANx)
 Deinitializes the CAN peripheral registers to their default reset values. More...
 
void CAN_Init (CAN_TypeDef *CANx, CAN_InitTypeDef *CAN_InitStruct)
 Initializes the CAN peripheral according to the specified parameters in the CAN_InitStruct. More...
 
void CANFD_Init (CAN_TypeDef *CANx, CANFD_InitTypeDef *CANFD_InitStruct)
 Initializes the CAN peripheral to FD Mode according to the specified parameters in the CAN_InitStruct. More...
 
void CAN_FilterInit (CAN_TypeDef *CANx, CAN_FilterInitTypeDef *CAN_FilterInitStruct)
 Initializes the CAN peripheral according to the specified. parameters in the CAN_FilterInitTypeDef. More...
 
void CAN_StructInit (CAN_InitTypeDef *CAN_InitStruct)
 Fills each CAN_InitStruct member with its default value. More...
 
void CANFD_StructInit (CANFD_InitTypeDef *CANFD_InitStruct)
 Fills each CANFD_InitTypeDef member with its default value. More...
 
void CAN_FilterStructInit (CAN_FilterInitTypeDef *CAN_FilterInitStruct)
 Fills each CANFD_InitStruct member with its default value. More...
 
void CAN_Reset (CAN_TypeDef *CANx, FunctionalState NewState)
 Set peripheral CAN to reset mode. More...
 
void CAN_SendCmd (CAN_TypeDef *CANx, uint32_t CAN_Cmd)
 Use peripheral CAN to send the transmission command. More...
 
void CAN_Transmit (CAN_TypeDef *CANx, CAN_Msg *Message, uint32_t AutoRetransmissionEnable)
 Initiates the transmission of a message in class mode. More...
 
void CAN_Receive (CAN_TypeDef *CANx, CAN_Msg *Message)
 Receives a message in class mode. More...
 
void CANFD_Transmit (CAN_TypeDef *CANx, CANFD_Msg *Message, uint32_t AutoRetransmissionEnable)
 Initiates the transmission of a message in FD mode. More...
 
void CANFD_Receive (CAN_TypeDef *CANx, CANFD_Msg *Message)
 Receives a message in FD mode. More...
 
void CAN_ITConfig (CAN_TypeDef *CANx, uint32_t CAN_IT, FunctionalState NewState)
 Enables or disables the specified CANx interrupts. More...
 
FlagStatus CAN_GetITStatus (CAN_TypeDef *CANx, uint32_t CAN_Flag)
 Checks whether the specified CAN flag is set or not. More...
 
void CAN_ClearITPendingBit (CAN_TypeDef *CANx, uint32_t CAN_Flag)
 Clears the CAN's pending flags. More...
 
FlagStatus CAN_GetFlagStatus (CAN_TypeDef *CANx, uint32_t CAN_Status)
 Checks whether the specified CAN status flag is set or not. More...
 
uint8_t CAN_GetArbitrationLosePosition (CAN_TypeDef *CANx)
 Checks CAN arbitrations lost capture position. More...
 
uint8_t CANFD_GetArbitrationErrorCount (CAN_TypeDef *CANx)
 Checks CAN arbitrations error count. More...
 
uint8_t CANFD_GetDataErrorCount (CAN_TypeDef *CANx)
 Checks CAN data error count. More...
 
FlagStatus CANFD_GetStatus (CAN_TypeDef *CANx, uint32_t CANFD_Status)
 Checks CAN FD running status. More...
 
FlagStatus CANFD_GetError (CAN_TypeDef *CANx, uint32_t CANFD_Error)
 Checks CAN FD error. More...
 
uint8_t CANFD_GetSecondarySamplePosition (CAN_TypeDef *CANx)
 Checks CAN FD Secondary Sample Position. More...
 
uint8_t CAN_GetMessageCount (CAN_TypeDef *CANx)
 Get CAN number of framed in the rxbuf. More...
 
uint8_t CAN_GetTransmitErrorCount (CAN_TypeDef *CANx)
 Get CAN Transmit Error Count. More...
 
uint8_t CAN_GetReceiveErrorCount (CAN_TypeDef *CANx)
 Get CAN Receive Error Count. More...
 

Detailed Description

Function Documentation

◆ CAN_ClearITPendingBit()

void CAN_ClearITPendingBit ( CAN_TypeDef CANx,
uint32_t  CAN_Flag 
)

Clears the CAN's pending flags.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
CAN_FLAGspecifies the flag to clear. This parameter can be one of the following flags:
  • CAN_Flag_DOI: CAN Data Overrun Interrupt Flag Bit
  • CAN_Flag_BEI: CAN Buss Error Interrupt Flag Bit
  • CAN_Flag_TI: CAN Transmission Interrupt Flag Bit
  • CAN_Flag_RI: CAN Receive Interrupt Flag Bit
  • CAN_Flag_EPI: CAN Error Passive Interrupt Flag Bit
  • CAN_Flag_EWI: CAN Error Warning Interrupt Flag Bit
  • CAN_Flag_ALI: CAN Arbitration Lost Interrupt Flag Bit
Returns
None

◆ CAN_DeInit()

void CAN_DeInit ( CAN_TypeDef CANx)

Deinitializes the CAN peripheral registers to their default reset values.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
Returns
None

◆ CAN_FilterInit()

void CAN_FilterInit ( CAN_TypeDef CANx,
CAN_FilterInitTypeDef CAN_FilterInitStruct 
)

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

Parameters
CANxwhere x can be 1 select the CAN peripheral.
CAN_FilterInitStructpointer to a CAN_FilterInitTypeDef structure that contains the configuration information.
Returns
None

◆ CAN_FilterStructInit()

void CAN_FilterStructInit ( CAN_FilterInitTypeDef CAN_FilterInitStruct)

Fills each CANFD_InitStruct member with its default value.

Parameters
CANFD_InitStructpointer to a CANFD_InitStruct structure which will be initialized
Returns
None

◆ CAN_GetArbitrationLosePosition()

uint8_t CAN_GetArbitrationLosePosition ( CAN_TypeDef CANx)

Checks CAN arbitrations lost capture position.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
Returns
The arbitrations lost capture position.

◆ CAN_GetFlagStatus()

FlagStatus CAN_GetFlagStatus ( CAN_TypeDef CANx,
uint32_t  CAN_Status 
)

Checks whether the specified CAN status flag is set or not.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
CAN_Statusspecifies the flag to check. This parameter can be one of the following flags:
  • CAN_Status_BS:CAN Bus off Status
  • CAN_Status_ES:CAN Error Status
  • CAN_Status_TS:CAN Transmit Status
  • CAN_Status_RS:CAN Receive Status
  • CAN_Status_TBS:CAN Transmit Buffer Status
  • CAN_Status_DSO:CAN Data Overrun Status
  • CAN_Status_RBS:CAN Receive Buffer Status
Returns
The new state of CAN_FLAG (SET or RESET).

◆ CAN_GetITStatus()

FlagStatus CAN_GetITStatus ( CAN_TypeDef CANx,
uint32_t  CAN_Flag 
)

Checks whether the specified CAN flag is set or not.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
CAN_FLAGspecifies the flag to check. This parameter can be one of the following flags:
  • CAN_Flag_DOI: CAN Data Overrun Interrupt Flag Bit
  • CAN_Flag_BEI: CAN Buss Error Interrupt Flag Bit
  • CAN_Flag_TI: CAN Transmission Interrupt Flag Bit
  • CAN_Flag_RI: CAN Receive Interrupt Flag Bit
  • CAN_Flag_EPI: CAN Error Passive Interrupt Flag Bit
  • CAN_Flag_EWI: CAN Error Warning Interrupt Flag Bit
  • CAN_Flag_ALI: CAN Arbitration Lost Interrupt Flag Bit
Returns
The new state of CAN_FLAG (SET or RESET).

◆ CAN_GetMessageCount()

uint8_t CAN_GetMessageCount ( CAN_TypeDef CANx)

Get CAN number of framed in the rxbuf.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
Returns
The number of data.

◆ CAN_GetReceiveErrorCount()

uint8_t CAN_GetReceiveErrorCount ( CAN_TypeDef CANx)

Get CAN Receive Error Count.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
Returns
The number of receive error.

◆ CAN_GetTransmitErrorCount()

uint8_t CAN_GetTransmitErrorCount ( CAN_TypeDef CANx)

Get CAN Transmit Error Count.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
Returns
The number of transmit error.

◆ CAN_Init()

void CAN_Init ( CAN_TypeDef CANx,
CAN_InitTypeDef CAN_InitStruct 
)

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

Parameters
CANxwhere x can be 1 select the CAN peripheral.
CAN_InitStructpointer to a CAN_InitTypeDef structure that contains the configuration information for the CAN peripheral.
Returns
None

◆ CAN_ITConfig()

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

Enables or disables the specified CANx interrupts.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
CAN_ITspecifies the CAN interrupt sources to be enabled or disabled. This parameter can be any combination of the following values:
  • CAN_IT_DOI: CAN Data Overrun Interrupt Enable
  • CAN_IT_BEI: CAN Buss Error Interrupt Enable
  • CAN_IT_TI: CAN Transmission Interrupt Enable
  • CAN_IT_RI: CAN Receive Interrupt Enable
  • CAN_IT_EPI: CAN Error Passive Interrupt Enable
  • CAN_IT_EWI: CAN Error Warning Interrupt Enable
  • CAN_IT_ALI: CAN Arbitration Lost Interrupt Enable
NewStatenew state of the CAN interrupts. This parameter can be: ENABLE or DISABLE.
Returns
None

◆ CAN_Receive()

void CAN_Receive ( CAN_TypeDef CANx,
CAN_Msg Message 
)

Receives a message in class mode.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
Messagepointer to a structure receive message.
Returns
None

◆ CAN_Reset()

void CAN_Reset ( CAN_TypeDef CANx,
FunctionalState  NewState 
)

Set peripheral CAN to reset mode.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
NewStatenew state of the CAN Reser mode. This parameter can be: ENABLE or DISABLE.
Returns
None

◆ CAN_SendCmd()

void CAN_SendCmd ( CAN_TypeDef CANx,
uint32_t  CAN_Cmd 
)

Use peripheral CAN to send the transmission command.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
CAN_Cmdspecifies the CAN transmission cmd. This parameter can be one of the following flags:
  • CAN_Cmd_TransmitAbort
  • CAN_Cmd_TransmitStart
  • CAN_Cmd_TransmitSingle
Returns
None

◆ CAN_StructInit()

void CAN_StructInit ( CAN_InitTypeDef CAN_InitStruct)

Fills each CAN_InitStruct member with its default value.

Parameters
CAN_InitStructpointer to a CAN_InitTypeDef structure which will be initialized
Returns
None

◆ CAN_Transmit()

void CAN_Transmit ( CAN_TypeDef CANx,
CAN_Msg Message,
uint32_t  AutoRetransmissionEnable 
)

Initiates the transmission of a message in class mode.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
Messagepointer to a structure which contains CAN info.
AutoRetransmissionEnableENABLE or DISABLE AutoRetransmission.
Returns
None

◆ CANFD_GetArbitrationErrorCount()

uint8_t CANFD_GetArbitrationErrorCount ( CAN_TypeDef CANx)

Checks CAN arbitrations error count.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
Returns
The arbitrations error count.

◆ CANFD_GetDataErrorCount()

uint8_t CANFD_GetDataErrorCount ( CAN_TypeDef CANx)

Checks CAN data error count.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
Returns
The data error count.

◆ CANFD_GetError()

FlagStatus CANFD_GetError ( CAN_TypeDef CANx,
uint32_t  CANFD_Error 
)

Checks CAN FD error.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
CANFD_Statusspecifies the error to check. This parameter can be one of the following flags:
  • CANFD_Error_BITERR:CAN Bit Error.
  • CANFD_Error_CRCERR:CAN Cyclic Redundancy Check Error.
  • CANFD_Error_FRMERR:CAN Form Error in Data Phase.
  • CANFD_Error_STFERR:CAN Bit filling Error.
Returns
The new state of CAN_FLAG (SET or RESET).

◆ CANFD_GetSecondarySamplePosition()

uint8_t CANFD_GetSecondarySamplePosition ( CAN_TypeDef CANx)

Checks CAN FD Secondary Sample Position.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
Returns
The Secondary Sample Position.

◆ CANFD_GetStatus()

FlagStatus CANFD_GetStatus ( CAN_TypeDef CANx,
uint32_t  CANFD_Status 
)

Checks CAN FD running status.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
CANFD_Statusspecifies the status to check. This parameter can be one of the following flags:
  • CANFD_Status_Init:CAN Init Status
  • CANFD_Status_Idle:CAN Idle Status
  • CANFD_Status_Recv:CAN Recv Status
  • CANFD_Status_Send:CAN Send Statuss
Returns
The new state of CAN_FLAG (SET or RESET).

◆ CANFD_Init()

void CANFD_Init ( CAN_TypeDef CANx,
CANFD_InitTypeDef CANFD_InitStruct 
)

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

Parameters
CANxwhere x can be 1 select the CAN peripheral.
CANFD_InitTypeDefpointer to a CANFD_InitTypeDef structure that contains the configuration information for the CAN peripheral FD Mode.
Returns
None

◆ CANFD_Receive()

void CANFD_Receive ( CAN_TypeDef CANx,
CANFD_Msg Message 
)

Receives a message in FD mode.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
Messagepointer to a structure receive message.
Returns
None

◆ CANFD_StructInit()

void CANFD_StructInit ( CANFD_InitTypeDef CANFD_InitStruct)

Fills each CANFD_InitTypeDef member with its default value.

Parameters
CANFD_InitStructpointer to a CANFD_InitTypeDef structure which will be initialized
Returns
None

◆ CANFD_Transmit()

void CANFD_Transmit ( CAN_TypeDef CANx,
CANFD_Msg Message,
uint32_t  AutoRetransmissionEnable 
)

Initiates the transmission of a message in FD mode.

Parameters
CANxwhere x can be 1 select the CAN peripheral.
Messagepointer to a structure which contains CAN FD info.
AutoRetransmissionEnableENABLE or DISABLE AutoRetransmission.
Returns
None