优化实现串口驱动,SPI驱动 W25QXX还需要初始化验证修复
This commit is contained in:
44
HAL/Src/arch/stm32f4/hal_stm32f4_delay.c
Normal file
44
HAL/Src/arch/stm32f4/hal_stm32f4_delay.c
Normal file
@ -0,0 +1,44 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : hal_stm32f4_delay.c
|
||||
* @brief : STM32F4 specific Delay HAL implementation
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
#include "hal.h"
|
||||
#include "hal_delay.h"
|
||||
#include "stm32f4xx_hal.h"
|
||||
|
||||
/**
|
||||
* @brief STM32F4 specific delay initialization
|
||||
*/
|
||||
void hal_stm32f4_delay_init(void) {
|
||||
/* Delay initialization is handled by HAL_Init() */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief STM32F4 specific delay in milliseconds
|
||||
* @param ms: Delay time in milliseconds
|
||||
*/
|
||||
void hal_stm32f4_delay_ms(uint32_t ms) {
|
||||
HAL_Delay(ms);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief STM32F4 specific delay in microseconds
|
||||
* @param us: Delay time in microseconds
|
||||
*/
|
||||
void hal_stm32f4_delay_us(uint32_t us) {
|
||||
uint32_t ticks = 0;
|
||||
uint32_t start_tick = 0;
|
||||
uint32_t tick_freq = HAL_RCC_GetHCLKFreq() / 1000000;
|
||||
|
||||
ticks = us * tick_freq;
|
||||
start_tick = HAL_GetTick() * tick_freq;
|
||||
|
||||
while ((HAL_GetTick() * tick_freq - start_tick) < ticks) {
|
||||
/* Busy wait */
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user