Elijah Stanger-Jones / mbed-dev-f303
Committer:
elijahsj
Date:
Mon Nov 09 00:33:19 2020 -0500
Revision:
2:4364577b5ad8
Parent:
1:8a094db1347f
copied mbed library

Who changed what in which revision?

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