当前位置:首页 > 嵌入式 > 嵌入式硬件
[导读]这几天看了下 mbed 的源码,给上层应用调用的接口封装的还是不错的。代码质量比较高,注释也很详细,文档和例程比较全。但是驱动层的程序全是 C 语言编写的,代码质量就没有那么高了,注释比较少而且不规范,比较怀疑 mbed 的稳定性。mbed 的实时内核是用的 RTX5 ,文件系统用的 FatFs ,还有一些开源的协议栈,整套系统比较繁杂。mbed 框架是为物联网设备开发的,工业控制级别的产品可以考虑用 RTE 框架。RTE 框架目前驱动层程序还不太完善,有好多需要自己去实现,可能在过一段时间会好一些吧。总

这几天看了下 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

*

* Copyright © 2018 XinLi

*

* 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 .

*

******************************************************************************

*/

#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

Line22 = LL_EXTI_LINE_22, /*!< EXTI line 22. */

#endif

#ifdef LL_EXTI_LINE_23

Line23 = LL_EXTI_LINE_23, /*!< EXTI line 23. */

#endif

#ifdef LL_EXTI_LINE_24

Line24 = LL_EXTI_LINE_24, /*!< EXTI line 24. */

#endif

#ifdef LL_EXTI_LINE_25

Line25 = LL_EXTI_LINE_25, /*!< EXTI line 25. */

#endif

#ifdef LL_EXTI_LINE_26

Line26 = LL_EXTI_LINE_26, /*!< EXTI line 26. */

#endif

#ifdef LL_EXTI_LINE_27

Line27 = LL_EXTI_LINE_27, /*!< EXTI line 27. */

#endif

#ifdef LL_EXTI_LINE_28

Line28 = LL_EXTI_LINE_28, /*!< EXTI line 28. */

#endif

#ifdef LL_EXTI_LINE_29

Line29 = LL_EXTI_LINE_29, /*!< EXTI line 29. */

#endif

#ifdef LL_EXTI_LINE_30

Line30 = LL_EXTI_LINE_30, /*!< EXTI line 30. */

#endif

#ifdef LL_EXTI_LINE_31

Line31 = LL_EXTI_LINE_31, /*!< EXTI line 31. */

#endif

};

/*! Enumerate of EXTI modes. */

enum ExtiMode

{

ModeInterrupt = LL_EXTI_MODE_IT, /*!< EXTI interrupt mode. */

ModeEvent = LL_EXTI_MODE_EVENT, /*!< EXTI event mode. */

ModeInterruptEvent = LL_EXTI_MODE_IT_EVENT, /*!< EXTI interrupt and event mode. */

};

/*! Enumerate of EXTI triggers. */

enum ExtiTrigger

{

TriggerNone = LL_EXTI_TRIGGER_NONE, /*!< EXTI none trigger. */

TriggerRising = LL_EXTI_TRIGGER_RISING, /*!< EXTI rising trigger. */

TriggerFalling = LL_EXTI_TRIGGER_FALLING, /*!< EXTI falling trigger. */

TriggerRisingFalling = LL_EXTI_TRIGGER_RISING_FALLING, /*!< EXTI rising and falling trigger. */

};

XExti(ExtiLine line, ExtiMode mode, ExtiTrigger trigger = TriggerNone);

virtual ~XExti();

void setLine(ExtiLine line);

ExtiLine getLine() const;

void setMode(ExtiMode mode);

ExtiMode getMode() const;

void setTrigger(ExtiTrigger trigger);

ExtiTrigger getTrigger() const;

void setFlag();

void clearFlag();

bool isFlagSet() const;

bool open();

void close();

bool isOpen() const;

private:

ExtiLine line;

ExtiMode mode;

ExtiTrigger trigger;

bool openFlag;

XExti(const XExti &) = delete;

XExti & operator = (const XExti &) = delete;

};

#endif // STM32F4XX_XEXTI_H

stm32f4xx_xexti.cpp 文件

/**

******************************************************************************

* \file stm32f4xx_xexti.cpp

* \author XinLi

* \version v1.0

* \date 20-March-2018

* \brief External interrupt/event controller module driver.

******************************************************************************

* \attention

*

* Copyright © 2018 XinLi

*

* 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 .

*

******************************************************************************

*/

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除。
换一批
延伸阅读

红外激光切割技术实现了纳米级精度的硅基板超薄层转移,为先进封装和晶体管微缩的三维集成带来革命性的变化。

关键字: 封装 半导体

该项目预计2025年初建成,届时将成为长电科技在国内建设的第一条智能化“黑灯工厂”生产线,同时也将成为国内大型专业汽车电子芯片成品制造标杆工厂,有助于带动整个产业链向高性能、高可靠性、高度自动化的方向发展。

关键字: 长电科技 封装 半导体

2023第三季度及前三季度财务要点: • 三季度实现收入为人民币82.6亿元,前三季度累计实现收入为人民币204.3亿元;三季度收入环比二季度增长30.8%。 • 三季度净利润为人民币4.8亿元,前三季度累计净利润为人民...

关键字: 长电科技 封装 集成电路

随着电动汽车的普及,充电桩作为电动汽车的重要基础设施,越来越受到人们的关注。然而,对于许多电动汽车用户来说,直流充电桩和交流充电桩的接口和区别仍然是一个令人困惑的问题。本文将从接口和区别两个方面,详细探讨直流充电桩和交流...

关键字: 电动汽车 接口 充电桩

武汉2023年9月19日 /美通社/ -- 目前,在国家政策和市场需求双重驱动下,国内数据库行业呈现出百花齐放的态势。充分竞争的市场环境下,达梦数据连续数年保持中国数据库管理系统市场占有率前列地位,成为当之无愧的国产数据...

关键字: DM DSC 国家电网 接口

深圳2023年9月15日 /美通社/ -- 9月14-15日,2023全球AI芯片峰会(GACS 2023)在深圳正式举行。峰会以【AI 大时代 逐鹿芯世界】为主题,共探AI芯片的产学研用,邀请了清华大学教授、中国半导体...

关键字: 接口 芯科 内存 AC

2023第二季度财务要点: 二季度实现收入为人民币63.1亿元,环比一季度增长7.7%。 二季度经营活动产生现金人民币11.9亿元。扣除资产投资净支出人民币7.5...

关键字: 封装 长电科技 集成电路产业 系统级封装

2023年8月24日,中国北京 —— 全球领先的半导体企业 Micron Technology Inc.(美光科技股份有限公司,纳斯达克股票代码:MU)今日宣布旗下美光基金会 (Micron Foundation)向赠与...

关键字: 美光 封装

作为集成电路封测行业领军企业,长电科技提出从“封测”到“芯片成品制造”的升级,带动行业重新定义封装测试的产业链价值。同时,长电科技积极与集成电路领域的专家学者、知名高校、科研院所开展产学研合作,探索集成电路产业技术创新的...

关键字: 长电科技 封装 集成电路

近日,长电科技董事、首席执行长郑力出席了第24届电子封装技术国际会议(ICEPT2023),并发表了《高性能先进封装创新推动微系统集成变革》主题演讲。郑力表示,随着产业发展趋势的演进,微系统集成成为驱动集成电路产业创新的...

关键字: 长电科技 封装 半导体
关闭
关闭