STM32標准外設庫中USE_STDPERIPH_DRIVER, STM32F10X_MD的含義


    在項目中使用stm32標准外設庫(STM32F10x Standard Peripherals Library)的時候,我們會在項目的選項中預定義兩個宏定義:USE_STDPERIPH_DRIVER, STM32F10X_MD,如下圖:

這兩個的作用是什么呢?

1、 USE_STDPERIPH_DRIVER : to use or not the peripheral’s drivers in application code (i.e. code will be based on direct access to peripheral’s registers rather than drivers API) , this option is controlled by the #define USE_STDPERIPH_DRIVER

    即這個定義控制了是否在應用中啟用外設驅動。我們使用標准外設庫本來就為了方便控制外設,所以要添加這個定義,以啟用外設驅動。

2、STM32F10X_MD:

    STM32有幾個大類:

 

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

  /* #define STM32F10X_LD */      /*!< STM32 Low density devices */ 


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

  /* #define STM32F10X_MD */      /*!< STM32 Medium density devices */ 
  /* #define STM32F10X_HD_VL */   /*!< STM32 High density Value line devices */ 
  /* #define STM32F10X_HD */      /*!< STM32 High density devices */ 

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

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

 

每種類別都有所區別,例如sram或者flash或者外設數量不一樣,所以stm32標准外設庫必須根據你使用的處理器來做相應的預處理。

This define will control the declaration of the following part of the Standard Peripherals library:

  • IRQ channel definition
  • Peripheral memory mapping and physical registers address definition
  • Peripheral pointer declaration and driver header file inclusion
  • Product miscellaneous configuration: external quartz (HSE) value…
  • Peripheral with Features w/ different/incompatible implementation across the family

Note : This define doesn’t apply to peripheral drivers, these drivers are always supporting features of the family’s superset.

User has only to select which device he will use by controlling preprocessor define declared in stm32f10x.h file ( No selected device by default) then the library will be configured accordingly。

 

這兩個定義都在stm32f10x.h里面,可以在這里面做定義(把注釋去掉),不一定非要在option->C/C++那里添加.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM