Host API Example for the ADMW1001

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers admw_gpio.h Source File

admw_gpio.h

Go to the documentation of this file.
00001 /*
00002 Copyright 2019 (c) Analog Devices, Inc.
00003 
00004 All rights reserved.
00005 
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are met:
00008   - Redistributions of source code must retain the above copyright
00009     notice, this list of conditions and the following disclaimer.
00010   - Redistributions in binary form must reproduce the above copyright
00011     notice, this list of conditions and the following disclaimer in
00012     the documentation and/or other materials provided with the
00013     distribution.
00014   - Neither the name of Analog Devices, Inc. nor the names of its
00015     contributors may be used to endorse or promote products derived
00016     from this software without specific prior written permission.
00017   - The use of this software may or may not infringe the patent rights
00018     of one or more patent holders. This license does not release you
00019     from the requirement that you obtain separate licenses from these
00020     patent holders to use this software.
00021   - Use of the software either in source or binary form, must be run
00022     on or directly connected to an Analog Devices Inc. component.
00023 
00024 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
00025 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
00026 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00027 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
00028 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00029 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
00030 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00032 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00033 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034 */
00035 
00036 /*!
00037  ******************************************************************************
00038  * @file:   admw_gpio.h
00039  * @brief:  ADMW OS-dependent wrapper layer for GPIO interface
00040  *-----------------------------------------------------------------------------
00041  */
00042 
00043 #ifndef __ADMW_GPIO_H__
00044 #define __ADMW_GPIO_H__
00045 
00046 #include "inc/admw_types.h"
00047 #include "inc/admw_platform.h"
00048 
00049 /*! @ingroup ADMW_Host */
00050 
00051 /*! @addtogroup ADMW_Gpio ADMW Host GPIO interface functions
00052  *  @{
00053  */
00054 
00055 /*! GPIO pin identifiers */
00056 typedef enum
00057 {
00058     ADMW_GPIO_PIN_RESET  = 0, /*!< RESET GPIO output signal */
00059     ADMW_GPIO_PIN_ALERT_ERROR ,     /*!< ALERT GPIO input signal */
00060     ADMW_GPIO_PIN_DATAREADY , /*!< DATAREADY GPIO input signal */
00061 } ADMW_GPIO_PIN ;
00062 
00063 /*!
00064  * GPIO callback function signature
00065  *
00066  * @param[in] ePinId The GPIO pin which triggered the interrupt notification
00067  * @param[in] pArg   Optional opaque parameter to be passed to the callback
00068  */
00069 typedef void (*ADMW_GPIO_CALLBACK )(
00070     ADMW_GPIO_PIN                ePinId,
00071     void                           * pArg);
00072 
00073 /*! A handle used in all API functions to identify the GPIO interface context */
00074 typedef void* ADMW_GPIO_HANDLE ;
00075 
00076 #ifdef __cplusplus
00077 extern "C"
00078 {
00079 #endif
00080 
00081 /*!
00082  * @brief Open the SPI interface and allocate resources
00083  *
00084  * @param[in]  pConfig  Pointer to platform-specific GPIO interface details
00085  * @param[out] phDevice Pointer to return a GPIO interface context handle
00086  *
00087  * @return Status
00088  *         - #ADMW_SUCCESS Call completed successfully
00089  *         - #ADMW_NO_MEM  Failed to allocate memory for interface context
00090  */
00091 ADMW_RESULT  admw_GpioOpen(
00092     ADMW_PLATFORM_GPIO_CONFIG * pConfig,
00093     ADMW_GPIO_HANDLE           * phDevice);
00094 
00095 /*!
00096  * @brief Close GPIO interface and free resources
00097  *
00098  * @param[in] hDevice GPIO interface context handle (@ref admw_GpioOpen)
00099  */
00100 void admw_GpioClose(
00101     ADMW_GPIO_HANDLE             hDevice);
00102 
00103 /*!
00104  * @brief Get the state of the specified GPIO pin
00105  *
00106  * @param[in]  hDevice GPIO interface context handle (@ref admw_GpioOpen)
00107  * @param[in]  ePinId  GPIO pin to be read
00108  * @param[out] pbState Pointer to return the state of the GPIO pin
00109  *
00110  * @return Status
00111  *         - #ADMW_SUCCESS Call completed successfully
00112  *         - #ADMW_INVALID_DEVICE_NUM Invalid GPIO pin specified
00113  */
00114 ADMW_RESULT  admw_GpioGet(
00115     ADMW_GPIO_HANDLE             hDevice,
00116     ADMW_GPIO_PIN                ePinId,
00117     bool                           * pbState);
00118 
00119 /*!
00120  * @brief Set the state of the specified GPIO pin
00121  *
00122  * @param[in] hDevice GPIO interface context handle (@ref admw_GpioOpen)
00123  * @param[in] ePinId  GPIO pin to be set
00124  * @param[in] bState  The state to set for GPIO pin
00125  *
00126  * @return Status
00127  *         - #ADMW_SUCCESS Call completed successfully
00128  *         - #ADMW_INVALID_DEVICE_NUM Invalid GPIO pin specified
00129  */
00130 ADMW_RESULT  admw_GpioSet(
00131     ADMW_GPIO_HANDLE             hDevice,
00132     ADMW_GPIO_PIN                ePinId,
00133     bool                             bState);
00134 
00135 /*!
00136  * @brief Enable interrupt notifications on the specified GPIO pin
00137  *
00138  * @param[in] hDevice  GPIO interface context handle (@ref admw_GpioOpen)
00139  * @param[in] ePinId   GPIO pin on which to enable interrupt notifications
00140  * @param[in] callback Callback function to invoke when the GPIO is asserted
00141  * @param[in] arg      Optional opaque parameter to be passed to the callback
00142  *
00143  * @return Status
00144  *         - #ADMW_SUCCESS Call completed successfully
00145  *         - #ADMW_INVALID_DEVICE_NUM Invalid GPIO pin specified
00146  */
00147 ADMW_RESULT  admw_GpioIrqEnable(
00148     ADMW_GPIO_HANDLE             hDevice,
00149     ADMW_GPIO_PIN                ePinId,
00150     ADMW_GPIO_CALLBACK           callback,
00151     void                           * arg);
00152 
00153 /*!
00154  * @brief Disable interrupt notifications on the specified GPIO pin
00155  *
00156  * @param[in] hDevice  GPIO interface context handle (@ref admw_GpioOpen)
00157  * @param[in] ePinId   GPIO pin on which to disable interrupt notifications
00158  *
00159  * @return Status
00160  *         - #ADMW_SUCCESS Call completed successfully
00161  *         - #ADMW_INVALID_DEVICE_NUM Invalid GPIO pin specified
00162  */
00163 ADMW_RESULT  admw_GpioIrqDisable(
00164     ADMW_GPIO_HANDLE             hDevice,
00165     ADMW_GPIO_PIN                ePinId);
00166 
00167 #ifdef __cplusplus
00168 }
00169 #endif
00170 
00171 /*!
00172  * @}
00173  */
00174 
00175 #endif /* __ADMW_GPIO_H__ */