CARME-M4 BSP  V1.5
CAN SJA1000 Controller

CARME-M4 CAN Interface. More...

+ Collaboration diagram for CAN SJA1000 Controller:

Modules

 CARME_CAN_EXT_Ctrl
 

Files

file  can.h
 Drivers for the CAN interface. Uses the SJA1000 CAN controller on the CARME motherboard.
 
file  can.c
 Drivers for the CAN interface. Uses the SJA1000 CAN controller on the CARME motherboard.
 

Data Structures

struct  _CARME_CAN_MESSAGE
 This struct encapsulates a CAN message. More...
 
struct  _CARME_CAN_ACCEPTANCE_FILTER
 Information about the acceptance filter. More...
 

Macros

#define CARME_CAN_nCAN_INT_PORT   GPIOI
 
#define CARME_CAN_nCAN_INT_PIN   GPIO_Pin_8
 
#define CARME_CAN_nCAN_IRQn_CH   EXTI9_5_IRQn
 
#define CARME_CAN_BAUD_125K   125000
 
#define CARME_CAN_BAUD_250K   250000
 
#define CARME_CAN_BAUD_500K   500000
 
#define CARME_CAN_BAUD_1M   1000000
 
#define CARME_ERROR_CAN   CARME_ERROR_CAN_BASE + 0
 
#define CARME_ERROR_CAN_INVALID_BAUDRATE   CARME_ERROR_CAN_BASE + 1
 
#define CARME_ERROR_CAN_RXFIFO_EMPTY   CARME_ERROR_CAN_BASE + 2
 
#define CARME_ERROR_CAN_INVALID_MODE   CARME_ERROR_CAN_BASE + 3
 
#define CARME_ERROR_CAN_INVALID_OPMODE   CARME_ERROR_CAN_BASE + 4
 
#define CARME_ERROR_CAN_INVALID_ACCEPTANCE_MODE   CARME_ERROR_CAN_BASE + 5
 
#define CARME_ERROR_CAN_ERROR_STATUS   CARME_ERROR_CAN_BASE + 6
 
#define CARME_CAN_INT_BUSERR   (SJA1000_IER_BEIE)
 
#define CARME_CAN_INT_ARBIT_LOST   (SJA1000_IER_ALIE)
 
#define CARME_CAN_INT_PASSIVE   (SJA1000_IER_EPIE)
 
#define CARME_CAN_INT_WAKEUP   (SJA1000_IER_WUIE)
 
#define CARME_CAN_INT_OVERRUN   (SJA1000_IER_DOIE)
 
#define CARME_CAN_INT_ERROR   (SJA1000_IER_EIE)
 
#define CARME_CAN_INT_TX   (SJA1000_IER_TIE)
 
#define CARME_CAN_INT_RX   (SJA1000_IER_RIE)
 
#define CARME_CAN_DF_RESET   0x00
 
#define CARME_CAN_DF_NORMAL   0x01
 
#define CARME_CAN_DF_LISTEN_ONLY   0x02
 

Typedefs

typedef struct _CARME_CAN_MESSAGE CARME_CAN_MESSAGE
 This struct encapsulates a CAN message.
 
typedef struct _CARME_CAN_ACCEPTANCE_FILTER CARME_CAN_ACCEPTANCE_FILTER
 Information about the acceptance filter. More...
 
typedef void(* IRQ_CALLBACK) ()
 Pointer to a function.
 

Enumerations

enum  CARME_CAN_IRQ_CALLBACKS {
  CARME_CAN_IRQID_RX_INTERRUPT = 0, CARME_CAN_IRQID_TX_INTERRUPT, CARME_CAN_IRQID_ERROR_INTERRUPT, CARME_CAN_IRQID_DATAOVERFLOW_INTERRUPT,
  CARME_CAN_IRQID_WAKEUP_INTERRUPT, CARME_CAN_IRQID_PASSIVE_INTERRUPT, CARME_CAN_IRQID_ARITRATION_LOST_INTERRUPT, CARME_CAN_IRQID_BUS_ERROR_INTERRUPT,
  CARME_CAN_IRQID_COUNT
}
 Interrupt sources of the CAN-Controller. More...
 
