mirror of
https://github.com/esphome/esphome.git
synced 2024-12-24 14:34:54 +01:00
pulse_counter_ulp: only read valid bits of ulp_edge_count
This commit is contained in:
parent
bd8858e053
commit
7cd5bad1c2
2 changed files with 3 additions and 2 deletions
|
@ -64,6 +64,7 @@ bool UlpPulseCounterStorage::pulse_counter_setup(InternalGPIOPin *pin) {
|
|||
*
|
||||
* Note that the ULP reads only the lower 16 bits of these variables.
|
||||
*/
|
||||
ulp_edge_count = 0;
|
||||
ulp_debounce_counter = 3;
|
||||
ulp_debounce_max_count = 3;
|
||||
ulp_next_edge = 0;
|
||||
|
@ -91,7 +92,7 @@ bool UlpPulseCounterStorage::pulse_counter_setup(InternalGPIOPin *pin) {
|
|||
|
||||
pulse_counter_t UlpPulseCounterStorage::read_raw_value() {
|
||||
// TODO count edges separately
|
||||
uint32_t count = ulp_edge_count;
|
||||
auto count = static_cast<pulse_counter_t>(ulp_edge_count);
|
||||
ulp_edge_count = 0;
|
||||
return count;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace pulse_counter_ulp {
|
|||
|
||||
enum class CountMode { disable = 0, increment = 1, decrement = -1 };
|
||||
|
||||
using pulse_counter_t = int32_t;
|
||||
using pulse_counter_t = int16_t;
|
||||
using timestamp_t = int64_t;
|
||||
|
||||
struct UlpPulseCounterStorage {
|
||||
|
|
Loading…
Reference in a new issue