STM32F0xx的头文件USE_STDPERIPH_DRIVER宏的作

http://bbs.21ic.com/icview-790448-1-1.html

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

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

第一处是:

  1. #if !defined USE_STDPERIPH_DRIVER
  2. /**
  3. * [url=home.php?mod=space&uid=247401]@brief[/url] Comment the line below if you will not use the peripherals drivers.
  4. In this case, these drivers will not be included and the application code will
  5. be based on direct access to peripherals registers
  6. */
  7. /*#define USE_STDPERIPH_DRIVER*/
  8. #endif /* USE_STDPERIPH_DRIVER */
第二处是:
  1. 第二处是:

  2. #ifdef USE_STDPERIPH_DRIVER
  3.   #include "stm32f0xx_conf.h"
  4. #endif
复制代码
而stm32f0xx_conf.h头文件的除了包含所有硬件资源的头文件外,还包含有一个宏定义:
  1. #include "stm32f0xx_adc.h"
  2. #include "stm32f0xx_cec.h"
  3. #include "stm32f0xx_crc.h"
  4. ……


  5. /* Exported macro ------------------------------------------------------------*/
  6. #ifdef  USE_FULL_ASSERT

  7. /**
  8.   * [url=home.php?mod=space&uid=247401]@brief[/url]  The assert_param macro is used for function's parameters check.
  9.   * @param  expr: If expr is false, it calls assert_failed function which reports
  10.   *         the name of the source file and the source line number of the call
  11.   *         that failed. If expr is true, it returns no value.
  12.   * @retval None
  13.   */
  14.   #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
  15. /* Exported functions ------------------------------------------------------- */
  16.   void assert_failed(uint8_t* file, uint32_t line);
  17. #else
  18.   #define assert_param(expr) ((void)0)
  19. #endif /* USE_FULL_ASSERT */
复制代码

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值