你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

STM32F4 C++ 封装库 之 EXTI

[复制链接]
XinLiYF 发布时间:2018-4-4 20:20
本帖最后由 XinLiYF 于 2018-4-4 20:23 编辑

STM32F4 C++ 封装库 之 EXTI

       这几天看了下 mbed 的源码,给上层应用调用的接口封装的还是不错的。代码质量比较高,注释也很详细,文档和例程比较全。但是驱动层的程序全是 C 语言编写的,代码质量就没有那么高了,注释比较少而且不规范,比较怀疑 mbed 的稳定性。mbed 的实时内核是用的 RTX5 ,文件系统用的 FatFs ,还有一些开源的协议栈,整套系统比较繁杂。mbed 框架是为物联网设备开发的,工业控制级别的产品可以考虑用 RTE 框架。RTE 框架目前驱动层程序还不太完善,有好多需要自己去实现,可能在过一段时间会好一些吧。总之物联网产品可以用 mbed ,工业控制产品可以用 RTE 。这几天封装了 EXTI ,距离整套系统可以产生生产力还有很长的距离要走,我也不知道整个系统会成什么样子,我能坚持多久,不管了先做再说。在这里分享我的 STM32F4 C++ 封装之旅。今天分享《STM32F4 C++ 封装库 之 EXTI》,直接上代码了~

