Skip to content

File syn_lin.c

FileList > proto > syn_lin.c

Go to the source code of this file

LIN Protocol Engine implementation.

  • #include "syn_lin.h"

Public Functions

Type Name
uint8_t syn_lin_calc_checksum (uint8_t pid, const uint8_t * data, uint8_t len, SYN_LIN_ChecksumMode mode)
Compute LIN Checksum (Classic or Enhanced).
uint8_t syn_lin_calc_pid (uint8_t id)
Compute LIN Protected Identifier (PID) from a 6-bit Frame ID.
SYN_Status syn_lin_master_init (SYN_LIN_Master * master, const SYN_LIN_ScheduleSlot * slots, size_t count)
Initialize LIN Master engine with a schedule table.
bool syn_lin_master_step (SYN_LIN_Master * master, uint32_t dt_ms, const SYN_LIN_ScheduleSlot ** active_slot)
Step LIN Master schedule table timer.
SYN_Status syn_lin_slave_add_frame (SYN_LIN_Slave * slave, uint8_t id, uint8_t len, SYN_LIN_SlotDirection dir, SYN_LIN_ChecksumMode mode)
Register a frame filter on LIN Slave.
SYN_Status syn_lin_slave_init (SYN_LIN_Slave * slave, uint8_t nad)
Initialize LIN Slave engine.
bool syn_lin_slave_process_byte (SYN_LIN_Slave * slave, uint8_t byte, SYN_LIN_Frame * out_frame)
Process an incoming byte stream byte by byte on LIN Slave.
SYN_Status syn_lin_slave_set_publish_data (SYN_LIN_Slave * slave, uint8_t id, const uint8_t * data, uint8_t len)
Set published payload data for a specific Frame ID on LIN Slave.
bool syn_lin_verify_pid (uint8_t pid)
Verify Protected Identifier (PID) parity bits.

Public Functions Documentation

function syn_lin_calc_checksum

Compute LIN Checksum (Classic or Enhanced).

uint8_t syn_lin_calc_checksum (
    uint8_t pid,
    const uint8_t * data,
    uint8_t len,
    SYN_LIN_ChecksumMode mode
) 

Parameters:

  • pid 8-bit Protected Identifier (used only in Enhanced mode).
  • data Pointer to payload data bytes.
  • len Data length (1..8 bytes).
  • mode Classic (data only) or Enhanced (PID + data).

Returns:

Inverted modulo-255 sum byte.


function syn_lin_calc_pid

Compute LIN Protected Identifier (PID) from a 6-bit Frame ID.

uint8_t syn_lin_calc_pid (
    uint8_t id
) 

Parameters:

  • id 6-bit LIN Frame ID (0..63).

Returns:

8-bit Protected Identifier byte with P0/P1 parity bits set.


function syn_lin_master_init

Initialize LIN Master engine with a schedule table.

SYN_Status syn_lin_master_init (
    SYN_LIN_Master * master,
    const SYN_LIN_ScheduleSlot * slots,
    size_t count
) 

Parameters:

  • master Pointer to LIN Master handle.
  • slots Pointer to array of schedule table slots.
  • count Number of slots in table.

Returns:

SYN_OK on success, SYN_INVALID_PARAM on invalid inputs.


function syn_lin_master_step

Step LIN Master schedule table timer.

bool syn_lin_master_step (
    SYN_LIN_Master * master,
    uint32_t dt_ms,
    const SYN_LIN_ScheduleSlot ** active_slot
) 

Parameters:

  • master Pointer to LIN Master handle.
  • dt_ms Elapsed time since last call in milliseconds.
  • active_slot Pointer to store currently executed slot reference (can be NULL).

Returns:

True if a new schedule slot trigger occurred.


function syn_lin_slave_add_frame

Register a frame filter on LIN Slave.

SYN_Status syn_lin_slave_add_frame (
    SYN_LIN_Slave * slave,
    uint8_t id,
    uint8_t len,
    SYN_LIN_SlotDirection dir,
    SYN_LIN_ChecksumMode mode
) 

Parameters:

  • slave Pointer to LIN Slave handle.
  • id Frame ID (0..63).
  • len Payload length (1..8 bytes).
  • dir SUBSCRIBE (slave receives) or PUBLISH (slave transmits).
  • mode Classic or Enhanced checksum mode.

Returns:

SYN_OK on success, SYN_ERROR if slave table is full.


function syn_lin_slave_init

Initialize LIN Slave engine.

SYN_Status syn_lin_slave_init (
    SYN_LIN_Slave * slave,
    uint8_t nad
) 

Parameters:

  • slave Pointer to LIN Slave handle.
  • nad Node Address (0..255, 0x7F = wildcard/broadcast).

Returns:

SYN_OK on success, SYN_INVALID_PARAM on invalid inputs.


function syn_lin_slave_process_byte

Process an incoming byte stream byte by byte on LIN Slave.

bool syn_lin_slave_process_byte (
    SYN_LIN_Slave * slave,
    uint8_t byte,
    SYN_LIN_Frame * out_frame
) 

Parameters:

  • slave Pointer to LIN Slave handle.
  • byte Incoming UART byte.
  • out_frame Pointer to output structure populated when a complete frame is received.

Returns:

True if a complete valid frame was processed.


function syn_lin_slave_set_publish_data

Set published payload data for a specific Frame ID on LIN Slave.

SYN_Status syn_lin_slave_set_publish_data (
    SYN_LIN_Slave * slave,
    uint8_t id,
    const uint8_t * data,
    uint8_t len
) 

Parameters:

  • slave Pointer to LIN Slave handle.
  • id Frame ID (0..63).
  • data Pointer to payload data bytes.
  • len Payload data length.

Returns:

SYN_OK on success, SYN_ERROR if ID not registered as PUBLISH.


function syn_lin_verify_pid

Verify Protected Identifier (PID) parity bits.

bool syn_lin_verify_pid (
    uint8_t pid
) 

Parameters:

  • pid 8-bit PID byte.

Returns:

True if P0 and P1 parity bits match the 6-bit Frame ID.



The documentation for this class was generated from the following file src/syntropic/proto/syn_lin.c