enum  CARME_CAN_ACCEPTANCE_FILTER_MODE { MODE_SINGLE = 1, MODE_DUAL = 2 }
 Acceptance filter modes. More...
 

Functions

void CARME_CAN_Init (uint32_t baud, uint8_t flags)
 Initialize GPIOs and the CAN-Controller. More...
 
void CARME_CAN_InitI (uint32_t baud, uint8_t flags, uint32_t interrupts)
 Initialize GPIOs and the CAN-Controller. More...
 
ERROR_CODES CARME_CAN_Write (CARME_CAN_MESSAGE *txMsg)
 Sends a CAN-Messsage over the CAN-Bus. More...
 
ERROR_CODES CARME_CAN_Read (CARME_CAN_MESSAGE *rxMsg)
 Reads a CAN-Message from the Receive-Buffer. If no message is in the buffer, the function returns CARME_ERROR_CAN_ERROR_RXFIFO_EMPTY. More...
 
void CARME_CAN_Interrupt_Handler (void)
 This function will be called from the Interrupt-Handler on a CAN-Interrupt.
If it was not the EXTI Line from the CAN controller, then the functions MyEXTI9_5_IRQHandler is called. More...
 
void CARME_CAN_RegisterIRQCallback (enum CARME_CAN_IRQ_CALLBACKS id, IRQ_CALLBACK pIRQCallback)
 Registers a callback function. Callback functions are called in Interruptmode. Use this function after CARME_CAN_init() or CARME_CAN_initI(). More...
 
void CARME_CAN_UnregisterIRQCallback (enum CARME_CAN_IRQ_CALLBACKS id)
 Unregisters a callback function. Callback functions are called in Interruptmode. More...
 
ERROR_CODES CARME_CAN_SetMode (uint8_t flags)
 Change operating mode from the CAN-Controller. More...
 
ERROR_CODES CARME_CAN_SetBaudrate (uint32_t baud)
 Set the baudrate for the CAN-Communication. More...
 
ERROR_CODES CARME_CAN_SetAcceptaceFilter (CARME_CAN_ACCEPTANCE_FILTER *af)
 ACCEPTANCE FILTER
With the help of the acceptance filter the CAN controller is able to allow passing of received messages to the RXFIFO only when the identifier bits of the received message are equal to the predefined ones within the acceptance filter registers.
The acceptance filter is defined by the Acceptance Code Registers (ACRn) and the Acceptance Mask Registers (AMRn). The bit patterns of messages to be received are defined within the acceptance code registers. The corresponding acceptance mask registers allow to define certain bit positions to be 'don't care'. Two different filter modes are selectable within the mode register: More...
 
ERROR_CODES CARME_CAN_GetAcceptaceFilter (CARME_CAN_ACCEPTANCE_FILTER *af)
 Get the Acceptance Filter settings. More...
 
static void CARME_CAN_Write_Register (uint8_t registerAddress, uint8_t val)
 Write a value in a SJA1000 register. More...
 
static uint8_t CARME_CAN_Read_Register (uint8_t registerAddress)
 Reads a value from a SJA1000 register. More...
 
static uint8_t CARME_CAN_IsBusOn (void)
 Returns 1 if the CAN Controller is involved in bus activities
The Function checks the BS-bit in the status register of the SJA1000. More...
 
static uint8_t CARME_CAN_IsDataOverrun (void)
 Returns 1 if an data overrun occurred The Function checks the DOS-bit in the status register of the SJA1000. More...
 
static uint8_t CARME_CAN_IsError (void)
 Returns 1 if at least one of the error counters has reached or exceeded the value in the Error Warning Limit Register.
The Function checks the ES-bit in the status register of the SJA1000. More...
 
static void CARME_CAN_ClearDataOverrun (void)
 Clear Data-Overrun-Bit in the status register of the SJA1000.
 
static void CARME_CAN_AbortTransmisssion (void)
 Cancel a pending transmission request.
 
static ERROR_CODES CARME_CAN_SetErrorWarningLimit (uint8_t limit)
 Set the value of the Error Warning Limit Register. The content can only be changed in reset mode. More...
 
static void CARME_CAN_GetErrorWarningLimit (uint8_t *limit)
 Get the value of the Error Warning Limit Register. More...
 
