ADISense1000 Version 2.1 code base

Fork of AdiSense1000_V21 by Sean Wilson

Committer:
danodonovan
Date:
Mon Mar 26 14:50:05 2018 +0000
Revision:
26:12d0204be712
Child:
27:567abf893938
Adding files missed in previous commit for v1.0.2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
danodonovan 26:12d0204be712 1 /*!
danodonovan 26:12d0204be712 2 ******************************************************************************
danodonovan 26:12d0204be712 3 * @file: adi_sense_spi.h
danodonovan 26:12d0204be712 4 * @brief: ADISENSE OS-dependent wrapper layer for SPI interface
danodonovan 26:12d0204be712 5 *-----------------------------------------------------------------------------
danodonovan 26:12d0204be712 6 */
danodonovan 26:12d0204be712 7
danodonovan 26:12d0204be712 8 /*
danodonovan 26:12d0204be712 9 Copyright 2017 (c) Analog Devices, Inc.
danodonovan 26:12d0204be712 10
danodonovan 26:12d0204be712 11 All rights reserved.
danodonovan 26:12d0204be712 12
danodonovan 26:12d0204be712 13 Redistribution and use in source and binary forms, with or without
danodonovan 26:12d0204be712 14 modification, are permitted provided that the following conditions are met:
danodonovan 26:12d0204be712 15 - Redistributions of source code must retain the above copyright
danodonovan 26:12d0204be712 16 notice, this list of conditions and the following disclaimer.
danodonovan 26:12d0204be712 17 - Redistributions in binary form must reproduce the above copyright
danodonovan 26:12d0204be712 18 notice, this list of conditions and the following disclaimer in
danodonovan 26:12d0204be712 19 the documentation and/or other materials provided with the
danodonovan 26:12d0204be712 20 distribution.
danodonovan 26:12d0204be712 21 - Neither the name of Analog Devices, Inc. nor the names of its
danodonovan 26:12d0204be712 22 contributors may be used to endorse or promote products derived
danodonovan 26:12d0204be712 23 from this software without specific prior written permission.
danodonovan 26:12d0204be712 24 - The use of this software may or may not infringe the patent rights
danodonovan 26:12d0204be712 25 of one or more patent holders. This license does not release you
danodonovan 26:12d0204be712 26 from the requirement that you obtain separate licenses from these
danodonovan 26:12d0204be712 27 patent holders to use this software.
danodonovan 26:12d0204be712 28 - Use of the software either in source or binary form, must be run
danodonovan 26:12d0204be712 29 on or directly connected to an Analog Devices Inc. component.
danodonovan 26:12d0204be712 30
danodonovan 26:12d0204be712 31 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
danodonovan 26:12d0204be712 32 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
danodonovan 26:12d0204be712 33 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
danodonovan 26:12d0204be712 34 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
danodonovan 26:12d0204be712 35 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
danodonovan 26:12d0204be712 36 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
danodonovan 26:12d0204be712 37 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
danodonovan 26:12d0204be712 38 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
danodonovan 26:12d0204be712 39 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
danodonovan 26:12d0204be712 40 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
danodonovan 26:12d0204be712 41 */
danodonovan 26:12d0204be712 42
danodonovan 26:12d0204be712 43 #ifndef __ADI_SENSE_SPI_H__
danodonovan 26:12d0204be712 44 #define __ADI_SENSE_SPI_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_Spi ADISENSE Host SPI interface functions
danodonovan 26:12d0204be712 52 * @{
danodonovan 26:12d0204be712 53 */
danodonovan 26:12d0204be712 54
danodonovan 26:12d0204be712 55 /*! A handle used in all API functions to identify the SPI interface context */
danodonovan 26:12d0204be712 56 typedef void * ADI_SENSE_SPI_HANDLE;
danodonovan 26:12d0204be712 57
danodonovan 26:12d0204be712 58 #ifdef __cplusplus
danodonovan 26:12d0204be712 59 extern "C"
danodonovan 26:12d0204be712 60 {
danodonovan 26:12d0204be712 61 #endif
danodonovan 26:12d0204be712 62
danodonovan 26:12d0204be712 63 /*!
danodonovan 26:12d0204be712 64 * @brief Open the SPI interface and allocate resources
danodonovan 26:12d0204be712 65 *
danodonovan 26:12d0204be712 66 * @param[in] pConfig Pointer to platform-specific SPI interface details
danodonovan 26:12d0204be712 67 * @param[out] phDevice Pointer to return a SPI interface context handle
danodonovan 26:12d0204be712 68 *
danodonovan 26:12d0204be712 69 * @return Status
danodonovan 26:12d0204be712 70 * - #ADI_SENSE_SUCCESS Call completed successfully
danodonovan 26:12d0204be712 71 * - #ADI_SENSE_NO_MEM Failed to allocate memory for interface context
danodonovan 26:12d0204be712 72 */
danodonovan 26:12d0204be712 73 ADI_SENSE_RESULT adi_sense_SpiOpen(
danodonovan 26:12d0204be712 74 ADI_SENSE_PLATFORM_SPI_CONFIG * pConfig,
danodonovan 26:12d0204be712 75 ADI_SENSE_SPI_HANDLE * phDevice);
danodonovan 26:12d0204be712 76
danodonovan 26:12d0204be712 77 /*!
danodonovan 26:12d0204be712 78 * @brief Close SPI interface and free resources
danodonovan 26:12d0204be712 79 *
danodonovan 26:12d0204be712 80 * @param[in] hDevice SPI interface context handle (@ref adi_sense_SpiOpen)
danodonovan 26:12d0204be712 81 */
danodonovan 26:12d0204be712 82 void adi_sense_SpiClose(
danodonovan 26:12d0204be712 83 ADI_SENSE_SPI_HANDLE hDevice);
danodonovan 26:12d0204be712 84
danodonovan 26:12d0204be712 85 /*!
danodonovan 26:12d0204be712 86 * @brief Transfer data to slave device
danodonovan 26:12d0204be712 87 *
danodonovan 26:12d0204be712 88 * @param[in] hDevice SPI interface context handle (@ref adi_sense_SpiOpen)
danodonovan 26:12d0204be712 89 * @param[in] pTxData Transmit data buffer, or NULL for read-only transfers
danodonovan 26:12d0204be712 90 * @param[in] pRxData Receive data buffer, or NULL for write-only transfers
danodonovan 26:12d0204be712 91 * @param[in] nLength Number of bytes to transfer
danodonovan 26:12d0204be712 92 * @param[in] bCsHold Leave the chip-select asserted when the transfer is done
danodonovan 26:12d0204be712 93 *
danodonovan 26:12d0204be712 94 * @return Status
danodonovan 26:12d0204be712 95 * - #ADI_SENSE_SUCCESS Call completed successfully
danodonovan 26:12d0204be712 96 * - #ADI_SENSE_FAILURE Failed to complete SPI transfer
danodonovan 26:12d0204be712 97 */
danodonovan 26:12d0204be712 98 ADI_SENSE_RESULT adi_sense_SpiTransfer(
danodonovan 26:12d0204be712 99 ADI_SENSE_SPI_HANDLE hDevice,
danodonovan 26:12d0204be712 100 void * pTxData,
danodonovan 26:12d0204be712 101 void * pRxData,
danodonovan 26:12d0204be712 102 unsigned nLength,
danodonovan 26:12d0204be712 103 bool bCsHold);
danodonovan 26:12d0204be712 104
danodonovan 26:12d0204be712 105 #ifdef __cplusplus
danodonovan 26:12d0204be712 106 }
danodonovan 26:12d0204be712 107 #endif
danodonovan 26:12d0204be712 108
danodonovan 26:12d0204be712 109 /*!
danodonovan 26:12d0204be712 110 * @}
danodonovan 26:12d0204be712 111 */
danodonovan 26:12d0204be712 112
danodonovan 26:12d0204be712 113 #endif /* __ADI_SENSE_SPI_H__ */
danodonovan 26:12d0204be712 114