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