File 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_SlotDirection¶
Direction of data for a Master schedule table slot.
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:
pid8-bit Protected Identifier (used only in Enhanced mode).dataPointer to payload data bytes.lenData length (1..8 bytes).modeClassic (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.
Parameters:
id6-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:
masterPointer to LIN Master handle.slotsPointer to array of schedule table slots.countNumber 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:
masterPointer to LIN Master handle.dt_msElapsed time since last call in milliseconds.active_slotPointer 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:
slavePointer to LIN Slave handle.idFrame ID (0..63).lenPayload length (1..8 bytes).dirSUBSCRIBE (slave receives) or PUBLISH (slave transmits).modeClassic 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.
Parameters:
slavePointer to LIN Slave handle.nadNode 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.
Parameters:
slavePointer to LIN Slave handle.byteIncoming UART byte.out_framePointer 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:
slavePointer to LIN Slave handle.idFrame ID (0..63).dataPointer to payload data bytes.lenPayload 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.
Parameters:
pid8-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¶
Maximum payload bytes per LIN frame
define SYN_LIN_ID_EXTENDED¶
LIN Extended Frame ID
define SYN_LIN_ID_MASTER_REQ¶
LIN Diagnostic Master Request ID
define SYN_LIN_ID_MAX¶
Maximum 6-bit LIN Frame ID (0..63)
define SYN_LIN_ID_RESERVED¶
LIN Reserved Frame ID
define SYN_LIN_ID_SLAVE_RESP¶
LIN Diagnostic Slave Response ID
define SYN_LIN_SLAVE_MAX_FRAMES¶
Maximum configured frame slots per LIN Slave
define SYN_LIN_SYNC_BYTE¶
LIN Sync Byte
The documentation for this class was generated from the following file src/syntropic/proto/syn_lin.h