em_can.h File Reference

Controller Area Network API.

Version
5.4.0

License

Copyright 2016 Silicon Laboratories, Inc. www.silabs.com

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no obligation to support this Software. Silicon Labs is providing the Software "AS IS", with no express or implied warranties of any kind, including, but not limited to, any implied warranties of merchantability or fitness for any particular purpose or warranties against infringement of any proprietary rights of a third party.

Silicon Labs will not be liable for any consequential, incidental, or special damages, or any other relief, or for any claim by any third party, arising from your use of this Software.

Definition in file em_can.h .

#include " em_bus.h "
#include " em_device.h "
#include <stdbool.h>

Data Structures

struct CAN_Init_TypeDef
struct CAN_MessageObject_TypeDef

Macros

#define CAN_INIT_DEFAULT

Enumerations

enum CAN_ErrorCode_TypeDef {
canErrorNoError = CAN_STATUS_LEC_NONE,
canErrorStuff = CAN_STATUS_LEC_STUFF,
canErrorForm = CAN_STATUS_LEC_FORM,
canErrorAck = CAN_STATUS_LEC_ACK,
canErrorBit1 = CAN_STATUS_LEC_BIT1,
canErrorBit0 = CAN_STATUS_LEC_BIT0,
canErrorCrc = CAN_STATUS_LEC_CRC,
canErrorUnused = CAN_STATUS_LEC_UNUSED
}
enum CAN_Mode_TypeDef {
canModeNormal ,
canModeBasic ,
canModeLoopBack ,
canModeSilentLoopBack ,
canModeSilent
}

Functions

void CAN_AbortSendMessage ( CAN_TypeDef *can, uint8_t interface, uint8_t msgNum, bool wait)
Abort the sending of a message.
void CAN_ConfigureMessageObject ( CAN_TypeDef *can, uint8_t interface, uint8_t msgNum, bool valid, bool tx, bool remoteTransfer, bool endOfBuffer, bool wait)
Configure valid, tx/rx, remoteTransfer for a specific Message Object.
__STATIC_INLINE void CAN_Enable ( CAN_TypeDef *can, bool enable)
Enable the Host Controller to send messages.
uint32_t CAN_GetClockFrequency ( CAN_TypeDef *can)
Get the CAN module frequency.
__STATIC_INLINE uint32_t CAN_GetErrorCount ( CAN_TypeDef *can)
Get the error count.
__STATIC_INLINE CAN_ErrorCode_TypeDef CAN_GetLastErrorCode ( CAN_TypeDef *can)
Get the last error code and clear its register.
__STATIC_INLINE uint32_t CAN_HasNewdata ( CAN_TypeDef *can)
Indicates which messages objects have received new data.
void CAN_Init ( CAN_TypeDef *can, const CAN_Init_TypeDef *init)
Initialize CAN.
__STATIC_INLINE bool CAN_IsEnabled ( CAN_TypeDef *can)
Gives the communication capabilities state.
__STATIC_INLINE void CAN_MessageIntClear ( CAN_TypeDef *can, uint32_t flags)
Clear one or more pending CAN message interrupts.
__STATIC_INLINE void CAN_MessageIntDisable ( CAN_TypeDef *can, uint32_t flags)
Disable CAN message interrupts.
__STATIC_INLINE void CAN_MessageIntEnable ( CAN_TypeDef *can, uint32_t flags)
Enable CAN message interrupts.
__STATIC_INLINE uint32_t CAN_MessageIntGet ( CAN_TypeDef *can)
Get pending CAN message interrupt flags.
__STATIC_INLINE uint32_t CAN_MessageIntGetEnabled ( CAN_TypeDef *can)
Get CAN message interrupt flags that are pending and enabled.
__STATIC_INLINE void CAN_MessageIntSet ( CAN_TypeDef *can, uint32_t flags)
Set one or more CAN message interrupts.
bool CAN_MessageLost ( CAN_TypeDef *can, uint8_t interface, uint8_t msgNum)
Read a Message Object to find if a message was lost ; reset the 'Message Lost' flag.
void CAN_ReadMessage ( CAN_TypeDef *can, uint8_t interface, CAN_MessageObject_TypeDef *message)
Read the data from a Message Object in the RAM and store it in message.
__STATIC_INLINE void CAN_ReadyWait ( CAN_TypeDef *can, uint8_t interface)
Waiting function.
void CAN_Reset ( CAN_TypeDef *can)
Set all the CAN registers to RESETVALUE. Leave the CAN Device disabled.
void CAN_ResetMessages ( CAN_TypeDef *can, uint8_t interface)
Reset all the Message Objects and set their data to 0.
void CAN_SendMessage ( CAN_TypeDef *can, uint8_t interface, const CAN_MessageObject_TypeDef *message, bool wait)
Send the data from the Message Object message.
void CAN_SendRequest ( CAN_TypeDef *can, uint8_t interface, uint8_t msgNum, bool wait)
Send request for writing or reading the RAM of Message Object msgNum.
void CAN_SetBitTiming ( CAN_TypeDef *can, uint32_t bitrate, uint16_t propagationTimeSegment, uint16_t phaseBufferSegment1, uint16_t phaseBufferSegment2, uint16_t synchronisationJumpWidth)
Set the bitrate and its parameters.
void CAN_SetIdAndFilter ( CAN_TypeDef *can, uint8_t interface, bool useMask, const CAN_MessageObject_TypeDef *message, bool wait)
Set the Id and the filter for a specific Message Object.
void CAN_SetMode ( CAN_TypeDef *can, CAN_Mode_TypeDef mode)
Set the CAN operation mode.
void CAN_SetRoute ( CAN_TypeDef *can, bool active, uint16_t pinRxLoc, uint16_t pinTxLoc)
Set the ROUTE registers.
__STATIC_INLINE void CAN_StatusClear ( CAN_TypeDef *can, uint32_t flags)
Clear CAN status.
__STATIC_INLINE uint32_t CAN_StatusGet ( CAN_TypeDef *can)
Get CAN status.
__STATIC_INLINE void CAN_StatusIntClear ( CAN_TypeDef *can, uint32_t flags)
Clear one or more pending CAN status interrupts.
__STATIC_INLINE void CAN_StatusIntDisable ( CAN_TypeDef *can, uint32_t flags)
Disable CAN status interrupts.
__STATIC_INLINE void CAN_StatusIntEnable ( CAN_TypeDef *can, uint32_t flags)
Enable CAN status interrupts.
__STATIC_INLINE uint32_t CAN_StatusIntGet ( CAN_TypeDef *can)
Get pending CAN status interrupt flags.
__STATIC_INLINE uint32_t CAN_StatusIntGetEnabled ( CAN_TypeDef *can)
Get pending and enabled CAN status interrupt flags.
__STATIC_INLINE void CAN_StatusIntSet ( CAN_TypeDef *can, uint32_t flags)
Set one or more CAN status interrupts.
void CAN_WriteData ( CAN_TypeDef *can, uint8_t interface, const CAN_MessageObject_TypeDef *message)
Write the data from message to the MIRx registers.