Example Code to get you up and running with ADISense1000

Fork of ADISense_ExampleFirmware by Sean Wilson

Committer:
seanwilson10
Date:
Thu Jan 25 16:00:23 2018 +0000
Revision:
0:76fed7dd9235
initial;

Who changed what in which revision?

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