AD4130 Mbed IIO Firmware

Dependencies:   tempsensors sdp_k1_sdram

Files at this revision

API Documentation at this revision

Comitter:
MPhalke@MPHALKE-L02.ad.analog.com
Date:
Fri Jul 15 17:47:44 2022 +0530
Parent:
1:e35d29042687
Commit message:
AD4130 firmware - initial commit

Changed in this revision

.gitignore Show annotated file Show diff for this revision Revisions of this file
LICENSE.md Show diff for this revision Revisions of this file
License.txt Show annotated file Show diff for this revision Revisions of this file
README.txt Show annotated file Show diff for this revision Revisions of this file
app/.mbedignore Show annotated file Show diff for this revision Revisions of this file
app/ad4130_data_capture.c Show annotated file Show diff for this revision Revisions of this file
app/ad4130_data_capture.h Show annotated file Show diff for this revision Revisions of this file
app/ad4130_ecg_config.c Show annotated file Show diff for this revision Revisions of this file
app/ad4130_ecg_config.h Show annotated file Show diff for this revision Revisions of this file
app/ad4130_iio.c Show annotated file Show diff for this revision Revisions of this file
app/ad4130_iio.h Show annotated file Show diff for this revision Revisions of this file
app/ad4130_loadcell_config.c Show annotated file Show diff for this revision Revisions of this file
app/ad4130_loadcell_config.h Show annotated file Show diff for this revision Revisions of this file
app/ad4130_noise_test_config.c Show annotated file Show diff for this revision Revisions of this file
app/ad4130_noise_test_config.h Show annotated file Show diff for this revision Revisions of this file
app/ad4130_power_test_config.c Show annotated file Show diff for this revision Revisions of this file
app/ad4130_power_test_config.h Show annotated file Show diff for this revision Revisions of this file
app/ad4130_regs.c Show annotated file Show diff for this revision Revisions of this file
app/ad4130_regs.h Show annotated file Show diff for this revision Revisions of this file
app/ad4130_rtd_config.c Show annotated file Show diff for this revision Revisions of this file
app/ad4130_rtd_config.h Show annotated file Show diff for this revision Revisions of this file
app/ad4130_support.c Show annotated file Show diff for this revision Revisions of this file
app/ad4130_support.h Show annotated file Show diff for this revision Revisions of this file
app/ad4130_temperature_sensor.cpp Show annotated file Show diff for this revision Revisions of this file
app/ad4130_temperature_sensor.h Show annotated file Show diff for this revision Revisions of this file
app/ad4130_thermistor_config.c Show annotated file Show diff for this revision Revisions of this file
app/ad4130_thermistor_config.h Show annotated file Show diff for this revision Revisions of this file
app/ad4130_thermocouple_config.c Show annotated file Show diff for this revision Revisions of this file
app/ad4130_thermocouple_config.h Show annotated file Show diff for this revision Revisions of this file
app/ad4130_user_config.c Show annotated file Show diff for this revision Revisions of this file
app/ad4130_user_config.h Show annotated file Show diff for this revision Revisions of this file
app/ad413x.c Show annotated file Show diff for this revision Revisions of this file
app/ad413x.h Show annotated file Show diff for this revision Revisions of this file
app/app_config.c Show annotated file Show diff for this revision Revisions of this file
app/app_config.h Show annotated file Show diff for this revision Revisions of this file
app/app_config_mbed.c Show annotated file Show diff for this revision Revisions of this file
app/app_config_mbed.h Show annotated file Show diff for this revision Revisions of this file
app/main.c Show annotated file Show diff for this revision Revisions of this file
app/no-OS.lib Show annotated file Show diff for this revision Revisions of this file
app/sdp_k1_sdram.lib Show annotated file Show diff for this revision Revisions of this file
app/sdram_sdpk1.c Show annotated file Show diff for this revision Revisions of this file
app/sdram_sdpk1.h Show annotated file Show diff for this revision Revisions of this file
app/tempsensors.lib Show annotated file Show diff for this revision Revisions of this file
docs/ad4130_evb_jumper_settings.xlsx Show annotated file Show diff for this revision Revisions of this file
main.cpp Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
scripts/ad4130.py Show annotated file Show diff for this revision Revisions of this file
scripts/ad4130_calibration.py Show annotated file Show diff for this revision Revisions of this file
scripts/ad4130_data_capture.py Show annotated file Show diff for this revision Revisions of this file
scripts/ad4130_sensor_measurement.py Show annotated file Show diff for this revision Revisions of this file
scripts/ad4130_xattr.py Show annotated file Show diff for this revision Revisions of this file
scripts/requirements.txt Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,19 @@
+*.swp
+*.profile*
+*.txt
+mbed-os
+app/sdp_k1_sdram/
+app/mbed_platform_drivers
+app/no-OS
+app/tempsensors
+Build
+Visual*
+Code*
+.gitattributes
+.vs/
+*.sln
+*.vgdbproj
+*.TMP
+*.user
+*.csv
+.mbed
\ No newline at end of file
--- a/LICENSE.md	Mon May 24 09:13:12 2021 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,205 +0,0 @@
-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.
-
-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.
-
-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.
-
-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.
-
-++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/License.txt	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,26 @@
+Analog Devices, Inc. (“ADI”)
+Source Code Software License Agreement
+20190709-LWSC-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 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.  
+
--- a/README.txt	Mon May 24 09:13:12 2021 +0000
+++ b/README.txt	Fri Jul 15 17:47:44 2022 +0530
@@ -1,45 +1,41 @@
 Evaluation Boards/Products Supported
 ------------------------------------ 
-EVAL-AD1234 (AD1234)
-EVAL-AD1256 (AD1256)
-<< add more here >>
- 
+-Products supported: AD4130
+
+
 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 evalute the AD4130 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: AD4130-8