stm32f4xx_xexti.h 文件
  1. /**
  2.   ******************************************************************************
  3.   * \file    stm32f4xx_xexti.h
  4.   * \author  XinLi
  5.   * \version v1.0
  6.   * \date    20-March-2018
  7.   * \brief   Header file for external interrupt/event controller module.
  8.   ******************************************************************************
  9.   * \attention
  10.   *
  11.   * <h2><center>Copyright © 2018 XinLi</center></h2>
  12.   *
  13.   * This program is free software: you can redistribute it and/or modify
  14.   * it under the terms of the GNU General Public License as published by
  15.   * the Free Software Foundation, either version 3 of the License, or
  16.   * (at your option) any later version.
  17.   *
  18.   * This program is distributed in the hope that it will be useful,
  19.   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.   * GNU General Public License for more details.
  22.   *
  23.   * You should have received a copy of the GNU General Public License
  24.   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  25.   *
  26.   ******************************************************************************
  27.   */

  28. #ifndef STM32F4XX_XEXTI_H
  29. #define STM32F4XX_XEXTI_H

  30. #include "stm32f4xx_ll_exti.h"

  31. /*! External interrupt/event controller module. */
  32. class XExti
  33. {
  34. public:
  35.   /*! Enumerate of EXTI lines. */
  36.   enum ExtiLine
  37.   {
  38.     Line0  = LL_EXTI_LINE_0,  /*!< EXTI line 0. */
  39.     Line1  = LL_EXTI_LINE_1,  /*!< EXTI line 1. */
  40.     Line2  = LL_EXTI_LINE_2,  /*!< EXTI line 2. */
  41.     Line3  = LL_EXTI_LINE_3,  /*!< EXTI line 3. */
  42.     Line4  = LL_EXTI_LINE_4,  /*!< EXTI line 4. */
  43.     Line5  = LL_EXTI_LINE_5,  /*!< EXTI line 5. */
  44.     Line6  = LL_EXTI_LINE_6,  /*!< EXTI line 6. */
  45.     Line7  = LL_EXTI_LINE_7,  /*!< EXTI line 7. */
  46.     Line8  = LL_EXTI_LINE_8,  /*!< EXTI line 8. */
  47.     Line9  = LL_EXTI_LINE_9,  /*!< EXTI line 9. */
  48.     Line10 = LL_EXTI_LINE_10, /*!< EXTI line 10. */
  49.     Line11 = LL_EXTI_LINE_11, /*!< EXTI line 11. */
  50.     Line12 = LL_EXTI_LINE_12, /*!< EXTI line 12. */
  51.     Line13 = LL_EXTI_LINE_13, /*!< EXTI line 13. */
  52.     Line14 = LL_EXTI_LINE_14, /*!< EXTI line 14. */
  53.     Line15 = LL_EXTI_LINE_15, /*!< EXTI line 15. */
  54.   #ifdef LL_EXTI_LINE_16
  55.     Line16 = LL_EXTI_LINE_16, /*!< EXTI line 16. */
  56.   #endif
  57.   #ifdef LL_EXTI_LINE_17
  58.     Line17 = LL_EXTI_LINE_17, /*!< EXTI line 17. */
  59.   #endif
  60.   #ifdef LL_EXTI_LINE_18
  61.     Line18 = LL_EXTI_LINE_18, /*!< EXTI line 18. */
  62.   #endif
  63.   #ifdef LL_EXTI_LINE_19
  64.     Line19 = LL_EXTI_LINE_19, /*!< EXTI line 19. */
  65.   #endif
  66.   #ifdef LL_EXTI_LINE_20
  67.     Line20 = LL_EXTI_LINE_20, /*!< EXTI line 20. */
  68.   #endif
  69.   #ifdef LL_EXTI_LINE_21
  70.     Line21 = LL_EXTI_LINE_21, /*!< EXTI line 21. */
  71.   #endif
  72.   #ifdef LL_EXTI_LINE_22
  73.     Line22 = LL_EXTI_LINE_22, /*!< EXTI line 22. */
  74.   #endif
  75.   #ifdef LL_EXTI_LINE_23
  76.     Line23 = LL_EXTI_LINE_23, /*!< EXTI line 23. */
  77.   #endif
  78.   #ifdef LL_EXTI_LINE_24
  79.     Line24 = LL_EXTI_LINE_24, /*!< EXTI line 24. */
  80.   #endif
  81.   #ifdef LL_EXTI_LINE_25
  82.     Line25 = LL_EXTI_LINE_25, /*!< EXTI line 25. */
  83.   #endif
  84.   #ifdef LL_EXTI_LINE_26
  85.     Line26 = LL_EXTI_LINE_26, /*!< EXTI line 26. */
  86.   #endif
  87.   #ifdef LL_EXTI_LINE_27
  88.     Line27 = LL_EXTI_LINE_27, /*!< EXTI line 27. */
  89.   #endif
  90.   #ifdef LL_EXTI_LINE_28
  91.     Line28 = LL_EXTI_LINE_28, /*!< EXTI line 28. */
  92.   #endif
  93.   #ifdef LL_EXTI_LINE_29
  94.     Line29 = LL_EXTI_LINE_29, /*!< EXTI line 29. */
  95.   #endif
  96.   #ifdef LL_EXTI_LINE_30
  97.     Line30 = LL_EXTI_LINE_30, /*!< EXTI line 30. */
  98.   #endif
  99.   #ifdef LL_EXTI_LINE_31
  100.     Line31 = LL_EXTI_LINE_31, /*!< EXTI line 31. */
  101.   #endif
  102.   };
  103.   
  104.   /*! Enumerate of EXTI modes. */
  105.   enum ExtiMode
  106.   {
  107.     ModeInterrupt      = LL_EXTI_MODE_IT,       /*!< EXTI interrupt mode. */
  108.     ModeEvent          = LL_EXTI_MODE_EVENT,    /*!< EXTI event mode. */
  109.     ModeInterruptEvent = LL_EXTI_MODE_IT_EVENT, /*!< EXTI interrupt and event mode. */
  110.   };
  111.   
  112.   /*! Enumerate of EXTI triggers. */
  113.   enum ExtiTrigger
  114.   {
  115.     TriggerNone          = LL_EXTI_TRIGGER_NONE,           /*!< EXTI none trigger. */
  116.     TriggerRising        = LL_EXTI_TRIGGER_RISING,         /*!< EXTI rising trigger. */
  117.     TriggerFalling       = LL_EXTI_TRIGGER_FALLING,        /*!< EXTI falling trigger. */
  118.     TriggerRisingFalling = LL_EXTI_TRIGGER_RISING_FALLING, /*!< EXTI rising and falling trigger. */
  119.   };
  120.   
  121.   XExti(ExtiLine line, ExtiMode mode, ExtiTrigger trigger = TriggerNone);
  122.   virtual ~XExti();
  123.   
  124.   void setLine(ExtiLine line);
  125.   ExtiLine getLine() const;
  126.   
  127.   void setMode(ExtiMode mode);
  128.   ExtiMode getMode() const;
  129.   
  130.   void setTrigger(ExtiTrigger trigger);
  131.   ExtiTrigger getTrigger() const;
  132.   
  133.   void setFlag();
  134.   void clearFlag();
  135.   
  136.   bool isFlagSet() const;
  137.   
  138.   bool open();
  139.   void close();
  140.   
  141.   bool isOpen() const;
  142.   
  143. private:
  144.   ExtiLine    line;
  145.   ExtiMode    mode;
  146.   ExtiTrigger trigger;
  147.   bool        openFlag;
  148.   
  149.   XExti(const XExti &) = delete;
  150.   XExti & operator = (const XExti &) = delete;
  151. };

  152. #endif // STM32F4XX_XEXTI_H
