Add back microsecond delay to STM32
This commit is contained in:
parent
a56170d7f8
commit
653b7619ec
@ -42,9 +42,12 @@
|
|||||||
#include "stm32f4xx_hal.h"
|
#include "stm32f4xx_hal.h"
|
||||||
|
|
||||||
void common_hal_mcu_delay_us(uint32_t delay) {
|
void common_hal_mcu_delay_us(uint32_t delay) {
|
||||||
if (__get_PRIMASK() == 0x00000000) {
|
uint32_t ticks_per_us = HAL_RCC_GetSysClockFreq()/1000000;
|
||||||
} else {
|
delay *= ticks_per_us;
|
||||||
}
|
SysTick->LOAD = delay;
|
||||||
|
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk;
|
||||||
|
while ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == 0) {}
|
||||||
|
SysTick->CTRL = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
volatile uint32_t nesting_count = 0;
|
volatile uint32_t nesting_count = 0;
|
||||||
|
@ -122,7 +122,7 @@
|
|||||||
* @brief External Low Speed oscillator (LSE) value.
|
* @brief External Low Speed oscillator (LSE) value.
|
||||||
*/
|
*/
|
||||||
#if !defined (LSE_VALUE)
|
#if !defined (LSE_VALUE)
|
||||||
#define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
|
#define LSE_VALUE 32768 /*!< Value of the External Low Speed oscillator in Hz */
|
||||||
#endif /* LSE_VALUE */
|
#endif /* LSE_VALUE */
|
||||||
|
|
||||||
#if !defined (LSE_STARTUP_TIMEOUT)
|
#if !defined (LSE_STARTUP_TIMEOUT)
|
||||||
|
Loading…
Reference in New Issue
Block a user