Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers gpio_irq_api.h Source File

gpio_irq_api.h

00001 
00002 /** \addtogroup hal */
00003 /** @{*/
00004 /* mbed Microcontroller Library
00005  * Copyright (c) 2006-2013 ARM Limited
00006  * SPDX-License-Identifier: Apache-2.0
00007  *
00008  * Licensed under the Apache License, Version 2.0 (the "License");
00009  * you may not use this file except in compliance with the License.
00010  * You may obtain a copy of the License at
00011  *
00012  *     http://www.apache.org/licenses/LICENSE-2.0
00013  *
00014  * Unless required by applicable law or agreed to in writing, software
00015  * distributed under the License is distributed on an "AS IS" BASIS,
00016  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00017  * See the License for the specific language governing permissions and
00018  * limitations under the License.
00019  */
00020 #ifndef MBED_GPIO_IRQ_API_H
00021 #define MBED_GPIO_IRQ_API_H
00022 
00023 #include "device.h"
00024 #include "pinmap.h"
00025 
00026 #if DEVICE_INTERRUPTIN
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 /** GPIO IRQ events
00033  */
00034 typedef enum {
00035     IRQ_NONE,
00036     IRQ_RISE,
00037     IRQ_FALL
00038 } gpio_irq_event;
00039 
00040 /** GPIO IRQ HAL structure. gpio_irq_s is declared in the target's HAL
00041  */
00042 typedef struct gpio_irq_s gpio_irq_t;
00043 
00044 typedef void (*gpio_irq_handler)(uint32_t id, gpio_irq_event event);
00045 
00046 /**
00047  * \defgroup hal_gpioirq GPIO IRQ HAL functions
00048  *
00049  * # Defined behavior
00050  * * ::gpio_irq_init initializes the GPIO IRQ pin
00051  * * ::gpio_irq_init attaches the interrupt handler
00052  * * ::gpio_irq_free releases the GPIO IRQ pin
00053  * * ::gpio_irq_set enables/disables pin IRQ event
00054  * * ::gpio_irq_enable enables GPIO IRQ
00055  * * ::gpio_irq_disable disables GPIO IRQ
00056  *
00057  * # Undefined behavior
00058  * * Calling other function before ::gpio_irq_init
00059  *
00060  * @{
00061  */
00062 
00063 /**
00064  * \defgroup hal_gpioirq_tests GPIO IRQ HAL tests
00065  * The GPIO IRQ HAL tests ensure driver conformance to defined behaviour.
00066  *
00067  * To run the GPIO IRQ hal tests use the command:
00068  *
00069  *     mbed test -t <toolchain> -m <target> -n tests-mbed_hal_fpga_ci_test_shield-gpio_irq
00070  *
00071  */
00072 
00073 /** Initialize the GPIO IRQ pin
00074  *
00075  * @param obj     The GPIO object to initialize
00076  * @param pin     The GPIO pin name
00077  * @param handler The handler to be attached to GPIO IRQ
00078  * @param id      The object ID (id != 0, 0 is reserved)
00079  * @return -1 if pin is NC, 0 otherwise
00080  */
00081 int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id);
00082 
00083 /** Release the GPIO IRQ PIN
00084  *
00085  * @param obj The gpio object
00086  */
00087 void gpio_irq_free(gpio_irq_t *obj);
00088 
00089 /** Enable/disable pin IRQ event
00090  *
00091  * @param obj    The GPIO object
00092  * @param event  The GPIO IRQ event
00093  * @param enable The enable flag
00094  */
00095 void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable);
00096 
00097 /** Enable GPIO IRQ
00098  *
00099  * This is target dependent, as it might enable the entire port or just a pin
00100  * @param obj The GPIO object
00101  */
00102 void gpio_irq_enable(gpio_irq_t *obj);
00103 
00104 /** Disable GPIO IRQ
00105  *
00106  * This is target dependent, as it might disable the entire port or just a pin
00107  * @param obj The GPIO object
00108  */
00109 void gpio_irq_disable(gpio_irq_t *obj);
00110 
00111 /** Get the pins that support all GPIO IRQ tests
00112  *
00113  * Return a PinMap array of pins that support GPIO IRQ.
00114  * The array is terminated with {NC, NC, 0}.
00115  *
00116  * Targets should override the weak implementation of this
00117  * function to provide the actual pinmap for GPIO IRQ testing.
00118  *
00119  * @return PinMap array
00120  */
00121 const PinMap *gpio_irq_pinmap(void);
00122 
00123 /**@}*/
00124 
00125 #ifdef __cplusplus
00126 }
00127 #endif
00128 
00129 #endif
00130 
00131 #endif
00132 
00133 /** @}*/