add wait_cpuclock() macro for AVR and CPU_CLOCK macro (#12755)
This commit is contained in:
parent
c4dbf4bf01
commit
c9c60d227e
@ -37,6 +37,8 @@
|
|||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#define wait_cpuclock(n) __builtin_avr_delay_cycles(n)
|
||||||
|
#define CPU_CLOCK F_CPU
|
||||||
|
|
||||||
/* The AVR series GPIOs have a one clock read delay for changes in the digital input signal.
|
/* The AVR series GPIOs have a one clock read delay for changes in the digital input signal.
|
||||||
* But here's more margin to make it two clocks. */
|
* But here's more margin to make it two clocks. */
|
||||||
@ -44,4 +46,4 @@
|
|||||||
# define GPIO_INPUT_PIN_DELAY 2
|
# define GPIO_INPUT_PIN_DELAY 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define waitInputPinDelay() __builtin_avr_delay_cycles(GPIO_INPUT_PIN_DELAY)
|
#define waitInputPinDelay() wait_cpuclock(GPIO_INPUT_PIN_DELAY)
|
||||||
|
@ -41,6 +41,10 @@ void wait_us(uint16_t duration);
|
|||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "_wait.c"
|
||||||
|
|
||||||
|
#define CPU_CLOCK STM32_SYSCLK
|
||||||
|
|
||||||
/* For GPIOs on ARM-based MCUs, the input pins are sampled by the clock of the bus
|
/* For GPIOs on ARM-based MCUs, the input pins are sampled by the clock of the bus
|
||||||
* to which the GPIO is connected.
|
* to which the GPIO is connected.
|
||||||
* The connected buses differ depending on the various series of MCUs.
|
* The connected buses differ depending on the various series of MCUs.
|
||||||
@ -51,11 +55,8 @@ void wait_us(uint16_t duration);
|
|||||||
* If the GPIO_INPUT_PIN_DELAY macro is not defined, the following default values will be used.
|
* If the GPIO_INPUT_PIN_DELAY macro is not defined, the following default values will be used.
|
||||||
* (A fairly large value of 0.25 microseconds is set.)
|
* (A fairly large value of 0.25 microseconds is set.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "_wait.c"
|
|
||||||
|
|
||||||
#ifndef GPIO_INPUT_PIN_DELAY
|
#ifndef GPIO_INPUT_PIN_DELAY
|
||||||
# define GPIO_INPUT_PIN_DELAY (STM32_SYSCLK / 1000000L / 4)
|
# define GPIO_INPUT_PIN_DELAY (CPU_CLOCK / 1000000L / 4)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define waitInputPinDelay() wait_cpuclock(GPIO_INPUT_PIN_DELAY)
|
#define waitInputPinDelay() wait_cpuclock(GPIO_INPUT_PIN_DELAY)
|
||||||
|
Loading…
Reference in New Issue
Block a user