File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 37
37
} \
38
38
} \
39
39
} while (0)
40
+ #define wait_cpuclock (n ) __builtin_avr_delay_cycles(n)
41
+ #define CPU_CLOCK F_CPU
40
42
41
43
/* The AVR series GPIOs have a one clock read delay for changes in the digital input signal.
42
44
* But here's more margin to make it two clocks. */
43
45
#ifndef GPIO_INPUT_PIN_DELAY
44
46
# define GPIO_INPUT_PIN_DELAY 2
45
47
#endif
46
48
47
- #define waitInputPinDelay () __builtin_avr_delay_cycles (GPIO_INPUT_PIN_DELAY)
49
+ #define waitInputPinDelay () wait_cpuclock (GPIO_INPUT_PIN_DELAY)
Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ void wait_us(uint16_t duration);
41
41
} while (0)
42
42
#endif
43
43
44
+ #include "_wait.c"
45
+
46
+ #define CPU_CLOCK STM32_SYSCLK
47
+
44
48
/* For GPIOs on ARM-based MCUs, the input pins are sampled by the clock of the bus
45
49
* to which the GPIO is connected.
46
50
* The connected buses differ depending on the various series of MCUs.
@@ -51,11 +55,8 @@ void wait_us(uint16_t duration);
51
55
* If the GPIO_INPUT_PIN_DELAY macro is not defined, the following default values will be used.
52
56
* (A fairly large value of 0.25 microseconds is set.)
53
57
*/
54
-
55
- #include "_wait.c"
56
-
57
58
#ifndef GPIO_INPUT_PIN_DELAY
58
- # define GPIO_INPUT_PIN_DELAY (STM32_SYSCLK / 1000000L / 4)
59
+ # define GPIO_INPUT_PIN_DELAY (CPU_CLOCK / 1000000L / 4)
59
60
#endif
60
61
61
62
#define waitInputPinDelay () wait_cpuclock(GPIO_INPUT_PIN_DELAY)
You can’t perform that action at this time.
0 commit comments