Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Enable the CAN Bus

Enabling the CAN bus interface means, that the CAN controller will go in active mode and is ready for communication.

Example

...

The CAN bus (we have configured in the chapter above) shall be enabled.

Source code

...

#include can_bus.h

void Com_Start(void)

{

CPU_INT16S err; /*-1-*/

CanBusInit(0L); /*-2-*/

err = CanBusEnable(&CanCfg); /*-3-*/

if (err == CAN_ERR_NONE) {

...

}

}

Description

  1. Local variable to hold the error code of CanBusEnable() function call.
  2. Initialize the CAN bus management layer. This function call must be performed one time (and only one time) after reset of the system.
  3. Enable the configured CAN bus. The configuration variable CanCfg is assumed to be the global (constant) variable as described

...

  1. in Configure the CAN Bus.