[374] | 1 |
|
---|
| 2 | /** \addtogroup hal */
|
---|
| 3 | /** @{*/
|
---|
| 4 | /* mbed Microcontroller Library
|
---|
| 5 | * Copyright (c) 2006-2013 ARM Limited
|
---|
| 6 | *
|
---|
| 7 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 8 | * you may not use this file except in compliance with the License.
|
---|
| 9 | * You may obtain a copy of the License at
|
---|
| 10 | *
|
---|
| 11 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 12 | *
|
---|
| 13 | * Unless required by applicable law or agreed to in writing, software
|
---|
| 14 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 16 | * See the License for the specific language governing permissions and
|
---|
| 17 | * limitations under the License.
|
---|
| 18 | */
|
---|
| 19 | #ifndef MBED_GPIO_IRQ_API_H
|
---|
| 20 | #define MBED_GPIO_IRQ_API_H
|
---|
| 21 |
|
---|
| 22 | #include "device.h"
|
---|
| 23 |
|
---|
| 24 | #if DEVICE_INTERRUPTIN
|
---|
| 25 |
|
---|
| 26 | #ifdef __cplusplus
|
---|
| 27 | extern "C" {
|
---|
| 28 | #endif
|
---|
| 29 |
|
---|
| 30 | /** GPIO IRQ events
|
---|
| 31 | */
|
---|
| 32 | typedef enum {
|
---|
| 33 | IRQ_NONE,
|
---|
| 34 | IRQ_RISE,
|
---|
| 35 | IRQ_FALL
|
---|
| 36 | } gpio_irq_event;
|
---|
| 37 |
|
---|
| 38 | /** GPIO IRQ HAL structure. gpio_irq_s is declared in the target's HAL
|
---|
| 39 | */
|
---|
| 40 | typedef struct gpio_irq_s gpio_irq_t;
|
---|
| 41 |
|
---|
| 42 | typedef void (*gpio_irq_handler)(uint32_t id, gpio_irq_event event);
|
---|
| 43 |
|
---|
| 44 | /**
|
---|
| 45 | * \defgroup hal_gpioirq GPIO IRQ HAL functions
|
---|
| 46 | * @{
|
---|
| 47 | */
|
---|
| 48 |
|
---|
| 49 | /** Initialize the GPIO IRQ pin
|
---|
| 50 | *
|
---|
| 51 | * @param obj The GPIO object to initialize
|
---|
| 52 | * @param pin The GPIO pin name
|
---|
| 53 | * @param handler The handler to be attached to GPIO IRQ
|
---|
| 54 | * @param id The object ID (id != 0, 0 is reserved)
|
---|
| 55 | * @return -1 if pin is NC, 0 otherwise
|
---|
| 56 | */
|
---|
| 57 | int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id);
|
---|
| 58 |
|
---|
| 59 | /** Release the GPIO IRQ PIN
|
---|
| 60 | *
|
---|
| 61 | * @param obj The gpio object
|
---|
| 62 | */
|
---|
| 63 | void gpio_irq_free(gpio_irq_t *obj);
|
---|
| 64 |
|
---|
| 65 | /** Enable/disable pin IRQ event
|
---|
| 66 | *
|
---|
| 67 | * @param obj The GPIO object
|
---|
| 68 | * @param event The GPIO IRQ event
|
---|
| 69 | * @param enable The enable flag
|
---|
| 70 | */
|
---|
| 71 | void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable);
|
---|
| 72 |
|
---|
| 73 | /** Enable GPIO IRQ
|
---|
| 74 | *
|
---|
| 75 | * This is target dependent, as it might enable the entire port or just a pin
|
---|
| 76 | * @param obj The GPIO object
|
---|
| 77 | */
|
---|
| 78 | void gpio_irq_enable(gpio_irq_t *obj);
|
---|
| 79 |
|
---|
| 80 | /** Disable GPIO IRQ
|
---|
| 81 | *
|
---|
| 82 | * This is target dependent, as it might disable the entire port or just a pin
|
---|
| 83 | * @param obj The GPIO object
|
---|
| 84 | */
|
---|
| 85 | void gpio_irq_disable(gpio_irq_t *obj);
|
---|
| 86 |
|
---|
| 87 | /**@}*/
|
---|
| 88 |
|
---|
| 89 | #ifdef __cplusplus
|
---|
| 90 | }
|
---|
| 91 | #endif
|
---|
| 92 |
|
---|
| 93 | #endif
|
---|
| 94 |
|
---|
| 95 | #endif
|
---|
| 96 |
|
---|
| 97 | /** @}*/
|
---|