复制代码

stm32f4xx_xexti.cpp 文件
  1. /**
  2.   ******************************************************************************
  3.   * \file    stm32f4xx_xexti.cpp
  4.   * \author  XinLi
  5.   * \version v1.0
  6.   * \date    20-March-2018
  7.   * \brief   External interrupt/event controller module driver.
  8.   ******************************************************************************
  9.   * \attention
  10.   *
  11.   * <h2><center>Copyright © 2018 XinLi</center></h2>
  12.   *
  13.   * This program is free software: you can redistribute it and/or modify
  14.   * it under the terms of the GNU General Public License as published by
  15.   * the Free Software Foundation, either version 3 of the License, or
  16.   * (at your option) any later version.
  17.   *
  18.   * This program is distributed in the hope that it will be useful,
  19.   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.   * GNU General Public License for more details.
  22.   *
  23.   * You should have received a copy of the GNU General Public License
  24.   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  25.   *
  26.   ******************************************************************************
  27.   */

  28. #include "stm32f4xx_xexti.h"

  29. static __IO uint32_t extiOpenFlag = 0;

  30. /*!
  31.    \brief Set external interrupt/event line flags.
  32.    \param line: EXTI line.
  33. */
  34. static void SetExtiLineFlag(XExti::ExtiLine line)
  35. {
  36.   extiOpenFlag |= line;
  37. }

  38. /*!
  39.    \brief Clear external interrupt/event line flags.
  40.    \param line: EXTI line.
  41. */
  42. static void ClearExtiLineFlag(XExti::ExtiLine line)
  43. {
  44.   extiOpenFlag &= ~line;
  45. }

  46. /*!
  47.    \brief  Is an external interrupt/event line flag set?
  48.    \param  line:  EXTI line.
  49.    \retval true:  External interrupt/event line flag is set.
  50.    \retval false: External interrupt/event line flag is not set.
  51. */
  52. static bool IsExtiLineFlagSet(XExti::ExtiLine line)
  53. {
  54.   return ((extiOpenFlag & line) == line);
  55. }

  56. /*!
  57.    \brief External interrupt/event controller module constructor.
  58.    \param line:    EXTI line.
  59.    \param mode:    EXTI mode.
  60.    \param trigger: EXTI trigger.
  61. */
  62. XExti::XExti(ExtiLine line, ExtiMode mode, ExtiTrigger trigger)
  63. {
  64.   this->line     = line;
  65.   this->mode     = mode;
  66.   this->trigger  = trigger;
  67.   this->openFlag = false;
  68. }

  69. /*!
  70.    \brief   External interrupt/event controller module destructor.
  71.    \details Restores the external interrupt/event controller to its default state.
  72. */
  73. XExti::~XExti()
  74. {
  75.   close();
  76. }

  77. /*!
  78.    \brief Set external interrupt/event line.
  79.    \param line: EXTI line.
  80. */
  81. void XExti::setLine(ExtiLine line)
  82. {
  83.   if(openFlag != true)
  84.   {
  85.     this->line = line;
  86.   }
  87. }

  88. /*!
  89.    \brief  Get external interrupt/event line.
  90.    \return EXTI line.
  91. */
  92. XExti::ExtiLine XExti::getLine() const
  93. {
  94.   return line;
  95. }

  96. /*!
  97.    \brief Set external interrupt/event mode.
  98.    \param mode: EXTI mode.
  99. */
  100. void XExti::setMode(ExtiMode mode)
  101. {
  102.   this->mode = mode;
  103.   
  104.   if(openFlag == true)
  105.   {
  106.     if(mode == ModeInterrupt)
  107.     {
  108.       LL_EXTI_DisableEvent_0_31(line);
  109.       LL_EXTI_EnableIT_0_31(line);
  110.     }
  111.     else if(mode == ModeEvent)
  112.     {
  113.       LL_EXTI_DisableIT_0_31(line);
  114.       LL_EXTI_EnableEvent_0_31(line);
  115.     }
  116.     else
  117.     {
  118.       LL_EXTI_EnableIT_0_31(line);
  119.       LL_EXTI_EnableEvent_0_31(line);
  120.     }
  121.   }
  122. }

  123. /*!
  124.    \brief  Get external interrupt/event mode.
  125.    \return EXTI mode.
  126. */
  127. XExti::ExtiMode XExti::getMode() const
  128. {
  129.   return mode;
  130. }

  131. /*!
  132.    \brief Set external interrupt/event trigger.
  133.    \param trigger: EXTI trigger.
  134. */
  135. void XExti::setTrigger(ExtiTrigger trigger)
  136. {
  137.   this->trigger = trigger;
  138.   
  139.   if(openFlag == true)
  140.   {
  141.     if(trigger == TriggerNone)
  142.     {
  143.       LL_EXTI_DisableRisingTrig_0_31(line);
  144.       LL_EXTI_DisableFallingTrig_0_31(line);
  145.     }
  146.     else if(trigger == TriggerRising)
  147.     {
  148.       LL_EXTI_DisableFallingTrig_0_31(line);
  149.       LL_EXTI_EnableRisingTrig_0_31(line);
  150.     }
  151.     else if(trigger == TriggerFalling)
  152.     {
  153.       LL_EXTI_DisableRisingTrig_0_31(line);
  154.       LL_EXTI_EnableFallingTrig_0_31(line);
  155.     }
  156.     else
  157.     {
  158.       LL_EXTI_EnableRisingTrig_0_31(line);
  159.       LL_EXTI_EnableFallingTrig_0_31(line);
  160.     }
  161.   }
  162. }

  163. /*!
  164.    \brief  Get external interrupt/event trigger.
  165.    \return EXTI trigger.
  166. */
  167. XExti::ExtiTrigger XExti::getTrigger() const
  168. {
  169.   return trigger;
  170. }

  171. /*!
  172.    \brief Set external interrupt/event flags.
  173. */
  174. void XExti::setFlag()
  175. {
  176.   if(openFlag == true)
  177.   {
  178.     LL_EXTI_GenerateSWI_0_31(line);
  179.   }
  180. }

  181. /*!
  182.    \brief Clear external interrupt/event flags.
  183. */
  184. void XExti::clearFlag()
  185. {
  186.   if(openFlag == true)
  187.   {
  188.     LL_EXTI_ClearFlag_0_31(line);
  189.   }
  190. }

  191. /*!
  192.    \brief  Is an external interrupt/event flag set?
  193.    \retval true:  External interrupt/event flag is set.
  194.    \retval false: External interrupt/event flag is not set.
  195. */
  196. bool XExti::isFlagSet() const
  197. {
  198.   if(openFlag == true)
  199.   {
  200.     return LL_EXTI_IsActiveFlag_0_31(line);
  201.   }
  202.   else
  203.   {
  204.     return false;
  205.   }
  206. }

  207. /*!
  208.    \brief  Open external interrupt/event line.
  209.    \retval true:  External interrupt/event line open success.
  210.    \retval false: External interrupt/event line open failure.
  211. */
  212. bool XExti::open()
  213. {
  214.   if(IsExtiLineFlagSet(line) != true)
  215.   {
  216.     if(mode == ModeInterrupt)
  217.     {
  218.       LL_EXTI_DisableEvent_0_31(line);
  219.       LL_EXTI_EnableIT_0_31(line);
  220.     }
  221.     else if(mode == ModeEvent)
  222.     {
  223.       LL_EXTI_DisableIT_0_31(line);
  224.       LL_EXTI_EnableEvent_0_31(line);
  225.     }
  226.     else
  227.     {
  228.       LL_EXTI_EnableIT_0_31(line);
  229.       LL_EXTI_EnableEvent_0_31(line);
  230.     }
  231.    
  232.     if(trigger == TriggerNone)
  233.     {
  234.       LL_EXTI_DisableRisingTrig_0_31(line);
  235.       LL_EXTI_DisableFallingTrig_0_31(line);
  236.     }
  237.     else if(trigger == TriggerRising)
  238.     {
  239.       LL_EXTI_DisableFallingTrig_0_31(line);
  240.       LL_EXTI_EnableRisingTrig_0_31(line);
  241.     }
  242.     else if(trigger == TriggerFalling)
  243.     {
  244.       LL_EXTI_DisableRisingTrig_0_31(line);
  245.       LL_EXTI_EnableFallingTrig_0_31(line);
  246.     }
  247.     else
  248.     {
  249.       LL_EXTI_EnableRisingTrig_0_31(line);
  250.       LL_EXTI_EnableFallingTrig_0_31(line);
  251.     }
  252.    
  253.     SetExtiLineFlag(line);
  254.    
  255.     openFlag = true;
  256.    
  257.     return true;
  258.   }
  259.   else
  260.   {
  261.     return false;
  262.   }
  263. }

  264. /*!
  265.    \brief   Close external interrupt/event line.
  266.    \details Restores the external interrupt/event controller to its default state.
  267. */
  268. void XExti::close()
  269. {
  270.   if(openFlag == true)
  271.   {
  272.     LL_EXTI_DisableIT_0_31(line);
  273.     LL_EXTI_DisableEvent_0_31(line);
  274.     LL_EXTI_DisableRisingTrig_0_31(line);
  275.     LL_EXTI_DisableFallingTrig_0_31(line);
  276.     LL_EXTI_ClearFlag_0_31(line);
  277.    
  278.     ClearExtiLineFlag(line);
  279.    
  280.     openFlag = false;
  281.   }
  282. }

  283. /*!
  284.    \brief  Is the external interrupt/event line open?
  285.    \retval true:  External interrupt/event line is open.
  286.    \retval false: External interrupt/event line is not open.
  287. */
  288. bool XExti::isOpen() const
  289. {
  290.   return openFlag;
  291. }
