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