static void CARME_CAN_GetRxErrCount (uint8_t *count)
 Get the value of the RX Error Count Register. More...
 
static void CARME_CAN_GetTxErrCount (uint8_t *count)
 Get the value of the TX Error Count Register. More...
 
static void CARME_CAN_GetArbitrationLostCapture (uint8_t *alc)
 Get the value of the TX Error Count Register. More...
 
static void CARME_CAN_GetErrorCodeCapture (uint8_t *ecc)
 Get the value of the TX Error Count Register. More...
 
static void CARME_CAN_InitSTM (void)
 Initialize the stm32f4xx GPIOs and the nCAN_INT.
The CAN interrupt is on CARME_CAN_nCAN_IRQn_CH with NVIC_IRQChannelPreemptionPriority = 0x0F and NVIC_IRQChannelSubPriority = 0x0F. More...
 
static void CARME_CAN_SetBusTiming (uint8_t btr0, uint8_t btr1)
 Set the Bus-Timing-Registers of the SJA1000 directly. More...
 

Variables

static __IO uint8_t * SJA1000_CMD = (__IO uint8_t *) (FSMC_CAN_BASE)
 
static __IO uint8_t * SJA1000_DATA = (__IO uint8_t *) (FSMC_CAN_BASE + 8)
 
static IRQ_CALLBACK CARME_CAN_IRQCallbacks [CARME_CAN_IRQID_COUNT]
 

Detailed Description

CARME-M4 CAN Interface.

Macro Definition Documentation

#define CARME_CAN_BAUD_125K   125000

Baudrade 125K

Definition at line 88 of file can.h.

#define CARME_CAN_BAUD_1M   1000000

Baudrade 1M

Definition at line 91 of file can.h.

#define CARME_CAN_BAUD_250K   250000

Baudrade 250K

Examples:
can.c, and can_acceptancefilter.c.

Definition at line 89 of file can.h.

#define CARME_CAN_BAUD_500K   500000

Baudrade 500K

Definition at line 90 of file can.h.

#define CARME_CAN_DF_LISTEN_ONLY   0x02

LOM-Bit in MOD register set

Definition at line 115 of file can.h.

#define CARME_CAN_DF_NORMAL   0x01

RM-Bit in MOD register cleared

Examples:
can.c, and can_acceptancefilter.c.

Definition at line 114 of file can.h.

#define CARME_CAN_DF_RESET   0x00

RM-Bit in MOD register set

Examples:
can.c, and can_acceptancefilter.c.

Definition at line 113 of file can.h.

#define CARME_CAN_INT_ARBIT_LOST   (SJA1000_IER_ALIE)

Arbitration Lost Interrupt Enable

Definition at line 104 of file can.h.

#define CARME_CAN_INT_BUSERR   (SJA1000_IER_BEIE)

Bus Error Interrupt Enable

Definition at line 103 of file can.h.

#define CARME_CAN_INT_ERROR   (SJA1000_IER_EIE)

Error Warning Interrupt Enable

Definition at line 108 of file can.h.

#define CARME_CAN_INT_OVERRUN   (SJA1000_IER_DOIE)

Data overrun Interrupt Enable

Definition at line 107 of file can.h.

#define CARME_CAN_INT_PASSIVE   (SJA1000_IER_EPIE)

Error Passive Interrupt Enable

Definition at line 105 of file can.h.

#define CARME_CAN_INT_RX   (SJA1000_IER_RIE)

Receive Interrupt Enable

Definition at line 110 of file can.h.

#define CARME_CAN_INT_TX   (SJA1000_IER_TIE)

Transmit Interrupt Enable

Definition at line 109 of file can.h.

#define CARME_CAN_INT_WAKEUP   (SJA1000_IER_WUIE)

Wake-up Interrupt Enable

Definition at line 106 of file can.h.

#define CARME_CAN_nCAN_INT_PIN   GPIO_Pin_8

CAN Interrupt Line Pin

Definition at line 84 of file can.h.

#define CARME_CAN_nCAN_INT_PORT   GPIOI

CAN Interrupt Line Port

Definition at line 83 of file can.h.

#define CARME_CAN_nCAN_IRQn_CH   EXTI9_5_IRQn

Used NVIC channel

