inport from local

Dependents:   Hobbyking_Cheetah_0511

Committer:
NYX
Date:
Mon Mar 16 06:35:48 2020 +0000
Revision:
0:85b3fd62ea1a
reinport to mbed;

Who changed what in which revision?

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