1 /** mbed Microcontroller Library
2   ******************************************************************************
3   * @file    gpio_irq_api.h
4   * @author
5   * @version V1.0.0
6   * @brief   This file provides following mbed GPIO IRQ API
7   ******************************************************************************
8   * @attention
9   *
10   * Copyright (c) 2006-2013 ARM Limited
11   *
12   * Licensed under the Apache License, Version 2.0 (the "License");
13   * you may not use this file except in compliance with the License.
14   * You may obtain a copy of the License at
15   *
16   *     http://www.apache.org/licenses/LICENSE-2.0
17   *
18   * Unless required by applicable law or agreed to in writing, software
19   * distributed under the License is distributed on an "AS IS" BASIS,
20   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21   * See the License for the specific language governing permissions and
22   * limitations under the License.
23   ******************************************************************************
24   */
25 #ifndef MBED_GPIO_IRQ_API_H
26 #define MBED_GPIO_IRQ_API_H
27 
28 #include "device.h"
29 
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /** @addtogroup gpio_irq_api GPIO_IRQ
36  *  @ingroup    hal
37  *  @brief      gpio IRQ functions
38  *  @{
39  */
40 
41 ///@name Ameba Common
42 ///@{
43 typedef enum {
44     IRQ_NONE,
45     IRQ_RISE,
46     IRQ_FALL
47 } gpio_irq_event;
48 
49 typedef void (*gpio_irq_handler)(uint32_t id, gpio_irq_event event);
50 
51 /**
52   * @brief  Initializes the GPIO device interrupt mode, include mode/trigger/polarity registers.
53   * @param  obj: gpio irq object define in application software.
54   * @param  pin: PinName according to pinmux spec.
55   * @param  handler: Interrupt handler to be assigned to the specified pin.
56   * @param  id: handler id.
57   * @retval none
58   * @note this API only works for Port A pins
59   */
60 int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id);
61 
62 /**
63   * @brief  Deinitializes the GPIO device interrupt mode, include mode/trigger/polarity registers.
64   * @param  obj: gpio irq object define in application software.
65   * @retval none
66   */
67 void gpio_irq_deinit(gpio_irq_t *obj) ;
68 
69 /**
70   * @brief  Deinitializes the GPIO device interrupt mode, include mode/trigger/polarity registers.
71   * @param  obj: gpio irq object define in application software.
72   * @retval none
73   * @note this API only works for Port A pins
74   */
75 void gpio_irq_free(gpio_irq_t *obj);
76 
77 /**
78   * @brief  Enable/Disable gpio interrupt.
79   * @param  obj: gpio irq object define in application software.
80   * @param  event: gpio interrupt event, this parameter can be one of the following values:
81   *		@arg IRQ_RISE: rising edge interrupt event
82   *		@arg IRQ_FALL: falling edge interrupt event
83   *		@arg IRQ_LOW: low level interrupt event
84   *		@arg IRQ_HIGH: high level interrupt event
85   *		@arg IRQ_NONE: no interrupt event
86   * @param  enable: this parameter can be one of the following values:
87   *		@arg 0 disable gpio interrupt
88   *		@arg 1 enable gpio interrupt
89   * @retval none
90   */
91 void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable);
92 
93 /**
94   * @brief  Enable gpio interrupt.
95   * @param  obj: gpio irq object define in application software.
96   * @retval none
97   */
98 void gpio_irq_enable(gpio_irq_t *obj);
99 
100 /**
101   * @brief  Disable gpio interrupt.
102   * @param  obj: gpio irq object define in application software.
103   * @retval none
104   */
105 void gpio_irq_disable(gpio_irq_t *obj);
106 
107 /**
108   * @brief  Enable the specified gpio interrupt event.
109   * @param  obj: gpio irq object define in application software.
110   * @param  event: gpio interrupt event, this parameter can be one of the following values:
111   *		@arg IRQ_RISE: rising edge interrupt event
112   *		@arg IRQ_FALL: falling edge interrupt event
113   *		@arg IRQ_LOW: low level interrupt event
114   *		@arg IRQ_HIGH: high level interrupt event
115   *		@arg IRQ_NONE: no interrupt event
116   * @retval none
117   */
118 void gpio_irq_set_event(gpio_irq_t *obj, gpio_irq_event event);
119 
120 ///@}
121 
122 /*\@}*/
123 
124 #ifdef __cplusplus
125 }
126 #endif
127 
128 #endif
129