Rohan Gurav
/
Sean_AdiSense1000_V21
ADISense1000 Version 2.1 code base
Fork of AdiSense1000_V21 by
inc/adi_sense_gpio.h@7:4dbae381f693, 2017-10-20 (annotated)
- Committer:
- kevin1990
- Date:
- Fri Oct 20 15:58:01 2017 +0000
- Revision:
- 7:4dbae381f693
v0.3 release (New Host api)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kevin1990 | 7:4dbae381f693 | 1 | /*! |
kevin1990 | 7:4dbae381f693 | 2 | ****************************************************************************** |
kevin1990 | 7:4dbae381f693 | 3 | * @file: adi_sense_gpio.h |
kevin1990 | 7:4dbae381f693 | 4 | * @brief: ADI Sense OS-dependent wrapper layer for GPIO interface |
kevin1990 | 7:4dbae381f693 | 5 | *----------------------------------------------------------------------------- |
kevin1990 | 7:4dbae381f693 | 6 | */ |
kevin1990 | 7:4dbae381f693 | 7 | |
kevin1990 | 7:4dbae381f693 | 8 | /* |
kevin1990 | 7:4dbae381f693 | 9 | Copyright (c) 2017 Emutex Ltd. / Analog Devices, Inc. |
kevin1990 | 7:4dbae381f693 | 10 | |
kevin1990 | 7:4dbae381f693 | 11 | All rights reserved. |
kevin1990 | 7:4dbae381f693 | 12 | |
kevin1990 | 7:4dbae381f693 | 13 | Redistribution and use in source and binary forms, with or without modification, |
kevin1990 | 7:4dbae381f693 | 14 | are permitted provided that the following conditions are met: |
kevin1990 | 7:4dbae381f693 | 15 | - Redistributions of source code must retain the above copyright notice, |
kevin1990 | 7:4dbae381f693 | 16 | this list of conditions and the following disclaimer. |
kevin1990 | 7:4dbae381f693 | 17 | - Redistributions in binary form must reproduce the above copyright notice, |
kevin1990 | 7:4dbae381f693 | 18 | this list of conditions and the following disclaimer in the documentation |
kevin1990 | 7:4dbae381f693 | 19 | and/or other materials provided with the distribution. |
kevin1990 | 7:4dbae381f693 | 20 | - Modified versions of the software must be conspicuously marked as such. |
kevin1990 | 7:4dbae381f693 | 21 | - This software is licensed solely and exclusively for use with processors |
kevin1990 | 7:4dbae381f693 | 22 | manufactured by or for Analog Devices, Inc. |
kevin1990 | 7:4dbae381f693 | 23 | - This software may not be combined or merged with other code in any manner |
kevin1990 | 7:4dbae381f693 | 24 | that would cause the software to become subject to terms and conditions |
kevin1990 | 7:4dbae381f693 | 25 | which differ from those listed here. |
kevin1990 | 7:4dbae381f693 | 26 | - Neither the name of Analog Devices, Inc. nor the names of its |
kevin1990 | 7:4dbae381f693 | 27 | contributors may be used to endorse or promote products derived |
kevin1990 | 7:4dbae381f693 | 28 | from this software without specific prior written permission. |
kevin1990 | 7:4dbae381f693 | 29 | - The use of this software may or may not infringe the patent rights of one |
kevin1990 | 7:4dbae381f693 | 30 | or more patent holders. This license does not release you from the |
kevin1990 | 7:4dbae381f693 | 31 | requirement that you obtain separate licenses from these patent holders |
kevin1990 | 7:4dbae381f693 | 32 | to use this software. |
kevin1990 | 7:4dbae381f693 | 33 | |
kevin1990 | 7:4dbae381f693 | 34 | THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND ANY |
kevin1990 | 7:4dbae381f693 | 35 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, |
kevin1990 | 7:4dbae381f693 | 36 | TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN |
kevin1990 | 7:4dbae381f693 | 37 | NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
kevin1990 | 7:4dbae381f693 | 38 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES |
kevin1990 | 7:4dbae381f693 | 39 | (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL |
kevin1990 | 7:4dbae381f693 | 40 | PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
kevin1990 | 7:4dbae381f693 | 41 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
kevin1990 | 7:4dbae381f693 | 42 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
kevin1990 | 7:4dbae381f693 | 43 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
kevin1990 | 7:4dbae381f693 | 44 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
kevin1990 | 7:4dbae381f693 | 45 | */ |
kevin1990 | 7:4dbae381f693 | 46 | |
kevin1990 | 7:4dbae381f693 | 47 | #ifndef __ADI_SENSE_GPIO_H__ |
kevin1990 | 7:4dbae381f693 | 48 | #define __ADI_SENSE_GPIO_H__ |
kevin1990 | 7:4dbae381f693 | 49 | |
kevin1990 | 7:4dbae381f693 | 50 | #include "inc/adi_sense_types.h" |
kevin1990 | 7:4dbae381f693 | 51 | #include "inc/adi_sense_platform.h" |
kevin1990 | 7:4dbae381f693 | 52 | |
kevin1990 | 7:4dbae381f693 | 53 | /*! @ingroup ADI_Sense_Host */ |
kevin1990 | 7:4dbae381f693 | 54 | |
kevin1990 | 7:4dbae381f693 | 55 | /*! @addtogroup ADI_Sense_Gpio ADI Sense Host GPIO interface functions |
kevin1990 | 7:4dbae381f693 | 56 | * @{ |
kevin1990 | 7:4dbae381f693 | 57 | */ |
kevin1990 | 7:4dbae381f693 | 58 | |
kevin1990 | 7:4dbae381f693 | 59 | /*! GPIO pin identifiers */ |
kevin1990 | 7:4dbae381f693 | 60 | typedef enum |
kevin1990 | 7:4dbae381f693 | 61 | { |
kevin1990 | 7:4dbae381f693 | 62 | ADI_SENSE_GPIO_PIN_RESET = 0, /*!< RESET GPIO output signal */ |
kevin1990 | 7:4dbae381f693 | 63 | ADI_SENSE_GPIO_PIN_ERROR, /*!< ERROR GPIO input signal */ |
kevin1990 | 7:4dbae381f693 | 64 | ADI_SENSE_GPIO_PIN_ALERT, /*!< ALERT GPIO input signal */ |
kevin1990 | 7:4dbae381f693 | 65 | ADI_SENSE_GPIO_PIN_DATAREADY, /*!< DATAREADY GPIO input signal */ |
kevin1990 | 7:4dbae381f693 | 66 | } ADI_SENSE_GPIO_PIN; |
kevin1990 | 7:4dbae381f693 | 67 | |
kevin1990 | 7:4dbae381f693 | 68 | /*! |
kevin1990 | 7:4dbae381f693 | 69 | * GPIO callback function signature |
kevin1990 | 7:4dbae381f693 | 70 | * |
kevin1990 | 7:4dbae381f693 | 71 | * @param[in] ePinId The GPIO pin which triggered the interrupt notification |
kevin1990 | 7:4dbae381f693 | 72 | * @param[in] pArg Optional opaque parameter to be passed to the callback |
kevin1990 | 7:4dbae381f693 | 73 | */ |
kevin1990 | 7:4dbae381f693 | 74 | typedef void (*ADI_SENSE_GPIO_CALLBACK)( |
kevin1990 | 7:4dbae381f693 | 75 | ADI_SENSE_GPIO_PIN ePinId, |
kevin1990 | 7:4dbae381f693 | 76 | void * pArg); |
kevin1990 | 7:4dbae381f693 | 77 | |
kevin1990 | 7:4dbae381f693 | 78 | /*! A handle used in all API functions to identify the GPIO interface context */ |
kevin1990 | 7:4dbae381f693 | 79 | typedef void* ADI_SENSE_GPIO_HANDLE; |
kevin1990 | 7:4dbae381f693 | 80 | |
kevin1990 | 7:4dbae381f693 | 81 | #ifdef __cplusplus |
kevin1990 | 7:4dbae381f693 | 82 | extern "C" |
kevin1990 | 7:4dbae381f693 | 83 | { |
kevin1990 | 7:4dbae381f693 | 84 | #endif |
kevin1990 | 7:4dbae381f693 | 85 | |
kevin1990 | 7:4dbae381f693 | 86 | /*! |
kevin1990 | 7:4dbae381f693 | 87 | * @brief Open the SPI interface and allocate resources |
kevin1990 | 7:4dbae381f693 | 88 | * |
kevin1990 | 7:4dbae381f693 | 89 | * @param[in] pConfig Pointer to platform-specific GPIO interface details |
kevin1990 | 7:4dbae381f693 | 90 | * @param[out] phDevice Pointer to return a GPIO interface context handle |
kevin1990 | 7:4dbae381f693 | 91 | * |
kevin1990 | 7:4dbae381f693 | 92 | * @return Status |
kevin1990 | 7:4dbae381f693 | 93 | * - #ADI_SENSE_SUCCESS Call completed successfully |
kevin1990 | 7:4dbae381f693 | 94 | * - #ADI_SENSE_NO_MEM Failed to allocate memory for interface context |
kevin1990 | 7:4dbae381f693 | 95 | */ |
kevin1990 | 7:4dbae381f693 | 96 | ADI_SENSE_RESULT adi_sense_GpioOpen( |
kevin1990 | 7:4dbae381f693 | 97 | ADI_SENSE_PLATFORM_GPIO_CONFIG * pConfig, |
kevin1990 | 7:4dbae381f693 | 98 | ADI_SENSE_GPIO_HANDLE * phDevice); |
kevin1990 | 7:4dbae381f693 | 99 | |
kevin1990 | 7:4dbae381f693 | 100 | /*! |
kevin1990 | 7:4dbae381f693 | 101 | * @brief Close GPIO interface and free resources |
kevin1990 | 7:4dbae381f693 | 102 | * |
kevin1990 | 7:4dbae381f693 | 103 | * @param[in] hDevice GPIO interface context handle (@ref adi_sense_GpioOpen) |
kevin1990 | 7:4dbae381f693 | 104 | */ |
kevin1990 | 7:4dbae381f693 | 105 | void adi_sense_GpioClose( |
kevin1990 | 7:4dbae381f693 | 106 | ADI_SENSE_GPIO_HANDLE hDevice); |
kevin1990 | 7:4dbae381f693 | 107 | |
kevin1990 | 7:4dbae381f693 | 108 | /*! |
kevin1990 | 7:4dbae381f693 | 109 | * @brief Get the state of the specified GPIO pin |
kevin1990 | 7:4dbae381f693 | 110 | * |
kevin1990 | 7:4dbae381f693 | 111 | * @param[in] hDevice GPIO interface context handle (@ref adi_sense_GpioOpen) |
kevin1990 | 7:4dbae381f693 | 112 | * @param[in] ePinId GPIO pin to be read |
kevin1990 | 7:4dbae381f693 | 113 | * @param[out] pbState Pointer to return the state of the GPIO pin |
kevin1990 | 7:4dbae381f693 | 114 | * |
kevin1990 | 7:4dbae381f693 | 115 | * @return Status |
kevin1990 | 7:4dbae381f693 | 116 | * - #ADI_SENSE_SUCCESS Call completed successfully |
kevin1990 | 7:4dbae381f693 | 117 | * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid GPIO pin specified |
kevin1990 | 7:4dbae381f693 | 118 | */ |
kevin1990 | 7:4dbae381f693 | 119 | ADI_SENSE_RESULT adi_sense_GpioGet( |
kevin1990 | 7:4dbae381f693 | 120 | ADI_SENSE_GPIO_HANDLE hDevice, |
kevin1990 | 7:4dbae381f693 | 121 | ADI_SENSE_GPIO_PIN ePinID, |
kevin1990 | 7:4dbae381f693 | 122 | bool_t * bState); |
kevin1990 | 7:4dbae381f693 | 123 | |
kevin1990 | 7:4dbae381f693 | 124 | /*! |
kevin1990 | 7:4dbae381f693 | 125 | * @brief Set the state of the specified GPIO pin |
kevin1990 | 7:4dbae381f693 | 126 | * |
kevin1990 | 7:4dbae381f693 | 127 | * @param[in] hDevice GPIO interface context handle (@ref adi_sense_GpioOpen) |
kevin1990 | 7:4dbae381f693 | 128 | * @param[in] ePinId GPIO pin to be set |
kevin1990 | 7:4dbae381f693 | 129 | * @param[in] bState The state to set for GPIO pin |
kevin1990 | 7:4dbae381f693 | 130 | * |
kevin1990 | 7:4dbae381f693 | 131 | * @return Status |
kevin1990 | 7:4dbae381f693 | 132 | * - #ADI_SENSE_SUCCESS Call completed successfully |
kevin1990 | 7:4dbae381f693 | 133 | * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid GPIO pin specified |
kevin1990 | 7:4dbae381f693 | 134 | */ |
kevin1990 | 7:4dbae381f693 | 135 | ADI_SENSE_RESULT adi_sense_GpioSet( |
kevin1990 | 7:4dbae381f693 | 136 | ADI_SENSE_GPIO_HANDLE hDevice, |
kevin1990 | 7:4dbae381f693 | 137 | ADI_SENSE_GPIO_PIN ePinID, |
kevin1990 | 7:4dbae381f693 | 138 | bool_t bState); |
kevin1990 | 7:4dbae381f693 | 139 | |
kevin1990 | 7:4dbae381f693 | 140 | /*! |
kevin1990 | 7:4dbae381f693 | 141 | * @brief Enable interrupt notifications on the specified GPIO pin |
kevin1990 | 7:4dbae381f693 | 142 | * |
kevin1990 | 7:4dbae381f693 | 143 | * @param[in] hDevice GPIO interface context handle (@ref adi_sense_GpioOpen) |
kevin1990 | 7:4dbae381f693 | 144 | * @param[in] ePinId GPIO pin on which to enable interrupt notifications |
kevin1990 | 7:4dbae381f693 | 145 | * @param[in] callback Callback function to invoke when the GPIO is asserted |
kevin1990 | 7:4dbae381f693 | 146 | * @param[in] arg Optional opaque parameter to be passed to the callback |
kevin1990 | 7:4dbae381f693 | 147 | * |
kevin1990 | 7:4dbae381f693 | 148 | * @return Status |
kevin1990 | 7:4dbae381f693 | 149 | * - #ADI_SENSE_SUCCESS Call completed successfully |
kevin1990 | 7:4dbae381f693 | 150 | * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid GPIO pin specified |
kevin1990 | 7:4dbae381f693 | 151 | */ |
kevin1990 | 7:4dbae381f693 | 152 | ADI_SENSE_RESULT adi_sense_GpioIrqEnable( |
kevin1990 | 7:4dbae381f693 | 153 | ADI_SENSE_GPIO_HANDLE hDevice, |
kevin1990 | 7:4dbae381f693 | 154 | ADI_SENSE_GPIO_PIN ePinID, |
kevin1990 | 7:4dbae381f693 | 155 | ADI_SENSE_GPIO_CALLBACK callback, |
kevin1990 | 7:4dbae381f693 | 156 | void * arg); |
kevin1990 | 7:4dbae381f693 | 157 | |
kevin1990 | 7:4dbae381f693 | 158 | /*! |
kevin1990 | 7:4dbae381f693 | 159 | * @brief Disable interrupt notifications on the specified GPIO pin |
kevin1990 | 7:4dbae381f693 | 160 | * |
kevin1990 | 7:4dbae381f693 | 161 | * @param[in] hDevice GPIO interface context handle (@ref adi_sense_GpioOpen) |
kevin1990 | 7:4dbae381f693 | 162 | * @param[in] ePinId GPIO pin on which to disable interrupt notifications |
kevin1990 | 7:4dbae381f693 | 163 | * |
kevin1990 | 7:4dbae381f693 | 164 | * @return Status |
kevin1990 | 7:4dbae381f693 | 165 | * - #ADI_SENSE_SUCCESS Call completed successfully |
kevin1990 | 7:4dbae381f693 | 166 | * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid GPIO pin specified |
kevin1990 | 7:4dbae381f693 | 167 | */ |
kevin1990 | 7:4dbae381f693 | 168 | ADI_SENSE_RESULT adi_sense_GpioIrqDisable( |
kevin1990 | 7:4dbae381f693 | 169 | ADI_SENSE_GPIO_HANDLE hDevice, |
kevin1990 | 7:4dbae381f693 | 170 | ADI_SENSE_GPIO_PIN ePinID); |
kevin1990 | 7:4dbae381f693 | 171 | |
kevin1990 | 7:4dbae381f693 | 172 | #ifdef __cplusplus |
kevin1990 | 7:4dbae381f693 | 173 | } |
kevin1990 | 7:4dbae381f693 | 174 | #endif |
kevin1990 | 7:4dbae381f693 | 175 | |
kevin1990 | 7:4dbae381f693 | 176 | /*! |
kevin1990 | 7:4dbae381f693 | 177 | * @} |
kevin1990 | 7:4dbae381f693 | 178 | */ |
kevin1990 | 7:4dbae381f693 | 179 | |
kevin1990 | 7:4dbae381f693 | 180 | #endif /* __ADI_SENSE_GPIO_H__ */ |
kevin1990 | 7:4dbae381f693 | 181 |