[FL-1684] IRDA Add SIRC protocol (#693)
* IRDA HAL: Fill buffer refactoring * IRDA: Add SIRC protocol * IRDA: correct adr/cmd bit length * Disable Unit tests Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -5,11 +5,8 @@
|
||||
#include "irda_i.h"
|
||||
|
||||
|
||||
#define MATCH_BIT_TIMING(x, v, delta) ( ((x) < (v + delta)) \
|
||||
&& ((x) > (v - delta)))
|
||||
|
||||
#define MATCH_PREAMBLE_TIMING(x, v, delta) ( ((x) < ((v) * (1 + (delta)))) \
|
||||
&& ((x) > ((v) * (1 - (delta)))))
|
||||
#define MATCH_TIMING(x, v, delta) ( ((x) < (v + delta)) \
|
||||
&& ((x) > (v - delta)))
|
||||
|
||||
typedef struct IrdaCommonDecoder IrdaCommonDecoder;
|
||||
typedef struct IrdaCommonEncoder IrdaCommonEncoder;
|
||||
@@ -21,6 +18,7 @@ typedef IrdaStatus (*IrdaCommonEncode)(IrdaCommonEncoder* encoder, uint32_t* out
|
||||
typedef struct {
|
||||
IrdaTimings timings;
|
||||
bool manchester_start_from_space;
|
||||
bool no_stop_bit;
|
||||
uint32_t databit_len;
|
||||
IrdaCommonDecode decode;
|
||||
IrdaCommonDecode decode_repeat;
|
||||
@@ -36,7 +34,7 @@ typedef enum {
|
||||
} IrdaCommonStateDecoder;
|
||||
|
||||
typedef enum {
|
||||
IrdaCommonEncoderStateSpace,
|
||||
IrdaCommonEncoderStateSilence,
|
||||
IrdaCommonEncoderStatePreamble,
|
||||
IrdaCommonEncoderStateEncode,
|
||||
IrdaCommonEncoderStateEncodeRepeat,
|
||||
@@ -44,13 +42,13 @@ typedef enum {
|
||||
|
||||
struct IrdaCommonDecoder {
|
||||
const IrdaCommonProtocolSpec* protocol;
|
||||
IrdaCommonStateDecoder state;
|
||||
IrdaMessage message;
|
||||
uint32_t timings[6];
|
||||
uint8_t timings_cnt;
|
||||
void* context;
|
||||
uint32_t timings[6];
|
||||
IrdaMessage message;
|
||||
IrdaCommonStateDecoder state;
|
||||
uint8_t timings_cnt;
|
||||
bool switch_detect;
|
||||
uint32_t level;
|
||||
bool level;
|
||||
uint16_t databit_cnt;
|
||||
uint8_t data[];
|
||||
};
|
||||
@@ -60,30 +58,23 @@ struct IrdaCommonEncoder {
|
||||
IrdaCommonStateEncoder state;
|
||||
bool switch_detect;
|
||||
uint32_t bits_encoded;
|
||||
uint32_t timings_sum;
|
||||
uint32_t timings_encoded;
|
||||
void* context;
|
||||
uint8_t data[];
|
||||
};
|
||||
|
||||
|
||||
static inline void shift_left_array(uint32_t *array, uint32_t len, uint32_t shift) {
|
||||
for (int i = 0; i < len; ++i)
|
||||
array[i] = array[i + shift];
|
||||
}
|
||||
|
||||
|
||||
IrdaMessage* irda_common_decode(IrdaCommonDecoder *decoder, bool level, uint32_t duration);
|
||||
IrdaStatus irda_common_decode_pdwm(IrdaCommonDecoder* decoder);
|
||||
IrdaStatus irda_common_decode_pdm(IrdaCommonDecoder* decoder);
|
||||
IrdaStatus irda_common_decode_pwm(IrdaCommonDecoder* decoder);
|
||||
IrdaStatus irda_common_decode_manchester(IrdaCommonDecoder* decoder);
|
||||
void irda_common_decoder_set_context(void* decoder, void* context);
|
||||
void* irda_common_decoder_alloc(const IrdaCommonProtocolSpec *protocol);
|
||||
void irda_common_decoder_free(void* decoder);
|
||||
void irda_common_decoder_reset(void* decoder);
|
||||
void irda_common_decoder_free(IrdaCommonDecoder* decoder);
|
||||
void irda_common_decoder_reset(IrdaCommonDecoder* decoder);
|
||||
|
||||
IrdaStatus irda_common_encode(IrdaCommonEncoder* encoder, uint32_t* duration, bool* polarity);
|
||||
IrdaStatus irda_common_encode_pdwm(IrdaCommonEncoder* encoder, uint32_t* duration, bool* polarity);
|
||||
IrdaStatus irda_common_encode_manchester(IrdaCommonEncoder* encoder, uint32_t* duration, bool* polarity);
|
||||
void irda_common_encoder_set_context(void* decoder, void* context);
|
||||
void* irda_common_encoder_alloc(const IrdaCommonProtocolSpec* protocol);
|
||||
void irda_common_encoder_free(IrdaCommonEncoder* encoder);
|
||||
void irda_common_encoder_reset(IrdaCommonEncoder* encoder);
|
||||
|
Reference in New Issue
Block a user