mirror of
https://github.com/esphome/esphome.git
synced 2026-10-28 00:42:11 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59e8b0b9c2 | ||
|
|
5b12ff419e | ||
|
|
3765f9072e |
No files matched your search
@@ -21,6 +21,23 @@ void I2CBus::i2c_scan_() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void I2CBus::dump_scan_results_() {
|
||||||
|
if (!this->scan_)
|
||||||
|
return;
|
||||||
|
ESP_LOGCONFIG(TAG, "Results from bus scan:");
|
||||||
|
if (this->scan_results_.empty()) {
|
||||||
|
ESP_LOGCONFIG(TAG, "Found no devices");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (const auto &s : this->scan_results_) {
|
||||||
|
if (s.second) {
|
||||||
|
ESP_LOGCONFIG(TAG, "Found device at address 0x%02X", s.first);
|
||||||
|
} else {
|
||||||
|
ESP_LOGE(TAG, "Unknown error at address 0x%02X", s.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void log_wrong_chip_id(uint8_t id, uint8_t expected) {
|
void log_wrong_chip_id(uint8_t id, uint8_t expected) {
|
||||||
ESP_LOGE(TAG, "Wrong chip ID 0x%02X, expected 0x%02X", id, expected);
|
ESP_LOGE(TAG, "Wrong chip ID 0x%02X, expected 0x%02X", id, expected);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ class I2CBus {
|
|||||||
/// @brief Scans the I2C bus for devices. Devices presence is kept in an array of std::pair
|
/// @brief Scans the I2C bus for devices. Devices presence is kept in an array of std::pair
|
||||||
/// that contains the address and the corresponding bool presence flag.
|
/// that contains the address and the corresponding bool presence flag.
|
||||||
void i2c_scan_();
|
void i2c_scan_();
|
||||||
|
/// @brief Logs the scan results at config level, if the bus was scanned
|
||||||
|
void dump_scan_results_();
|
||||||
std::vector<std::pair<uint8_t, bool>> scan_results_; ///< array containing scan results
|
std::vector<std::pair<uint8_t, bool>> scan_results_; ///< array containing scan results
|
||||||
bool scan_{false}; ///< Should we scan ? Can be set in the yaml
|
bool scan_{false}; ///< Should we scan ? Can be set in the yaml
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -85,20 +85,7 @@ void ArduinoI2CBus::dump_config() {
|
|||||||
ESP_LOGCONFIG(TAG, " Recovery: failed, SDA is held low on the bus");
|
ESP_LOGCONFIG(TAG, " Recovery: failed, SDA is held low on the bus");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this->scan_) {
|
this->dump_scan_results_();
|
||||||
ESP_LOGI(TAG, "Results from bus scan:");
|
|
||||||
if (this->scan_results_.empty()) {
|
|
||||||
ESP_LOGI(TAG, "Found no devices");
|
|
||||||
} else {
|
|
||||||
for (const auto &s : this->scan_results_) {
|
|
||||||
if (s.second) {
|
|
||||||
ESP_LOGI(TAG, "Found device at address 0x%02X", s.first);
|
|
||||||
} else {
|
|
||||||
ESP_LOGE(TAG, "Unknown error at address 0x%02X", s.first);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode ArduinoI2CBus::write_readv(uint8_t address, const uint8_t *write_buffer, size_t write_count,
|
ErrorCode ArduinoI2CBus::write_readv(uint8_t address, const uint8_t *write_buffer, size_t write_count,
|
||||||
|
|||||||
@@ -127,20 +127,7 @@ void IDFI2CBus::dump_config() {
|
|||||||
ESP_LOGCONFIG(TAG, " Recovery: failed, SDA is held low on the bus");
|
ESP_LOGCONFIG(TAG, " Recovery: failed, SDA is held low on the bus");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this->scan_) {
|
this->dump_scan_results_();
|
||||||
ESP_LOGCONFIG(TAG, "Results from bus scan:");
|
|
||||||
if (this->scan_results_.empty()) {
|
|
||||||
ESP_LOGCONFIG(TAG, "Found no devices");
|
|
||||||
} else {
|
|
||||||
for (const auto &s : this->scan_results_) {
|
|
||||||
if (s.second) {
|
|
||||||
ESP_LOGCONFIG(TAG, "Found device at address 0x%02X", s.first);
|
|
||||||
} else {
|
|
||||||
ESP_LOGE(TAG, "Unknown error at address 0x%02X", s.first);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode IDFI2CBus::write_readv(uint8_t address, const uint8_t *write_buffer, size_t write_count, uint8_t *read_buffer,
|
ErrorCode IDFI2CBus::write_readv(uint8_t address, const uint8_t *write_buffer, size_t write_count, uint8_t *read_buffer,
|
||||||
|
|||||||
@@ -62,14 +62,7 @@ void HostI2CBus::dump_config() {
|
|||||||
ESP_LOGE(TAG, " Setup Error: %s", this->first_error_.c_str());
|
ESP_LOGE(TAG, " Setup Error: %s", this->first_error_.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->scan_) {
|
this->dump_scan_results_();
|
||||||
ESP_LOGI(TAG, " Scan Results:");
|
|
||||||
for (const auto &s : this->scan_results_) {
|
|
||||||
if (s.second) {
|
|
||||||
ESP_LOGI(TAG, " 0x%02X: Found", s.first);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode HostI2CBus::write_readv(uint8_t address, const uint8_t *write_buffer, size_t write_count,
|
ErrorCode HostI2CBus::write_readv(uint8_t address, const uint8_t *write_buffer, size_t write_count,
|
||||||
|
|||||||
@@ -51,20 +51,7 @@ void SoftwareI2CBus::dump_config() {
|
|||||||
if (this->recovered_) {
|
if (this->recovered_) {
|
||||||
ESP_LOGCONFIG(TAG, " Recovery: bus successfully recovered");
|
ESP_LOGCONFIG(TAG, " Recovery: bus successfully recovered");
|
||||||
}
|
}
|
||||||
if (this->scan_) {
|
this->dump_scan_results_();
|
||||||
ESP_LOGI(TAG, "Results from bus scan:");
|
|
||||||
if (this->scan_results_.empty()) {
|
|
||||||
ESP_LOGI(TAG, "Found no devices");
|
|
||||||
} else {
|
|
||||||
for (const auto &s : this->scan_results_) {
|
|
||||||
if (s.second) {
|
|
||||||
ESP_LOGI(TAG, "Found device at address 0x%02X", s.first);
|
|
||||||
} else {
|
|
||||||
ESP_LOGE(TAG, "Unknown error at address 0x%02X", s.first);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Half of one clock period in microseconds, rounded up. The frequency is validated to be non-zero.
|
// Half of one clock period in microseconds, rounded up. The frequency is validated to be non-zero.
|
||||||
|
|||||||
@@ -60,20 +60,7 @@ void ZephyrI2CBus::dump_config() {
|
|||||||
} else {
|
} else {
|
||||||
ESP_LOGCONFIG(TAG, " Recovery: bus successfully recovered");
|
ESP_LOGCONFIG(TAG, " Recovery: bus successfully recovered");
|
||||||
}
|
}
|
||||||
if (this->scan_) {
|
this->dump_scan_results_();
|
||||||
ESP_LOGI(TAG, "Results from I2C bus scan:");
|
|
||||||
if (scan_results_.empty()) {
|
|
||||||
ESP_LOGI(TAG, "Found no I2C devices!");
|
|
||||||
} else {
|
|
||||||
for (const auto &s : scan_results_) {
|
|
||||||
if (s.second) {
|
|
||||||
ESP_LOGI(TAG, "Found I2C device at address 0x%02X", s.first);
|
|
||||||
} else {
|
|
||||||
ESP_LOGE(TAG, "Unknown error at address 0x%02X", s.first);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode ZephyrI2CBus::write_readv(uint8_t address, const uint8_t *write_buffer, size_t write_count,
|
ErrorCode ZephyrI2CBus::write_readv(uint8_t address, const uint8_t *write_buffer, size_t write_count,
|
||||||
|
|||||||
Reference in new issue
Block a user