VSF Documented
vsf_template_exti.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 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 __VSF_TEMPLATE_EXTI_H__
19#define __VSF_TEMPLATE_EXTI_H__
20
21/*============================ INCLUDES ======================================*/
22
24#include "hal/arch/vsf_arch.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/*============================ MACROS ========================================*/
31
39#ifndef VSF_EXTI_CFG_MULTI_CLASS
40# define VSF_EXTI_CFG_MULTI_CLASS ENABLED
41#endif
42
50#if defined(VSF_HW_EXTI_COUNT) && !defined(VSF_HW_EXTI_MASK)
51# define VSF_HW_EXTI_MASK VSF_HAL_COUNT_TO_MASK(VSF_HW_EXTI_COUNT)
52#endif
53
61#if defined(VSF_HW_EXTI_MASK) && !defined(VSF_HW_EXTI_COUNT)
62# define VSF_HW_EXTI_COUNT VSF_HAL_MASK_TO_COUNT(VSF_HW_EXTI_MASK)
63#endif
64
72#if defined(VSF_HW_EXTI_CHANNEL_COUNT) && !defined(VSF_HW_EXTI_CHANNEL_MASK)
73# define VSF_HW_EXTI_CHANNEL_MASK VSF_HAL_COUNT_TO_MASK(VSF_HW_EXTI_CHANNEL_COUNT)
74#endif
75
83#if defined(VSF_HW_EXTI_CHANNEL_MASK) && !defined(VSF_HW_EXTI_CHANNEL_COUNT)
84# define VSF_HW_EXTI_CHANNEL_COUNT VSF_HAL_MASK_TO_COUNT(VSF_HW_EXTI_CHANNEL_MASK)
85#endif
86
110#ifndef VSF_EXTI_CFG_PREFIX
111# if VSF_EXTI_CFG_MULTI_CLASS == ENABLED
112# define VSF_EXTI_CFG_PREFIX vsf
113# elif defined(VSF_HW_EXTI_CHANNEL_MASK) && (VSF_HW_EXTI_CHANNEL_MASK != 0)
114# define VSF_EXTI_CFG_PREFIX vsf_hw
115# else
116# define VSF_EXTI_CFG_PREFIX vsf
117# endif
118#endif
119
127#ifndef VSF_EXTI_CFG_REIMPLEMENT_TYPE_MODE
128# define VSF_EXTI_CFG_REIMPLEMENT_TYPE_MODE DISABLED
129#endif
130
138#ifndef VSF_EXTI_CFG_FUNCTION_RENAME
139# define VSF_EXTI_CFG_FUNCTION_RENAME ENABLED
140#endif
141
142
146#ifndef VSF_EXTI_CFG_REIMPLEMENT_TYPE_CFG
147# define VSF_EXTI_CFG_REIMPLEMENT_TYPE_CFG DISABLED
148#endif
149
153#ifndef VSF_EXTI_CFG_REIMPLEMENT_TYPE_CAPABILITY
154# define VSF_EXTI_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED
155#endif
156
157
158#ifndef VSF_EXTI_CFG_INHERIT_HAL_CAPABILITY
159# define VSF_EXTI_CFG_INHERIT_HAL_CAPABILITY ENABLED
160#endif
161
171#ifndef VSF_EXTI_CFG_REIMPLEMENT_TYPE_CTRL
172# define VSF_EXTI_CFG_REIMPLEMENT_TYPE_CTRL DISABLED
173#endif
174
175/*============================ MACROFIED FUNCTIONS ===========================*/
176
185#define VSF_EXTI_APIS(__prefix_name) \
186 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, exti, init, VSF_MCONNECT(__prefix_name, _t) *exti_ptr) \
187 __VSF_HAL_TEMPLATE_API(__prefix_name, void, exti, fini, VSF_MCONNECT(__prefix_name, _t) *exti_ptr) \
188 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_exti_status_t, exti, status, VSF_MCONNECT(__prefix_name, _t) *exti_ptr) \
189 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_exti_capability_t, exti, capability, VSF_MCONNECT(__prefix_name, _t) *exti_ptr) \
190 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, exti, trigger, VSF_MCONNECT(__prefix_name, _t) *exti_ptr, vsf_exti_channel_mask_t channel_mask) \
191 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, exti, config_channels, VSF_MCONNECT(__prefix_name, _t) *exti_ptr, vsf_exti_channel_mask_t channel_mask, vsf_exti_channel_cfg_t * cfg_ptr)\
192 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, exti, irq_enable, VSF_MCONNECT(__prefix_name, _t) *exti_ptr, vsf_exti_channel_mask_t channel_mask) \
193 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, exti, irq_disable, VSF_MCONNECT(__prefix_name, _t) *exti_ptr, vsf_exti_channel_mask_t channel_mask) \
194 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_exti_channel_mask_t, exti, irq_clear, VSF_MCONNECT(__prefix_name, _t) *exti_ptr, vsf_exti_channel_mask_t channel_mask) \
195 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, exti, ctrl, VSF_MCONNECT(__prefix_name, _t) *exti_ptr, vsf_exti_ctrl_t ctrl, void* param)
196
197/*============================ TYPES =========================================*/
198
199#ifndef vsf_exti_channel_mask_t
200# if defined(VSF_HW_EXTI_CHANNEL_COUNT) && (VSF_HW_EXTI_CHANNEL_COUNT > 32)
202# elif defined(VSF_HW_EXTI_CHANNEL_MASK) && (VSF_HW_EXTI_CHANNEL_MASK & 0xFFFFFFFF00000000)
204# else
206# endif
207# define vsf_exti_channel_mask_t vsf_exti_channel_mask_t
208#endif
209
210#if VSF_EXTI_CFG_REIMPLEMENT_TYPE_MODE == DISABLED
251typedef enum vsf_exti_mode_t {
259
267
275
283
291#define VSF_EXTI_MODE_LOW_LEVEL VSF_EXTI_MODE_LOW_LEVEL
292
302#endif
303
304enum {
306#ifdef VSF_EXTI_MODE_LOW_LEVEL
308#endif
309#ifdef VSF_EXTI_MODE_HIGH_LEVEL
311#endif
315};
316
317#if VSF_EXTI_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
319typedef struct vsf_exti_t vsf_exti_t;
320
322typedef void vsf_exti_isr_handler_t(void *target_ptr, vsf_exti_t *exti_ptr,
323 vsf_exti_channel_mask_t channel_mask);
324
331#endif
332
333#if VSF_EXTI_CFG_REIMPLEMENT_TYPE_STATUS == DISABLED
340typedef struct vsf_exti_status_t {
344#endif
345
346#if VSF_EXTI_CFG_REIMPLEMENT_TYPE_CTRL == DISABLED
375typedef enum vsf_exti_ctrl_t {
395#endif
396
397#if VSF_EXTI_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
398typedef struct vsf_exti_capability_t {
399#if VSF_EXTI_CFG_INHERIT_HAL_CAPABILITY == ENABLED
401#endif
402
409 uint8_t support_level_trigger : 1;
410
418
426
436
444
455#endif
456
457typedef struct vsf_exti_op_t {
459#undef __VSF_HAL_TEMPLATE_API
460#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
462
463 VSF_EXTI_APIS(vsf_exti)
465
466#if VSF_EXTI_CFG_MULTI_CLASS == ENABLED
477};
478#endif
479
480/*============================ GLOBAL VARIABLES ==============================*/
481/*============================ MACROFIED FUNCTIONS ===========================*/
482/*============================ PROTOTYPES ====================================*/
483
501extern vsf_err_t vsf_exti_init(vsf_exti_t *exti_ptr);
502
514extern void vsf_exti_fini(vsf_exti_t *exti_ptr);
515
530extern vsf_err_t vsf_exti_trigger(vsf_exti_t *exti_ptr, vsf_exti_channel_mask_t channel_mask);
531
544
562 vsf_exti_channel_mask_t channel_mask,
563 vsf_exti_channel_cfg_t *cfg_ptr);
564
577
597
615
642
643extern vsf_err_t vsf_exti_ctrl(vsf_exti_t *exti_ptr, vsf_exti_ctrl_t ctrl, void * param);
644
645/*============================ MACROS ========================================*/
646
648#if VSF_EXTI_CFG_FUNCTION_RENAME == ENABLED
649# define __vsf_exti_t VSF_MCONNECT(VSF_EXTI_CFG_PREFIX, _exti_t)
650# define vsf_exti_init(__EXTI) VSF_MCONNECT(VSF_EXTI_CFG_PREFIX, _exti_init) ((__vsf_exti_t *)(__EXTI))
651# define vsf_exti_fini(__EXTI) VSF_MCONNECT(VSF_EXTI_CFG_PREFIX, _exti_fini) ((__vsf_exti_t *)(__EXTI))
652# define vsf_exti_status(__EXTI) VSF_MCONNECT(VSF_EXTI_CFG_PREFIX, _exti_status) ((__vsf_exti_t *)(__EXTI))
653# define vsf_exti_capability(__EXTI) VSF_MCONNECT(VSF_EXTI_CFG_PREFIX, _exti_capability) ((__vsf_exti_t *)(__EXTI))
654# define vsf_exti_trigger(__EXTI, ...) VSF_MCONNECT(VSF_EXTI_CFG_PREFIX, _exti_trigger) ((__vsf_exti_t *)(__EXTI), ##__VA_ARGS__)
655# define vsf_exti_config_channels(__EXTI, ...) VSF_MCONNECT(VSF_EXTI_CFG_PREFIX, _exti_config_channels) ((__vsf_exti_t *)(__EXTI), ##__VA_ARGS__)
656# define vsf_exti_irq_enable(__EXTI, ...) VSF_MCONNECT(VSF_EXTI_CFG_PREFIX, _exti_irq_enable) ((__vsf_exti_t *)(__EXTI), ##__VA_ARGS__)
657# define vsf_exti_irq_disable(__EXTI, ...) VSF_MCONNECT(VSF_EXTI_CFG_PREFIX, _exti_irq_disable) ((__vsf_exti_t *)(__EXTI), ##__VA_ARGS__)
658# define vsf_exti_irq_clear(__EXTI, ...) VSF_MCONNECT(VSF_EXTI_CFG_PREFIX, _exti_irq_clear) ((__vsf_exti_t *)(__EXTI), ##__VA_ARGS__)
659# define vsf_exti_ctrl(__EXTI, ...) VSF_MCONNECT(VSF_EXTI_CFG_PREFIX, _exti_ctrl) ((__vsf_exti_t *)(__EXTI), ##__VA_ARGS__)
660#endif
662
663#ifdef __cplusplus
664}
665#endif
666
667#endif /* __VSF_TEMPLATE_EXTI_H__ */
vsf_err_t
Definition __type.h:42
vsf_arch_prio_t
Definition cortex_a_generic.h:88
vsf_exti_mode_t
Definition exti.h:67
@ VSF_EXTI_MODE_RISING_FALLING
Definition exti.h:71
unsigned uint32_t
Definition stdint.h:9
unsigned long long uint64_t
Definition stdint.h:11
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_template_exti.h:398
uint8_t irq_num
interrupt number for exti. Some EXTI supports multiple interrupt, and the actual length of irq_channe...
Definition vsf_template_exti.h:435
vsf_exti_channel_mask_t channel_mask
channel number for exti.
Definition vsf_template_exti.h:443
vsf_exti_channel_mask_t irq_channel_mask[0]
interrupt channel mask for corresponding irq. Some EXTI supports multiple interrupt,...
Definition vsf_template_exti.h:453
uint8_t support_sw_trigger
Support for software trigger provided by vsf_exti_trigger.
Definition vsf_template_exti.h:425
inherit(vsf_peripheral_capability_t) uint8_t support_level_trigger uint8_t support_edge_trigger
Support for level trigger.
Definition vsf_template_exti.h:400
Definition vsf_template_exti.h:325
void * target_ptr
Definition vsf_template_exti.h:328
vsf_exti_isr_handler_t * handler_fn
Definition vsf_template_exti.h:327
vsf_arch_prio_t prio
Definition vsf_template_exti.h:329
vsf_exti_mode_t mode
Definition vsf_template_exti.h:326
Definition vsf_template_exti.h:457
Predefined VSF EXTI status that can be reimplemented in specific hal drivers.
Definition vsf_template_exti.h:340
vsf_exti_channel_mask_t status_mask
Definition vsf_template_exti.h:342
vsf_exti_channel_mask_t enable_mask
Definition vsf_template_exti.h:341
Definition vsf_template_exti.h:475
const vsf_exti_op_t * op
Definition vsf_template_exti.h:476
Definition vsf_template_hal_driver.h:204
vsf_err_t vsf_exti_ctrl(vsf_exti_t *exti_ptr, vsf_exti_ctrl_t ctrl, void *param)
Definition exti_common.c:116
vsf_err_t vsf_exti_init(vsf_exti_t *exti_ptr)
Initialize a EXTI instance.
Definition exti_common.c:44
#define vsf_exti_channel_mask_t
Definition vsf_template_exti.h:207
vsf_exti_ctrl_t
Predefined VSF EXTI control commands that can be reimplemented in specific HAL drivers.
Definition vsf_template_exti.h:375
@ __VSF_EXTI_CTRL_DUMMY
Dummy value for compilation, required when no actual control commands are defined.
Definition vsf_template_exti.h:393
vsf_err_t vsf_exti_irq_enable(vsf_exti_t *exti_ptr, vsf_exti_channel_mask_t channel_mask)
Enable interrupt of one or more channels.
Definition exti_common.c:89
vsf_err_t vsf_exti_irq_disable(vsf_exti_t *exti_ptr, vsf_exti_channel_mask_t channel_mask)
Disable interrupt of one or more channels.
Definition exti_common.c:98
vsf_exti_status_t vsf_exti_status(vsf_exti_t *exti_ptr)
Get the status of EXTI instance.
Definition exti_common.c:62
#define VSF_EXTI_APIS(__prefix_name)
EXTI API template, used to generate EXTI type, specific prefix function declarations,...
Definition vsf_template_exti.h:185
vsf_err_t vsf_exti_trigger(vsf_exti_t *exti_ptr, vsf_exti_channel_mask_t channel_mask)
Trigger EXTI channels.
Definition exti_common.c:80
void vsf_exti_isr_handler_t(void *target_ptr, vsf_exti_t *exti_ptr, vsf_exti_channel_mask_t channel_mask)
External interrupt callback function for exti.
Definition vsf_template_exti.h:322
vsf_exti_channel_mask_t vsf_exti_irq_clear(vsf_exti_t *exti_ptr, vsf_exti_channel_mask_t channel_mask)
Clear interrupt flags of EXTI instance and return previous state.
Definition exti_common.c:107
void vsf_exti_fini(vsf_exti_t *exti_ptr)
Finalize a EXTI instance.
Definition exti_common.c:53
vsf_err_t vsf_exti_config_channels(vsf_exti_t *exti_ptr, vsf_exti_channel_mask_t channel_mask, vsf_exti_channel_cfg_t *cfg_ptr)
Configure one or more channels of the exti instance.
Definition exti_common.c:35
#define VSF_EXTI_MODE_LOW_LEVEL
Definition vsf_template_exti.h:291
#define VSF_EXTI_MODE_HIGH_LEVEL
Definition vsf_template_exti.h:300
@ VSF_EXTI_MODE_MASK
Definition vsf_template_exti.h:305
uint32_t vsf_exti_channel_mask_t
Definition vsf_template_exti.h:205
vsf_exti_mode_t
Predefined VSF EXTI modes that can be reimplemented in specific hal drivers.
Definition vsf_template_exti.h:251
@ VSF_EXTI_MODE_RISING
Detect interrupts on rising edge of signal.
Definition vsf_template_exti.h:266
@ VSF_EXTI_MODE_FALLING
Detect interrupts on falling edge of signal.
Definition vsf_template_exti.h:274
@ VSF_EXTI_MODE_EDGE_RISING_FALLING
Detect interrupts on both rising and falling edges.
Definition vsf_template_exti.h:282
@ VSF_EXTI_MODE_NONE
No external interrupt detection enabled.
Definition vsf_template_exti.h:258
vsf_exti_capability_t vsf_exti_capability(vsf_exti_t *exti_ptr)
Get the capability of exti instance.
Definition exti_common.c:71
Generated from commit: vsfteam/vsf@b2e9e8a