Skip to content

File syn_lin.h

FileList > proto > syn_lin.h

Go to the source code of this file

LIN (Local Interconnect Network 2.1 / 2.2a & ISO 17987) Protocol Engine. More...

  • #include "../common/syn_defs.h"

Classes

Type Name
struct SYN_LIN_Frame
LIN Frame representation.
struct SYN_LIN_Master
LIN Master state machine handle.
struct SYN_LIN_ScheduleSlot
Schedule table slot entry for LIN Master.
struct SYN_LIN_Slave
LIN Slave state machine handle.
struct SYN_LIN_SlaveFrame
Configuration for a single frame ID handled by a LIN Slave.

Public Types

Type Name
enum SYN_LIN_ChecksumMode
LIN Checksum calculation mode.
enum SYN_LIN_SlotDirection
Direction of data for a Master schedule table slot.
enum SYN_LIN_State

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.

Macros

Type Name
define SYN_LIN_DATA_MAX 8
define SYN_LIN_ID_EXTENDED 0x3E
define SYN_LIN_ID_MASTER_REQ 0x3C
define SYN_LIN_ID_MAX 0x3F
define SYN_LIN_ID_RESERVED 0x3F
define SYN_LIN_ID_SLAVE_RESP 0x3D
define SYN_LIN_SLAVE_MAX_FRAMES 8
define SYN_LIN_SYNC_BYTE 0x55

Detailed Description

Provides non-blocking, zero-allocation LIN frame parsing, PID parity logic, classic/enhanced checksum verification, Master schedule table execution, and Slave response publishing/subscription state machines.

Public Types Documentation

enum SYN_LIN_ChecksumMode

LIN Checksum calculation mode.

enum SYN_LIN_ChecksumMode {
    SYN_LIN_CHECKSUM_CLASSIC =
        0,
    SYN_LIN_CHECKSUM_ENHANCED = 1
};


enum SYN_LIN_SlotDirection

Direction of data for a Master schedule table slot.

enum SYN_LIN_SlotDirection {
    SYN_LIN_SLOT_PUBLISH = 0,
    SYN_LIN_SLOT_SUBSCRIBE = 1
};


enum SYN_LIN_State

enum SYN_LIN_State {
    SYN_LIN_STATE_IDLE = 0,
    SYN_LIN_STATE_SYNC,
    SYN_LIN_STATE_PID,
    SYN_LIN_STATE_DATA,
    SYN_LIN_STATE_CHECKSUM
};

LIN Bus Receiver State Machine Enum.


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.


Macro Definition Documentation

define SYN_LIN_DATA_MAX

#define SYN_LIN_DATA_MAX `8`

Maximum payload bytes per LIN frame


define SYN_LIN_ID_EXTENDED

#define SYN_LIN_ID_EXTENDED `0x3E`

LIN Extended Frame ID


define SYN_LIN_ID_MASTER_REQ

#define SYN_LIN_ID_MASTER_REQ `0x3C`

LIN Diagnostic Master Request ID


define SYN_LIN_ID_MAX

#define SYN_LIN_ID_MAX `0x3F`

Maximum 6-bit LIN Frame ID (0..63)


define SYN_LIN_ID_RESERVED

#define SYN_LIN_ID_RESERVED `0x3F`

LIN Reserved Frame ID


define SYN_LIN_ID_SLAVE_RESP

#define SYN_LIN_ID_SLAVE_RESP `0x3D`

LIN Diagnostic Slave Response ID


define SYN_LIN_SLAVE_MAX_FRAMES

#define SYN_LIN_SLAVE_MAX_FRAMES `8`

Maximum configured frame slots per LIN Slave


define SYN_LIN_SYNC_BYTE

#define SYN_LIN_SYNC_BYTE `0x55`

LIN Sync Byte



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