版权声明:如需转载请标注 https://blog.csdn.net/weixin_40973138/article/details/85219276
本工程板级支持包文件适用于野火stm32f429 开发板。
bsp_systick.c
/**
******************************************************************************
* @file bsp_systick.c
* @author Waao
* @version V1.0.0
* @date 22-Dec-2018
* @brief This file contains some board support package's functions for the configuration of the SysTick.
*
******************************************************************************
* @attention
*
* None
*
******************************************************************************
*/
#include <bsp_systick.h>
__IO uint32_t TimingDelay;
/**
* @brief Configure the NVIC
* @param None
* @retval None
*/
void SysTick_Init(void)
{
/*SysTick_Config(): This function will do most of the essential work of the Initialization of the SysTick for us.
* We just need to configure the length of time the interrupt was triggered.
*/
while(SysTick_Config(SystemCoreClock / 100000) != 0);
}
/**
* @brief Delay
* @param times : While generate a interrupt, the times that SysTick turn to 0 you want.
* @retval None
*/
void Delay(uint32_t times)
{
TimingDelay = times;
while(TimingDelay != 0);
}
/**
* @brief Waiting the TimingDelay decrease to 0
* @param None
* @retval None
*/
void TimingDelay_Decrease(void)
{
if(TimingDelay != 0)
{
TimingDelay--;
}
}
bsp_systick.h
/**
******************************************************************************
* @file bsp_systick.c
* @author Waao
* @version V1.0.0
* @date 22-Dec-2018
* @brief This file contains some board support package's functions for the configuration of the SysTick.
*
******************************************************************************
* @attention
*
* None
*
******************************************************************************
*/
#ifndef __BSP_SYSTICK_H_
#define __BSP_SYSTICK_H_
#include <stm32f4xx.h>
void SysTick_Init(void);
void Delay(uint32_t times);
void TimingDelay_Decrease(void);
#endif
stm32f4xx_it.c
/**
* @brief This function handles SysTick Handler.
* @param None
* @retval None
*/
void SysTick_Handler(void)
{
TimingDelay_Decrease();
}
main.c
#include <bsp_exti.h>
#include <bsp_key.h>
#include <bsp_led.h>
#include <bsp_systick.h>
int main(void)
{
LED_GPIO_Config();
LED2_OFF;
LED3_OFF
SysTick_Init();
while(1)
{
LED1_TOGGLE;
Delay(100000);
}
}