Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: sdp_k1_sdram
Revision 2:007533849deb, committed 2022-07-21
- Comitter:
- Mahesh Phalke
- Date:
- Thu Jul 21 16:45:24 2022 +0530
- Parent:
- 1:e8361ea27191
- Commit message:
- Initial firmware commit
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,15 @@ +*.swp +*.profile* +*.txt +mbed-os +app/mbed_platform_drivers +app/no-OS +app/sdp_k1_sdram +Visual* +Code* +.gitattributes +.vs/ +*.sln +*.vgdbproj +*.TMP +*.user \ No newline at end of file
--- a/LICENSE.md Mon May 24 09:14:55 2021 +0000 +++ b/LICENSE.md Thu Jul 21 16:45:24 2022 +0530 @@ -1,205 +1,14 @@ -Analog Devices, Inc. (ADI) -Source Code Software License Agreement -20210129-LWSCMOS-CTSLA -BEFORE YOU SELECT THE "I ACCEPT" BUTTON AT THE BOTTOM OF THIS WINDOW, CAREFULLY READ THE TERMS AND CONDITIONS SET FORTH BELOW. BY SELECTING THE "I ACCEPT" BUTTON BELOW, OR DOWNLOADING, REPRODUCING, DISTRIBUTING OR OTHERWISE USING THE SOFTWARE, YOU AGREE TO BE BOUND BY THE TERMS AND CONDITIONS SET FORTH BELOW. IF YOU DO NOT AGREE TO ALL OF THE TERMS AND CONDITIONS, SELECT THE 'I DO NOT ACCEPT' BUTTON AND YOU MUST NOT DOWNLOAD, INSTALL OR OTHERWISE USE THE SOFTWARE. - -DOWNLOADING, REPRODUCING, DISTRIBUTING OR OTHERWISE USING THE SOFTWARE CONSTITUTES ACCEPTANCE OF THIS LICENSE. THE SOFTWARE MAY NOT BE USED EXCEPT AS EXPRESSLY AUTHORIZED UNDER THIS LICENSE. - -The software is protected by copyright law and international copyright treaties. - -1. License: Subject to the terms and conditions of this license, the software may be reproduced, modified and distributed in source code and object code form. - -2. Conditions: -(a) Any distribution of the software must include a complete copy of this license and retain all copyright and other proprietary notices. The software that is distributed (including modified versions of the software) shall be subject to the terms and conditions of this license. -(b) The software may not be combined or merged with other software in any manner that would cause the software to become subject to terms and conditions which differ from those of this license. -(c) The software is licensed solely and exclusively for use with processors / products manufactured by or for ADI. -(d) Licensee shall not use the name or any trademark of ADI (including those of its licensors) or any contributor to endorse or promote products without prior written consent of the owner of the name or trademark. The term �contributor� means any person or entity that modifies or distributes the software. -(e) Modified versions of the Software must be conspicuously marked as such. -(f) Use of the software may or may not infringe patent rights of one or more patent holders. This license does not alleviate the obligation to obtain separate licenses from patent holders to use the software. -(g) All rights not expressly granted hereunder are reserved. -(h) This license shall be governed by the laws of Massachusetts, without regard to its conflict of laws rules. The software shall only be used in compliance with all applicable laws and regulations, including without limitation export control laws. - -3. WARRANTY DISCLAIMER: THE SOFTWARE AND ANY RELATED INFORMATION AND/OR ADVICE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT REPRESENTATIONS, GUARANTEES OR WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, ORAL OR WRITTEN, INCLUDING WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. There is no obligation to provide software support or updates. The Software is not fault-tolerant and is not intended for use in high risk applications, including without limitation in the operation of nuclear facilities, aircraft navigation or control systems, air traffic control, life support machines, weapons systems, autonomous driving or other safety critical automotive applications, or any other application in which the failure of the software could lead to death, personal injury, or severe physical or environmental damages. The software is not authorized to be used under such circumstances. - -4. LIMITATION OF LIABILITY: TO THE MAXIMUM EXTENT PERMITTED BY LAW ADI (INCLUDING ITS LICENSORS) AND CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY DAMAGES ARISING FROM OR RELATED TO THE SOFTWARE, ITS USE OR ANY RELATED INFORMATION AND/OR SERVICES, INCLUDING BUT NOT LIMITED TO ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE, EXEMPLARY, CONSEQUENTIAL OR ANALOGOUS DAMAGES (INCLUDING WITHOUT LIMITATION ANY DAMAGES RESULTING FROM LOSS OF USE, DATA, REVENUE, PROFITS, OR SAVINGS, COMPUTER DAMAGE OR ANY OTHER CAUSE), UNDER ANY LEGAL THEORY (INCLUDING WITHOUT LIMITATION CONTRACT, WARRANTY, TORT, NEGLIGENCE, STRICT OR PRODUCT LIABILITY), EVEN IF IT HAS BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. Some jurisdictions do not permit the exclusion or limitation of liability for consequential, incidental or other damages, and, as such, some portion of the above limitation may not apply. In such jurisdictions, liability is limited to the greatest extent permitted by law. -5. Third Party Software: The software may be accompanied by or include software made available by one or more third parties (Third Party Software). Each portion of Third Party Software is subject to its own separate software license terms and conditions (�Third Party Licenses�). The Third Party Licenses for Third Party Software delivered with the software are set forth or identified (by url or otherwise) in (i) Appendix A to this license (if any), (ii) the applicable software header or footer text, (iii) a text file located in the directory of the applicable Third Party Software component and/or (iv) such other location customarily used for licensing terms. The use of each portion of Third Party Software is subject to the Third Party Licenses, and you agree that your use of any Third Party Software is bound by the applicable Third Party License. You agree to review and comply with all applicable Third Party Licenses prior to any use or distribution of any Third Party Software. Third Party Software is provided on an �as is� basis without any representation, warranty or liability of any kind. ADI (including its licensors) and contributors shall have no liability or responsibility for the operation or performance of the Third Party Software and shall not be liable for any damages, costs, or expenses, direct or indirect, arising out of the performance or failure to perform of the Third Party Software. ADI (including its licensors) and contributors shall be entitled to the benefit of any and all limitations of liability and disclaimers of warranties contained in the Third Party Licenses. For the avoidance of doubt, this license does not alter, limit or expand the terms and conditions of, or rights granted to you pursuant to, Third Party Licenses. - -Appendix A - Third Party License - -Mbed-OS - -Download page:https://github.com/ARMmbed/mbed-os/ -Online license: https://github.com/ARMmbed/mbed-os/blob/master/LICENSE-apache-2.0.txt - - -Apache License 2.0 - -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and -distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright -owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities -that control, are controlled by, or are under common control with that entity. -For the purposes of this definition, "control" means (i) the power, direct or -indirect, to cause the direction or management of such entity, whether by -contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the -outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising -permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including -but not limited to software source code, documentation source, and configuration -files. - -"Object" form shall mean any form resulting from mechanical transformation or -translation of a Source form, including but not limited to compiled object code, -generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made -available under the License, as indicated by a copyright notice that is included -in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that -is based on (or derived from) the Work and for which the editorial revisions, -annotations, elaborations, or other modifications represent, as a whole, an -original work of authorship. For the purposes of this License, Derivative Works -shall not include works that remain separable from, or merely link (or bind by -name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version -of the Work and any modifications or additions to that Work or Derivative Works -thereof, that is intentionally submitted to Licensor for inclusion in the Work -by the copyright owner or by an individual or Legal Entity authorized to submit -on behalf of the copyright owner. For the purposes of this definition, -"submitted" means any form of electronic, verbal, or written communication sent -to the Licensor or its representatives, including but not limited to -communication on electronic mailing lists, source code control systems, and -issue tracking systems that are managed by, or on behalf of, the Licensor for -the purpose of discussing and improving the Work, but excluding communication -that is conspicuously marked or otherwise designated in writing by the copyright -owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf -of whom a Contribution has been received by Licensor and subsequently -incorporated within the Work. - -2. Grant of Copyright License. +Copyright (c) 2020 Analog Devices, Inc. All rights reserved. -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable copyright license to reproduce, prepare Derivative Works of, -publicly display, publicly perform, sublicense, and distribute the Work and such -Derivative Works in Source or Object form. - -3. Grant of Patent License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable (except as stated in this section) patent license to make, have -made, use, offer to sell, sell, import, and otherwise transfer the Work, where -such license applies only to those patent claims licensable by such Contributor -that are necessarily infringed by their Contribution(s) alone or by combination -of their Contribution(s) with the Work to which such Contribution(s) was -submitted. If You institute patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Work or a -Contribution incorporated within the Work constitutes direct or contributory -patent infringement, then any patent licenses granted to You under this License -for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. - -You may reproduce and distribute copies of the Work or Derivative Works thereof -in any medium, with or without modifications, and in Source or Object form, -provided that You meet the following conditions: - -You must give any other recipients of the Work or Derivative Works a copy of -this License; and -You must cause any modified files to carry prominent notices stating that You -changed the files; and -You must retain, in the Source form of any Derivative Works that You distribute, -all copyright, patent, trademark, and attribution notices from the Source form -of the Work, excluding those notices that do not pertain to any part of the -Derivative Works; and -If the Work includes a "NOTICE" text file as part of its distribution, then any -Derivative Works that You distribute must include a readable copy of the -attribution notices contained within such NOTICE file, excluding those notices -that do not pertain to any part of the Derivative Works, in at least one of the -following places: within a NOTICE text file distributed as part of the -Derivative Works; within the Source form or documentation, if provided along -with the Derivative Works; or, within a display generated by the Derivative -Works, if and wherever such third-party notices normally appear. The contents of -the NOTICE file are for informational purposes only and do not modify the -License. You may add Your own attribution notices within Derivative Works that -You distribute, alongside or as an addendum to the NOTICE text from the Work, -provided that such additional attribution notices cannot be construed as -modifying the License. -You may add Your own copyright statement to Your modifications and may provide -additional or different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works as a whole, -provided Your use, reproduction, and distribution of the Work otherwise complies -with the conditions stated in this License. +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + - Modified versions of the software must be conspicuously marked as such. + - This software is licensed solely and exclusively for use with processors/products manufactured by or for Analog Devices, Inc. + - This software may not be combined or merged with other code in any manner that would cause the software to become subject to terms and conditions which differ from those listed here. + - Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + - The use of this software may or may not infringe the patent rights of one or more patent holders. This license does not release you from the requirement that you obtain separate licenses from these patent holders to use this software. -5. Submission of Contributions. - -Unless You explicitly state otherwise, any Contribution intentionally submitted -for inclusion in the Work by You to the Licensor shall be under the terms and -conditions of this License, without any additional terms or conditions. -Notwithstanding the above, nothing herein shall supersede or modify the terms of -any separate license agreement you may have executed with Licensor regarding -such Contributions. - -6. Trademarks. - -This License does not grant permission to use the trade names, trademarks, -service marks, or product names of the Licensor, except as required for -reasonable and customary use in describing the origin of the Work and -reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. - -Unless required by applicable law or agreed to in writing, Licensor provides the -Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, -including, without limitation, any warranties or conditions of TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are -solely responsible for determining the appropriateness of using or -redistributing the Work and assume any risks associated with Your exercise of -permissions under this License. +THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -8. Limitation of Liability. - -In no event and under no legal theory, whether in tort (including negligence), -contract, or otherwise, unless required by applicable law (such as deliberate -and grossly negligent acts) or agreed to in writing, shall any Contributor be -liable to You for damages, including any direct, indirect, special, incidental, -or consequential damages of any character arising as a result of this License or -out of the use or inability to use the Work (including but not limited to -damages for loss of goodwill, work stoppage, computer failure or malfunction, or -any and all other commercial damages or losses), even if such Contributor has -been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. - -While redistributing the Work or Derivative Works thereof, You may choose to -offer, and charge a fee for, acceptance of support, warranty, indemnity, or -other liability obligations and/or rights consistent with this License. However, -in accepting such obligations, You may act only on Your own behalf and on Your -sole responsibility, not on behalf of any other Contributor, and only if You -agree to indemnify, defend, and hold each Contributor harmless for any liability -incurred by, or claims asserted against, such Contributor by reason of your -accepting any such warranty or additional liability. - -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - +2020-02-24-7CBSD SLA
--- a/README.txt Mon May 24 09:14:55 2021 +0000 +++ b/README.txt Thu Jul 21 16:45:24 2022 +0530 @@ -1,45 +1,37 @@ Evaluation Boards/Products Supported ------------------------------------ -EVAL-AD1234 (AD1234) -EVAL-AD1256 (AD1256) -<< add more here >> - +EVAL-AD7689 + Overview -------- -These code files provide drivers to interface with AD1234 and communicate with -EVAL-AD1234 board. This code was developed and tested on SDP-K1 controller board -https://os.mbed.com/platforms/SDP_K1/. - -Product details: https://www.analog.com/en/products/ad1234.html -Eval board details: https://www.analog.com/en/design-center/evaluation-hardware-and-software/evaluation-boards-kits/EVAL-AD1234.html - - +This is an IIO ecosystem based firmware application to evaluate the AD7689 family devices. +This code was developed and tested on SDP-K1 controller board: https://os.mbed.com/platforms/SDP_K1/ +Use of Mbed platform allows code to port on other Mbed supported target boards with little or no modifications. + +Product details: AD7689, AD7682, AD7949, AD7699 +Product Evaluation board details: EVAL-AD7689-ARDZ +User Guide for this code: https://wiki.analog.com/resources/tools-software/product-support-software/ad7689_mbed_iio_support +Communication Protocol: SPI + Hardware Setup -------------- -Required: SDP-K1, EVAL-AD1234, USB cable, 12 V power supply, 60 MHz external -clock supply. -Plug in the EVAL-AD124 board on SDP-K1 board (or any other Mbed enabled -controller board) using the SDP connector and screws. -Connect SDP-K1 board to the PC using the USB cable. - - +Required: SDP-K1 (or alternative Mbed enabled controller board), EVAL-AD7689 board and USB cable. +Plug in the EVAL-AD7689 board on SDP-K1 board (or any other Mbed enabled controller board) using the Arduino connector +(refer software wiki page for connection setup). +Connect SDP-K1 board to the PC using the USB cable. AD7689 EVB is powered through USB supply coming from SDP-K1. + How to Get Started ------------------ -Open Mbed online compiler. https://ide.mbed.com/compiler -Import Code into compiler from here: https://os.mbed.com/teams/AnalogDevices/code/EVAL-AD1234/ -instructions on how to import code are here: https://os.mbed.com/docs/mbed-os/v5.12/tools/importing-code.html -Compile code. Drag and drop binary into SDP-K1 controller board. Find detailed instructions -here: https://os.mbed.com/docs/mbed-os/v5.12/tools/getting-your-program-on-your-board.html -Open Tera Term (or alternative), select 9600 baud rate, and the applicable COM port to see the -list of options. - -A detailed user guide on how to use SDP-K1 board on Mbed platform is available -here: https://wiki.analog.com/resources/tools-software/mbed - - +Mbed web/online compiler: https://studio.keil.arm.com/auth/login/ +Import code into compiler and compile it to generate executable binary file. +Drag and drop binary file into USB drive hosted by SDP-K1 controller board. +Find detailed instructions here: https://developer.arm.com/documentation/102497/1-5/Arm-Keil-Studio + Notes ----- -If using Win 7, install serial drivers for Mbed. https://os.mbed.com/docs/mbed-os/v5.12/tutorials/windows-serial-driver.html -A detailed user guide on SDP-K1 controller board is available here https://www.analog.com/en/design-center/evaluation-hardware-and-software/evaluation-boards-kits/SDP-K1.html. - - \ No newline at end of file +A detailed user guide on SDP-K1 controller board is available here: +https://os.mbed.com/platforms/SDP_K1/ +https://www.analog.com/en/design-center/evaluation-hardware-and-software/evaluation-boards-kits/SDP-K1.html. + + +Copyright (c) 2021 Analog Devices, Inc. All rights reserved.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/.mbedignore Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,66 @@ +no-OS/ad5758-sdz/ +no-OS/AD6673-EBZ/ +no-OS/AD9250-EBZ/ +no-OS/adum7701_fmc/ +no-OS/ci/ +no-OS/common_drivers/ +no-OS/device_drivers/ +no-OS/doc/ +no-OS/drivers/accel/ +no-OS/drivers/afe/ +no-OS/drivers/axi_core/ +no-OS/drivers/adc/ad4* +no-OS/drivers/adc/ad6* +no-OS/drivers/adc/ad70* +no-OS/drivers/adc/ad71* +no-OS/drivers/adc/ad72* +no-OS/drivers/adc/ad73* +no-OS/drivers/adc/ad74* +no-OS/drivers/adc/ad75* +no-OS/drivers/adc/ad7606/ +no-OS/drivers/adc/ad7616/ +no-OS/drivers/adc/ad77* +no-OS/drivers/adc/ad78* +no-OS/drivers/adc/ad79* +no-OS/drivers/adc/adaq7980/ +no-OS/drivers/adc/adaq8092/ +no-OS/drivers/adc/ad9* +no-OS/drivers/adc/ltc2312/ +no-OS/drivers/adc/adc_demo/ +no-OS/drivers/adc-dac/ad5592r/ +no-OS/drivers/instr-amplif/ +no-OS/drivers/tdm/ +no-OS/drivers/cdc/ +no-OS/drivers/dac/ +no-OS/drivers/ecg/ +no-OS/drivers/frequency/ +no-OS/drivers/gyro/ +no-OS/drivers/impedance-analyzer/ +no-OS/drivers/io-expander/ +no-OS/drivers/mux/ +no-OS/drivers/photo-electronic/ +no-OS/drivers/platform/aducm3029/ +no-OS/drivers/platform/altera/ +no-OS/drivers/platform/generic/ +no-OS/drivers/platform/linux/ +no-OS/drivers/platform/maxim/ +no-OS/drivers/platform/stm32/ +no-OS/drivers/platform/xilinx/ +no-OS/drivers/potentiometer/ +no-OS/drivers/rf-transceiver/ +no-OS/drivers/sd-card/ +no-OS/drivers/temperature/ +no-OS/drivers/display/ +no-OS/drivers/amplifiers/ +no-OS/drivers/filter/ +no-OS/legacy/ +no-OS/libraries/fatfs/ +no-OS/libraries/mbedtls/ +no-OS/libraries/mqtt/ +no-OS/network/ +no-OS/projects/ +no-OS/scripts/ +no-OS/tools/ +no-OS/v4l2_config/ +mbed_platform_drivers/adc_data_capture.c +mbed_platform_drivers/adc_data_capture.h \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/ad7689_data_capture.c Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,704 @@ +/***************************************************************************//** + * @file ad7689_data_capture.c + * @brief Data capture interface for AD7689 IIO application + * @details This module handles the AD7689 data capturing for IIO client +******************************************************************************** + * Copyright (c) 2021-22 Analog Devices, Inc. + * All rights reserved. + * + * This software is proprietary to Analog Devices, Inc. and its licensors. + * By using this software you agree to the terms of the associated + * Analog Devices Software License Agreement. +*******************************************************************************/ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ +#include <string.h> + +#include "ad7689_data_capture.h" +#include "app_config.h" +#include "ad7689_iio.h" +#include "ad7689_user_config.h" +#include "no_os_delay.h" +#include "no_os_spi.h" +#include "no_os_util.h" +#include "no_os_gpio.h" +#include "no_os_error.h" + +/******************************************************************************/ +/********************** Macros and Constants Definition ***********************/ +/******************************************************************************/ + +/* Timeout count to avoid stuck into potential infinite loop while checking + * for new data into an acquisition buffer. The actual timeout factor is determined + * through 'sampling_frequency' attribute of IIO app, but this period here makes sure + * we are not stuck into a forever loop in case data capture is interrupted + * or failed in between. + * Note: This timeout factor is dependent upon the MCU clock frequency. Below timeout + * is tested for SDP-K1 platform @180Mhz default core clock */ +#define BUF_READ_TIMEOUT 0xffffffff + +#define BYTE_SIZE 8 + +/* Value indicating end of channels from active channels list */ +#define END_OF_CHN 0xff + +/* Config register bit positions */ +#define CONFIG_OVERRIDE_BIT_POS 13 +#define CHN_CONFIG_SELECT_BIT_POS 10 +#define CHN_SELECT_BIT_POS 7 +#define REF_SRC_SELECT_BIT_POS 3 + +/******************************************************************************/ +/********************** Variables and User Defined Data Types *****************/ +/******************************************************************************/ + +/* ADC data buffer */ +#if !defined(USE_SDRAM_CAPTURE_BUFFER) +int8_t adc_data_buffer[DATA_BUFFER_SIZE] = { 0 }; +#endif + +/* + *@enum acq_buffer_state_e + *@details Enum holding the data acquisition buffer states + **/ +typedef enum { + BUF_AVAILABLE, + BUF_EMPTY, + BUF_FULL +} acq_buffer_state_e; + +/* + *@struct acq_buf_t + *@details Structure holding the data acquisition buffer parameters + **/ +typedef struct { + acq_buffer_state_e state; // Buffer state + uint32_t wr_indx; // Buffer write index (incremented per sample read) + uint32_t rd_indx; // Buffer read index (incremented per sample read) + int8_t *wr_pdata; // Data buffer write pointer + int8_t *rd_pdata; // Data buffer read pointer + bool reindex_buffer; // Reindex buffer to 0th channel +} acq_buf_t; + +/* ADC data acquisition buffers */ +static volatile acq_buf_t acq_buffer; + +/* Flag to indicate data capture status */ +static volatile bool start_cont_data_capture = false; + +/* Count to track number of actual samples requested by IIO client */ +static volatile uint32_t num_of_requested_samples = 0; + +/* ADC sample/raw data size in bytes */ +static volatile uint8_t sample_size_in_bytes; + +/* Max available buffer size (after considering the data alignment with IIO buffer) */ +static volatile uint32_t max_buffer_sz; + +/* List of input channels to be captured */ +static volatile uint8_t input_channels[ADC_CHN_COUNT]; + +/* Number of active channels */ +static volatile uint8_t num_of_active_channels; + +/* Current active channel index */ +static volatile uint8_t chn_indx; + +/* Active channels list */ +static uint8_t active_chns[ADC_CHN_COUNT + 1]; + +/* Index to next channel from active channels list */ +static uint8_t next_chn_indx; + +static uint8_t first_active_chn; +static uint8_t second_active_chn; + +/******************************************************************************/ +/************************ Functions Declarations ******************************/ +/******************************************************************************/ + +/******************************************************************************/ +/************************ Functions Definitions *******************************/ +/******************************************************************************/ + +/*! + * @brief Read the single ADC sample (raw data) for input channel + * @param input_chn[in] - Input channel to be sampled and read data for + * @param raw_data[in, out]- ADC raw data + * @return 0 in case of success, negative error code otherwise + */ +int32_t read_single_sample(uint8_t input_chn, uint32_t *raw_data) +{ + uint16_t adc_raw = 0; + int32_t ret; + + /* Configure 1st channel (n) for acquisition, data is read for (n-2) channel + * (undefined conversion result) */ + if (input_chn == TEMPERATURE_CHN) { + ad7689_current_config.inx = input_chn; + ad7689_current_config.incc = AD7689_TEMPERATURE_SENSOR; + ad7689_current_config.ref = AD7689_REF_INTERNAL_4p096V; + } else { + ad7689_current_config.inx = input_chn; + ad7689_current_config.incc = ADC_INPUT_TYPE_CFG; + ad7689_current_config.ref = ADC_REF_VOLTAGE_CFG; + } + + ret = ad7689_write_config(p_ad7689_dev_inst, &ad7689_current_config); + if (ret) { + return ret; + } + + /* Previous conversion wait delay */ + no_os_udelay(10); + + /* Configure 2nd channel (n+1) for acquisition, data is read for (n-1) channel */ + if (input_chn == TEMPERATURE_CHN) { + /* Load the inx bit to a next valid channel */ + ad7689_current_config.inx = input_chn; + ad7689_current_config.incc = AD7689_TEMPERATURE_SENSOR; + ad7689_current_config.ref = AD7689_REF_INTERNAL_4p096V; + } else { + ad7689_current_config.inx = input_chn; + ad7689_current_config.incc = ADC_INPUT_TYPE_CFG; + ad7689_current_config.ref = ADC_REF_VOLTAGE_CFG; + } + + ret = ad7689_write_config(p_ad7689_dev_inst, &ad7689_current_config); + if (ret) { + return ret; + } + + /* Previous conversion wait delay */ + no_os_udelay(10); + + /* The acquisition for channel (n) started from + * 'ad7689_enable_single_read_conversion' function. Data for that channel + * is available here (after 2 dummy reads). + **/ + ret = ad7689_read(p_ad7689_dev_inst, &adc_raw, 1); + if (ret) { + return ret; + } + + *raw_data = adc_raw; + + return 0; +} + +/*! + * @brief Read ADC raw data for recently sampled channel + * @param adc_data[out] - Pointer to adc data read variable + * @param input_chn[in] - Input channel + * @return 0 in case of success, negative error code otherwise + * @note This function is intended to call from the conversion end trigger + * event. Therefore, this function should just read raw ADC data + * without further monitoring conversion end event + */ +static int32_t adc_read_converted_sample(uint32_t *adc_data, + uint8_t input_chn) +{ + uint16_t adc_raw; + uint16_t config_reg; + uint8_t next_chn; + uint8_t buf[2] = { 0, 0 }; + int32_t ret; + + if (!adc_data) { + return -EINVAL; + } + + /* The acquisition for 1st (n) and 2nd (n+1) active channels is started from + * 'ad7689_enable_continuous_read_conversion' function. When chn_indx = 0, + * (i.e. first entry to this function), the converion result for 1st active + * channel (n) is read and is returned back. The next channel to be set for + * acquisition therefore must be (n+2). This is done by adding +2 offset in + * channel index recursively. + **/ + if (active_chns[next_chn_indx] == END_OF_CHN) { + next_chn_indx = 0; + } + next_chn = active_chns[next_chn_indx++]; + + /* Form the config register with new channel configuration */ + config_reg = (1 << CONFIG_OVERRIDE_BIT_POS); + config_reg |= (next_chn << CHN_SELECT_BIT_POS); + if (next_chn == TEMPERATURE_CHN) { + config_reg |= ((AD7689_TEMPERATURE_SENSOR << CHN_CONFIG_SELECT_BIT_POS) | + (AD7689_REF_INTERNAL_4p096V + << REF_SRC_SELECT_BIT_POS)); + } else { + config_reg |= ((ad7689_current_config.incc << CHN_CONFIG_SELECT_BIT_POS) | + (ad7689_current_config.ref + << REF_SRC_SELECT_BIT_POS)); + } + + /* Config word must to be sent during first 14 (MSBbits) clocks, therefore left + * shifted by 2 */ + config_reg <<= 2; + + buf[0] = config_reg >> BYTE_SIZE; + buf[1] = config_reg; + + /* Read the conversion result */ + ret = no_os_spi_write_and_read(p_ad7689_dev_inst->spi_desc, + buf, + sizeof(buf)); + if (ret) { + return ret; + } + + /* Extract the data */ + adc_raw = ((uint16_t)buf[0] << BYTE_SIZE) | buf[1]; +#if (ADC_RESOLUTION == 14) + adc_raw >>= 2; +#endif + + *adc_data = adc_raw; + return 0; +} + +/*! + * @brief Reset the data capture specific variables + * @return none + */ +static void reset_data_capture(void) +{ + /* Reset data capture flags */ + start_cont_data_capture = false; + num_of_active_channels = 0; + chn_indx = 0; + + /* Reset acquisition buffer states and clear old data */ + acq_buffer.state = BUF_EMPTY; + acq_buffer.wr_indx = 0; + acq_buffer.rd_indx = 0; + acq_buffer.reindex_buffer = false; + + acq_buffer.wr_pdata = adc_data_buffer; + acq_buffer.rd_pdata = adc_data_buffer; + + max_buffer_sz = DATA_BUFFER_SIZE; +} + +/*! + * @brief Store the list of all previously enabled channels and enable + * new channels set in the channel mask argument + * @param chn_mask[in] - Active channels list + * @return 0 in case of success, negative error code otherwise + */ +static int32_t adc_store_active_chns(uint32_t chn_mask) +{ + uint8_t chn; + uint8_t indx = 0; + + /* Get the list of active channels */ + for (chn = 0; chn < ADC_CHN_COUNT; chn++) { + if (chn_mask & 0x1) { + if (indx == 0) { + /* Get the n channel */ + first_active_chn = chn; + } else if (indx == 1) { + /* Get the n+1 channel */ + second_active_chn = chn; + } else { + /* Store the list of n+2 and onward channels */ + active_chns[indx - 2] = chn; + } + indx++; + } + chn_mask >>= 1; + } + + if (indx >= 2) { + active_chns[indx - 2] = first_active_chn; + active_chns[indx - 1] = second_active_chn; + } else { + active_chns[0] = first_active_chn; + } + + next_chn_indx = 0; + active_chns[indx] = END_OF_CHN; // end of channel list + + return 0; +} + +/*! + * @brief Trigger a data capture in continuous/burst mode + * @return 0 in case of success, negative error code otherwise + */ +static int32_t adc_start_data_capture(void) +{ + int32_t ret; + + /* From power-up, in any read/write mode, the first three conversion results are + * undefined because a valid CFG does not take place until the second EOC; + * therefore, two dummy conversions are required + **/ + + /* Configure 1st channel (n) for acquisition, data is read for (n-2) channel + * (undefined conversion reult) */ + ad7689_current_config.inx = first_active_chn; + ret = ad7689_write_config(p_ad7689_dev_inst, &ad7689_current_config); + if (ret) { + return ret; + } + + /* Previous conversion wait delay */ + no_os_udelay(10); + + if (num_of_active_channels > 1) { + /* Configure 2nd channel (n+1) for acquisition, data is read for (n-1) channel */ + ad7689_current_config.inx = second_active_chn; + ret = ad7689_write_config(p_ad7689_dev_inst, &ad7689_current_config); + if (ret) { + return ret; + } + + /* Previous conversion wait delay */ + no_os_udelay(10); + } + + return 0; +} + +/*! + * @brief Function to prepare the data ADC capture for new READBUFF + * request from IIO client (for active channels) + * @param chn_mask[in] - Channels to enable for data capturing + * @param num_of_chns[in] - ADC channel count + * @param sample_size[in] - Sample size in bytes + * @return 0 in case of success, negative error code otherwise + */ +int32_t prepare_data_transfer(uint32_t chn_mask, + uint8_t num_of_chns, + uint8_t sample_size) +{ + int32_t ret; + uint32_t mask = 0x1; + uint8_t index = 0; + + /* Reset data capture module specific flags and variables */ + reset_data_capture(); + + sample_size_in_bytes = sample_size; + + /* Get the active channels count based on the channel mask set in an IIO + * client application (channel mask starts from bit 0) */ + for (uint8_t chn = 0; chn < num_of_chns; chn++) { + if (chn_mask & mask) { + input_channels[index++] = chn; + num_of_active_channels++; + } + + mask <<= 1; + } + + /* Store active channels */ + ret = adc_store_active_chns(chn_mask); + if (ret) { + return ret; + } + +#if (DATA_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE) + /* Trigger continuous data capture */ + ret = adc_start_data_capture(); + if (ret) { + return ret; + } + + acq_buffer.state = BUF_AVAILABLE; + start_cont_data_capture = true; +#endif + + return 0; +} + +/*! + * @brief Function to stop data capture + * @return 0 in case of success, negative error code otherwise + */ +int32_t end_data_transfer(void) +{ + start_cont_data_capture = false; + + /* Reset data capture module specific flags and variables */ + reset_data_capture(); + + return 0; +} + +/*! + * @brief Perform buffer read operations to read requested samples + * @param nb_of_samples[in] - Requested number of samples to read + * @return 0 in case of success, negative error code otherwise + */ +static int32_t buffer_read_operations(uint32_t nb_of_samples) +{ + uint32_t timeout = BUF_READ_TIMEOUT; + int32_t offset; + + /* Wait until requested samples are available in the buffer to read */ + do { + if (acq_buffer.wr_indx >= acq_buffer.rd_indx) { + offset = acq_buffer.wr_indx - acq_buffer.rd_indx; + } else { + offset = max_buffer_sz + (acq_buffer.wr_indx - acq_buffer.rd_indx); + } + + timeout--; + } while ((offset < (int32_t)(nb_of_samples)) && (timeout > 0)); + + if (timeout == 0) { + /* This returns the empty buffer */ + return -EIO; + } + + if (acq_buffer.rd_indx >= max_buffer_sz) { + acq_buffer.rd_indx = 0; + } + + return 0; +} + +/*! + * @brief Perform buffer write operations such as buffer full or empty + * check, resetting buffer index and pointers, etc + * @return none + */ +static void buffer_write_operations(void) +{ + acq_buffer.wr_indx++; + + /* Perform buffer full check and operations */ + if (acq_buffer.wr_indx >= max_buffer_sz) { + if ((acq_buffer.rd_indx >= num_of_requested_samples) + && (acq_buffer.rd_indx != 0)) { + /* Reset buffer write index and write pointer when enough + * space available in the buffer to wrap to start */ + acq_buffer.wr_indx = 0; + + acq_buffer.wr_pdata = adc_data_buffer; + if (acq_buffer.rd_indx >= max_buffer_sz) { + /* Wrap the read index and read pointer to start of buffer + * if buffer is completely read/emptied */ + acq_buffer.rd_indx = 0; + acq_buffer.rd_pdata = adc_data_buffer; + } + + acq_buffer.state = BUF_AVAILABLE; + } else { + /* Wait until enough space available to wrap buffer write index + * at the start of buffer */ + acq_buffer.wr_indx = max_buffer_sz; + acq_buffer.state = BUF_FULL; + acq_buffer.reindex_buffer = true; + } + } +} + +/*! + * @brief This is an ISR (Interrupt Service Routine) to monitor end of conversion event. + * @param ctx[in] - Callback context (unused) + * @return none + * @details This is an Interrupt callback function/ISR invoked in synchronous/asynchronous + * manner depending upon the application implementation. The conversion results + * are read into acquisition buffer and control continue to sample next channel. + * This continues until conversion is stopped (through IIO client command) + */ +void data_capture_callback(void *ctx) +{ + uint32_t adc_sample; + volatile uint8_t *wr_addr; + + if (start_cont_data_capture == true) { + /* Read the sample for channel which has been sampled recently */ + if (!adc_read_converted_sample(&adc_sample, + input_channels[chn_indx])) { + do { + if (acq_buffer.state == BUF_AVAILABLE) { + if (acq_buffer.reindex_buffer) { + /* Buffer refilling must start with first active channel data + * for IIO client to synchronize the buffered data */ + if (chn_indx != 0) { + break; + } + acq_buffer.reindex_buffer = false; + } + + /* Copy adc samples into acquisition buffer to transport over + * communication link */ + wr_addr = (volatile uint8_t *)(acq_buffer.wr_pdata + (acq_buffer.wr_indx * + sample_size_in_bytes)); + memcpy((uint8_t *)wr_addr, &adc_sample, sample_size_in_bytes); + } + + /* Perform buffer write operations */ + buffer_write_operations(); + } while (0); + + /* Track the count for recently sampled channel */ + chn_indx++; + if (chn_indx >= num_of_active_channels) { + chn_indx = 0; + } + } + } +} + +/*! + * @brief Capture requested number of ADC samples in burst mode + * @param pbuf[out] - Pointer to ADC data buffer + * @param nb_of_samples[in] - Number of samples to be read + * @return 0 in case of success, negative error code otherwise + */ +static int32_t read_burst_data(int8_t *pbuf, uint32_t nb_of_samples) +{ + int32_t ret; + uint32_t sample_indx = 0; + uint8_t next_chn_indx = 0; + uint16_t config_reg; + uint16_t adc_raw; + uint8_t next_chn; + uint8_t buf[2] = { 0, 0 }; + + ret = adc_start_data_capture(); + if (ret) { + return ret; + } + + while (sample_indx < nb_of_samples) { + if (active_chns[next_chn_indx] == END_OF_CHN) { + next_chn_indx = 0; + } + next_chn = active_chns[next_chn_indx++]; + + /* Form the config register with new channel configuration */ + config_reg = (1 << CONFIG_OVERRIDE_BIT_POS); + config_reg |= (next_chn << CHN_SELECT_BIT_POS); + if (next_chn == TEMPERATURE_CHN) { + config_reg |= ((AD7689_TEMPERATURE_SENSOR << CHN_CONFIG_SELECT_BIT_POS) | + (AD7689_REF_INTERNAL_4p096V + << REF_SRC_SELECT_BIT_POS)); + } else { + config_reg |= ((ad7689_current_config.incc << CHN_CONFIG_SELECT_BIT_POS) | + (ad7689_current_config.ref + << REF_SRC_SELECT_BIT_POS)); + } + + /* Config word must to be sent during first 14 (MSBbits) clocks, therefore left + * shifted by 2 */ + config_reg <<= 2; + + buf[0] = config_reg >> BYTE_SIZE; + buf[1] = config_reg; + + /* Read the conversion result */ + ret = no_os_spi_write_and_read(p_ad7689_dev_inst->spi_desc, + buf, + sizeof(buf)); + if (ret) { + return ret; + } + + /* Extract the data */ + adc_raw = ((uint16_t)buf[0] << BYTE_SIZE) | buf[1]; +#if (ADC_RESOLUTION == 14) + adc_raw >>= 2; +#endif + + memcpy((uint8_t *)pbuf, &adc_raw, sample_size_in_bytes); + pbuf += sample_size_in_bytes; + + /* Conversion delay = Acquisition time + Data read time + * Conv time = 4usec (min), Read time = ~2.1usec (@22.5Mhz SPI clock) + * Acq Time (req) = 4usec - 2.1usec = 1.9usec. + * Due to inaccuracy and overhead in the udelay() function, + * 1usec delay typically results into ~2.5usec time on SDP-K1 Mbed board. + * This delay is very critical in the conversion and may change + * from compiler to compiler and hardware to hardware. */ + if (next_chn == TEMPERATURE_CHN) { + no_os_udelay(5); + } else { + no_os_udelay(1); + } + + sample_indx++; + } + + return 0; +} + +/*! + * @brief Read requested number of ADC samples in continuous mode + * @param pbuf[in] - Pointer to data buffer + * @param nb_of_samples[in] - Number of samples to read + * @return 0 in case of success, negative error code otherwise + * @note The actual sample capturing happens through interrupt. This + * function tracks the buffer read pointer to read block of data + */ +static int32_t read_continuous_conv_data(int8_t **pbuf, uint32_t nb_of_samples) +{ + volatile int8_t *rd_addr; + int32_t ret; + + /* Determine the max available buffer size based on the requested + * samples count and actual avilable buffer size. Buffer should be + * capable of holding all requested 'n' samples from previous write + * index upto to the end of buffer, as data is read linearly + * from adc buffer in IIO library. + * E.g. If actual buffer size is 2048 samples and requested samples + * are 1600, max available buffer size is actually 1600. So in given + * iteration, only 1600 samples will be stored into buffer and after + * that buffer indexes will be wrapped to a start of buffer. If index + * is not wrapped, the next 1600 requested samples won't accomodate into + * remaining 448 samples space. As buffer is read in linear fashion, the + * read index can't be wrapped to start of buffer to read remaining samples. + * So max available space in this case is 2048 but only utilized space + * will be 1600 in single read buffer request from IIO client. + **/ + max_buffer_sz = ((DATA_BUFFER_SIZE / sample_size_in_bytes) / + nb_of_samples) * nb_of_samples; + + ret = buffer_read_operations(nb_of_samples); + if (ret) { + return ret; + } + + /* Get the next read address */ + rd_addr = (volatile int8_t *)(acq_buffer.rd_pdata + (acq_buffer.rd_indx * + sample_size_in_bytes)); + acq_buffer.rd_indx += nb_of_samples; + + /* Update the IIO buffer pointer to point to next read start location */ + *pbuf = rd_addr; + + return 0; +} + +/*! + * @brief Function to read the ADC buffered raw data requested + * by IIO client + * @param pbuf[in] - Pointer to data buffer + * @param nb_of_bytes[in] - Number of bytes to read + * @return 0 in case of success, negative error code otherwise + */ +int32_t read_buffered_data(int8_t **pbuf, uint32_t nb_of_bytes) +{ + int32_t ret; + num_of_requested_samples = nb_of_bytes / sample_size_in_bytes; + +#if (DATA_CAPTURE_MODE == BURST_DATA_CAPTURE) + ret = read_burst_data(*pbuf, num_of_requested_samples); +#else + ret = read_continuous_conv_data(pbuf, num_of_requested_samples); +#endif + + if (ret) { + return ret; + } + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/ad7689_data_capture.h Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,50 @@ +/***************************************************************************//** + * @file ad7689_data_capture.h + * @brief Header for AD7689 data capture interfaces +******************************************************************************** + * Copyright (c) 2021-22 Analog Devices, Inc. + * All rights reserved. + * + * This software is proprietary to Analog Devices, Inc. and its licensors. + * By using this software you agree to the terms of the associated + * Analog Devices Software License Agreement. +*******************************************************************************/ + +#ifndef _AD7689_DATA_CAPTURE_H_ +#define _AD7689_DATA_CAPTURE_H_ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ + +#include <stdint.h> +#include "app_config.h" + +/******************************************************************************/ +/********************** Macros and Constants Definition ***********************/ +/******************************************************************************/ + +#if defined(USE_SDRAM_CAPTURE_BUFFER) +#define adc_data_buffer SDRAM_START_ADDRESS +#define DATA_BUFFER_SIZE SDRAM_SIZE_BYTES +#else +extern int8_t adc_data_buffer[]; +#define DATA_BUFFER_SIZE (32768) // 32kbytes +#endif + +/******************************************************************************/ +/********************** Variables and User Defined Data Types *****************/ +/******************************************************************************/ + +/******************************************************************************/ +/************************ Public Declarations *********************************/ +/******************************************************************************/ + +int32_t read_single_sample(uint8_t input_chn, uint32_t *raw_data); +int32_t read_buffered_data(int8_t **pbuf, uint32_t nb_of_bytes); +int32_t prepare_data_transfer(uint32_t ch_mask, uint8_t num_of_chns, + uint8_t sample_size_in_byte); +int32_t end_data_transfer(void); +void data_capture_callback(void *ctx); + +#endif /* _AD7689_DATA_CAPTURE_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/ad7689_iio.c Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,513 @@ +/***************************************************************************//** + * @file ad7689_iio.c + * @brief Implementation of AD7689 IIO application interfaces +******************************************************************************** + * Copyright (c) 2021-22 Analog Devices, Inc. + * All rights reserved. + * + * This software is proprietary to Analog Devices, Inc. and its licensors. + * By using this software you agree to the terms of the associated + * Analog Devices Software License Agreement. +*******************************************************************************/ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ + +#include <stdint.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> + +#include "ad7689_iio.h" +#include "app_config.h" +#include "ad7689_user_config.h" +#include "ad7689_data_capture.h" +#include "no_os_error.h" + +/******************************************************************************/ +/********************* Macros and Constants Definition ************************/ +/******************************************************************************/ + +/* ADC Raw to Voltage conversion default scale factor for IIO client */ +#if defined(BIPOLAR) +/* Device supports only pseudo-bipolar mode. INX- = Vref / 2 */ +#define ADC_DEFAULT_SCALE (((ADC_DEFAULT_REF_VOLTAGE / 2) / ADC_MAX_COUNT_BIPOLAR) * 1000) +#else +#define ADC_DEFAULT_SCALE ((ADC_DEFAULT_REF_VOLTAGE / ADC_MAX_COUNT_UNIPOLAR) * 1000) +#endif + +/* The output of temperature sensor is always unipolar (streight-binary) */ +#define TEMPERATURE_SENSITIVITY 0.283 // 283mv +#define ROOM_TEMPERATURE 25.0 +#define TEMPERATURE_CONV_SCALE (ROOM_TEMPERATURE / TEMPERATURE_SENSITIVITY) * \ + ((ADC_DEFAULT_REF_VOLTAGE / ADC_MAX_COUNT_UNIPOLAR) * 1000) + +/* Bytes per sample. This count should divide the total 256 bytes into 'n' equivalent + * ADC samples as IIO library requests only 256bytes of data at a time in a given + * data read query. + * For 1 to 8-bit ADC, bytes per sample = 1 (2^0) + * For 9 to 16-bit ADC, bytes per sample = 2 (2^1) + * For 17 to 32-bit ADC, bytes per sample = 4 (2^2) + **/ +#define BYTES_PER_SAMPLE sizeof(uint16_t) // For ADC resolution of 16-bits + +/* Number of data storage bits (needed for IIO client to plot ADC data) */ +#define CHN_STORAGE_BITS (BYTES_PER_SAMPLE * 8) + +/* Private IDs for IIO attributes */ +#define IIO_RAW_ATTR_ID 0 +#define IIO_SCALE_ATTR_ID 1 +#define IIO_OFFSET_ATTR_ID 2 + +/******************************************************************************/ +/******************** Variables and User Defined Data Types *******************/ +/******************************************************************************/ + +/* IIO interface descriptor */ +static struct iio_desc *p_ad7689_iio_desc; + +/* Device name */ +static const char dev_name[] = ACTIVE_DEVICE_NAME; + +/* Pointer to the struct representing the AD7689 IIO device */ +struct ad7689_dev *p_ad7689_dev_inst = NULL; + +/* Device attributes with default values */ + +/* Scale attribute value per channel */ +static float attr_scale_val[ADC_CHN_COUNT] = { + ADC_DEFAULT_SCALE, ADC_DEFAULT_SCALE, ADC_DEFAULT_SCALE, ADC_DEFAULT_SCALE, +#if !defined(DEV_AD7682) + ADC_DEFAULT_SCALE, ADC_DEFAULT_SCALE, ADC_DEFAULT_SCALE, ADC_DEFAULT_SCALE, +#endif + TEMPERATURE_CONV_SCALE +}; + +/* AD7689 current configuration */ +struct ad7689_config ad7689_current_config; + +/******************************************************************************/ +/************************** Functions Declarations ****************************/ +/******************************************************************************/ + +/******************************************************************************/ +/************************ Functions Definitions *******************************/ +/******************************************************************************/ + +/*! + * @brief Getter/Setter for the sampling frequency attribute value + * @param device- pointer to IIO device structure + * @param buf- pointer to buffer holding attribute value + * @param len- length of buffer string data + * @param channel- pointer to IIO channel structure + * @param id- Attribute ID (optional) + * @return Number of characters read/written + * @Note This attribute is used to define the timeout period in IIO + * client during data capture. + * Timeout = (number of requested samples * (1/sampling frequency)) + 1sec + * e.g. if sampling frequency = 60KSPS and requested samples = 400 + * Timeout = (400 * (1/60000)) + 1 = 1.0067sec = ~1sec + */ +static int get_sampling_frequency(void *device, + char *buf, + uint32_t len, + const struct iio_ch_info *channel, + intptr_t id) +{ + return sprintf(buf, "%d", SAMPLING_RATE); +} + +static int set_sampling_frequency(void *device, + char *buf, + uint32_t len, + const struct iio_ch_info *channel, + intptr_t id) +{ + /* sampling frequency is read-only attribute */ + return len; +} + + +/*! + * @brief Getter/Setter for the raw, offset and scale attribute value + * @param device- pointer to IIO device structure + * @param buf- pointer to buffer holding attribute value + * @param len- length of buffer string data + * @param channel- pointer to IIO channel structure + * @param id- Attribute ID (optional) + * @return Number of characters read/written + */ +static int get_adc_raw(void *device, + char *buf, + uint32_t len, + const struct iio_ch_info *channel, + intptr_t id) +{ + static uint32_t adc_data_raw = 0; + int32_t offset = 0; + int32_t ret; + + switch (id) { + case IIO_RAW_ATTR_ID: + /* Capture the raw adc data */ + ret = read_single_sample((uint8_t)channel->ch_num, &adc_data_raw); + if (ret) { + return sprintf(buf, " %s", "Error"); + } + return sprintf(buf, "%d", adc_data_raw); + + case IIO_SCALE_ATTR_ID: + return sprintf(buf, "%g", attr_scale_val[channel->ch_num]); + + case IIO_OFFSET_ATTR_ID: +#if defined(BIPOLAR) + if (channel->ch_num == TEMPERATURE_CHN) { + offset = 0; + } else { + if (adc_data_raw >= ADC_MAX_COUNT_BIPOLAR) { + offset = -ADC_MAX_COUNT_UNIPOLAR; + } else { + offset = 0; + } + } +#endif + return sprintf(buf, "%d", offset); + + default: + break; + } + + return len; +} + +static int set_adc_raw(void *device, + char *buf, + uint32_t len, + const struct iio_ch_info *channel, + intptr_t id) +{ + /* ADC raw, offset and scale are read-only attributes */ + return len; +} + +/** + * @brief Read buffer data corresponding to AD4170 IIO device + * @param iio_dev_data[in] - Pointer to IIO device data structure + * @return 0 in case of success, negative error code otherwise + */ +static int32_t iio_ad7689_submit_buffer(struct iio_device_data *iio_dev_data) +{ + uint32_t ret; + + /* Read the samples counts equal to buffer size/block */ + ret = read_buffered_data(&iio_dev_data->buffer->buf->buff, + iio_dev_data->buffer->size); + + /* Increment the write spin count as buffer reads all 'n' samples + * in one go which is also the size of buffer block for a given instance. + * The read spin count is incremented from IIO library during buffer + * write/offloading into transmit buffer */ + if (iio_dev_data->buffer->buf->write.spin_count >= UINT32_MAX) { + iio_dev_data->buffer->buf->write.spin_count = 0; + } + + iio_dev_data->buffer->buf->write.spin_count += 1; + + return ret; +} + +/** + * @brief Transfer the device data into memory (optional) + * @param dev_instance[in] - IIO device instance + * @param ch_mask[in] - Channels select mask + * @return 0 in case of success, negative error code otherwise + */ +static int32_t iio_ad7689_prepare_transfer(void *dev_instance, + uint32_t ch_mask) +{ + return prepare_data_transfer(ch_mask, ADC_CHN_COUNT, BYTES_PER_SAMPLE); +} + +/** + * @brief Perform tasks before end of current data transfer + * @param dev[in] - IIO device instance + * @return 0 in case of success, negative error code otherwise + */ +static int32_t iio_ad7689_end_transfer(void *dev) +{ + return end_data_transfer(); +} + +/********************************************************* + * IIO Attributes and Structures + ********************************************************/ + +/* IIOD channels attributes list */ +struct iio_attribute channel_input_attributes[] = { + { + .name = "raw", + .show = get_adc_raw, + .store = set_adc_raw, + .priv = IIO_RAW_ATTR_ID + }, + { + .name = "scale", + .show = get_adc_raw, + .store = set_adc_raw, + .priv = IIO_SCALE_ATTR_ID + }, + { + .name = "offset", + .show = get_adc_raw, + .store = set_adc_raw, + .priv = IIO_OFFSET_ATTR_ID + }, + + END_ATTRIBUTES_ARRAY +}; + +/* IIOD context attributes list */ +static struct iio_context_attribute iio_context_attributes[] = { + { + .name = "hw_mezzanine", + .value = HW_MEZZANINE_NAME + }, + { + .name = "hw_carrier", + .value = HW_CARRIER_NAME + }, + { + .name = "hw_name", + .value = HW_NAME + }, + END_ATTRIBUTES_ARRAY +}; + +/* IIOD device (global) attributes list */ +static struct iio_attribute global_attributes[] = { + { + .name = "sampling_frequency", + .show = get_sampling_frequency, + .store = set_sampling_frequency, + }, + + END_ATTRIBUTES_ARRAY +}; + +/* IIOD channels configurations */ +struct scan_type chn_scan = { +#if defined(BIPOLAR) + .sign = 's', +#else + .sign = 'u', +#endif + .realbits = CHN_STORAGE_BITS, + .storagebits = CHN_STORAGE_BITS, + .shift = 0, + .is_big_endian = false +}; + +static struct iio_channel iio_ad7689_channels[] = { + { + .name = "voltage0", + .ch_type = IIO_VOLTAGE, + .channel = 0, + .scan_index = 0, + .scan_type = &chn_scan, + .attributes = channel_input_attributes, + .ch_out = false, + .indexed = true, + }, + { + .name = "voltage1", + .ch_type = IIO_VOLTAGE, + .channel = 1, + .scan_index = 1, + .scan_type = &chn_scan, + .attributes = channel_input_attributes, + .ch_out = false, + .indexed = true + }, + { + .name = "voltage2", + .ch_type = IIO_VOLTAGE, + .channel = 2, + .scan_index = 2, + .scan_type = &chn_scan, + .attributes = channel_input_attributes, + .ch_out = false, + .indexed = true + }, + { + .name = "voltage3", + .ch_type = IIO_VOLTAGE, + .channel = 3, + .scan_index = 3, + .scan_type = &chn_scan, + .attributes = channel_input_attributes, + .ch_out = false, + .indexed = true + }, +#if !defined(DEV_AD7682) + { + .name = "voltage4", + .ch_type = IIO_VOLTAGE, + .channel = 4, + .scan_index = 4, + .scan_type = &chn_scan, + .attributes = channel_input_attributes, + .ch_out = false, + .indexed = true + }, + { + .name = "voltage5", + .ch_type = IIO_VOLTAGE, + .channel = 5, + .scan_index = 5, + .scan_type = &chn_scan, + .attributes = channel_input_attributes, + .ch_out = false, + .indexed = true + }, + { + .name = "voltage6", + .ch_type = IIO_VOLTAGE, + .channel = 6, + .scan_index = 6, + .scan_type = &chn_scan, + .attributes = channel_input_attributes, + .ch_out = false, + .indexed = true + }, + { + .name = "voltage7", + .ch_type = IIO_VOLTAGE, + .channel = 7, + .scan_index = 7, + .scan_type = &chn_scan, + .attributes = channel_input_attributes, + .ch_out = false, + .indexed = true + }, +#endif + { + .name = "temperature", + .ch_type = IIO_TEMP, +#if !defined(DEV_AD7682) + .channel = 8, + .scan_index = 8, +#else + .channel = 4, + .scan_index = 4, +#endif + .scan_type = &chn_scan, + .attributes = channel_input_attributes, + .ch_out = false, + .indexed = true + }, +}; + + +/** + * @brief Init for reading/writing and parameterization of a + * ad7689 IIO device + * @param desc[in,out] - IIO device descriptor + * @return 0 in case of success, negative error code otherwise + */ +static int32_t iio_ad7689_init(struct iio_device **desc) +{ + struct iio_device *iio_ad7689_inst; + + iio_ad7689_inst = calloc(1, sizeof(struct iio_device)); + if (!iio_ad7689_inst) { + return -EINVAL; + } + + iio_ad7689_inst->num_ch = sizeof(iio_ad7689_channels) / sizeof( + iio_ad7689_channels[0]); + iio_ad7689_inst->channels = iio_ad7689_channels; + iio_ad7689_inst->attributes = global_attributes; + iio_ad7689_inst->context_attributes = iio_context_attributes; + + iio_ad7689_inst->submit = iio_ad7689_submit_buffer; + iio_ad7689_inst->pre_enable = iio_ad7689_prepare_transfer; + iio_ad7689_inst->post_disable = iio_ad7689_end_transfer; + + iio_ad7689_inst->debug_reg_read = NULL; + iio_ad7689_inst->debug_reg_write = NULL; + + *desc = iio_ad7689_inst; + + return 0; +} + +/** + * @brief Initialize the IIO interface for AD7689 IIO device + * @return none + * @return 0 in case of success, negative error code otherwise + */ +int32_t ad7689_iio_initialize(void) +{ + int32_t init_status; + + /* IIO device descriptor */ + struct iio_device *p_iio_ad7689_dev; + + /* IIO interface init parameters */ + struct iio_init_param iio_init_params = { + .phy_type = USE_UART, + .nb_devs = 1, + }; + + /* IIOD init parameters */ + struct iio_device_init iio_device_init_params = { + .name = (char *)dev_name, + .raw_buf = adc_data_buffer, + .raw_buf_len = DATA_BUFFER_SIZE + }; + + /* Init the system peripherals */ + init_status = init_system(); + if (init_status) { + return init_status; + } + + /* Initialize AD7689 device and peripheral interface */ + init_status = ad7689_init(&p_ad7689_dev_inst, &ad7689_init_params); + if (init_status) { + return init_status; + } + + /* Initialize the AD7689 IIO application interface */ + init_status = iio_ad7689_init(&p_iio_ad7689_dev); + if (init_status) { + return init_status; + } + + /* Initialize the IIO interface */ + iio_init_params.uart_desc = uart_desc; + iio_device_init_params.dev = p_ad7689_dev_inst; + iio_device_init_params.dev_descriptor = p_iio_ad7689_dev; + iio_init_params.devs = &iio_device_init_params; + init_status = iio_init(&p_ad7689_iio_desc, &iio_init_params); + if (init_status) { + return init_status; + } + + /* Load the init config into current configuration */ + memcpy(&ad7689_current_config, &ad7689_init_params.config, + sizeof(ad7689_current_config)); + + return 0; +} + +/** + * @brief Run the AD7689 IIO event handler + * @return none + * @details This function monitors the new IIO client event + */ +void ad7689_iio_event_handler(void) +{ + (void)iio_step(p_ad7689_iio_desc); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/ad7689_iio.h Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,43 @@ +/***************************************************************************//** +* @file ad7689_iio.h +* @brief Header file for AD7689 IIO interface +******************************************************************************** +* Copyright (c) 2021 Analog Devices, Inc. +* All rights reserved. +* +* This software is proprietary to Analog Devices, Inc. and its licensors. +* By using this software you agree to the terms of the associated +* Analog Devices Software License Agreement. +*******************************************************************************/ +#ifndef _AD7689_IIO_H_ +#define _AD7689_IIO_H_ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ + +#include "iio.h" +#include "iio_types.h" +#include "ad7689.h" + +/******************************************************************************/ +/********************** Macros and Constants Definition ***********************/ +/******************************************************************************/ + +/******************************************************************************/ +/********************** Public/Extern Declarations ****************************/ +/******************************************************************************/ + +/* AD7689 global device instance for accessing device specific APIs */ +extern struct ad7689_dev *p_ad7689_dev_inst; + +/* AD7689 current device config */ +extern struct ad7689_config ad7689_current_config; + +/* Init the IIO interface */ +int32_t ad7689_iio_initialize(void); + +/* Run the IIO event handler */ +void ad7689_iio_event_handler(void); + +#endif /* _AD7689_IIO_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/ad7689_user_config.c Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,48 @@ +/***************************************************************************//** + * @file ad7689_user_config.c + * @brief User configurations for AD7689 No-OS driver +******************************************************************************** +* Copyright (c) 2021-22 Analog Devices, Inc. +* All rights reserved. +* +* This software is proprietary to Analog Devices, Inc. and its licensors. +* By using this software you agree to the terms of the associated +* Analog Devices Software License Agreement. +*******************************************************************************/ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ + +#include "ad7689_user_config.h" +#include "app_config.h" + +/******************************************************************************/ +/********************* Macros and Constants Definition ************************/ +/******************************************************************************/ + +/******************************************************************************/ +/******************** Variables and User Defined Data Types *******************/ +/******************************************************************************/ + +/* AD7689 No-OS driver init parameters */ +struct ad7689_init_param ad7689_init_params = { + .id = ACTIVE_DEVICE, + + .config = { + .incc = ADC_INPUT_TYPE_CFG, + .inx = 0, + .bw = AD7689_BW_FULL, + .ref = ADC_REF_VOLTAGE_CFG, + .seq = AD7689_SEQ_DISABLE, + .rb = false + }, + + .spi_init = { + .max_speed_hz = 22500000, + .mode = NO_OS_SPI_MODE_0, + .chip_select = SPI_CSB, + .platform_ops = &spi_ops, + .extra = &spi_extra_init_params + } +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/ad7689_user_config.h Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,50 @@ +/***************************************************************************//* + * @file ad7689_user_config.h + * @brief User configurations for AD7689 No-OS driver +****************************************************************************** + * Copyright (c) 2021 Analog Devices, Inc. + * All rights reserved. + * + * This software is proprietary to Analog Devices, Inc. and its licensors. + * By using this software you agree to the terms of the associated + * Analog Devices Software License Agreement. +******************************************************************************/ + +#ifndef _AD7689_USER_CONFIG_H_ +#define _AD7689_USER_CONFIG_H_ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ + +#include "ad7689.h" + +/******************************************************************************/ +/********************** Macros and Constants Definition ***********************/ +/******************************************************************************/ + +/* Select Input type (one at a time- default is unipolar) */ +#define UNIPOLAR +//#define BIPOLAR + +/* Default ADC channel config (for all channels) + * Note: DO NOT SELECT TYPE AS 'AD7689_TEMPERATURE_SENSOR'. The input type is set to + * to 'temperature' during temperature channel scanning at run-time. + **/ +#if defined(UNIPOLAR) +#define ADC_INPUT_TYPE_CFG AD7689_UNIPOLAR_GND +#else +#define ADC_INPUT_TYPE_CFG AD7689_BIPOLAR_COM +#endif + +/* Default ADC reference voltage configurations (temperature sensor enabled by default) */ +#define ADC_REF_VOLTAGE_CFG AD7689_REF_EXTERNAL_TEMP_IBUF +#define ADC_DEFAULT_REF_VOLTAGE 5.0 + +/******************************************************************************/ +/********************** Public/Extern Declarations ****************************/ +/******************************************************************************/ + +extern struct ad7689_init_param ad7689_init_params; + +#endif /* _AD7689_USER_CONFIG_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/app_config.c Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,218 @@ +/***************************************************************************//** + * @file app_config.c + * @brief Application configurations module (platform-agnostic) + * @details This module performs the system configurations +******************************************************************************** + * Copyright (c) 2021-22 Analog Devices, Inc. + * All rights reserved. + * + * This software is proprietary to Analog Devices, Inc. and its licensors. + * By using this software you agree to the terms of the associated + * Analog Devices Software License Agreement. +*******************************************************************************/ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ + +#include <stdbool.h> + +#include "app_config.h" +#include "ad7689_data_capture.h" +#include "no_os_error.h" +#include "no_os_uart.h" +#include "no_os_gpio.h" +#include "no_os_irq.h" +#include "no_os_pwm.h" + +/******************************************************************************/ +/************************ Macros/Constants ************************************/ +/******************************************************************************/ + +/******************************************************************************/ +/******************** Variables and User Defined Data Types *******************/ +/******************************************************************************/ + +/* UART init parameters */ +static struct no_os_uart_init_param uart_init_params = { + .device_id = NULL, + .baud_rate = IIO_UART_BAUD_RATE, + .size = NO_OS_UART_CS_8, + .parity = NO_OS_UART_PAR_NO, + .stop = NO_OS_UART_STOP_1_BIT, + .extra = &uart_extra_init_params +}; + +/* LED GPO init parameters */ +static struct no_os_gpio_init_param led_gpio_init_params = { + .number = LED_GPO, + .platform_ops = &gpio_ops, + .extra = NULL +}; + +/* External interrupt init parameters */ +static struct no_os_irq_init_param ext_int_init_params = { + .irq_ctrl_id = 0, + .platform_ops = &irq_ops, + .extra = &ext_int_extra_init_params +}; + +/* External interrupt callback descriptor */ +static struct no_os_callback_desc ext_int_callback_desc = { + data_capture_callback, + NULL, + NULL +}; + +/* PWM init parameters */ +static struct no_os_pwm_init_param pwm_init_params = { + .id = 0, + .period_ns = CONV_TRIGGER_PERIOD_NSEC, // PWM period in nsec + .duty_cycle_ns = CONV_TRIGGER_DUTY_CYCLE_NSEC, // PWM duty cycle in nsec + .extra = &pwm_extra_init_params +}; + +/* LED GPO descriptor */ +struct no_os_gpio_desc *led_gpio_desc; + +/* UART descriptor */ +struct no_os_uart_desc *uart_desc; + +/* External interrupt descriptor */ +struct no_os_irq_ctrl_desc *ext_int_desc; + +/* PWM descriptor */ +struct no_os_pwm_desc *pwm_desc; + +/******************************************************************************/ +/************************** Functions Declarations ****************************/ +/******************************************************************************/ + +/******************************************************************************/ +/************************** Functions Definitions *****************************/ +/******************************************************************************/ + +/** + * @brief Initialize the GPIOs + * @return 0 in case of success, negative error code otherwise + */ +static int32_t init_gpio(void) +{ + int32_t ret; + + /* Initialize the LED GPO */ + ret = no_os_gpio_get_optional(&led_gpio_desc, &led_gpio_init_params); + if (ret) { + return ret; + } + + ret = no_os_gpio_direction_output(led_gpio_desc, NO_OS_GPIO_HIGH); + if (ret) { + return ret; + } + + return 0; +} + +/** + * @brief Initialize the UART peripheral + * @return 0 in case of success, negative error code otherwise + */ +static int32_t init_uart(void) +{ + return no_os_uart_init(&uart_desc, &uart_init_params); +} + +/** + * @brief Initialize the IRQ contoller + * @return 0 in case of success, negative error code otherwise + */ +static int32_t init_interrupt(void) +{ + int32_t ret; + + /* Init interrupt controller for external interrupt */ + ret = no_os_irq_ctrl_init(&ext_int_desc, &ext_int_init_params); + if (ret) { + return ret; + } + + /* Register a callback function for external interrupt */ + ret = no_os_irq_register_callback(ext_int_desc, + EXT_INT_ID, + &ext_int_callback_desc); + if (ret) { + return ret; + } + + /* Enable external interrupt */ + ret = no_os_irq_enable(ext_int_desc, EXT_INT_ID); + if (ret) { + return ret; + } + + return 0; +} + +/** + * @brief Initialize the PWM contoller + * @return 0 in case of success, negative error code otherwise + */ +static int32_t init_pwm(void) +{ + int32_t ret; + + /* Initialize the PWM interface to generate PWM signal + * on conversion trigger event pin */ + ret = no_os_pwm_init(&pwm_desc, &pwm_init_params); + if (ret) { + return ret; + } + + ret = no_os_pwm_enable(pwm_desc); + if (ret) { + return ret; + } + + return 0; +} + +/** + * @brief Initialize the system peripherals + * @return 0 in case of success, negative error code otherwise + */ +int32_t init_system(void) +{ + int32_t ret; + + ret = init_gpio(); + if (ret) { + return ret; + } + + ret = init_uart(); + if (ret) { + return ret; + } + +#if (DATA_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE) + ret = init_interrupt(); + if (ret) { + return ret; + } + + ret = init_pwm(); + if (ret) { + return ret; + } +#endif + +#if defined(USE_SDRAM_CAPTURE_BUFFER) + ret = sdram_init(); + if (ret) { + return ret; + } +#endif + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/app_config.h Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,161 @@ +/***************************************************************************//* + * @file app_config.h + * @brief Header file for application configurations (platform-agnostic) +****************************************************************************** + * Copyright (c) 2021-22 Analog Devices, Inc. + * All rights reserved. + * + * This software is proprietary to Analog Devices, Inc. and its licensors. + * By using this software you agree to the terms of the associated + * Analog Devices Software License Agreement. +******************************************************************************/ + +#ifndef _APP_CONFIG_H_ +#define _APP_CONFIG_H_ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ + +#include <stdint.h> + +/******************************************************************************/ +/********************** Macros and Constants Definition ***********************/ +/******************************************************************************/ + +/* List of supported platforms */ +#define MBED_PLATFORM 1 + +/* List of data capture modes */ +#define CONTINUOUS_DATA_CAPTURE 0 +#define BURST_DATA_CAPTURE 1 + +/* Macros for stringification */ +#define XSTR(s) #s +#define STR(s) XSTR(s) + +/******************************************************************************/ + +/**** ACTIVE_DEVICE selection ***** +* Define the device type here from the available list of devices (one at a time) +* e.g. #define DEV_AD7689 -> This will make AD7689 as an ACTIVE_DEVICE. +**/ +//#define DEV_AD7689 + +/* Name of the active device */ +#if defined(DEV_AD7689) +#define ACTIVE_DEVICE ID_AD7689 +#define ACTIVE_DEVICE_NAME "ad7689" +#elif defined(DEV_AD7682) +#define ACTIVE_DEVICE ID_AD7682 +#define ACTIVE_DEVICE_NAME "ad7682" +#elif defined(DEV_AD7949) +#define ACTIVE_DEVICE ID_AD7949 +#define ACTIVE_DEVICE_NAME "ad7949" +#elif defined(DEV_AD7699) +#define ACTIVE_DEVICE ID_AD7699 +#define ACTIVE_DEVICE_NAME "ad7699" +#else +#warning No/Unsupported device selected. AD7689 used as default. +#define ACTIVE_DEVICE ID_AD7689 +#define ACTIVE_DEVICE_NAME "ad7689" +#endif + +/* Select the active platform (default is Mbed) */ +#if !defined(ACTIVE_PLATFORM) +#define ACTIVE_PLATFORM MBED_PLATFORM +#endif + +/* Select the ADC data capture mode (default is CC mode) */ +#if !defined(DATA_CAPTURE_MODE) +#define DATA_CAPTURE_MODE CONTINUOUS_DATA_CAPTURE +#endif + +#if (ACTIVE_PLATFORM == MBED_PLATFORM) +#include "app_config_mbed.h" + +#define HW_CARRIER_NAME STR(TARGET_NAME) + +/* Redefine the init params structure mapping w.r.t. platform */ +#define ext_int_extra_init_params mbed_ext_int_extra_init_params +#define pwm_extra_init_params mbed_pwm_extra_init_params +#define uart_extra_init_params mbed_uart_extra_init_params +#define spi_extra_init_params mbed_spi_extra_init_params +#define irq_ops mbed_irq_ops +#define gpio_ops mbed_gpio_ops +#define spi_ops mbed_spi_ops +#define EXT_INT_ID EXTERNAL_INT_ID1 +#else +#error "No/Invalid active platform selected" +#endif + +/* TODO - These values must be read from EEPROM of target EVB */ +#define HW_MEZZANINE_NAME "EVAL-AD7689-EBZ" +#define HW_NAME ACTIVE_DEVICE_NAME + +/* ADC resolution for active device */ +#if defined(DEV_AD7949) +#define ADC_RESOLUTION 14 +#else +#define ADC_RESOLUTION 16 +#endif + +/* ADC max count (full scale value) for unipolar inputs */ +#define ADC_MAX_COUNT_UNIPOLAR (uint32_t)((1 << ADC_RESOLUTION) - 1) + +/* ADC max count (full scale value) for bipolar inputs */ +#define ADC_MAX_COUNT_BIPOLAR (uint32_t)(1 << (ADC_RESOLUTION-1)) + +/* Max number of ADC channels */ +#if defined(DEV_AD7682) +#define TEMPERATURE_CHN 4 +#define ADC_CHN_COUNT 5 // Chn0-3 + 1 temperature channel +#else +#define TEMPERATURE_CHN 8 +#define ADC_CHN_COUNT 9 // Chn0-7 + 1 temperature channel +#endif + +/****** Macros used to form a VCOM serial number ******/ +#if !defined(DEVICE_NAME) +#define DEVICE_NAME "DEV_AD7689" +#endif + +/* Used to form a VCOM serial number */ +#if !defined(FIRMWARE_NAME) +#define FIRMWARE_NAME "ad7689_iio_application" +#endif + +#if !defined(PLATFORM_NAME) +#define PLATFORM_NAME HW_CARRIER_NAME +#endif +/******/ + +/* Enable the UART/VirtualCOM port connection (default VCOM) */ +//#define USE_PHY_COM_PORT // Uncomment to select UART + +#if !defined(USE_PHY_COM_PORT) +/* Below USB configurations (VID and PID) are owned and assigned by ADI. + * If intended to distribute software further, use the VID and PID owned by your + * organization */ +#define VIRTUAL_COM_PORT_VID 0x0456 +#define VIRTUAL_COM_PORT_PID 0xb66c +/* Serial number string is formed as: application name + device (target) name + platform (host) name */ +#define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" PLATFORM_NAME) +#endif + +/* Default baud rate for IIO UART interface */ +#define IIO_UART_BAUD_RATE (230400) + +/* Enable/Disable the use of SDRAM for ADC data capture buffer */ +//#define USE_SDRAM_CAPTURE_BUFFER // Uncomment to use SDRAM as data buffer + +/******************************************************************************/ +/********************** Public/Extern Declarations ****************************/ +/******************************************************************************/ + +extern struct no_os_uart_desc *uart_desc; +extern struct no_os_gpio_desc *led_gpio_desc; + +int32_t init_system(void); + +#endif /* _APP_CONFIG_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/app_config_mbed.c Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,67 @@ +/***************************************************************************//** + * @file app_config_mbed.c + * @brief Application configurations module for Mbed platform +******************************************************************************** + * Copyright (c) 2021-22 Analog Devices, Inc. + * All rights reserved. + * + * This software is proprietary to Analog Devices, Inc. and its licensors. + * By using this software you agree to the terms of the associated + * Analog Devices Software License Agreement. +*******************************************************************************/ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ + +#include <stdbool.h> +#include "app_config.h" +#include "app_config_mbed.h" + +/******************************************************************************/ +/************************ Macros/Constants ************************************/ +/******************************************************************************/ + +/******************************************************************************/ +/******************** Variables and User Defined Data Types *******************/ +/******************************************************************************/ + +/* UART Mbed platform specific init parameters */ +struct mbed_uart_init_param mbed_uart_extra_init_params = { +#if defined(USE_PHY_COM_PORT) + .virtual_com_enable = false, + .uart_tx_pin = UART_TX, + .uart_rx_pin = UART_RX +#else + .virtual_com_enable = true, + .vendor_id = VIRTUAL_COM_PORT_VID, + .product_id = VIRTUAL_COM_PORT_PID, + .serial_number = VIRTUAL_COM_SERIAL_NUM +#endif +}; + +/* External interrupt Mbed platform specific parameters */ +struct mbed_irq_init_param mbed_ext_int_extra_init_params = { + .int_mode = EXT_IRQ_FALL, + .ext_int_pin = INT_EVENT, + .int_obj_type = NULL +}; + +struct mbed_pwm_init_param mbed_pwm_extra_init_params = { + .pwm_pin = PWM_TRIGGER +}; + +/* SPI Mbed platform specific parameters */ +struct mbed_spi_init_param mbed_spi_extra_init_params = { + .spi_clk_pin = SPI_SCK, + .spi_miso_pin = SPI_HOST_SDI, + .spi_mosi_pin = SPI_HOST_SDO +}; + +/******************************************************************************/ +/************************** Functions Declarations ****************************/ +/******************************************************************************/ + +/******************************************************************************/ +/************************** Functions Definitions *****************************/ +/******************************************************************************/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/app_config_mbed.h Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,71 @@ +/***************************************************************************//** + * @file app_config_mbed.h + * @brief Header file for Mbed platform configurations +******************************************************************************** + * Copyright (c) 2021-22 Analog Devices, Inc. + * All rights reserved. + * + * This software is proprietary to Analog Devices, Inc. and its licensors. + * By using this software you agree to the terms of the associated + * Analog Devices Software License Agreement. +*******************************************************************************/ + +#ifndef APP_CONFIG_MBED_H_ +#define APP_CONFIG_MBED_H_ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ + +#include <stdint.h> +#include <PinNames.h> + +#include "mbed_uart.h" +#include "mbed_irq.h" +#include "mbed_spi.h" +#include "mbed_pwm.h" +#include "mbed_gpio.h" + +#if defined(TARGET_SDP_K1) +#include "sdram_sdpk1.h" +#endif + +/******************************************************************************/ +/********************** Macros and Constants Definition ***********************/ +/******************************************************************************/ + +/* Pin mapping of SDP-K1 w.r.t Arduino connector */ +#define SPI_CSB ARDUINO_UNO_D10 +#define SPI_HOST_SDO ARDUINO_UNO_D11 +#define SPI_HOST_SDI ARDUINO_UNO_D12 +#define SPI_SCK ARDUINO_UNO_D13 + +/* Pins used to trigger and/or read a new (periodic) conversion event */ +#define PWM_TRIGGER ARDUINO_UNO_D3 +#define INT_EVENT ARDUINO_UNO_D3 + +/* Common pin mapping on SDP-K1 */ +#define UART_TX CONSOLE_TX +#define UART_RX CONSOLE_RX +#define LED_GPO LED3 + +/* Define the max possible sampling (or output data) rate for a given platform. + * This is also used to find the time period to trigger a periodic conversion event. + * Note: Max possible ODR is 62.5KSPS per channel for continuous data capture on + * IIO client. This is derived by testing the firmware on SDP-K1 controller board + * @22Mhz SPI clock. The max possible ODR can vary from board to board and + * data continuity is not guaranteed above this ODR on IIO oscilloscope */ +#define SAMPLING_RATE (62500) +#define CONV_TRIGGER_PERIOD_NSEC (((float)(1.0 / SAMPLING_RATE) * 1000000) * 1000) +#define CONV_TRIGGER_DUTY_CYCLE_NSEC (CONV_TRIGGER_PERIOD_NSEC / 2) + +/******************************************************************************/ +/********************** Public/Extern Declarations ****************************/ +/******************************************************************************/ + +extern struct mbed_irq_init_param mbed_ext_int_extra_init_params; +extern struct mbed_pwm_init_param mbed_pwm_extra_init_params; +extern struct mbed_uart_init_param mbed_uart_extra_init_params; +extern struct mbed_spi_init_param mbed_spi_extra_init_params; + +#endif /* APP_CONFIG_MBED_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main.c Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,53 @@ +/***************************************************************************//** + * @file main.c + * @brief Main interface for AD7689 IIO firmware application +******************************************************************************** +* Copyright (c) 2021-22 Analog Devices, Inc. +* All rights reserved. +* +* This software is proprietary to Analog Devices, Inc. and its licensors. +* By using this software you agree to the terms of the associated +* Analog Devices Software License Agreement. +*******************************************************************************/ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ + +#include <stdio.h> +#include <stdint.h> + +#include "ad7689_iio.h" +#include "no_os_error.h" + +/******************************************************************************/ +/********************* Macros and Constants Definition ************************/ +/******************************************************************************/ + +/******************************************************************************/ +/******************** Variables and User Defined Data Types *******************/ +/******************************************************************************/ + +/******************************************************************************/ +/************************** Functions Declarations ****************************/ +/******************************************************************************/ + +/******************************************************************************/ +/************************** Functions Definitions *****************************/ +/******************************************************************************/ + +/* @brief Main function + * @details This is a main entry function for AD7689 IIO application + */ +int main(void) +{ + /* Initialize the AD7689 IIO interface */ + if (ad7689_iio_initialize()) { + printf("IIO initialization failure!!\r\n"); + } + + while (1) { + /* Monitor the IIO client events */ + ad7689_iio_event_handler(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/no-OS.lib Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,1 @@ +https://github.com/analogdevicesinc/no-OS/#bc621a71a741656d86eddc7900d50bfc80385e05
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/sdp_k1_sdram.lib Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/AnalogDevices/code/sdp_k1_sdram/#c02d2095090a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/sdram_sdpk1.c Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,35 @@ +/***************************************************************************//** + * @file sdram_sdpk1.c + * @brief SDP-K1 SDRAM interfaces +******************************************************************************** + * Copyright (c) 2022 Analog Devices, Inc. + * All rights reserved. + * + * This software is proprietary to Analog Devices, Inc. and its licensors. + * By using this software you agree to the terms of the associated + * Analog Devices Software License Agreement. +*******************************************************************************/ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ + +#include "sdp_k1_sdram.h" +#include "no_os_error.h" + +/******************************************************************************/ +/************************ Functions Definitions *******************************/ +/******************************************************************************/ + +/** + * @brief Initialize the SDP-K1 SDRAM + * @return 0 in case of success, negative error code otherwise + */ +int32_t sdram_init(void) +{ + if (SDP_SDRAM_Init() != SDRAM_OK) { + return -EIO; + } + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/sdram_sdpk1.h Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,36 @@ +/***************************************************************************//** + * @file sdram_sdpk1.c + * @brief SDP-K1 SDRAM interfaces header file +******************************************************************************** + * Copyright (c) 2022 Analog Devices, Inc. + * All rights reserved. + * + * This software is proprietary to Analog Devices, Inc. and its licensors. + * By using this software you agree to the terms of the associated + * Analog Devices Software License Agreement. +*******************************************************************************/ + +#ifndef SDRAM_SDPK1_ +#define SDRAM_SDPK1_ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ + +#include <stdint.h> + +/******************************************************************************/ +/********************** Macros and Constants Definition ***********************/ +/******************************************************************************/ + +/* SDRAM configs for SDP-K1 */ +#define SDRAM_START_ADDRESS (volatile int8_t *)0xC0000000 +#define SDRAM_SIZE_BYTES (16777216) // 16MBytes + +/******************************************************************************/ +/************************ Public Declarations *********************************/ +/******************************************************************************/ + +int32_t sdram_init(void); + +#endif /* end of SDRAM_SDPK1_ */
--- a/main.cpp Mon May 24 09:14:55 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* Copyright (c) 2019 Analog Devices, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - Modified versions of the software must be conspicuously marked as such. - - This software is licensed solely and exclusively for use with processors/products - manufactured by or for Analog Devices, Inc. - - This software may not be combined or merged with other code in any manner - that would cause the software to become subject to terms and conditions which - differ from those listed here. - - Neither the name of Analog Devices, Inc. nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - The use of this software may or may not infringe the patent rights of one or - more patent holders. This license does not release you from the requirement - that you obtain separate licenses from these patent holders to use this software. - -THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, -TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL -PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -2019-01-10-7CBSD SLA -*/ - -#include "mbed.h" - -// LED Blinking rate in milliseconds (Note: need to define the unit of a time duration i.e. seconds(s) or milliseconds(ms)) -#define SLEEP_TIME 500ms - -// Initialise the digital pin that controls LED1 -DigitalOut led(LED1); -// Initialise the serial object with TX and RX pins -static BufferedSerial serial_port(USBTX, USBRX); - -// The File handler is needed to allow printf commands to write to the terminal -FileHandle *mbed::mbed_override_console(int fd) -{ - return &serial_port; -} - -// main() runs in its own thread in the OS -int main() -{ - // printing the Mbed OS version this example was written to the console - printf("This Application has been developed on Mbed OS version 6.4\r\n"); - - // printing the actual Mbed OS version that this application is using to the console. - printf( - "Mbed OS version %d.%d.%d is what this applicaiton is currently using\r\n", - MBED_MAJOR_VERSION, - MBED_MINOR_VERSION, - MBED_PATCH_VERSION - ); - - // The loop will toggle the LED every 500ms(SLEEP_TIME = 500ms) and print LED1s current state to the terminal - while (1) { - led = !led; // toggle LED1 state - printf("LED1 state: %d \r\n", (uint8_t)led); - ThisThread::sleep_for(SLEEP_TIME); - } -} -
--- a/mbed-os.lib Mon May 24 09:14:55 2021 +0000 +++ b/mbed-os.lib Thu Jul 21 16:45:24 2022 +0530 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#8ef0a435b2356f8159dea8e427b2935d177309f8 +https://github.com/ARMmbed/mbed-os/#2eb06e76208588afc6cb7580a8dd64c5429a10ce
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed_app.json Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,23 @@ +{ + "config": { + "usb_speed": { + "help": "USE_USB_OTG_FS or USE_USB_OTG_HS or USE_USB_HS_IN_FS", + "value": "USE_USB_OTG_HS" + } + }, + "requires": ["bare-metal", "drivers-usb", "events"], + "macros": [ + "TINYIIOD_VERSION_MAJOR=0", + "TINYIIOD_VERSION_MINOR=1", + "TINYIIOD_VERSION_GIT=\"0.1\"", + "IIOD_BUFFER_SIZE=0x1000", + "_USE_STD_INT_TYPES" + ], + "target_overrides": { + "*": { + "platform.default-serial-baud-rate": 230400, + "target.printf_lib": "std", + "target.device_has_remove": ["CAN"] + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/ad7689_data_capture.py Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,157 @@ +import numpy as np +from time import sleep +from pynput import keyboard +import sys +import select +import os +import csv +import math +from adi import ad7689 + +# Global variables +line = 0 +writer = 0 +run_continuous = False +iterations = 0 +data_capture_abort = False +chn_count = 0 +data_list = [] + +def key_press_event(key): + global data_capture_abort + data_capture_abort = True + +def init_data_capture(): + global device + global data_list + global chn_count + global listener + global samples_block + + ######## User configuration ########## + # Configure the backend for PC to IIOD interface + uri = "serial:COM11,230400" # For UART, baud rate must be same as set in the FW. COM port is physical Or VCOM. + device_name = "ad7689" # Name of the device must be same as set in the FW. + ###################################### + + # Create an IIO device context + device = ad7689(uri, device_name) + device._ctx.set_timeout(100000) + + ######## User configuration ########## + # Channels to be captured + device.rx_enabled_channels = ["voltage0", "voltage1", "voltage2", "voltage3", "voltage4", "voltage5", "voltage6", "voltage7", "temp8"] + + # The block of samples to be captured. Total samples are received in multiple iterations or blocks + samples_block = 400 # The samples needs to be captured in smaller blocks due to limitations + # of buffer size (RAM) in the firmware and IIO client timeout factor. + # Request to capture samples more than buffer size, will be ignored by firmware. + # Large time taken to read the samples from device, may cause timeout on IIO client. + ###################################### + + # Get the channels count from user + chn_count = len(device.rx_enabled_channels) + + # Store the rx buffer size and rx data type based on input channels + device.rx_buffer_size = samples_block # Size of the IIO buffer (buffer is submitted during call to rx() method) + device._rx_data_type = np.uint16 # size of ADC sample + + listener = keyboard.Listener(on_press=key_press_event) + listener.start() + +def read_user_inputs(): + global iterations + global run_continuous + global device + global samples_block + + samples_count = int(input("Enter the number of samples to be captured \n\ + 0: Unlimited \n\ + <50-1000000>: ")) + + if (samples_count == 0): + run_continuous = True + else: + run_continuous = False + if (samples_count <= samples_block): + device.rx_buffer_size = samples_count + iterations = 1 + else: + iterations = math.ceil(samples_count / samples_block) + +def init_data_logger(): + global writer + global chn_count + + file_name = "adc_data_capture.csv" + current_dir = os.getcwd() + output_file = os.path.join(current_dir, file_name) + result_file = open(output_file, 'w', newline="") + writer = csv.writer(result_file) + row = [] + # Write the channels list header + for chn in range(0,chn_count): + item = "Ch {}".format(chn) + row.insert(chn, item) + writer.writerow(row) + +def read_buffered_data(): + global line + global writer + global device + + # Receive data from device + data = device.rx() + if (line == 0): + print("Data capture started >>") + print("."*line, end="\r") + + if (chn_count == 1): + # Convert 1-D array to 2-D array + data_arr = np.reshape(data, (-1,1)) + else: + # Transpose data from N-D data array + data_arr = np.transpose(data) + + writer.writerows(data_arr) + + line = line+1 + if (line == 100): + line = 1 + print("\n", end="\r") + +def do_data_capture(): + global data_capture_abort + done = False + + if (run_continuous == True): + print("Press any key to stop data capture..") + sleep(2) + data_capture_abort = False + while not data_capture_abort: + read_buffered_data() + else: + for val in range(0,iterations): + read_buffered_data() + + print("\r\nData capture finished\r\n") + +def exit(): + global listener + global writer + global device + + # Delete the objects + del listener + del writer + del device + +def main(): + init_data_capture() + init_data_logger() + read_user_inputs() + do_data_capture() + exit() + +if __name__ == "__main__": + main() \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/requirements.txt Thu Jul 21 16:45:24 2022 +0530 @@ -0,0 +1,5 @@ +numpy==1.22.4 +pyadi-iio==0.0.13 +pylibiio==0.23.1 +pynput==1.7.6 +pyserial==3.5 \ No newline at end of file