Definition at line 85 of file can.h.

#define CARME_ERROR_CAN   CARME_ERROR_CAN_BASE + 0

Common CAN error

Definition at line 94 of file can.h.

#define CARME_ERROR_CAN_ERROR_STATUS   CARME_ERROR_CAN_BASE + 6

Status error

Definition at line 100 of file can.h.

#define CARME_ERROR_CAN_INVALID_ACCEPTANCE_MODE   CARME_ERROR_CAN_BASE + 5

Invalid acceptance mode

Definition at line 99 of file can.h.

#define CARME_ERROR_CAN_INVALID_BAUDRATE   CARME_ERROR_CAN_BASE + 1

Invalid baudrate

Definition at line 95 of file can.h.

#define CARME_ERROR_CAN_INVALID_MODE   CARME_ERROR_CAN_BASE + 3

Invalid mode

Definition at line 97 of file can.h.

#define CARME_ERROR_CAN_INVALID_OPMODE   CARME_ERROR_CAN_BASE + 4

Invalid opmode

Definition at line 98 of file can.h.

#define CARME_ERROR_CAN_RXFIFO_EMPTY   CARME_ERROR_CAN_BASE + 2

RxFIFO empty

Definition at line 96 of file can.h.

Typedef Documentation

Information about the acceptance filter.

See also
CARME_CAN_SetAcceptaceFilter()

Enumeration Type Documentation

Acceptance filter modes.

See also
CARME_CAN_SetAcceptaceFilter()
Enumerator
MODE_SINGLE 

single acceptance filter option is enabled (one filter with the length of 32 bits)

MODE_DUAL 

dual acceptance filter option is enabled (two filters with the length of 16 bits)

Definition at line 152 of file can.h.

Interrupt sources of the CAN-Controller.

Enumerator
CARME_CAN_IRQID_RX_INTERRUPT 

Telegram received Interrupt

CARME_CAN_IRQID_TX_INTERRUPT 

Telegram transmitted Interrupt

CARME_CAN_IRQID_ERROR_INTERRUPT 

Error warning Interrupt

CARME_CAN_IRQID_DATAOVERFLOW_INTERRUPT 

Overflow Interrupt

CARME_CAN_IRQID_WAKEUP_INTERRUPT 

Wakeup Interrupt Occurs when the sleep mode is left

CARME_CAN_IRQID_PASSIVE_INTERRUPT 

Passive Interrupt

CARME_CAN_IRQID_ARITRATION_LOST_INTERRUPT 

Arbitration Lost Interrupt

CARME_CAN_IRQID_BUS_ERROR_INTERRUPT 

Bus Error Interrupt

CARME_CAN_IRQID_COUNT 

this must be the last entry (used for array size)

Definition at line 122 of file can.h.

Function Documentation

ERROR_CODES CARME_CAN_GetAcceptaceFilter ( CARME_CAN_ACCEPTANCE_FILTER af)

Get the Acceptance Filter settings.

See also
CARME_CAN_setAcceptaceFilter()
Parameters
[in]afacceptance filter information. Refer the struct CARME_CAN_ACCEPTANCE_FILTER for details.
Returns
0 = CARME_NO_ERROR
44 = CARME_ERROR_CAN_INVALID_OPMODE

Definition at line 700 of file can.c.

+ Here is the call graph for this function:

static void CARME_CAN_GetArbitrationLostCapture ( uint8_t *  alc)
inlinestatic

Get the value of the TX Error Count Register.

Parameters
[in]alcPointer to a variable which will contain the content of the Arbitration Lost Capture Register.

Definition at line 321 of file can.h.

+ Here is the call graph for this function:

static void CARME_CAN_GetErrorCodeCapture ( uint8_t *  ecc)
inlinestatic

Get the value of the TX Error Count Register.

Parameters
[in]eccPointer to a variable which will contain the content of the Error Code Capture Register.

Definition at line 330 of file can.h.

+ Here is the call graph for this function:

static void CARME_CAN_GetErrorWarningLimit ( uint8_t *  limit)
inlinestatic

Get the value of the Error Warning Limit Register.

Parameters
[in]limitPointer to a variable which will contain the content of the Error Warning Limit Register

Definition at line 293 of file can.h.

