2021-05-18 13:51:00 +03:00
|
|
|
#pragma once
|
|
|
|
#include "irda.h"
|
|
|
|
#include <stddef.h>
|
2021-09-10 00:37:32 +03:00
|
|
|
#include <stdint.h>
|
2021-07-08 21:20:13 +03:00
|
|
|
|
|
|
|
typedef struct {
|
2021-09-15 20:22:58 +03:00
|
|
|
uint32_t min_split_time;
|
2021-07-08 21:20:13 +03:00
|
|
|
uint32_t silence_time;
|
|
|
|
uint16_t preamble_mark;
|
|
|
|
uint16_t preamble_space;
|
|
|
|
uint16_t bit1_mark;
|
|
|
|
uint16_t bit1_space;
|
|
|
|
uint16_t bit0_mark;
|
|
|
|
uint16_t bit0_space;
|
2021-09-10 00:37:32 +03:00
|
|
|
uint32_t preamble_tolerance;
|
2021-07-08 21:20:13 +03:00
|
|
|
uint32_t bit_tolerance;
|
|
|
|
} IrdaTimings;
|
2021-05-18 13:51:00 +03:00
|
|
|
|
2021-08-20 23:51:15 +03:00
|
|
|
typedef struct {
|
|
|
|
const char* name;
|
|
|
|
uint8_t address_length;
|
|
|
|
uint8_t command_length;
|
|
|
|
uint32_t frequency;
|
|
|
|
float duty_cycle;
|
|
|
|
} IrdaProtocolSpecification;
|
|
|
|
|
2022-01-05 19:10:18 +03:00
|
|
|
typedef const IrdaProtocolSpecification* (*IrdaGetProtocolSpec)(IrdaProtocol protocol);
|
2021-08-20 23:51:15 +03:00
|
|
|
|
2022-01-05 19:10:18 +03:00
|
|
|
typedef void* (*IrdaAlloc)(void);
|
|
|
|
typedef void (*IrdaFree)(void*);
|
2021-05-18 13:51:00 +03:00
|
|
|
|
2022-01-05 19:10:18 +03:00
|
|
|
typedef void (*IrdaDecoderReset)(void*);
|
|
|
|
typedef IrdaMessage* (*IrdaDecode)(void* ctx, bool level, uint32_t duration);
|
|
|
|
typedef IrdaMessage* (*IrdaDecoderCheckReady)(void*);
|
2021-09-10 00:37:32 +03:00
|
|
|
|
2021-07-08 21:20:13 +03:00
|
|
|
typedef void (*IrdaEncoderReset)(void* encoder, const IrdaMessage* message);
|
|
|
|
typedef IrdaStatus (*IrdaEncode)(void* encoder, uint32_t* out, bool* polarity);
|
|
|
|
|
|
|
|
static inline uint8_t reverse(uint8_t value) {
|
|
|
|
uint8_t reverse_value = 0;
|
2022-01-05 19:10:18 +03:00
|
|
|
for(int i = 0; i < 8; ++i) {
|
2021-07-08 21:20:13 +03:00
|
|
|
reverse_value |= (value & (0x01 << i)) ? 1 << (7 - i) : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return reverse_value;
|
|
|
|
}
|