少许等待后,就自动生成了代码。这里我们需要LED每隔1秒闪烁1次,我们利用系统SysTick定时器和系统里自带的延时函数来编程。我们打开stm32l4xx_hal.c,找到如下代码:
/**
* @brief Provide accurate delay (in milliseconds) based on variable incremented.
* @note In the default implementation , SysTick timer is the source of time base.
* It is used to generate interrupts at regular time intervals where uwTick
* is incremented.
* @note This function is declared as __weak to be overwritten in case of other
* implementations in user file.
* @param Delay: specifies the delay time length, in milliseconds.
* @retval None
*/
__weak void HAL_Delay(uint32_t Delay)
{
uint32_t tickstart = 0;
tickstart = HAL_GetTick();
while((HAL_GetTick() - tickstart) < Delay)
{
}
}