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:
Can_Initconfigured the whole CAN unit and every channel; channels startSTOPPED.Can_SetChannelState(..., STARTED)put channel 0 on the bus.Can_Transmitcopied the frame into a free hardware object and started sending. Completion is reported asynchronously throughCanIf_OnTransmission.
Where to go next:
Configuration — define your own configuration set.
Initialize a channel, Transmit a frame, Receive a frame, Handle bus-off — task guides per capability.
Common mistakes — the pitfalls to avoid.