Entrega 3er corte - sistemas embebidos

Committer:
Bethory
Date:
Wed May 30 00:01:50 2018 +0000
Revision:
0:6ad07c9019fd
Codigo de tales para todos los pasculaes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Bethory 0:6ad07c9019fd 1
Bethory 0:6ad07c9019fd 2 /** \addtogroup hal */
Bethory 0:6ad07c9019fd 3 /** @{*/
Bethory 0:6ad07c9019fd 4 /* mbed Microcontroller Library
Bethory 0:6ad07c9019fd 5 * Copyright (c) 2006-2013 ARM Limited
Bethory 0:6ad07c9019fd 6 *
Bethory 0:6ad07c9019fd 7 * Licensed under the Apache License, Version 2.0 (the "License");
Bethory 0:6ad07c9019fd 8 * you may not use this file except in compliance with the License.
Bethory 0:6ad07c9019fd 9 * You may obtain a copy of the License at
Bethory 0:6ad07c9019fd 10 *
Bethory 0:6ad07c9019fd 11 * http://www.apache.org/licenses/LICENSE-2.0
Bethory 0:6ad07c9019fd 12 *
Bethory 0:6ad07c9019fd 13 * Unless required by applicable law or agreed to in writing, software
Bethory 0:6ad07c9019fd 14 * distributed under the License is distributed on an "AS IS" BASIS,
Bethory 0:6ad07c9019fd 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Bethory 0:6ad07c9019fd 16 * See the License for the specific language governing permissions and
Bethory 0:6ad07c9019fd 17 * limitations under the License.
Bethory 0:6ad07c9019fd 18 */
Bethory 0:6ad07c9019fd 19 #ifndef MBED_GPIO_API_H
Bethory 0:6ad07c9019fd 20 #define MBED_GPIO_API_H
Bethory 0:6ad07c9019fd 21
Bethory 0:6ad07c9019fd 22 #include <stdint.h>
Bethory 0:6ad07c9019fd 23 #include "device.h"
Bethory 0:6ad07c9019fd 24
Bethory 0:6ad07c9019fd 25 #ifdef __cplusplus
Bethory 0:6ad07c9019fd 26 extern "C" {
Bethory 0:6ad07c9019fd 27 #endif
Bethory 0:6ad07c9019fd 28
Bethory 0:6ad07c9019fd 29 /**
Bethory 0:6ad07c9019fd 30 * \defgroup hal_gpio GPIO HAL functions
Bethory 0:6ad07c9019fd 31 * @{
Bethory 0:6ad07c9019fd 32 */
Bethory 0:6ad07c9019fd 33
Bethory 0:6ad07c9019fd 34 /** Set the given pin as GPIO
Bethory 0:6ad07c9019fd 35 *
Bethory 0:6ad07c9019fd 36 * @param pin The pin to be set as GPIO
Bethory 0:6ad07c9019fd 37 * @return The GPIO port mask for this pin
Bethory 0:6ad07c9019fd 38 **/
Bethory 0:6ad07c9019fd 39 uint32_t gpio_set(PinName pin);
Bethory 0:6ad07c9019fd 40 /* Checks if gpio object is connected (pin was not initialized with NC)
Bethory 0:6ad07c9019fd 41 * @param pin The pin to be set as GPIO
Bethory 0:6ad07c9019fd 42 * @return 0 if port is initialized with NC
Bethory 0:6ad07c9019fd 43 **/
Bethory 0:6ad07c9019fd 44 int gpio_is_connected(const gpio_t *obj);
Bethory 0:6ad07c9019fd 45
Bethory 0:6ad07c9019fd 46 /** Initialize the GPIO pin
Bethory 0:6ad07c9019fd 47 *
Bethory 0:6ad07c9019fd 48 * @param obj The GPIO object to initialize
Bethory 0:6ad07c9019fd 49 * @param pin The GPIO pin to initialize
Bethory 0:6ad07c9019fd 50 */
Bethory 0:6ad07c9019fd 51 void gpio_init(gpio_t *obj, PinName pin);
Bethory 0:6ad07c9019fd 52
Bethory 0:6ad07c9019fd 53 /** Set the input pin mode
Bethory 0:6ad07c9019fd 54 *
Bethory 0:6ad07c9019fd 55 * @param obj The GPIO object
Bethory 0:6ad07c9019fd 56 * @param mode The pin mode to be set
Bethory 0:6ad07c9019fd 57 */
Bethory 0:6ad07c9019fd 58 void gpio_mode(gpio_t *obj, PinMode mode);
Bethory 0:6ad07c9019fd 59
Bethory 0:6ad07c9019fd 60 /** Set the pin direction
Bethory 0:6ad07c9019fd 61 *
Bethory 0:6ad07c9019fd 62 * @param obj The GPIO object
Bethory 0:6ad07c9019fd 63 * @param direction The pin direction to be set
Bethory 0:6ad07c9019fd 64 */
Bethory 0:6ad07c9019fd 65 void gpio_dir(gpio_t *obj, PinDirection direction);
Bethory 0:6ad07c9019fd 66
Bethory 0:6ad07c9019fd 67 /** Set the output value
Bethory 0:6ad07c9019fd 68 *
Bethory 0:6ad07c9019fd 69 * @param obj The GPIO object
Bethory 0:6ad07c9019fd 70 * @param value The value to be set
Bethory 0:6ad07c9019fd 71 */
Bethory 0:6ad07c9019fd 72 void gpio_write(gpio_t *obj, int value);
Bethory 0:6ad07c9019fd 73
Bethory 0:6ad07c9019fd 74 /** Read the input value
Bethory 0:6ad07c9019fd 75 *
Bethory 0:6ad07c9019fd 76 * @param obj The GPIO object
Bethory 0:6ad07c9019fd 77 * @return An integer value 1 or 0
Bethory 0:6ad07c9019fd 78 */
Bethory 0:6ad07c9019fd 79 int gpio_read(gpio_t *obj);
Bethory 0:6ad07c9019fd 80
Bethory 0:6ad07c9019fd 81 // the following functions are generic and implemented in the common gpio.c file
Bethory 0:6ad07c9019fd 82 // TODO: fix, will be moved to the common gpio header file
Bethory 0:6ad07c9019fd 83
Bethory 0:6ad07c9019fd 84 /** Init the input pin and set mode to PullDefault
Bethory 0:6ad07c9019fd 85 *
Bethory 0:6ad07c9019fd 86 * @param gpio The GPIO object
Bethory 0:6ad07c9019fd 87 * @param pin The pin name
Bethory 0:6ad07c9019fd 88 */
Bethory 0:6ad07c9019fd 89 void gpio_init_in(gpio_t* gpio, PinName pin);
Bethory 0:6ad07c9019fd 90
Bethory 0:6ad07c9019fd 91 /** Init the input pin and set the mode
Bethory 0:6ad07c9019fd 92 *
Bethory 0:6ad07c9019fd 93 * @param gpio The GPIO object
Bethory 0:6ad07c9019fd 94 * @param pin The pin name
Bethory 0:6ad07c9019fd 95 * @param mode The pin mode to be set
Bethory 0:6ad07c9019fd 96 */
Bethory 0:6ad07c9019fd 97 void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode);
Bethory 0:6ad07c9019fd 98
Bethory 0:6ad07c9019fd 99 /** Init the output pin as an output, with predefined output value 0
Bethory 0:6ad07c9019fd 100 *
Bethory 0:6ad07c9019fd 101 * @param gpio The GPIO object
Bethory 0:6ad07c9019fd 102 * @param pin The pin name
Bethory 0:6ad07c9019fd 103 * @return An integer value 1 or 0
Bethory 0:6ad07c9019fd 104 */
Bethory 0:6ad07c9019fd 105 void gpio_init_out(gpio_t* gpio, PinName pin);
Bethory 0:6ad07c9019fd 106
Bethory 0:6ad07c9019fd 107 /** Init the pin as an output and set the output value
Bethory 0:6ad07c9019fd 108 *
Bethory 0:6ad07c9019fd 109 * @param gpio The GPIO object
Bethory 0:6ad07c9019fd 110 * @param pin The pin name
Bethory 0:6ad07c9019fd 111 * @param value The value to be set
Bethory 0:6ad07c9019fd 112 */
Bethory 0:6ad07c9019fd 113 void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value);
Bethory 0:6ad07c9019fd 114
Bethory 0:6ad07c9019fd 115 /** Init the pin to be in/out
Bethory 0:6ad07c9019fd 116 *
Bethory 0:6ad07c9019fd 117 * @param gpio The GPIO object
Bethory 0:6ad07c9019fd 118 * @param pin The pin name
Bethory 0:6ad07c9019fd 119 * @param direction The pin direction to be set
Bethory 0:6ad07c9019fd 120 * @param mode The pin mode to be set
Bethory 0:6ad07c9019fd 121 * @param value The value to be set for an output pin
Bethory 0:6ad07c9019fd 122 */
Bethory 0:6ad07c9019fd 123 void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value);
Bethory 0:6ad07c9019fd 124
Bethory 0:6ad07c9019fd 125 /**@}*/
Bethory 0:6ad07c9019fd 126
Bethory 0:6ad07c9019fd 127 #ifdef __cplusplus
Bethory 0:6ad07c9019fd 128 }
Bethory 0:6ad07c9019fd 129 #endif
Bethory 0:6ad07c9019fd 130
Bethory 0:6ad07c9019fd 131 #endif
Bethory 0:6ad07c9019fd 132
Bethory 0:6ad07c9019fd 133 /** @}*/