STM32F4 C++ 封装库 之 EXTI
这几天看了下 mbed 的源码,给上层应用调用的接口封装的还是不错的。代码质量比较高,注释也很详细,文档和例程比较全。但是驱动层的程序全是 C 语言编写的,代码质量就没有那么高了,注释比较少而且不规范,比较怀疑 mbed 的稳定性。mbed 的实时内核是用的 RTX5 ,文件系统用的 FatFs ,还有一些开源的协议栈,整套系统比较繁杂。mbed 框架是为物联网设备开发的,工业控制级别的产品可以考虑用 RTE 框架。RTE 框架目前驱动层程序还不太完善,有好多需要自己去实现,可能在过一段时间会好一些吧。总之物联网产品可以用 mbed ,工业控制产品可以用 RTE 。这几天封装了 EXTI ,距离整套系统可以产生生产力还有很长的距离要走,我也不知道整个系统会成什么样子,我能坚持多久,不管了先做再说。在这里分享我的 STM32F4 C++ 封装之旅。今天分享《STM32F4 C++ 封装库 之 EXTI》,直接上代码了~
stm32f4xx_xexti.h 文件
/**
******************************************************************************
* \file stm32f4xx_xexti.h
* \author XinLi
* \version v1.0
* \date 20-March-2018
* \brief Header file for external interrupt/event controller module.
******************************************************************************
* \attention
*
* <h2><center>Copyright © 2018 XinLi</center></h2>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
******************************************************************************
*/
#ifndef STM32F4XX_XEXTI_H
#define STM32F4XX_XEXTI_H
#include "stm32f4xx_ll_exti.h"
/*! External interrupt/event controller module. */
class XExti
{
public:
/*! Enumerate of EXTI lines. */
enum ExtiLine
{
Line0 = LL_EXTI_LINE_0, /*!< EXTI line 0. */
Line1 = LL_EXTI_LINE_1, /*!< EXTI line 1. */
Line2 = LL_EXTI_LINE_2, /*!< EXTI line 2. */
Line3 = LL_EXTI_LINE_3, /*!< EXTI line 3. */
Line4 = LL_EXTI_LINE_4, /*!< EXTI line 4. */
Line5 = LL_EXTI_LINE_5, /*!< EXTI line 5. */
Line6 = LL_EXTI_LINE_6, /*!< EXTI line 6. */
Line7 = LL_EXTI_LINE_7, /*!< EXTI line 7. */
Line8 = LL_EXTI_LINE_8, /*!< EXTI line 8. */
Line9 = LL_EXTI_LINE_9, /*!< EXTI line 9. */
Line10 = LL_EXTI_LINE_10, /*!< EXTI line 10. */
Line11 = LL_EXTI_LINE_11, /*!< EXTI line 11. */
Line12 = LL_EXTI_LINE_12, /*!< EXTI line 12. */
Line13 = LL_EXTI_LINE_13, /*!< EXTI line 13. */
Line14 = LL_EXTI_LINE_14, /*!< EXTI line 14. */
Line15 = LL_EXTI_LINE_15, /*!< EXTI line 15. */
#ifdef LL_EXTI_LINE_16
Line16 = LL_EXTI_LINE_16, /*!< EXTI line 16. */
#endif
#ifdef LL_EXTI_LINE_17
Line17 = LL_EXTI_LINE_17, /*!< EXTI line 17. */
#endif
#ifdef LL_EXTI_LINE_18
Line18 = LL_EXTI_LINE_18, /*!< EXTI line 18. */
#endif
#ifdef LL_EXTI_LINE_19
Line19 = LL_EXTI_LINE_19, /*!< EXTI line 19. */
#endif
#ifdef LL_EXTI_LINE_20
Line20 = LL_EXTI_LINE_20, /*!< EXTI line 20. */
#endif
#ifdef LL_EXTI_LINE_21
Line21 = LL_EXTI_LINE_21, /*!< EXTI line 21. */
#endif
#ifdef LL_EXTI_LINE_22