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