CDY version that shares functionality with Counter

Dependencies:   SDFileSystem_HelloWorld mbed FATFileSystem

Committer:
Charles David Young
Date:
Mon Nov 05 09:52:17 2018 -0700
Revision:
3:c547dba5d39b
Parent:
0:aa13e1c335cd
debug

Who changed what in which revision?

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