mirror of
https://github.com/esphome/esphome.git
synced 2025-04-01 00:18:18 +01:00
Update mcp4461.cpp
This commit is contained in:
parent
3e5f4c847f
commit
c536812dc2
@ -127,12 +127,14 @@ uint8_t Mcp4461Component::get_status_register() {
|
||||
return 0;
|
||||
}
|
||||
uint8_t msb = buf >> 8;
|
||||
if (msb != 1) {
|
||||
// D8 bit is hardlocked to 1 -> a status msb of 0 indicates device/communication issues, therefore mark component failed
|
||||
uint8_t lsb;
|
||||
lsb = static_cast<uint8_t>(buf & 0x00ff);
|
||||
if (msb != 1 || ((lsb >> 7) & 0x01)) != 1 || ((lsb >> 1) & 0x01) != 1) {
|
||||
// D8, D7 and R1 bits are hardlocked to 1 -> a status msb bit 0 (bit 9 of status register) of 0 or lsb bit 1/7 = 0 indicate device/communication issues, therefore mark component failed
|
||||
this->mark_failed();
|
||||
return 0;
|
||||
}
|
||||
return static_cast<uint8_t>(buf & 0x00ff);
|
||||
return ;
|
||||
}
|
||||
|
||||
bool Mcp4461Component::is_writing_() { return static_cast<bool>((this->get_status_register() >> 4) & 0x01); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user