7 namespace remote_base {
9 static const char *
const TAG =
"remote.byronsx";
11 static const uint32_t BIT_TIME_US = 333;
12 static const uint8_t NBITS_ADDRESS = 8;
13 static const uint8_t NBITS_COMMAND = 4;
14 static const uint8_t NBITS_START_BIT = 1;
15 static const uint8_t NBITS_DATA = NBITS_ADDRESS + NBITS_COMMAND ;
54 uint32_t out_data = 0x0;
56 ESP_LOGD(TAG,
"Send ByronSX: address=%04x command=%03x", data.
address, data.
command);
59 out_data <<= NBITS_COMMAND;
62 ESP_LOGV(TAG,
"Send ByronSX: out_data %03" PRIx32, out_data);
65 dst->
mark(1 * BIT_TIME_US);
67 for (uint32_t mask = 1UL << (NBITS_DATA - 1); mask != 0; mask >>= 1) {
68 if (out_data & mask) {
69 dst->
space(2 * BIT_TIME_US);
70 dst->
mark(1 * BIT_TIME_US);
72 dst->
space(1 * BIT_TIME_US);
73 dst->
mark(2 * BIT_TIME_US);
77 dst->
space(17 * BIT_TIME_US);
86 if (src.
size() != (NBITS_DATA + NBITS_START_BIT) * 2) {
96 "%3" PRId32
": %" PRId32
" %" PRId32
" %" PRId32
" %" PRId32
" %" PRId32
" %" PRId32
" %" PRId32
" %" PRId32
97 " %" PRId32
" %" PRId32
" %" PRId32
" %" PRId32
" %" PRId32
" %" PRId32
" %" PRId32
" %" PRId32
" %" PRId32
98 " %" PRId32
" %" PRId32
" %" PRId32,
103 ESP_LOGVV(TAG,
" %" PRId32
" %" PRId32
" %" PRId32
" %" PRId32
" %" PRId32
" %" PRId32, src.
peek(20),
107 uint32_t out_data = 0;
108 int8_t bit = NBITS_DATA;
111 out_data |= 1 << bit;
113 out_data |= 0 << bit;
115 ESP_LOGV(TAG,
"Decode ByronSX: Fail 2, %2d %08" PRIx32, bit, out_data);
118 ESP_LOGVV(TAG,
"Decode ByronSX: Data, %2d %08" PRIx32, bit, out_data);
123 ESP_LOGV(TAG,
"Decode ByronSX: Fail 4 ");
127 out.command = (uint8_t) (out_data & 0xF);
128 out_data >>= NBITS_COMMAND;
129 out.address = (uint16_t) (out_data & 0xFF);
135 ESP_LOGD(TAG,
"Received ByronSX: address=0x%08X, command=0x%02x", data.
address, data.
command);
bool expect_space(uint32_t length)
void dump(const ByronSXData &data) override
bool expect_mark(uint32_t length)
optional< ByronSXData > decode(RemoteReceiveData src) override
void mark(uint32_t length)
int32_t peek(uint32_t offset=0) const
void space(uint32_t length)
void encode(RemoteTransmitData *dst, const ByronSXData &data) override
Implementation of SPI Controller mode.
bool peek_space_at_least(uint32_t length, uint32_t offset=0) const