File tree 1 file changed +5
-7
lines changed
Filter options
1 file changed +5
-7
lines changed
Original file line number Diff line number Diff line change 17
17
//#include <limits.h>
18
18
#include "wiring_private.h"
19
19
#include "pins_arduino.h"
20
-
21
-
22
- extern uint32_t xthal_get_ccount ();
20
+ #include <hal/cpu_hal.h>
23
21
24
22
#define WAIT_FOR_PIN_STATE (state ) \
25
23
while (digitalRead(pin) != (state)) { \
26
- if (xthal_get_ccount () - start_cycle_count > timeout_cycles) { \
24
+ if (cpu_hal_get_cycle_count () - start_cycle_count > timeout_cycles) { \
27
25
return 0; \
28
26
} \
29
27
}
@@ -36,12 +34,12 @@ unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
36
34
timeout = max_timeout_us ;
37
35
}
38
36
const uint32_t timeout_cycles = microsecondsToClockCycles (timeout );
39
- const uint32_t start_cycle_count = xthal_get_ccount ();
37
+ const uint32_t start_cycle_count = cpu_hal_get_cycle_count ();
40
38
WAIT_FOR_PIN_STATE (!state );
41
39
WAIT_FOR_PIN_STATE (state );
42
- const uint32_t pulse_start_cycle_count = xthal_get_ccount ();
40
+ const uint32_t pulse_start_cycle_count = cpu_hal_get_cycle_count ();
43
41
WAIT_FOR_PIN_STATE (!state );
44
- return clockCyclesToMicroseconds (xthal_get_ccount () - pulse_start_cycle_count );
42
+ return clockCyclesToMicroseconds (cpu_hal_get_cycle_count () - pulse_start_cycle_count );
45
43
}
46
44
47
45
unsigned long pulseInLong (uint8_t pin , uint8_t state , unsigned long timeout )
You can’t perform that action at this time.
0 commit comments