VSF Documented
sthal_exti.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2024 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __ST_HAL_EXTI_H__
19#define __ST_HAL_EXTI_H__
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/*============================ INCLUDES ======================================*/
26
27#include "sthal_def.h"
28
29/*============================ MACROS ========================================*/
30
31#define EXTI_LINE_0 (EXTI_GPIO | 0x00u)
32#define EXTI_LINE_1 (EXTI_GPIO | 0x01u)
33#define EXTI_LINE_2 (EXTI_GPIO | 0x02u)
34#define EXTI_LINE_3 (EXTI_GPIO | 0x03u)
35#define EXTI_LINE_4 (EXTI_GPIO | 0x04u)
36#define EXTI_LINE_5 (EXTI_GPIO | 0x05u)
37#define EXTI_LINE_6 (EXTI_GPIO | 0x06u)
38#define EXTI_LINE_7 (EXTI_GPIO | 0x07u)
39#define EXTI_LINE_8 (EXTI_GPIO | 0x08u)
40#define EXTI_LINE_9 (EXTI_GPIO | 0x09u)
41#define EXTI_LINE_10 (EXTI_GPIO | 0x0Au)
42#define EXTI_LINE_11 (EXTI_GPIO | 0x0Bu)
43#define EXTI_LINE_12 (EXTI_GPIO | 0x0Cu)
44#define EXTI_LINE_13 (EXTI_GPIO | 0x0Du)
45#define EXTI_LINE_14 (EXTI_GPIO | 0x0Eu)
46#define EXTI_LINE_15 (EXTI_GPIO | 0x0Fu)
47#define EXTI_LINE_16 (EXTI_CONFIG | 0x10u)
48#define EXTI_LINE_17 (EXTI_CONFIG | 0x11u)
49#if defined(EXTI_IMR_IM18)
50# define EXTI_LINE_18 (EXTI_CONFIG | 0x12u)
51#else
52# define EXTI_LINE_18 (EXTI_RESERVED | 0x12u)
53#endif
54#if defined(EXTI_IMR_IM19)
55# define EXTI_LINE_19 (EXTI_CONFIG | 0x13u)
56#else
57# define EXTI_LINE_19 (EXTI_RESERVED | 0x13u)
58#endif
59#if defined(EXTI_IMR_IM20)
60# define EXTI_LINE_20 (EXTI_CONFIG | 0x14u)
61#else
62# define EXTI_LINE_20 (EXTI_RESERVED | 0x14u)
63#endif
64#define EXTI_LINE_21 (EXTI_CONFIG | 0x15u)
65#define EXTI_LINE_22 (EXTI_CONFIG | 0x16u)
66#if defined(EXTI_IMR_IM23)
67# define EXTI_LINE_23 (EXTI_CONFIG | 0x17u)
68#endif
69
70#define EXTI_MODE_NONE 0x00000000u
71#define EXTI_MODE_INTERRUPT 0x00000001u
72#define EXTI_MODE_EVENT 0x00000002u
73
74#define EXTI_TRIGGER_NONE 0x00000000u
75#define EXTI_TRIGGER_RISING 0x00000001u
76#define EXTI_TRIGGER_FALLING 0x00000002u
77#define EXTI_TRIGGER_RISING_FALLING (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING)
78
79#define EXTI_GPIOA 0x00000000u
80#define EXTI_GPIOB 0x00000001u
81#define EXTI_GPIOC 0x00000002u
82#if defined(GPIOD)
83# define EXTI_GPIOD 0x00000003u
84#endif
85#if defined(GPIOE)
86# define EXTI_GPIOE 0x00000004u
87#endif
88#if defined(GPIOF)
89# define EXTI_GPIOF 0x00000005u
90#endif
91#if defined(GPIOG)
92# define EXTI_GPIOG 0x00000006u
93#endif
94#if defined(GPIOH)
95# define EXTI_GPIOH 0x00000007u
96#endif
97#if defined(GPIOI)
98# define EXTI_GPIOI 0x00000008u
99#endif
100#if defined(GPIOJ)
101# define EXTI_GPIOJ 0x00000009u
102#endif
103#if defined(GPIOK)
104# define EXTI_GPIOK 0x0000000Au
105#endif
106
107#define EXTI_PROPERTY_SHIFT 24u
108#define EXTI_CONFIG (0x02uL << EXTI_PROPERTY_SHIFT)
109#define EXTI_GPIO ((0x04uL << EXTI_PROPERTY_SHIFT) | EXTI_CONFIG)
110#define EXTI_RESERVED (0x08uL << EXTI_PROPERTY_SHIFT)
111#define EXTI_PROPERTY_MASK (EXTI_CONFIG | EXTI_GPIO)
112
113#define EXTI_PIN_MASK 0x0000001Fu
114
115#define EXTI_MODE_MASK (EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT)
116
117#define EXTI_TRIGGER_MASK (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING)
118
119#if defined(EXTI_IMR_IM23)
120# define EXTI_LINE_NB 24UL
121#else
122# define EXTI_LINE_NB 23UL
123#endif
124
125#define IS_EXTI_LINE(__EXTI_LINE__) \
126 ((((__EXTI_LINE__) & ~(EXTI_PROPERTY_MASK | EXTI_PIN_MASK)) == 0x00u) && \
127 ((((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_CONFIG) || \
128 (((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_GPIO)) && \
129 (((__EXTI_LINE__) & EXTI_PIN_MASK) < EXTI_LINE_NB))
130
131#define IS_EXTI_MODE(__EXTI_LINE__) \
132 ((((__EXTI_LINE__) & EXTI_MODE_MASK) != 0x00u) && \
133 (((__EXTI_LINE__) & ~EXTI_MODE_MASK) == 0x00u))
134
135#define IS_EXTI_TRIGGER(__EXTI_LINE__) \
136 (((__EXTI_LINE__) & ~EXTI_TRIGGER_MASK) == 0x00u)
137
138#define IS_EXTI_PENDING_EDGE(__EXTI_LINE__) \
139 ((__EXTI_LINE__) == EXTI_TRIGGER_RISING_FALLING)
140
141#define IS_EXTI_CONFIG_LINE(__EXTI_LINE__) \
142 (((__EXTI_LINE__) & EXTI_CONFIG) != 0x00u)
143
144#if !defined(GPIOD)
145# define IS_EXTI_GPIO_PORT(__PORT__) \
146 (((__PORT__) == EXTI_GPIOA) || ((__PORT__) == EXTI_GPIOB) || \
147 ((__PORT__) == EXTI_GPIOC) || ((__PORT__) == EXTI_GPIOH))
148#elif !defined(GPIOE)
149# define IS_EXTI_GPIO_PORT(__PORT__) \
150 (((__PORT__) == EXTI_GPIOA) || ((__PORT__) == EXTI_GPIOB) || \
151 ((__PORT__) == EXTI_GPIOC) || ((__PORT__) == EXTI_GPIOD) || \
152 ((__PORT__) == EXTI_GPIOH))
153#elif !defined(GPIOF)
154# define IS_EXTI_GPIO_PORT(__PORT__) \
155 (((__PORT__) == EXTI_GPIOA) || ((__PORT__) == EXTI_GPIOB) || \
156 ((__PORT__) == EXTI_GPIOC) || ((__PORT__) == EXTI_GPIOD) || \
157 ((__PORT__) == EXTI_GPIOE) || ((__PORT__) == EXTI_GPIOH))
158#elif !defined(GPIOI)
159# define IS_EXTI_GPIO_PORT(__PORT__) \
160 (((__PORT__) == EXTI_GPIOA) || ((__PORT__) == EXTI_GPIOB) || \
161 ((__PORT__) == EXTI_GPIOC) || ((__PORT__) == EXTI_GPIOD) || \
162 ((__PORT__) == EXTI_GPIOE) || ((__PORT__) == EXTI_GPIOF) || \
163 ((__PORT__) == EXTI_GPIOG) || ((__PORT__) == EXTI_GPIOH))
164#elif !defined(GPIOJ)
165# define IS_EXTI_GPIO_PORT(__PORT__) \
166 (((__PORT__) == EXTI_GPIOA) || ((__PORT__) == EXTI_GPIOB) || \
167 ((__PORT__) == EXTI_GPIOC) || ((__PORT__) == EXTI_GPIOD) || \
168 ((__PORT__) == EXTI_GPIOE) || ((__PORT__) == EXTI_GPIOF) || \
169 ((__PORT__) == EXTI_GPIOG) || ((__PORT__) == EXTI_GPIOH) || \
170 ((__PORT__) == EXTI_GPIOI))
171#else
172# define IS_EXTI_GPIO_PORT(__PORT__) \
173 (((__PORT__) == EXTI_GPIOA) || ((__PORT__) == EXTI_GPIOB) || \
174 ((__PORT__) == EXTI_GPIOC) || ((__PORT__) == EXTI_GPIOD) || \
175 ((__PORT__) == EXTI_GPIOE) || ((__PORT__) == EXTI_GPIOF) || \
176 ((__PORT__) == EXTI_GPIOG) || ((__PORT__) == EXTI_GPIOH) || \
177 ((__PORT__) == EXTI_GPIOI) || ((__PORT__) == EXTI_GPIOJ) || \
178 ((__PORT__) == EXTI_GPIOK))
179#endif
180
181#define IS_EXTI_GPIO_PIN(__PIN__) ((__PIN__) < 16U)
182
183/*============================ MACROFIED FUNCTIONS ===========================*/
184/*============================ TYPES =========================================*/
185
186typedef enum {
189
190typedef struct {
192 void (*PendingCallback)(void);
194
195typedef struct {
201
202/*============================ GLOBAL VARIABLES ==============================*/
203/*============================ PROTOTYPES ====================================*/
204
206 EXTI_ConfigTypeDef *pExtiConfig);
208 EXTI_ConfigTypeDef *pExtiConfig);
211 EXTI_CallbackIDTypeDef CallbackID,
212 void (*pPendingCbfn)(void));
214 uint32_t ExtiLine);
215
220
221#ifdef __cplusplus
222}
223#endif
224
225#endif
unsigned uint32_t
Definition stdint.h:9
HAL_StatusTypeDef
Definition sthal_def.h:65
EXTI_CallbackIDTypeDef
Definition sthal_exti.h:186
@ HAL_EXTI_COMMON_CB_ID
Definition sthal_exti.h:187
HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig)
void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti)
void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti)
uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge)
HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine)
void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge)
HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig)
HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void(*pPendingCbfn)(void))
HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti)
Definition sthal_exti.h:195
uint32_t Line
Definition sthal_exti.h:196
uint32_t Mode
Definition sthal_exti.h:197
uint32_t GPIOSel
Definition sthal_exti.h:199
uint32_t Trigger
Definition sthal_exti.h:198
Definition sthal_exti.h:190
uint32_t Line
Definition sthal_exti.h:191