新手菜鸟急需帮助!"NVIC_InitTypeDef" is undefined 没定义问题!!!!!!

2019-03-23 20:19发布

    RT!! 部份代码如下: 编译时出了两个错:..main.c(137): error:  #20: identifier "NVIC_InitTypeDef" is undefined                              ..main.c(143): warning:  #223-D: function "NVIC_Init" declared implicitly 求大神帮忙!!!!              感谢!!       #include "stm32f10x.h"
#include "stm32f10x_exti.h" /* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
void RCC_Configuration(void);
void GPIO_Configuration(void);
void EXTI_Config(void);
void NVIC_Configuration(void);
void delay(void); /* Private functions ---------------------------------------------------------*/ int main(void)
{
   u8 flag0;
   u8 flag1;
   u8 pin0;
   u8 pin1;
   pin0=0;
   pin1=0;
   flag0=1;
   flag1=1;
  /* System Clocks Configuration */
  RCC_Configuration();   /* GPIO Configuration */
  GPIO_Configuration();    EXTI_Config();
   NVIC_Configuration();   GPIO_SetBits(GPIOD, GPIO_Pin_12);
   delay();
   
  
  while (1)
  {  
   
  pin1=GPIO_ReadInputDataBit(GPIOD,GPIO_Pin_14);
  if(0x00==pin1)
  {
    if(flag1==1)
  {
       GPIO_ResetBits(GPIOD, GPIO_Pin_12);
    delay();
        GPIO_SetBits(GPIOD, GPIO_Pin_13);
    delay();
  
    flag1=0;
  }
   }
  pin0=GPIO_ReadInputDataBit(GPIOD,GPIO_Pin_15);
  if(0x00==pin0)
   {
     if(flag0==1)
  {
       GPIO_ResetBits(GPIOD, GPIO_Pin_12);
          delay();
   
          GPIO_ResetBits(GPIOD, GPIO_Pin_13);
          delay();
   
    flag0=0;
         }
  }
  if((0x01==pin0)&(0x01==pin1))
    {
      flag0=1;
      flag1=1;
   GPIO_SetBits(GPIOD, GPIO_Pin_12);
         delay();
        
    }
  }
} /**
  * @brief  Configures the different system clocks.
  * @param  None
  * @retval None
  */
void RCC_Configuration(void)
{
  /* GPIOD clock enable */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO, ENABLE); }
void GPIO_Configuration(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;   /* GPIOD Configuration: Channel 2N,3N as alternate function push-pull */   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12| GPIO_Pin_13;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_Init(GPIOD, &GPIO_InitStructure);
  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_2|GPIO_Pin_14| GPIO_Pin_15;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  GPIO_Init(GPIOD, &GPIO_InitStructure);
} void EXTI_Config(void)
{
  EXTI_InitTypeDef EXTI_InitStructure;
  GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource2);
  EXTI_ClearITPendingBit(EXTI_Line2);
  EXTI_InitStructure.EXTI_Mode=EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger=EXTI_Trigger_Rising;
  EXTI_InitStructure.EXTI_Line=EXTI_Line2;
  EXTI_InitStructure.EXTI_LineCmd=ENABLE;
  EXTI_Init(&EXTI_InitStructure);
} /**
  * @brief  Configure the nested vectored interrupt controller.
  * @param  None
  * @retval None
  */
void NVIC_Configuration(void)
{
   NVIC_InitTypeDef NVIC_InitStructure;         
  /* Enable DMA1 channel6 IRQ Channel */
  NVIC_InitStructure.NVIC_IRQChannel = EXTI2_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
} void EXTI2_IRQHandler (void)
{
  if(EXTI_GetITStatus(EXTI_Line2)!= RESET)
  {
   EXTI_ClearITPendingBit(EXTI_Line2);
  }
} void delay()
{
  int i;
  for (i=0; i<0xfffff; i++)
    ;
}
此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。