+ Here is the call graph for this function:

static void CARME_CAN_GetRxErrCount ( uint8_t *  count)
inlinestatic

Get the value of the RX Error Count Register.

Parameters
[in]countPointer to a variable which will contain the content of the RX Error Count Register

Definition at line 302 of file can.h.

+ Here is the call graph for this function:

static void CARME_CAN_GetTxErrCount ( uint8_t *  count)
inlinestatic

Get the value of the TX Error Count Register.

Parameters
[in]countPointer to a variable which will contain the content of the TX Error Count Register.

Definition at line 311 of file can.h.

+ Here is the call graph for this function:

void CARME_CAN_Init ( uint32_t  baud,
uint8_t  flags 
)

Initialize GPIOs and the CAN-Controller.

Initializes the global variables from the driver, the baudrate and the acceptance-filter. This initialization function configures the CAN-Controller for communication without interrupts.

Parameters
[in]baudBaud-rate. Refer CARME_CAN_setBaudrate() for valid arguments.
[in]flagsDriver Flags. The Flags can be OR-ed.
  • CARME_CAN_DF_RESET Leaves the CAN Controller in Reset-Mode.
  • CARME_CAN_DF_NORMAL Put the CAN-Controller in Operating-Mode after initialization.
  • CARME_CAN_DF_LISTEN_ONLY Put the CAN-Controller in Listen Only Mode after initialization.
Returns
None
Examples:
can.c, and can_acceptancefilter.c.

Definition at line 166 of file can.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CARME_CAN_InitI ( uint32_t  baud,
uint8_t  flags,
uint32_t  interrupts 
)

Initialize GPIOs and the CAN-Controller.

Initializes the global variables from the driver, the baudrate and the acceptance-filter. This initialization function configures the CAN-Controller for communication without interrupts.

Parameters
[in]baudBaud-rate. Refer CARME_CAN_setBaudrate() for valid arguments.
[in]flagsDriver Flags. The Flags can be OR-ed.
  • CARME_CAN_DF_RESET Leaves the CAN Controller in Reset-Mode.
  • CARME_CAN_DF_NORMAL Put the CAN-Controller in Operating-Mode after initialization.
  • CARME_CAN_DF_LISTEN_ONLY Put the CAN- Controller in Listen Only Mode after initialization.
[in]interruptsEnable specified Interrupts. The Flags can be OR-ed.
  • CARME_CAN_INT_BUSERR Bus Error
  • CARME_CAN_INT_ARBIT_LOST Arbitration Lost
  • CARME_CAN_INT_PASSIVE Error Passive
  • CARME_CAN_INT_WAKEUP Wake-up
  • CARME_CAN_INT_OVERRUN Data overrun
  • CARME_CAN_INT_ERROR Error Warning
  • CARME_CAN_INT_TX Transmit
  • CARME_CAN_INT_RX Receive
Returns
None

Definition at line 236 of file can.c.

+ Here is the call graph for this function:

static void CARME_CAN_InitSTM ( void  )
static

Initialize the stm32f4xx GPIOs and the nCAN_INT.
The CAN interrupt is on CARME_CAN_nCAN_IRQn_CH with NVIC_IRQChannelPreemptionPriority = 0x0F and NVIC_IRQChannelSubPriority = 0x0F.

Returns
None

Definition at line 116 of file can.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CARME_CAN_Interrupt_Handler ( void  )

This function will be called from the Interrupt-Handler on a CAN-Interrupt.
If it was not the EXTI Line from the CAN controller, then the functions MyEXTI9_5_IRQHandler is called.

Returns
None

Definition at line 391 of file can.c.

+ Here is the call graph for this function:

static uint8_t CARME_CAN_IsBusOn ( void  )
inlinestatic

Returns 1 if the CAN Controller is involved in bus activities
The Function checks the BS-bit in the status register of the SJA1000.

Returns
1 on bus-on

Definition at line 229 of file can.h.

+ Here is the call graph for this function:

static uint8_t CARME_CAN_IsDataOverrun ( void  )
inlinestatic

Returns 1 if an data overrun occurred The Function checks the DOS-bit in the status register of the SJA1000.

Returns
1 on data overrun

Definition at line 239 of file can.h.

+ Here is the call graph for this function:

