mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers gpio_api.h Source File

gpio_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_API_H
00021 #define MBED_GPIO_API_H
00022 
00023 #include <stdint.h>
00024 #include "device.h"
00025 
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029 
00030 /**
00031  * \defgroup hal_gpio GPIO HAL functions
00032  * @{
00033  */
00034 
00035 /** Set the given pin as GPIO
00036  *
00037  * @param pin The pin to be set as GPIO
00038  * @return The GPIO port mask for this pin
00039  **/
00040 uint32_t gpio_set(PinName pin);
00041 /* Checks if gpio object is connected (pin was not initialized with NC)
00042  * @param pin The pin to be set as GPIO
00043  * @return 0 if port is initialized with NC
00044  **/
00045 int gpio_is_connected(const gpio_t *obj);
00046 
00047 /** Initialize the GPIO pin
00048  *
00049  * @param obj The GPIO object to initialize
00050  * @param pin The GPIO pin to initialize
00051  */
00052 void gpio_init(gpio_t *obj, PinName pin);
00053 
00054 /** Set the input pin mode
00055  *
00056  * @param obj  The GPIO object
00057  * @param mode The pin mode to be set
00058  */
00059 void gpio_mode(gpio_t *obj, PinMode mode);
00060 
00061 /** Set the pin direction
00062  *
00063  * @param obj       The GPIO object
00064  * @param direction The pin direction to be set
00065  */
00066 void gpio_dir(gpio_t *obj, PinDirection direction);
00067 
00068 /** Set the output value
00069  *
00070  * @param obj   The GPIO object
00071  * @param value The value to be set
00072  */
00073 void gpio_write(gpio_t *obj, int value);
00074 
00075 /** Read the input value
00076  *
00077  * @param obj The GPIO object
00078  * @return An integer value 1 or 0
00079  */
00080 int gpio_read(gpio_t *obj);
00081 
00082 // the following functions are generic and implemented in the common gpio.c file
00083 // TODO: fix, will be moved to the common gpio header file
00084 
00085 /** Init the input pin and set mode to PullDefault
00086  *
00087  * @param gpio The GPIO object
00088  * @param pin  The pin name
00089  */
00090 void gpio_init_in(gpio_t *gpio, PinName pin);
00091 
00092 /** Init the input pin and set the mode
00093  *
00094  * @param gpio  The GPIO object
00095  * @param pin   The pin name
00096  * @param mode  The pin mode to be set
00097  */
00098 void gpio_init_in_ex(gpio_t *gpio, PinName pin, PinMode mode);
00099 
00100 /** Init the output pin as an output, with predefined output value 0
00101  *
00102  * @param gpio The GPIO object
00103  * @param pin  The pin name
00104  * @return     An integer value 1 or 0
00105  */
00106 void gpio_init_out(gpio_t *gpio, PinName pin);
00107 
00108 /** Init the pin as an output and set the output value
00109  *
00110  * @param gpio  The GPIO object
00111  * @param pin   The pin name
00112  * @param value The value to be set
00113  */
00114 void gpio_init_out_ex(gpio_t *gpio, PinName pin, int value);
00115 
00116 /** Init the pin to be in/out
00117  *
00118  * @param gpio      The GPIO object
00119  * @param pin       The pin name
00120  * @param direction The pin direction to be set
00121  * @param mode      The pin mode to be set
00122  * @param value     The value to be set for an output pin
00123  */
00124 void gpio_init_inout(gpio_t *gpio, PinName pin, PinDirection direction, PinMode mode, int value);
00125 
00126 /**@}*/
00127 
00128 #ifdef __cplusplus
00129 }
00130 #endif
00131 
00132 #endif
00133 
00134 /** @}*/