9 static const char *
const TAG =
"vbus";
12 ESP_LOGCONFIG(TAG,
"VBus:");
16 static void septet_spread(uint8_t *data,
int start,
int count, uint8_t septet) {
17 for (
int i = 0; i < count; i++, septet >>= 1) {
19 data[start + i] |= 0x80;
23 static bool checksum(
const uint8_t *data,
int start,
int count) {
25 for (
int i = 0; i < count; i++)
26 csum = (csum - data[start + i]) & 0x7f;
52 if (this->
buffer_.size() == 7) {
61 ESP_LOGE(TAG,
"P2 checksum failed");
68 ESP_LOGV(TAG,
"P1 C%04x %04x->%04x: %04x %04" PRIx32
" (%" PRIu32
")", this->
command_, this->
source_,
69 this->
dest_,
id, value, value);
72 ESP_LOGE(TAG,
"P1 checksum failed");
84 ESP_LOGD(TAG,
"P1 empty message");
96 ESP_LOGE(TAG,
"frame checksum failed");
100 for (
int i = 0; i < 4; i++)
101 this->
buffer_.push_back(this->fbytes_[i]);
102 if (++this->cframe_ < this->
frames_)
119 if ((this->
dest_ != 0xffff) && (this->
dest_ != dest))
121 this->handle_message(message);
std::string format_hex(const uint8_t *data, size_t length)
Format the byte array data of length len in lowercased hex.
std::vector< VBusListener * > listeners_
void on_message(uint16_t command, uint16_t source, uint16_t dest, std::vector< uint8_t > &message)
void check_uart_settings(uint32_t baud_rate, uint8_t stop_bits=1, UARTParityOptions parity=UART_CONFIG_PARITY_NONE, uint8_t data_bits=8)
Check that the configuration of the UART bus matches the provided values and otherwise print a warnin...
std::vector< uint8_t > buffer_
bool read_byte(uint8_t *data)
Implementation of SPI Controller mode.
void dump_config() override