static uint8_t CARME_CAN_IsError ( void  )
inlinestatic

Returns 1 if at least one of the error counters has reached or exceeded the value in the Error Warning Limit Register.
The Function checks the ES-bit in the status register of the SJA1000.

Returns
1 on error

Definition at line 251 of file can.h.

+ Here is the call graph for this function:

ERROR_CODES CARME_CAN_Read ( CARME_CAN_MESSAGE rxMsg)

Reads a CAN-Message from the Receive-Buffer. If no message is in the buffer, the function returns CARME_ERROR_CAN_ERROR_RXFIFO_EMPTY.

Parameters
[in]rxMsgPointer to a CAN_MESSAGE struct for the received message.
Returns
0 = CARME_NO_ERROR
42 = CARME_ERROR_CAN_RXFIFO_EMPTY
46 = CARME_ERROR_CAN_ERROR_STATUS
Examples:
can.c.

Definition at line 324 of file can.c.

+ Here is the call graph for this function:

static uint8_t CARME_CAN_Read_Register ( uint8_t  registerAddress)
static

Reads a value from a SJA1000 register.

Parameters
[in]registerAddressAddress from the SJA1000 register.
Returns
error code

Definition at line 217 of file can.h.

+ Here is the caller graph for this function:

void CARME_CAN_RegisterIRQCallback ( enum CARME_CAN_IRQ_CALLBACKS  id,
IRQ_CALLBACK  pIRQCallback 
)

Registers a callback function. Callback functions are called in Interruptmode. Use this function after CARME_CAN_init() or CARME_CAN_initI().

Parameters
[in]idid of the Callback function
[in]pIRQCallbackpointer to the callback function
Returns
None

Definition at line 258 of file can.c.

ERROR_CODES CARME_CAN_SetAcceptaceFilter ( CARME_CAN_ACCEPTANCE_FILTER af)

ACCEPTANCE FILTER
With the help of the acceptance filter the CAN controller is able to allow passing of received messages to the RXFIFO only when the identifier bits of the received message are equal to the predefined ones within the acceptance filter registers.
The acceptance filter is defined by the Acceptance Code Registers (ACRn) and the Acceptance Mask Registers (AMRn). The bit patterns of messages to be received are defined within the acceptance code registers. The corresponding acceptance mask registers allow to define certain bit positions to be 'don't care'. Two different filter modes are selectable within the mode register:

  • Single filter mode (bit AFM is logic 1)
  • Dual filter mode (bit AFM is logic 0).

Single filter configuration
In this filter configuration one long filter (4-bytes) could be defined. The bit correspondences between the filter bytes and the message bytes depend on the currently received frame format.

Standard frame: if a standard frame format message is received, the complete identifier including the RTR bit and the first two data bytes are used for acceptance filtering. Messages may also be accepted if there are no data bytes existing due to a set RTR bit or if there is none or only one data byte because of the corresponding data length code. For a successful reception of a message, all single bit comparisons have to signal acceptance.

Note
The 4 least significant bits of AMR1 and ACR1 are not used. In order to be compatible with future products these bits should be programmed to be 'don't care' by setting AMR1.3, AMR1.2, AMR1.1 and AMR1.0 to logic 1.

acceptanceFilter.png
"Single filter configuration, receiving standard frame messages."

Extended frame: if an extended frame format message is received, the complete identifier including the RTR bit is used for acceptance filtering.
For a successful reception of a message, all single bit comparisons have to signal acceptance.

Note
The 2 least significant bits of AMR3 and ACR3 are not used. In order to be compatible with future products these bits should be programmed to be 'don't care' by setting AMR3.1 and AMR3.0 to logic 1.

Dual filter configuration
In this filter configuration two short filters can be defined. A received message is compared with both filters to decide, whether this message should be copied into the receive buffer or not. If at least one of the filters signals an acceptance, the received message becomes valid. The bit correspondences between the filter bytes and the message bytes depends on the currently received frame format.

