Quickstart

Informative

A minimal, end-to-end example of using the CAN driver from upper-layer code. It shows how to call the driver, not how to implement it, and does not constrain implementations.

A quickstart example from reset to a transmitted frame:

/* Upper-layer usage — not driver internals. */

/* 1. Bring the driver up from its configuration set. */
Can_Init(&CanConfig);                       /* driver: UNINIT -> INIT, channels -> STOPPED */

/* 2. Activate channel 0 so it participates on the bus. */
Can_SetChannelState(0u, CAN_CH_STATE_STARTED);

/* 3. Send one classic-CAN frame from TX mailbox 0. */
uint8 payload[8] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 };
Can_PduInfoType pdu = {
    .pduId     = 0u,
    .frameId   = 0x123u,        /* standard id; MSBs select frame/id type */
    .sduLength = 8u,
    .sduDataPtr = payload,
};
if (Can_Transmit(0u, &pdu) == E_OK) {
    /* Accepted by hardware. CanIf_OnTransmission(pdu.pduId) fires on completion. */
}

What just happened:

  1. Can_Init configured the whole CAN unit and every channel; channels start STOPPED.

  2. Can_SetChannelState(..., STARTED) put channel 0 on the bus.

  3. Can_Transmit copied the frame into a free hardware object and started sending. Completion is reported asynchronously through CanIf_OnTransmission.

Where to go next: