Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
inc/adi_sense_gpio.h@0:85855ecd3257, 2019-04-01 (annotated)
- Committer:
- ADIJake
- Date:
- Mon Apr 01 11:09:52 2019 +0000
- Revision:
- 0:85855ecd3257
Initial Commit
Who changed what in which revision?
| User | Revision | Line number | New 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 | * @file: adi_sense_gpio.h |
| ADIJake | 0:85855ecd3257 | 39 | * @brief: ADISENSE OS-dependent wrapper layer for GPIO interface |
| ADIJake | 0:85855ecd3257 | 40 | *----------------------------------------------------------------------------- |
| ADIJake | 0:85855ecd3257 | 41 | */ |
| ADIJake | 0:85855ecd3257 | 42 | |
| ADIJake | 0:85855ecd3257 | 43 | #ifndef __ADI_SENSE_GPIO_H__ |
| ADIJake | 0:85855ecd3257 | 44 | #define __ADI_SENSE_GPIO_H__ |
| ADIJake | 0:85855ecd3257 | 45 | |
| ADIJake | 0:85855ecd3257 | 46 | #include "inc/adi_sense_types.h" |
| ADIJake | 0:85855ecd3257 | 47 | #include "inc/adi_sense_platform.h" |
| ADIJake | 0:85855ecd3257 | 48 | |
| ADIJake | 0:85855ecd3257 | 49 | /*! @ingroup ADISENSE_Host */ |
| ADIJake | 0:85855ecd3257 | 50 | |
| ADIJake | 0:85855ecd3257 | 51 | /*! @addtogroup ADISENSE_Gpio ADISENSE Host GPIO interface functions |
| ADIJake | 0:85855ecd3257 | 52 | * @{ |
| ADIJake | 0:85855ecd3257 | 53 | */ |
| ADIJake | 0:85855ecd3257 | 54 | |
| ADIJake | 0:85855ecd3257 | 55 | /*! GPIO pin identifiers */ |
| ADIJake | 0:85855ecd3257 | 56 | typedef enum |
| ADIJake | 0:85855ecd3257 | 57 | { |
| ADIJake | 0:85855ecd3257 | 58 | ADI_SENSE_GPIO_PIN_RESET = 0, /*!< RESET GPIO output signal */ |
| ADIJake | 0:85855ecd3257 | 59 | ADI_SENSE_GPIO_PIN_ERROR, /*!< ERROR GPIO input signal */ |
| ADIJake | 0:85855ecd3257 | 60 | ADI_SENSE_GPIO_PIN_ALERT, /*!< ALERT GPIO input signal */ |
| ADIJake | 0:85855ecd3257 | 61 | ADI_SENSE_GPIO_PIN_DATAREADY, /*!< DATAREADY GPIO input signal */ |
| ADIJake | 0:85855ecd3257 | 62 | } ADI_SENSE_GPIO_PIN; |
| ADIJake | 0:85855ecd3257 | 63 | |
| ADIJake | 0:85855ecd3257 | 64 | /*! |
| ADIJake | 0:85855ecd3257 | 65 | * GPIO callback function signature |
| ADIJake | 0:85855ecd3257 | 66 | * |
| ADIJake | 0:85855ecd3257 | 67 | * @param[in] ePinId The GPIO pin which triggered the interrupt notification |
| ADIJake | 0:85855ecd3257 | 68 | * @param[in] pArg Optional opaque parameter to be passed to the callback |
| ADIJake | 0:85855ecd3257 | 69 | */ |
| ADIJake | 0:85855ecd3257 | 70 | typedef void (*ADI_SENSE_GPIO_CALLBACK)( |
| ADIJake | 0:85855ecd3257 | 71 | ADI_SENSE_GPIO_PIN ePinId, |
| ADIJake | 0:85855ecd3257 | 72 | void * pArg); |
| ADIJake | 0:85855ecd3257 | 73 | |
| ADIJake | 0:85855ecd3257 | 74 | /*! A handle used in all API functions to identify the GPIO interface context */ |
| ADIJake | 0:85855ecd3257 | 75 | typedef void* ADI_SENSE_GPIO_HANDLE; |
| ADIJake | 0:85855ecd3257 | 76 | |
| ADIJake | 0:85855ecd3257 | 77 | #ifdef __cplusplus |
| ADIJake | 0:85855ecd3257 | 78 | extern "C" |
| ADIJake | 0:85855ecd3257 | 79 | { |
| ADIJake | 0:85855ecd3257 | 80 | #endif |
| ADIJake | 0:85855ecd3257 | 81 | |
| ADIJake | 0:85855ecd3257 | 82 | /*! |
| ADIJake | 0:85855ecd3257 | 83 | * @brief Open the SPI interface and allocate resources |
| ADIJake | 0:85855ecd3257 | 84 | * |
| ADIJake | 0:85855ecd3257 | 85 | * @param[in] pConfig Pointer to platform-specific GPIO interface details |
| ADIJake | 0:85855ecd3257 | 86 | * @param[out] phDevice Pointer to return a GPIO interface context handle |
| ADIJake | 0:85855ecd3257 | 87 | * |
| ADIJake | 0:85855ecd3257 | 88 | * @return Status |
| ADIJake | 0:85855ecd3257 | 89 | * - #ADI_SENSE_SUCCESS Call completed successfully |
| ADIJake | 0:85855ecd3257 | 90 | * - #ADI_SENSE_NO_MEM Failed to allocate memory for interface context |
| ADIJake | 0:85855ecd3257 | 91 | */ |
| ADIJake | 0:85855ecd3257 | 92 | ADI_SENSE_RESULT adi_sense_GpioOpen( |
| ADIJake | 0:85855ecd3257 | 93 | ADI_SENSE_PLATFORM_GPIO_CONFIG * pConfig, |
| ADIJake | 0:85855ecd3257 | 94 | ADI_SENSE_GPIO_HANDLE * phDevice); |
| ADIJake | 0:85855ecd3257 | 95 | |
| ADIJake | 0:85855ecd3257 | 96 | /*! |
| ADIJake | 0:85855ecd3257 | 97 | * @brief Close GPIO interface and free resources |
| ADIJake | 0:85855ecd3257 | 98 | * |
| ADIJake | 0:85855ecd3257 | 99 | * @param[in] hDevice GPIO interface context handle (@ref adi_sense_GpioOpen) |
| ADIJake | 0:85855ecd3257 | 100 | */ |
| ADIJake | 0:85855ecd3257 | 101 | void adi_sense_GpioClose( |
| ADIJake | 0:85855ecd3257 | 102 | ADI_SENSE_GPIO_HANDLE hDevice); |
| ADIJake | 0:85855ecd3257 | 103 | |
| ADIJake | 0:85855ecd3257 | 104 | /*! |
| ADIJake | 0:85855ecd3257 | 105 | * @brief Get the state of the specified GPIO pin |
| ADIJake | 0:85855ecd3257 | 106 | * |
| ADIJake | 0:85855ecd3257 | 107 | * @param[in] hDevice GPIO interface context handle (@ref adi_sense_GpioOpen) |
| ADIJake | 0:85855ecd3257 | 108 | * @param[in] ePinId GPIO pin to be read |
| ADIJake | 0:85855ecd3257 | 109 | * @param[out] pbState Pointer to return the state of the GPIO pin |
| ADIJake | 0:85855ecd3257 | 110 | * |
| ADIJake | 0:85855ecd3257 | 111 | * @return Status |
| ADIJake | 0:85855ecd3257 | 112 | * - #ADI_SENSE_SUCCESS Call completed successfully |
| ADIJake | 0:85855ecd3257 | 113 | * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid GPIO pin specified |
| ADIJake | 0:85855ecd3257 | 114 | */ |
| ADIJake | 0:85855ecd3257 | 115 | ADI_SENSE_RESULT adi_sense_GpioGet( |
| ADIJake | 0:85855ecd3257 | 116 | ADI_SENSE_GPIO_HANDLE hDevice, |
| ADIJake | 0:85855ecd3257 | 117 | ADI_SENSE_GPIO_PIN ePinId, |
| ADIJake | 0:85855ecd3257 | 118 | bool * pbState); |
| ADIJake | 0:85855ecd3257 | 119 | |
| ADIJake | 0:85855ecd3257 | 120 | /*! |
| ADIJake | 0:85855ecd3257 | 121 | * @brief Set the state of the specified GPIO pin |
| ADIJake | 0:85855ecd3257 | 122 | * |
| ADIJake | 0:85855ecd3257 | 123 | * @param[in] hDevice GPIO interface context handle (@ref adi_sense_GpioOpen) |
| ADIJake | 0:85855ecd3257 | 124 | * @param[in] ePinId GPIO pin to be set |
| ADIJake | 0:85855ecd3257 | 125 | * @param[in] bState The state to set for GPIO pin |
| ADIJake | 0:85855ecd3257 | 126 | * |
| ADIJake | 0:85855ecd3257 | 127 | * @return Status |
| ADIJake | 0:85855ecd3257 | 128 | * - #ADI_SENSE_SUCCESS Call completed successfully |
| ADIJake | 0:85855ecd3257 | 129 | * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid GPIO pin specified |
| ADIJake | 0:85855ecd3257 | 130 | */ |
| ADIJake | 0:85855ecd3257 | 131 | ADI_SENSE_RESULT adi_sense_GpioSet( |
| ADIJake | 0:85855ecd3257 | 132 | ADI_SENSE_GPIO_HANDLE hDevice, |
| ADIJake | 0:85855ecd3257 | 133 | ADI_SENSE_GPIO_PIN ePinId, |
| ADIJake | 0:85855ecd3257 | 134 | bool bState); |
| ADIJake | 0:85855ecd3257 | 135 | |
| ADIJake | 0:85855ecd3257 | 136 | /*! |
| ADIJake | 0:85855ecd3257 | 137 | * @brief Enable interrupt notifications on the specified GPIO pin |
| ADIJake | 0:85855ecd3257 | 138 | * |
| ADIJake | 0:85855ecd3257 | 139 | * @param[in] hDevice GPIO interface context handle (@ref adi_sense_GpioOpen) |
| ADIJake | 0:85855ecd3257 | 140 | * @param[in] ePinId GPIO pin on which to enable interrupt notifications |
| ADIJake | 0:85855ecd3257 | 141 | * @param[in] callback Callback function to invoke when the GPIO is asserted |
| ADIJake | 0:85855ecd3257 | 142 | * @param[in] arg Optional opaque parameter to be passed to the callback |
| ADIJake | 0:85855ecd3257 | 143 | * |
| ADIJake | 0:85855ecd3257 | 144 | * @return Status |
| ADIJake | 0:85855ecd3257 | 145 | * - #ADI_SENSE_SUCCESS Call completed successfully |
| ADIJake | 0:85855ecd3257 | 146 | * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid GPIO pin specified |
| ADIJake | 0:85855ecd3257 | 147 | */ |
| ADIJake | 0:85855ecd3257 | 148 | ADI_SENSE_RESULT adi_sense_GpioIrqEnable( |
| ADIJake | 0:85855ecd3257 | 149 | ADI_SENSE_GPIO_HANDLE hDevice, |
| ADIJake | 0:85855ecd3257 | 150 | ADI_SENSE_GPIO_PIN ePinId, |
| ADIJake | 0:85855ecd3257 | 151 | ADI_SENSE_GPIO_CALLBACK callback, |
| ADIJake | 0:85855ecd3257 | 152 | void * arg); |
| ADIJake | 0:85855ecd3257 | 153 | |
| ADIJake | 0:85855ecd3257 | 154 | /*! |
| ADIJake | 0:85855ecd3257 | 155 | * @brief Disable interrupt notifications on the specified GPIO pin |
| ADIJake | 0:85855ecd3257 | 156 | * |
| ADIJake | 0:85855ecd3257 | 157 | * @param[in] hDevice GPIO interface context handle (@ref adi_sense_GpioOpen) |
| ADIJake | 0:85855ecd3257 | 158 | * @param[in] ePinId GPIO pin on which to disable interrupt notifications |
| ADIJake | 0:85855ecd3257 | 159 | * |
| ADIJake | 0:85855ecd3257 | 160 | * @return Status |
| ADIJake | 0:85855ecd3257 | 161 | * - #ADI_SENSE_SUCCESS Call completed successfully |
| ADIJake | 0:85855ecd3257 | 162 | * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid GPIO pin specified |
| ADIJake | 0:85855ecd3257 | 163 | */ |
| ADIJake | 0:85855ecd3257 | 164 | ADI_SENSE_RESULT adi_sense_GpioIrqDisable( |
| ADIJake | 0:85855ecd3257 | 165 | ADI_SENSE_GPIO_HANDLE hDevice, |
| ADIJake | 0:85855ecd3257 | 166 | ADI_SENSE_GPIO_PIN ePinId); |
| ADIJake | 0:85855ecd3257 | 167 | |
| ADIJake | 0:85855ecd3257 | 168 | #ifdef __cplusplus |
| ADIJake | 0:85855ecd3257 | 169 | } |
| ADIJake | 0:85855ecd3257 | 170 | #endif |
| ADIJake | 0:85855ecd3257 | 171 | |
| ADIJake | 0:85855ecd3257 | 172 | /*! |
| ADIJake | 0:85855ecd3257 | 173 | * @} |
| ADIJake | 0:85855ecd3257 | 174 | */ |
| ADIJake | 0:85855ecd3257 | 175 | |
| ADIJake | 0:85855ecd3257 | 176 | #endif /* __ADI_SENSE_GPIO_H__ */ |
| ADIJake | 0:85855ecd3257 | 177 |