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