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 .?
*?
******************************************************************************?
*/?
評論
查看更多