Skip to content

File syn_ir.c

FileList > proto > syn_ir.c

Go to the source code of this file

Infrared (IR) Remote Control Protocol Engine implementation.

  • #include "../util/syn_assert.h"
  • #include "syn_ir.h"
  • #include <string.h>

Classes

Type Name
struct SYN_IR_ProtoDesc
Internal infrared protocol timing descriptor.

Public Static Attributes

Type Name
const SYN_IR_ProtoDesc proto_table

Public Functions

Type Name
bool syn_ir_decode_pulse (SYN_IR_Decoder * decoder, uint16_t duration_us, bool is_mark, SYN_IR_Frame * frame_out)
Process a single pulse duration (mark or space) in microseconds.
bool syn_ir_decode_timeout (SYN_IR_Decoder * decoder, SYN_IR_Frame * frame_out)
Signal a gap/timeout (>10ms silence) to finalize protocols.
SYN_Status syn_ir_decoder_init (SYN_IR_Decoder * decoder)
Initialize or reset an IR decoder instance.
SYN_Status syn_ir_encode_frame (const SYN_IR_Frame * frame, SYN_IR_Pulse * pulse_buf, size_t buf_len, size_t * count_out)
Encode a frame into a sequence of pulse timing pairs.
const char * syn_ir_protocol_name (SYN_IR_Protocol proto)
Get human-readable protocol string name.

Public Static Functions

Type Name
void reset_decoder_state (SYN_IR_Decoder * decoder)
Reset IR decoder state machine.
bool timing_match (uint16_t actual, uint16_t expected, uint16_t tolerance)
Check if measured pulse timing matches expected duration within tolerance.
bool unpack_frame (const SYN_IR_Decoder * decoder, SYN_IR_Frame * frame_out)
Unpack raw 64-bit frame buffer into decoded SYN_IR_Frame fields.

Public Static Attributes Documentation

variable proto_table

const SYN_IR_ProtoDesc proto_table[SYN_IR_PROTO_COUNT];

Protocol timing lookup table.


Public Functions Documentation

function syn_ir_decode_pulse

Process a single pulse duration (mark or space) in microseconds.

bool syn_ir_decode_pulse (
    SYN_IR_Decoder * decoder,
    uint16_t duration_us,
    bool is_mark,
    SYN_IR_Frame * frame_out
) 

Parameters:

  • decoder Pointer to IR decoder handle.
  • duration_us Pulse duration in microseconds.
  • is_mark true if pulse is active IR carrier (mark), false if space.
  • frame_out [out] Populated with decoded frame when function returns true.

Returns:

true if a complete, valid frame was decoded, false otherwise.


function syn_ir_decode_timeout

Signal a gap/timeout (>10ms silence) to finalize protocols.

bool syn_ir_decode_timeout (
    SYN_IR_Decoder * decoder,
    SYN_IR_Frame * frame_out
) 

Parameters:

  • decoder Pointer to IR decoder handle.
  • frame_out [out] Populated with decoded frame if timeout completed frame.

Returns:

true if a complete valid frame was finalized by timeout, false otherwise.


function syn_ir_decoder_init

Initialize or reset an IR decoder instance.

SYN_Status syn_ir_decoder_init (
    SYN_IR_Decoder * decoder
) 

Parameters:

  • decoder Pointer to IR decoder handle.

Returns:

SYN_OK on success, SYN_INVALID_PARAM on NULL.


function syn_ir_encode_frame

Encode a frame into a sequence of pulse timing pairs.

SYN_Status syn_ir_encode_frame (
    const SYN_IR_Frame * frame,
    SYN_IR_Pulse * pulse_buf,
    size_t buf_len,
    size_t * count_out
) 

Parameters:

  • frame Pointer to frame to encode.
  • pulse_buf Output array for pulse timings.
  • buf_len Capacity of pulse_buf.
  • count_out [out] Number of pulse timing pairs written.

Returns:

SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on failure.


function syn_ir_protocol_name

Get human-readable protocol string name.

const char * syn_ir_protocol_name (
    SYN_IR_Protocol proto
) 

Parameters:

  • proto Protocol enum value.

Returns:

Pointer to const string.


Public Static Functions Documentation

function reset_decoder_state

Reset IR decoder state machine.

static void reset_decoder_state (
    SYN_IR_Decoder * decoder
) 

Parameters:

  • decoder Decoder instance pointer.

function timing_match

Check if measured pulse timing matches expected duration within tolerance.

static bool timing_match (
    uint16_t actual,
    uint16_t expected,
    uint16_t tolerance
) 

Parameters:

  • actual Measured pulse duration in us.
  • expected Nominal target duration in us.
  • tolerance Allowable +/- error window in us.

Returns:

true if within tolerance, false otherwise.


function unpack_frame

Unpack raw 64-bit frame buffer into decoded SYN_IR_Frame fields.

static bool unpack_frame (
    const SYN_IR_Decoder * decoder,
    SYN_IR_Frame * frame_out
) 

Parameters:

  • decoder Pointer to IR decoder instance.
  • frame_out Pointer to output frame structure.

Returns:

True on successful frame unpacking, false otherwise.



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