Marco Zecchini
/
Example_RTOS
Rtos API example
Embed:
(wiki syntax)
Show/hide line numbers
gpio_api.h
00001 00002 /** \addtogroup hal */ 00003 /** @{*/ 00004 /* mbed Microcontroller Library 00005 * Copyright (c) 2006-2013 ARM Limited 00006 * 00007 * Licensed under the Apache License, Version 2.0 (the "License"); 00008 * you may not use this file except in compliance with the License. 00009 * You may obtain a copy of the License at 00010 * 00011 * http://www.apache.org/licenses/LICENSE-2.0 00012 * 00013 * Unless required by applicable law or agreed to in writing, software 00014 * distributed under the License is distributed on an "AS IS" BASIS, 00015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00016 * See the License for the specific language governing permissions and 00017 * limitations under the License. 00018 */ 00019 #ifndef MBED_GPIO_API_H 00020 #define MBED_GPIO_API_H 00021 00022 #include <stdint.h> 00023 #include "device.h" 00024 00025 #ifdef __cplusplus 00026 extern "C" { 00027 #endif 00028 00029 /** 00030 * \defgroup hal_gpio GPIO HAL functions 00031 * @{ 00032 */ 00033 00034 /** Set the given pin as GPIO 00035 * 00036 * @param pin The pin to be set as GPIO 00037 * @return The GPIO port mask for this pin 00038 **/ 00039 uint32_t gpio_set(PinName pin); 00040 /* Checks if gpio object is connected (pin was not initialized with NC) 00041 * @param pin The pin to be set as GPIO 00042 * @return 0 if port is initialized with NC 00043 **/ 00044 int gpio_is_connected(const gpio_t *obj); 00045 00046 /** Initialize the GPIO pin 00047 * 00048 * @param obj The GPIO object to initialize 00049 * @param pin The GPIO pin to initialize 00050 */ 00051 void gpio_init(gpio_t *obj, PinName pin); 00052 00053 /** Set the input pin mode 00054 * 00055 * @param obj The GPIO object 00056 * @param mode The pin mode to be set 00057 */ 00058 void gpio_mode(gpio_t *obj, PinMode mode); 00059 00060 /** Set the pin direction 00061 * 00062 * @param obj The GPIO object 00063 * @param direction The pin direction to be set 00064 */ 00065 void gpio_dir(gpio_t *obj, PinDirection direction); 00066 00067 /** Set the output value 00068 * 00069 * @param obj The GPIO object 00070 * @param value The value to be set 00071 */ 00072 void gpio_write(gpio_t *obj, int value); 00073 00074 /** Read the input value 00075 * 00076 * @param obj The GPIO object 00077 * @return An integer value 1 or 0 00078 */ 00079 int gpio_read(gpio_t *obj); 00080 00081 // the following functions are generic and implemented in the common gpio.c file 00082 // TODO: fix, will be moved to the common gpio header file 00083 00084 /** Init the input pin and set mode to PullDefault 00085 * 00086 * @param gpio The GPIO object 00087 * @param pin The pin name 00088 */ 00089 void gpio_init_in(gpio_t* gpio, PinName pin); 00090 00091 /** Init the input pin and set the mode 00092 * 00093 * @param gpio The GPIO object 00094 * @param pin The pin name 00095 * @param mode The pin mode to be set 00096 */ 00097 void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode); 00098 00099 /** Init the output pin as an output, with predefined output value 0 00100 * 00101 * @param gpio The GPIO object 00102 * @param pin The pin name 00103 * @return An integer value 1 or 0 00104 */ 00105 void gpio_init_out(gpio_t* gpio, PinName pin); 00106 00107 /** Init the pin as an output and set the output value 00108 * 00109 * @param gpio The GPIO object 00110 * @param pin The pin name 00111 * @param value The value to be set 00112 */ 00113 void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value); 00114 00115 /** Init the pin to be in/out 00116 * 00117 * @param gpio The GPIO object 00118 * @param pin The pin name 00119 * @param direction The pin direction to be set 00120 * @param mode The pin mode to be set 00121 * @param value The value to be set for an output pin 00122 */ 00123 void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value); 00124 00125 /**@}*/ 00126 00127 #ifdef __cplusplus 00128 } 00129 #endif 00130 00131 #endif 00132 00133 /** @}*/
Generated on Sun Jul 17 2022 08:25:23 by 1.7.2