我是STM32的初学者,现有有问题不明白,向各位询问一下
#include "stm32f10x.h"
vu32 TimingDelay;
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_13|GPIO_Pin_3|GPIO_Pin_4;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOD,&GPIO_InitStructure);
}
void RCC_Configuration(void)
{
SystemInit();
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
}
void SysTick_Configuration(void)
{
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
NVIC_SystemHandlerPriorityConfig(SystemHandler_SysTick, 3, 0);
SysTick_SetReload(72000);
SysTick_ITConfig(ENABLE);
}
void Delay(u32 nTime)
{
TimingDelay = nTime;
SysTick_CounterCmd(SysTick_Counter_Enable);
while(TimingDelay != 0);
SysTick_CounterCmd(SysTick_Counter_Disable);
SysTick_CounterCmd(SysTick_Counter_Clear);
}
void SysTickHandler(void)
{
if(TimingDelay != 0)
TimingDelay--;
}
void InitAllPeriph(void)
{
GPIO_Configuration();
RCC_Configuration();
NVIC_Configuration();
SysTick_Configuration();
}
int main(void)
{
InitAllPeriph();
while(1)
{
GPIO_SetBits(GPIOD,GPIO_Pin_7);
Delay(1000);
GPIO_ResetBits(GPIOD,GPIO_Pin_7);
Delay(1000);
}
} |