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 */
複製代碼

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章