+Product Evaluation board details: EVAL-AD4130-8WARDZ
+User Guide for this code: https://wiki.analog.com/resources/eval/user-guides/ad4130/mbed_iio_app
+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-AD4130 board and USB cable.
+Plug in the EVAL-AD4130 board on SDP-K1 board (or any other Mbed enabled controller board)
+using the Arduino connector (refer software wiki page for connection interface).
+Connect SDP-K1 board to the PC using the USB cable. AD4130 EVB is powered through USB supply of 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) 2022 Analog Devices, Inc.  All rights reserved.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/.mbedignore	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,64 @@
+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/ad76*
+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/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/ad4130_data_capture.c	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,776 @@
+/***************************************************************************//**
+ *   @file    ad4130_data_capture.c
+ *   @brief   AD4130 data capture interface for IIO based applications
+ *   @details This module handles the ADC 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 "app_config.h"
+#include "ad413x.h"
+#include "ad4130_support.h"
+#include "ad4130_iio.h"
+#include "ad4130_regs.h"
+#include "ad4130_data_capture.h"
+#include "ad4130_user_config.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
+
+/* Fifo depth limit (watermark count) for data capture */
+#define FIFO_SIZE		256		// Range: 1-256
+
+/******************************************************************************/
+/********************** 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 channels to be captured */
+static volatile uint8_t active_channels[ADC_USER_CHANNELS];
+
+/* Number of active channels */
+static volatile uint8_t num_of_active_channels;
+
+/* Current active channel index */
+static volatile uint8_t chn_indx;
+
+/* FIFO data capture flags */
+static volatile bool start_fifo_mode_data_capture = false;
+static volatile bool fifo_data_available = false;
+static uint32_t fifo_data[FIFO_SIZE];
+
+/******************************************************************************/
+/************************ Functions Declarations ******************************/
+/******************************************************************************/
+
+/******************************************************************************/
+/************************ Functions Definitions *******************************/
+/******************************************************************************/
+
+/*!
+ * @brief	Function to init the data capture for AD4130 device
+ * @return	0 in case of success, negative error code otherwise
+ */
+int32_t ad4130_data_capture_init(void)
+{
+	int32_t ret;
+	uint8_t preset;
+	adc_conv_int_source_e conv_int_source;
+
+	/* Stop any previous conversion */
+	ret = ad413x_set_adc_mode(ad4130_dev_inst, AD413X_STANDBY_MODE);
+	if (ret) {
+		return ret;
+	}
+
+	/* Select and enable the interupt pin source for data conversion monitor */
+#if defined(AD4130_WLCSP_PACKAGE_TYPE)
+	conv_int_source = INT_PIN;
+#else
+	conv_int_source = CLK_PIN;
+#endif
+
+	ret = ad413x_set_int_source(ad4130_dev_inst, conv_int_source);
+	if (ret) {
+		return ret;
+	}
+
+	/* Set the filter FS value (same for all setups/channels for
+	 * consistant ODR/sample rate) */
+	for (preset = 0; preset <= ADC_PRESETS; preset++) {
+		ret = ad413x_set_filter_fs(ad4130_dev_inst, AD4130_FS_CONFIG, preset);
+		if (ret) {
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+/*!
+ * @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 mask = 0x1;
+	uint8_t index = 0;
+	uint8_t chn;
+	int32_t ret;
+
+	/* Enable/Disable channels based on channel mask set in the IIO client */
+	for (chn = 0; chn < ADC_USER_CHANNELS; chn++) {
+		if (chn_mask & mask) {
+			/* Store the active channel */
+			active_channels[index++] = chn;
+			num_of_active_channels++;
+
+			/* Enable the selected channel */
+			ret = ad413x_ch_en(ad4130_dev_inst, chn, 1);
+		} else {
+			/* Disable the selected channel */
+			ret = ad413x_ch_en(ad4130_dev_inst, chn, 0);
+		}
+
+		if (ret) {
+			return ret;
+		}
+
+		mask <<= 1;
+	}
+
+	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;
+
+	/* Stop any previous conversion */
+	ret = ad413x_set_adc_mode(ad4130_dev_inst, AD413X_STANDBY_MODE);
+	if (ret) {
+		return ret;
+	}
+
+	/* Trigger new conversion */
+	ret = ad413x_set_adc_mode(ad4130_dev_inst, AD413X_CONTINOUS_CONV_MODE);
+	if (ret) {
+		return ret;
+	}
+
+	return 0;
+}
+
+/*!
+ * @brief	Stop a data capture from continuous/burst/fifo mode
+ * @return	0 in case of success, negative error code otherwise
+ */
+static int32_t adc_stop_data_capture(void)
+{
+	/* Stop any active conversion */
+	return ad413x_set_adc_mode(ad4130_dev_inst, AD413X_STANDBY_MODE);
+}
+
+/*!
+ * @brief	Trigger a data capture in FIFO mode
+ * @return	0 in case of success, negative error code otherwise
+ */
+static int32_t adc_start_fifo_data_capture(void)
+{
+	int32_t ret;
+	uint32_t fifo_control_reg_val;
+
+	/* Read FIFO control register */
+	ret = ad413x_reg_read(ad4130_dev_inst, AD413X_REG_FIFO_CTRL,
+			      &fifo_control_reg_val);
+	if (ret) {
+		return ret;
+	}
+
+	/* Store the watermark count in FIFO */
+	fifo_control_reg_val = (fifo_control_reg_val & ~AD413X_WATERMARK_MSK) |
+			       AD413X_WATERMARK(FIFO_SIZE);
+
+	/* Select the FIFO mode to enable FIFO and enable watermark interrupt */
+	fifo_control_reg_val = (fifo_control_reg_val & ~AD4130_FIFO_MODE_MSK) |
+			       AD413X_FIFO_MODE(FIFO_OLDEST_SAVE_MODE) |
+			       AD413X_WATERMARK_INT_EN;
+
+	/* Disable the FIFO header and status (FIFO status and header is not appended to data) */
+	fifo_control_reg_val &= ~(AD413X_ADD_FIFO_HEADER | AD413X_ADD_FIFO_STATUS);
+
+	/* Write to ADC fifo_ctrl register */
+	ret = ad413x_reg_write(ad4130_dev_inst, AD413X_REG_FIFO_CTRL,
+			       fifo_control_reg_val);
+	if (ret) {
+		return ret;
+	}
+
+	start_fifo_mode_data_capture = true;
+	ret = adc_start_data_capture();
+	if (ret) {
+		return ret;
+	}
+
+	return 0;
+}
+
+/*!
+ * @brief	Read a single sample of ADC
+ * @param	adc_raw[in] - Pointer to ADC raw data variable
+ * @return	0 in case of success, negative error code otherwise
+ */
+static int32_t adc_read_single_sample(uint32_t *adc_raw)
+{
+	if (!adc_raw) {
+		return -EINVAL;
+	}
+
+	return ad413x_mon_conv_and_read_data(ad4130_dev_inst, adc_raw);
+}
+
+/*!
+ * @brief	Read a single sample of ADC
+ * @param	data[in] - Pointer to FIFO data array
+ * @param	samples[in] - Number of samples to read
+ * @return	0 in case of success, negative error code otherwise
+ */
+static int32_t adc_read_fifo(uint32_t *data, uint32_t samples)
+{
+	if (!data) {
+		return -EINVAL;
+	}
+
+	return ad4130_read_fifo(ad4130_dev_inst, data, samples);
+}
+
+/*!
+ * @brief	Read ADC raw data for recently sampled channel
+ * @param	adc_data[in, out] - Pointer to adc data read variable
+ * @param	input_chn[in] - Input channel (optional)
+ * @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.
+ *			Continuous conversion mode is used to for this operation.
+ */
+static int32_t adc_read_converted_sample(uint32_t *adc_data,
+		uint8_t input_chn)
+{
+	if (!adc_data) {
+		return -EINVAL;
+	}
+
+	/* Read the ADC data for previously sampled channel in sequencer */
+	return ad413x_reg_read(ad4130_dev_inst, AD413X_REG_DATA, adc_data);
+}
+
+/*!
+ * @brief	Function to 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
+ * @note	The single conversion mode is used to read a single sample
+ */
+int32_t read_single_sample(uint8_t input_chn, uint32_t *adc_raw)
+{
+	uint32_t chn_mask = 0;
+	uint8_t chn;
+	int32_t ret;
+
+	if (!adc_raw) {
+		return -EINVAL;
+	}
+
+	/* Disable all active channels */
+	for (chn = 0; chn < ADC_USER_CHANNELS; chn++) {
+		if (ad4130_dev_inst->ch[chn].enable) {
+			chn_mask |= (1 << chn);
+
+			/* Disable the current channel */
+			ret = ad413x_ch_en(ad4130_dev_inst, chn, 0);
+			if (ret) {
+				return ret;
+			}
+		}
+	}
+
+	/* Enable user input channel */
+	if (!ad4130_dev_inst->ch[input_chn].enable) {
+		ret = ad413x_ch_en(ad4130_dev_inst, input_chn, 1);
+		if (ret) {
+			return ret;
+		}
+	}
+
+	/* Put device into single conversion mode */
+	ret = ad413x_set_adc_mode(ad4130_dev_inst, AD413X_SINGLE_CONV_MODE);
+	if (ret) {
+		return ret;
+	}
+
+	/* Monitor conversion and read the result */
+	ret = ad413x_mon_conv_and_read_data(ad4130_dev_inst, adc_raw);
+
+	/* Disable user input channel */
+	ret = ad413x_ch_en(ad4130_dev_inst, input_chn, 0);
+	if (ret) {
+		return ret;
+	}
+
+	return 0;
+}
+
+/********* Device Independent Data Capture Code Begin ************/
+
+/*!
+ * @brief	Reset the data capture specific variables
+ * @return	none
+ */
+static void reset_data_capture(void)
+{
+	/* Reset data capture flags */
+	start_cont_data_capture = false;
+	start_fifo_mode_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	Function to prepare the data ADC capture for new READBUFF
+ *			request from IIO client (for active channels)
+ * @param	ch_mask[in] - Channels to enable for data capturing
+ * @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 ch_mask, uint8_t sample_size)
+{
+	int32_t ret;
+
+	/* Reset data capture module specific flags and variables */
+	reset_data_capture();
+
+	sample_size_in_bytes = sample_size;
+
+	/* Store active channels */
+	ret = adc_store_active_chns(ch_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 ADC data capture
+ * @return	0 in case of success, negative error code otherwise
+ */
+int32_t end_data_transfer(void)
+{
+	int32_t ret;
+	start_cont_data_capture = false;
+
+	/* Stop data capture */
+	ret = adc_stop_data_capture();
+	if (ret) {
+		return ret;
+	}
+
+	/* 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,
+					       active_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	This is an ISR (Interrupt Service Routine) to monitor FIFO data available event.
+ *			This function is expected to be called asynchronously when data from internal device
+ *			FIFO is available to read.
+ * @param	ctx[in] - Callback context (unused)
+ * @return	none
+ */
+void fifo_data_capture_callback(void *ctx)
+{
+	if (start_fifo_mode_data_capture) {
+		fifo_data_available = true;
+	}
+}
+
+/*!
+ * @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)
+{
+	uint32_t sample_indx = 0;
+	uint32_t adc_raw;
+	int32_t ret;
+
+	if (!pbuf) {
+		return -EINVAL;
+	}
+
+	ret = adc_start_data_capture();
+	if (ret) {
+		return ret;
+	}
+
+	while (sample_indx < nb_of_samples) {
+		ret = adc_read_single_sample(&adc_raw);
+		if (ret) {
+			return ret;
+		}
+
+		/* Copy adc samples into acquisition buffer to transport over
+		 * communication link */
+		memcpy((uint8_t *)pbuf, &adc_raw, sample_size_in_bytes);
+		pbuf += sample_size_in_bytes;
+
+		sample_indx++;
+	}
+
+	/* Stop any active conversion */
+	ret = adc_stop_data_capture();
+	if (ret) {
+		return ret;
+	}
+
+	return 0;
+}
+
+/*!
+ * @brief	Capture requested number of ADC samples in FIFO mode
+ * @param	pbuf[in] - Input buffer
+ * @param	nb_of_samples[in] - Number of samples to read
+ * @return	0 in case of success, negative error code otherwise
+ */
+static int32_t read_fifo_data(int8_t *pbuf,
+			      uint32_t nb_of_samples)
+{
+	uint32_t sample_cnt;
+	uint32_t remaining_samples = nb_of_samples;
+	uint32_t timeout = BUF_READ_TIMEOUT;
+	int32_t ret;
+
+	if (!pbuf) {
+		return -EINVAL;
+	}
+
+	fifo_data_available = false;
+
+	ret = adc_start_fifo_data_capture();
+	if (ret) {
+		return ret;
+	}
+
+	/* Read all requeted samples into acquisition buffer */
+	do {
+		/* Wait for new FIFO event */
+		timeout = BUF_READ_TIMEOUT;
+		do {
+			timeout--;
+		} while ((!fifo_data_available) && (timeout > 0));
+
+		if (timeout == 0) {
+			return -EIO;
+		}
+
+		fifo_data_available = false;
+
+		if (remaining_samples > FIFO_SIZE) {
+			nb_of_samples = FIFO_SIZE;
+			remaining_samples -= nb_of_samples;
+		} else {
+			nb_of_samples = remaining_samples;
+			remaining_samples = 0;
+		}
+
+		/* Read data from FIFO and store into local buffer */
+		ret = adc_read_fifo(fifo_data, nb_of_samples);
+		if (ret) {
+			return ret;
+		}
+
+		/* Read offloaded FIFO data and store into acquisition buffer */
+		for (sample_cnt = 0; sample_cnt < nb_of_samples; sample_cnt++) {
+			memcpy(pbuf, &fifo_data[sample_cnt], sample_size_in_bytes);
+			pbuf += sample_size_in_bytes;
+		}
+	} while (remaining_samples > 0);
+
+	/* Stop any active conversion */
+	ret = adc_stop_data_capture();
+	if (ret) {
+		return ret;
+	}
+
+	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;
+
+	if (!pbuf) {
+		return -EINVAL;
+	}
+
+	/* 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);
+#elif (DATA_CAPTURE_MODE == FIFO_DATA_CAPTURE)
+	ret = read_fifo_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/ad4130_data_capture.h	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,52 @@
+/***************************************************************************//**
+ *   @file   ad4130_data_capture.h
+ *   @brief  Header for AD4130 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 AD4130_DATA_CAPTURE_H_
+#define AD4130_DATA_CAPTURE_H_
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stddef.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 ad4130_data_capture_init(void);
+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 sample_size);
+int32_t end_data_transfer(void);
+void data_capture_callback(void *ctx);
+void fifo_data_capture_callback(void *ctx);
+
+#endif /* AD4130_DATA_CAPTURE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_ecg_config.c	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,68 @@
+/*************************************************************************//**
+ *   @file   ad4130_ecg_config.c
+ *   @brief  ECG user configurations file for AD4130 device
+******************************************************************************
+* 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 "app_config.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/******************************************************************************/
+/********************** Variables and User Defined Data Types *****************/
+/******************************************************************************/
+
+/* AD4130 device initialization parameters */
+struct ad413x_init_param ad4130_ecg_config_params = {
+	.spi_init = &spi_init_params,
+
+	/* Setup (Preset) Configurations */
+	.preset = {
+		// Setup 0
+		{
+			.ref_buf = {
+				.ref_buf_p_en = true,
+				.ref_buf_m_en = true,
+			},
+			.ref_sel = AD413X_REFOUT_AVSS,
+			.gain = AD413X_GAIN_8,
+			.filter = AD4130_FILTER_TYPE,
+			.s_time = AD413X_32_MCLK
+		},
+	},
+
+	/* Chnnel Configurations */
+	.ch = {
+		// Chn0
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 1,
+			.ain_p = AD413X_AIN11,
+			.ain_m = AD413X_AIN14
+		},
+	},
+
+	.chip_id = AD4130_8,
+	.mclk = AD413X_INT_76_8_KHZ_OUT_OFF,
+	.bipolar = true,
+	.int_ref = AD413X_INTREF_1_25V,
+	.standby_ctrl = {
+		.standby_int_ref_en = true,
+		.standby_vbias_en = true
+	},
+	.v_bias = NO_OS_BIT(15), 	// V_Bias on AIN15
+	.data_stat = 0,
+	.spi_crc_en = 0
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_ecg_config.h	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,43 @@
+/*************************************************************************//**
+ *   @file   ad4130_ecg_config.h
+ *   @brief  Header for AD4130 ECG user configuration 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 _AD4130_ECG_CONFIG_H_
+#define _AD4130_ECG_CONFIG_H_
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+
+#include <stdint.h>
+#include "ad413x.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/* Select FS (or ODR) for ECG config (applicable to all channels) */
+#define AD4130_FS_CONFIG				8	// ODR = 300SPS for SINC3/4 filter
+
+/* Filter type for ECG config
+ * Note: Applicable for all setups to keep the same ODR for all channels */
+#define AD4130_FILTER_TYPE				AD413X_SYNC3_STANDALONE
+
+/* Scaler factor used in FS to ODR conversion (For SINC3/4 filter) */
+#define FS_TO_ODR_CONV_SCALER			(32U * AD4130_FS_CONFIG)
+
+/******************************************************************************/
+/********************** Public/Extern Declarations ****************************/
+/******************************************************************************/
+
+extern struct ad413x_init_param ad4130_ecg_config_params;
+
+#endif /* end of _AD4130_ECG_CONFIG_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_iio.c	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,1154 @@
+/***************************************************************************//**
+ *   @file    ad4130_iio.c
+ *   @brief   Implementation of AD4130 IIO application interfaces
+ *   @details This module acts as an interface for AD4130 IIO application
+********************************************************************************
+ * Copyright (c) 2020-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 <stdint.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include "app_config.h"
+#include "ad4130_iio.h"
+#include "ad4130_data_capture.h"
+#include "ad4130_support.h"
+#include "ad4130_user_config.h"
+#include "ad4130_temperature_sensor.h"
+#include "ad4130_regs.h"
+#include "no_os_error.h"
+
+/******** Forward declaration of getter/setter functions ********/
+static int iio_ad4130_attr_get(void *device, char *buf, uint32_t len,
+			       const struct iio_ch_info *channel, intptr_t priv);
+
+static int iio_ad4130_attr_set(void *device, char *buf, uint32_t len,
+			       const struct iio_ch_info *channel, intptr_t priv);
+
+static int iio_ad4130_attr_available_get(void *device, char *buf,
+		uint32_t len,
+		const struct iio_ch_info *channel, intptr_t priv);
+
+static int iio_ad4130_attr_available_set(void *device, char *buf,
+		uint32_t len,
+		const struct iio_ch_info *channel, intptr_t priv);
+
+/******************************************************************************/
+/************************ Macros/Constants ************************************/
+/******************************************************************************/
+
+#define AD4130_CHN_ATTR(_name, _priv) {\
+	.name = _name,\
+	.priv = _priv,\
+	.show = iio_ad4130_attr_get,\
+	.store = iio_ad4130_attr_set\
+}
+
+#define AD4130_CHN_AVAIL_ATTR(_name, _priv) {\
+	.name = _name,\
+	.priv = _priv,\
+	.show = iio_ad4130_attr_available_get,\
+	.store = iio_ad4130_attr_available_set\
+}
+
+#define AD4130_CH(_name, _idx, _type) {\
+	.name = _name, \
+	.ch_type = _type,\
+	.ch_out = 0,\
+	.indexed = true,\
+	.channel = _idx,\
+	.scan_index = _idx,\
+	.scan_type = &chn_scan,\
+	.attributes = ad4130_iio_ch_attributes\
+}
+
+/* Minimum sampling frequency supported/configured in the firmware.
+ * Note: This is not an actual device sampling frequency.
+ * It is just used for IIO oscilloscope timeout calculations. */
+#define AD4130_MIN_SAMPLING_FREQ	(50 / ADC_USER_CHANNELS)
+
+/* Default offset value for AD4130 */
+#define AD4130_DEFAULT_OFFSET		0x800000
+
+/* 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(uint32_t)	// For ADC resolution of 24-bits
+
+/* Number of data storage bits (needed for IIO client to plot ADC data) */
+#define CHN_STORAGE_BITS	(BYTES_PER_SAMPLE * 8)
+
+/* Number of adc samples for loadcell calibration */
+#define LOADCELL_SAMPLES_COUNT	10
+
+/* CJC channel is 1 (common sensor for all Thermocouples).
+ * Chn0 is used for TC connections */
+#define CJC_CHANNEL		1
+
+/* Shunt resistance (in ohms) for AVDD/IOVDD current calculation */
+#define I_RSENSE	10
+
+/* Multiplier for AVDD/IOVDD voltage calculation */
+#define V_SCALE		6
+
+/******************************************************************************/
+/*************************** Types Declarations *******************************/
+/******************************************************************************/
+
+/* IIO interface descriptor */
+static struct iio_desc *p_ad4130_iio_desc;
+
+/**
+ * Device name.
+ */
+static const char dev_name[] = ACTIVE_DEVICE_NAME;
+
+/**
+ * Pointer to the struct representing the AD4130 IIO device
+ */
+struct ad413x_dev *ad4130_dev_inst = NULL;
+
+/* Device attributes with default values */
+
+/* Scale attribute value per channel */
+static float attr_scale_val[ADC_USER_CHANNELS];
+
+/* IIOD channels scan structure */
+static struct scan_type chn_scan;
+
+/* AD4130 Attribute IDs */
+enum ad4130_attribute_id {
+	RAW_ATTR_ID,
+	SCALE_ATTR_ID,
+	OFFSET_ATTR_ID,
+	SAMPLING_FREQ_ATTR_ID,
+	DEMO_CONFIG_ATTR_ID,
+	INTERNAL_CALIB_ID,
+	SYSTEM_CALIB_ID,
+	LOADCELL_GAIN_CALIB_ID,
+	LOADCELL_OFFSET_CALIB_ID,
+};
+
+/* Calibration state */
+enum calibration_state {
+	FULL_SCALE_CALIB_STATE,
+	ZERO_SCALE_CALIB_STATE,
+	CALIB_COMPLETE_STATE
+};
+
+/* Calibration status */
+enum calib_status {
+	CALIB_NOT_DONE,
+	CALIB_IN_PROGRESS,
+	CALIB_DONE,
+	CALIB_ERROR,
+	CALIB_SKIPPED
+};
+
+/* ADC calibration configs */
+typedef struct {
+	uint32_t gain_before_calib;
+	uint32_t gain_after_calib;
+	uint32_t offset_before_calib;
+	uint32_t offset_after_calib;
+} adc_calibration_configs;
+
+/* ADC calibration variables */
+static enum calibration_state system_calibration_state = ZERO_SCALE_CALIB_STATE;
+static enum calibration_state internal_calibration_state =
+	FULL_SCALE_CALIB_STATE;
+static enum calib_status adc_calibration_status[ADC_USER_CHANNELS];
+static adc_calibration_configs adc_calibration_config[ADC_USER_CHANNELS];
+
+/* IIOD channels attributes list */
+static struct iio_attribute ad4130_iio_ch_attributes[] = {
+	AD4130_CHN_ATTR("raw", RAW_ATTR_ID),
+	AD4130_CHN_ATTR("scale", SCALE_ATTR_ID),
+	AD4130_CHN_ATTR("offset", OFFSET_ATTR_ID),
+	AD4130_CHN_ATTR("internal_calibration", INTERNAL_CALIB_ID),
+	AD4130_CHN_ATTR("system_calibration", SYSTEM_CALIB_ID),
+#if (ACTIVE_DEMO_MODE_CONFIG == LOADCELL_CONFIG)
+	AD4130_CHN_ATTR("loadcell_gain_calibration", LOADCELL_GAIN_CALIB_ID),
+	AD4130_CHN_ATTR("loadcell_offset_calibration", LOADCELL_OFFSET_CALIB_ID),
+#endif
+	END_ATTRIBUTES_ARRAY
+};
+
+/* IIOD device (global) attributes list */
+static struct iio_attribute ad4130_iio_global_attributes[] = {
+	AD4130_CHN_ATTR("sampling_frequency", SAMPLING_FREQ_ATTR_ID),
+	AD4130_CHN_ATTR("demo_config", DEMO_CONFIG_ATTR_ID),
+	END_ATTRIBUTES_ARRAY
+};
+
+/* IIOD context attributes list */
+static struct iio_context_attribute ad4130_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
+};
+
+static struct iio_channel ad4130_iio_channels[] = {
+#if (ACTIVE_DEMO_MODE_CONFIG == THERMISTOR_CONFIG)
+	AD4130_CH("Sensor1", SENSOR_CHANNEL0, IIO_TEMP)
+#elif (ACTIVE_DEMO_MODE_CONFIG == RTD_3WIRE_CONFIG)
+	AD4130_CH("Sensor1", SENSOR_CHANNEL0, IIO_TEMP)
+#elif (ACTIVE_DEMO_MODE_CONFIG == RTD_2WIRE_CONFIG || \
+	   ACTIVE_DEMO_MODE_CONFIG == RTD_4WIRE_CONFIG)
+	AD4130_CH("Sensor1", SENSOR_CHANNEL0, IIO_TEMP)
+#elif (ACTIVE_DEMO_MODE_CONFIG == THERMOCOUPLE_CONFIG)
+	AD4130_CH("Sensor1", SENSOR_CHANNEL0, IIO_TEMP),
+	AD4130_CH("CJC", CJC_CHANNEL, IIO_TEMP),
+#elif (ACTIVE_DEMO_MODE_CONFIG == LOADCELL_CONFIG)
+	/* Note: Channel type is considered as voltage as IIO
+	 * oscilloscope doesn't support loadcell unit fomat of gram */
+	AD4130_CH("Sensor1", SENSOR_CHANNEL0, IIO_VOLTAGE),
+#elif (ACTIVE_DEMO_MODE_CONFIG == ECG_CONFIG)
+	AD4130_CH("Sensor1", SENSOR_CHANNEL0, IIO_VOLTAGE),
+#elif (ACTIVE_DEMO_MODE_CONFIG == NOISE_TEST_CONFIG)
+	AD4130_CH("Chn0", 0, IIO_VOLTAGE),
+#elif (ACTIVE_DEMO_MODE_CONFIG == POWER_TEST_CONFIG)
+	AD4130_CH("V_AVDD", POWER_TEST_V_AVDD_CHN, IIO_VOLTAGE),
+	AD4130_CH("V_IOVDD", POWER_TEST_V_IOVDD_CHN, IIO_VOLTAGE),
+	AD4130_CH("I_AVDD", POWER_TEST_I_AVDD_CHN, IIO_CURRENT),
+	AD4130_CH("I_IOVDD", POWER_TEST_I_IOVDD_CHN, IIO_CURRENT),
+	AD4130_CH("V_AVSS-DGND", POWER_TEST_V_AVSS_DGND_CHN, IIO_VOLTAGE),
+	AD4130_CH("V_REF", POWER_TEST_V_REF_CHN, IIO_VOLTAGE),
+#else
+	/* User default config */
+	AD4130_CH("Chn0", 0, IIO_VOLTAGE),
+	AD4130_CH("Chn1", 1, IIO_VOLTAGE),
+	AD4130_CH("Chn2", 2, IIO_VOLTAGE),
+	AD4130_CH("Chn3", 3, IIO_VOLTAGE),
+	AD4130_CH("Chn4", 4, IIO_VOLTAGE),
+	AD4130_CH("Chn5", 5, IIO_VOLTAGE),
+	AD4130_CH("Chn6", 6, IIO_VOLTAGE),
+	AD4130_CH("Chn7", 7, IIO_VOLTAGE),
+#if (ADC_USER_CHANNELS > 8)
+	AD4130_CH("Chn8", 8, IIO_VOLTAGE),
+	AD4130_CH("Chn9", 9, IIO_VOLTAGE),
+	AD4130_CH("Chn10", 10, IIO_VOLTAGE),
+	AD4130_CH("Chn11", 11, IIO_VOLTAGE),
+	AD4130_CH("Chn12", 12, IIO_VOLTAGE),
+	AD4130_CH("Chn13", 13, IIO_VOLTAGE),
+	AD4130_CH("Chn14", 14, IIO_VOLTAGE),
+	AD4130_CH("Chn15", 15, IIO_VOLTAGE)
+#endif
+#endif
+};
+
+/* ADC raw averaged values from loadcell calibration */
+static uint32_t adc_raw_offset;
+static uint32_t adc_raw_gain;
+
+/******************************************************************************/
+/************************ Functions Prototypes ********************************/
+/******************************************************************************/
+
+static void update_vltg_conv_scale_factor(uint8_t chn);
+static void perform_sensor_measurement_and_update_scale(uint32_t adc_raw,
+		uint16_t chn);
+static int get_calibration_status(char *buf,
+				  uint32_t len,
+				  uint8_t chn,
+				  intptr_t id);
+static int set_calibration_routine(char *buf,
+				   uint32_t len,
+				   uint8_t chn,
+				   intptr_t id);
+static int get_loadcell_calibration_status(char *buf,
+		uint32_t len,
+		uint8_t chn,
+		intptr_t id);
+static int set_loadcell_calibration_status(char *buf,
+		uint32_t len,
+		uint8_t chn,
+		intptr_t id);
+
+/******************************************************************************/
+/************************ Functions Definitions *******************************/
+/******************************************************************************/
+
+static char *get_demo_mode_config(void)
+{
+#if (ACTIVE_DEMO_MODE_CONFIG == RTD_2WIRE_CONFIG)
+	return "2-Wire RTD";
+#elif (ACTIVE_DEMO_MODE_CONFIG == RTD_3WIRE_CONFIG)
+	return "3-Wire RTD";
+#elif (ACTIVE_DEMO_MODE_CONFIG == RTD_4WIRE_CONFIG)
+	return "4-Wire RTD";
+#elif (ACTIVE_DEMO_MODE_CONFIG == THERMISTOR_CONFIG)
+	return "Thermistor";
+#elif (ACTIVE_DEMO_MODE_CONFIG == THERMOCOUPLE_CONFIG)
+	return "Thermocouple";
+#elif (ACTIVE_DEMO_MODE_CONFIG == LOADCELL_CONFIG)
+	return "Loadcell";
+#elif (ACTIVE_DEMO_MODE_CONFIG == ECG_CONFIG)
+	return "ECG";
+#elif (ACTIVE_DEMO_MODE_CONFIG == NOISE_TEST_CONFIG)
+	return "Noise Test";
+#elif (ACTIVE_DEMO_MODE_CONFIG == POWER_TEST_CONFIG)
+	return "Power Test";
+#else
+	return "User Default";
+#endif
+}
+
+/*!
+ * @brief	Getter functions for AD4130 attributes
+ * @param	device[in]- Pointer to IIO device instance
+ * @param	buf[in]- IIO input data buffer
+ * @param	len[in]- Number of input bytes
+ * @param	channel[in] - Input channel
+ * @param	priv[in] - Attribute private ID
+ * @return	0 in case of success, negative error code otherwise
+ * @Note	This sampling_frequency attribute is used to define the
+ *			timeout period in IIO client during data capture.
+ *			Timeout (1 chn) = (requested samples * sampling frequency) + 1sec
+ *			Timeout (n chns) = ((requested samples * n) / sampling frequency) + 1sec
+ *			e.g. If sampling frequency = 31.5KSPS, requested samples = 4000, n=1min or 8max
+ *			Timeout (1 chn) = (4000 / 315000) + 1 = ~1.13sec
+ *			Timeout (8 chns) = ((4000 * 8) / 315000) + 1 = ~2.01sec
+ */
+static int iio_ad4130_attr_get(void *device,
+			       char *buf,
+			       uint32_t len,
+			       const struct iio_ch_info *channel,
+			       intptr_t priv)
+{
+	uint32_t adc_data_raw;
+	int32_t offset = 0;
+	uint8_t bipolar;
+	uint32_t val;
+	int32_t	 ret;
+	uint8_t preset = ad4130_dev_inst->ch[channel->ch_num].preset;
+
+	val = no_os_str_to_uint32(buf);
+
+	switch (priv) {
+	case RAW_ATTR_ID:
+		/* Apply calibrated coefficients before new sampling */
+		if (adc_calibration_status[channel->ch_num] == CALIB_DONE) {
+			ret = ad413x_reg_write(ad4130_dev_inst,
+					       AD413X_REG_OFFSET(preset),
+					       adc_calibration_config[channel->ch_num].offset_after_calib);
+			if (ret) {
+				break;
+			}
+
+			ret = ad413x_reg_write(ad4130_dev_inst,
+					       AD413X_REG_GAIN(preset),
+					       adc_calibration_config[channel->ch_num].gain_after_calib);
+			if (ret) {
+				break;
+			}
+		}
+
+		/* Capture the raw adc data */
+		ret = read_single_sample((uint8_t)channel->ch_num, &adc_data_raw);
+		if (ret) {
+			break;
+		}
+
+		perform_sensor_measurement_and_update_scale(adc_data_raw, channel->ch_num);
+		return sprintf(buf, "%d", adc_data_raw);
+
+	case SCALE_ATTR_ID:
+		return snprintf(buf, len, "%.10f", attr_scale_val[channel->ch_num]);
+
+	case OFFSET_ATTR_ID:
+#if (ACTIVE_DEMO_MODE_CONFIG == USER_DEFAULT_CONFIG || \
+	 ACTIVE_DEMO_MODE_CONFIG == LOADCELL_CONFIG || \
+	 ACTIVE_DEMO_MODE_CONFIG == ECG_CONFIG || \
+	 ACTIVE_DEMO_MODE_CONFIG == NOISE_TEST_CONFIG || \
+	 ACTIVE_DEMO_MODE_CONFIG == POWER_TEST_CONFIG)
+		/* Note: For temperature type channels, the offset
+		 * is ignored, as signed conversion needed for IIO client
+		 * is done through perform_sensor_measurement_and_update_scale() */
+		bipolar = ad4130_dev_inst->bipolar;
+		if (bipolar) {
+			/* For IIO clients, the raw to voltage conversion happens
+			 * using formula: voltage = (adc_raw + offset) * scale
+			 * Offset is determined based on the coding scheme of device.
+			 * 'Offset binary coding' is used in bipolar mode while
+			 * 'Streight binary coding' is used in unipolar mode.
+			 * */
+			offset = -ADC_MAX_COUNT_BIPOLAR;
+		}
+#endif
+		return sprintf(buf, "%d", offset);
+
+	case SAMPLING_FREQ_ATTR_ID:
+		/* Sampling frequency for IIO oscilloscope timeout purpose.
+		 * Does not indicate an actual sampling rate of device.
+		 * Refer the 'note' in function description above for timeout calculations */
+		return sprintf(buf, "%d", AD4130_MIN_SAMPLING_FREQ);
+
+	case DEMO_CONFIG_ATTR_ID:
+		return sprintf(buf, "%s", get_demo_mode_config());
+
+	case INTERNAL_CALIB_ID:
+	case SYSTEM_CALIB_ID:
+		return get_calibration_status(buf, len, channel->ch_num, priv);
+
+	case LOADCELL_GAIN_CALIB_ID:
+	case LOADCELL_OFFSET_CALIB_ID:
+		return get_loadcell_calibration_status(buf, len, channel->ch_num, priv);
+
+	default:
+		break;
+	}
+
+	return len;
+}
+
+/*!
+ * @brief	Setter functions for AD4130 attributes
+ * @param	device[in]- Pointer to IIO device instance
+ * @param	buf[in]- IIO input data buffer
+ * @param	len[in]- Number of input bytes
+ * @param	channel[in] - Input channel
+ * @param	priv[in] - Attribute private ID
+ * @return	0 in case of success, negative error code otherwise
+ */
+static int iio_ad4130_attr_set(void *device,
+			       char *buf,
+			       uint32_t len,
+			       const struct iio_ch_info *channel,
+			       intptr_t priv)
+{
+	switch (priv) {
+	case RAW_ATTR_ID:
+	case SCALE_ATTR_ID:
+	case SAMPLING_FREQ_ATTR_ID:
+	case DEMO_CONFIG_ATTR_ID:
+		/* All are read-only attributes */
+		break;
+
+	case INTERNAL_CALIB_ID:
+	case SYSTEM_CALIB_ID:
+		return set_calibration_routine(buf, len, channel->ch_num, priv);
+
+	case LOADCELL_GAIN_CALIB_ID:
+	case LOADCELL_OFFSET_CALIB_ID:
+		return set_loadcell_calibration_status(buf, len, channel->ch_num, priv);
+
+	default:
+		break;
+	}
+
+	return len;
+}
+
+/*!
+ * @brief	Perform the ADC internal/system calibration
+ * @param	chn[in] - ADC channel
+ * @param	calib_mode[in] - ADC calibration mode
+ * @return	0 in case of success, negative error code otherwise
+ */
+static int32_t perform_adc_calibration(uint8_t chn,
+				       enum ad413x_adc_mode calib_mode)
+{
+	int32_t ret;
+	uint32_t data;
+	uint8_t preset = ad4130_dev_inst->ch[chn].preset;
+	uint8_t pga = ad4130_dev_inst->preset[preset].gain;
+
+	/* Put ADC into standby mode */
+	ret = ad413x_set_adc_mode(ad4130_dev_inst, AD413X_STANDBY_MODE);
+	if (ret) {
+		return ret;
+	}
+
+	/* Read the gain/offset coefficient values before calibration */
+	if ((calib_mode == AD413X_INT_GAIN_CAL)
+	    || (calib_mode == AD413X_SYS_GAIN_CAL)) {
+		if (calib_mode == AD413X_INT_GAIN_CAL) {
+			/* Write offset default value before internal gain calibration
+			 * as internal offset calibration is performed after internal
+			 * gain calibration */
+			ret = ad413x_reg_write(ad4130_dev_inst,
+					       AD413X_REG_OFFSET(preset),
+					       AD4130_DEFAULT_OFFSET);
+			if (ret) {
+				return ret;
+			}
+		}
+
+		ret = ad413x_reg_read(ad4130_dev_inst,
+				      AD413X_REG_GAIN(preset),
+				      &data);
+		if (ret) {
+			return ret;
+		}
+		adc_calibration_config[chn].gain_before_calib = data;
+	} else {
+		ret = ad413x_reg_read(ad4130_dev_inst,
+				      AD413X_REG_OFFSET(preset),
+				      &data);
+
+		if (ret) {
+			return ret;
+		}
+		adc_calibration_config[chn].offset_before_calib = data;
+	}
+
+	/* Enable channel for calibration */
+	ret = ad413x_ch_en(ad4130_dev_inst, chn, 1);
+	if (ret) {
+		return ret;
+	}
+
+	if ((calib_mode == AD413X_INT_GAIN_CAL)
+	    || (calib_mode == AD413X_SYS_GAIN_CAL)) {
+		if ((calib_mode == AD413X_INT_GAIN_CAL) && (pga == AD413X_GAIN_1)) {
+			/* Internal gain calibration is not supported at gain of 1 */
+			adc_calibration_config[chn].gain_after_calib =
+				adc_calibration_config[chn].gain_before_calib;
+			adc_calibration_status[chn] = CALIB_SKIPPED;
+			return 0;
+		}
+
+		/* Perform internal/system gain (full-scale) calibration */
+		ret = ad413x_set_adc_mode(ad4130_dev_inst, calib_mode);
+		if (ret) {
+			return ret;
+		}
+
+		/* Wait for conversion to finish */
+		no_os_mdelay(200);
+
+		/* Read the gain coefficient value (post calibrated) */
+		ret = ad413x_reg_read(ad4130_dev_inst,
+				      AD413X_REG_GAIN(preset),
+				      &data);
+		if (ret) {
+			return ret;
+		}
+		adc_calibration_config[chn].gain_after_calib = data;
+
+		/* Compare the pre and post adc calibration gain coefficients to check calibration status */
+		if (adc_calibration_config[chn].gain_after_calib ==
+		    adc_calibration_config[chn].gain_before_calib) {
+			/* Error in gain calibration */
+			return -EINVAL;
+		}
+	} else {
+		/* Perform internal/system offset (zero-scale) calibration */
+		ret = ad413x_set_adc_mode(ad4130_dev_inst, calib_mode);
+		if (ret) {
+			return ret;
+		}
+
+		/* Wait for conversion to finish */
+		no_os_mdelay(200);
+
+		/* Read the coefficient value (post calibrated) */
+		ret = ad413x_reg_read(ad4130_dev_inst,
+				      AD413X_REG_OFFSET(preset),
+				      &data);
+		if (ret) {
+			return ret;
+		}
+		adc_calibration_config[chn].offset_after_calib = data;
+
+		/* Compare the pre and post adc calibration offset coefficients to check calibration status */
+		if (adc_calibration_config[chn].offset_after_calib ==
+		    adc_calibration_config[chn].offset_before_calib) {
+			/* Error in offset calibration */
+			return -EINVAL;
+		}
+	}
+
+	/* Disable previously enabled channel */
+	ret = ad413x_ch_en(ad4130_dev_inst, chn, 0);
+	if (ret) {
+		return ret;
+	}
+
+	return 0;
+}
+
+/*!
+ * @brief	Getter for the ADC internal/system calibration
+ * @param	buf[in]- pointer to buffer holding attribute value
+ * @param	len[in]- length of buffer string data
+ * @param	chn[in]- ADC channel
+ * @param	id[in]- Attribute ID
+ * @return	Number of characters read/written
+ */
+static int get_calibration_status(char *buf,
+				  uint32_t len,
+				  uint8_t chn,
+				  intptr_t id)
+{
+	uint8_t buf_offset = 0;
+
+	switch (id) {
+	case SYSTEM_CALIB_ID:
+	case INTERNAL_CALIB_ID:
+		if (id == SYSTEM_CALIB_ID && system_calibration_state == CALIB_COMPLETE_STATE) {
+			system_calibration_state = ZERO_SCALE_CALIB_STATE;
+		} else if (id == INTERNAL_CALIB_ID
+			   && internal_calibration_state == CALIB_COMPLETE_STATE) {
+			internal_calibration_state = FULL_SCALE_CALIB_STATE;
+		} else {
+			if (adc_calibration_status[chn] != CALIB_ERROR
+			    && adc_calibration_status[chn] != CALIB_SKIPPED
+			    && adc_calibration_status[chn] != CALIB_IN_PROGRESS) {
+				/* Return NA to indicate that system calibration is not supported
+				 * using IIO oscilloscope. Pyadi-iio script needs to be executed
+				 * to perform a system calibration due to manual intervention
+				 **/
+				return snprintf(buf, len, "%s", "NA");
+			}
+		}
+
+		sprintf(buf + buf_offset, "%08x",
+			adc_calibration_config[chn].gain_before_calib);
+		buf_offset += 8;
+		sprintf(buf + buf_offset, "%08x",
+			adc_calibration_config[chn].gain_after_calib);
+		buf_offset += 8;
+		sprintf(buf + buf_offset, "%08x",
+			adc_calibration_config[chn].offset_before_calib);
+		buf_offset += 8;
+		sprintf(buf + buf_offset, "%08x",
+			adc_calibration_config[chn].offset_after_calib);
+		buf_offset += 8;
+
+		if (adc_calibration_status[chn] == CALIB_ERROR) {
+			sprintf(buf + buf_offset, "%s", "calibration_failed");
+			buf_offset += (strlen("calibration_failed") + 1);
+			adc_calibration_status[chn] = CALIB_NOT_DONE;
+		} else if (adc_calibration_status[chn] == CALIB_SKIPPED) {
+			sprintf(buf + buf_offset, "%s", "calibration_skipped");
+			buf_offset += (strlen("calibration_skipped") + 1);
+			adc_calibration_status[chn] = CALIB_NOT_DONE;
+		} else {
+			sprintf(buf + buf_offset, "%s", "calibration_done");
+			buf_offset += (strlen("calibration_done") + 1);
+		}
+
+		return buf_offset;
+
+	default:
+		return -EINVAL;
+	}
+
+	return len;
+}
+
+/*!
+ * @brief	Setter for the ADC internal/system calibration
+ * @param	buf[in]- pointer to buffer holding attribute value
+ * @param	len[in]- length of buffer string data
+ * @param	chn[in]- ADC channel
+ * @param	id[in]- Attribute ID
+ * @return	Number of characters read/written
+ */
+static int set_calibration_routine(char *buf,
+				   uint32_t len,
+				   uint8_t chn,
+				   intptr_t id)
+{
+	switch (id) {
+	case INTERNAL_CALIB_ID:
+		if (!strncmp(buf, "start_calibration", strlen(buf))) {
+			switch (internal_calibration_state) {
+			case FULL_SCALE_CALIB_STATE:
+				adc_calibration_status[chn] = CALIB_IN_PROGRESS;
+				if (perform_adc_calibration(chn,
+							    AD413X_INT_GAIN_CAL)) {
+					adc_calibration_status[chn] = CALIB_ERROR;
+				}
+				internal_calibration_state = ZERO_SCALE_CALIB_STATE;
+				break;
+
+			case ZERO_SCALE_CALIB_STATE:
+				if (perform_adc_calibration(chn,
+							    AD413X_INT_OFFSET_CAL)) {
+					adc_calibration_status[chn] = CALIB_ERROR;
+					internal_calibration_state = FULL_SCALE_CALIB_STATE;
+					break;
+				}
+				adc_calibration_status[chn] = CALIB_DONE;
+				internal_calibration_state = CALIB_COMPLETE_STATE;
+				break;
+
+			case CALIB_COMPLETE_STATE:
+			default:
+				internal_calibration_state = FULL_SCALE_CALIB_STATE;
+				break;
+			}
+		}
+		break;
+
+	case SYSTEM_CALIB_ID:
+		if (!strncmp(buf, "start_calibration", strlen(buf))) {
+			switch (system_calibration_state) {
+			case ZERO_SCALE_CALIB_STATE:
+				adc_calibration_status[chn] = CALIB_IN_PROGRESS;
+				if (perform_adc_calibration(chn,
+							    AD413X_SYS_OFFSET_CAL)) {
+					adc_calibration_status[chn] = CALIB_ERROR;
+				}
+				system_calibration_state = FULL_SCALE_CALIB_STATE;
+				break;
+
+			case FULL_SCALE_CALIB_STATE:
+				if (perform_adc_calibration(chn,
+							    AD413X_SYS_GAIN_CAL)) {
+					adc_calibration_status[chn] = CALIB_ERROR;
+					system_calibration_state = ZERO_SCALE_CALIB_STATE;
+					break;
+				}
+				adc_calibration_status[chn] = CALIB_DONE;
+				system_calibration_state = CALIB_COMPLETE_STATE;
+				break;
+
+			case CALIB_COMPLETE_STATE:
+			default:
+				system_calibration_state = ZERO_SCALE_CALIB_STATE;
+				break;
+			}
+		}
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	return len;
+}
+
+/*!
+ * @brief	Getter for the Loadcell offset/gain calibration
+ * @param	buf[in]- pointer to buffer holding attribute value
+ * @param	len[in]- length of buffer string data
+ * @param	chn[in]- ADC channel
+ * @param	id[in]- Attribute ID
+ * @return	Number of characters read/written
+ */
+static int get_loadcell_calibration_status(char *buf,
+		uint32_t len,
+		uint8_t chn,
+		intptr_t id)
+{
+	switch (id) {
+	case LOADCELL_OFFSET_CALIB_ID:
+		return sprintf(buf, "%d", adc_raw_offset);
+
+	case LOADCELL_GAIN_CALIB_ID:
+		return sprintf(buf, "%d", adc_raw_gain);
+
+	default:
+		return -EINVAL;
+	}
+
+	return len;
+}
+
+/*!
+ * @brief	Setter for the Loadcell offset/gain calibration
+ * @param	buf[in]- pointer to buffer holding attribute value
+ * @param	len[in]- length of buffer string data
+ * @param	chn[in]- ADC channel
+ * @param	id[in]- Attribute ID
+ * @return	Number of characters read/written
+ */
+static int set_loadcell_calibration_status(char *buf,
+		uint32_t len,
+		uint8_t chn,
+		intptr_t id)
+{
+	uint32_t adc_raw;
+	uint8_t sample_cnt;
+	uint64_t adc_raw_avg = 0;
+
+	if (!strncmp(buf, "start_calibration", strlen(buf))) {
+		switch (id) {
+		case LOADCELL_OFFSET_CALIB_ID:
+			for (sample_cnt = 0; sample_cnt < LOADCELL_SAMPLES_COUNT; sample_cnt++) {
+				read_single_sample(chn, &adc_raw);
+				adc_raw_avg += adc_raw;
+			}
+
+			adc_raw_avg /= LOADCELL_SAMPLES_COUNT;
+			adc_raw_offset = (uint32_t)adc_raw_avg;
+			break;
+
+		case LOADCELL_GAIN_CALIB_ID:
+			for (sample_cnt = 0; sample_cnt < LOADCELL_SAMPLES_COUNT; sample_cnt++) {
+				read_single_sample(chn, &adc_raw);
+				adc_raw_avg += adc_raw;
+			}
+
+			adc_raw_avg /= LOADCELL_SAMPLES_COUNT;
+			adc_raw_gain = (uint32_t)adc_raw_avg;
+			break;
+
+		default:
+			return -EINVAL;
+		}
+	}
+
+	return len;
+}
+
+/*!
+ * @brief	Read the debug register value
+ * @param	dev[in]- Pointer to IIO device instance
+ * @param	reg[in]- Register address to read from
+ * @param	readval[in,out]- Pointer to variable to read data into
+ * @return	0 in case of success or negative value otherwise
+ */
+int32_t debug_reg_read(void *dev, uint32_t reg, uint32_t *readval)
+{
+	int32_t ret;
+
+	if (!dev || !readval || (reg > MAX_REGISTER_ADDRESS)) {
+		return -EINVAL;
+	}
+
+	ret = ad413x_reg_read(dev, ad413x_regs[reg], readval);
+	if (ret) {
+		return ret;
+	}
+
+	return 0;
+}
+
+/*!
+ * @brief	Write into the debug register
+ * @param	dev[in]- Pointer to IIO device instance
+ * @param	reg[in]- Register address to write into
+ * @param	writeval[in]- Register value to write
+ * @return	0 in case of success or negative value otherwise
+ */
+int32_t debug_reg_write(void *dev, uint32_t reg, uint32_t writeval)
+{
+	int32_t ret;
+
+	if (!dev || (reg > MAX_REGISTER_ADDRESS)) {
+		return -EINVAL;
+	}
+
+	ret = ad413x_reg_write(dev, ad413x_regs[reg], writeval);
+	if (ret) {
+		return ret;
+	}
+
+	return 0;
+}
+
+/**
+ * @brief	Read buffer data corresponding to AD4130 ADC IIO device
+ * @param	iio_dev_data[in] - IIO device data instance
+ * @return	0 in case of success or negative value otherwise
+ */
+static int32_t iio_ad4130_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	Prepare for data transfer
+ * @param	dev[in] - IIO device instance
+ * @param	ch_mask[in] - Channels select mask
+ * @return	0 in case of success or negative value otherwise
+ */
+static int32_t iio_ad4130_prepare_transfer(void *dev,
+		uint32_t ch_mask)
+{
+	return prepare_data_transfer(ch_mask, BYTES_PER_SAMPLE);
+}
+
+/**
+ * @brief	Terminate current data transfer
+ * @param	dev[in] - IIO device instance
+ * @return	0 in case of success or negative value otherwise
+ */
+static int32_t iio_ad4130_end_transfer(void *dev)
+{
+	return end_data_transfer();
+}
+
+/**
+ * @brief	Perform the sensor measurement as per current demo config and update
+ *			the adc_raw value to sensor conversion scale factor for IIO client
+ * @param	adc_raw[in] - ADC raw value
+ * @param	chn[in] -  ADC channel
+ * @return	none
+ */
+static void perform_sensor_measurement_and_update_scale(uint32_t adc_raw,
+		uint16_t chn)
+{
+	float temperature = 0;
+	int32_t cjc_raw_data;
+	float cjc_temp;
+
+#if (ACTIVE_DEMO_MODE_CONFIG == THERMISTOR_CONFIG)
+	temperature = get_ntc_thermistor_temperature(ad4130_dev_inst, adc_raw, chn);
+	attr_scale_val[chn] = (temperature / adc_raw) * 1000.0;
+#elif ((ACTIVE_DEMO_MODE_CONFIG == RTD_2WIRE_CONFIG) || \
+	(ACTIVE_DEMO_MODE_CONFIG == RTD_3WIRE_CONFIG) || \
+	(ACTIVE_DEMO_MODE_CONFIG == RTD_4WIRE_CONFIG))
+	temperature = get_rtd_temperature(ad4130_dev_inst, adc_raw, chn);
+	attr_scale_val[chn] = (temperature / adc_raw) * 1000.0;
+#elif (ACTIVE_DEMO_MODE_CONFIG == THERMOCOUPLE_CONFIG)
+	if (chn != CJC_CHANNEL) {
+		/* Sample the CJC channel (TC channel is already sampled through
+		 * get_raw() function) */
+		if (read_single_sample(CJC_CHANNEL, (uint32_t *)&cjc_raw_data)) {
+			return;
+		}
+	} else {
+		/* For calculating CJC temperature, TC raw data is not used */
+		chn = SENSOR_CHANNEL0;
+		cjc_raw_data = adc_raw;
+		adc_raw = 0;
+	}
+
+	/* Calculate the TC and CJC temperature and update scale factor */
+	temperature = get_tc_temperature(ad4130_dev_inst, adc_raw,
+					 cjc_raw_data, chn, CJC_CHANNEL, &cjc_temp);
+	attr_scale_val[chn] = (temperature / adc_raw) * 1000.0;
+	attr_scale_val[CJC_CHANNEL] = (cjc_temp / cjc_raw_data) * 1000.0;
+#endif
+}
+
+/*!
+ * @brief	Update scale factor for adc data to voltage conversion
+ *			for IIO client
+ * @param	chn[in] - Input channel
+ * @return	none
+ */
+static void update_vltg_conv_scale_factor(uint8_t chn)
+{
+	enum ad413x_gain pga;
+	uint8_t preset;
+	uint8_t bipolar;
+	float vref;
+
+	preset = ad4130_dev_inst->ch[chn].preset;
+	pga = ad4130_dev_inst->preset[preset].gain;
+	bipolar = ad4130_dev_inst->bipolar;
+
+	vref = ad4130_get_reference_voltage(ad4130_dev_inst, chn);
+
+	/* Get the scale factor for voltage conversion */
+	if (bipolar) {
+		attr_scale_val[chn] = (vref / (ADC_MAX_COUNT_BIPOLAR *
+					       (1 << pga))) * 1000;
+	} else {
+		attr_scale_val[chn] = (vref / (ADC_MAX_COUNT_UNIPOLAR *
+					       (1 << pga))) * 1000;
+	}
+
+#if (ACTIVE_DEMO_MODE_CONFIG == POWER_TEST_CONFIG)
+	switch (chn) {
+	case POWER_TEST_I_AVDD_CHN:
+	case POWER_TEST_I_IOVDD_CHN:
+		attr_scale_val[chn] /= I_RSENSE;
+		break;
+
+	case POWER_TEST_V_AVDD_CHN:
+	case POWER_TEST_V_IOVDD_CHN:
+		attr_scale_val[chn] *= V_SCALE;
+		break;
+
+	default:
+		break;
+	}
+#endif
+}
+
+/**
+ * @brief	Init for reading/writing and parameterization of a
+ * 			ad4130 IIO device
+ * @param 	desc[in,out] - IIO device descriptor
+ * @return	0 in case of success, negative error code otherwise
+ */
+int32_t ad4130_iio_init(struct iio_device **desc)
+{
+	struct iio_device *iio_ad4130_inst;
+	uint8_t chn;
+	uint8_t bipolar;
+
+	iio_ad4130_inst = calloc(1, sizeof(struct iio_device));
+	if (!iio_ad4130_inst) {
+		return -ENOMEM;
+	}
+
+	/* Update IIO device init parameters */
+	for (chn = 0; chn < ADC_USER_CHANNELS; chn++) {
+		update_vltg_conv_scale_factor(chn);
+	}
+
+	/* Get the polarity of device */
+	bipolar = ad4130_dev_inst->bipolar;
+
+	if (bipolar) {
+		/* Using offset-binary coding for bipolar mode */
+		chn_scan.sign = 's';
+		chn_scan.realbits = CHN_STORAGE_BITS;
+	} else {
+		/* Using streight-binary coding for bipolar mode */
+		chn_scan.sign = 'u';
+		chn_scan.realbits = ADC_RESOLUTION;
+	}
+
+	chn_scan.storagebits = CHN_STORAGE_BITS;
+	chn_scan.shift = 0;
+	chn_scan.is_big_endian = false;
+
+	iio_ad4130_inst->num_ch = NO_OS_ARRAY_SIZE(ad4130_iio_channels);
+	iio_ad4130_inst->channels = ad4130_iio_channels;
+	iio_ad4130_inst->attributes = ad4130_iio_global_attributes;
+	iio_ad4130_inst->context_attributes = ad4130_iio_context_attributes;
+
+	iio_ad4130_inst->submit = iio_ad4130_submit_buffer;
+	iio_ad4130_inst->pre_enable = iio_ad4130_prepare_transfer;
+	iio_ad4130_inst->post_disable = iio_ad4130_end_transfer;
+
+	iio_ad4130_inst->debug_reg_read = debug_reg_read;
+	iio_ad4130_inst->debug_reg_write = debug_reg_write;
+
+	*desc = iio_ad4130_inst;
+
+	return 0;
+}
+
+/**
+ * @brief Release resources allocated for IIO device
+ * @param desc[in] - IIO device descriptor
+ * @return 0 in case of success, negative error code otherwise
+ */
+int32_t ad4130_iio_remove(struct iio_desc *desc)
+{
+	int32_t status;
+
+	if (!desc) {
+		return -ENOMEM;
+	}
+
+	status = iio_remove(desc);
+	if (status) {
+		return status;
+	}
+
+	return 0;
+}
+
+/**
+ * @brief	Initialize the IIO interface for AD4130 IIO device
+ * @return	0 in case of success, negative error code otherwise
+ */
+int32_t ad4130_iio_initialize(void)
+{
+	int32_t init_status;
+
+	/* IIO device descriptor */
+	struct iio_device *p_iio_ad4130_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 AD4130 device and peripheral interface */
+	init_status = ad413x_init(&ad4130_dev_inst, ad4130_init_params);
+	if (init_status) {
+		return init_status;
+	}
+
+	/* Initialize the AD4130 IIO application interface */
+	init_status = ad4130_iio_init(&p_iio_ad4130_dev);
+	if (init_status) {
+		return init_status;
+	}
+
+	/* Initialize the IIO interface */
+	iio_init_params.uart_desc = uart_desc;
+	iio_device_init_params.dev = ad4130_dev_inst;
+	iio_device_init_params.dev_descriptor = p_iio_ad4130_dev;
+	iio_init_params.devs = &iio_device_init_params;
+	init_status = iio_init(&p_ad4130_iio_desc, &iio_init_params);
+	if (init_status) {
+		return init_status;
+	}
+
+	/* Perform data capture initialization */
+	init_status = ad4130_data_capture_init();
+	if (init_status) {
+		return init_status;
+	}
+
+	return 0;
+}
+
+/**
+ * @brief 	Run the AD4130 IIO event handler
+ * @return	none
+ * @details	This function monitors the new IIO client event
+ */
+void ad4130_iio_event_handler(void)
+{
+	(void)iio_step(p_ad4130_iio_desc);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_iio.h	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,48 @@
+/***************************************************************************//**
+*   @file   ad4130_iio.h
+*   @brief  Header file of AD4130 IIO interface
+********************************************************************************
+* Copyright (c) 2020, 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 AD4130_IIO_H_
+#define AD4130_IIO_H_
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+
+#include <stdio.h>
+#include <stdbool.h>
+#include "iio.h"
+#include "iio_types.h"
+
+/******************************************************************************/
+/****************************** Macros ****************************************/
+/******************************************************************************/
+
+/* ADC channels assigned to sensors for the measurement
+ * (each channel per sensor) */
+enum sensor_channels {
+	SENSOR_CHANNEL0,
+	SENSOR_CHANNEL1,
+	NUM_OF_SENSOR_CHANNELS
+};
+
+/******************************************************************************/
+/************************ Public Declarations *********************************/
+/******************************************************************************/
+
+/* Init the IIO interface */
+int32_t ad4130_iio_initialize(void);
+
+/* Run the IIO event handler */
+void ad4130_iio_event_handler(void);
+
+extern struct ad413x_dev *ad4130_dev_inst;
+
+#endif /* AD4130_IIO_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_loadcell_config.c	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,67 @@
+/*************************************************************************//**
+ *   @file   ad4130_loadcell_config.c
+ *   @brief  Loadcell user configurations file for AD4130 device
+******************************************************************************
+* 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 "app_config.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/******************************************************************************/
+/********************** Variables and User Defined Data Types *****************/
+/******************************************************************************/
+
+/* AD4130 device initialization parameters */
+struct ad413x_init_param ad4130_loadcell_config_params = {
+	.spi_init = &spi_init_params,
+
+	/* Setup (Preset) Configurations */
+	.preset = {
+		// Setup 0
+		{
+			.ref_buf = {
+				.ref_buf_p_en = true,
+				.ref_buf_m_en = true,
+			},
+			.ref_sel = AD413X_REFIN1,
+			.gain = AD413X_GAIN_128,
+			.filter = AD4130_FILTER_TYPE,
+			.s_time = AD413X_32_MCLK
+		},
+	},
+
+	/* Chnnel Configurations */
+	.ch = {
+		// Chn0
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 1,
+			.ain_p = AD413X_AIN5,
+			.ain_m = AD413X_AIN6,
+			.pdsw_en = true,
+		},
+	},
+
+	.chip_id = AD4130_8,
+	.mclk = AD413X_INT_76_8_KHZ_OUT_OFF,
+	.bipolar = true,
+	.int_ref = AD413X_INTREF_DISABLED,
+	.standby_ctrl = {
+		.standby_pdsw_en = true,
+	},
+	.data_stat = 0,
+	.spi_crc_en = 0
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_loadcell_config.h	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,43 @@
+/*************************************************************************//**
+ *   @file   ad4130_loadcell_config.h
+ *   @brief  Header for AD4130 loadcell user configuration 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 _AD4130_LOADCELL_CONFIG_H_
+#define _AD4130_LOADCELL_CONFIG_H_
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+
+#include <stdint.h>
+#include "ad413x.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/* Select FS (or ODR) for loadcell config (applicable to all channels) */
+#define AD4130_FS_CONFIG				48	// ODR = 50SPS for SINC3/4 filter
+
+/* Filter type for default loadcell config
+ * Note: Applicable for all setups to keep the same ODR for all channels */
+#define AD4130_FILTER_TYPE				AD413X_SYNC3_STANDALONE
+
+/* Scaler factor used in FS to ODR conversion (For SINC3/4 filter) */
+#define FS_TO_ODR_CONV_SCALER			(32U * AD4130_FS_CONFIG)
+
+/******************************************************************************/
+/********************** Public/Extern Declarations ****************************/
+/******************************************************************************/
+
+extern struct ad413x_init_param ad4130_loadcell_config_params;
+
+#endif /* end of _AD4130_LOADCELL_CONFIG_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_noise_test_config.c	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,68 @@
+/*************************************************************************//**
+ *   @file   ad4130_noise_test_config.c
+ *   @brief  Noise test user configurations file for AD4130 device
+******************************************************************************
+* 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 "app_config.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/******************************************************************************/
+/********************** Variables and User Defined Data Types *****************/
+/******************************************************************************/
+
+/* AD4130 device initialization parameters */
+struct ad413x_init_param ad4130_noise_test_config_params = {
+	.spi_init = &spi_init_params,
+
+	/* Setup (Preset) Configurations */
+	.preset = {
+		// Setup 0
+		{
+			.ref_buf = {
+				.ref_buf_p_en = true,
+				.ref_buf_m_en = true,
+			},
+			.ref_sel = AD413X_REFOUT_AVSS,
+			.gain = AD413X_GAIN_1,
+			.filter = AD4130_FILTER_TYPE,
+			.s_time = AD413X_32_MCLK
+		},
+	},
+
+	/* Chnnel Configurations */
+	.ch = {
+		// Chn0
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 1,
+			.ain_p = AD413X_AIN0,
+			.ain_m = AD413X_AIN1
+		},
+	},
+
+	.chip_id = AD4130_8,
+	.mclk = AD413X_INT_76_8_KHZ_OUT_OFF,
+	.bipolar = true,
+	.int_ref = AD413X_INTREF_2_5V,
+	.standby_ctrl = {
+		.standby_int_ref_en = true,
+		.standby_vbias_en = true
+	},
+	.v_bias = NO_OS_BIT(0), 	// V_Bias on AIN0
+	.data_stat = 0,
+	.spi_crc_en = 0
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_noise_test_config.h	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,43 @@
+/*************************************************************************//**
+ *   @file   ad4130_noise_test_config.h
+ *   @brief  Header for AD4130 noise test user configuration 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 _AD4130_NOISE_TEST_CONFIG_H_
+#define _AD4130_NOISE_TEST_CONFIG_H_
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+
+#include <stdint.h>
+#include "ad413x.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/* Select FS (or ODR) for noise test config (applicable to all channels) */
+#define AD4130_FS_CONFIG				48	// ODR = 50SPS for SINC3/4 filter
+
+/* Filter type for noise test config
+ * Note: Applicable for all setups to keep the same ODR for all channels */
+#define AD4130_FILTER_TYPE				AD413X_SYNC3_STANDALONE
+
+/* Scaler factor used in FS to ODR conversion (For SINC3/4 filter) */
+#define FS_TO_ODR_CONV_SCALER			(32U * AD4130_FS_CONFIG)
+
+/******************************************************************************/
+/********************** Public/Extern Declarations ****************************/
+/******************************************************************************/
+
+extern struct ad413x_init_param ad4130_noise_test_config_params;
+
+#endif /* end of _AD4130_NOISE_TEST_CONFIG_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_power_test_config.c	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,99 @@
+/*************************************************************************//**
+ *   @file   ad4130_power_test_config.c
+ *   @brief  Power test user configurations file for AD4130 device
+******************************************************************************
+* 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 "app_config.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/******************************************************************************/
+/********************** Variables and User Defined Data Types *****************/
+/******************************************************************************/
+
+/* AD4130 device initialization parameters */
+struct ad413x_init_param ad4130_power_test_config_params = {
+	.spi_init = &spi_init_params,
+
+	/* Setup (Preset) Configurations */
+	.preset = {
+		// Setup 0
+		{
+			.ref_buf = {
+				.ref_buf_p_en = true,
+				.ref_buf_m_en = true,
+			},
+			.ref_sel = AD413X_AVDD_AVSS,
+			.gain = AD413X_GAIN_1,
+			.filter = AD4130_FILTER_TYPE,
+			.s_time = AD413X_32_MCLK
+		},
+	},
+
+	/* Chnnel Configurations */
+	.ch = {
+		// Chn0 (V_AVDD)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 1,
+			.ain_p = AD413X_AVDD_AVSS_6P,
+			.ain_m = AD413X_AVDD_AVSS_6M
+		},
+		// Chn1 (V_IOVDD)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 1,
+			.ain_p = AD413X_IOVDD_DGND_6P,
+			.ain_m = AD413X_IOVDD_DGND_6M
+		},
+		// Chn2 (I_AVDD)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 1,
+			.ain_p = AD413X_AIN12,
+			.ain_m = AD413X_AIN13
+		},
+		// Chn3 (I_IOVDD)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 1,
+			.ain_p = AD413X_AIN10,
+			.ain_m = AD413X_AIN11
+		},
+		// Chn4 (V_AVSS-DGND)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 1,
+			.ain_p = AD413X_AVSS,
+			.ain_m = AD413X_DGND
+		},
+		// Chn5 (V_REF)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 1,
+			.ain_p = AD413X_AIN14,
+			.ain_m = AD413X_AIN15
+		},
+	},
+
+	.chip_id = AD4130_8,
+	.mclk = AD413X_INT_76_8_KHZ_OUT_OFF,
+	.bipolar = true,
+	.int_ref = AD413X_INTREF_DISABLED,
+	.v_bias = 0,
+	.data_stat = 0,
+	.spi_crc_en = 0
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_power_test_config.h	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,51 @@
+/*************************************************************************//**
+ *   @file   ad4130_power_test_config.h
+ *   @brief  Header for AD4130 power test user configuration 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 _AD4130_POWER_TEST_CONFIG_H_
+#define _AD4130_POWER_TEST_CONFIG_H_
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+
+#include <stdint.h>
+#include "ad413x.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/* Select FS (or ODR) for power test config (applicable to all channels) */
+#define AD4130_FS_CONFIG				4	// ODR = 600SPS for SINC3/4 filter
+
+/* Filter type for power test config
+ * Note: Applicable for all setups to keep the same ODR for all channels */
+#define AD4130_FILTER_TYPE				AD413X_SYNC3_STANDALONE
+
+/* Scaler factor used in FS to ODR conversion (For SINC3/4 filter) */
+#define FS_TO_ODR_CONV_SCALER			(32U * AD4130_FS_CONFIG)
+
+/* Power test channels list */
+#define POWER_TEST_V_AVDD_CHN		0
+#define POWER_TEST_V_IOVDD_CHN		1
+#define POWER_TEST_I_AVDD_CHN		2
+#define POWER_TEST_I_IOVDD_CHN		3
+#define POWER_TEST_V_AVSS_DGND_CHN	4
+#define POWER_TEST_V_REF_CHN		5
+
+/******************************************************************************/
+/********************** Public/Extern Declarations ****************************/
+/******************************************************************************/
+
+extern struct ad413x_init_param ad4130_power_test_config_params;
+
+#endif /* end of _AD4130_POWER_TEST_CONFIG_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_regs.c	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,93 @@
+/***************************************************************************//**
+ *   @file    ad4130_regs.c
+ *   @brief   AD4130 registers map
+********************************************************************************
+ * 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 <stdint.h>
+
+#include "ad413x.h"
+#include "ad4130_regs.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/******************************************************************************/
+/*************************** Types Declarations *******************************/
+/******************************************************************************/
+
+const uint32_t ad413x_regs[] = {
+	AD413X_REG_STATUS,
+	AD413X_REG_ADC_CTRL,
+	AD413X_REG_DATA,
+	AD413X_REG_IO_CTRL,
+	AD413X_REG_VBIAS_CTRL,
+	AD413X_REG_ID,
+	AD413X_REG_ERROR,
+	AD413X_REG_ERROR_EN,
+	AD413X_REG_MCLK_CNT,
+	AD413X_REG_CHN(0),
+	AD413X_REG_CHN(1),
+	AD413X_REG_CHN(2),
+	AD413X_REG_CHN(3),
+	AD413X_REG_CHN(4),
+	AD413X_REG_CHN(5),
+	AD413X_REG_CHN(6),
+	AD413X_REG_CHN(7),
+	AD413X_REG_CHN(8),
+	AD413X_REG_CHN(9),
+	AD413X_REG_CHN(10),
+	AD413X_REG_CHN(11),
+	AD413X_REG_CHN(12),
+	AD413X_REG_CHN(13),
+	AD413X_REG_CHN(14),
+	AD413X_REG_CHN(15),
+	AD413X_REG_CONFIG(0),
+	AD413X_REG_CONFIG(1),
+	AD413X_REG_CONFIG(2),
+	AD413X_REG_CONFIG(3),
+	AD413X_REG_CONFIG(4),
+	AD413X_REG_CONFIG(5),
+	AD413X_REG_CONFIG(6),
+	AD413X_REG_CONFIG(7),
+	AD413X_REG_FILTER(0),
+	AD413X_REG_FILTER(1),
+	AD413X_REG_FILTER(2),
+	AD413X_REG_FILTER(3),
+	AD413X_REG_FILTER(4),
+	AD413X_REG_FILTER(5),
+	AD413X_REG_FILTER(6),
+	AD413X_REG_FILTER(7),
+	AD413X_REG_OFFSET(0),
+	AD413X_REG_OFFSET(1),
+	AD413X_REG_OFFSET(2),
+	AD413X_REG_OFFSET(3),
+	AD413X_REG_OFFSET(4),
+	AD413X_REG_OFFSET(5),
+	AD413X_REG_OFFSET(6),
+	AD413X_REG_OFFSET(7),
+	AD413X_REG_GAIN(0),
+	AD413X_REG_GAIN(1),
+	AD413X_REG_GAIN(2),
+	AD413X_REG_GAIN(3),
+	AD413X_REG_GAIN(4),
+	AD413X_REG_GAIN(5),
+	AD413X_REG_GAIN(6),
+	AD413X_REG_GAIN(7),
+	AD413X_REG_MISC,
+	AD413X_REG_FIFO_CTRL,
+	AD413X_REG_FIFO_STS,
+	AD413X_REG_FIFO_THRSHLD,
+	AD413X_REG_FIFO_DATA
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_regs.h	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,37 @@
+/***************************************************************************//**
+*   @file   ad4130_regs.h
+*   @brief  Global declarations for ad4130_regs module
+********************************************************************************
+* 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 _AD4130_REGS_H_
+#define _AD4130_REGS_H_
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+
+#include <stdint.h>
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+#define AD413X_ADDR(x)		((x) & 0xFF)
+
+/* Max register address available (last register address defined
+ * in the ad413x.h file) */
+#define MAX_REGISTER_ADDRESS	(AD413X_ADDR(AD413X_REG_FIFO_DATA))
+
+/******************************************************************************/
+/************************ Public Declarations *********************************/
+/******************************************************************************/
+
+extern const uint32_t ad413x_regs[];
+
+#endif /* _AD4130_REGS_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_rtd_config.c	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,74 @@
+/*************************************************************************//**
+ *   @file   ad4130_rtd_config.c
+ *   @brief  RTD user configurations file for AD4130 device
+******************************************************************************
+* 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 "app_config.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/******************************************************************************/
+/********************** Variables and User Defined Data Types *****************/
+/******************************************************************************/
+
+/* AD4130 device initialization parameters */
+struct ad413x_init_param ad4130_rtd_config_params = {
+	.spi_init = &spi_init_params,
+
+	/* Setup (Preset) Configurations */
+	.preset = {
+		// Setup 0
+		{
+			.ref_buf = {
+				.ref_buf_p_en = true,
+				.ref_buf_m_en = true,
+			},
+			.ref_sel = AD413X_REFIN1,
+			.gain = AD413X_GAIN_16,
+			.filter = AD4130_FILTER_TYPE,
+			.iout0_exc_current = AD413X_EXC_200UA,
+#if (ACTIVE_DEMO_MODE_CONFIG == RTD_3WIRE_CONFIG)
+			.iout1_exc_current = AD413X_EXC_200UA,
+#endif
+			.s_time = AD413X_32_MCLK
+		},
+	},
+
+	/* Chnnel Configurations */
+	.ch = {
+		// Chn0
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 1,
+			.ain_p = AD413X_AIN2,
+			.ain_m = AD413X_AIN3,
+			.iout0_exc_input = AD413X_AIN0,
+#if (ACTIVE_DEMO_MODE_CONFIG == RTD_3WIRE_CONFIG)
+			.iout1_exc_input = AD413X_AIN1,
+#endif
+		},
+	},
+
+	.chip_id = AD4130_8,
+	.mclk = AD413X_INT_76_8_KHZ_OUT_OFF,
+	.bipolar = true,
+	.int_ref = AD413X_INTREF_DISABLED,
+	.standby_ctrl = {
+		.standby_iexc_en = true
+	},
+	.data_stat = 0,
+	.spi_crc_en = 0
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_rtd_config.h	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,43 @@
+/*************************************************************************//**
+ *   @file   ad4130_rtd_config.h
+ *   @brief  Header for AD4130 RTD user configuration 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 _AD4130_RTD_CONFIG_H_
+#define _AD4130_RTD_CONFIG_H_
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+
+#include <stdint.h>
+#include "ad413x.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/* Select FS (or ODR) for RTD config (applicable to all channels) */
+#define AD4130_FS_CONFIG				48	// ODR = 50SPS for SINC3/4 filter
+
+/* Filter type for RTD config
+ * Note: Applicable for all setups to keep the same ODR for all channels */
+#define AD4130_FILTER_TYPE				AD413X_SYNC3_STANDALONE
+
+/* Scaler factor used in FS to ODR conversion (For SINC3/4 filter) */
+#define FS_TO_ODR_CONV_SCALER			(32U * AD4130_FS_CONFIG)
+
+/******************************************************************************/
+/********************** Public/Extern Declarations ****************************/
+/******************************************************************************/
+
+extern struct ad413x_init_param ad4130_rtd_config_params;
+
+#endif /* end of _AD4130_RTD_CONFIG_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_support.c	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,380 @@
+/*************************************************************************//**
+ *   @file   ad4130_support.c
+ *   @brief  AD4130 device No-OS driver supports
+******************************************************************************
+* Copyright (c) 2020, 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 <stdint.h>
+
+#include "app_config.h"
+#include "ad4130_support.h"
+#include "no_os_error.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/* AD4130 FIFO size and readback command size in bytes */
+#define AD4130_FIFO_MAX_SIZE		(256)
+#define AD4130_FIFO_READ_CMD_BYTES	(2)
+
+#define BYTE_SIZE					(8)
+
+/* Timeout to monitor CON monitor GPIO. The timeout count is dependent upon the
+ * MCU clock frequency. This timeout is tested for SDP-K1 Mbed controller platform */
+#define CONV_MON_GPIO_TIMEOUT	(10000)
+
+/* Select between GPIO Or STATUS register to monitor the end
+ * of conversion in single conversion mode */
+//#define CONV_MON_USING_RDY_STATUS		// Uncomment to use STATUS reg
+
+/* FIFO busy time as per specifications (in usec)
+ * Note : This time is stringent in FIFO readback.The minimum time period
+ * as per specifications is 20usec
+ */
+#define	FIFO_BUSY_TIME		(20)
+
+/******************************************************************************/
+/********************** Variables and User Defined Data Types *****************/
+/******************************************************************************/
+
+/* AD4130 FIFO readback buffer.
+ * Size for 24-bit ADC = (256 * 3) + 2 = 770 bytes
+ * Size for 16-bit ADC = (256 * 2) + 2 = 514 bytes
+ * */
+static uint8_t fifo_buf[(AD4130_FIFO_MAX_SIZE * (ADC_RESOLUTION / BYTE_SIZE)) +
+									      AD4130_FIFO_READ_CMD_BYTES];
+
+/******************************************************************************/
+/************************ Functions Definitions *******************************/
+/******************************************************************************/
+
+/*!
+ * @brief	Get reference voltage based on the reference source
+ * @param	dev[in] - Device instance
+ * @param	chn[in] - ADC channel
+ * @return	Reference voltage
+ */
+float ad4130_get_reference_voltage(struct ad413x_dev *dev, uint8_t chn)
+{
+	float ref_voltage;
+	uint8_t preset = dev->ch[chn].preset;
+	enum ad413x_ref_sel ref = dev->preset[preset].ref_sel;
+	enum ad413x_int_ref int_ref = dev->int_ref;
+
+	switch (ref) {
+	case AD413X_REFIN1:
+		ref_voltage = AD4130_REFIN1_VOLTAGE;
+		break;
+
+	case AD413X_REFIN2:
+		ref_voltage = AD4130_REFIN2_VOLTAGE;
+		break;
+
+	case AD413X_AVDD_AVSS:
+		ref_voltage = AD4130_AVDD_VOLTAGE;
+		break;
+
+	case AD413X_REFOUT_AVSS:
+		if (int_ref == AD413X_INTREF_1_25V) {
+			ref_voltage = AD4170_1_25V_INT_REF_VOLTAGE;
+		} else {
+			ref_voltage = AD4170_2_5V_INT_REF_VOLTAGE;
+		}
+		break;
+
+	default:
+		ref_voltage = AD4170_2_5V_INT_REF_VOLTAGE;
+		break;
+	}
+
+	return ref_voltage;
+}
+
+/*!
+ * @brief	Perform the sign conversion for handling negative voltages in
+ *			bipolar mode
+ * @param	dev[in] - Device instance
+ * @param	adc_raw_data[in] - ADC raw value
+ * @param	chn[in] - ADC Channel
+ * @return	ADC data after signed conversion
+ */
+int32_t perform_sign_conversion(struct ad413x_dev *dev, uint32_t adc_raw_data,
+				uint8_t chn)
+{
+	int32_t adc_data;
+	bool bipolar = dev->bipolar;
+
+	/* Bipolar ADC Range:  (-FS) <-> 0 <-> (+FS) : 0 <-> 2^(ADC_RES-1)-1 <-> 2^(ADC_RES-1)
+	   Unipolar ADC Range: 0 <-> (+FS) : 0 <-> 2^ADC_RES
+	 **/
+	if (bipolar) {
+		/* Data output format is offset binary for bipolar mode */
+		adc_data = adc_raw_data - ADC_MAX_COUNT_BIPOLAR;
+	} else {
+		/* Data output format is straight binary for unipolar mode */
+		adc_data = adc_raw_data;
+	}
+
+	return adc_data;
+}
+
+/*!
+ * @brief	Convert the ADC raw value into equivalent voltage
+ * @param	dev[in] - Device instance
+ * @param	adc_raw[in]- ADC raw data
+ * @param	chn[in] - ADC channel
+ * @return	ADC voltage value
+ */
+float convert_adc_sample_into_voltage(void *dev, uint32_t adc_raw,
+				      uint8_t chn)
+{
+	enum ad413x_gain pga;
+	float vref;
+	int32_t adc_data;
+	uint8_t preset = ((struct ad413x_dev *)dev)->ch[chn].preset;
+	bool bipolar = ((struct ad413x_dev *)dev)->bipolar;
+
+	pga = ((struct ad413x_dev *)dev)->preset[preset].gain;
+	vref = ad4130_get_reference_voltage(dev, chn);
+	adc_data = perform_sign_conversion(dev, adc_raw, chn);
+
+	if (bipolar) {
+		return (adc_data * (vref / (ADC_MAX_COUNT_BIPOLAR * (1 << pga))));
+	} else {
+		return (adc_data * (vref / (ADC_MAX_COUNT_UNIPOLAR * (1 << pga))));
+	}
+}
+
+/*!
+ * @brief	Convert the ADC raw value into equivalent RTD resistance
+ * @param	dev[in] - Device instance
+ * @param	adc_raw[in] - ADC raw sample
+ * @param	rtd_ref[in] - RTD reference resistance in ohms
+ * @param	chn[in] - ADC channel
+ * @return	RTD resistance value
+ * @note	RTD is biased with constant excitation current. Below formula
+ *			is based on ratiometric measurement, where fixed value of RTD RREF
+ *			(reference resistor) and gain is taken into account
+ */
+float convert_adc_raw_into_rtd_resistance(void *dev, uint32_t adc_raw,
+		float rtd_ref, uint8_t chn)
+{
+	enum ad413x_gain pga;
+	int32_t adc_data;
+	uint8_t preset = ((struct ad413x_dev *)dev)->ch[chn].preset;
+	bool bipolar = ((struct ad413x_dev *)dev)->bipolar;
+
+	pga = ((struct ad413x_dev *)dev)->preset[preset].gain;
+	adc_data = perform_sign_conversion(dev, adc_raw, chn);
+
+	if (bipolar) {
+		return (((float)adc_data * rtd_ref) / (ADC_MAX_COUNT_BIPOLAR * (1 << pga)));
+	} else {
+		return (((float)adc_data * rtd_ref) / (ADC_MAX_COUNT_UNIPOLAR * (1 << pga)));
+	}
+}
+
+/*!
+ * @brief	Function to monitor end of conversion and read
+ *			conversion result
+ * @param	dev[in] - Device instance
+ * @param	raw_data[in, out]- ADC raw data
+ * @return	0 in case of success, negative error code otherwise
+ */
+int32_t ad413x_mon_conv_and_read_data(struct ad413x_dev *dev,
+				      uint32_t *raw_data)
+{
+	int32_t ret;
+	uint8_t conv_mon = 0;
+	uint32_t timeout = CONV_MON_GPIO_TIMEOUT;
+
+	if (!dev || !raw_data) {
+		return -EINVAL;
+	}
+
+	/* Wait for conversion */
+#if defined(CONV_MON_USING_RDY_STATUS)
+	while (!conv_mon && timeout--) {
+		/* Read the value of the Status Register */
+		ret = ad413x_reg_read(dev, AD413X_REG_STATUS, raw_data);
+		if (ret) {
+			return ret;
+		}
+
+		/* Check the RDY bit in the Status Register */
+		conv_mon = (*raw_data & AD413X_ADC_DATA_STATUS);
+	}
+
+	if (!timeout) {
+		return -EIO;
+	}
+
+	/* Read the conversion result */
+	ret = ad413x_reg_read(dev, AD413X_REG_DATA, raw_data);
+	if (ret) {
+		return ret;
+	}
+#else
+	conv_mon = NO_OS_GPIO_HIGH;
+	while (conv_mon == NO_OS_GPIO_HIGH && timeout--) {
+		ret = no_os_gpio_get_value(conv_mon_gpio_desc, &conv_mon);
+		if (ret) {
+			return ret;
+		}
+	}
+
+	if (!timeout) {
+		return -EIO;
+	}
+
+	/* Read the conversion result */
+	ret = ad413x_reg_read(dev, AD413X_REG_DATA, raw_data);
+	if (ret) {
+		return ret;
+	}
+
+	conv_mon = NO_OS_GPIO_LOW;
+	timeout = CONV_MON_GPIO_TIMEOUT;
+	while (conv_mon == NO_OS_GPIO_LOW && timeout--) {
+		ret = no_os_gpio_get_value(conv_mon_gpio_desc, &conv_mon);
+		if (ret) {
+			return ret;
+		}
+	}
+
+	if (!timeout) {
+		return -EIO;
+	}
+#endif
+
+	return 0;
+}
+
+/*!
+ * @brief	Read the data from FIFO
+ * @param	dev[in] - device instance
+ * @param	data[in] - Buffer to store FIFO data
+ * @param	adc_samples[in] - Number of ADC samples to read
+ * @return	0 in case of success, negative error code otherwise
+ * @note	This function doesn't consider the FIFO status and header information
+ *			during data readback. It is assumed data user is intending to read
+ *			only the data from FIFO.
+ */
+int32_t ad4130_read_fifo(struct ad413x_dev *dev, uint32_t *data,
+			 uint32_t adc_samples)
+{
+	int32_t ret;
+	uint32_t loop_cntr;
+	uint32_t buf_indx = 0;
+	uint32_t bytes;
+
+	if (!dev || !data) {
+		return -EINVAL;
+	}
+
+	/* Watermark count of 0 implies full FIFO readback */
+	if ((adc_samples == 0) || (adc_samples > AD4130_FIFO_MAX_SIZE)) {
+		adc_samples = AD4130_FIFO_MAX_SIZE;
+	}
+
+	/* Delay b/w interrupt trigger and FIFO readback start */
+	no_os_udelay(FIFO_BUSY_TIME);
+
+	/* MOSI pin outputs 0x00 during FIFO data readback */
+	memset(fifo_buf, 0, sizeof(fifo_buf));
+
+	/* Enter into FIFO read mode by issuing dummy read command. Command consists of first byte as
+	 * address of FIFO data register and 2nd byte as number of samples to read from FIFO */
+	fifo_buf[0] = AD413X_COMM_REG_RD | AD413X_ADDR(AD413X_REG_FIFO_DATA);
+	fifo_buf[1] = adc_samples;
+
+	/* Bytes to read = (samples * data size) + fifo data reg address + sample_cnt */
+	bytes = (adc_samples * (ADC_RESOLUTION / BYTE_SIZE)) +
+		AD4130_FIFO_READ_CMD_BYTES;
+
+	/* Read all bytes over SPI */
+	ret = no_os_spi_write_and_read(dev->spi_dev, fifo_buf, bytes);
+	if (ret) {
+		return ret;
+	}
+
+	/* Extract the data from buffer (data doesn't contain header/status info) */
+	for (loop_cntr = AD4130_FIFO_READ_CMD_BYTES; loop_cntr < bytes;
+	     loop_cntr += (ADC_RESOLUTION / BYTE_SIZE)) {
+#if (ADC_RESOLUTION == 24)
+		data[buf_indx++] = ((int32_t)fifo_buf[loop_cntr] << 16) |
+				   ((int32_t)fifo_buf[loop_cntr + 1] << 8) |
+				   (int32_t)fifo_buf[loop_cntr + 2];
+#else
+		/* For 16-bit resolution */
+		data[buf_indx++] = ((int32_t)fifo_buf[loop_cntr] << 8) |
+				   (int32_t)fifo_buf[loop_cntr + 1];
+#endif
+	}
+
+	return 0;
+}
+
+/*!
+ * @brief	Set interrupt conversion source (GPIO)
+ * @param	dev[in] - Device instance
+ * @param	conv_int_source[in]- Interrupt source
+ * @return	0 in case of success, negative error code otherwise
+ */
+int32_t ad413x_set_int_source(struct ad413x_dev *dev,
+			      adc_conv_int_source_e conv_int_source)
+{
+	int32_t ret;
+
+	if (!dev) {
+		return -EINVAL;
+	}
+
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_IO_CTRL,
+				   AD413X_INT_PIN_SEL(conv_int_source),
+				   AD4130_INT_SRC_SEL_MSK);
+	if (ret) {
+		return ret;
+	}
+
+	return 0;
+}
+
+/*!
+ * @brief	Set filter FS value
+ * @param	dev[in] - Device instance
+ * @param	fs[in]- FS value
+ * @param	preset[in] - Channel setup
+ * @return	0 in case of success, negative error code otherwise
+ */
+int32_t ad413x_set_filter_fs(struct ad413x_dev *dev, uint32_t fs,
+			     uint8_t preset)
+{
+	int32_t ret;
+
+	if (!dev) {
+		return -EINVAL;
+	}
+
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_FILTER(preset),
+				   AD413X_FS_N(fs),
+				   AD4130_FILTER_FS_MSK);
+	if (ret) {
+		return ret;
+	}
+
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_support.h	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,74 @@
+/***************************************************************************//**
+ *   @file   ad4130_support.h
+ *   @brief  Header for AD4130 No-OS driver supports
+********************************************************************************
+ * Copyright (c) 2020-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 AD4130_SUPPORT_H_
+#define AD4130_SUPPORT_H_
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+
+#include <stdint.h>
+#include "ad413x.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+#define AD413X_ADDR(x)		((x) & 0xFF)
+
+#define AD4130_INT_SRC_SEL_MSK		NO_OS_GENMASK(9, 8)
+#define AD4130_FILTER_FS_MSK		NO_OS_GENMASK(10, 0)
+#define AD4130_FIFO_MODE_MSK		NO_OS_GENMASK(17, 16)
+#define AD413X_WATERMARK_MSK		NO_OS_GENMASK(7, 0)
+
+#define AD413X_COMM_REG_RD			NO_OS_BIT(6)
+
+/******************************************************************************/
+/********************** Variables and User Defined Data Types *****************/
+/******************************************************************************/
+
+/* FIFO modes */
+typedef enum {
+	FIFO_DISABLED,
+	FIFO_OLDEST_SAVE_MODE,
+	FIFO_STREAM_MODE
+} fifo_mode_e;
+
+/* ADC conversion interrupt source */
+typedef enum {
+	INT_PIN,
+	CLK_PIN,
+	GPIO1_PIN
+} adc_conv_int_source_e;
+
+/******************************************************************************/
+/************************ Public Declarations *********************************/
+/******************************************************************************/
+
+float ad4130_get_reference_voltage(struct ad413x_dev *dev, uint8_t chn);
+int32_t perform_sign_conversion(struct ad413x_dev *dev, uint32_t adc_raw_data,
+				uint8_t chn);
+float convert_adc_sample_into_voltage(void *dev, uint32_t adc_raw,
+				      uint8_t chn);
+float convert_adc_raw_into_rtd_resistance(void *dev, uint32_t adc_raw,
+		float rtd_ref, uint8_t chn);
+int32_t ad4130_read_fifo(struct ad413x_dev *dev, uint32_t *data,
+			 uint32_t adc_samples);
+int32_t ad413x_mon_conv_and_read_data(struct ad413x_dev *dev,
+				      uint32_t *raw_data);
+int32_t ad413x_set_int_source(struct ad413x_dev *dev,
+			      adc_conv_int_source_e conv_int_source);
+int32_t ad413x_set_filter_fs(struct ad413x_dev *dev, uint32_t fs,
+			     uint8_t preset);
+
+#endif /* AD4130_SUPPORT_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_temperature_sensor.cpp	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,151 @@
+/***************************************************************************//*
+ * @file    ad4130_temperature_sensor.cpp
+ * @brief   AD4130 temperature sensor measurement functionality
+******************************************************************************
+ * 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 <stdint.h>
+#include <math.h>
+
+#include <thermocouple.h>
+#include <ntc_10k_44031.h>
+#include <ptxxx.h>
+#include "ad4130_temperature_sensor.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif //  _cplusplus
+
+#include "app_config.h"
+#include "ad4130_support.h"
+
+#ifdef __cplusplus  // Closing extern c
+}
+#endif //  _cplusplus
+
+/******************************************************************************/
+/********************* Macros and Constants Definitions ***********************/
+/******************************************************************************/
+
+/* NTC thermistor Rsense value (in ohms) */
+#define NTC_RSENSE			10000U
+
+/* RTD Rref Resistance value (in ohms) */
+#define RTD_RREF			5110U
+
+/******************************************************************************/
+/******************** Variables and User Defined Data Types *******************/
+/******************************************************************************/
+
+/******************************************************************************/
+/************************** Functions Definitions *****************************/
+/******************************************************************************/
+
+/*!
+ * @brief	Convert the NTC thermistor voltage into equivalent resistance
+ * @param	ntc_voltage[in] - NTC Thermistor voltage
+ * @return	NTC Thermistor resistance value
+ * @note	The NTC is biased with constant ADC reference voltage. Below formula
+ *			is based on ratiometric measurement, where fixed value of ADC REF
+ *			and gain is taken into account
+ */
+static float convert_ntc_voltage_into_resistance(float ntc_voltage)
+{
+	return ((ntc_voltage * NTC_RSENSE) / (AD4170_1_25V_INT_REF_VOLTAGE -
+					      ntc_voltage));
+}
+
+/**
+ * @brief  	Convert ADC raw value into equivalent NTC temperature
+ * @param	dev[in] - Device instance
+ * @param	ntc_sample[in] - Raw ADC sample for NTC sensor
+ * @param	chn[in] - ADC channel
+ * @return	NTC temperature
+ * @note	Fixed NTC 10K 44031RC sensor is used
+ */
+float get_ntc_thermistor_temperature(void *dev, uint32_t ntc_sample,
+				     uint8_t chn)
+{
+	ntc_10k_44031rc ntc_thermistor;
+	float ntc_voltage;
+	float ntc_resistance;
+
+	ntc_voltage = convert_adc_sample_into_voltage(dev, ntc_sample, chn);
+	ntc_resistance = convert_ntc_voltage_into_resistance(ntc_voltage);
+
+	return ntc_thermistor.convert(ntc_resistance);
+}
+
+/**
+ * @brief  	Convert ADC raw value into equivalent RTD temperature
+ * @param	dev[in] - Device instance
+ * @param	rtd_sample[in] - Raw ADC sample for RTD sensor
+ * @pram	chn[in] - ADC channel
+ * @return	RTD temperature
+ * @note	Fixed PT100 RTD sensor is used
+ */
+float get_rtd_temperature(void *dev, uint32_t rtd_sample, uint8_t chn)
+{
+	PT100 rtd_sensor;
+	float rtd_resistance;
+
+	rtd_resistance = convert_adc_raw_into_rtd_resistance(dev, rtd_sample, RTD_RREF,
+			 chn);
+	return rtd_sensor.convertResistanceToTemperature(rtd_resistance);
+}
+
+/**
+ * @brief  	Convert ADC raw value into TC temperature
+ * @param	dev[in] - Device instance
+ * @param	tc_sample[in] - Raw TC sample
+ * @param	cjc_sample[in] - Raw CJC sample
+ * @param	tc_chn[in] - TC ADC channel
+ * @param	cjc_chn[in] - CJC ADC channel
+ * @param	cjc_temp[in, out] - CJC temperature value
+ * @return	TC temperature
+ * @note	T type thermocouple is used as default. For CJC, PT1000
+ *			RTD sensor is used as default.
+ */
+float get_tc_temperature(void *dev,
+			 uint32_t tc_sample, uint32_t cjc_sample,
+			 uint8_t tc_chn, uint8_t cjc_chn,
+			 float *cjc_temp)
+{
+	Thermocouple_Type_T tcSensor;
+	float tc_mv;
+	float tc_temperature;
+	float cjc_temperature;
+	PT1000 rtd_sensor;
+	float rtd_resistance;
+
+	tc_mv = convert_adc_sample_into_voltage(dev, tc_sample, tc_chn) * 1000;
+	tc_temperature = tcSensor.convert(tc_mv);
+
+#if defined(USE_CJC_AS_RTD)
+	rtd_resistance = convert_adc_raw_into_rtd_resistance(dev, cjc_sample, RTD_RREF,
+			 cjc_chn);
+	cjc_temperature = rtd_sensor.convertResistanceToTemperature(rtd_resistance);
+#else
+	cjc_temperature = get_ntc_thermistor_temperature(dev, cjc_sample, cjc_chn);
+#endif
+
+	/* Get the CJC temperature */
+	*cjc_temp = cjc_temperature;
+
+	/* NOTE The simplest approach of adding the CJC temperature to TC temperature is taken here.
+	 * A better method is to convert RTD back to thermocouple mV, and add that to TC value
+	 * then do the thermocouple to degC conversion.
+	 * */
+	return (tc_temperature + cjc_temperature);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_temperature_sensor.h	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,47 @@
+/***************************************************************************//*
+ * @file    ad4130_temperature_sensor.h
+ * @brief   AD4130 temperature sensor module global defines
+******************************************************************************
+ * 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 AD4130_TEMPERATURE_SENSOR_H_
+#define AD4130_TEMPERATURE_SENSOR_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif //  _cplusplus
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+
+#include <stdint.h>
+
+/******************************************************************************/
+/********************* Macros and Constants Definitions ***********************/
+/******************************************************************************/
+
+/******************************************************************************/
+/********************** Public/Extern Declarations ****************************/
+/******************************************************************************/
+
+float get_ntc_thermistor_temperature(void *dev, uint32_t ntc_sample,
+				     uint8_t chn);
+float get_rtd_temperature(void *dev, uint32_t rtd_sample, uint8_t chn);
+float get_tc_temperature(void *dev,
+			 uint32_t tc_sample, uint32_t cjc_sample,
+			 uint8_t tc_chn, uint8_t cjc_chn,
+			 float *cjc_temp);
+
+#ifdef __cplusplus  // Closing extern c
+}
+#endif //  _cplusplus
+
+#endif	// end of AD4130_TEMPERATURE_SENSOR_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_thermistor_config.c	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,66 @@
+/*************************************************************************//**
+ *   @file   ad4130_thermistor_config.c
+ *   @brief  Thermistor user configurations file for AD4130 device
+******************************************************************************
+* 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 "app_config.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/******************************************************************************/
+/********************** Variables and User Defined Data Types *****************/
+/******************************************************************************/
+
+/* AD4130 device initialization parameters */
+struct ad413x_init_param ad4130_thermistor_config_params = {
+	.spi_init = &spi_init_params,
+
+	/* Setup (Preset) Configurations */
+	.preset = {
+		// Setup 0
+		{
+			.ref_buf = {
+				.ref_buf_p_en = true,
+				.ref_buf_m_en = true,
+			},
+			.ref_sel = AD413X_REFOUT_AVSS,
+			.gain = AD413X_GAIN_1,
+			.filter = AD4130_FILTER_TYPE,
+			.s_time = AD413X_32_MCLK
+		},
+	},
+
+	/* Chnnel Configurations */
+	.ch = {
+		// Chn0
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 1,
+			.ain_p = AD413X_AIN4,
+			.ain_m = AD413X_AIN5
+		},
+	},
+
+	.chip_id = AD4130_8,
+	.mclk = AD413X_INT_76_8_KHZ_OUT_OFF,
+	.bipolar = true,
+	.int_ref = AD413X_INTREF_1_25V,
+	.standby_ctrl = {
+		.standby_int_ref_en = true,
+	},
+	.data_stat = 0,
+	.spi_crc_en = 0
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_thermistor_config.h	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,43 @@
+/*************************************************************************//**
+ *   @file   ad4130_thermistor_config.h
+ *   @brief  Header for AD4130 thermistors user configuration 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 _AD4130_THERMISTOR_CONFIG_H_
+#define _AD4130_THERMISTOR_CONFIG_H_
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+
+#include <stdint.h>
+#include "ad413x.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/* Select FS (or ODR) for thermistor config (applicable to all channels) */
+#define AD4130_FS_CONFIG				48	// ODR = 50SPS for SINC3/4 filter
+
+/* Filter type for default thermistor config
+ * Note: Applicable for all setups to keep the same ODR for all channels */
+#define AD4130_FILTER_TYPE				AD413X_SYNC3_STANDALONE
+
+/* Scaler factor used in FS to ODR conversion (For SINC3/4 filter) */
+#define FS_TO_ODR_CONV_SCALER			(32U * AD4130_FS_CONFIG)
+
+/******************************************************************************/
+/********************** Public/Extern Declarations ****************************/
+/******************************************************************************/
+
+extern struct ad413x_init_param ad4130_thermistor_config_params;
+
+#endif /* end of _AD4130_THERMISTOR_CONFIG_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_thermocouple_config.c	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,94 @@
+/*************************************************************************//**
+ *   @file   ad4130_thermocouple_config.c
+ *   @brief  Thermocouple user configurations file for AD4130 device
+******************************************************************************
+* 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 "app_config.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/******************************************************************************/
+/********************** Variables and User Defined Data Types *****************/
+/******************************************************************************/
+
+/* AD4130 device initialization parameters */
+struct ad413x_init_param ad4130_thermocouple_config_params = {
+	.spi_init = &spi_init_params,
+
+	/* Setup (Preset) Configurations */
+	.preset = {
+		// Setup 0 (Chn0)
+		{
+			.ref_buf = {
+				.ref_buf_p_en = true,
+				.ref_buf_m_en = true,
+			},
+			.ref_sel = AD413X_REFOUT_AVSS,
+			.gain = AD413X_GAIN_128,
+			.filter = AD4130_FILTER_TYPE,
+			.s_time = AD413X_32_MCLK
+		},
+		// Setup 1 (Chn1)
+		{
+			.ref_buf = {
+				.ref_buf_p_en = true,
+				.ref_buf_m_en = true,
+			},
+#if defined(USE_CJC_AS_RTD)
+			.ref_sel = AD413X_REFIN1,
+			.iout0_exc_current = AD413X_EXC_200UA,
+#else
+			.ref_sel = AD413X_REFOUT_AVSS,
+#endif
+			.gain = AD413X_GAIN_1,
+			.filter = AD4130_FILTER_TYPE,
+			.s_time = AD413X_32_MCLK
+		},
+	},
+
+	/* Chnnel Configurations */
+	.ch = {
+		// Chn0 (TC)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 1,
+			.ain_p = AD413X_AIN2,
+			.ain_m = AD413X_AIN3
+		},
+		// Chn1 (CJC)
+		{
+			.preset = AD413X_PRESET_1,
+			.enable = 1,
+			.ain_p = AD413X_AIN4,
+			.ain_m = AD413X_AIN5,
+#if defined(USE_CJC_AS_RTD)
+			.iout0_exc_input = AD413X_AIN0,
+#endif
+		},
+	},
+
+	.chip_id = AD4130_8,
+	.mclk = AD413X_INT_76_8_KHZ_OUT_OFF,
+	.bipolar = true,
+	.int_ref = AD413X_INTREF_1_25V,
+	.standby_ctrl = {
+		.standby_int_ref_en = true,
+		.standby_vbias_en = true
+	},
+	.v_bias = NO_OS_BIT(2),	// V_Bias on AIN2
+	.data_stat = 0,
+	.spi_crc_en = 0
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_thermocouple_config.h	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,47 @@
+/*************************************************************************//**
+ *   @file   ad4130_thermocouple_config.h
+ *   @brief  Header for AD4130 thermocouple user configuration 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 _AD4130_THERMOCOUPLE_CONFIG_H_
+#define _AD4130_THERMOCOUPLE_CONFIG_H_
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+
+#include <stdint.h>
+#include "ad413x.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/* Select the Cold Junction Compensation (CJC) sensor type for TC measurement */
+#define USE_CJC_AS_RTD
+//#define USE_CJC_AS_THERMISTOR
+
+/* Select FS (or ODR) for thermocouple config (applicable to all channels) */
+#define AD4130_FS_CONFIG				48	// ODR = 50SPS for SINC3/4 filter
+
+/* Filter type for default thermocouple config
+ * Note: Applicable for all setups to keep the same ODR for all channels */
+#define AD4130_FILTER_TYPE				AD413X_SYNC3_STANDALONE
+
+/* Scaler factor used in FS to ODR conversion (For SINC3/4 filter) */
+#define FS_TO_ODR_CONV_SCALER			(32U * AD4130_FS_CONFIG)
+
+/******************************************************************************/
+/********************** Public/Extern Declarations ****************************/
+/******************************************************************************/
+
+extern struct ad413x_init_param ad4130_thermocouple_config_params;
+
+#endif /* end of _AD4130_THERMOCOUPLE_CONFIG_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_user_config.c	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,160 @@
+/*************************************************************************//**
+ *   @file   ad4130_user_config.c
+ *   @brief  User configuration file for AD4130 device
+******************************************************************************
+* Copyright (c) 2020-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 "app_config.h"
+#include "ad4130_user_config.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/******************************************************************************/
+/********************** Variables and User Defined Data Types *****************/
+/******************************************************************************/
+
+/* AD4130 device initialization parameters */
+struct ad413x_init_param ad4130_user_config_params = {
+	.spi_init = &spi_init_params,
+
+	/* Setup (Preset) Configurations */
+	.preset = {
+		// Setup 0
+		{
+			.ref_sel = AD413X_REFIN1,
+			.gain = AD413X_GAIN_1,
+			.filter = AD4130_FILTER_TYPE,
+			.s_time = AD413X_32_MCLK
+		},
+	},
+
+	/* Channel Configurations */
+	.ch = {
+		// Chn0 (Setup0)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 1,
+			.ain_p = CHN0_AINP, .ain_m = CHN0_AINM
+		},
+		// Chn1 (Setup0)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 0,
+			.ain_p = CHN1_AINP, .ain_m = CHN1_AINM
+		},
+		// Chn2 (Setup0)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 0,
+			.ain_p = CHN2_AINP, .ain_m = CHN2_AINM
+		},
+		// Chn3 (Setup0)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 0,
+			.ain_p = CHN3_AINP, .ain_m = CHN3_AINM
+		},
+		// Chn4 (Setup0)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 0,
+			.ain_p = CHN4_AINP, .ain_m = CHN4_AINM
+		},
+		// Chn5 (Setup0)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 0,
+			.ain_p = CHN5_AINP, .ain_m = CHN5_AINM
+		},
+		// Chn6 (Setup0)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 0,
+			.ain_p = CHN6_AINP, .ain_m = CHN6_AINM
+		},
+		// Chn7 (Setup0)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 0,
+			.ain_p = CHN7_AINP, .ain_m = CHN7_AINM
+		},
+#if (ADC_USER_CHANNELS > 8)
+		// Chn8 (Setup0)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 0,
+			.ain_p = CHN8_AINP, .ain_m = CHN8_AINM
+		},
+		// Chn9 (Setup0)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 0,
+			.ain_p = CHN9_AINP, .ain_m = CHN9_AINM
+		},
+		// Chn10 (Setup0)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 0,
+			.ain_p = CHN10_AINP, .ain_m = CHN10_AINM
+		},
+		// Chn11 (Setup0)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 0,
+			.ain_p = CHN11_AINP, .ain_m = CHN11_AINM
+		},
+		// Chn12 (Setup0)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 0,
+			.ain_p = CHN12_AINP, .ain_m = CHN12_AINM
+		},
+		// Chn13 (Setup0)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 0,
+			.ain_p = CHN13_AINP, .ain_m = CHN13_AINM
+		},
+		// Chn14 (Setup0)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 0,
+			.ain_p = CHN14_AINP, .ain_m = CHN14_AINM
+		},
+		// Chn15 (Setup0)
+		{
+			.preset = AD413X_PRESET_0,
+			.enable = 0,
+			.ain_p = CHN15_AINP, .ain_m = CHN15_AINM
+		},
+#endif
+	},
+
+	.chip_id = AD4130_8,
+	.mclk = AD413X_INT_76_8_KHZ_OUT_OFF,
+	.bipolar = true,
+	.int_ref = AD413X_INTREF_DISABLED,
+	.v_bias = NO_OS_BIT(0) | NO_OS_BIT(1) | NO_OS_BIT(2) | \
+	NO_OS_BIT(3) | NO_OS_BIT(4) | NO_OS_BIT(5) | \
+	NO_OS_BIT(6) | NO_OS_BIT(7) | NO_OS_BIT(8) | \
+	NO_OS_BIT(9) | NO_OS_BIT(10) | NO_OS_BIT(11) | \
+	NO_OS_BIT(12) | NO_OS_BIT(13) | NO_OS_BIT(14) | \
+	NO_OS_BIT(15),
+	.standby_ctrl = {
+		.standby_vbias_en = true
+	},
+	.data_stat = 0,
+	.spi_crc_en = 0
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad4130_user_config.h	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,105 @@
+/*************************************************************************//**
+ *   @file   ad4130_user_config.h
+ *   @brief  Header for AD4130 user configuration file
+******************************************************************************
+* Copyright (c) 2020, 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 _AD4130_USER_CONFIG_H_
+#define _AD4130_USER_CONFIG_H_
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+
+#include <stdint.h>
+#include "ad413x.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/* Select channel config for default user config (applicable to all channels) */
+//#define DIFFERENTIAL_CHN_CFG	// Uncomment to select differential config
+
+/* Select FS (or ODR) for default user config (applicable to all channels) */
+#if (FS_CONFIG_VALUE != 0)
+#define AD4130_FS_CONFIG				FS_CONFIG_VALUE
+#else
+#define AD4130_FS_CONFIG				1	// ODR = 2.4KSPS (max)
+#endif
+
+/* Filter type for default user config
+ * Note: Applicable for all setups to keep the same ODR for all channels */
+#define AD4130_FILTER_TYPE				AD413X_SYNC3_STANDALONE
+
+/* Scaler factor used in FS to ODR conversion (For SINC3/4 filter) */
+#define FS_TO_ODR_CONV_SCALER			(32U * AD4130_FS_CONFIG)
+
+/* Select the positive and negative analog inputs for each channel */
+#if defined(DIFFERENTIAL_CHN_CFG)
+#define CHN0_AINP	AD413X_AIN0
+#define CHN0_AINM	AD413X_AIN1
+#define CHN1_AINP	AD413X_AIN2
+#define CHN1_AINM	AD413X_AIN3
+#define CHN2_AINP	AD413X_AIN4
+#define CHN2_AINM	AD413X_AIN5
+#define CHN3_AINP	AD413X_AIN6
+#define CHN3_AINM	AD413X_AIN7
+#define CHN4_AINP	AD413X_AIN8
+#define CHN4_AINM	AD413X_AIN9
+#define CHN5_AINP	AD413X_AIN10
+#define CHN5_AINM	AD413X_AIN11
+#define CHN6_AINP	AD413X_AIN12
+#define CHN6_AINM	AD413X_AIN13
+#define CHN7_AINP	AD413X_AIN14
+#define CHN7_AINM	AD413X_AIN15
+#define ADC_USER_CHANNELS	ADC_DIFFERENTIAL_CHNS
+#else
+#define CHN0_AINP	AD413X_AIN0
+#define CHN0_AINM	AD413X_AVSS
+#define CHN1_AINP	AD413X_AIN1
+#define CHN1_AINM	AD413X_AVSS
+#define CHN2_AINP	AD413X_AIN2
+#define CHN2_AINM	AD413X_AVSS
+#define CHN3_AINP	AD413X_AIN3
+#define CHN3_AINM	AD413X_AVSS
+#define CHN4_AINP	AD413X_AIN4
+#define CHN4_AINM	AD413X_AVSS
+#define CHN5_AINP	AD413X_AIN5
+#define CHN5_AINM	AD413X_AVSS
+#define CHN6_AINP	AD413X_AIN6
+#define CHN6_AINM	AD413X_AVSS
+#define CHN7_AINP	AD413X_AIN7
+#define CHN7_AINM	AD413X_AVSS
+#define CHN8_AINP	AD413X_AIN8
+#define CHN8_AINM	AD413X_AVSS
+#define CHN9_AINP	AD413X_AIN9
+#define CHN9_AINM	AD413X_AVSS
+#define CHN10_AINP	AD413X_AIN10
+#define CHN10_AINM	AD413X_AVSS
+#define CHN11_AINP	AD413X_AIN11
+#define CHN11_AINM	AD413X_AVSS
+#define CHN12_AINP	AD413X_AIN12
+#define CHN12_AINM	AD413X_AVSS
+#define CHN13_AINP	AD413X_AIN13
+#define CHN13_AINM	AD413X_AVSS
+#define CHN14_AINP	AD413X_AIN14
+#define CHN14_AINM	AD413X_AVSS
+#define CHN15_AINP	AD413X_AIN15
+#define CHN15_AINM	AD413X_AVSS
+#define ADC_USER_CHANNELS	ADC_PSEUDO_DIFF_CHNS
+#endif
+
+/******************************************************************************/
+/********************** Public/Extern Declarations ****************************/
+/******************************************************************************/
+
+extern struct ad413x_init_param ad4130_user_config_params;
+
+#endif /* end of _AD4130_USER_CONFIG_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad413x.c	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,1106 @@
+/***************************************************************************//**
+ *   @file   ad413x.c
+ *   @brief  Implementation of AD413X Driver.
+ *   @author Andrei Porumb (andrei.porumb@analog.com)
+********************************************************************************
+ * Copyright 2022(c) 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.
+ *  - 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.
+ *  - Use of the software either in source or binary form, must be run
+ *    on or directly connected to an Analog Devices Inc. component.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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.
+*******************************************************************************/
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include "ad413x.h"
+#include "no_os_error.h"
+#include "no_os_irq.h"
+#include "no_os_print_log.h"
+#include "no_os_delay.h"
+#include "no_os_crc8.h"
+#include "no_os_spi.h"
+
+NO_OS_DECLARE_CRC8_TABLE(ad413x_crc8);
+uint32_t timeout = 0xFFFFFF;
+
+/******************************************************************************/
+/************************** Functions Implementation **************************/
+/******************************************************************************/
+
+/***************************************************************************//**
+ * IRQ handler for ADC read.
+*******************************************************************************/
+static void irq_adc_read(struct ad413x_callback_ctx *ctx)
+{
+	struct ad413x_dev *dev = ctx->dev;
+	timeout = 0xFFFFFF;
+	if(ctx->buffer_size > 0) {
+		ad413x_reg_read(ctx->dev, AD413X_REG_DATA, ctx->buffer);
+		ctx->buffer_size--;
+		ctx->buffer++;
+		no_os_irq_enable(dev->irq_desc, dev->rdy_pin);
+	} else {
+		no_os_irq_disable(dev->irq_desc, dev->rdy_pin);
+	}
+}
+
+/***************************************************************************//**
+ * SPI internal register write to device using a mask.
+ *
+ * @param dev      - The device structure.
+ * @param reg_addr - The register address.
+ * @param data     - The register data.
+ * @param mask     - The mask.
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_reg_write_msk(struct ad413x_dev *dev,
+			     uint32_t reg_addr,
+			     uint32_t data,
+			     uint32_t mask)
+{
+	int32_t ret;
+	uint32_t reg_data;
+
+	ret = ad413x_reg_read(dev, reg_addr, &reg_data);
+	if (ret)
+		return ret;
+	reg_data &= ~mask;
+	reg_data |= data;
+	return ad413x_reg_write(dev, reg_addr, reg_data);
+}
+
+/***************************************************************************//**
+ * Set the mode of the ADC.
+ *
+ * @param dev       - The device structure.
+ * @param mode      - The ADC mode
+ *		      Accepted values: AD4110_CONTINOUS_CONV_MODE
+ *				       AD4110_SINGLE_CONV_MODE
+ *				       AD4110_STANDBY_MODE
+ *				       AD4110_PW_DOWN_MODE
+ *				       AD4110_SYS_OFFSET_CAL
+ *				       AD4110_SYS_GAIN_CAL
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_set_adc_mode(struct ad413x_dev *dev, enum ad413x_adc_mode mode)
+{
+	int32_t ret;
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_ADC_CTRL,
+				   AD413X_ADC_MODE(mode),
+				   AD413X_ADC_MODE(0xF));
+	if (ret)
+		return ret;
+
+	dev->op_mode = mode;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Set the internal reference.
+ *
+ * @param dev       - The device structure.
+ * @param int_ref   - The internal reference option.
+ *		      Accepted values: AD413X_INTREF_DISABLED
+ *					   AD413X_INTREF_2_5V,
+ *					   AD413X_INTREF_1_25V
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_set_int_ref(struct ad413x_dev *dev, enum ad413x_int_ref int_ref)
+{
+	int32_t ret;
+	switch (int_ref) {
+	case AD413X_INTREF_DISABLED:
+		ret = ad413x_reg_write_msk(dev,
+					   AD413X_REG_ADC_CTRL,
+					   0U,
+					   AD413X_ADC_REF_EN);
+		break;
+
+	case AD413X_INTREF_2_5V:
+		ret = ad413x_reg_write_msk(dev,
+					   AD413X_REG_ADC_CTRL,
+					   AD413X_ADC_REF_EN,
+					   AD413X_ADC_REF_EN);
+		if (ret)
+			return ret;
+		ret = ad413x_reg_write_msk(dev,
+					   AD413X_REG_ADC_CTRL,
+					   0U,
+					   AD413X_ADC_REF_VAL);
+		break;
+
+	case AD413X_INTREF_1_25V:
+		ret = ad413x_reg_write_msk(dev,
+					   AD413X_REG_ADC_CTRL,
+					   AD413X_ADC_REF_EN,
+					   AD413X_ADC_REF_EN);
+		if (ret)
+			return ret;
+		ret = ad413x_reg_write_msk(dev,
+					   AD413X_REG_ADC_CTRL,
+					   AD413X_ADC_REF_VAL,
+					   AD413X_ADC_REF_VAL);
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	if (ret)
+		return ret;
+
+	dev->int_ref = int_ref;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Enable/disable DATA_STAT field.
+ *
+ * @param dev       - The device structure.
+ * @param enable	- 0 DISABLE
+ * 					  1 ENABLE
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_data_stat_en(struct ad413x_dev *dev, uint8_t enable)
+{
+	int32_t ret;
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_ADC_CTRL,
+				   enable ? AD413X_ADC_DATA_STATUS : 0x0U,
+				   AD413X_ADC_DATA_STATUS);
+	if (ret)
+		return ret;
+
+	dev->data_stat = enable;
+
+	return 0;
+}
+/***************************************************************************//**
+ * Set the gain from configuration register.
+ *
+ * @param dev  - The device structure.
+ * @param gain - The gain value.
+ * 		 Accepted values: AD413X_GAIN_1
+ * 				  AD413X_GAIN_2
+ * 				  AD413X_GAIN_4
+ * 				  AD413X_GAIN_8
+ * 				  AD413X_GAIN_16
+ * 				  AD413X_GAIN_32
+ * 				  AD413X_GAIN_64
+ *				  AD413X_GAIN_128
+ * @param reg_nb - Number of Configuration Register
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_set_gain(struct ad413x_dev *dev, enum ad413x_gain gain,
+			enum ad413x_preset_nb reg_nb)
+{
+	int32_t ret;
+
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_CONFIG(reg_nb),
+				   AD413X_PGA_N(gain),
+				   AD413X_PGA_N(0xF));
+	if (ret)
+		return ret;
+
+	dev->preset[reg_nb].gain = gain;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Select reference from configuration register.
+ *
+ * @param dev  - The device structure.
+ * @param ref - The reference value.
+ * 		 Accepted values: AD413X_REFIN1
+ *					AD413X_REFIN2
+ *					AD413X_REFOUT_AVSS
+ *					AD413X_AVDD_AVSS
+ * @param reg_nb - Number of Configuration Register
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_set_ref(struct ad413x_dev *dev, enum ad413x_ref_sel ref,
+		       enum ad413x_preset_nb reg_nb)
+{
+	int32_t ret;
+
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_CONFIG(reg_nb),
+				   AD413X_REF_SEL_N(ref),
+				   AD413X_REF_SEL_N(0xF));
+	if (ret)
+		return ret;
+
+	dev->preset[reg_nb].ref_sel = ref;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Select the reference buffers.
+ *
+ * @param dev  - The device structure.
+ * @param ref_buf - The reference buffer status.
+ * @param reg_nb - Number of Configuration Register
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_set_ref_buf(struct ad413x_dev *dev,
+			   struct ad413x_ref_buf ref_buf,
+			   enum ad413x_preset_nb reg_nb)
+{
+	int32_t ret;
+	uint32_t reg_val;
+
+	reg_val = no_os_field_prep(AD413X_REF_BUFP_N, ref_buf.ref_buf_p_en);
+	reg_val |= no_os_field_prep(AD413X_REF_BUFM_N, ref_buf.ref_buf_m_en);
+
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_CONFIG(reg_nb),
+				   reg_val,
+				   AD413X_REF_BUF_MSK);
+	if (ret)
+		return ret;
+
+	dev->preset[reg_nb].ref_buf = ref_buf;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Select filter from filter register.
+ *
+ * @param dev  	 - The device structure.
+ * @param filter - The filter type.
+ * 		 Accepted values: AD413X_SYNC4_STANDALONE
+ *					AD413X_SYNC4_SYNC1
+ *					AD413X_SYNC3_STANDALONE
+ *					AD413X_SYNC3_REJ60
+ *					AD413X_SYNC3_SYNC1
+ *					AD413X_SYNC3_PF1
+ *					AD413X_SYNC3_PF2
+ *					AD413X_SYNC3_PF3
+ *					AD413X_SYNC3_PF4
+ * @param reg_nb - Number of Configuration Register
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_set_filter(struct ad413x_dev *dev, enum ad413x_filter filter,
+			  enum ad413x_preset_nb reg_nb)
+{
+	int32_t ret;
+
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_FILTER(reg_nb),
+				   AD413X_FILTER_MODE_N(filter),
+				   AD413X_FILTER_MODE_N(0xF));
+	if (ret)
+		return ret;
+
+	dev->preset[reg_nb].filter = filter;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Select settle time from filter register.
+ *
+ * @param dev  	 - The device structure.
+ * @param s_time - The settle time value.
+ * 		 Accepted values: AD413X_32_MCLK
+ *					AD413X_64_MCLK
+ *					AD413X_128_MCLK
+ *					AD413X_256_MCLK
+ *					AD413X_512_MCLK
+ *					AD413X_1024_MCLK
+ *					AD413X_2048_MCLK
+ *					AD413X_4096_MCLK
+ * @param reg_nb - Number of Configuration Register
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_set_settle_time(struct ad413x_dev *dev,
+			       enum ad413x_settle_time s_time,
+			       enum ad413x_preset_nb reg_nb)
+{
+	int32_t ret;
+
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_FILTER(reg_nb),
+				   AD413X_SETTLE_N(s_time),
+				   AD413X_SETTLE_N(0xFF));
+	if (ret)
+		return ret;
+
+	dev->preset[reg_nb].s_time = s_time;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Select excitation current value from config register.
+ *
+ * @param dev  	 - The device structure.
+ * @param iout0_exc - The Iout0 excitation current value.
+ * @param iout1_exc - The Iout1 excitation current value.
+ * 		 Accepted values: AD413X_EXC_OFF
+ *					AD413X_EXC_10UA
+ *					AD413X_EXC_20UA
+ *					AD413X_EXC_50UA
+ *					AD413X_EXC_100UA
+ *					AD413X_EXC_150UA
+ *					AD413X_EXC_200UA
+ *					AD413X_EXC_100NA
+ * @param reg_nb - Number of Configuration Register
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_set_exc_current(struct ad413x_dev *dev,
+			       enum ad413x_exc_current iout0_exc,
+			       enum ad413x_exc_current iout1_exc,
+			       enum ad413x_preset_nb reg_nb)
+{
+	int32_t ret;
+
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_CONFIG(reg_nb),
+				   AD413X_I_OUT0_N(iout0_exc) | AD413X_I_OUT1_N(iout1_exc),
+				   AD413X_I_OUT_MSK);
+	if (ret)
+		return ret;
+
+	dev->preset[reg_nb].iout0_exc_current = iout0_exc;
+	dev->preset[reg_nb].iout1_exc_current = iout1_exc;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Select preset for adc channel.
+ *
+ * @param dev  		- The device structure.
+ * @param ch_nb  	- The channel number.
+ * @param preset_nb - The preset number.
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_set_ch_preset(struct ad413x_dev *dev, uint8_t ch_nb,
+			     enum ad413x_preset_nb preset_nb)
+{
+	int32_t ret;
+
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_CHN(ch_nb),
+				   AD413X_SETUP_M(preset_nb),
+				   AD413X_SETUP_M(0xF));
+	if (ret)
+		return ret;
+
+	dev->ch[ch_nb].preset = preset_nb;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Select the excitation source pins.
+ *
+ * @param dev  		- The device structure.
+ * @param ch_nb  	- The channel number.
+ * @param iout0_exc_inp 	- IOUT0 excitation input pin.
+ * @param iout1_exc_inp 	- IOUT1 excitation input pin.
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_ch_exc_input(struct ad413x_dev *dev, uint8_t ch_nb,
+			    enum ad413x_input iout0_exc_inp,
+			    enum ad413x_input iout1_exc_inp)
+{
+	int32_t ret;
+
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_CHN(ch_nb),
+				   AD413X_I_OUT0_CH_M(iout0_exc_inp) |
+				   AD413X_I_OUT1_CH_M(iout1_exc_inp),
+				   AD413X_I_OUT_CH_MSK);
+	if (ret)
+		return ret;
+
+	dev->ch[ch_nb].iout0_exc_input = iout0_exc_inp;
+	dev->ch[ch_nb].iout1_exc_input = iout1_exc_inp;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Enable/disable channel.
+ *
+ * @param dev  		- The device structure.
+ * @param ch_nb  	- The channel number.
+ * @param enable 	- Channel status.
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_ch_en(struct ad413x_dev *dev, uint8_t ch_nb, uint8_t enable)
+{
+	int32_t ret;
+
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_CHN(ch_nb),
+				   enable ? AD413X_ENABLE_M : 0x0U,
+				   AD413X_ENABLE_M);
+	if (ret)
+		return ret;
+
+	dev->ch[ch_nb].enable = enable;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Enable/disable Power-Down Switch (PDSW).
+ *
+ * @param dev  		- The device structure.
+ * @param ch_nb  	- The channel number.
+ * @param pdsw_en 	- PDSW status.
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_pdsw_en(struct ad413x_dev *dev, uint8_t ch_nb, bool pdsw_en)
+{
+	int32_t ret;
+
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_CHN(ch_nb),
+				   pdsw_en ? AD413X_PDSW_M : 0x0U,
+				   AD413X_PDSW_M);
+	if (ret)
+		return ret;
+
+	dev->ch[ch_nb].pdsw_en = pdsw_en;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Enable/disable bipolar data coding.
+ *
+ * @param dev  		- The device structure.
+ * @param enable 	- 1 - Bipolar
+ * 					  0 - Unipolar
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_adc_bipolar(struct ad413x_dev *dev, uint8_t enable)
+{
+	int32_t ret;
+
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_ADC_CTRL,
+				   enable ? AD413X_ADC_BIPOLAR : 0x0U,
+				   AD413X_ADC_BIPOLAR);
+	if (ret)
+		return ret;
+
+	dev->bipolar = enable;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Set output VBIAS on analog inputs.
+ *
+ * @param dev  		- The device structure.
+ * @param v_bias_val 	- V_BIAS control register value
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_set_v_bias(struct ad413x_dev *dev, uint16_t v_bias_val)
+{
+	int32_t ret;
+
+	ret = ad413x_reg_write(dev,
+			       AD413X_REG_VBIAS_CTRL,
+			       v_bias_val);
+	if (ret)
+		return ret;
+
+	dev->v_bias = v_bias_val;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Set standby control flags.
+ *
+ * @param dev  		- The device structure.
+ * @param standby_ctrl 	- Standby control value
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_set_standby_ctrl(struct ad413x_dev *dev,
+				struct ad413x_standby_ctrl standby_ctrl)
+{
+	int32_t ret;
+	uint32_t reg_val;
+
+	reg_val = no_os_field_prep(AD413X_STBY_INTREF_EN,
+				   standby_ctrl.standby_int_ref_en);
+	reg_val |= no_os_field_prep(AD413X_STBY_REFHOL_EN,
+				    standby_ctrl.standby_ref_holder_en);
+	reg_val |= no_os_field_prep(AD413X_STBY_IEXC_EN, standby_ctrl.standby_iexc_en);
+	reg_val |= no_os_field_prep(AD413X_STBY_VBIAS_EN,
+				    standby_ctrl.standby_vbias_en);
+	reg_val |= no_os_field_prep(AD413X_STBY_BURNOUT_EN,
+				    standby_ctrl.standby_burnout_en);
+	reg_val |= no_os_field_prep(AD413X_STBY_PDSW_EN, standby_ctrl.standby_pdsw_en);
+	reg_val |= no_os_field_prep(AD413X_STBY_GPO_EN, standby_ctrl.standby_gpio_en);
+	reg_val |= no_os_field_prep(AD413X_STBY_DIAGNOSTICS_EN,
+				    standby_ctrl.standby_diagn_en);
+	reg_val |= no_os_field_prep(AD413X_STBY_OUT_EN, standby_ctrl.standby_output_en);
+
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_MISC,
+				   reg_val,
+				   AD413X_STBY_CTRL_MSK);
+	if (ret)
+		return ret;
+
+	dev->standby_ctrl = standby_ctrl;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Set ADC master clock mode.
+ *
+ * @param dev  - The device structure.
+ * @param clk  - The clock mode.
+ * 		 Accepted values: AD413X_INT_76_8_KHZ_OUT_OFF
+ * 				  AD413X_INT_76_8_KHZ_OUT_ON
+ * 				  AD413X_EXT_76_8KHZ
+ * 				  AD413X_EXT_153_6_KHZ_DIV_2
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_set_mclk(struct ad413x_dev *dev, enum ad413x_mclk_sel clk)
+{
+	int32_t ret;
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_ADC_CTRL,
+				   AD413X_ADC_CNTRL_MCLK(clk),
+				   AD413X_ADC_CNTRL_MCLK(0xF));
+	if(ret)
+		return ret;
+
+	dev->mclk = clk;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Do a SPI software reset.
+ *
+ * @param dev - The device structure.
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_do_soft_reset(struct ad413x_dev *dev)
+{
+	int32_t ret;
+	uint8_t buf [ 8 ] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
+
+	/* The AD413X can be reset by writing a series of 64 consecutive 1s
+	 * to the DIN input */
+	ret = no_os_spi_write_and_read(dev->spi_dev, buf, 8);
+	if(ret)
+		return ret;
+
+	no_os_mdelay(5); // TBD
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * SPI internal register write to device.
+ *
+ * @param dev      - The device structure.
+ * @param reg_addr - The register address.
+ * @param reg_data - The register data.
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_reg_write(struct ad413x_dev *dev,
+			 uint32_t reg_addr,
+			 uint32_t reg_data)
+{
+	uint8_t buf[5];
+
+	uint8_t data_size = AD413X_TRANSF_LEN(reg_addr);
+
+	buf[0] = AD413X_CMD_WR_COM_REG(reg_addr);
+
+	switch(data_size) {
+	case 1:
+		buf[1] = (reg_data & 0xFF);
+		break;
+
+	case 2:
+		buf[1] = (reg_data & 0xFF00) >> 8;
+		buf[2] = (reg_data & 0xFF);
+		break;
+
+	case 3:
+		buf[1] = (reg_data & 0xFF0000) >> 16;
+		buf[2] = (reg_data & 0xFF00) >> 8;
+		buf[3] = (reg_data & 0xFF);
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	if (dev->spi_crc_en)
+		buf[data_size] = no_os_crc8(ad413x_crc8, buf, ++data_size, 0);
+
+	return no_os_spi_write_and_read(dev->spi_dev, buf, data_size + 1);
+}
+
+/***************************************************************************//**
+ * SPI internal register read from device.
+ *
+ * @param dev      - The device structure.
+ * @param reg_addr - The register address.
+ * @param reg_data - The register data.
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_reg_read(struct ad413x_dev *dev,
+			uint32_t reg_addr,
+			uint32_t *reg_data)
+{
+	uint8_t ret;
+	uint8_t buf[] = {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA};
+	uint32_t data;
+	uint8_t crc;
+
+	uint8_t data_size = AD413X_TRANSF_LEN(reg_addr);
+
+	buf[0] = AD413X_CMD_RD_COM_REG(reg_addr);
+
+	if ((reg_addr == AD413X_REG_DATA) && (dev->data_stat))
+		data_size++;
+
+	if (dev->spi_crc_en)
+		data_size++;
+
+	ret = no_os_spi_write_and_read(dev->spi_dev, buf, data_size + 1);
+	if (ret)
+		return ret;
+
+	if (dev->spi_crc_en) {
+		buf[0] = AD413X_CMD_RD_COM_REG(reg_addr);
+		crc = no_os_crc8(ad413x_crc8, buf, data_size, 0);
+		if (buf[data_size] != crc)
+			return -EBADMSG;
+		data_size--;
+	}
+
+	switch (data_size) {
+	case 1:
+		data = buf[1];
+		break;
+
+	case 2:
+		data = (buf[1] << 8) | buf[2];
+		break;
+
+	case 3:
+		data = (buf[1] << 16) | (buf[2] << 8) | buf[3];
+		break;
+
+	case 4:
+		data = (buf[1] << 24) | (buf[2] << 16) | (buf[3] << 8) | buf[4];
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	*reg_data = data;
+
+	return 0;
+}
+
+/***************************************************************************//**
+ * Single conversion of each adc active channel.
+ *
+ * @param dev	     - The device structure.
+ * @param buffer	 - Buffer to store read data. Buffer size needs to be at
+ * 					least equal to the number of active channels. Results will
+ * 					be stored in consecutive order of the active channels.
+ * @param ch_nb		 - Number of active channels.
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_single_conv(struct ad413x_dev *dev, uint32_t *buffer,
+			   uint8_t ch_nb)
+{
+	int32_t ret;
+
+	struct ad413x_callback_ctx ctx = {
+		.dev = dev,
+		.buffer = buffer,
+		.buffer_size = ch_nb
+	};
+
+	struct no_os_callback_desc irq_callback = {
+		.callback = &irq_adc_read,
+		.ctx = &ctx
+	};
+
+	ret = no_os_irq_trigger_level_set(dev->irq_desc, dev->rdy_pin,
+					  NO_OS_IRQ_EDGE_FALLING);
+	if (ret)
+		return ret;
+
+	ret = no_os_irq_register_callback(dev->irq_desc, dev->rdy_pin, &irq_callback);
+	if (ret)
+		return ret;
+
+	ret = no_os_irq_enable(dev->irq_desc, dev->rdy_pin);
+	if (ret)
+		return ret;
+
+	ret = ad413x_set_adc_mode(dev, AD413X_SINGLE_CONV_MODE);
+	if (ret)
+		return ret;
+
+	while((ctx.buffer_size != 0U) && --timeout) ;
+
+	if (!timeout)
+		pr_err("Timeout error (%s)\n", __func__);
+
+	ret = no_os_irq_disable(dev->irq_desc, dev->rdy_pin);
+	if (ret)
+		return ret;
+
+	return no_os_irq_unregister_callback(dev->irq_desc, dev->rdy_pin,
+					     &irq_callback);
+}
+
+/***************************************************************************//**
+ * Continuous conversion of each adc active channel.
+ *
+ * @param dev        - The device structure.
+ * @param buffer	 - Buffer to store read data. Buffer size needs to be at
+ * 					least equal to the number of active channels * samples number.
+ * 					Results will be stored in consecutive order of the active
+ * 					channels.
+ * @param ch_nb		 - Number of active channels.
+ * @param sample_nb  - Samples number.
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_continuous_conv(struct ad413x_dev *dev, uint32_t *buffer,
+			       uint8_t ch_nb, uint32_t sample_nb)
+{
+	int32_t ret;
+
+	struct ad413x_callback_ctx ctx = {
+		.dev = dev,
+		.buffer = buffer,
+		.buffer_size = ch_nb * sample_nb
+	};
+
+	struct no_os_callback_desc irq_callback = {
+		.callback = &irq_adc_read,
+		.ctx = &ctx
+	};
+
+	ret = no_os_irq_trigger_level_set(dev->irq_desc, dev->rdy_pin,
+					  NO_OS_IRQ_EDGE_FALLING);
+	if (ret)
+		return ret;
+
+	ret = no_os_irq_register_callback(dev->irq_desc, dev->rdy_pin, &irq_callback);
+	if (ret)
+		return ret;
+
+	ret = no_os_irq_enable(dev->irq_desc, dev->rdy_pin);
+	if (ret)
+		return ret;
+
+	ret = ad413x_set_adc_mode(dev, AD413X_CONTINOUS_CONV_MODE);
+	if (ret)
+		return ret;
+
+	while((ctx.buffer_size != 0U) && --timeout) ;
+
+	if (!timeout)
+		pr_err("Timeout error (%s)\n", __func__);
+
+	ret = ad413x_set_adc_mode(dev, AD413X_STANDBY_MODE);
+	if (ret)
+		return ret;
+
+	return no_os_irq_unregister_callback(dev->irq_desc, dev->rdy_pin,
+					     &irq_callback);
+}
+
+/***************************************************************************//**
+ * Store adc channel presets.
+ *
+ * @param dev        - The device structure.
+ * @param preset 	 - The structure to be saved as preset.
+ * @param preset_nb	 - Preset's number.
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_preset_store(struct ad413x_dev *dev, struct ad413x_preset preset,
+			    enum ad413x_preset_nb preset_nb)
+{
+	int32_t ret;
+
+	ret = ad413x_set_gain(dev, preset.gain, preset_nb);
+	if (ret)
+		return ret;
+
+	ret = ad413x_set_ref(dev, preset.ref_sel, preset_nb);
+	if (ret)
+		return ret;
+
+	ret = ad413x_set_ref_buf(dev, preset.ref_buf, preset_nb);
+	if (ret)
+		return ret;
+
+	ret = ad413x_set_settle_time(dev, preset.s_time, preset_nb);
+	if (ret)
+		return ret;
+
+	ret = ad413x_set_exc_current(dev, preset.iout0_exc_current,
+				     preset.iout1_exc_current, preset_nb);
+	if (ret)
+		return ret;
+
+	return ad413x_set_filter(dev, preset.filter, preset_nb);
+}
+
+/***************************************************************************//**
+ * Initialize the device.
+ *
+ * @param device     - The device structure.
+ * @param init_param - The structure that contains the device initial
+ * 		       parameters.
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_init(struct ad413x_dev **device,
+		    struct ad413x_init_param init_param)
+{
+	struct ad413x_dev *dev;
+	uint32_t reg_data;
+	int32_t ret;
+	int32_t i;
+
+	no_os_crc8_populate_msb(ad413x_crc8, AD413X_CRC8_POLY);
+
+	dev = (struct ad413x_dev *)malloc(sizeof(*dev));
+	if (!dev)
+		return -1;
+
+	dev->chip_id = init_param.chip_id;
+	dev->irq_desc = init_param.irq_desc;
+	dev->rdy_pin = init_param.rdy_pin;
+	dev->spi_crc_en = 0;
+
+	/* SPI */
+	ret = no_os_spi_init(&dev->spi_dev, init_param.spi_init);
+	if (ret)
+		goto err_dev;
+
+	/* Device Settings */
+	ret = ad413x_do_soft_reset(dev);
+	if (ret)
+		goto err_spi;
+
+	/* Reset POR flag */
+	ret = ad413x_reg_read(dev, AD413X_REG_STATUS, &reg_data);
+	if (ret)
+		return -1;
+
+	/* Change SPI to 4 wire*/
+	ret = ad413x_reg_write_msk(dev,
+				   AD413X_REG_ADC_CTRL,
+				   AD413X_ADC_CSB_EN,
+				   AD413X_ADC_CSB_EN);
+	if (ret)
+		goto err_spi;
+
+	/* TBD - chip ID is 0x00 for now */
+	ret = ad413x_reg_read(dev, AD413X_REG_ID, &reg_data);
+	if (ret)
+		goto err_spi;
+
+	switch(dev->chip_id) {
+	case AD4130_8:
+		if(reg_data != AD4130_8) {
+			goto err_spi;
+		}
+		break;
+	default:
+		goto err_spi;
+	}
+
+	ret = ad413x_set_adc_mode(dev, AD413X_STANDBY_MODE);
+	if (ret)
+		goto err_spi;
+
+	if (init_param.spi_crc_en) {
+		ret = ad413x_reg_write_msk(dev,
+					   AD413X_REG_ERROR_EN,
+					   AD413X_SPI_CRC_ERR_EN,
+					   AD413X_SPI_CRC_ERR_EN);
+		if (ret)
+			goto err_spi;
+		dev->spi_crc_en = init_param.spi_crc_en;
+	}
+
+	/* Preset configured and saved in dev */
+	for (i = 0; i < 8; i++) {
+		ret = ad413x_preset_store(dev, init_param.preset[i], i);
+		if (ret)
+			goto err_spi;
+	}
+
+	/* Channel setup */
+	for (i = 0; i < 16; i++) {
+		ret = ad413x_set_ch_preset(dev, i, init_param.ch[i].preset);
+		if (ret)
+			goto err_spi;
+
+		ret = ad413x_reg_write_msk(dev,
+					   AD413X_REG_CHN(i),
+					   AD413X_AINP_M(init_param.ch[i].ain_p),
+					   AD413X_AINP_M(0xFF));
+		if (ret)
+			goto err_spi;
+		dev->ch[i].ain_p = init_param.ch[i].ain_p;
+
+		ret = ad413x_reg_write_msk(dev,
+					   AD413X_REG_CHN(i),
+					   AD413X_AINM_M(init_param.ch[i].ain_m),
+					   AD413X_AINM_M(0xFF));
+		if (ret)
+			goto err_spi;
+		dev->ch[i].ain_m = init_param.ch[i].ain_m;
+
+		ret = ad413x_ch_exc_input(dev, i, init_param.ch[i].iout0_exc_input,
+					  init_param.ch[i].iout1_exc_input);
+		if (ret)
+			goto err_spi;
+
+		ret = ad413x_pdsw_en(dev, i, init_param.ch[i].pdsw_en);
+		if (ret)
+			goto err_spi;
+
+		ret = ad413x_ch_en(dev, i, init_param.ch[i].enable);
+		if (ret)
+			goto err_spi;
+	}
+
+	ret = ad413x_set_int_ref(dev, init_param.int_ref);
+	if (ret)
+		goto err_spi;
+
+	ret = ad413x_adc_bipolar(dev, init_param.bipolar);
+	if (ret)
+		goto err_spi;
+
+	ret = ad413x_set_v_bias(dev, init_param.v_bias);
+	if (ret)
+		goto err_spi;
+
+	ret = ad413x_set_standby_ctrl(dev, init_param.standby_ctrl);
+	if (ret)
+		goto err_spi;
+
+	ret = ad413x_set_mclk(dev, init_param.mclk);
+	if (ret)
+		goto err_spi;
+
+	ret = ad413x_data_stat_en(dev, init_param.data_stat);
+	if (ret)
+		goto err_spi;
+
+	*device = dev;
+
+	pr_info("AD413X successfully initialized\n");
+	return 0;
+
+err_spi:
+	no_os_spi_remove(dev->spi_dev);
+err_dev:
+	free(dev);
+	pr_err("AD413X initialization error (%d)\n", ret);
+	return ret;
+}
+
+/***************************************************************************//**
+ * @brief Free the resources allocated by ad413x_init().
+ *
+ * @param dev - The device structure.
+ *
+ * @return 0 in case of success, negative error code otherwise.
+*******************************************************************************/
+int32_t ad413x_remove(struct ad413x_dev *dev)
+{
+	int32_t ret;
+
+	ret = no_os_spi_remove(dev->spi_dev);
+	if (ret)
+		return ret;
+
+	free(dev);
+
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ad413x.h	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,635 @@
+/***************************************************************************//**
+ *   @file   ad413x.h
+ *   @brief  Header file of AD413X Driver.
+ *   @author Andrei Porumb (andrei.porumb@analog.com)
+********************************************************************************
+ * Copyright 2022(c) 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.
+ *  - 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.
+ *  - Use of the software either in source or binary form, must be run
+ *    on or directly connected to an Analog Devices Inc. component.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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.
+*******************************************************************************/
+
+#ifndef AD413X_H_
+#define AD413X_H_
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+#include <stdint.h>
+#include "no_os_delay.h"
+#include "no_os_gpio.h"
+#include "no_os_spi.h"
+#include "no_os_irq.h"
+#include "no_os_util.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definitions **********************/
+/******************************************************************************/
+#define AD413X_CMD_WR_COM_REG(x)	(0x00 | ((x) & 0x3F)) // Write to Register x
+#define AD413X_CMD_RD_COM_REG(x) 	(0x40 | ((x) & 0x3F)) // Read from Register x
+
+/*************************** ADC Register Lengths *****************************/
+#define AD413X_R1B				(1 << 8)
+#define AD413X_R2B				(2 << 8)
+#define AD413X_R3B				(3 << 8)
+#define AD413X_TRANSF_LEN(x)			(((x) >> 8) & 0xFF)
+
+/***************************** ADC Register Map *******************************/
+#define AD413X_REG_STATUS 			(AD413X_R1B | 0x0)
+#define AD413X_REG_ADC_CTRL			(AD413X_R2B | 0x1)
+#define AD413X_REG_DATA				(AD413X_R3B | 0x2)
+#define AD413X_REG_IO_CTRL			(AD413X_R2B | 0x3)
+#define AD413X_REG_VBIAS_CTRL			(AD413X_R2B | 0x4)
+#define AD413X_REG_ID				(AD413X_R1B | 0x5)
+#define AD413X_REG_ERROR			(AD413X_R2B | 0x6)
+#define AD413X_REG_ERROR_EN			(AD413X_R2B | 0x7)
+#define AD413X_REG_MCLK_CNT			(AD413X_R1B | 0x8)
+#define AD413X_REG_CHN(x)			(AD413X_R3B | (0x09U + (x)))
+#define AD413X_REG_CONFIG(x)			(AD413X_R2B | (0x19U + (x)))
+#define AD413X_REG_FILTER(x)			(AD413X_R3B | (0x21U + (x)))
+#define AD413X_REG_OFFSET(x)			(AD413X_R3B | (0x29U + (x)))
+#define AD413X_REG_GAIN(x)			(AD413X_R3B | (0x31U + (x)))
+#define AD413X_REG_MISC				(AD413X_R2B | 0x39)
+#define AD413X_REG_FIFO_CTRL			(AD413X_R3B | 0x3A)
+#define AD413X_REG_FIFO_STS			(AD413X_R1B | 0x3B)
+#define AD413X_REG_FIFO_THRSHLD			(AD413X_R3B | 0x3C)
+#define AD413X_REG_FIFO_DATA			(AD413X_R3B | 0x3D)
+
+
+/* ADC_CONTROL Register */
+#define AD413X_ADC_BIPOLAR				NO_OS_BIT(14)
+#define AD413X_ADC_REF_VAL				NO_OS_BIT(13)
+#define AD413X_ADC_DOUT_DIS_DEL				NO_OS_BIT(12)
+#define AD413X_ADC_CONT_READ				NO_OS_BIT(11)
+#define AD413X_ADC_DATA_STATUS				NO_OS_BIT(10)
+#define AD413X_ADC_CSB_EN				NO_OS_BIT(9)
+#define AD413X_ADC_REF_EN				NO_OS_BIT(8)
+#define AD413X_ADC_DUTY_CYC_RATIO			NO_OS_BIT(6)
+#define AD413X_ADC_MODE(x)				(((x) & 0xF) << 2)
+#define AD413X_ADC_CNTRL_MCLK(x)			((x) & 0x3)
+
+/* IO_CONTROL Register */
+#define AD413X_SYNCB_CLEAR 				NO_OS_BIT(10)
+#define AD413X_INT_PIN_SEL(x) 				(((x) & 0x3) << 8)
+#define AD413X_GPO_DATA_P4 				NO_OS_BIT(7)
+#define AD413X_GPO_DATA_P3 				NO_OS_BIT(6)
+#define AD413X_GPO_DATA_P2 				NO_OS_BIT(5)
+#define AD413X_GPO_DATA_P1 				NO_OS_BIT(4)
+#define AD413X_GPO_CTRL_P4		 		NO_OS_BIT(3)
+#define AD413X_GPO_CTRL_P3		 		NO_OS_BIT(2)
+#define AD413X_GPO_CTRL_P2		 		NO_OS_BIT(1)
+#define AD413X_GPO_CTRL_P1		 		0x01
+
+/* VBIAS_CTRL Register */
+#define AD413X_VBIAS_15					NO_OS_BIT(15)
+#define AD413X_VBIAS_14					NO_OS_BIT(14)
+#define AD413X_VBIAS_13					NO_OS_BIT(13)
+#define AD413X_VBIAS_12					NO_OS_BIT(12)
+#define AD413X_VBIAS_11					NO_OS_BIT(11)
+#define AD413X_VBIAS_10					NO_OS_BIT(10)
+#define AD413X_VBIAS_9					NO_OS_BIT(9)
+#define AD413X_VBIAS_8					NO_OS_BIT(8)
+#define AD413X_VBIAS_7					NO_OS_BIT(7)
+#define AD413X_VBIAS_6					NO_OS_BIT(6)
+#define AD413X_VBIAS_5					NO_OS_BIT(5)
+#define AD413X_VBIAS_4					NO_OS_BIT(4)
+#define AD413X_VBIAS_3					NO_OS_BIT(3)
+#define AD413X_VBIAS_2					NO_OS_BIT(2)
+#define AD413X_VBIAS_1					NO_OS_BIT(1)
+#define AD413X_VBIAS_0					0x01
+
+/* ERROR Register */
+#define AD413X_AINP_OV_UV_ERR				NO_OS_BIT(11)
+#define AD413X_AINM_OV_UV_ERR				NO_OS_BIT(10)
+#define AD413X_REF_OV_UV_ERR				NO_OS_BIT(9)
+#define AD413X_REF_DETECT_ERR				NO_OS_BIT(8)
+#define AD413X_ADC_ERR					NO_OS_BIT(7)
+#define AD413X_SPI_IGNORE_ERR				NO_OS_BIT(6)
+#define AD413X_SPI_SCLK_CNT_ERR				NO_OS_BIT(5)
+#define AD413X_SPI_READ_ERR				NO_OS_BIT(4)
+#define AD413X_SPI_WRITE_ERR				NO_OS_BIT(3)
+#define AD413X_SPI_CRC_ERR				NO_OS_BIT(2)
+#define AD413X_MM_CRC_ERR				NO_OS_BIT(1)
+#define AD413X_ROM_CRC_ERR				0x01
+
+/* ERROR_EN Register */
+#define AD413X_MCLK_CNT_EN				NO_OS_BIT(12)
+#define AD413X_AINP_OV_UV_ERR_EN			NO_OS_BIT(11)
+#define AD413X_AINM_OV_UV_ERR_EN			NO_OS_BIT(10)
+#define AD413X_REF_OV_UV_ERR_EN				NO_OS_BIT(9)
+#define AD413X_REF_DETECT_ERR_EN			NO_OS_BIT(8)
+#define AD413X_ADC_ERR_EN				NO_OS_BIT(7)
+#define AD413X_SPI_IGNORE_ERR_EN			NO_OS_BIT(6)
+#define AD413X_SPI_SCLK_CNT_ERR_EN			NO_OS_BIT(5)
+#define AD413X_SPI_READ_ERR_EN				NO_OS_BIT(4)
+#define AD413X_SPI_WRITE_ERR_EN				NO_OS_BIT(3)
+#define AD413X_SPI_CRC_ERR_EN				NO_OS_BIT(2)
+#define AD413X_MM_CRC_ERR_EN				NO_OS_BIT(1)
+#define AD413X_ROM_CRC_ERR_EN				0x01
+
+/* CHANNEL_M Register */
+#define AD413X_ENABLE_M					NO_OS_BIT(23)
+#define AD413X_SETUP_M(x)				(((x) & 0x7) << 20)
+#define AD413X_PDSW_M					NO_OS_BIT(19)
+#define AD413X_THRES_EN_M				NO_OS_BIT(18)
+#define AD413X_AINP_M(x)				(((x) & 0x1F) << 13)
+#define AD413X_AINM_M(x)				(((x) & 0x1F) <<  8)
+#define AD413X_I_OUT1_CH_M(x)				(((x) & 0xF) <<   4)
+#define AD413X_I_OUT0_CH_M(x)				((x) & 0xF)
+#define AD413X_I_OUT_CH_MSK				NO_OS_GENMASK(7,0)
+
+/* CONFIG_N Register */
+#define AD413X_I_OUT1_N(x)				(((x) & 0x7) << 13)
+#define AD413X_I_OUT0_N(x)				(((x) & 0x7) << 10)
+#define AD413X_I_OUT_MSK				NO_OS_GENMASK(15,10)
+#define AD413X_BURNOUT_N(x)				(((x) & 0x3) <<  8)
+#define AD413X_REF_BUF_MSK				NO_OS_GENMASK(7,6)
+#define AD413X_REF_BUFP_N				NO_OS_BIT(7)
+#define AD413X_REF_BUFM_N				NO_OS_BIT(6)
+#define AD413X_REF_SEL_N(x)				(((x) & 0x3) <<  4)
+#define AD413X_PGA_N(x)					(((x) & 0x7) <<  1)
+#define AD413X_PGA_BYP_N				0x01
+
+/* FILTER_N Register */
+#define AD413X_SETTLE_N(x)				(((x) & 0x7) <<  21)
+#define AD413X_REPEAT_N(x)				(((x) & 0x1F) << 16)
+#define AD413X_FILTER_MODE_N(x)				(((x) & 0xF) <<  12)
+#define AD413X_FS_N(x)					((x) & 0x7FF)
+
+/* OFFSET_N Register */
+#define AD413X_OFFSET_N(x)				((x) & 0xFFFFFF)
+
+/* GAIN_N Register */
+#define AD413X_GAIN_N(x)				((x) & 0xFFFFFF)
+
+/* MISC Register */
+#define AD413X_BYPASS_OSC				NO_OS_BIT(15)
+#define AD413X_PD_ALDO					NO_OS_BIT(14)
+#define AD413X_CAL_RANGE_X2				NO_OS_BIT(13)
+#define AD413X_RESERVED(x)				(((x) & 0xF) << 9)
+#define AD413X_STBY_CTRL_MSK				NO_OS_GENMASK(8,0)
+#define AD413X_STBY_OUT_EN				NO_OS_BIT(8)
+#define AD413X_STBY_DIAGNOSTICS_EN			NO_OS_BIT(7)
+#define AD413X_STBY_GPO_EN				NO_OS_BIT(6)
+#define AD413X_STBY_PDSW_EN				NO_OS_BIT(5)
+#define AD413X_STBY_BURNOUT_EN				NO_OS_BIT(4)
+#define AD413X_STBY_VBIAS_EN				NO_OS_BIT(3)
+#define AD413X_STBY_IEXC_EN				NO_OS_BIT(2)
+#define AD413X_STBY_REFHOL_EN				NO_OS_BIT(1)
+#define AD413X_STBY_INTREF_EN				0x01
+
+/* FIFO_CONTROL Register */
+#define AD413X_ADD_FIFO_STATUS				NO_OS_BIT(19)
+#define AD413X_ADD_FIFO_HEADER				NO_OS_BIT(18)
+#define AD413X_FIFO_MODE(x) 				(((x) & 0x3) << 16)
+#define AD413X_FIFO_WRITE_ERR_INT_EN 			NO_OS_BIT(14)
+#define AD413X_FIFO_READ_ERR_INT_EN 			NO_OS_BIT(13)
+#define AD413X_THRES_HIGH_INT_EN 			NO_OS_BIT(12)
+#define AD413X_THRES_LOW_INT_EN  			NO_OS_BIT(11)
+#define AD413X_OVERRUN_INT_EN 				NO_OS_BIT(10)
+#define AD413X_WATERMARK_INT_EN 			NO_OS_BIT(9)
+#define AD413X_EMPTY_INT_EN 				NO_OS_BIT(8)
+#define AD413X_WATERMARK(x) 				((x) & 0xFF)
+
+/* FIFO_STATUS Register */
+#define AD413X_MASTER_ERR 				NO_OS_BIT(7)
+#define AD413X_FIFO_WRITE_ERR 				NO_OS_BIT(6)
+#define AD413X_FIFO_READ_ERR 				NO_OS_BIT(5)
+#define AD413X_THRES_HIGH_FLAG 				NO_OS_BIT(4)
+#define AD413X_THRES_LOW_FLAG 				NO_OS_BIT(3)
+#define AD413X_OVERRUN_FLAG 				NO_OS_BIT(2)
+#define AD413X_WATERMARK_FLAG 				NO_OS_BIT(1)
+#define AD413X_EMPTY_FLAG 				0x01
+
+/* FIFO_THRESHOLD Register */
+#define AD413X_THRES_HIGH_VAL(x)		(((x) & 0xFFF) << 12)
+#define AD413X_THRES_LOW_VAL(x)			((x) & 0xFFF)
+
+/* 8-bits wide checksum generated using the polynomial */
+#define AD413X_CRC8_POLY	0x07 // x^8 + x^2 + x^1 + x^0
+
+#define ENABLE				1U
+#define DISABLE				0U
+
+/******************************************************************************/
+/*************************** Types Declarations *******************************/
+/******************************************************************************/
+/**
+ * @enum ad413x_input
+ * @brief ADC input sources for each channel.
+ */
+enum ad413x_input {
+	AD413X_AIN0,
+	AD413X_AIN1,
+	AD413X_AIN2,
+	AD413X_AIN3,
+	AD413X_AIN4,
+	AD413X_AIN5,
+	AD413X_AIN6,
+	AD413X_AIN7,
+	AD413X_AIN8,
+	AD413X_AIN9,
+	AD413X_AIN10,
+	AD413X_AIN11,
+	AD413X_AIN12,
+	AD413X_AIN13,
+	AD413X_AIN14,
+	AD413X_AIN15,
+	AD413X_TEMP,
+	AD413X_AVSS,
+	AD413X_INT_REF,
+	AD413X_DGND,
+	AD413X_AVDD_AVSS_6P,
+	AD413X_AVDD_AVSS_6M,
+	AD413X_IOVDD_DGND_6P,
+	AD413X_IOVDD_DGND_6M,
+	AD413X_ALDO_AVSS_6P,
+	AD413X_ALDO_AVSS_6M,
+	AD413X_DLDO_DGND_6P,
+	AD413X_DLDO_DGND_6M,
+	AD413X_V_MV_P,
+	AD413X_V_MV_M,
+};
+
+/**
+ * @enum ad413x_preset_nb
+ * @brief Preset number.
+ */
+enum ad413x_preset_nb {
+	AD413X_PRESET_0,
+	AD413X_PRESET_1,
+	AD413X_PRESET_2,
+	AD413X_PRESET_3,
+	AD413X_PRESET_4,
+	AD413X_PRESET_5,
+	AD413X_PRESET_6,
+	AD413X_PRESET_7
+};
+
+/**
+ * @enum ad413x_mclk_sel
+ * @brief Master clock options.
+ */
+enum ad413x_mclk_sel {
+	AD413X_INT_76_8_KHZ_OUT_OFF,
+	AD413X_INT_76_8_KHZ_OUT_ON,
+	AD413X_EXT_76_8KHZ,
+	AD413X_EXT_153_6_KHZ_DIV_2
+};
+
+/**
+ * @enum ad413x_adc_mode
+ * @brief ADC conversion modes.
+ */
+enum ad413x_adc_mode {
+	AD413X_CONTINOUS_CONV_MODE = 0,
+	AD413X_SINGLE_CONV_MODE = 1,
+	AD413X_STANDBY_MODE = 2,
+	AD413X_PW_DOWN_MODE = 3,
+	AD413X_IDLE_MODE = 4,
+	AD413X_INT_OFFSET_CAL = 5,
+	AD413X_INT_GAIN_CAL = 6,
+	AD413X_SYS_OFFSET_CAL = 7,
+	AD413X_SYS_GAIN_CAL = 8,
+	AD413X_DUTY_CYCLING_MODE = 9,
+	AD413X_SINGLE_CONV_SYNC_IDLE_MODE = 10,
+	AD413X_DUTY_CYCLING_SYNC_STBY_MODE = 11
+};
+
+/**
+ * @struct ad413x_ref_buf
+ * @brief ADC reference buffer selection.
+ */
+struct ad413x_ref_buf {
+	bool ref_buf_p_en;
+	bool ref_buf_m_en;
+};
+
+/**
+ * @enum ad413x_ref_sel
+ * @brief ADC reference selection.
+ */
+enum ad413x_ref_sel {
+	AD413X_REFIN1,
+	AD413X_REFIN2,
+	AD413X_REFOUT_AVSS,
+	AD413X_AVDD_AVSS
+};
+
+/**
+ * @enum ad413x_int_ref
+ * @brief Internal reference selection.
+ */
+enum ad413x_int_ref {
+	AD413X_INTREF_DISABLED,
+	AD413X_INTREF_2_5V,
+	AD413X_INTREF_1_25V
+};
+
+/**
+ * @enum ad413x_filter
+ * @brief Filter types.
+ */
+enum ad413x_filter {
+	AD413X_SYNC4_STANDALONE,
+	AD413X_SYNC4_SYNC1,
+	AD413X_SYNC3_STANDALONE,
+	AD413X_SYNC3_REJ60,
+	AD413X_SYNC3_SYNC1,
+	AD413X_SYNC3_PF1,
+	AD413X_SYNC3_PF2,
+	AD413X_SYNC3_PF3,
+	AD413X_SYNC3_PF4
+};
+
+/**
+ * @enum ad413x_gain
+ * @brief Gain options.
+ */
+enum ad413x_gain {
+	AD413X_GAIN_1,
+	AD413X_GAIN_2,
+	AD413X_GAIN_4,
+	AD413X_GAIN_8,
+	AD413X_GAIN_16,
+	AD413X_GAIN_32,
+	AD413X_GAIN_64,
+	AD413X_GAIN_128,
+};
+
+/**
+ * @enum ad413x_chip_id
+ * @brief Chip IDs.
+ */
+enum ad413x_chip_id {
+	/* TBD */
+	AD4130_8 = 0x00
+};
+
+/**
+ * @enum ad413x_settle_time
+ * @brief Channel settle time.
+ */
+enum ad413x_settle_time {
+	AD413X_32_MCLK,
+	AD413X_64_MCLK,
+	AD413X_128_MCLK,
+	AD413X_256_MCLK,
+	AD413X_512_MCLK,
+	AD413X_1024_MCLK,
+	AD413X_2048_MCLK,
+	AD413X_4096_MCLK
+};
+
+/**
+ * @enum ad413x_exc_current
+ * @brief Excitation current value
+ */
+enum ad413x_exc_current {
+	AD413X_EXC_OFF,
+	AD413X_EXC_10UA,
+	AD413X_EXC_20UA,
+	AD413X_EXC_50UA,
+	AD413X_EXC_100UA,
+	AD413X_EXC_150UA,
+	AD413X_EXC_200UA,
+	AD413X_EXC_100NA
+};
+
+/**
+ * @struct ad413x_standby_ctrl
+ * @brief Standby control flags
+ */
+struct ad413x_standby_ctrl {
+	bool standby_int_ref_en;
+	bool standby_ref_holder_en;
+	bool standby_iexc_en;
+	bool standby_vbias_en;
+	bool standby_burnout_en;
+	bool standby_pdsw_en;
+	bool standby_gpio_en;
+	bool standby_diagn_en;
+	bool standby_output_en;
+};
+
+/**
+ * @struct ad413x_preset
+ * @brief Preset setting.
+ */
+struct ad413x_preset {
+	struct ad413x_ref_buf ref_buf;
+	enum ad413x_ref_sel ref_sel;
+	enum ad413x_gain gain;
+	enum ad413x_filter filter;
+	/* By default, settle time = 32MCLK */
+	enum ad413x_settle_time s_time;
+	enum ad413x_exc_current iout0_exc_current;
+	enum ad413x_exc_current iout1_exc_current;
+};
+
+/**
+ * @struct ad413x_channel
+ * @brief Channel setting.
+ */
+struct ad413x_channel {
+	enum ad413x_preset_nb preset;
+	uint8_t enable;
+	enum ad413x_input ain_p;
+	enum ad413x_input ain_m;
+	enum ad413x_input iout0_exc_input;
+	enum ad413x_input iout1_exc_input;
+	bool pdsw_en;
+};
+
+/**
+ * @struct ad413x_dev
+ * @brief Device structure.
+ */
+struct ad413x_dev {
+	/* SPI */
+	struct no_os_spi_desc			*spi_dev;
+	/* GPIO - used to know when conversion is rdy */
+	struct no_os_irq_ctrl_desc *irq_desc;
+	uint32_t rdy_pin;
+	/* Device Settings */
+	struct ad413x_preset preset[8];
+	struct ad413x_channel ch[16];
+	enum ad413x_chip_id chip_id;
+	enum ad413x_mclk_sel mclk;
+	enum ad413x_adc_mode op_mode;
+	uint8_t bipolar;
+	enum ad413x_int_ref int_ref;
+	uint16_t v_bias;
+	struct ad413x_standby_ctrl standby_ctrl;
+	uint8_t data_stat;
+	uint8_t spi_crc_en;
+};
+
+/**
+ * @struct ad413x_init_param
+ * @brief Initial parameter structure.
+ */
+struct ad413x_init_param {
+	/* SPI */
+	struct no_os_spi_init_param	*spi_init;
+	/* GPIO - used to know when conversion is rdy */
+	struct no_os_irq_ctrl_desc *irq_desc;
+	uint32_t rdy_pin;
+	/* Device Settings */
+	struct ad413x_preset preset[8];
+	struct ad413x_channel ch[16];
+	enum ad413x_chip_id chip_id;
+	enum ad413x_mclk_sel mclk;
+	uint8_t bipolar;
+	enum ad413x_int_ref int_ref;
+	uint16_t v_bias;
+	struct ad413x_standby_ctrl standby_ctrl;
+	uint8_t data_stat;
+	uint8_t spi_crc_en;
+};
+
+/**
+ * @struct ad413x_callback_ctx
+ * @brief Callback structure.
+ */
+struct ad413x_callback_ctx {
+	struct ad413x_dev *dev;
+	int32_t *buffer;
+	int32_t buffer_size;
+};
+
+/******************************************************************************/
+/************************ Functions Declarations ******************************/
+/******************************************************************************/
+/* SPI write to device using a mask. */
+int32_t ad413x_reg_write_msk(struct ad413x_dev *dev,
+			     uint32_t reg_addr,
+			     uint32_t data,
+			     uint32_t mask);
+
+/* Set the mode of the ADC. */
+int32_t ad413x_set_adc_mode(struct ad413x_dev *dev, enum ad413x_adc_mode mode);
+
+/* Set the internal reference. */
+int32_t ad413x_set_int_ref(struct ad413x_dev *dev, enum ad413x_int_ref int_ref);
+
+/* Enable/disable DATA_STAT. */
+int32_t ad413x_data_stat_en(struct ad413x_dev *dev, uint8_t enable);
+
+/* Set the gain. */
+int32_t ad413x_set_gain(struct ad413x_dev *dev, enum ad413x_gain gain,
+			enum ad413x_preset_nb reg_nb);
+
+/* Set the reference. */
+int32_t ad413x_set_ref(struct ad413x_dev *dev, enum ad413x_ref_sel ref,
+		       enum ad413x_preset_nb reg_nb);
+
+/* Set the reference buffers */
+int32_t ad413x_set_ref_buf(struct ad413x_dev *dev,
+			   struct ad413x_ref_buf ref_buf,
+			   enum ad413x_preset_nb reg_nb);
+
+/* Set the filter */
+int32_t ad413x_set_filter(struct ad413x_dev *dev, enum ad413x_filter filter,
+			  enum ad413x_preset_nb reg_nb);
+
+/* Set settle time */
+int32_t ad413x_set_settle_time(struct ad413x_dev *dev,
+			       enum ad413x_settle_time s_time,
+			       enum ad413x_preset_nb reg_nb);
+
+/* Set excitation currents */
+int32_t ad413x_set_exc_current(struct ad413x_dev *dev,
+			       enum ad413x_exc_current iout0_exc,
+			       enum ad413x_exc_current iout1_exc,
+			       enum ad413x_preset_nb reg_nb);
+
+/* Set excitation source pins */
+int32_t ad413x_ch_exc_input(struct ad413x_dev *dev, uint8_t ch_nb,
+			    enum ad413x_input iout0_exc_inp,
+			    enum ad413x_input iout1_exc_inp);
+
+/* Set channel preset */
+int32_t ad413x_set_ch_preset(struct ad413x_dev *dev, uint8_t ch_nb,
+			     enum ad413x_preset_nb preset_nb);
+
+/* Enable channel */
+int32_t ad413x_ch_en(struct ad413x_dev *dev, uint8_t ch_nb, uint8_t enable);
+
+/* Enable PDSW */
+int32_t ad413x_pdsw_en(struct ad413x_dev *dev, uint8_t ch_nb, bool pdsw_en);
+
+/* Set output VBIAS */
+int32_t ad413x_set_v_bias(struct ad413x_dev *dev, uint16_t v_bias_val);
+
+/* Set standby control flags */
+int32_t ad413x_set_standby_ctrl(struct ad413x_dev *dev,
+				struct ad413x_standby_ctrl standby_ctrl);
+
+/* Set ADC master clock mode. */
+int32_t ad413x_set_mclk(struct ad413x_dev *dev, enum ad413x_mclk_sel clk);
+
+/* Do a SPI software reset. */
+int32_t ad413x_do_soft_reset(struct ad413x_dev *dev);
+
+/* SPI internal register write to device. */
+int32_t ad413x_reg_write(struct ad413x_dev *dev,
+			 uint32_t reg_addr,
+			 uint32_t reg_data);
+
+/* SPI internal register read from device. */
+int32_t ad413x_reg_read(struct ad413x_dev *dev,
+			uint32_t reg_addr,
+			uint32_t *reg_data);
+
+/* Fills buffer with data read from each active channel */
+int32_t ad413x_single_conv(struct ad413x_dev *dev, uint32_t *buffer,
+			   uint8_t ch_nb);
+
+/* Fills buffer with data from continuous conv mode from each active channel */
+int32_t ad413x_continuous_conv(struct ad413x_dev *dev, uint32_t *buffer,
+			       uint8_t ch_nb, uint32_t sample_nb);
+
+/* Set adc bipolar/unipolar coding. */
+int32_t ad413x_adc_bipolar(struct ad413x_dev *dev, uint8_t enable);
+
+/* Store presets for adc channels */
+int32_t ad413x_preset_store(struct ad413x_dev *dev, struct ad413x_preset preset,
+			    enum ad413x_preset_nb preset_nb);
+
+/* Initialize the device. */
+int32_t ad413x_init(struct ad413x_dev **device,
+		    struct ad413x_init_param init_param);
+
+/* Remove the device. */
+int32_t ad413x_remove(struct ad413x_dev *dev);
+
+#endif // AD413X_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/app_config.c	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,195 @@
+/***************************************************************************//**
+ *   @file    app_config.c
+ *   @brief   Application configurations module
+ *   @details This module contains the configurations needed for IIO application
+********************************************************************************
+ * Copyright (c) 2020-2022 Analog Devices, Inc.
+ *
+ * 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 "ad4130_data_capture.h"
+#include "no_os_error.h"
+#include "no_os_uart.h"
+#include "no_os_irq.h"
+#include "no_os_gpio.h"
+
+/******************************************************************************/
+/************************ Macros/Constants ************************************/
+/******************************************************************************/
+
+/******************************************************************************/
+/******************** Variables and User Defined Data Types *******************/
+/******************************************************************************/
+
+/* UART init parameters */
+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
+};
+
+/* SPI initialization parameters */
+struct no_os_spi_init_param spi_init_params = {
+	.max_speed_hz = 10000000,		// Max SPI Speed
+	.chip_select = SPI_CSB,			// Chip Select
+	.mode = NO_OS_SPI_MODE_3,		// CPOL = 1, CPHA = 1
+	.platform_ops = &spi_ops,
+	.extra = &spi_extra_init_params	// SPI extra configurations
+};
+
+/* External interrupt init parameters */
+static struct no_os_irq_init_param ext_int_init_params = {
+	.irq_ctrl_id = EXT_INT_ID,
+	.platform_ops = &irq_ops,
+	.extra = &ext_int_extra_init_params
+};
+
+/* External interrupt callback descriptor */
+static struct no_os_callback_desc ext_int_callback_desc = {
+#if (DATA_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE)
+	data_capture_callback,
+#elif (DATA_CAPTURE_MODE == FIFO_DATA_CAPTURE)
+	fifo_data_capture_callback,
+#else
+	NULL,
+#endif
+	NULL,
+	NULL
+};
+
+/* Conversion monitor GPO init parameters */
+static struct no_os_gpio_init_param conv_mon_gpio_init_params = {
+	.number = CONV_MON,
+	.platform_ops = &gpio_ops,
+	.extra = NULL
+};
+
+/* UART descriptor */
+struct no_os_uart_desc *uart_desc;
+
+/* External interrupt descriptor */
+struct no_os_irq_ctrl_desc *external_int_desc;
+
+/* LED GPO descriptor */
+struct no_os_gpio_desc *conv_mon_gpio_desc = NULL;
+
+/******************************************************************************/
+/************************ Functions Prototypes ********************************/
+/******************************************************************************/
+
+/******************************************************************************/
+/************************ 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 conversion monitor GPO */
+	ret = no_os_gpio_get_optional(&conv_mon_gpio_desc,
+				      &conv_mon_gpio_init_params);
+	if (ret) {
+		return ret;
+	}
+
+	ret = no_os_gpio_direction_input(conv_mon_gpio_desc);
+	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;
+
+#if (DATA_CAPTURE_MODE != BURST_DATA_CAPTURE_MODE)
+	/* Init interrupt controller for external interrupt (for monitoring
+	 * conversion event on BUSY pin) */
+	ext_int_extra_init_params.ext_int_pin = CONV_MON;
+	ret = no_os_irq_ctrl_init(&external_int_desc, &ext_int_init_params);
+	if (ret) {
+		return ret;
+	}
+
+	/* Register a callback function for external interrupt */
+	ret = no_os_irq_register_callback(external_int_desc,
+					  EXT_INT_ID,
+					  &ext_int_callback_desc);
+	if (ret) {
+		return ret;
+	}
+
+	/* Enable external interrupt */
+	ret = no_os_irq_enable(external_int_desc, EXT_INT_ID);
+	if (ret) {
+		return ret;
+	}
+#endif
+
+	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;
+	}
+
+	ret = init_interrupt();
+	if (ret) {
+		return ret;
+	}
+
+#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	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,204 @@
+/*************************************************************************//**
+ *   @file   app_config.h
+ *   @brief  Configuration file for AD4130 device applications
+******************************************************************************
+* Copyright (c) 2020-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 _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 for AD4130 device */
+#define BURST_DATA_CAPTURE			0
+#define CONTINUOUS_DATA_CAPTURE		1
+#define FIFO_DATA_CAPTURE			2
+
+/* List of demo mode configurations */
+#define		USER_DEFAULT_CONFIG		0
+#define		RTD_2WIRE_CONFIG		1
+#define		RTD_3WIRE_CONFIG		2
+#define		RTD_4WIRE_CONFIG		3
+#define		THERMISTOR_CONFIG		4
+#define		THERMOCOUPLE_CONFIG		5
+#define		LOADCELL_CONFIG			6
+#define		ECG_CONFIG				7
+#define		NOISE_TEST_CONFIG		8
+#define		POWER_TEST_CONFIG		9
+
+/* Macros for stringification */
+#define XSTR(s)		#s
+#define STR(s)		XSTR(s)
+
+/******************************************************************************/
+
+/* Name of active device */
+#define ACTIVE_DEVICE_NAME	"ad4130"
+
+/* Select the AD4130 package type (required for interrupt source) */
+#define AD4130_WLCSP_PACKAGE_TYPE
+//#define AD4130_LFCSP_PACKAGE_TYPE
+
+/* Select the active platform (default is Mbed) */
+#if !defined(ACTIVE_PLATFORM)
+#define ACTIVE_PLATFORM		MBED_PLATFORM
+#endif
+
+/* Select the demo mode configuration (default is user config) */
+#if !defined(ACTIVE_DEMO_MODE_CONFIG)
+#define ACTIVE_DEMO_MODE_CONFIG		USER_DEFAULT_CONFIG
+#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 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-AD4130-8WASDZ"
+#define HW_NAME				ACTIVE_DEVICE_NAME
+
+/* Include user config files and params according to active/selected
+ * demo mode config */
+#if (ACTIVE_DEMO_MODE_CONFIG == USER_DEFAULT_CONFIG)
+#include "ad4130_user_config.h"
+#define ad4130_init_params	ad4130_user_config_params
+#elif ((ACTIVE_DEMO_MODE_CONFIG == RTD_2WIRE_CONFIG) || \
+(ACTIVE_DEMO_MODE_CONFIG == RTD_3WIRE_CONFIG) || \
+(ACTIVE_DEMO_MODE_CONFIG == RTD_4WIRE_CONFIG))
+#include "ad4130_rtd_config.h"
+#define ad4130_init_params	ad4130_rtd_config_params
+#elif (ACTIVE_DEMO_MODE_CONFIG == THERMISTOR_CONFIG)
+#include "ad4130_thermistor_config.h"
+#define ad4130_init_params	ad4130_thermistor_config_params
+#elif (ACTIVE_DEMO_MODE_CONFIG == THERMOCOUPLE_CONFIG)
+#include "ad4130_thermocouple_config.h"
+#define ad4130_init_params	ad4130_thermocouple_config_params
+#elif (ACTIVE_DEMO_MODE_CONFIG == LOADCELL_CONFIG)
+#include "ad4130_loadcell_config.h"
+#define ad4130_init_params	ad4130_loadcell_config_params
+#elif (ACTIVE_DEMO_MODE_CONFIG == ECG_CONFIG)
+#include "ad4130_ecg_config.h"
+#define ad4130_init_params	ad4130_ecg_config_params
+#elif (ACTIVE_DEMO_MODE_CONFIG == NOISE_TEST_CONFIG)
+#include "ad4130_noise_test_config.h"
+#define ad4130_init_params	ad4130_noise_test_config_params
+#elif (ACTIVE_DEMO_MODE_CONFIG == POWER_TEST_CONFIG)
+#include "ad4130_power_test_config.h"
+#define ad4130_init_params	ad4130_power_test_config_params
+#else
+#include "ad4130_user_config.h"
+#define ad4130_init_params	ad4130_user_config_params
+#warning "No/Invalid active demo config selected, user config used as default"
+#endif
+
+/* ADC resolution for active device */
+#define ADC_RESOLUTION		24
+
+/* Number of ADC presets/setups */
+#define ADC_PRESETS			7
+
+/* Number of actually used ADC channels.
+ * Note : There can be max 16 channels in the device sequencer but since
+ * input pairs can be only 8 or 16, either 8 or 16 channels are exposed
+ * out, based on the user selected channel configuration.
+ * The auxilary inputs(such as temperature, ref, etc) are not used.
+ * */
+#define	ADC_DIFFERENTIAL_CHNS	8
+#define	ADC_PSEUDO_DIFF_CHNS	16
+
+/* Default ADC reference voltages for each reference source */
+#define AD4130_REFIN1_VOLTAGE			2.5
+#define AD4130_REFIN2_VOLTAGE			2.5
+#define AD4130_AVDD_VOLTAGE				3.3		// 3.3 or 1.8
+#define AD4170_2_5V_INT_REF_VOLTAGE		2.5
+#define AD4170_1_25V_INT_REF_VOLTAGE	1.25
+
+/* 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))
+
+/****** Macros used to form a VCOM serial number ******/
+#if !defined(FIRMWARE_NAME)
+#define	FIRMWARE_NAME	"ad4130_iio_application"
+#endif
+
+#if !defined(DEVICE_NAME)
+#define DEVICE_NAME		"DEV_AD4130"
+#endif
+
+#if !defined(PLATFORM_NAME)
+#define PLATFORM_NAME	HW_CARRIER_NAME
+#endif
+
+#if !defined(EVB_INTERFACE)
+#define EVB_INTERFACE	"ARDUINO"
+#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 + evb interface name */
+#define VIRTUAL_COM_SERIAL_NUM	(FIRMWARE_NAME "_" DEVICE_NAME "_" PLATFORM_NAME "_" EVB_INTERFACE)
+#endif
+
+/* Baud rate for IIO application 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 Declarations *********************************/
+/******************************************************************************/
+
+extern struct no_os_uart_desc *uart_desc;
+extern struct no_os_gpio_desc *conv_mon_gpio_desc;
+extern struct no_os_spi_init_param spi_init_params;
+
+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	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,63 @@
+/***************************************************************************//**
+ *   @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_RISE,
+	.ext_int_pin = CONV_MON,
+	.int_obj_type = NULL
+};
+
+/* 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	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,83 @@
+/***************************************************************************//**
+ *   @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 "no_os_gpio.h"
+#include "mbed_uart.h"
+#include "mbed_irq.h"
+#include "mbed_spi.h"
+#include "mbed_gpio.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definition ***********************/
+/******************************************************************************/
+
+/* Select b/w Arduino or SDP-120 pin header (default is Arduino) */
+//#define  SDP_120
+
+#ifdef SDP_120
+/* Pin mapping of SDP-K1 w.r.t SDP-120 connector */
+#define SPI_CSB			SDP_SPI_CS_A
+#define SPI_HOST_SDO	SDP_SPI_MOSI
+#define SPI_HOST_SDI	SDP_SPI_MISO
+#define SPI_SCK			SDP_SPI_SCK
+
+#define MBED_CONV_MON	SDP_GPIO_1
+#else
+/* 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
+
+#define MBED_CONV_MON	ARDUINO_UNO_D2
+#endif
+
+#if defined(AD4130_WLCSP_PACKAGE_TYPE)
+#define	CONV_MON	MBED_CONV_MON
+#else
+#define	CONV_MON	ARDUINO_UNO_D2		// Conversion interrupt source pin (The selected interrupt source pin 
+// e.g. MCLK or GPIO needs to be tied to D2 pin on Arduino header).
+// The selection of interrupt source is done in 'iio_data_capture_init' function
+#endif
+
+/* Common pin mapping on SDP-K1 */
+#define UART_TX			CONSOLE_TX
+#define	UART_RX			CONSOLE_RX
+#define LED_GPO			LED3
+
+/* Select FS scaler value for the default user config mode.
+ * This is not a max FS value that can be set into device but rather a value to
+ * achieve max approximate ODR in the firmware for a given platform/setup.
+ * Max ODR is derived by testing the firmware on SDP-K1 controller board
+ * @10Mhz SPI clock. The max possible ODR can vary from board to board and
+ * data continuity is not guaranteed above this ODR on IIO client */
+#define FS_CONFIG_VALUE		1	// ODR = 2.4KSPS
+
+/******************************************************************************/
+/********************** Public/Extern Declarations ****************************/
+/******************************************************************************/
+
+extern struct mbed_irq_init_param mbed_ext_int_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	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,47 @@
+/***************************************************************************//**
+ *   @file    main.c
+ *   @brief   Main module for AD4130 IIO application
+ *   @details This module invokes the AD4130 IIO interfaces
+ *            through forever loop.
+********************************************************************************
+ * Copyright (c) 2020, 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 <stdio.h>
+#include <stdint.h>
+
+#include "ad4130_iio.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definitions **********************/
+/******************************************************************************/
+
+/******************************************************************************/
+/************************ Functions Definitions *******************************/
+/******************************************************************************/
+
+/**
+ * @brief	Main entry point to application
+ * @return	none
+ */
+int main(void)
+{
+	/* Initialize the AD4130 IIO interface */
+	if (ad4130_iio_initialize()) {
+		printf("IIO initialization failure!!\r\n");
+	}
+
+	while (1) {
+		/* Monitor the IIO client events */
+		ad4130_iio_event_handler();
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/no-OS.lib	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,1 @@
+https://github.com/analogdevicesinc/no-OS/#c88339f49acce4f744b9903a77482eb5b342bbce
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/sdp_k1_sdram.lib	Fri Jul 15 17:47:44 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	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,35 @@
+/***************************************************************************//**
+ *   @file    sdram_sdpk1.c
+ *   @brief   SDP-K1 SDRAM interafaces
+********************************************************************************
+ * 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	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,36 @@
+/***************************************************************************//**
+ *   @file    sdram_sdpk1.c
+ *   @brief   SDP-K1 SDRAM interafaces 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_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/tempsensors.lib	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/AnalogDevices/code/tempsensors/#d8246c20aed2
\ No newline at end of file
Binary file docs/ad4130_evb_jumper_settings.xlsx has changed
--- a/main.cpp	Mon May 24 09:13:12 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:13:12 2021 +0000
+++ b/mbed-os.lib	Fri Jul 15 17:47:44 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	Fri Jul 15 17:47:44 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/ad4130.py	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,124 @@
+# Copyright (C) 2021 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.
+#     - 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.
+#     - Use of the software either in source or binary form, must be run
+#       on or directly connected to an Analog Devices Inc. component.
+#
+# THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A
+# PARTICULAR PURPOSE ARE DISCLAIMED.
+#
+# IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY
+# RIGHTS, 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.
+
+
+from decimal import Decimal
+
+import numpy as np
+from adi.attribute import attribute
+from adi.context_manager import context_manager
+from adi.rx_tx import rx
+
+
+class ad4130(rx, context_manager):
+    """ AD4130 ADC """
+
+    _complex_data = False
+    channel = []  # type: ignore
+    _device_name = ""
+
+    def __init__(self, uri="", device_name=""):
+
+        context_manager.__init__(self, uri, self._device_name)
+
+        compatible_parts = [
+            "ad4130"
+        ]
+
+        self._ctrl = None
+
+        if not device_name:
+            device_name = compatible_parts[0]
+        else:
+            if device_name not in compatible_parts:
+                raise Exception("Not a compatible device: " + device_name)
+
+        # Select the device matching device_name as working device
+        for device in self._ctx.devices:
+            if device.name == device_name:
+                self._ctrl = device
+                self._rxadc = device
+                break
+
+        for ch in self._ctrl.channels:
+            name = ch._id
+            self._rx_channel_names.append(name)
+            self.channel.append(self._channel(self._ctrl, name))
+
+        rx.__init__(self)
+
+
+    class _channel(attribute):
+        """AD4130 channel"""
+
+        def __init__(self, ctrl, channel_name):
+            self.name = channel_name
+            self._ctrl = ctrl
+
+        @property
+        def raw(self):
+            """AD4130 channel raw value"""
+            return self._get_iio_attr(self.name, "raw", False)
+
+        @property
+        def offset(self):
+            """AD4130 channel offset"""
+            return float(self._get_iio_attr_str(self.name, "offset", False))
+
+        @offset.setter
+        def offset(self, value):
+            self._set_iio_attr(self.name, "offset", False, str(Decimal(value).real))
+
+        @property
+        def scale(self):
+            """AD4130 channel scale"""
+            return float(self._get_iio_attr_str(self.name, "scale", False))
+
+        @scale.setter
+        def scale(self, value):
+            self._set_iio_attr(self.name, "scale", False, str(Decimal(value).real))
+
+
+    def to_volts(self, index, val):
+        """Converts raw value to SI"""
+        _scale = self.channel[index].scale
+
+        ret = None
+
+        if isinstance(val, np.int16):
+            ret = val * _scale
+
+        if isinstance(val, np.ndarray):
+            ret = [x * _scale for x in val]
+
+        return ret
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ad4130_calibration.py	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,164 @@
+import serial
+from time import sleep
+from ad4130 import *
+from ad4130_xattr import *
+
+# Delays in second
+short_time = 0.2
+
+# Calibration type identifiers
+internal_calibration = '1'
+system_calibration = '2'
+
+# Analog input mapping as configured in the firmware
+ain_mapping = {
+    "User Default" :  [ 'AIN0-AVSS', 'AIN1-AVSS', 'AIN2-AVSS', 'AIN3-AVSS', 
+                        'AIN4-AVSS', 'AIN5-AVSS', 'AIN6-AVSS', 'AIN7-AVSS',
+                        'AIN8-AVSS', 'AIN9-AVSS', 'AIN10-AVSS', 'AIN11-AVSS', 
+                        'AIN12-AVSS', 'AIN13-AVSS', 'AIN14-AVSS', 'AIN15-AVSS'
+                      ],
+    "Thermistor" :    [ 'AIN4-AIN5' ],
+    "Thermocouple" :  [ 'AIN2-AIN3', 'AIN4-AIN5' ],
+    "2-Wire RTD" :    [ 'AIN2-AIN3' ],
+    "3-Wire RTD" :    [ 'AIN2-AIN3' ],
+    "4-Wire RTD" :    [ 'AIN2-AIN3' ],
+    "Loadcell"   :    [ 'AIN5-AIN6' ],
+    "ECG"        :    [ 'AIN11-AIN14' ],
+    "Noise Test" :    [ 'AIN0-AIN1' ],
+}
+
+# IIO Channel name and respective channel index mapping
+chn_mappping = {
+    "voltage0" : 0, "voltage1" : 1, "voltage2" : 2, "voltage3" : 3, "voltage4" : 4,
+    "voltage5" : 5, "voltage6" : 6, "voltage7" : 7, "voltage8" : 8, "voltage9" : 9,
+    "voltage10" : 10, "voltage11" : 11, "voltage12" : 12, "voltage13" : 13,
+    "voltage14" : 14, "voltage15" : 15,
+
+    "current0" : 0, "current1" : 1, "current2" : 2, "current3" : 3, "current4" : 4,
+    "current5" : 5, "current6" : 6, "current7" : 7, "current8" : 8, "current9" : 9,
+    "current10" : 10, "current11" : 11, "current12" : 12, "current13" : 13,
+    "current14" : 14, "current15" : 15,
+
+    "temp0" : 0, "temp1" : 1, "temp2" : 2, "temp3" : 3, "temp4" : 4,
+    "temp5" : 5, "temp6" : 6, "temp7" : 7, "temp8" : 8, "temp9" : 9,
+    "temp10" : 10, "temp11" : 11, "temp12" : 12, "temp13" : 13,
+    "temp14" : 14, "temp15" : 15,
+}
+
+def init_calibration():
+    global device
+    global demo_config
+
+    ######## User configuration ##########
+    # Configure the backend for PC to IIOD interface
+    uri = "serial:COM12,230400"  # For UART, baud rate must be same as set in the FW. COM port is physical Or VCOM.
+    device_name = "ad4130"      # Name of the device must be same as set in the FW.
+    ######################################
+
+    # Create an IIO device context
+    device = ad4130_xattr(uri, device_name)
+    device._ctx.set_timeout(100000)
+
+    # Get current user device config from the firmware
+    demo_config = device.demo_config
+    print("\r\nDemo Config: {}\r\n".format(demo_config))
+
+def get_calibration_status(calibration_type, chn, chn_index):
+    global gain_before_calib, gain_after_calib
+    global offset_before_calib, offset_after_calib
+    global calibration_status
+
+    if (calibration_type == system_calibration):
+        calib_status = chn.system_calibration
+    else:
+        calib_status = chn.internal_calibration
+
+    gain_before_calib = calib_status[0:8]
+    gain_after_calib = calib_status[8:16]
+    offset_before_calib = calib_status[16:24]
+    offset_after_calib = calib_status[24:32]
+    calibration_status = calib_status[32:]
+
+def perform_calibration():
+
+    if (demo_config == "Power Test"):
+        # Power test uses internal ADC channels, on which calibration can't be performed
+        print("Invalid demo mode config. Calibration can't be performed on internal ADC channels!!")
+        return
+
+    # Select calibration type
+    calibration_type = input("\r\nSelect Calibration Type:\r\n\
+                            {}. Internal Calibration\r\n\
+                            {}. System Calibration\r\n".format(internal_calibration, system_calibration))
+    if (calibration_type > system_calibration):
+        print("Invalid Input!!")
+        return
+
+    # Perform calibration for all channels
+    for chn in device.channel:
+        chn_index = chn_mappping[chn.name]
+        print("-------------------------------------------")
+        print("Calibrating channel {} ".format(chn_index))
+
+        if (calibration_type == system_calibration):
+            # Perform zero-scale (offset) system calibration
+            val = input("Apply zero-scale voltage between {} and press enter".format(ain_mapping[demo_config][chn_index]))
+            chn.system_calibration = "start_calibration"
+            sleep(short_time)
+            get_calibration_status(calibration_type, chn, chn_index)
+            print("Offset (before calibration): 0x{}".format(offset_before_calib))
+            print("Offset (after calibration): 0x{}".format(offset_after_calib))
+            if (calibration_status == "calibration_done"):
+                print("System offset calibration successfull..\r\n")
+            else:
+                print("System offset calibration failed!!\r\n")
+
+            # Perform full-scale (gain) system calibration
+            val = input("Apply full-scale voltage between {} and press enter".format(ain_mapping[demo_config][chn_index]))
+            chn.system_calibration = "start_calibration"
+            sleep(short_time)
+            get_calibration_status(calibration_type, chn, chn_index)
+            print("Gain (before calibration): 0x{}".format(gain_before_calib))
+            print("Gain (after calibration): 0x{}".format(gain_after_calib))
+            if (calibration_status == "calibration_done"):
+                print("System gain calibration successfull..\r\n")
+            else:
+                print("System gain calibration failed!!\r\n")
+        else:
+            # Perform full-scale (gain) internal calibration
+            chn.internal_calibration = "start_calibration"
+            sleep(short_time)
+            get_calibration_status(calibration_type, chn, chn_index)
+            print("Gain (before calibration): 0x{}".format(gain_before_calib))
+            print("Gain (after calibration): 0x{}".format(gain_after_calib))
+            if (calibration_status == "calibration_done"):
+                print("Internal gain calibration successfull..\r\n")
+            elif (calibration_status == "calibration_skipped"):
+                print("Internal gain calibration skipped due to PGA=1\r\n")
+            else:
+                print("Internal gain calibration failed..\r\n")
+
+            # Perform zero-scale (offset) internal calibration
+            chn.internal_calibration = "start_calibration"
+            sleep(short_time)
+            get_calibration_status(calibration_type, chn, chn_index)
+            print("Offset (before calibration): 0x{}".format(offset_before_calib))
+            print("Offset (after calibration): 0x{}".format(offset_after_calib))
+            if (calibration_status == "calibration_done"):
+                print("Internal offset calibration successfull..\r\n")
+            else:
+                print("Internal offset calibration failed!!\r\n")
+
+def exit():
+    global device
+
+    # Delete the objects
+    del device
+
+def main():
+    init_calibration()
+    perform_calibration()
+    exit()
+
+if __name__ == "__main__":
+    main()
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ad4130_data_capture.py	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,160 @@
+import numpy
+from serial import Serial
+from time import sleep
+from pynput import keyboard
+import sys
+import select
+import os
+import csv
+import math
+from ad4130 import *
+
+# 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:COM12,230400" # For UART, baud rate must be same as set in the FW. COM port is physical Or VCOM.
+    device_name = "ad4130"      # Name of the device must be same as set in the FW.
+    ######################################
+
+    # Create an IIO device context
+    device = ad4130(uri, device_name)
+    device._ctx.set_timeout(100000)
+
+    ######## User configuration ##########
+    # Channels to be captured e.g. [0]: 1chn, [0,1]: 2chns, [0,1,2,3]: 4chns, [0,1,2,3,4,5,6,7]: 8chns
+    device.rx_enabled_channels = [0]
+
+    # 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.int32     # 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 iterations
+    global run_continuous
+    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/ad4130_sensor_measurement.py	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,180 @@
+import serial
+from time import sleep
+from pynput import keyboard
+from ad4130 import *
+from ad4130_xattr import *
+
+# Delays in seconds
+short_time = 0.1
+long_time = 1
+loadcell_settling_time = 2
+
+# Global variables
+weight_input = 0
+loadcell_offset = [ 0 ]
+loadcell_gain = [ 0 ]
+
+# Power test channels defined in the firmware
+POWER_TEST_V_AVDD_CHN = 0
+POWER_TEST_V_IOVDD_CHN = 1
+POWER_TEST_I_AVDD_CHN = 2
+POWER_TEST_I_IOVDD_CHN = 3
+POWER_TEST_V_AVSS_DGND_CHN = 4
+POWER_TEST_V_REF_CHN = 5
+
+# IIO Channel name and respective channel index mapping
+chn_mappping = {
+    "voltage0" : 0, "voltage1" : 1, "voltage2" : 2, "voltage3" : 3, "voltage4" : 4,
+    "voltage5" : 5, "voltage6" : 6, "voltage7" : 7, "voltage8" : 8, "voltage9" : 9,
+    "voltage10" : 10, "voltage11" : 11, "voltage12" : 12, "voltage13" : 13,
+    "voltage14" : 14, "voltage15" : 15,
+
+    "current0" : 0, "current1" : 1, "current2" : 2, "current3" : 3, "current4" : 4,
+    "current5" : 5, "current6" : 6, "current7" : 7, "current8" : 8, "current9" : 9,
+    "current10" : 10, "current11" : 11, "current12" : 12, "current13" : 13,
+    "current14" : 14, "current15" : 15,
+
+    "temp0" : 0, "temp1" : 1, "temp2" : 2, "temp3" : 3, "temp4" : 4,
+    "temp5" : 5, "temp6" : 6, "temp7" : 7, "temp8" : 8, "temp9" : 9,
+    "temp10" : 10, "temp11" : 11, "temp12" : 12, "temp13" : 13,
+    "temp14" : 14, "temp15" : 15,
+}
+
+def key_press_event(key):
+    global key_pressed
+    key_pressed = True
+
+def init_sensor_measurement():
+    global device
+    global demo_config
+    global listener
+
+    ######## User configuration ##########
+    # Configure the backend for PC to IIOD interface
+    uri = "serial:COM12,230400"  # For UART, baud rate must be same as set in the FW. COM port is physical Or VCOM.
+    device_name = "ad4130"      # Name of the device must be same as set in the FW.
+    ######################################
+
+    # Create an IIO device context
+    device = ad4130_xattr(uri, device_name)
+    device._ctx.set_timeout(100000)
+
+    # Get current user device config from the firmware
+    demo_config = device.demo_config
+    print("\r\nDemo Config: {}\r\n".format(demo_config))
+
+    listener = keyboard.Listener(on_press=key_press_event)
+    listener.start()
+
+def perform_loadcell_calibration(chn):
+        global loadcell_offset
+        global loadcell_gain
+        global weight_input
+        global device
+
+        chn_indx = chn_mappping[chn.name]
+
+        print("\r\nCalibrating Loadcell for channel {}".format(chn_indx))
+        input("Please ensure no weight is applied on Loadcell and press enter to continue calibration ")
+        print("Waiting to settle-down the Loadcell..")
+        sleep(loadcell_settling_time)
+        print("Performing Loadcell offset calibration..")
+        chn.loadcell_offset_calibration = 'start_calibration'
+        print("Loadcell offset calibration complete")
+        loadcell_offset[chn_indx] = chn.loadcell_offset_calibration
+        print("Loadcell offset: {}".format(loadcell_offset[chn_indx]))
+
+        weight_input_done = False
+        while weight_input_done is False:
+            try:
+                weight_input = int(input("\r\nApply the weight on loadcell and enter here (in grams): "))
+                if (weight_input <= 0):
+                    print("Please ensure weight is > 0!!")
+                else:
+                    weight_input_done = True
+            except:
+                print("Invalid input")
+
+        print("Waiting to settle-down the Loadcell..")
+        sleep(loadcell_settling_time)
+        print("Performing load cell gain calibration..")
+        chn.loadcell_gain_calibration = 'start_calibration'
+        print("Load cell gain calibration complete")
+        loadcell_gain[chn_indx] = chn.loadcell_gain_calibration
+        print("Loadcell gain: {}".format(loadcell_gain[chn_indx]))
+
+def perform_sensor_measurement():
+    global device
+    global key_pressed
+    global loadcell_offset
+    global loadcell_gain
+    global weight_input
+
+    # Loadcell must be calibrated before performing measurement
+    if (demo_config == 'Loadcell'):
+        for chn in device.channel:
+            perform_loadcell_calibration(chn)
+
+    weight = 0
+    print("\r\n*** Press any key to stop the measurement ***\r\n")
+    sleep(long_time)
+    
+    # Print the header
+    header = ""
+    for chn in device.channel:
+        header = header + chn.name + ' '
+    print(header)
+
+    key_pressed = False
+    while not key_pressed:
+        result_str = ""
+        for chn in device.channel:
+            sleep(short_time)
+            if (demo_config == 'Loadcell'):
+                adc_raw = chn.raw
+                try:
+                    chn_indx = chn_mappping[chn.name]
+                    weight = ((adc_raw - loadcell_offset[chn_indx]) * weight_input) / (loadcell_gain[chn_indx] - loadcell_offset[chn_indx])
+                    result_str = result_str + str(round(weight,4)) + ' gram  '
+                except:
+                    print("\r\nInvalid measurement result. Please check device settings!!")
+                    break
+            elif (demo_config == 'ECG' or demo_config == 'Noise Test' or demo_config == 'Power Test' or demo_config == 'User Default'):
+                adc_raw = chn.raw
+                scale = chn.scale
+                offset = chn.offset
+                if (demo_config == 'Power Test'):
+                    chn_indx = chn_mappping[chn.name]
+                    if (chn_indx == POWER_TEST_I_AVDD_CHN or chn_indx == POWER_TEST_I_IOVDD_CHN):
+                        current = ((adc_raw + offset) * scale)
+                        result_str = result_str + str(round(current,4)) + 'mA  '
+                    else:
+                        voltage = ((adc_raw + offset) * scale) / 1000
+                        result_str = result_str + str(round(voltage,4)) + 'V  '
+                else:
+                    voltage = ((adc_raw + offset) * scale) / 1000
+                    result_str = result_str + str(round(voltage,4)) + 'V  '
+            else:
+                # Temperature sensors demo configs (RTD, Thermocouple and Thermistor)
+                adc_raw = chn.raw
+                scale = chn.scale
+                temperature = (adc_raw * scale) / 1000
+                result_str = result_str + str(round(temperature,4)) + 'C  '
+
+        print(result_str)
+
+def exit():
+    global listener
+    global device
+
+    # Delete the objects
+    del listener
+    del device
+
+def main():
+    init_sensor_measurement()
+    perform_sensor_measurement()
+    exit()
+
+if __name__ == "__main__":
+    main()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ad4130_xattr.py	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,124 @@
+# Copyright (C) 2022 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.
+#     - 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.
+#     - Use of the software either in source or binary form, must be run
+#       on or directly connected to an Analog Devices Inc. component.
+#
+# THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A
+# PARTICULAR PURPOSE ARE DISCLAIMED.
+#
+# IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY
+# RIGHTS, 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.
+
+#import adi.ad4130              # TODO - Enable later
+#from adi.ad4130 import ad4130  # TODO - Enable later
+from ad4130 import *            # TODO - Delete later
+from adi.attribute import attribute
+from decimal import Decimal
+
+# Create a child class of ad4130 parent class for defining extended iio attributes (the ones which
+# are not part of original linux iio drivers and created for non-linux iio applications)
+class ad4130_xattr(ad4130):
+
+    # List of extended iio channels
+    xchannel = []
+
+    def __init__(self, uri, device_name):
+        super().__init__(uri, device_name)
+
+        # Create an instances of the extended channel class
+        for ch in self._ctrl.channels:
+            name = ch._id
+            self._rx_channel_names.append(name)
+            self.xchannel.append(self._xchannel(self._ctrl, name))
+
+        # Add the _xchannel class methods as _channel methods, so that they can be accessed with 
+        # attribute name as 'channel' instead 'xchannel'
+        # e.g. channel attribute 'system_calibration' can be accessed as either "obj.channel[chn_num].system_calibration" Or
+        # "obj.xchannel[chn_num].system_calibration", where obj refers to object of 'ad4130_xattr' class
+        self._channel.system_calibration = self._xchannel.system_calibration
+        self._channel.internal_calibration = self._xchannel.internal_calibration
+        self._channel.loadcell_offset_calibration = self._xchannel.loadcell_offset_calibration
+        self._channel.loadcell_gain_calibration = self._xchannel.loadcell_gain_calibration
+
+    #------------------------------------------------
+    # Device extended attributes
+    #------------------------------------------------
+    
+    @property
+    def demo_config(self):
+        """AD4130 demo mode config"""
+        return self._get_iio_dev_attr_str("demo_config")
+
+    @property
+    def sample_rate(self):
+        """AD4130 device sample_rate"""
+        return int(self._get_iio_dev_attr_str("sampling_frequency"))
+
+    #------------------------------------------------
+    # Channel extended attributes
+    #------------------------------------------------
+
+    class _xchannel(attribute):
+
+        def __init__(self, ctrl, channel_name):
+            self.name = channel_name
+            self._ctrl = ctrl
+
+        @property
+        def system_calibration(self):
+            """AD4130 channel system calibration"""
+            return self._get_iio_attr_str(self.name, "system_calibration", False)
+
+        @system_calibration.setter
+        def system_calibration(self, value):
+            self._set_iio_attr(self.name, "system_calibration", False, value)
+
+        @property
+        def internal_calibration(self):
+            """AD4130 channel internal calibration"""
+            return self._get_iio_attr_str(self.name, "internal_calibration", False)
+
+        @internal_calibration.setter
+        def internal_calibration(self, value):
+            self._set_iio_attr(self.name, "internal_calibration", False, value)
+
+        @property
+        def loadcell_offset_calibration(self):
+            """AD4130 loadcell offset calibration"""
+            return self._get_iio_attr_str(self.name, "loadcell_offset_calibration", False)
+
+        @loadcell_offset_calibration.setter
+        def loadcell_offset_calibration(self, value):
+            self._set_iio_attr(self.name, "loadcell_offset_calibration", False, value)
+
+        @property
+        def loadcell_gain_calibration(self):
+            """AD4130 loadcell gain calibration"""
+            return self._get_iio_attr_str(self.name, "loadcell_gain_calibration", False)
+
+        @loadcell_gain_calibration.setter
+        def loadcell_gain_calibration(self, value):
+            self._set_iio_attr(self.name, "loadcell_gain_calibration", False, value)
+    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/requirements.txt	Fri Jul 15 17:47:44 2022 +0530
@@ -0,0 +1,4 @@
+matplotlib
+pyserial
+pynput
+csv
\ No newline at end of file