Standard frame: if a standard frame message is received, the two defined filters are looking different. The first filter compares the complete standard identifier including the RTR bit and the first data byte of the message. The second filter just compares the complete standard identifier including the RTR bit.
For a successful reception of a message, all single bit comparisons of at least one complete filter have to signal acceptance. In case of a set RTR bit or a data length code of logic 0 no data byte is existing. Nevertheless a message may pass filter 1, if the first part up to the RTR bit signals acceptance.
If no data byte filtering is required for filter 1, the four least significant bits of AMR1 and AMR3 have to be set to logic 1 (don't care). Then both filters are working identically using the standard identifier range including the RTR bit.

DualAcceptanceFilterMode.png
"Dual filter configuration, receiving standard frame messages."

Extended frame: if an extended frame message is received, the two defined filters are looking identically. Both filters are comparing the first two bytes of the extended identifier range only.
For a successful reception of a message, all single bit comparisons of at least one complete filter have to indicate acceptance.

Parameters
[in]afacceptance filter information. Refer the struct CARME_CAN_ACCEPTANCE_FILTER for details.
Returns
0 = CARME_NO_ERROR
44 = CARME_ERROR_CAN_INVALID_OPMODE
45 = CARME_ERROR_CAN_INVALID_ACCEPTANCE_MODE
Examples:
can_acceptancefilter.c.

Definition at line 657 of file can.c.

+ Here is the call graph for this function:

ERROR_CODES CARME_CAN_SetBaudrate ( uint32_t  baud)

Set the baudrate for the CAN-Communication.

The Bus-Timing is set as follows for the different baudrates:

  • 125kHz: SJW = 1, TSEG1 = 12, TSEG2 = 1, SAM (Trible) = 0
  • 250kHz: SJW = 1, TSEG1 = 12, TSEG2 = 1, SAM (Trible) = 0
  • 500kHz: SJW = 1, TSEG1 = 15, TSEG2 = 15, SAM (Trible) = 0
  • 1MHz: SJW = 1, TSEG1 = 12, TSEG2 = 9, SAM (Trible) = 0
Parameters
[in]baudBaudrate. Can be one of the following constants:
Returns
0 = CARME_NO_ERROR
61 = CARME_ERROR_CAN_INVALID_BAUDRATE

Definition at line 469 of file can.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void CARME_CAN_SetBusTiming ( uint8_t  btr0,
uint8_t  btr1 
)
static

Set the Bus-Timing-Registers of the SJA1000 directly.

Parameters
[in]btr0Content of the BTR0 register
[in]btr1Content of the BTR1 register
Returns
None

Definition at line 444 of file can.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ERROR_CODES CARME_CAN_SetErrorWarningLimit ( uint8_t  limit)
inlinestatic

Set the value of the Error Warning Limit Register. The content can only be changed in reset mode.

Parameters
[in]limitThe new content of the Error Warning Limit Register
Returns
Error code

Definition at line 277 of file can.h.

+ Here is the call graph for this function:

ERROR_CODES CARME_CAN_SetMode ( uint8_t  flags)

Change operating mode from the CAN-Controller.

This function is used to switch the controller in reset or normal mode for change settings like acceptance-filter, baud rate, bus timing,...

Parameters
[in]flagsCan be one of the following constants:
Returns
0 = CARME_NO_ERROR
43 = CARME_ERROR_CAN_INVALID_MODE
Examples:
can.c, and can_acceptancefilter.c.

Definition at line 292 of file can.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CARME_CAN_UnregisterIRQCallback ( enum CARME_CAN_IRQ_CALLBACKS  id)

Unregisters a callback function. Callback functions are called in Interruptmode.

Parameters
[in]idid of the Callback function
Returns
None

Definition at line 273 of file can.c.

ERROR_CODES CARME_CAN_Write ( CARME_CAN_MESSAGE txMsg)

Sends a CAN-Messsage over the CAN-Bus.

Parameters
[in]txMsgCAN-ID
Returns
0 = CARME_NO_ERROR
66 = CARME_ERROR_CAN_ERROR_STATUS
Examples:
can.c.

Definition at line 501 of file can.c.

+ Here is the call graph for this function:

static void CARME_CAN_Write_Register ( uint8_t  registerAddress,
uint8_t  val 
)
static

Write a value in a SJA1000 register.

Parameters
[in]registerAddressAddress from the SJA1000 register.
[in]valValue to write.

Definition at line 207 of file can.h.

+ Here is the caller graph for this function: