Mbed OS Reference
Loading...
Searching...
No Matches
gpio_irq_api.h
1
2/** \addtogroup hal */
3/** @{*/
4/* mbed Microcontroller Library
5 * Copyright (c) 2006-2013 ARM Limited
6 * SPDX-License-Identifier: Apache-2.0
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20#ifndef MBED_GPIO_IRQ_API_H
21#define MBED_GPIO_IRQ_API_H
22
23#include "device.h"
24#include "pinmap.h"
25
26#if DEVICE_INTERRUPTIN
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/** GPIO IRQ events
33 */
34typedef enum {
35 IRQ_NONE,
36 IRQ_RISE,
37 IRQ_FALL
39
40/** GPIO IRQ HAL structure. gpio_irq_s is declared in the target's HAL
41 */
42typedef struct gpio_irq_s gpio_irq_t;
43
44typedef void (*gpio_irq_handler)(uintptr_t context, gpio_irq_event event);
45
46/**
47 * \defgroup hal_gpioirq GPIO IRQ HAL functions
48 *
49 * # Defined behavior
50 * * ::gpio_irq_init initializes the GPIO IRQ pin
51 * * ::gpio_irq_init attaches the interrupt handler
52 * * ::gpio_irq_init enables the IRQ
53 * * ::gpio_irq_free releases the GPIO IRQ pin
54 * * ::gpio_irq_set enables/disables pin IRQ event
55 * * ::gpio_irq_enable enables GPIO IRQ
56 * * ::gpio_irq_disable disables GPIO IRQ
57 *
58 * # Undefined behavior
59 * * Calling other function before ::gpio_irq_init
60 *
61 * @{
62 */
63
64/**
65 * \defgroup hal_gpioirq_tests GPIO IRQ HAL tests
66 * The GPIO IRQ HAL tests ensure driver conformance to defined behaviour.
67 *
68 * To run the GPIO IRQ hal tests use the command:
69 *
70 * mbed test -t <toolchain> -m <target> -n tests-mbed_hal_fpga_ci_test_shield-gpio_irq
71 *
72 */
73
74/** Initialize the GPIO IRQ pin
75 *
76 * @param obj The GPIO object to initialize
77 * @param pin The GPIO pin name
78 * @param handler The handler to be attached to GPIO IRQ
79 * @param context The context to be passed back to the handler (context != 0, 0 is reserved)
80 * @return -1 if pin is NC, 0 otherwise
81 */
82int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uintptr_t context);
83
84/** Release the GPIO IRQ PIN
85 *
86 * @param obj The gpio object
87 */
89
90/** Enable/disable pin IRQ event
91 *
92 * @param obj The GPIO object
93 * @param event The GPIO IRQ event
94 * @param enable The enable flag
95 */
96void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable);
97
98/** Enable GPIO IRQ
99 *
100 * This is target dependent, as it might enable the entire port or just a pin
101 * @param obj The GPIO object
102 */
104
105/** Disable GPIO IRQ
106 *
107 * This is target dependent, as it might disable the entire port or just a pin
108 * @param obj The GPIO object
109 */
111
112/** Get the pins that support all GPIO IRQ tests
113 *
114 * Return a PinMap array of pins that support GPIO IRQ.
115 * The array is terminated with {NC, NC, 0}.
116 *
117 * Targets should override the weak implementation of this
118 * function to provide the actual pinmap for GPIO IRQ testing.
119 *
120 * @return PinMap array
121 */
123
124/**@}*/
125
126#ifdef __cplusplus
127}
128#endif
129
130#endif
131
132#endif
133
134/** @}*/
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uintptr_t context)
Initialize the GPIO IRQ pin.
void gpio_irq_enable(gpio_irq_t *obj)
Enable GPIO IRQ.
void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
Enable/disable pin IRQ event.
void gpio_irq_disable(gpio_irq_t *obj)
Disable GPIO IRQ.
void gpio_irq_free(gpio_irq_t *obj)
Release the GPIO IRQ PIN.
const PinMap * gpio_irq_pinmap(void)
Get the pins that support all GPIO IRQ tests.
gpio_irq_event
GPIO IRQ events.
struct gpio_irq_s gpio_irq_t
GPIO IRQ HAL structure.