ADISense1000 Version 2.1 code base

Fork of AdiSense1000_V21 by Sean Wilson

Committer:
danodonovan
Date:
Mon Jan 22 17:40:50 2018 +0000
Revision:
24:5a2272a25ff1
Updating example to adisense1000 v1.0.1

Who changed what in which revision?

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