IIO Application Library

Dependents:  

Committer:
mahphalke
Date:
Mon Oct 05 12:28:13 2020 +0530
Revision:
1:182a6f54cab0
IIO application library- Initial Revision

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mahphalke 1:182a6f54cab0 1 /***************************************************************************//**
mahphalke 1:182a6f54cab0 2 * @file iio_types.h
mahphalke 1:182a6f54cab0 3 * @brief Header file for iio_types
mahphalke 1:182a6f54cab0 4 * @author Cristian Pop (cristian.pop@analog.com)
mahphalke 1:182a6f54cab0 5 ********************************************************************************
mahphalke 1:182a6f54cab0 6 * Copyright 2013, 2020(c) Analog Devices, Inc.
mahphalke 1:182a6f54cab0 7 *
mahphalke 1:182a6f54cab0 8 * All rights reserved.
mahphalke 1:182a6f54cab0 9 *
mahphalke 1:182a6f54cab0 10 * Redistribution and use in source and binary forms, with or without
mahphalke 1:182a6f54cab0 11 * modification, are permitted provided that the following conditions are met:
mahphalke 1:182a6f54cab0 12 * - Redistributions of source code must retain the above copyright
mahphalke 1:182a6f54cab0 13 * notice, this list of conditions and the following disclaimer.
mahphalke 1:182a6f54cab0 14 * - Redistributions in binary form must reproduce the above copyright
mahphalke 1:182a6f54cab0 15 * notice, this list of conditions and the following disclaimer in
mahphalke 1:182a6f54cab0 16 * the documentation and/or other materials provided with the
mahphalke 1:182a6f54cab0 17 * distribution.
mahphalke 1:182a6f54cab0 18 * - Neither the name of Analog Devices, Inc. nor the names of its
mahphalke 1:182a6f54cab0 19 * contributors may be used to endorse or promote products derived
mahphalke 1:182a6f54cab0 20 * from this software without specific prior written permission.
mahphalke 1:182a6f54cab0 21 * - The use of this software may or may not infringe the patent rights
mahphalke 1:182a6f54cab0 22 * of one or more patent holders. This license does not release you
mahphalke 1:182a6f54cab0 23 * from the requirement that you obtain separate licenses from these
mahphalke 1:182a6f54cab0 24 * patent holders to use this software.
mahphalke 1:182a6f54cab0 25 * - Use of the software either in source or binary form, must be run
mahphalke 1:182a6f54cab0 26 * on or directly connected to an Analog Devices Inc. component.
mahphalke 1:182a6f54cab0 27 *
mahphalke 1:182a6f54cab0 28 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
mahphalke 1:182a6f54cab0 29 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
mahphalke 1:182a6f54cab0 30 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
mahphalke 1:182a6f54cab0 31 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
mahphalke 1:182a6f54cab0 32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
mahphalke 1:182a6f54cab0 33 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
mahphalke 1:182a6f54cab0 34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mahphalke 1:182a6f54cab0 35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mahphalke 1:182a6f54cab0 36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mahphalke 1:182a6f54cab0 37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mahphalke 1:182a6f54cab0 38 *******************************************************************************/
mahphalke 1:182a6f54cab0 39 #ifndef IIO_TYPES_H_
mahphalke 1:182a6f54cab0 40 #define IIO_TYPES_H_
mahphalke 1:182a6f54cab0 41
mahphalke 1:182a6f54cab0 42 /******************************************************************************/
mahphalke 1:182a6f54cab0 43 /***************************** Include Files **********************************/
mahphalke 1:182a6f54cab0 44 /******************************************************************************/
mahphalke 1:182a6f54cab0 45
mahphalke 1:182a6f54cab0 46 #include <stdbool.h>
mahphalke 1:182a6f54cab0 47 #include <stdint.h>
mahphalke 1:182a6f54cab0 48
mahphalke 1:182a6f54cab0 49 /******************************************************************************/
mahphalke 1:182a6f54cab0 50 /*************************** Types Declarations *******************************/
mahphalke 1:182a6f54cab0 51 /******************************************************************************/
mahphalke 1:182a6f54cab0 52
mahphalke 1:182a6f54cab0 53 /**
mahphalke 1:182a6f54cab0 54 * @struct iio_ch_info
mahphalke 1:182a6f54cab0 55 * @brief Structure holding channel attributess.
mahphalke 1:182a6f54cab0 56 */
mahphalke 1:182a6f54cab0 57 struct iio_ch_info {
mahphalke 1:182a6f54cab0 58 /** Channel number */
mahphalke 1:182a6f54cab0 59 int16_t ch_num;
mahphalke 1:182a6f54cab0 60 /** Channel type: input/output */
mahphalke 1:182a6f54cab0 61 bool ch_out;
mahphalke 1:182a6f54cab0 62 };
mahphalke 1:182a6f54cab0 63
mahphalke 1:182a6f54cab0 64 /**
mahphalke 1:182a6f54cab0 65 * @struct iio_attribute
mahphalke 1:182a6f54cab0 66 * @brief Structure holding pointers to show and store functions.
mahphalke 1:182a6f54cab0 67 */
mahphalke 1:182a6f54cab0 68 struct iio_attribute {
mahphalke 1:182a6f54cab0 69 /** Attribute name */
mahphalke 1:182a6f54cab0 70 const char *name;
mahphalke 1:182a6f54cab0 71 /** Show function pointer */
mahphalke 1:182a6f54cab0 72 ssize_t (*show)(void *device, char *buf, size_t len,
mahphalke 1:182a6f54cab0 73 const struct iio_ch_info *channel);
mahphalke 1:182a6f54cab0 74 /** Store function pointer */
mahphalke 1:182a6f54cab0 75 ssize_t (*store)(void *device, char *buf, size_t len,
mahphalke 1:182a6f54cab0 76 const struct iio_ch_info *channel);
mahphalke 1:182a6f54cab0 77 };
mahphalke 1:182a6f54cab0 78
mahphalke 1:182a6f54cab0 79 /**
mahphalke 1:182a6f54cab0 80 * @struct iio_channel
mahphalke 1:182a6f54cab0 81 * @brief Structure holding attributes of a channel.
mahphalke 1:182a6f54cab0 82 */
mahphalke 1:182a6f54cab0 83 struct iio_channel {
mahphalke 1:182a6f54cab0 84 /** channel name */
mahphalke 1:182a6f54cab0 85 char *name;
mahphalke 1:182a6f54cab0 86 /** list of attributes */
mahphalke 1:182a6f54cab0 87 struct iio_attribute **attributes;
mahphalke 1:182a6f54cab0 88 /** if true, the channel is an output channel */
mahphalke 1:182a6f54cab0 89 bool ch_out;
mahphalke 1:182a6f54cab0 90 };
mahphalke 1:182a6f54cab0 91
mahphalke 1:182a6f54cab0 92 /**
mahphalke 1:182a6f54cab0 93 * @struct iio_device
mahphalke 1:182a6f54cab0 94 * @brief Structure holding channels and attributes of a device.
mahphalke 1:182a6f54cab0 95 */
mahphalke 1:182a6f54cab0 96 struct iio_device {
mahphalke 1:182a6f54cab0 97 /** Device name */
mahphalke 1:182a6f54cab0 98 const char *name;
mahphalke 1:182a6f54cab0 99 /** Device number of channels */
mahphalke 1:182a6f54cab0 100 uint16_t num_ch;
mahphalke 1:182a6f54cab0 101 /** List of channels */
mahphalke 1:182a6f54cab0 102 struct iio_channel **channels;
mahphalke 1:182a6f54cab0 103 /** List of attributes */
mahphalke 1:182a6f54cab0 104 struct iio_attribute **attributes;
mahphalke 1:182a6f54cab0 105 };
mahphalke 1:182a6f54cab0 106
mahphalke 1:182a6f54cab0 107 /**
mahphalke 1:182a6f54cab0 108 * @struct iio_server_ops
mahphalke 1:182a6f54cab0 109 * @brief iio interface for server read/write operations
mahphalke 1:182a6f54cab0 110 */
mahphalke 1:182a6f54cab0 111 struct iio_server_ops {
mahphalke 1:182a6f54cab0 112 /** Read from from a peripheral device (UART, USB, NETWORK) */
mahphalke 1:182a6f54cab0 113 ssize_t (*read)(char *buf, size_t len);
mahphalke 1:182a6f54cab0 114 /** Write to a peripheral device (UART, USB, NETWORK) */
mahphalke 1:182a6f54cab0 115 ssize_t (*write)(const char *buf, size_t len);
mahphalke 1:182a6f54cab0 116 };
mahphalke 1:182a6f54cab0 117
mahphalke 1:182a6f54cab0 118 #endif /* IIO_TYPES_H_ */