One wire slave: fix presence timing, disable irq early (#348)

This commit is contained in:
SG 2021-02-18 11:22:13 +10:00 committed by GitHub
parent d2200a00d1
commit da91482b7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View File

@ -256,24 +256,23 @@ bool OneWireSlave::bus_start(void) {
if(device == nullptr) {
result = false;
} else {
__disable_irq();
pin_init_opendrain_in_isr_ctx();
error = OneWireSlaveError::NO_ERROR;
if(show_presence()) {
__disable_irq();
// TODO think about multiple command cycles
receive_and_process_cmd();
result =
(error == OneWireSlaveError::NO_ERROR ||
error == OneWireSlaveError::INCORRECT_ONEWIRE_CMD);
__enable_irq();
} else {
result = false;
}
pin_init_interrupt_in_isr_ctx();
__enable_irq();
}
return result;

View File

@ -41,7 +41,7 @@ public:
constexpr static const OneWiteTimeType RESET_MAX = 960;
constexpr static const OneWiteTimeType PRESENCE_TIMEOUT = 20;
constexpr static const OneWiteTimeType PRESENCE_MIN = 160;
constexpr static const OneWiteTimeType PRESENCE_MIN = 100;
constexpr static const OneWiteTimeType PRESENCE_MAX = 480;
constexpr static const OneWiteTimeType MSG_HIGH_TIMEOUT = 15000;