Analog Devices / Mbed OS EVAL-AD717x-AD411x-IIO

Dependencies:   sdp_k1_sdram

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ad717x_support.c Source File

ad717x_support.c

Go to the documentation of this file.
00001 /*************************************************************************//**
00002  *   @file   ad717x_support.c
00003  *   @brief  Support file for AD717X device configurations
00004 ******************************************************************************
00005 * Copyright (c) 2022 Analog Devices, Inc.
00006 *
00007 * All rights reserved.
00008 *
00009 * This software is proprietary to Analog Devices, Inc. and its licensors.
00010 * By using this software you agree to the terms of the associated
00011 * Analog Devices Software License Agreement.
00012 *****************************************************************************/
00013 
00014 /******************************************************************************/
00015 /***************************** Include Files **********************************/
00016 /******************************************************************************/
00017 
00018 #include "ad717x_support.h"
00019 #include "ad717x_iio.h"
00020 #include "no_os_error.h"
00021 
00022 /******************************************************************************/
00023 /********************** Variables and User Defined Data Types *****************/
00024 /******************************************************************************/
00025 
00026 /******************************************************************************/
00027 /************************** Functions Declarations ****************************/
00028 /******************************************************************************/
00029 
00030 /******************************************************************************/
00031 /************************ Functions Definitions *******************************/
00032 /******************************************************************************/
00033 
00034 /**
00035  * @brief Enable/Disable continuous read mode
00036  * @param device[in] - The AD717x Device descriptor
00037  * @param cont_read_en[in] - True in case of enable CONT_READ/ False in case of disable
00038  * @return 0 in case of success, negative error code otherwise
00039  */
00040 int32_t ad717x_enable_cont_read(ad717x_dev *device, bool cont_read_en)
00041 {
00042     ad717x_st_reg *ifmode_reg;
00043     int32_t ret;
00044 
00045     /* Retrieve the IFMODE Register */
00046     ifmode_reg = AD717X_GetReg(p_ad717x_dev_inst, AD717X_IFMODE_REG);
00047     if (!ifmode_reg) {
00048         return -EINVAL;
00049     }
00050 
00051     if (cont_read_en) {
00052         ifmode_reg->value |= (AD717X_IFMODE_REG_CONT_READ);
00053     } else {
00054         ifmode_reg->value &= ~(AD717X_IFMODE_REG_CONT_READ);
00055     }
00056 
00057     ret = AD717X_WriteRegister(p_ad717x_dev_inst, AD717X_IFMODE_REG);
00058     if (ret) {
00059         return ret;
00060     }
00061 
00062     return 0;
00063 }