this is testing

Committer:
pmallick
Date:
Thu Jan 14 18:54:16 2021 +0530
Revision:
0:3afcd581558d
this is testing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pmallick 0:3afcd581558d 1 /***************************************************************************//**
pmallick 0:3afcd581558d 2 * @file iio_app.c
pmallick 0:3afcd581558d 3 * @brief Implementation of iio_app.
pmallick 0:3afcd581558d 4 * This application instantiates iio_axi_adc and iio_axi_dac devices, for
pmallick 0:3afcd581558d 5 * reading/writing and parameterization.
pmallick 0:3afcd581558d 6 * @author Cristian Pop (cristian.pop@analog.com)
pmallick 0:3afcd581558d 7 ********************************************************************************
pmallick 0:3afcd581558d 8 * Copyright 2019, 2020(c) Analog Devices, Inc.
pmallick 0:3afcd581558d 9 *
pmallick 0:3afcd581558d 10 * All rights reserved.
pmallick 0:3afcd581558d 11 *
pmallick 0:3afcd581558d 12 * Redistribution and use in source and binary forms, with or without
pmallick 0:3afcd581558d 13 * modification, are permitted provided that the following conditions are met:
pmallick 0:3afcd581558d 14 * - Redistributions of source code must retain the above copyright
pmallick 0:3afcd581558d 15 * notice, this list of conditions and the following disclaimer.
pmallick 0:3afcd581558d 16 * - Redistributions in binary form must reproduce the above copyright
pmallick 0:3afcd581558d 17 * notice, this list of conditions and the following disclaimer in
pmallick 0:3afcd581558d 18 * the documentation and/or other materials provided with the
pmallick 0:3afcd581558d 19 * distribution.
pmallick 0:3afcd581558d 20 * - Neither the name of Analog Devices, Inc. nor the names of its
pmallick 0:3afcd581558d 21 * contributors may be used to endorse or promote products derived
pmallick 0:3afcd581558d 22 * from this software without specific prior written permission.
pmallick 0:3afcd581558d 23 * - The use of this software may or may not infringe the patent rights
pmallick 0:3afcd581558d 24 * of one or more patent holders. This license does not release you
pmallick 0:3afcd581558d 25 * from the requirement that you obtain separate licenses from these
pmallick 0:3afcd581558d 26 * patent holders to use this software.
pmallick 0:3afcd581558d 27 * - Use of the software either in source or binary form, must be run
pmallick 0:3afcd581558d 28 * on or directly connected to an Analog Devices Inc. component.
pmallick 0:3afcd581558d 29 *
pmallick 0:3afcd581558d 30 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
pmallick 0:3afcd581558d 31 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
pmallick 0:3afcd581558d 32 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
pmallick 0:3afcd581558d 33 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
pmallick 0:3afcd581558d 34 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
pmallick 0:3afcd581558d 35 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
pmallick 0:3afcd581558d 36 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
pmallick 0:3afcd581558d 37 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
pmallick 0:3afcd581558d 38 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
pmallick 0:3afcd581558d 39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
pmallick 0:3afcd581558d 40 *******************************************************************************/
pmallick 0:3afcd581558d 41
pmallick 0:3afcd581558d 42 /******************************************************************************/
pmallick 0:3afcd581558d 43 /***************************** Include Files **********************************/
pmallick 0:3afcd581558d 44 /******************************************************************************/
pmallick 0:3afcd581558d 45
pmallick 0:3afcd581558d 46 #include "error.h"
pmallick 0:3afcd581558d 47 #include "iio.h"
pmallick 0:3afcd581558d 48 #include "iio_app.h"
pmallick 0:3afcd581558d 49
pmallick 0:3afcd581558d 50 /**
pmallick 0:3afcd581558d 51 * @brief Application parameterization.
pmallick 0:3afcd581558d 52 * @param desc - Application descriptor.
pmallick 0:3afcd581558d 53 * @param param - Application initial configuration structure.
pmallick 0:3afcd581558d 54 * @return SUCCESS in case of success, FAILURE otherwise.
pmallick 0:3afcd581558d 55 */
pmallick 0:3afcd581558d 56 int32_t iio_app_init(struct iio_app_desc **desc,
pmallick 0:3afcd581558d 57 struct iio_app_init_param *param)
pmallick 0:3afcd581558d 58 {
pmallick 0:3afcd581558d 59 struct tinyiiod *iiod;
pmallick 0:3afcd581558d 60 int32_t status;
pmallick 0:3afcd581558d 61
pmallick 0:3afcd581558d 62 if (!param)
pmallick 0:3afcd581558d 63 return FAILURE;
pmallick 0:3afcd581558d 64
pmallick 0:3afcd581558d 65 status = iio_init(&iiod, param->iio_server_ops);
pmallick 0:3afcd581558d 66 if(status < 0)
pmallick 0:3afcd581558d 67 return status;
pmallick 0:3afcd581558d 68
pmallick 0:3afcd581558d 69 *desc = calloc(1, sizeof(struct iio_app_desc));
pmallick 0:3afcd581558d 70 if (!(*desc))
pmallick 0:3afcd581558d 71 return FAILURE;
pmallick 0:3afcd581558d 72
pmallick 0:3afcd581558d 73 (*desc)->iiod = iiod;
pmallick 0:3afcd581558d 74
pmallick 0:3afcd581558d 75 return SUCCESS;
pmallick 0:3afcd581558d 76 }
pmallick 0:3afcd581558d 77
pmallick 0:3afcd581558d 78 /**
pmallick 0:3afcd581558d 79 * @brief Release resources.
pmallick 0:3afcd581558d 80 * @param desc - Application descriptor.
pmallick 0:3afcd581558d 81 * @return SUCCESS in case of success, FAILURE otherwise.
pmallick 0:3afcd581558d 82 */
pmallick 0:3afcd581558d 83 int32_t iio_app_remove(struct iio_app_desc *desc)
pmallick 0:3afcd581558d 84 {
pmallick 0:3afcd581558d 85 int32_t status;
pmallick 0:3afcd581558d 86
pmallick 0:3afcd581558d 87 if (!desc)
pmallick 0:3afcd581558d 88 return FAILURE;
pmallick 0:3afcd581558d 89
pmallick 0:3afcd581558d 90 status = iio_remove(desc->iiod);
pmallick 0:3afcd581558d 91 if(status < 0)
pmallick 0:3afcd581558d 92 return status;
pmallick 0:3afcd581558d 93
pmallick 0:3afcd581558d 94 free(desc);
pmallick 0:3afcd581558d 95
pmallick 0:3afcd581558d 96 return SUCCESS;
pmallick 0:3afcd581558d 97 }
pmallick 0:3afcd581558d 98
pmallick 0:3afcd581558d 99 /**
pmallick 0:3afcd581558d 100 * @brief iio application, reads commands and executes them.
pmallick 0:3afcd581558d 101 * @param desc - Application descriptor.
pmallick 0:3afcd581558d 102 * @return: SUCCESS in case of success, FAILURE otherwise.
pmallick 0:3afcd581558d 103 */
pmallick 0:3afcd581558d 104 int32_t iio_app(struct iio_app_desc *desc)
pmallick 0:3afcd581558d 105 {
pmallick 0:3afcd581558d 106 int32_t status;
pmallick 0:3afcd581558d 107
pmallick 0:3afcd581558d 108 status = tinyiiod_read_command(desc->iiod);
pmallick 0:3afcd581558d 109 if(status < 0)
pmallick 0:3afcd581558d 110 return status;
pmallick 0:3afcd581558d 111 }