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