Versions Compared

Key

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

...

The following demo is taken from the µCOS-II or -III can_demo.c file found in $:\Micrium\Software\uC-CAN\Examples. Please note that when running µC/CAN with NO OS the following demo will slightly vary. Please refer to the can_demo.c file for No OS ('NONE') for further details.

App_CAN_Startup()
Anchor
ex_using_sig-msg-bus_can-startup
ex_using_sig-msg-bus_can-startup

Code Block
languagecpp
linenumberstrue
void  App_CAN_Startup (void)
{
    CPU_INT16S    can_err;
    CANMSG_PARA  *m;
#if (CANSIG_STATIC_CONFIG == 0u)
    CANSIG_PARA  *s;
#endif
#if ((APP_CAN_DEMO_SELECT == APP_CAN_RX_TX_DEMO) || \
     (APP_CAN_DEMO_SELECT == APP_CAN_ECHO_DEMO))
    CPU_INT08U    os_err;
#endif
                                                                /* ------------------ HARDWARE SETUP ------------------ */
    ...                                               [1]

                                                                /* ------------------- uC/CAN SETUP ------------------- */
    CanSigInit(0L);                                   [2]       /* Initialize CAN Signals.                              */
#if (CANSIG_STATIC_CONFIG == 0u)
    s = CanSig;
    while (s < &CanSig[S_MAX]) {                                /* Create CAN Signals                                   */
        can_err = CanSigCreate(s);
        if (can_err < 0) {
           while (1);                                           /* Failure Handling Here.                               */
        }
        s++;
    }
#endif
    CanMsgInit(0L);                                             /* Initialize CAN Messages.                             */
    m = (CANMSG_PARA *)CanMsg;
    while (m < &CanMsg[CANMSG_N]) {                             /* Create CAN Messages.                                 */
        can_err = CanMsgCreate(m);
        if (can_err < 0) {
           while (1);                                           /* Failure Handling Here.                               */
        }
        m++;
    }

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

...