STM32-STM32CubeIDE如何将头文件和宏加入到工程设置

 将头文件的目录添加到【C/C++ Build】->【Settings】->【Tool Settings】->【MCU GCC Compiler】->【Include paths】

 

  将宏定义编译进工程【C/C++ Build】->【Settings】->【Tool Settings】->【MCU GCC Compiler】->【Preprocessor】

 

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
由于STM32F10x.h头文件比较大,这里只展示其中部分主要内容的代码。完整的STM32F10x.h头文件可以在STMicroelectronics官网上下载。 ```c #ifndef __STM32F10x_H #define __STM32F10x_H #include "core_cm3.h" // CMSIS头文件,包含Cortex-M3内核相关的和函数 // 定义STM32F10x系列微控制器的型号,例如STM32F103xB #if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && \ !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL) #define STM32F10X_LD #endif // 定义STM32F10x系列微控制器的系统时钟频率 #if !defined HSI_VALUE #define HSI_VALUE ((uint32_t)8000000) /*!< Value of the Internal oscillator in Hz*/ #endif /* HSI_VALUE */ #if !defined HSE_VALUE #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #define SYSCLK_FREQ_HSI HSI_VALUE /*!< System clock frequency with HSI as reference clock */ #define SYSCLK_FREQ_72MHz 72000000UL /*!< System clock frequency with PLL enabled and HSE as reference clock */ // 定义一些常用的类型和 typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState; typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus, BitStatus; typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus; #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) #define IS_FLAG_STATUS(STATUS) (((STATUS) == RESET) || ((STATUS) == SET)) #define IS_IT_STATUS(STATUS) (((STATUS) == RESET) || ((STATUS) == SET)) #define IS_BIT_STATUS(STATUS) (((STATUS) == RESET) || ((STATUS) == SET)) #define IS_ERROR_STATUS(STATUS) (((STATUS) == ERROR) || ((STATUS) == SUCCESS)) // 定义IO口类型 typedef struct { __IO uint32_t CRL; __IO uint32_t CRH; __IO uint32_t IDR; __IO uint32_t ODR; __IO uint32_t BSRR; __IO uint32_t BRR; __IO uint32_t LCKR; } GPIO_TypeDef; // 定义外设寄存器类型 typedef struct { __IO uint32_t CR1; __IO uint32_t CR2; __IO uint32_t SR; __IO uint32_t DR; __IO uint32_t CRCPR; __IO uint32_t RXCRCR; __IO uint32_t TXCRCR; __IO uint32_t I2SCFGR; } SPI_TypeDef; // 定义一些常用的函数 void NVIC_EnableIRQ(IRQn_Type IRQn); void GPIO_Init(GPIO_TypeDef* GPIOx, uint32_t GPIO_Pin, uint32_t GPIO_Mode); #endif /* __STM32F10x_H */ ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值