File 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:
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.
The documentation for this class was generated from the following file src/syntropic/proto/syn_lin.c