Quickstart

Informative

The shortest path to a working LIN responder: initialize, go operational, and answer a header. Binding rules are in Lin — Requirements; signatures in API Reference.

Bring the driver up and go operational

Lin_Init(NULL_PTR);                       /* driver: UNINIT -> INIT; channels -> SLEEP */
Lin_WakeupInternal(0u);                   /* channel 0: SLEEP -> OPERATIONAL (no pulse) */

After Lin_Init the driver is initialized and every channel is in SLEEP. Move the channel to OPERATIONAL so it takes part in bus traffic.

Answer a header

The driver calls back when a header arrives; you decide how to react. To respond with data:

static uint8 my_response[8] = { 0x11, 0x22, 0x33, 0x44 };

void LinIf_OnHeader(uint8 channelId, Lin_PduInfoType *pduInfoPtr)
{
    if (pduInfoPtr->pid == 0x30u) {       /* the frame we answer */
        pduInfoPtr->reaction = LIN_REACTION_TX;
        pduInfoPtr->cs       = LIN_CS_ENHANCED;
        pduInfoPtr->dl       = 4u;
        pduInfoPtr->sduPtr   = my_response;   /* driver transmits these bytes */
    } else {
        pduInfoPtr->reaction = LIN_REACTION_IGNORE;
    }
}

void LinIf_OnTransmission(uint8 channelId)
{
    /* the response we set up above was sent successfully */
}

That is a complete responder: Lin_Interrupt (or Lin_PollFunction) drives the callbacks; you only fill in the reaction. To receive a response instead, set reaction = LIN_REACTION_RX and read the data in Handle a transaction (LinIf_OnReception).