TUKS MCU Introductory course / TUKS-COURSE-TIMER
Committer:
elmot
Date:
Fri Feb 24 21:13:56 2017 +0000
Revision:
1:d0dfbce63a89
Ready-to-copy

Who changed what in which revision?

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