日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【STM32】中断相关函数和类型

發布時間:2024/4/24 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【STM32】中断相关函数和类型 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

00. 目錄

文章目錄

    • 00. 目錄
    • 01. 概述
    • 02. 相關類型
    • 03. 相關函數
    • 04. 結構體封裝
    • 05. 附錄
    • 06. 聲明

01. 概述

中斷相關代碼主要分布在固件庫的 stm32f4xx_exti.hstm32f4xx_exti.c 文件中。

02. 相關類型

EXTI模式枚舉

/** * @brief EXTI mode enumeration */typedef enum {EXTI_Mode_Interrupt = 0x00,EXTI_Mode_Event = 0x04 }EXTIMode_TypeDef;#define IS_EXTI_MODE(MODE) (((MODE) == EXTI_Mode_Interrupt) || ((MODE) == EXTI_Mode_Event))

EXTI觸發枚舉

/** * @brief EXTI Trigger enumeration */typedef enum {EXTI_Trigger_Rising = 0x08, //上升沿EXTI_Trigger_Falling = 0x0C, //下降沿EXTI_Trigger_Rising_Falling = 0x10 //邊沿觸發 }EXTITrigger_TypeDef;#define IS_EXTI_TRIGGER(TRIGGER) (((TRIGGER) == EXTI_Trigger_Rising) || \((TRIGGER) == EXTI_Trigger_Falling) || \((TRIGGER) == EXTI_Trigger_Rising_Falling))

EXTI初始化結構體

/** * @brief EXTI Init Structure definition */typedef struct {uint32_t EXTI_Line; /*!< Specifies the EXTI lines to be enabled or disabled.This parameter can be any combination value of @ref EXTI_Lines */EXTIMode_TypeDef EXTI_Mode; /*!< Specifies the mode for the EXTI lines.This parameter can be a value of @ref EXTIMode_TypeDef */EXTITrigger_TypeDef EXTI_Trigger; /*!< Specifies the trigger signal active edge for the EXTI lines.This parameter can be a value of @ref EXTITrigger_TypeDef */FunctionalState EXTI_LineCmd; /*!< Specifies the new state of the selected EXTI lines.This parameter can be set either to ENABLE or DISABLE */ }EXTI_InitTypeDef;

外部中斷線

/** @defgroup EXTI_Lines * @{*/#define EXTI_Line0 ((uint32_t)0x00001) /*!< External interrupt line 0 */ #define EXTI_Line1 ((uint32_t)0x00002) /*!< External interrupt line 1 */ #define EXTI_Line2 ((uint32_t)0x00004) /*!< External interrupt line 2 */ #define EXTI_Line3 ((uint32_t)0x00008) /*!< External interrupt line 3 */ #define EXTI_Line4 ((uint32_t)0x00010) /*!< External interrupt line 4 */ #define EXTI_Line5 ((uint32_t)0x00020) /*!< External interrupt line 5 */ #define EXTI_Line6 ((uint32_t)0x00040) /*!< External interrupt line 6 */ #define EXTI_Line7 ((uint32_t)0x00080) /*!< External interrupt line 7 */ #define EXTI_Line8 ((uint32_t)0x00100) /*!< External interrupt line 8 */ #define EXTI_Line9 ((uint32_t)0x00200) /*!< External interrupt line 9 */ #define EXTI_Line10 ((uint32_t)0x00400) /*!< External interrupt line 10 */ #define EXTI_Line11 ((uint32_t)0x00800) /*!< External interrupt line 11 */ #define EXTI_Line12 ((uint32_t)0x01000) /*!< External interrupt line 12 */ #define EXTI_Line13 ((uint32_t)0x02000) /*!< External interrupt line 13 */ #define EXTI_Line14 ((uint32_t)0x04000) /*!< External interrupt line 14 */ #define EXTI_Line15 ((uint32_t)0x08000) /*!< External interrupt line 15 */ #define EXTI_Line16 ((uint32_t)0x10000) /*!< External interrupt line 16 Connected to the PVD Output */ #define EXTI_Line17 ((uint32_t)0x20000) /*!< External interrupt line 17 Connected to the RTC Alarm event */ #define EXTI_Line18 ((uint32_t)0x40000) /*!< External interrupt line 18 Connected to the USB OTG FS Wakeup from suspend event */ #define EXTI_Line19 ((uint32_t)0x80000) /*!< External interrupt line 19 Connected to the Ethernet Wakeup event */ #define EXTI_Line20 ((uint32_t)0x00100000) /*!< External interrupt line 20 Connected to the USB OTG HS (configured in FS) Wakeup event */ #define EXTI_Line21 ((uint32_t)0x00200000) /*!< External interrupt line 21 Connected to the RTC Tamper and Time Stamp events */ #define EXTI_Line22 ((uint32_t)0x00400000) /*!< External interrupt line 22 Connected to the RTC Wakeup event */ #define EXTI_Line23 ((uint32_t)0x00800000) /*!< External interrupt line 23 Connected to the LPTIM Wakeup event */#define IS_EXTI_LINE(LINE) ((((LINE) & (uint32_t)0xFF800000) == 0x00) && ((LINE) != (uint16_t)0x00))#define IS_GET_EXTI_LINE(LINE) (((LINE) == EXTI_Line0) || ((LINE) == EXTI_Line1) || \((LINE) == EXTI_Line2) || ((LINE) == EXTI_Line3) || \((LINE) == EXTI_Line4) || ((LINE) == EXTI_Line5) || \((LINE) == EXTI_Line6) || ((LINE) == EXTI_Line7) || \((LINE) == EXTI_Line8) || ((LINE) == EXTI_Line9) || \((LINE) == EXTI_Line10) || ((LINE) == EXTI_Line11) || \((LINE) == EXTI_Line12) || ((LINE) == EXTI_Line13) || \((LINE) == EXTI_Line14) || ((LINE) == EXTI_Line15) || \((LINE) == EXTI_Line16) || ((LINE) == EXTI_Line17) || \((LINE) == EXTI_Line18) || ((LINE) == EXTI_Line19) || \((LINE) == EXTI_Line20) || ((LINE) == EXTI_Line21) ||\((LINE) == EXTI_Line22) || ((LINE) == EXTI_Line23))

03. 相關函數

/* Exported macro ------------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*//* Function used to set the EXTI configuration to the default reset state *****/ void EXTI_DeInit(void);/* Initialization and Configuration functions *********************************/ void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct); void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct); void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line);/* Interrupts and flags management functions **********************************/ FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line); void EXTI_ClearFlag(uint32_t EXTI_Line); ITStatus EXTI_GetITStatus(uint32_t EXTI_Line); void EXTI_ClearITPendingBit(uint32_t EXTI_Line);

04. 結構體封裝

外部中斷控制器結構體封裝

/** * @brief External Interrupt/Event Controller*/typedef struct {__IO uint32_t IMR; /*!< EXTI Interrupt mask register, Address offset: 0x00 */__IO uint32_t EMR; /*!< EXTI Event mask register, Address offset: 0x04 */__IO uint32_t RTSR; /*!< EXTI Rising trigger selection register, Address offset: 0x08 */__IO uint32_t FTSR; /*!< EXTI Falling trigger selection register, Address offset: 0x0C */__IO uint32_t SWIER; /*!< EXTI Software interrupt event register, Address offset: 0x10 */__IO uint32_t PR; /*!< EXTI Pending register, Address offset: 0x14 */ } EXTI_TypeDef;

05. 附錄

5.1 【STM32】STM32系列教程匯總

網址:【STM32】STM32系列教程匯總

06. 聲明

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的【STM32】中断相关函数和类型的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。