Backup 1

Committer:
borlanic
Date:
Tue Apr 24 11:45:18 2018 +0000
Revision:
0:02dd72d1d465
BaBoRo_test2 - backup 1

Who changed what in which revision?

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