Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 14 Current »

Enabling the CAN bus interface means, that the CAN controller will go in active mode and will be ready for communication. The CAN Bus that we configured in the previous section will be the source of our example. (For more info on how to configure the CAN Bus, click Here). The following code snippets are taken from can_demo.c found in $:\Micrium\Software\uC-CAN\Examples\<OS> where 'OS' is either NONE (for No-OS), uCOS-II or uCOS-III.

 

 #include "can_bus.h"

extern  CANBUS_PARA  CanCfg;

void  App_CAN_Startup (void)
{
    CPU_INT16S    can_err;

    ...                                               [1]

    CanBusInit(0L);                                   [2]       /* Initialize CAN Objects & Bus Layer.                  */
    can_err = CanBusEnable((CANBUS_PARA *)&CanCfg);   [3]       /* Enable CAN Device according to Configuration.        */
    if (can_err != CAN_ERR_NONE) {
        while (1);                                    [4]       /* Failure Handling Here.                               */
    }
                                                                /* --------------- uC/OS-III DEMO TASKs --------------- */
    ...                                               [4]
}


  • No labels