stm32f10x_conf.h 与 stm32f10x.h

简介: stm32f10x_conf.h 与 stm32f10x.h  刚才编写stm32外设的程序时注意到,新版的固件库V3.

stm32f10x_conf.h 与 stm32f10x.h  

刚才编写stm32外设的程序时注意到,新版的固件库V3.0以上 main等源文件中不再直接包含stm32f10x_conf.h,而是stm32f10x.h,stm32f10x.h则定义了启动设置,以及所有寄存器宏定义,此文件中需要注意的有:

1、device选择

#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 */     /*!< STM32F10X_LD: STM32 Low density devices */

  /* #define STM32F10X_LD_VL */  /*!< STM32F10X_LD_VL: STM32 Low density Value Line devices */  

  /* #define STM32F10X_MD */     /*!< STM32F10X_MD: STM32 Medium density devices */

   #define STM32F10X_MD

  /* #define STM32F10X_MD_VL */  /*!< STM32F10X_MD_VL: STM32 Medium density Value Line devices */  

  /* #define STM32F10X_HD */     /*!< STM32F10X_HD: STM32 High density devices */

  /* #define STM32F10X_HD_VL */  /*!< STM32F10X_HD_VL: STM32 High density value line devices */  

  /* #define STM32F10X_XL */     /*!< STM32F10X_XL: STM32 XL-density devices */

  /* #define STM32F10X_CL */     /*!< STM32F10X_CL: STM32 Connectivity line devices */

#endif

此段代码在stm32f10x.h的开始处,根据所用的器件 取消合适的注释。我常用的是stm32f103c8t6  属于Medium density Value Line devices.

2、外部时钟频率选择

#if !defined  HSE_VALUE

 #ifdef STM32F10X_CL   

  #define HSE_VALUE    ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */

 #else 

  #define HSE_VALUE    ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */

 #endif /* STM32F10X_CL */

#endif /* HSE_VALUE */

注意STM32F10X_CL,STM32F10X_CL是stm32f105 和stm32f107 互联型的device,用到此器件外部要选用25MHz的晶体,由于前面的代买没有取消  /* #define STM32F10X_CL */     /*!< STM32F10X_CL: STM32 Connectivity line devices */的注释,所以此处默认的外部8MHz的晶体

3、外设宏定义USE_STDPERIPH_DRIVER

#if !defined  USE_STDPERIPH_DRIVER

/**

 * @brief Comment the line below if you will not use the peripherals drivers.

   In this case, these drivers will not be included and the application code will 

   be based on direct access to peripherals registers 

   */

  /*#define USE_STDPERIPH_DRIVER*/

#endif

如果不适用片内外设,则不要取消  /*#define USE_STDPERIPH_DRIVER*/的注释

注意stm32f10x.h文件的最后有这样的代码:

#ifdef USE_STDPERIPH_DRIVER

  #include "stm32f10x_conf.h"

#endif

stm32f10x_conf.h中包含了所有外设的头文件,因此任意源文件只要包含了stm32f10x.h,就可以在源文件调用任意外设的函数。

若有外设为使用到,在stm32f10x_conf.h注释相应部分,项目编译时就不会在编译去掉的外设。

目录
相关文章
|
8月前
|
Rust 物联网 数据处理
Rust +时序数据库 TDengine:打造高性能时序数据处理利器
TDengine 是一款专为物联网、车联网、工业互联网等时序数据场景优化设计的开源时序数据库,支持高并发写入、高效查询及流式计算,通过“一个数据采集点一张表”与“超级表”的概念显著提升性能。 Rust 作为一门系统级编程语言,近年来在数据库、嵌入式系统、分布式服务等领域迅速崛起,以其内存安全、高性能著称,与 TDengine 的高效特性天然契合,适合构建高可靠、高性能的数据处理系统。
311 2
|
12月前
|
前端开发 JavaScript 虚拟化
React 树形组件 Tree View
本文从零开始构建了一个简单的React树形组件,介绍了环境准备、项目创建、基础组件构建等步骤,并探讨了常见问题及解决方案,包括层次嵌套过深、状态管理复杂、事件处理不当和样式问题,帮助读者在实际项目中更好地应用树形组件。
545 3
|
JSON 监控 数据格式
Grafana导入 json 文件的 dashboard 错误 Templating Failed to upgrade legacy queries Datasource xxx not found
Grafana导入 json 文件的 dashboard 错误 Templating Failed to upgrade legacy queries Datasource xxx not found
862 0
|
JavaScript 前端开发
uni-app组件 子组件onLoad、onReady事件无效
突然发现在项目中,组件 子组件的onLoad、onReady事件无效 打印也出不来值 怎么处理呢?
806 1
|
Linux 编译器 C语言
Linux 中 EXPORT_SYMBOL宏详解
Linux 中 EXPORT_SYMBOL宏详解
技术好文:UEFoliage工具拓展
技术好文:UEFoliage工具拓展
230 0
|
Kubernetes NoSQL Linux
Ubuntu18.04 gRPC编译安装
Ubuntu18.04 gRPC编译安装
成功解决pywintypes.com_error: (-2147221005, '无效的类字符串', None, None)
成功解决pywintypes.com_error: (-2147221005, '无效的类字符串', None, None)
成功解决pywintypes.com_error: (-2147221005, '无效的类字符串', None, None)
|
网络协议 机器人 中间件
单片机和FreeRTOS上跑机器人ROS的应用
单片机和FreeRTOS上跑机器人ROS的应用
670 0
报错:Keil5执行文件之后显示Target not created
报错:Keil5执行文件之后显示Target not created
3768 0