this is testing

Committer:
pmallick
Date:
Thu Jan 14 18:54:16 2021 +0530
Revision:
0:3afcd581558d
this is testing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pmallick 0:3afcd581558d 1 /***************************************************************************//**
pmallick 0:3afcd581558d 2 * @file gpio.h
pmallick 0:3afcd581558d 3 * @brief Header file of GPIO Interface
pmallick 0:3afcd581558d 4 * @author DBogdan (dragos.bogdan@analog.com)
pmallick 0:3afcd581558d 5 ********************************************************************************
pmallick 0:3afcd581558d 6 * Copyright 2019(c) Analog Devices, Inc.
pmallick 0:3afcd581558d 7 *
pmallick 0:3afcd581558d 8 * All rights reserved.
pmallick 0:3afcd581558d 9 *
pmallick 0:3afcd581558d 10 * Redistribution and use in source and binary forms, with or without
pmallick 0:3afcd581558d 11 * modification, are permitted provided that the following conditions are met:
pmallick 0:3afcd581558d 12 * - Redistributions of source code must retain the above copyright
pmallick 0:3afcd581558d 13 * notice, this list of conditions and the following disclaimer.
pmallick 0:3afcd581558d 14 * - Redistributions in binary form must reproduce the above copyright
pmallick 0:3afcd581558d 15 * notice, this list of conditions and the following disclaimer in
pmallick 0:3afcd581558d 16 * the documentation and/or other materials provided with the
pmallick 0:3afcd581558d 17 * distribution.
pmallick 0:3afcd581558d 18 * - Neither the name of Analog Devices, Inc. nor the names of its
pmallick 0:3afcd581558d 19 * contributors may be used to endorse or promote products derived
pmallick 0:3afcd581558d 20 * from this software without specific prior written permission.
pmallick 0:3afcd581558d 21 * - The use of this software may or may not infringe the patent rights
pmallick 0:3afcd581558d 22 * of one or more patent holders. This license does not release you
pmallick 0:3afcd581558d 23 * from the requirement that you obtain separate licenses from these
pmallick 0:3afcd581558d 24 * patent holders to use this software.
pmallick 0:3afcd581558d 25 * - Use of the software either in source or binary form, must be run
pmallick 0:3afcd581558d 26 * on or directly connected to an Analog Devices Inc. component.
pmallick 0:3afcd581558d 27 *
pmallick 0:3afcd581558d 28 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
pmallick 0:3afcd581558d 29 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
pmallick 0:3afcd581558d 30 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
pmallick 0:3afcd581558d 31 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
pmallick 0:3afcd581558d 32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
pmallick 0:3afcd581558d 33 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
pmallick 0:3afcd581558d 34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
pmallick 0:3afcd581558d 35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
pmallick 0:3afcd581558d 36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
pmallick 0:3afcd581558d 37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
pmallick 0:3afcd581558d 38 *******************************************************************************/
pmallick 0:3afcd581558d 39
pmallick 0:3afcd581558d 40 #ifndef GPIO_H_
pmallick 0:3afcd581558d 41 #define GPIO_H_
pmallick 0:3afcd581558d 42
pmallick 0:3afcd581558d 43 /******************************************************************************/
pmallick 0:3afcd581558d 44 /***************************** Include Files **********************************/
pmallick 0:3afcd581558d 45 /******************************************************************************/
pmallick 0:3afcd581558d 46
pmallick 0:3afcd581558d 47 #include <stdint.h>
pmallick 0:3afcd581558d 48
pmallick 0:3afcd581558d 49 /******************************************************************************/
pmallick 0:3afcd581558d 50 /********************** Macros and Constants Definitions **********************/
pmallick 0:3afcd581558d 51 /******************************************************************************/
pmallick 0:3afcd581558d 52
pmallick 0:3afcd581558d 53 #define GPIO_OUT 0x01
pmallick 0:3afcd581558d 54 #define GPIO_IN 0x00
pmallick 0:3afcd581558d 55
pmallick 0:3afcd581558d 56 /******************************************************************************/
pmallick 0:3afcd581558d 57 /*************************** Types Declarations *******************************/
pmallick 0:3afcd581558d 58 /******************************************************************************/
pmallick 0:3afcd581558d 59
pmallick 0:3afcd581558d 60 /**
pmallick 0:3afcd581558d 61 * @struct gpio_platform_ops
pmallick 0:3afcd581558d 62 * @brief Structure holding gpio function pointers that point to the platform
pmallick 0:3afcd581558d 63 * specific function
pmallick 0:3afcd581558d 64 */
pmallick 0:3afcd581558d 65 struct gpio_platform_ops ;
pmallick 0:3afcd581558d 66
pmallick 0:3afcd581558d 67 /**
pmallick 0:3afcd581558d 68 * @struct gpio_init_param
pmallick 0:3afcd581558d 69 * @brief Structure holding the parameters for GPIO initialization.
pmallick 0:3afcd581558d 70 */
pmallick 0:3afcd581558d 71 typedef struct gpio_init_param {
pmallick 0:3afcd581558d 72 /** GPIO number */
pmallick 0:3afcd581558d 73 uint32_t number;
pmallick 0:3afcd581558d 74 /** GPIO platform specific functions */
pmallick 0:3afcd581558d 75 const struct gpio_platform_ops *platform_ops;
pmallick 0:3afcd581558d 76 /** GPIO extra parameters (device specific) */
pmallick 0:3afcd581558d 77 void *extra;
pmallick 0:3afcd581558d 78 } gpio_init_param;
pmallick 0:3afcd581558d 79
pmallick 0:3afcd581558d 80 /**
pmallick 0:3afcd581558d 81 * @struct gpio_desc
pmallick 0:3afcd581558d 82 * @brief Structure holding the GPIO descriptor.
pmallick 0:3afcd581558d 83 */
pmallick 0:3afcd581558d 84 typedef struct gpio_desc {
pmallick 0:3afcd581558d 85 /** GPIO number */
pmallick 0:3afcd581558d 86 uint32_t number;
pmallick 0:3afcd581558d 87 /** GPIO platform specific functions */
pmallick 0:3afcd581558d 88 const struct gpio_platform_ops *platform_ops;
pmallick 0:3afcd581558d 89 /** GPIO extra parameters (device specific) */
pmallick 0:3afcd581558d 90 void *extra;
pmallick 0:3afcd581558d 91 } gpio_desc;
pmallick 0:3afcd581558d 92
pmallick 0:3afcd581558d 93 /**
pmallick 0:3afcd581558d 94 * @enum gpio_values
pmallick 0:3afcd581558d 95 * @brief Enum that holds the possible output states of a GPIO.
pmallick 0:3afcd581558d 96 */
pmallick 0:3afcd581558d 97 enum gpio_values {
pmallick 0:3afcd581558d 98 /** GPIO logic low */
pmallick 0:3afcd581558d 99 GPIO_LOW,
pmallick 0:3afcd581558d 100 /** GPIO logic high */
pmallick 0:3afcd581558d 101 GPIO_HIGH,
pmallick 0:3afcd581558d 102 /** GPIO high impedance */
pmallick 0:3afcd581558d 103 GPIO_HIGH_Z
pmallick 0:3afcd581558d 104 };
pmallick 0:3afcd581558d 105
pmallick 0:3afcd581558d 106 /**
pmallick 0:3afcd581558d 107 * @struct gpio_platform_ops
pmallick 0:3afcd581558d 108 * @brief Structure holding gpio function pointers that point to the platform
pmallick 0:3afcd581558d 109 * specific function
pmallick 0:3afcd581558d 110 */
pmallick 0:3afcd581558d 111 struct gpio_platform_ops {
pmallick 0:3afcd581558d 112 /** gpio initialization function pointer */
pmallick 0:3afcd581558d 113 int32_t (*gpio_ops_get)(struct gpio_desc **, const struct gpio_init_param *);
pmallick 0:3afcd581558d 114 /** gpio optional descriptor function pointer */
pmallick 0:3afcd581558d 115 int32_t (*gpio_ops_get_optional)(struct gpio_desc **,
pmallick 0:3afcd581558d 116 const struct gpio_init_param *);
pmallick 0:3afcd581558d 117 /** gpio remove function pointer */
pmallick 0:3afcd581558d 118 int32_t (*gpio_ops_remove)(struct gpio_desc *);
pmallick 0:3afcd581558d 119 /** gpio direction input function pointer */
pmallick 0:3afcd581558d 120 int32_t (*gpio_ops_direction_input)(struct gpio_desc *);
pmallick 0:3afcd581558d 121 /** gpio direction output function pointer */
pmallick 0:3afcd581558d 122 int32_t (*gpio_ops_direction_output)(struct gpio_desc *, uint8_t);
pmallick 0:3afcd581558d 123 /** gpio get direction function pointer */
pmallick 0:3afcd581558d 124 int32_t (*gpio_ops_get_direction)(struct gpio_desc *, uint8_t *);
pmallick 0:3afcd581558d 125 /** gpio set value function pointer */
pmallick 0:3afcd581558d 126 int32_t (*gpio_ops_set_value)(struct gpio_desc *, uint8_t);
pmallick 0:3afcd581558d 127 /** gpio get value function pointer */
pmallick 0:3afcd581558d 128 int32_t (*gpio_ops_get_value)(struct gpio_desc *, uint8_t *);
pmallick 0:3afcd581558d 129 };
pmallick 0:3afcd581558d 130
pmallick 0:3afcd581558d 131 /******************************************************************************/
pmallick 0:3afcd581558d 132 /************************ Functions Declarations ******************************/
pmallick 0:3afcd581558d 133 /******************************************************************************/
pmallick 0:3afcd581558d 134
pmallick 0:3afcd581558d 135 /* Obtain the GPIO decriptor. */
pmallick 0:3afcd581558d 136 int32_t gpio_get(struct gpio_desc **desc,
pmallick 0:3afcd581558d 137 const struct gpio_init_param *param);
pmallick 0:3afcd581558d 138
pmallick 0:3afcd581558d 139 /* Obtain optional GPIO descriptor. */
pmallick 0:3afcd581558d 140 int32_t gpio_get_optional(struct gpio_desc **desc,
pmallick 0:3afcd581558d 141 const struct gpio_init_param *param);
pmallick 0:3afcd581558d 142
pmallick 0:3afcd581558d 143 /* Free the resources allocated by gpio_get() */
pmallick 0:3afcd581558d 144 int32_t gpio_remove(struct gpio_desc *desc);
pmallick 0:3afcd581558d 145
pmallick 0:3afcd581558d 146 /* Enable the input direction of the specified GPIO. */
pmallick 0:3afcd581558d 147 int32_t gpio_direction_input(struct gpio_desc *desc);
pmallick 0:3afcd581558d 148
pmallick 0:3afcd581558d 149 /* Enable the output direction of the specified GPIO. */
pmallick 0:3afcd581558d 150 int32_t gpio_direction_output(struct gpio_desc *desc,
pmallick 0:3afcd581558d 151 uint8_t value);
pmallick 0:3afcd581558d 152
pmallick 0:3afcd581558d 153 /* Get the direction of the specified GPIO. */
pmallick 0:3afcd581558d 154 int32_t gpio_get_direction(struct gpio_desc *desc,
pmallick 0:3afcd581558d 155 uint8_t *direction);
pmallick 0:3afcd581558d 156
pmallick 0:3afcd581558d 157 /* Set the value of the specified GPIO. */
pmallick 0:3afcd581558d 158 int32_t gpio_set_value(struct gpio_desc *desc,
pmallick 0:3afcd581558d 159 uint8_t value);
pmallick 0:3afcd581558d 160
pmallick 0:3afcd581558d 161 /* Get the value of the specified GPIO. */
pmallick 0:3afcd581558d 162 int32_t gpio_get_value(struct gpio_desc *desc,
pmallick 0:3afcd581558d 163 uint8_t *value);
pmallick 0:3afcd581558d 164
pmallick 0:3afcd581558d 165 #endif // GPIO_H_