<span]
<span]
<span]#define PA1 GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_1) <span]
<span]{ <span] RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); <span] GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; <span] GPIO_Init(GPIOA,&GPIO_InitStructure); <span] GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2; <span] GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; <span]} <span]void NVIC_Configuration() <span] NVIC_InitTypeDef NVIC_InitStructure; <span] NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn; <span] NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; <span] NVIC_Init(&NVIC_InitStructure); <span]
<span]{ <span] RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE); <span] TIM_TimeBaseStructure.TIM_Prescaler = 7200; <span] TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; <span] TIM_ClearITPendingBit(TIM3,TIM_IT_Update); <span] NVIC_Configuration();// <span]} <span]void TIM3_IRQHandler(void)// <span] if(TIM_GetITStatus(TIM3,TIM_IT_Update) == SET) <span] void avoiding(); <span] TIM_ClearITPendingBit(TIM3,TIM_IT_Update); <span]
<span]{ <span] GPIO_ResetBits(GPIOA,GPIO_Pin_4|GPIO_Pin_6); <span]
<span]{ <span] GPIO_ResetBits(GPIOA,GPIO_Pin_4|GPIO_Pin_6|GPIO_Pin_5); <span]
<span]{ <span] GPIO_ResetBits(GPIOA,GPIO_Pin_4|GPIO_Pin_6|GPIO_Pin_3); <span]
<span]{ <span] if((PA0 == 0)&&(PA1 == 1)&&(PA2 == 0)) left(); <span] if(((PA0 == 1)&&(PA1 ==1)&&(PA2 ==0))|| <span] if(((PA0 == 0)&&(PA1 ==1)&&(PA2 ==1))|| <span] if((PA0 == 0)&&(PA1 == 0)&&(PA1 == 0)) right(); <span]
<span]
<span]{ <span] GPIO_Configuration(); <span] while(1) <span] GPIO_SetBits(GPIOA,GPIO_Pin_3|GPIO_Pin_5); <span] } <span]
我的小车只执行
while(1)
{
GPIO_SetBits(GPIOA,GPIO_Pin_3|GPIO_Pin_5);
GPIO_ResetBits(GPIOA,GPIO_Pin_4|GPIO_Pin_6);
}
不知道怎么办,求各位大神帮帮忙,
|