Bumped Mbed FW version to 01.20.0080

Committer:
Vkadaba
Date:
Wed Jun 05 05:39:15 2019 +0000
Revision:
5:0728bde67bdb
Parent:
src/mbed/adi_sense_gpio.cpp@0:85855ecd3257
Child:
23:bb685f35b08b
Replaced all references to ADISense/ADISENSE1000/adi_sense with ADMW/ADMW1001/admw and the prject builds.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ADIJake 0:85855ecd3257 1 /******************************************************************************
ADIJake 0:85855ecd3257 2 Copyright 2017 (c) Analog Devices, Inc.
ADIJake 0:85855ecd3257 3
ADIJake 0:85855ecd3257 4 All rights reserved.
ADIJake 0:85855ecd3257 5
ADIJake 0:85855ecd3257 6 Redistribution and use in source and binary forms, with or without
ADIJake 0:85855ecd3257 7 modification, are permitted provided that the following conditions are met:
ADIJake 0:85855ecd3257 8 - Redistributions of source code must retain the above copyright
ADIJake 0:85855ecd3257 9 notice, this list of conditions and the following disclaimer.
ADIJake 0:85855ecd3257 10 - Redistributions in binary form must reproduce the above copyright
ADIJake 0:85855ecd3257 11 notice, this list of conditions and the following disclaimer in
ADIJake 0:85855ecd3257 12 the documentation and/or other materials provided with the
ADIJake 0:85855ecd3257 13 distribution.
ADIJake 0:85855ecd3257 14 - Neither the name of Analog Devices, Inc. nor the names of its
ADIJake 0:85855ecd3257 15 contributors may be used to endorse or promote products derived
ADIJake 0:85855ecd3257 16 from this software without specific prior written permission.
ADIJake 0:85855ecd3257 17 - The use of this software may or may not infringe the patent rights
ADIJake 0:85855ecd3257 18 of one or more patent holders. This license does not release you
ADIJake 0:85855ecd3257 19 from the requirement that you obtain separate licenses from these
ADIJake 0:85855ecd3257 20 patent holders to use this software.
ADIJake 0:85855ecd3257 21 - Use of the software either in source or binary form, must be run
ADIJake 0:85855ecd3257 22 on or directly connected to an Analog Devices Inc. component.
ADIJake 0:85855ecd3257 23
ADIJake 0:85855ecd3257 24 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
ADIJake 0:85855ecd3257 25 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
ADIJake 0:85855ecd3257 26 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
ADIJake 0:85855ecd3257 27 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
ADIJake 0:85855ecd3257 28 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
ADIJake 0:85855ecd3257 29 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
ADIJake 0:85855ecd3257 30 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
ADIJake 0:85855ecd3257 31 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
ADIJake 0:85855ecd3257 32 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
ADIJake 0:85855ecd3257 33 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ADIJake 0:85855ecd3257 34 *
ADIJake 0:85855ecd3257 35 *****************************************************************************/
ADIJake 0:85855ecd3257 36
ADIJake 0:85855ecd3257 37 /*!
ADIJake 0:85855ecd3257 38 ******************************************************************************
ADIJake 0:85855ecd3257 39 * @file:
Vkadaba 5:0728bde67bdb 40 * @brief: ADMW OS-dependent wrapper layer for GPIO interface
ADIJake 0:85855ecd3257 41 *-----------------------------------------------------------------------------
ADIJake 0:85855ecd3257 42 */
ADIJake 0:85855ecd3257 43
ADIJake 0:85855ecd3257 44 #include <mbed.h>
ADIJake 0:85855ecd3257 45
Vkadaba 5:0728bde67bdb 46 #include "inc/admw_gpio.h"
Vkadaba 5:0728bde67bdb 47 #include "inc/admw_log.h"
ADIJake 0:85855ecd3257 48
ADIJake 0:85855ecd3257 49 class GpioContext
ADIJake 0:85855ecd3257 50 {
ADIJake 0:85855ecd3257 51 public:
ADIJake 0:85855ecd3257 52 GpioContext(
ADIJake 0:85855ecd3257 53 PinName resetPin,
Vkadaba 5:0728bde67bdb 54 PinName alertErrorPin,
ADIJake 0:85855ecd3257 55 PinName datareadyPin)
ADIJake 0:85855ecd3257 56 : _reset(resetPin),
Vkadaba 5:0728bde67bdb 57 _alertError(alertErrorPin),
ADIJake 0:85855ecd3257 58 _dataready(datareadyPin),
Vkadaba 5:0728bde67bdb 59 _alertErrorIrq(alertErrorPin),
ADIJake 0:85855ecd3257 60 _datareadyIrq(datareadyPin) {}
ADIJake 0:85855ecd3257 61
Vkadaba 5:0728bde67bdb 62 ADMW_RESULT get(
Vkadaba 5:0728bde67bdb 63 ADMW_GPIO_PIN ePinId,
ADIJake 0:85855ecd3257 64 bool *pState);
ADIJake 0:85855ecd3257 65
Vkadaba 5:0728bde67bdb 66 ADMW_RESULT set(
Vkadaba 5:0728bde67bdb 67 ADMW_GPIO_PIN ePinId,
ADIJake 0:85855ecd3257 68 bool state);
ADIJake 0:85855ecd3257 69
Vkadaba 5:0728bde67bdb 70 ADMW_RESULT enableIrq(
Vkadaba 5:0728bde67bdb 71 ADMW_GPIO_PIN ePinId,
Vkadaba 5:0728bde67bdb 72 ADMW_GPIO_CALLBACK callbackFn,
ADIJake 0:85855ecd3257 73 void *pArg);
ADIJake 0:85855ecd3257 74
Vkadaba 5:0728bde67bdb 75 ADMW_RESULT disableIrq(
Vkadaba 5:0728bde67bdb 76 ADMW_GPIO_PIN ePinId);
ADIJake 0:85855ecd3257 77
ADIJake 0:85855ecd3257 78 private:
ADIJake 0:85855ecd3257 79 DigitalOut _reset;
ADIJake 0:85855ecd3257 80
Vkadaba 5:0728bde67bdb 81 DigitalIn _alertError;
ADIJake 0:85855ecd3257 82 DigitalIn _dataready;
ADIJake 0:85855ecd3257 83
Vkadaba 5:0728bde67bdb 84 InterruptIn _alertErrorIrq;
ADIJake 0:85855ecd3257 85 InterruptIn _datareadyIrq;
ADIJake 0:85855ecd3257 86
Vkadaba 5:0728bde67bdb 87 ADMW_GPIO_CALLBACK _alertErrorIrqCallback;
Vkadaba 5:0728bde67bdb 88 ADMW_GPIO_CALLBACK _datareadyIrqCallback;
ADIJake 0:85855ecd3257 89
Vkadaba 5:0728bde67bdb 90 void *_alertErrorIrqArg;
ADIJake 0:85855ecd3257 91 void *_datareadyIrqArg;
ADIJake 0:85855ecd3257 92
Vkadaba 5:0728bde67bdb 93 void _alertErrorIrqHandler()
ADIJake 0:85855ecd3257 94 {
Vkadaba 5:0728bde67bdb 95 _alertErrorIrqCallback(ADMW_GPIO_PIN_ALERT_ERROR, _alertErrorIrqArg);
ADIJake 0:85855ecd3257 96 }
ADIJake 0:85855ecd3257 97 void _datareadyIrqHandler()
ADIJake 0:85855ecd3257 98 {
Vkadaba 5:0728bde67bdb 99 _datareadyIrqCallback(ADMW_GPIO_PIN_DATAREADY, _datareadyIrqArg);
ADIJake 0:85855ecd3257 100 }
ADIJake 0:85855ecd3257 101 };
ADIJake 0:85855ecd3257 102
Vkadaba 5:0728bde67bdb 103 ADMW_RESULT GpioContext::get(
Vkadaba 5:0728bde67bdb 104 ADMW_GPIO_PIN ePinId,
ADIJake 0:85855ecd3257 105 bool *pState)
ADIJake 0:85855ecd3257 106 {
ADIJake 0:85855ecd3257 107 switch(ePinId)
ADIJake 0:85855ecd3257 108 {
Vkadaba 5:0728bde67bdb 109 case ADMW_GPIO_PIN_ALERT_ERROR:
Vkadaba 5:0728bde67bdb 110 *pState = _alertError;
Vkadaba 5:0728bde67bdb 111 return ADMW_SUCCESS;
Vkadaba 5:0728bde67bdb 112 case ADMW_GPIO_PIN_DATAREADY:
ADIJake 0:85855ecd3257 113 *pState = _dataready;
Vkadaba 5:0728bde67bdb 114 return ADMW_SUCCESS;
Vkadaba 5:0728bde67bdb 115 case ADMW_GPIO_PIN_RESET:
ADIJake 0:85855ecd3257 116 *pState = _reset;
Vkadaba 5:0728bde67bdb 117 return ADMW_SUCCESS;
ADIJake 0:85855ecd3257 118 default:
Vkadaba 5:0728bde67bdb 119 return ADMW_INVALID_DEVICE_NUM;
ADIJake 0:85855ecd3257 120 }
ADIJake 0:85855ecd3257 121 }
ADIJake 0:85855ecd3257 122
Vkadaba 5:0728bde67bdb 123 ADMW_RESULT GpioContext::set(
Vkadaba 5:0728bde67bdb 124 ADMW_GPIO_PIN ePinId,
ADIJake 0:85855ecd3257 125 bool state)
ADIJake 0:85855ecd3257 126 {
ADIJake 0:85855ecd3257 127 switch(ePinId)
ADIJake 0:85855ecd3257 128 {
Vkadaba 5:0728bde67bdb 129 case ADMW_GPIO_PIN_RESET:
ADIJake 0:85855ecd3257 130 _reset = state;
ADIJake 0:85855ecd3257 131 break;
ADIJake 0:85855ecd3257 132 default:
Vkadaba 5:0728bde67bdb 133 return ADMW_INVALID_DEVICE_NUM;
ADIJake 0:85855ecd3257 134 }
ADIJake 0:85855ecd3257 135
Vkadaba 5:0728bde67bdb 136 return ADMW_SUCCESS;
ADIJake 0:85855ecd3257 137 }
ADIJake 0:85855ecd3257 138
Vkadaba 5:0728bde67bdb 139 ADMW_RESULT GpioContext::enableIrq(
Vkadaba 5:0728bde67bdb 140 ADMW_GPIO_PIN ePinId,
Vkadaba 5:0728bde67bdb 141 ADMW_GPIO_CALLBACK callbackFn,
ADIJake 0:85855ecd3257 142 void *pArg)
ADIJake 0:85855ecd3257 143 {
ADIJake 0:85855ecd3257 144 switch(ePinId)
ADIJake 0:85855ecd3257 145 {
Vkadaba 5:0728bde67bdb 146 case ADMW_GPIO_PIN_ALERT_ERROR:
Vkadaba 5:0728bde67bdb 147 _alertErrorIrqCallback = callbackFn;
Vkadaba 5:0728bde67bdb 148 _alertErrorIrqArg = pArg;
Vkadaba 5:0728bde67bdb 149 _alertErrorIrq.rise(callback(this, &GpioContext::_alertErrorIrqHandler));
Vkadaba 5:0728bde67bdb 150 return ADMW_SUCCESS;
Vkadaba 5:0728bde67bdb 151 case ADMW_GPIO_PIN_DATAREADY:
ADIJake 0:85855ecd3257 152 _datareadyIrqCallback = callbackFn;
ADIJake 0:85855ecd3257 153 _datareadyIrqArg = pArg;
ADIJake 0:85855ecd3257 154 _datareadyIrq.rise(callback(this, &GpioContext::_datareadyIrqHandler));
Vkadaba 5:0728bde67bdb 155 return ADMW_SUCCESS;
ADIJake 0:85855ecd3257 156 default:
Vkadaba 5:0728bde67bdb 157 return ADMW_INVALID_DEVICE_NUM;
ADIJake 0:85855ecd3257 158 }
ADIJake 0:85855ecd3257 159 }
ADIJake 0:85855ecd3257 160
Vkadaba 5:0728bde67bdb 161 ADMW_RESULT GpioContext::disableIrq(
Vkadaba 5:0728bde67bdb 162 ADMW_GPIO_PIN ePinId)
ADIJake 0:85855ecd3257 163 {
ADIJake 0:85855ecd3257 164 switch(ePinId)
ADIJake 0:85855ecd3257 165 {
Vkadaba 5:0728bde67bdb 166 case ADMW_GPIO_PIN_ALERT_ERROR:
Vkadaba 5:0728bde67bdb 167 _alertErrorIrq.rise(NULL);
Vkadaba 5:0728bde67bdb 168 return ADMW_SUCCESS;
Vkadaba 5:0728bde67bdb 169 case ADMW_GPIO_PIN_DATAREADY:
ADIJake 0:85855ecd3257 170 _datareadyIrq.rise(NULL);
Vkadaba 5:0728bde67bdb 171 return ADMW_SUCCESS;
ADIJake 0:85855ecd3257 172 default:
Vkadaba 5:0728bde67bdb 173 return ADMW_INVALID_DEVICE_NUM;
ADIJake 0:85855ecd3257 174 }
ADIJake 0:85855ecd3257 175 }
ADIJake 0:85855ecd3257 176
ADIJake 0:85855ecd3257 177 #ifdef __cplusplus
ADIJake 0:85855ecd3257 178 extern "C" {
ADIJake 0:85855ecd3257 179 #endif
ADIJake 0:85855ecd3257 180
ADIJake 0:85855ecd3257 181 /*
ADIJake 0:85855ecd3257 182 * Open the GPIO interface and allocate resources
ADIJake 0:85855ecd3257 183 */
Vkadaba 5:0728bde67bdb 184 ADMW_RESULT admw_GpioOpen(
Vkadaba 5:0728bde67bdb 185 ADMW_PLATFORM_GPIO_CONFIG *pConfig,
Vkadaba 5:0728bde67bdb 186 ADMW_GPIO_HANDLE *phDevice)
ADIJake 0:85855ecd3257 187 {
ADIJake 0:85855ecd3257 188 GpioContext *pCtx = new GpioContext((PinName)pConfig->resetPin,
Vkadaba 5:0728bde67bdb 189 (PinName)pConfig->alertErrorPin,
ADIJake 0:85855ecd3257 190 (PinName)pConfig->datareadyPin);
ADIJake 0:85855ecd3257 191 if (!pCtx)
ADIJake 0:85855ecd3257 192 {
Vkadaba 5:0728bde67bdb 193 ADMW_LOG_ERROR("Failed to allocate memory for GPIO context");
Vkadaba 5:0728bde67bdb 194 return ADMW_NO_MEM;
ADIJake 0:85855ecd3257 195 }
ADIJake 0:85855ecd3257 196
Vkadaba 5:0728bde67bdb 197 *phDevice = reinterpret_cast<ADMW_GPIO_HANDLE>(pCtx);
Vkadaba 5:0728bde67bdb 198 return ADMW_SUCCESS;
ADIJake 0:85855ecd3257 199 }
ADIJake 0:85855ecd3257 200
ADIJake 0:85855ecd3257 201 /*
ADIJake 0:85855ecd3257 202 * Get the state of the specified GPIO pin
ADIJake 0:85855ecd3257 203 */
Vkadaba 5:0728bde67bdb 204 ADMW_RESULT admw_GpioGet(
Vkadaba 5:0728bde67bdb 205 ADMW_GPIO_HANDLE hDevice,
Vkadaba 5:0728bde67bdb 206 ADMW_GPIO_PIN ePinId,
ADIJake 0:85855ecd3257 207 bool *pbState)
ADIJake 0:85855ecd3257 208 {
ADIJake 0:85855ecd3257 209 GpioContext *pCtx = reinterpret_cast<GpioContext *>(hDevice);
ADIJake 0:85855ecd3257 210
ADIJake 0:85855ecd3257 211 return pCtx->get(ePinId, pbState);
ADIJake 0:85855ecd3257 212 }
ADIJake 0:85855ecd3257 213
ADIJake 0:85855ecd3257 214 /*
ADIJake 0:85855ecd3257 215 * Set the state of the specified GPIO pin
ADIJake 0:85855ecd3257 216 */
Vkadaba 5:0728bde67bdb 217 ADMW_RESULT admw_GpioSet(
Vkadaba 5:0728bde67bdb 218 ADMW_GPIO_HANDLE hDevice,
Vkadaba 5:0728bde67bdb 219 ADMW_GPIO_PIN ePinId,
ADIJake 0:85855ecd3257 220 bool bState)
ADIJake 0:85855ecd3257 221 {
ADIJake 0:85855ecd3257 222 GpioContext *pCtx = reinterpret_cast<GpioContext *>(hDevice);
ADIJake 0:85855ecd3257 223
ADIJake 0:85855ecd3257 224 return pCtx->set(ePinId, bState);
ADIJake 0:85855ecd3257 225 }
ADIJake 0:85855ecd3257 226
ADIJake 0:85855ecd3257 227 /*
ADIJake 0:85855ecd3257 228 * Enable interrupt notifications on the specified GPIO pin
ADIJake 0:85855ecd3257 229 */
Vkadaba 5:0728bde67bdb 230 ADMW_RESULT admw_GpioIrqEnable(
Vkadaba 5:0728bde67bdb 231 ADMW_GPIO_HANDLE hDevice,
Vkadaba 5:0728bde67bdb 232 ADMW_GPIO_PIN ePinId,
Vkadaba 5:0728bde67bdb 233 ADMW_GPIO_CALLBACK callback,
ADIJake 0:85855ecd3257 234 void *arg)
ADIJake 0:85855ecd3257 235 {
ADIJake 0:85855ecd3257 236 GpioContext *pCtx = reinterpret_cast<GpioContext *>(hDevice);
ADIJake 0:85855ecd3257 237
ADIJake 0:85855ecd3257 238 return pCtx->enableIrq(ePinId, callback, arg);
ADIJake 0:85855ecd3257 239 }
ADIJake 0:85855ecd3257 240
ADIJake 0:85855ecd3257 241 /*
ADIJake 0:85855ecd3257 242 * Disable interrupt notifications on the specified GPIO pin
ADIJake 0:85855ecd3257 243 */
Vkadaba 5:0728bde67bdb 244 ADMW_RESULT admw_GpioIrqDisable(
Vkadaba 5:0728bde67bdb 245 ADMW_GPIO_HANDLE hDevice,
Vkadaba 5:0728bde67bdb 246 ADMW_GPIO_PIN ePinId)
ADIJake 0:85855ecd3257 247 {
ADIJake 0:85855ecd3257 248 GpioContext *pCtx = reinterpret_cast<GpioContext *>(hDevice);
ADIJake 0:85855ecd3257 249
ADIJake 0:85855ecd3257 250 return pCtx->disableIrq(ePinId);
ADIJake 0:85855ecd3257 251 }
ADIJake 0:85855ecd3257 252
ADIJake 0:85855ecd3257 253 /*
ADIJake 0:85855ecd3257 254 * Close the GPIO interface and free resources
ADIJake 0:85855ecd3257 255 */
Vkadaba 5:0728bde67bdb 256 void admw_GpioClose(
Vkadaba 5:0728bde67bdb 257 ADMW_GPIO_HANDLE hDevice)
ADIJake 0:85855ecd3257 258 {
ADIJake 0:85855ecd3257 259 GpioContext *pCtx = reinterpret_cast<GpioContext *>(hDevice);
ADIJake 0:85855ecd3257 260
ADIJake 0:85855ecd3257 261 delete pCtx;
ADIJake 0:85855ecd3257 262 }
ADIJake 0:85855ecd3257 263
ADIJake 0:85855ecd3257 264 #ifdef __cplusplus
ADIJake 0:85855ecd3257 265 }
ADIJake 0:85855ecd3257 266 #endif