复制代码

例程
  1. /**
  2.   ******************************************************************************
  3.   * @file    main.cpp
  4.   * @author  XinLi
  5.   * @version v1.0
  6.   * @date    20-March-2018
  7.   * @brief   Main program body.
  8.   ******************************************************************************
  9.   * @attention
  10.   *
  11.   * <h2><center>Copyright © 2018 XinLi</center></h2>
  12.   *
  13.   * This program is free software: you can redistribute it and/or modify
  14.   * it under the terms of the GNU General Public License as published by
  15.   * the Free Software Foundation, either version 3 of the License, or
  16.   * (at your option) any later version.
  17.   *
  18.   * This program is distributed in the hope that it will be useful,
  19.   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.   * GNU General Public License for more details.
  22.   *
  23.   * You should have received a copy of the GNU General Public License
  24.   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  25.   *
  26.   ******************************************************************************
  27.   */

  28. /* Header includes -----------------------------------------------------------*/
  29. #include "main.h"
  30. #include "stm32f4xx_xgpio.h"
  31. #include "stm32f4xx_xexti.h"

  32. /* Macro definitions ---------------------------------------------------------*/
  33. /* Type definitions ----------------------------------------------------------*/
  34. /* Variable declarations -----------------------------------------------------*/
  35. /* Variable definitions ------------------------------------------------------*/
  36. /* Function declarations -----------------------------------------------------*/
  37. static void SystemClock_Config(void);

  38. /* Function definitions ------------------------------------------------------*/

  39. /**
  40.   * @brief  Main program.
  41.   * @param  None.
  42.   * @return None.
  43.   */
  44. int main(void)
  45. {
  46.   /* STM32F4xx HAL library initialization:
  47.        - Configure the Flash prefetch, instruction and Data caches
  48.        - Configure the Systick to generate an interrupt each 1 msec
  49.        - Set NVIC Group Priority to 4
  50.        - Global MSP (MCU Support Package) initialization
  51.      */
  52.   HAL_Init();
  53.   
  54.   /* Configure the system clock to 168 MHz */
  55.   SystemClock_Config();
  56.   
  57.   XExti exti4(XExti::Line4, XExti::ModeInterrupt);
  58.   
  59.   exti4.open();
  60.   
  61.   XGpio led0(XGpio::PortF, XGpio::Pin9,  XGpio::ModeOutput);
  62.   XGpio led1(XGpio::PortF, XGpio::Pin10, XGpio::ModeOutput);
  63.   
  64.   led0.open();
  65.   led1.open();
  66.   
  67.   for(;;)
  68.   {
  69.     if(exti4.isFlagSet() != true)
  70.     {
  71.       exti4.setFlag();
  72.       led0.setLevel(XGpio::LevelLow);
  73.       led1.setLevel(XGpio::LevelHigh);
  74.     }
  75.     else
  76.     {
  77.       exti4.clearFlag();
  78.       led0.setLevel(XGpio::LevelHigh);
  79.       led1.setLevel(XGpio::LevelLow);
  80.     }
  81.    
  82.     HAL_Delay(250);
  83.   }
  84. }

  85. /**
  86.   * @brief  System Clock Configuration
  87.   *         The system Clock is configured as follow :
  88.   *            System Clock source            = PLL (HSE)
  89.   *            SYSCLK(Hz)                     = 168000000
  90.   *            HCLK(Hz)                       = 168000000
  91.   *            AHB Prescaler                  = 1
  92.   *            APB1 Prescaler                 = 4
  93.   *            APB2 Prescaler                 = 2
  94.   *            HSE Frequency(Hz)              = 8000000
  95.   *            PLL_M                          = 8
  96.   *            PLL_N                          = 336
  97.   *            PLL_P                          = 2
  98.   *            PLL_Q                          = 7
  99.   *            VDD(V)                         = 3.3
  100.   *            Main regulator output voltage  = Scale1 mode
  101.   *            Flash Latency(WS)              = 5
  102.   * @param  None
  103.   * @retval None
  104.   */
  105. static void SystemClock_Config(void)
  106. {
  107.   RCC_ClkInitTypeDef RCC_ClkInitStruct;
  108.   RCC_OscInitTypeDef RCC_OscInitStruct;

  109.   /* Enable Power Control clock */
  110.   __HAL_RCC_PWR_CLK_ENABLE();

  111.   /* The voltage scaling allows optimizing the power consumption when the device is
  112.      clocked below the maximum system frequency, to update the voltage scaling value
  113.      regarding system frequency refer to product datasheet.  */
  114.   __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

  115.   /* Enable HSE Oscillator and activate PLL with HSE as source */
  116.   RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  117.   RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  118.   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  119.   RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  120.   RCC_OscInitStruct.PLL.PLLM = 8;
  121.   RCC_OscInitStruct.PLL.PLLN = 336;
  122.   RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  123.   RCC_OscInitStruct.PLL.PLLQ = 7;
  124.   HAL_RCC_OscConfig(&RCC_OscInitStruct);
  125.   
  126.   /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
  127.      clocks dividers */
  128.   RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
  129.   RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  130.   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  131.   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;  
  132.   RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;  
  133.   HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);

  134.   /* STM32F405x/407x/415x/417x Revision Z devices: prefetch is supported  */
  135.   if (HAL_GetREVID() == 0x1001)
  136.   {
  137.     /* Enable the Flash prefetch */
  138.     __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
  139.   }
  140. }
复制代码

归档链接

STM32F4 C++ 封装库 之 GPIO

收藏 评论3 发布时间:2018-4-4 20:20

举报

3个回答
maxtch 回答时间:2018-4-5 01:33:02
建议开一个 Github 代码库,方便用家一次性 clone 下来,并且追踪你这里的进度。
XinLiYF 回答时间:2018-4-5 10:06:08
maxtch 发表于 2018-4-5 01:33
建议开一个 Github 代码库,方便用家一次性 clone 下来,并且追踪你这里的进度。 ...

现在还没想好程序的框架,过段时间会去 GitHub 上建立仓库。
gh.huang 回答时间:2018-4-23 13:40:02
这个很不错啊。必须得赞一个。
关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版