![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ADISense1000 Version 2.1 code base
Fork of AdiSense1000_V21 by
src/mbed/adi_sense_gpio.cpp@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.cpp |
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 | |
kevin1990 | 7:4dbae381f693 | 48 | #include <mbed.h> |
kevin1990 | 7:4dbae381f693 | 49 | |
kevin1990 | 7:4dbae381f693 | 50 | #include "inc/adi_sense_gpio.h" |
kevin1990 | 7:4dbae381f693 | 51 | #include "inc/adi_sense_log.h" |
kevin1990 | 7:4dbae381f693 | 52 | |
kevin1990 | 7:4dbae381f693 | 53 | class GpioContext |
kevin1990 | 7:4dbae381f693 | 54 | { |
kevin1990 | 7:4dbae381f693 | 55 | public: |
kevin1990 | 7:4dbae381f693 | 56 | GpioContext( |
kevin1990 | 7:4dbae381f693 | 57 | PinName resetPin, |
kevin1990 | 7:4dbae381f693 | 58 | PinName errorPin, |
kevin1990 | 7:4dbae381f693 | 59 | PinName alertPin, |
kevin1990 | 7:4dbae381f693 | 60 | PinName datareadyPin) |
kevin1990 | 7:4dbae381f693 | 61 | : _reset(resetPin), |
kevin1990 | 7:4dbae381f693 | 62 | _error(errorPin), |
kevin1990 | 7:4dbae381f693 | 63 | _alert(alertPin), |
kevin1990 | 7:4dbae381f693 | 64 | _dataready(datareadyPin), |
kevin1990 | 7:4dbae381f693 | 65 | _errorIrq(errorPin), |
kevin1990 | 7:4dbae381f693 | 66 | _alertIrq(alertPin), |
kevin1990 | 7:4dbae381f693 | 67 | _datareadyIrq(datareadyPin) {} |
kevin1990 | 7:4dbae381f693 | 68 | |
kevin1990 | 7:4dbae381f693 | 69 | ADI_SENSE_RESULT get( |
kevin1990 | 7:4dbae381f693 | 70 | ADI_SENSE_GPIO_PIN ePinId, |
kevin1990 | 7:4dbae381f693 | 71 | bool_t *pState); |
kevin1990 | 7:4dbae381f693 | 72 | |
kevin1990 | 7:4dbae381f693 | 73 | ADI_SENSE_RESULT set( |
kevin1990 | 7:4dbae381f693 | 74 | ADI_SENSE_GPIO_PIN ePinId, |
kevin1990 | 7:4dbae381f693 | 75 | bool_t state); |
kevin1990 | 7:4dbae381f693 | 76 | |
kevin1990 | 7:4dbae381f693 | 77 | ADI_SENSE_RESULT enableIrq( |
kevin1990 | 7:4dbae381f693 | 78 | ADI_SENSE_GPIO_PIN ePinId, |
kevin1990 | 7:4dbae381f693 | 79 | ADI_SENSE_GPIO_CALLBACK callbackFn, |
kevin1990 | 7:4dbae381f693 | 80 | void *pArg); |
kevin1990 | 7:4dbae381f693 | 81 | |
kevin1990 | 7:4dbae381f693 | 82 | ADI_SENSE_RESULT disableIrq( |
kevin1990 | 7:4dbae381f693 | 83 | ADI_SENSE_GPIO_PIN ePinId); |
kevin1990 | 7:4dbae381f693 | 84 | |
kevin1990 | 7:4dbae381f693 | 85 | private: |
kevin1990 | 7:4dbae381f693 | 86 | DigitalOut _reset; |
kevin1990 | 7:4dbae381f693 | 87 | |
kevin1990 | 7:4dbae381f693 | 88 | DigitalIn _error; |
kevin1990 | 7:4dbae381f693 | 89 | DigitalIn _alert; |
kevin1990 | 7:4dbae381f693 | 90 | DigitalIn _dataready; |
kevin1990 | 7:4dbae381f693 | 91 | |
kevin1990 | 7:4dbae381f693 | 92 | InterruptIn _errorIrq; |
kevin1990 | 7:4dbae381f693 | 93 | InterruptIn _alertIrq; |
kevin1990 | 7:4dbae381f693 | 94 | InterruptIn _datareadyIrq; |
kevin1990 | 7:4dbae381f693 | 95 | |
kevin1990 | 7:4dbae381f693 | 96 | ADI_SENSE_GPIO_CALLBACK _errorIrqCallback; |
kevin1990 | 7:4dbae381f693 | 97 | ADI_SENSE_GPIO_CALLBACK _alertIrqCallback; |
kevin1990 | 7:4dbae381f693 | 98 | ADI_SENSE_GPIO_CALLBACK _datareadyIrqCallback; |
kevin1990 | 7:4dbae381f693 | 99 | |
kevin1990 | 7:4dbae381f693 | 100 | void *_errorIrqArg; |
kevin1990 | 7:4dbae381f693 | 101 | void *_alertIrqArg; |
kevin1990 | 7:4dbae381f693 | 102 | void *_datareadyIrqArg; |
kevin1990 | 7:4dbae381f693 | 103 | |
kevin1990 | 7:4dbae381f693 | 104 | void _errorIrqHandler() |
kevin1990 | 7:4dbae381f693 | 105 | { |
kevin1990 | 7:4dbae381f693 | 106 | _errorIrqCallback(ADI_SENSE_GPIO_PIN_ERROR, _errorIrqArg); |
kevin1990 | 7:4dbae381f693 | 107 | } |
kevin1990 | 7:4dbae381f693 | 108 | void _alertIrqHandler() |
kevin1990 | 7:4dbae381f693 | 109 | { |
kevin1990 | 7:4dbae381f693 | 110 | _alertIrqCallback(ADI_SENSE_GPIO_PIN_ALERT, _alertIrqArg); |
kevin1990 | 7:4dbae381f693 | 111 | } |
kevin1990 | 7:4dbae381f693 | 112 | void _datareadyIrqHandler() |
kevin1990 | 7:4dbae381f693 | 113 | { |
kevin1990 | 7:4dbae381f693 | 114 | _datareadyIrqCallback(ADI_SENSE_GPIO_PIN_DATAREADY, _datareadyIrqArg); |
kevin1990 | 7:4dbae381f693 | 115 | } |
kevin1990 | 7:4dbae381f693 | 116 | }; |
kevin1990 | 7:4dbae381f693 | 117 | |
kevin1990 | 7:4dbae381f693 | 118 | ADI_SENSE_RESULT GpioContext::get( |
kevin1990 | 7:4dbae381f693 | 119 | ADI_SENSE_GPIO_PIN ePinId, |
kevin1990 | 7:4dbae381f693 | 120 | bool_t *pState) |
kevin1990 | 7:4dbae381f693 | 121 | { |
kevin1990 | 7:4dbae381f693 | 122 | switch(ePinId) |
kevin1990 | 7:4dbae381f693 | 123 | { |
kevin1990 | 7:4dbae381f693 | 124 | case ADI_SENSE_GPIO_PIN_ERROR: |
kevin1990 | 7:4dbae381f693 | 125 | *pState = _error; |
kevin1990 | 7:4dbae381f693 | 126 | return ADI_SENSE_SUCCESS; |
kevin1990 | 7:4dbae381f693 | 127 | case ADI_SENSE_GPIO_PIN_ALERT: |
kevin1990 | 7:4dbae381f693 | 128 | *pState = _alert; |
kevin1990 | 7:4dbae381f693 | 129 | return ADI_SENSE_SUCCESS; |
kevin1990 | 7:4dbae381f693 | 130 | case ADI_SENSE_GPIO_PIN_DATAREADY: |
kevin1990 | 7:4dbae381f693 | 131 | *pState = _dataready; |
kevin1990 | 7:4dbae381f693 | 132 | return ADI_SENSE_SUCCESS; |
kevin1990 | 7:4dbae381f693 | 133 | case ADI_SENSE_GPIO_PIN_RESET: |
kevin1990 | 7:4dbae381f693 | 134 | *pState = _reset; |
kevin1990 | 7:4dbae381f693 | 135 | return ADI_SENSE_SUCCESS; |
kevin1990 | 7:4dbae381f693 | 136 | default: |
kevin1990 | 7:4dbae381f693 | 137 | return ADI_SENSE_INVALID_DEVICE_NUM; |
kevin1990 | 7:4dbae381f693 | 138 | } |
kevin1990 | 7:4dbae381f693 | 139 | } |
kevin1990 | 7:4dbae381f693 | 140 | |
kevin1990 | 7:4dbae381f693 | 141 | ADI_SENSE_RESULT GpioContext::set( |
kevin1990 | 7:4dbae381f693 | 142 | ADI_SENSE_GPIO_PIN ePinId, |
kevin1990 | 7:4dbae381f693 | 143 | bool_t state) |
kevin1990 | 7:4dbae381f693 | 144 | { |
kevin1990 | 7:4dbae381f693 | 145 | switch(ePinId) |
kevin1990 | 7:4dbae381f693 | 146 | { |
kevin1990 | 7:4dbae381f693 | 147 | case ADI_SENSE_GPIO_PIN_RESET: |
kevin1990 | 7:4dbae381f693 | 148 | _reset = state; |
kevin1990 | 7:4dbae381f693 | 149 | break; |
kevin1990 | 7:4dbae381f693 | 150 | default: |
kevin1990 | 7:4dbae381f693 | 151 | return ADI_SENSE_INVALID_DEVICE_NUM; |
kevin1990 | 7:4dbae381f693 | 152 | } |
kevin1990 | 7:4dbae381f693 | 153 | |
kevin1990 | 7:4dbae381f693 | 154 | return ADI_SENSE_SUCCESS; |
kevin1990 | 7:4dbae381f693 | 155 | } |
kevin1990 | 7:4dbae381f693 | 156 | |
kevin1990 | 7:4dbae381f693 | 157 | ADI_SENSE_RESULT GpioContext::enableIrq( |
kevin1990 | 7:4dbae381f693 | 158 | ADI_SENSE_GPIO_PIN ePinId, |
kevin1990 | 7:4dbae381f693 | 159 | ADI_SENSE_GPIO_CALLBACK callbackFn, |
kevin1990 | 7:4dbae381f693 | 160 | void *pArg) |
kevin1990 | 7:4dbae381f693 | 161 | { |
kevin1990 | 7:4dbae381f693 | 162 | switch(ePinId) |
kevin1990 | 7:4dbae381f693 | 163 | { |
kevin1990 | 7:4dbae381f693 | 164 | case ADI_SENSE_GPIO_PIN_ERROR: |
kevin1990 | 7:4dbae381f693 | 165 | _errorIrqCallback = callbackFn; |
kevin1990 | 7:4dbae381f693 | 166 | _errorIrqArg = pArg; |
kevin1990 | 7:4dbae381f693 | 167 | _errorIrq.rise(callback(this, &GpioContext::_errorIrqHandler)); |
kevin1990 | 7:4dbae381f693 | 168 | return ADI_SENSE_SUCCESS; |
kevin1990 | 7:4dbae381f693 | 169 | case ADI_SENSE_GPIO_PIN_ALERT: |
kevin1990 | 7:4dbae381f693 | 170 | _alertIrqCallback = callbackFn; |
kevin1990 | 7:4dbae381f693 | 171 | _alertIrqArg = pArg; |
kevin1990 | 7:4dbae381f693 | 172 | _alertIrq.rise(callback(this, &GpioContext::_alertIrqHandler)); |
kevin1990 | 7:4dbae381f693 | 173 | return ADI_SENSE_SUCCESS; |
kevin1990 | 7:4dbae381f693 | 174 | case ADI_SENSE_GPIO_PIN_DATAREADY: |
kevin1990 | 7:4dbae381f693 | 175 | _datareadyIrqCallback = callbackFn; |
kevin1990 | 7:4dbae381f693 | 176 | _datareadyIrqArg = pArg; |
kevin1990 | 7:4dbae381f693 | 177 | _datareadyIrq.rise(callback(this, &GpioContext::_datareadyIrqHandler)); |
kevin1990 | 7:4dbae381f693 | 178 | return ADI_SENSE_SUCCESS; |
kevin1990 | 7:4dbae381f693 | 179 | default: |
kevin1990 | 7:4dbae381f693 | 180 | return ADI_SENSE_INVALID_DEVICE_NUM; |
kevin1990 | 7:4dbae381f693 | 181 | } |
kevin1990 | 7:4dbae381f693 | 182 | } |
kevin1990 | 7:4dbae381f693 | 183 | |
kevin1990 | 7:4dbae381f693 | 184 | ADI_SENSE_RESULT GpioContext::disableIrq( |
kevin1990 | 7:4dbae381f693 | 185 | ADI_SENSE_GPIO_PIN ePinId) |
kevin1990 | 7:4dbae381f693 | 186 | { |
kevin1990 | 7:4dbae381f693 | 187 | switch(ePinId) |
kevin1990 | 7:4dbae381f693 | 188 | { |
kevin1990 | 7:4dbae381f693 | 189 | case ADI_SENSE_GPIO_PIN_ERROR: |
kevin1990 | 7:4dbae381f693 | 190 | _errorIrq.rise(NULL); |
kevin1990 | 7:4dbae381f693 | 191 | return ADI_SENSE_SUCCESS; |
kevin1990 | 7:4dbae381f693 | 192 | case ADI_SENSE_GPIO_PIN_ALERT: |
kevin1990 | 7:4dbae381f693 | 193 | _alertIrq.rise(NULL); |
kevin1990 | 7:4dbae381f693 | 194 | return ADI_SENSE_SUCCESS; |
kevin1990 | 7:4dbae381f693 | 195 | case ADI_SENSE_GPIO_PIN_DATAREADY: |
kevin1990 | 7:4dbae381f693 | 196 | _datareadyIrq.rise(NULL); |
kevin1990 | 7:4dbae381f693 | 197 | return ADI_SENSE_SUCCESS; |
kevin1990 | 7:4dbae381f693 | 198 | default: |
kevin1990 | 7:4dbae381f693 | 199 | return ADI_SENSE_INVALID_DEVICE_NUM; |
kevin1990 | 7:4dbae381f693 | 200 | } |
kevin1990 | 7:4dbae381f693 | 201 | } |
kevin1990 | 7:4dbae381f693 | 202 | |
kevin1990 | 7:4dbae381f693 | 203 | #ifdef __cplusplus |
kevin1990 | 7:4dbae381f693 | 204 | extern "C" { |
kevin1990 | 7:4dbae381f693 | 205 | #endif |
kevin1990 | 7:4dbae381f693 | 206 | |
kevin1990 | 7:4dbae381f693 | 207 | /* |
kevin1990 | 7:4dbae381f693 | 208 | * Open the GPIO interface and allocate resources |
kevin1990 | 7:4dbae381f693 | 209 | */ |
kevin1990 | 7:4dbae381f693 | 210 | ADI_SENSE_RESULT adi_sense_GpioOpen( |
kevin1990 | 7:4dbae381f693 | 211 | ADI_SENSE_PLATFORM_GPIO_CONFIG *pConfig, |
kevin1990 | 7:4dbae381f693 | 212 | ADI_SENSE_GPIO_HANDLE *phDevice) |
kevin1990 | 7:4dbae381f693 | 213 | { |
kevin1990 | 7:4dbae381f693 | 214 | GpioContext *pCtx = new GpioContext((PinName)pConfig->resetPin, |
kevin1990 | 7:4dbae381f693 | 215 | (PinName)pConfig->errorPin, |
kevin1990 | 7:4dbae381f693 | 216 | (PinName)pConfig->alertPin, |
kevin1990 | 7:4dbae381f693 | 217 | (PinName)pConfig->datareadyPin); |
kevin1990 | 7:4dbae381f693 | 218 | if (!pCtx) |
kevin1990 | 7:4dbae381f693 | 219 | { |
kevin1990 | 7:4dbae381f693 | 220 | ADI_SENSE_LOG_ERROR("Failed to allocate memory for GPIO context"); |
kevin1990 | 7:4dbae381f693 | 221 | return ADI_SENSE_NO_MEM; |
kevin1990 | 7:4dbae381f693 | 222 | } |
kevin1990 | 7:4dbae381f693 | 223 | |
kevin1990 | 7:4dbae381f693 | 224 | *phDevice = reinterpret_cast<ADI_SENSE_GPIO_HANDLE>(pCtx); |
kevin1990 | 7:4dbae381f693 | 225 | return ADI_SENSE_SUCCESS; |
kevin1990 | 7:4dbae381f693 | 226 | } |
kevin1990 | 7:4dbae381f693 | 227 | |
kevin1990 | 7:4dbae381f693 | 228 | /* |
kevin1990 | 7:4dbae381f693 | 229 | * Get the state of the specified GPIO pin |
kevin1990 | 7:4dbae381f693 | 230 | */ |
kevin1990 | 7:4dbae381f693 | 231 | ADI_SENSE_RESULT adi_sense_GpioGet( |
kevin1990 | 7:4dbae381f693 | 232 | ADI_SENSE_GPIO_HANDLE hDevice, |
kevin1990 | 7:4dbae381f693 | 233 | ADI_SENSE_GPIO_PIN ePinId, |
kevin1990 | 7:4dbae381f693 | 234 | bool_t *pbState) |
kevin1990 | 7:4dbae381f693 | 235 | { |
kevin1990 | 7:4dbae381f693 | 236 | GpioContext *pCtx = reinterpret_cast<GpioContext *>(hDevice); |
kevin1990 | 7:4dbae381f693 | 237 | |
kevin1990 | 7:4dbae381f693 | 238 | return pCtx->get(ePinId, pbState); |
kevin1990 | 7:4dbae381f693 | 239 | } |
kevin1990 | 7:4dbae381f693 | 240 | |
kevin1990 | 7:4dbae381f693 | 241 | /* |
kevin1990 | 7:4dbae381f693 | 242 | * Set the state of the specified GPIO pin |
kevin1990 | 7:4dbae381f693 | 243 | */ |
kevin1990 | 7:4dbae381f693 | 244 | ADI_SENSE_RESULT adi_sense_GpioSet( |
kevin1990 | 7:4dbae381f693 | 245 | ADI_SENSE_GPIO_HANDLE hDevice, |
kevin1990 | 7:4dbae381f693 | 246 | ADI_SENSE_GPIO_PIN ePinId, |
kevin1990 | 7:4dbae381f693 | 247 | bool_t bState) |
kevin1990 | 7:4dbae381f693 | 248 | { |
kevin1990 | 7:4dbae381f693 | 249 | GpioContext *pCtx = reinterpret_cast<GpioContext *>(hDevice); |
kevin1990 | 7:4dbae381f693 | 250 | |
kevin1990 | 7:4dbae381f693 | 251 | return pCtx->set(ePinId, bState); |
kevin1990 | 7:4dbae381f693 | 252 | } |
kevin1990 | 7:4dbae381f693 | 253 | |
kevin1990 | 7:4dbae381f693 | 254 | /* |
kevin1990 | 7:4dbae381f693 | 255 | * Enable interrupt notifications on the specified GPIO pin |
kevin1990 | 7:4dbae381f693 | 256 | */ |
kevin1990 | 7:4dbae381f693 | 257 | ADI_SENSE_RESULT adi_sense_GpioIrqEnable( |
kevin1990 | 7:4dbae381f693 | 258 | ADI_SENSE_GPIO_HANDLE hDevice, |
kevin1990 | 7:4dbae381f693 | 259 | ADI_SENSE_GPIO_PIN ePinId, |
kevin1990 | 7:4dbae381f693 | 260 | ADI_SENSE_GPIO_CALLBACK callback, |
kevin1990 | 7:4dbae381f693 | 261 | void *arg) |
kevin1990 | 7:4dbae381f693 | 262 | { |
kevin1990 | 7:4dbae381f693 | 263 | GpioContext *pCtx = reinterpret_cast<GpioContext *>(hDevice); |
kevin1990 | 7:4dbae381f693 | 264 | |
kevin1990 | 7:4dbae381f693 | 265 | return pCtx->enableIrq(ePinId, callback, arg); |
kevin1990 | 7:4dbae381f693 | 266 | } |
kevin1990 | 7:4dbae381f693 | 267 | |
kevin1990 | 7:4dbae381f693 | 268 | /* |
kevin1990 | 7:4dbae381f693 | 269 | * Disable interrupt notifications on the specified GPIO pin |
kevin1990 | 7:4dbae381f693 | 270 | */ |
kevin1990 | 7:4dbae381f693 | 271 | ADI_SENSE_RESULT adi_sense_GpioIrqDisable( |
kevin1990 | 7:4dbae381f693 | 272 | ADI_SENSE_GPIO_HANDLE hDevice, |
kevin1990 | 7:4dbae381f693 | 273 | ADI_SENSE_GPIO_PIN ePinId) |
kevin1990 | 7:4dbae381f693 | 274 | { |
kevin1990 | 7:4dbae381f693 | 275 | GpioContext *pCtx = reinterpret_cast<GpioContext *>(hDevice); |
kevin1990 | 7:4dbae381f693 | 276 | |
kevin1990 | 7:4dbae381f693 | 277 | return pCtx->disableIrq(ePinId); |
kevin1990 | 7:4dbae381f693 | 278 | } |
kevin1990 | 7:4dbae381f693 | 279 | |
kevin1990 | 7:4dbae381f693 | 280 | /* |
kevin1990 | 7:4dbae381f693 | 281 | * Close the GPIO interface and free resources |
kevin1990 | 7:4dbae381f693 | 282 | */ |
kevin1990 | 7:4dbae381f693 | 283 | void adi_sense_GpioClose( |
kevin1990 | 7:4dbae381f693 | 284 | ADI_SENSE_GPIO_HANDLE hDevice) |
kevin1990 | 7:4dbae381f693 | 285 | { |
kevin1990 | 7:4dbae381f693 | 286 | GpioContext *pCtx = reinterpret_cast<GpioContext *>(hDevice); |
kevin1990 | 7:4dbae381f693 | 287 | |
kevin1990 | 7:4dbae381f693 | 288 | delete pCtx; |
kevin1990 | 7:4dbae381f693 | 289 | } |
kevin1990 | 7:4dbae381f693 | 290 | |
kevin1990 | 7:4dbae381f693 | 291 | #ifdef __cplusplus |
kevin1990 | 7:4dbae381f693 | 292 | } |
kevin1990 | 7:4dbae381f693 | 293 | #endif |
kevin1990 | 7:4dbae381f693 | 294 |