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

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)
bool timing_match (uint16_t actual, uint16_t expected, uint16_t tolerance)
bool unpack_frame (const SYN_IR_Decoder * decoder, SYN_IR_Frame * frame_out)

Public Static Attributes Documentation

variable proto_table

const SYN_IR_ProtoDesc proto_table[SYN_IR_PROTO_COUNT];

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

static void reset_decoder_state (
    SYN_IR_Decoder * decoder
) 

function timing_match

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

function unpack_frame

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


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