#include "stm32f10x.h" #include "usart.h" #include "systick.h" volatile uint32_t TickCounter = 0; /************************************************************************** * systick_init **************************************************************************/ void SysTickInit(uint16_t ms, uint8_t priority) { RCC_ClocksTypeDef RCC_Clocks; RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(RCC_Clocks.SYSCLK_Frequency /(1000/ms)); NVIC_SetPriority (SysTick_IRQn, priority); } /************************************************************************** * SysTick_Handler **************************************************************************/ void SysTick_Handler(void) { TickCounter++; } ///************************************************ //函数名称 : delay_ms //功 能 : 软件延时 //参 数 : cnt 延迟时间 //返 回 值 : 无 //作 者 : sun //*************************************************/ //void delay_ms(uint32_t cnt) //{ // volatile uint32_t i = cnt * 4510; // // while(i--); //} ///************************************************ //函数名称 : delay_us //功 能 : 软件延时 //参 数 : cnt 延迟时间 //返 回 值 : 无 //作 者 : sun //*************************************************/ //void delay_us(uint32_t cnt) //{ // volatile uint32_t i = cnt * 4; // // while(i--); //}