对于新手来说,编译STM32工程的时候时常会遇到找不到定义的问题,如下:
..\HARDWARE\EXTI\exti.c(4): error: #20: identifier "EXTI_InitTypeDef" is undefined
EXTI_InitTypeDef EXTI_InitStructure;//定?宄?始化?峁???
..\HARDWARE\EXTI\exti.c(17): error: #20: identifier "EXTI_Line2" is undefined
EXTI_InitStructure.EXTI_Line=EXTI_Line2; //?卸??叩谋旰? 取值范围为EXTI_Line0~EXTI_Line15
..\HARDWARE\EXTI\exti.c(18): error: #20: identifier "EXTI_Mode_Interrupt" is undefined
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;//?卸?模式,??选值为?卸? EXTI_Mode_Interrupt ???录? EXTI_Mode_Event。
..\HARDWARE\EXTI\exti.c(19): error: #20: identifier "EXTI_Trigger_Falling" is undefined
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;//触发方式,???????陆??卮シ? EXTI_Trigger_Falling,?????卮シ? EXTI_Trigger_Rising,???????獾?平(?????睾??陆??兀┐シ?EXTI_Trigger_Rising_Falling
..\HARDWARE\EXTI\exti.c(21): warning: #223-D: function "EXTI_Init" declared implicitly
EXTI_Init(&EXTI_InitStructure);//?萁峁?????息???谐?始化
..\HARDWARE\EXTI\exti.c(33): warning: #223-D: function "EXTI_GetITStatus" declared implicitly
if(EXTI_GetITStatus(EXTI_Line2)!=RESET)//?卸?某?????系??卸??欠穹???
..\HARDWARE\EXTI\exti.c(33): error: #20: identifier "EXTI_Line2" is undefined
if(EXTI_GetITStatus(EXTI_Line2)!=RESET)//?卸?某?????系??卸??欠穹???
..\HARDWARE\EXTI\exti.c(37): warning: #223-D: function "EXTI_ClearITPendingBit" declared implicitly
EXTI_ClearITPendingBit(EXTI_Line2); //?宄? LINE ?系??卸媳?志位
..\HARDWARE\EXTI\exti.c: 3 warnings, 5 errors
stm32f10x_it.c(86): warning: #223-D: function "TIM_GetITStatus" declared implicitly
if(TIM_GetITStatus(TIM2,TIM_IT_Update)!=RESET)
stm32f10x_it.c(86): error: #20: identifier "TIM_IT_Update" is undefined
if(TIM_GetITStatus(
IM2,TIM_IT_Update)!=RESET)
stm32f10x_it.c(89): warning: #223-D: function "TIM_ClearITPendingBit" declared implicitly
TIM_ClearITPendingBit(TIM2,TIM_IT_Update);
其实解决方法很简单,就是在工程中引入官方库函数,通常在一个完整的库函数工程中,会存在这个文件夹:STM32F10x_FWLib,这个文件夹中的文件就是库函数所在,完整的文件夹中通常会存在以下文件:
├─inc
│ misc.h
│ stm32f10x_adc.h
│ stm32f10x_bkp.h
│ stm32f10x_can.h
│ stm32f10x_cec.h
│ stm32f10x_crc.h
│ stm32f10x_dac.h
│ stm32f10x_dbgmcu.h
│ stm32f10x_dma.h
│ stm32f10x_exti.h
│ stm32f10x_flash.h
│ stm32f10x_fsmc.h
│ stm32f10x_gpio.h
│ stm32f10x_i2c.h
│ stm32f10x_iwdg.h
│ stm32f10x_pwr.h
│ stm32f10x_rcc.h
│ stm32f10x_rtc.h
│ stm32f10x_sdio.h
│ stm32f10x_spi.h
│ stm32f10x_tim.h
│ stm32f10x_usart.h
│ stm32f10x_wwdg.h
│
└─src
misc.c
stm32f10x_adc.c
stm32f10x_bkp.c
stm32f10x_can.c
stm32f10x_cec.c
stm32f10x_crc.c
stm32f10x_dac.c
stm32f10x_dbgmcu.c
stm32f10x_dma.c
stm32f10x_exti.c
stm32f10x_flash.c
stm32f10x_fsmc.c
stm32f10x_gpio.c
stm32f10x_i2c.c
stm32f10x_iwdg.c
stm32f10x_pwr.c
stm32f10x_rcc.c
stm32f10x_rtc.c
stm32f10x_sdio.c
stm32f10x_spi.c
stm32f10x_tim.c
stm32f10x_usart.c
stm32f10x_wwdg.c
则时候,如果用到某些功能的时候,在sys.h中引入对应的头文件,然后将对应的*.c文件加入工程编译即可解决问题。