3732|1

1万

帖子

28

TA的资源

裸片初长成(高级)

楼主
 

【晒心得】-- STM32F0xx的头文件USE_STDPERIPH_DRIVER宏的作用 [复制链接]

ST公司提供STM32F0xx的头文件STM32F0xx.h,编译器都要定义一个宏:USE_STDPERIPH_DRIVER,如果不定义它 ----  照ST公司的做法,就会出现问题,如

实际上,打开头文件研究一下就知道,关系到这个宏的地方只有两处:

第一处是:

#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 /* USE_STDPERIPH_DRIVER */

第二处是:

#ifdef USE_STDPERIPH_DRIVER
  #include "stm32f0xx_conf.h"
#endif


大家一看就应该明白,使用这个宏的目的只有一个,就是把头文件stm32f0xx_conf.h包含进来。

而stm32f0xx_conf.h头文件的除了包含所有硬件资源的头文件外,还包含有一个宏定义:

#include "stm32f0xx_adc.h"
#include "stm32f0xx_cec.h"
#include "stm32f0xx_crc.h"
……


/* Exported macro ------------------------------------------------------------*/
#ifdef  USE_FULL_ASSERT

/**
  * @brief  The assert_param macro is used for function's parameters check.
  * @param  expr: If expr is false, it calls assert_failed function which reports
  *         the name of the source file and the source line number of the call
  *         that failed. If expr is true, it returns no value.
  * @retval None
  */
  #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
  void assert_failed(uint8_t* file, uint32_t line);
#else
  #define assert_param(expr) ((void)0)
#endif /* USE_FULL_ASSERT */


可见,如果知道了它的使用目的,用户完全可以根据自己的喜好,随意更改之。
此帖出自stm32/stm8论坛

最新回复

预处理啦  详情 回复 发表于 2013-11-20 10:11
点赞 关注
 

回复
举报

272

帖子

0

TA的资源

纯净的硅(初级)

沙发
 
预处理啦
此帖出自stm32/stm8论坛
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/10 下一条
有奖直播:当AI遇见仿真,会有什么样的电子行业革新之路?
首场直播:Simcenter AI 赋能电子行业研发创新
直播时间:04月15日14:00-14:50

查看 »

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

 
机器人开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网 8

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表