Forked repository for Analog Devices EVAL-TempSense-ARDZ

Dependencies:   platform_drivers

Files at this revision

API Documentation at this revision

Comitter:
Janani Sunil
Date:
Thu Sep 23 12:40:39 2021 +0530
Parent:
6:0228e21af1f0
Commit message:
1.) Updated the project repository structure
2.) Made modifications in the code to align with the latest no-OS drivers and the platform drivers

Changed in this revision

ADT73xx-ADT74xx.lib Show diff for this revision Revisions of this file
app/.mbedignore Show annotated file Show diff for this revision Revisions of this file
app/adt7xxx_support.c Show annotated file Show diff for this revision Revisions of this file
app/adt7xxx_support.h 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/main.cpp Show annotated file Show diff for this revision Revisions of this file
app/mbed_platform_drivers.lib 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_config.h 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
platform_drivers.lib Show diff for this revision Revisions of this file
diff -r 0228e21af1f0 -r a3472d023b12 ADT73xx-ADT74xx.lib
--- a/ADT73xx-ADT74xx.lib	Mon Dec 09 17:54:51 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/teams/AnalogDevices/code/ADT73xx-ADT74xx/#a86efb0ef0ad
diff -r 0228e21af1f0 -r a3472d023b12 app/.mbedignore
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/.mbedignore	Thu Sep 23 12:40:39 2021 +0530
@@ -0,0 +1,64 @@
+mbed_platform_drivers/adc_data_capture.c
+mbed_platform_drivers/irq.cpp
+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/ad9*
+no-OS/drivers/adc/ltc2312/
+no-OS/drivers/adc/adc_demo/
+no-OS/drivers/adc-dac/ad5592r/
+no-OS/drivers/amplifiers/
+no-OS/drivers/instr-amplif/
+no-OS/drivers/tdm/
+no-OS/drivers/cdc/
+no-OS/drivers/dac/
+no-OS/drivers/display/
+no-OS/drivers/ecg/
+no-OS/drivers/frequency/
+no-OS/drivers/gpio/
+no-OS/drivers/gyro/
+no-OS/drivers/i2c/
+no-OS/drivers/irq/
+no-OS/drivers/impedance-analyzer/
+no-OS/drivers/io-expander/
+no-OS/drivers/mux/
+no-OS/drivers/photo-electronic/
+no-OS/drivers/platform/
+no-OS/drivers/potentiometer/
+no-OS/drivers/rf-transceiver/
+no-OS/drivers/sd-card/
+no-OS/drivers/spi/
+no-OS/iio/
+no-OS/legacy/
+no-OS/libraries/fatfs/
+no-OS/libraries/mbedtls/
+no-OS/libraries/mqtt/
+no-OS/libraries/iio/
+no-OS/network/
+no-OS/projects/
+no-OS/scripts/
+no-OS/tools/
+no-OS/v4l2_config/
+libtinyiiod/ci/
+libtinyiiod/example.c
\ No newline at end of file
diff -r 0228e21af1f0 -r a3472d023b12 app/adt7xxx_support.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/adt7xxx_support.c	Thu Sep 23 12:40:39 2021 +0530
@@ -0,0 +1,325 @@
+/***************************************************************************//**
+ *   @file   adt7xxx_support.c
+ *   @brief  Support Source File for adt7xxx
+********************************************************************************
+ * Copyright (c) 2021 Analog Devices, Inc.
+ * All rights reserved.
+ *
+ * This software is proprietary to Analog Devices, Inc. and its licensors.
+ * By using this software you agree to the terms of the associated
+ * Analog Devices Software License Agreement.
+*******************************************************************************/
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+
+#include <stdint.h>
+#include "adt7420.h"
+#include "error.h"
+#include "adt7xxx_support.h"
+
+/******************************************************************************/
+/********************** Macros and Constants Definitions **********************/
+/******************************************************************************/
+
+/******************************************************************************/
+/************************ Functions Definitions *******************************/
+/******************************************************************************/
+
+/***************************************************************************//**
+ * @brief Reads the value of a register SPI/I2C.
+ *
+ * @param dev              - The device structure.
+ * @param register_address - Address of the register.
+ *
+ * @return register_value  - Value of the register.
+*******************************************************************************/
+uint16_t adt7420_get_register_address_and_value(struct adt7420_dev *dev,
+			    uint8_t register_address)
+{
+	uint16_t register_value = 0;
+
+	//remap register map
+	if(adt7420_is_spi(dev)) {
+		switch (register_address) {
+		case REG_TEMP:
+			register_address = ADT7320_REG_TEMP;
+			break;	 // Temperature value
+		case REG_STATUS :
+			register_address = ADT7320_REG_STATUS;
+			break; // status info
+		case REG_CONFIG :
+			register_address = ADT7320_REG_CONFIG;
+			break; // Configuration
+		case REG_T_CRIT :
+			register_address = ADT7320_REG_T_CRIT;
+			break; // Temperature CRIT setpoint (147'C)
+		case REG_HIST :
+			register_address = ADT7320_REG_HIST;
+			break;   // Temperature HYST setpoint (5'C)
+		case REG_T_HIGH :
+			register_address = ADT7320_REG_T_HIGH;
+			break; // Temperature HIGH setpoint (64'C)
+		case REG_T_LOW :
+			register_address = ADT7320_REG_T_LOW;
+			break;  // Temperature LOW setpoint (10'C)
+		case REG_ID :
+			register_address = ADT7320_REG_ID;
+			break;	 // ID value
+		}
+		register_value = adt7420_get_register_value(dev, register_address);
+	} else {
+		switch (register_address) {
+		case REG_TEMP: {
+			register_value  = adt7420_get_register_value(dev,
+					  ADT7420_REG_TEMP_MSB) << 8;
+			register_value |= adt7420_get_register_value(dev, ADT7420_REG_TEMP_LSB);
+			break;
+		}
+		case REG_STATUS:
+			register_value = adt7420_get_register_value(dev, ADT7420_REG_STATUS);
+			break;
+		case REG_CONFIG:
+			register_value = adt7420_get_register_value(dev, ADT7420_REG_CONFIG);
+			break;
+		case REG_T_HIGH: {
+			register_value  = adt7420_get_register_value(dev,
+					  ADT7420_REG_T_HIGH_MSB) << 8;
+			register_value |= adt7420_get_register_value(dev, ADT7420_REG_T_HIGH_LSB);
+			break;
+		}
+		case REG_T_LOW: {
+			register_value  = adt7420_get_register_value(dev,
+					  ADT7420_REG_T_LOW_MSB) << 8;
+			register_value |= adt7420_get_register_value(dev, ADT7420_REG_T_LOW_LSB);
+			break;
+		}
+		case REG_T_CRIT: {
+			register_value  = adt7420_get_register_value(dev,
+					  ADT7420_REG_T_CRIT_MSB) << 8;
+			register_value |= adt7420_get_register_value(dev, ADT7420_REG_T_CRIT_LSB);
+			break;
+		}
+		case REG_HIST:
+			register_value = adt7420_get_register_value(dev, ADT7420_REG_HIST);
+			break;
+		case REG_ID:
+			register_value = adt7420_get_register_value(dev, ADT7420_REG_ID);
+			break;
+		}
+	}
+	return register_value;
+}
+
+
+/**************************************************************************//**
+ * @brief Configure write typev register based on communication interface.
+ *
+ * @param dev					- The device structure.
+ * @param register_address		- Register type.
+ *
+ * @return  register_address	- Register Address.
+******************************************************************************/
+uint16_t configure_write_type_registers(struct adt7420_dev *dev,
+					uint8_t register_address)
+{
+	if (adt7420_is_spi(dev)) {
+		//simple address re-map for SPI devices
+		switch(register_address) {
+		case REG_TEMP:
+			register_address = ADT7320_REG_TEMP;
+			break; // Temperature value
+		case REG_STATUS :
+			register_address = ADT7320_REG_STATUS;
+			break; // status info
+		case REG_CONFIG :
+			register_address = ADT7320_REG_CONFIG;
+			break; // Configuration
+		case REG_T_CRIT :
+			register_address = ADT7320_REG_T_CRIT;
+			break; // Temperature CRIT setpoint (147'C)
+		case REG_HIST :
+			register_address = ADT7320_REG_HIST;
+			break; // Temperature HYST setpoint (5'C)
+		case REG_T_HIGH :
+			register_address = ADT7320_REG_T_HIGH;
+			break; // Temperature HIGH setpoint (64'C)
+		case REG_T_LOW :
+			register_address = ADT7320_REG_T_LOW;
+			break; // Temperature LOW setpoint (10'C)
+		case REG_ID :
+			register_address = ADT7320_REG_ID;
+			break; // ID value
+		}
+	} else {
+		//simple address re-map for I2Cdevices
+		switch(register_address) {
+		case REG_TEMP:
+			register_address = ADT7420_REG_T_HIGH_MSB;
+			break; // Temperature value
+		case REG_STATUS :
+			register_address = ADT7420_REG_STATUS;
+			break; // status info
+		case REG_CONFIG :
+			register_address = ADT7420_REG_CONFIG;
+			break; // Configuration
+		case REG_T_CRIT :
+			register_address = ADT7420_REG_T_CRIT_MSB;
+			break; // Temperature CRIT setpoint (147'C)
+		case REG_HIST :
+			register_address = ADT7420_REG_HIST;
+			break; // Temperature HYST setpoint (5'C)
+		case REG_T_HIGH :
+			register_address = ADT7420_REG_T_HIGH_MSB;
+			break; // Temperature HIGH setpoint (64'C)
+		case REG_T_LOW :
+			register_address = ADT7420_REG_T_LOW_MSB;
+			break; // Temperature LOW setpoint (10'C)
+		case REG_ID :
+			register_address = ADT7420_REG_ID;
+			break; // ID value
+		}
+	}
+
+	return register_address;
+}
+
+/**************************************************************************//**
+ * @brief Write to a setpoint register.
+ *
+ * @param dev            - The device structure.
+ * @param register_value - Command control bits.
+ * @param data           - Data to be written in input register.
+ *
+ * @return  read_back_data - value read from register.
+******************************************************************************/
+uint8_t adt7420_wr_setpoint_reg(struct adt7420_dev *dev,
+				uint8_t register_value,
+				uint16_t data)
+{
+	uint16_t read_back_data = 0;
+	uint8_t address, num_bytes;
+	uint8_t data_buffer[3] = { 0, 0, 0 };
+
+	switch (register_value) {
+	case REG_T_CRIT:
+	case REG_T_HIGH:
+	case REG_T_LOW: {
+		num_bytes = 3;
+		data_buffer[0] = ((data & ADT7420_MSB_MASK) >> ADT7420_MSB_OFFSET);
+		data_buffer[1] = data & ADT7420_LSB_MASK;
+		break;
+	}
+	case REG_HIST: {
+		num_bytes = 2;
+		data_buffer[0] = data & ADT7420_LSB_MASK;
+		break;
+	}
+	}
+
+	address = configure_write_type_registers(dev, register_value);
+	set_register_value(dev, address, num_bytes, data_buffer, ADT7420_MASK_SET_PT_REGISTER, 0x00);
+	read_back_data  = adt7420_get_register_value(dev, address);
+
+	if (register_value == REG_HIST) {
+		data &= 0x000F; //msbits are all low for HIST register
+		read_back_data &= 0x000F; //msbits are all low for HIST register
+	}
+
+	return read_back_data == data ? SUCCESS : FAILURE;
+}
+
+/***************************************************************************//**
+ * @brief Sets the Fault Queue option for ADT7420/ADT7320.
+ *
+ * @param dev        - The device structure.
+ * @param mode       - Fault Queue selection.
+ *                     Example: 1 - 1 fault (default).
+ *                            	2 - 2 faults.
+ *			                    3 - 3 faults.
+ *			                    4 - 4 faults.
+ *
+ * @return None.
+*******************************************************************************/
+void adt7420_set_fault_queue(struct adt7420_dev *dev,
+			     uint8_t mode)
+{
+	uint8_t register_value[1] = { 0 };
+	uint8_t address;
+
+	if (adt7420_is_spi(dev)) {
+		address = ADT7320_REG_CONFIG;
+		register_value[0]  = adt7420_get_register_value(dev, ADT7320_REG_CONFIG);
+	} else {
+		address = ADT7420_REG_CONFIG;
+		register_value[0]  = adt7420_get_register_value(dev, ADT7420_REG_CONFIG);
+	}
+
+	set_register_value(dev, address, 2, register_value,
+			   ADT7420_CONFIG_FAULT_QUEUE(ADT7420_FAULT_QUEUE_4_FAULTS),
+			   ADT7420_CONFIG_FAULT_QUEUE(mode));
+}
+
+/***************************************************************************//**
+ * @brief Sets comparator/interrupt (CT/INT) mode for ADT7420/ADT7320.
+ *
+ * @param dev        - The device structure.
+ * @param setting    - Mode selection.
+ *                     Example: 0 - Interrupt (default).
+ *                            	1 - Comparator.
+ *
+ *
+ * @return None.
+*******************************************************************************/
+void adt7420_set_ct_int_mode(struct adt7420_dev *dev,
+			     uint8_t setting)
+{
+	uint8_t register_value[1] = { 0 };
+	uint8_t address;
+
+	if (adt7420_is_spi(dev)) {
+		address = ADT7320_REG_CONFIG;
+		register_value[0]  = adt7420_get_register_value(dev, ADT7320_REG_CONFIG);
+	} else {
+		address = ADT7420_REG_CONFIG;
+		register_value[0]  = adt7420_get_register_value(dev, ADT7420_REG_CONFIG);
+	}
+
+	set_register_value(dev, address,2 ,register_value, ADT7420_CONFIG_INT_CT_MODE,
+			   (setting * ADT7420_CONFIG_INT_CT_MODE));
+}
+
+/***************************************************************************//**
+ * @brief Sets output polarity for the pins CT/INT (Critical Temp - Over/Under Temp).
+ *
+ * @param dev        - The device structure.
+ * @param polarity   - Polarity selection.
+ *                     Example: 0 - Active Low (default).
+ *                            	1 - Active High.
+ *
+ *
+ * @return None.
+*******************************************************************************/
+void adt7420_set_ct_int_polarity(struct adt7420_dev *dev,
+				 uint8_t polarity)
+{
+	uint8_t register_value[1] = { 0 };
+	uint8_t address;
+	uint8_t bit_mask, bit_value;
+
+	if (adt7420_is_spi(dev)) {
+		address = ADT7320_REG_CONFIG;
+		register_value[0]  = adt7420_get_register_value(dev, ADT7320_REG_CONFIG);
+	} else {
+		address = ADT7420_REG_CONFIG;
+		register_value[0]  = adt7420_get_register_value(dev, ADT7420_REG_CONFIG);
+		register_value[0]  = adt7420_get_register_value(dev, ADT7420_REG_CONFIG);
+	}
+
+	bit_mask = (ADT7420_CONFIG_CT_POL) | (ADT7420_CONFIG_INT_POL);
+	bit_value = (polarity * ADT7420_CONFIG_CT_POL) | (polarity *
+			ADT7420_CONFIG_INT_POL);
+
+	set_register_value(dev, address, 2, register_value, bit_mask, bit_value);
+}
diff -r 0228e21af1f0 -r a3472d023b12 app/adt7xxx_support.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/adt7xxx_support.h	Thu Sep 23 12:40:39 2021 +0530
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ *   @file   adt7xxx_support.h
+ *   @brief  Support Header File for adt7xxx
+******************************************************************************
+ * Copyright (c) 2021 Analog Devices, Inc.
+ * All rights reserved.
+ *
+ * This software is proprietary to Analog Devices, Inc. and its licensors.
+ * By using this software you agree to the terms of the associated
+ * Analog Devices Software License Agreement.
+*****************************************************************************/
+
+#ifndef _ADT7XXX_SUPPORT_H
+#define _ADT7XXX_SUPPORT_H
+
+/* ADT7420 bit mask */
+#define ADT7420_LSB_MASK	            0x00FF
+#define ADT7420_MSB_MASK	            0xFF00
+#define ADT7420_LSB_OFFSET	            0
+#define ADT7420_MSB_OFFSET          	    8
+#define ADT7420_CONFIG_CT_POL		    BIT(2)
+#define ADT7420_CONFIG_FAULT_QUEUE(x)	    ((x) & 0x3)
+#define ADT7420_CONFIG_INT_POL		    BIT(3)
+#define ADT7420_CONFIG_INT_CT_MODE	    BIT(4)
+#define ADT7420_MASK_SET_PT_REGISTER	    0x00
+
+/* ADT7420_CONFIG_FAULT_QUEUE(x) options */
+#define ADT7420_FAULT_QUEUE_1_FAULT	    0
+#define ADT7420_FAULT_QUEUE_2_FAULTS	    1
+#define ADT7420_FAULT_QUEUE_3_FAULTS	    2
+#define ADT7420_FAULT_QUEUE_4_FAULTS	    3
+
+/* ADT7xxx default ID */
+#define ADT7320_DEFAULT_ID		    0xC3
+#define ADT7420_DEFAULT_ID		    0xCB
+
+typedef enum {
+	REG_TEMP,		// Temperature value
+	REG_STATUS,		// status info
+	REG_CONFIG,		// Configuration
+	REG_T_CRIT,		// Temperature CRIT setpoint (147'C)
+	REG_HIST,		// Temperature HYST setpoint (5'C)
+	REG_T_HIGH,		// Temperature HIGH setpoint (64'C)
+	REG_T_LOW,		// Temperature LOW setpoint (10'C)
+	REG_ID,			// ID value
+	REG_RESET
+} registers_e;
+
+
+/*! Sets the Fault Queue option for ADT7420/ADT7320.*/
+void adt7420_set_fault_queue(struct adt7420_dev *dev,
+			     uint8_t mode);
+
+/*! Sets comparator/interrupt (CT/INT) mode for ADT7420/ADT7320.*/
+void adt7420_set_ct_int_mode(struct adt7420_dev *dev,
+			     uint8_t setting);
+
+/*! Sets output polarity for the pins CT/INT (Critical Temp - Over/Under Temp).*/
+void adt7420_set_ct_int_polarity(struct adt7420_dev *dev,
+				 uint8_t polarity);
+
+/*! Writes data to temperature registers*/
+uint8_t adt7420_wr_setpoint_reg(struct adt7420_dev *device,
+				uint8_t register_value,
+				uint16_t data);
+
+/*! Get the register address of write type registers */
+uint16_t configure_write_type_registers(struct adt7420_dev *dev,
+					uint8_t register_address);
+
+/*! Get the register address based on the register type enum- registers_e */
+uint16_t adt7420_get_register_address_and_value(struct adt7420_dev *dev,
+			    uint8_t register_address);
+#endif // _ADT7XXX_SUPPORT_H
\ No newline at end of file
diff -r 0228e21af1f0 -r a3472d023b12 app/app_config.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/app_config.h	Thu Sep 23 12:40:39 2021 +0530
@@ -0,0 +1,108 @@
+/*****************************************************************************
+ *   @file   app_config.h
+ *   @brief  Application configuration file
+ *   @author ssmith (sean.smith@analog.com)
+******************************************************************************
+* Copyright (c) 2019, 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.  
+*   - 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.
+* 
+* 20180927-7CBSD SLA
+*****************************************************************************/
+
+#ifndef _APP_CONFIG_H_
+#define _APP_CONFIG_H_
+
+#include <stdint.h>
+#include "PinNames.h"
+
+#ifndef ACTIVE_DEVICE
+/** 
+   #define your chosen device here from the 
+   adt7420_type (adt7420.h) enum
+*/
+#define ACTIVE_DEVICE ID_ADT7320
+#endif // !
+
+/**
+   ADT7420 is a 7-bit I2C address
+*/
+#define EXT_I2C_ADDRESS  0x49
+#define INT_I2C_ADDRESS  0x48
+
+/**
+  Add a line-ending constant as different emulators 
+  implement it in various ways - simple to change it here
+*/
+#define EOL "\r\n"
+
+/**
+  The ADI SDP_K1 can be used with either arduino headers
+  or the 120-pin SDP connector found on ADI evaluation
+  boards. The default is the SDP connector
+
+  Uncomment the ARDUINO #define above to enable the ARDUINO connector
+*/
+
+//#define  ARDUINO
+
+#ifdef ARDUINO
+	#define I2C_SCL     D15
+	#define I2C_SDA     D14
+
+	#define SPI_CS		D10
+	#define SPI_MISO	D12
+	#define SPI_MOSI	D11
+	#define SPI_SCK		D13
+
+	#define SPI_CSE 	D9 
+	
+#else
+	#define I2C_SCL     SDP_I2C_SCL
+	#define I2C_SDA     SDP_I2C_SDA
+
+	#define SPI_CS		SDP_SPI_CS_A
+	#define SPI_MISO	SDP_SPI_MISO
+	#define SPI_MOSI	SDP_SPI_MOSI
+	#define SPI_SCK		SDP_SPI_SCK
+
+	#define SPI_CSE 	SDP_SPI_CS_B
+	
+#endif
+
+#endif //_APP_CONFIG_H_
\ No newline at end of file
diff -r 0228e21af1f0 -r a3472d023b12 app/main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/main.cpp	Thu Sep 23 12:40:39 2021 +0530
@@ -0,0 +1,790 @@
+/*****************************************************************************
+ *   @file   main.cpp
+ *   @brief  EVAL-TempSense-ARDZ example program
+ *   @author ssmith (sean.smith@analog.com)
+******************************************************************************
+* Copyright (c) 2019, 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.
+*   - 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.
+*
+* 20180927-7CBSD SLA
+*****************************************************************************/
+#include <cstdio>
+#include <mbed.h>
+#include <cmath>
+
+#include "app_config.h"
+#include "spi.h"
+#include "i2c.h"
+#include "error.h"
+#include "i2c_extra.h"
+#include "spi_extra.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#include "delay.h"
+#include "platform_support.h"
+#include "adt7420.h"
+#include "adt7xxx_support.h"
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
+
+#define TEMP_MIN                -40
+#define TEMP_MAX                150
+#define MAX_HYST_TEMP           15
+#define MIN_HYST_TEMP           0
+
+#define RESET_DELAY             500
+#define WAIT_MENU_TIME          1000
+#define NOT_USED                0
+
+static void print_title(void);
+static void print_prompt(void);
+static uint8_t select_device();
+static void print_active_device(int ext_int_value);
+static int get_menu_select(uint8_t *menu_select);
+static uint8_t read_temperature();
+static uint8_t set_resolution();
+static uint8_t set_op_mode();
+static uint8_t bunch_of_temps();
+static uint8_t readback_reg();
+static uint8_t reset_interface();
+static uint8_t write_to_setpoint_reg();
+static uint8_t set_fault_queue();
+static uint8_t set_ct_int_config();
+static void microcontroller_reset();
+static int input_check(int input_val,
+		       int lowest_accepted_val,
+		       int highest_accepted_val,
+		       int invalid_check);
+
+
+/******************************************************************************/
+/************************** Variables Declarations ****************************/
+/******************************************************************************/
+
+// Initialize the extra parameters for I2C initialization
+mbed_i2c_init_param i2c_init_extra_params = {
+	.i2c_sda_pin = I2C_SDA,
+	.i2c_scl_pin = I2C_SCL
+};
+
+i2c_init_param i2c_params = {
+	.max_speed_hz = 100000, 		 // i2c max speed (hz)
+	.slave_address  = INT_I2C_ADDRESS, // i2c slave address
+	.extra = &i2c_init_extra_params	// I2C extra init parameters
+};
+
+// Initialize the extra parameters for SPI initialization
+mbed_spi_init_param spi_init_extra_params = {
+	.spi_miso_pin = SPI_MISO,
+	.spi_mosi_pin = SPI_MOSI,
+	.spi_clk_pin = SPI_SCK
+};
+
+spi_init_param spi_params = {
+	.max_speed_hz  = 1000000,		 //SPI frequency (Hz)
+	.chip_select  = SPI_CS,	 		 //Chip Select
+	.mode = SPI_MODE_3,		 //CPOL/CPHA settings for your device
+	.extra = &spi_init_extra_params	// SPI extra init parameters
+};
+
+adt7420_init_param init_params = {
+	.resolution_setting  = NOT_USED,		//Resolution setting
+	.active_device =  ACTIVE_DEVICE   //Set this in app_config.h
+};
+
+adt7420_dev *device;
+
+registers_e registers;
+
+int32_t connected = -1;
+uint8_t device_id = 0;
+
+
+int main()
+{
+	uint8_t menu_select = 0;
+
+	print_title();
+
+	device_id = select_device();
+
+	connected = adt7420_init(&device, init_params);
+
+	if (connected != SUCCESS) {
+		printf(EOL EOL "  Connection to device failed :(" EOL);
+		printf("  ...Restarting application...  " EOL);
+		mdelay(WAIT_MENU_TIME);
+		microcontroller_reset();
+	} else {
+		printf(EOL EOL "  Connection to device succeeded!" EOL);
+	}
+
+	while (connected == SUCCESS) {
+		menu_select = 0;
+		print_active_device(device_id);
+		print_prompt();
+
+		if (get_menu_select(&menu_select) == FAILURE)
+			printf(EOL "*****   Returning to main menu   *****" EOL);
+		else {
+			switch (menu_select) {
+			case 1:
+				read_temperature();
+				break;
+			case 2:
+				set_resolution();
+				break;
+			case 3:
+				set_op_mode();
+				break;
+			case 4:
+				bunch_of_temps();
+				break;
+			case 5:
+				readback_reg();
+				break;
+			case 6:
+				reset_interface();
+				break;
+			case 7:
+				write_to_setpoint_reg();
+				break;
+			case 8:
+				set_fault_queue();
+				break;
+			case 9:
+				set_ct_int_config();
+				break;
+			case 10:
+				/*Restore device registers to default values before restarting microcontroller*/
+				reset_interface();
+				microcontroller_reset();
+				break;
+			default:
+				printf("Invalid option" EOL);
+				break;
+			}
+		}
+		mdelay(WAIT_MENU_TIME); //wait 1 second
+	}
+}
+
+
+/*******************************************************************************
+ * @brief	Prints the title block.
+ *******************************************************************************/
+void print_title()
+{
+	printf("*****************************************************************" EOL);
+	printf("* EVAL-TempeSense-ARDZ Demonstration Program                    *" EOL);
+	printf("*                                                               *" EOL);
+	printf("* This program demonstrates communication with the ADT7xx       *" EOL);
+	printf("* High-Accuracy digital temperature sensor family               *" EOL);
+	printf("* It works with both SPI & I2C versions                         *" EOL);
+	printf("*                                                               *" EOL);
+	printf("*****************************************************************" EOL);
+}
+
+/*******************************************************************************
+ * @brief	Prints the "main menu" prompt to the console.
+ *******************************************************************************/
+void print_prompt()
+{
+	printf(EOL EOL "Command Summary:" EOL);
+	printf("  1  -Read temperature" EOL);
+	printf("  2  -Set resolution" EOL);
+	printf("  3  -Set operation mode" EOL);
+	printf("  4  -Poll temperature" EOL);
+	printf("  5  -Read a register" EOL);
+	printf("  6  -Reset the interface" EOL);
+	printf("  7  -Write to a setpoint register" EOL);
+	printf("  8  -Set Fault Queue configuration" EOL);
+	printf("  9  -Set CT/INT polarity and mode" EOL);
+	printf("  10 -Full System Reset" EOL);
+	printf(EOL);
+}
+
+static int get_menu_select(uint8_t *menu_select)
+{
+	int invalid_check = scanf("%d",(int *) menu_select);
+	return input_check(*menu_select, 1, 10, invalid_check);
+}
+
+/*******************************************************************************
+ * @brief 	- Select the serial interface (SPI/I2C) and device
+ *				based on the part family.
+ *		  	- Only one device and interface can be active.
+ *						Example: ADT7320 - SPI (Internal or Remote device)
+ *								 ADT7420 - I2C (Internal or Remote device)
+ *
+ * @param 	None
+ *
+ * @return 	new_dev - Return device selected
+ *				 	  Example: 1  - Internal(Main PCB)
+ *							   2  - Remote (External PCB)
+ *******************************************************************************/
+uint8_t select_device()
+{
+	printf("Please select interface by choosing a device:" EOL);
+	printf("    1- ADT7320 (SPI)" EOL);
+	printf("    2- ADT7420 (I2C)" EOL);
+	printf("  Select an option: ");
+
+	int invalid_check, new_interface = 0;
+	invalid_check = scanf("%d", &new_interface);
+
+	//Prompts for user input while correct interface is not selected
+	while (input_check(new_interface, 1, 2, invalid_check) == FAILURE) {
+		printf("Please select interface by choosing a device:" EOL);
+		printf("    1- ADT7320 (SPI)" EOL);
+		printf("    2- ADT7420 (I2C)" EOL);
+		printf("  Select an option: ");
+		invalid_check = scanf("%d", &new_interface);
+	}
+	printf("%d", new_interface);
+
+	switch (new_interface) {
+	case 1:
+		printf("  ADT7320 sensor selected!" EOL EOL);
+		init_params.active_device = ID_ADT7320;
+		init_params.interface_init.spi_init = spi_params;
+		break;
+	case 2:
+		printf(" ADT7420 sensor selected!" EOL EOL);
+		init_params.active_device = ID_ADT7420;
+		init_params.interface_init.i2c_init = i2c_params;
+		break;
+	}
+
+	printf("Available devices:" EOL);
+	printf("    1- Internal (Main PCB)" EOL);
+	printf("    2- Remote   (External PCB)" EOL);
+	printf("  Select an option: ");
+
+	int new_dev = 0;
+	invalid_check = scanf("%d", &new_dev);
+
+	//Prompts for user input while correct device is not selected
+	while (input_check(new_dev, 1, 2, invalid_check) == FAILURE) {
+		printf("Device select:" EOL);
+		printf("    1- Internal (Main PCB)" EOL);
+		printf("    2- Remote   (External PCB)" EOL);
+		printf("  Select an option: ");
+		invalid_check = scanf("%d", &new_dev);
+	}
+
+	printf("%d", new_dev);
+
+	switch (new_dev) {
+	case 1:
+		printf("  Internal sensor selected!");
+		init_params.interface_init.i2c_init.slave_address = INT_I2C_ADDRESS;
+		init_params.interface_init.spi_init.chip_select = SPI_CS;
+		break;
+	case 2:
+		printf("  External sensor selected!");
+		init_params.interface_init.i2c_init.slave_address = EXT_I2C_ADDRESS;
+		init_params.interface_init.spi_init.chip_select = SPI_CSE;
+		break;
+	}
+
+	return new_dev;
+}
+
+/*******************************************************************************
+ * @brief	- Reads and prints the temperature in Celsius Degree
+ *
+ * @param None
+ *
+ * @return	- Return SUCCESS flag - currently unused.
+ *******************************************************************************/
+static uint8_t read_temperature()
+{
+	float temp = adt7420_get_temperature(device);
+
+	printf("Current temperature:%.3f C", temp);
+	return SUCCESS;
+}
+
+/*******************************************************************************
+ * @brief	-Set the device resolution for 13 or 16 bits
+ *
+ * @param None
+ *
+ * @return	- Return SUCCESS/FAILURE flags
+ *******************************************************************************/
+static uint8_t set_resolution()
+{
+	printf("  Available resolutions:" EOL);
+	printf("    1- 13-bit" EOL);
+	printf("    2- 16-bit" EOL);
+	printf("  Select an option: ");
+
+	int new_res, invalid_check = 0;
+	invalid_check = scanf("%d", &new_res);
+
+	if (input_check(new_res, 1, 2, invalid_check) == FAILURE) {
+		return FAILURE;
+	} else {
+		printf("%d" EOL, new_res);
+		new_res = (new_res == 1) ? 0 : 1;
+		adt7420_set_resolution(device, new_res);
+		printf("Set resolution to %d-bit", (13 + 3 * new_res));
+		return SUCCESS;
+	}
+}
+
+/*******************************************************************************
+ * @brief	- Set the device operation mode
+ *			  (Continuous conversion, One-shot, SPS, Shutdown).
+ *			- Consult datasheet for more information.
+ *
+ * @param None
+ *
+ * @return - Return SUCCESS/FAILURE flags
+ *******************************************************************************/
+static uint8_t set_op_mode()
+{
+	printf("  Available operation modes:" EOL);
+	printf("    1- Continuous conversion mode (default)" EOL);
+	printf("    2- One-shot mode" EOL);
+	printf("    3- 1 SPS mode" EOL);
+	printf("    4- Shutdown" EOL);
+	printf("  Select a mode: ");
+
+	int new_mode, invalid_check = 0;
+	invalid_check = scanf("%d", &new_mode);
+	if (input_check(new_mode, 1, 4, invalid_check) == FAILURE) {
+		return FAILURE;
+	} else {
+		printf("%d" EOL, new_mode);
+		switch (new_mode) {
+		case 1:
+			adt7420_set_operation_mode(device, ADT7420_OP_MODE_CONT_CONV);
+			break;
+		case 2:
+			/*When One shot mode is set completes one conversion and immediately goes to shutdown mode*/
+			adt7420_set_operation_mode(device, ADT7420_OP_MODE_ONE_SHOT);
+			printf( EOL"       One Shot mode enabled, device will enter shutdown mode once a conversion is complete."
+				EOL);
+			printf("         See page 10 in datasheet for details." EOL);
+			break;
+		case 3:
+			adt7420_set_operation_mode(device, ADT7420_OP_MODE_1_SPS);
+			break;
+		case 4:
+			adt7420_set_operation_mode(device, ADT7420_OP_MODE_SHUTDOWN);
+			break;
+		default:
+			printf("Invalid option" EOL);
+			break;
+		}
+		return SUCCESS;
+	}
+}
+
+/*******************************************************************************
+ * @brief	- Prints poll of temperature based on the frequency of readings and
+ *			  number of samples.
+ *
+ *
+ * @param None
+ *
+ * @return	- Return SUCCESS/FAILURE flags
+ *******************************************************************************/
+static uint8_t bunch_of_temps()
+{
+	printf("  Enter number of desired samples: ");
+	int num_samples, invalid_check = 1;
+
+	invalid_check = scanf("%d", &num_samples);
+	if (input_check(num_samples, 1, 2000000, invalid_check) == FAILURE) {
+		return FAILURE;
+	}
+	printf("%d" EOL, num_samples);
+
+	printf("  Enter a desired frequency in samples/sec (max 10): ");
+	int sample_freq = 1;
+	invalid_check = scanf("%d", &sample_freq);
+	if (input_check(sample_freq, 1, 10, invalid_check) == FAILURE) {
+		return FAILURE;
+	}
+	sample_freq = constrain(sample_freq, 1, 10);
+	printf("%d", sample_freq);
+
+	uint32_t delay_sec = 1000000 / sample_freq;
+
+	printf("  Gathering %d seconds of samples" EOL, num_samples/sample_freq);
+	printf("Press enter to continue and then press again to quit" EOL);
+	getchar();
+
+	for (int i = 0; i < num_samples; i++) {
+		if(getchar_noblock()) {
+			return SUCCESS;
+		} else {
+			printf("  Sample:%d: Temperature:", i + 1);
+			float temp = adt7420_get_temperature(device);
+			printf("%.4f" EOL, temp);
+			udelay(delay_sec);
+		}
+	}
+	return SUCCESS;
+}
+
+/*******************************************************************************
+ * @brief	- Reads back data store in device registers
+ *
+ * @param None
+ *
+ * @return	- Return SUCCESS/FAILURE flags
+ *******************************************************************************/
+
+static uint8_t readback_reg()
+{
+	printf("  Available registers:" EOL);
+	printf("    1- Status" EOL);
+	printf("    2- Configuration" EOL);
+	printf("    3- Temperature" EOL);
+	printf("    4- ID" EOL);
+	printf("    5- Critical Temperature setpoint" EOL);
+	printf("    6- Hysteresis Temperature setpoint" EOL);
+	printf("    7- Temperature high setpoint" EOL);
+	printf("    8- Temperature low setpoint" EOL);
+	printf("  Select a mode: ");
+
+	uint16_t read_value = 0;
+	int new_mode, invalid_check = 0;
+	invalid_check = scanf("%d", &new_mode);
+	if (input_check(new_mode, 1, 8, invalid_check) == FAILURE) {
+		return FAILURE;
+	}
+	printf("%d" EOL, new_mode);
+
+	switch (new_mode) {
+	case 1:
+		read_value = adt7420_get_register_address_and_value(device, REG_STATUS);
+		break;
+	case 2:
+		read_value = adt7420_get_register_address_and_value(device, REG_CONFIG);
+		break;
+	case 3:
+		read_value = adt7420_get_register_address_and_value(device, REG_TEMP);
+		break;
+	case 4:
+		read_value = adt7420_get_register_address_and_value(device, REG_ID);
+		break;
+	case 5:
+		read_value = adt7420_get_register_address_and_value(device, REG_T_CRIT);
+		break;
+	case 6:
+		read_value = adt7420_get_register_address_and_value(device, REG_HIST);
+		break;
+	case 7:
+		read_value = adt7420_get_register_address_and_value(device, REG_T_HIGH);
+		break;
+	case 8:
+		read_value = adt7420_get_register_address_and_value(device, REG_T_LOW);
+		break;
+	default:
+		break;
+	}
+	printf("Read value: 0x%x" EOL, read_value);
+
+	return SUCCESS;
+}
+
+/*******************************************************************************
+ * @brief	- Resets device interface (SPI/I2C) (power-on reset)
+ *
+ * @param None
+ *
+ * @return	- Return SUCCESS flag - currently unused.
+ *******************************************************************************/
+static uint8_t reset_interface()
+{
+	printf("  Resetting interface..." EOL);
+	adt7420_reset(device);
+	udelay(RESET_DELAY);
+	return SUCCESS;
+}
+
+/*******************************************************************************
+ * @brief	- Write to setpoint registers THIGH, TLOW, TCRIT and THYST.
+			- Values entered in Celsius and rounded to a near integer value.
+ *
+ * @param None
+ *
+ * @return	- Return SUCCESS/FAILURE flags
+ *******************************************************************************/
+static uint8_t write_to_setpoint_reg()
+{
+	printf("  Available registers:" EOL);
+	printf("    1- Critical setpoint" EOL);
+	printf("    2- Hystersis setpoint" EOL);
+	printf("    3- Temperature high setpoint" EOL);
+	printf("    4- Temperature low setpoint" EOL);
+	printf("  Select a mode: ");
+
+	int new_mode, invalid_check = 0;
+	invalid_check = scanf("%d", &new_mode);
+	if (input_check(new_mode, 1, 4, invalid_check) == FAILURE) {
+		return FAILURE;
+	}
+	printf("%d" EOL, new_mode);
+
+	float temp_c;
+
+	if(new_mode == 2) {
+		printf("Enter value to write (0 to 15) Celsius:");
+		invalid_check = scanf("%f", &temp_c);
+		if(input_check(temp_c, MIN_HYST_TEMP, MAX_HYST_TEMP,
+			       invalid_check) == FAILURE) {
+			return FAILURE;
+		}
+	} else {
+		printf("Enter value to write (in Celsius):");
+		invalid_check = scanf("%f", &temp_c);
+		if(input_check(temp_c, TEMP_MIN, TEMP_MAX, invalid_check) == FAILURE) {
+			return FAILURE;
+		}
+	}
+
+	printf(" %.2f", temp_c);
+
+	int16_t write_value;
+
+	if(new_mode == 2)
+		write_value = round(temp_c);
+	else
+		write_value = round(128 * temp_c);
+
+	switch (new_mode) {
+	case 1:
+		if (adt7420_wr_setpoint_reg(device, REG_T_CRIT, write_value) == SUCCESS)
+			printf(EOL "0x%x successfuly written" EOL, write_value);
+		else
+			printf(EOL "0x%x NOT successfuly written" EOL, write_value);
+		break;
+	case 2:
+		if (adt7420_wr_setpoint_reg(device, REG_HIST, write_value) == SUCCESS)
+			printf(EOL "0x%x successfuly written (bits 7:4 are fixed at 0)" EOL,
+			       write_value);
+		else
+			printf(EOL "0x%x NOT successfuly written" EOL, write_value);
+		break;
+	case 3:
+		if (adt7420_wr_setpoint_reg(device, REG_T_HIGH, write_value) == SUCCESS)
+			printf(EOL "0x%x successfuly written" EOL, write_value);
+		else
+			printf(EOL "0x%x NOT successfuly written" EOL, write_value);
+		break;
+	case 4:
+		if (adt7420_wr_setpoint_reg(device, REG_T_LOW, write_value) == SUCCESS)
+			printf(EOL "0x%x successfuly written" EOL, write_value);
+		else
+			printf(EOL "0x%x NOT successfuly written" EOL, write_value);
+		break;
+	default:
+		printf("Invalid selection - try again." EOL);
+		mdelay(2000);
+		break;
+	}
+	return SUCCESS;
+}
+
+/*******************************************************************************
+ * @brief	- Set the number of undertemperature/overtemperature faults
+ *			that can occur before setting the INT and CT output pins
+ *
+ * @param None
+ *
+ * @return	- Return SUCCESS/FAILURE flags
+ *******************************************************************************/
+static uint8_t set_fault_queue()
+{
+	printf("  Available fault queue options:" EOL);
+	printf("    1- 1 fault (default) " EOL);
+	printf("    2- 2 faults" EOL);
+	printf("    3- 3 faults" EOL);
+	printf("    4- 4 faults" EOL);
+	printf("  Select a mode: ");
+
+	int new_fault, invalid_check = 0;
+	invalid_check = scanf("%d", &new_fault);
+	if (input_check(new_fault, 1, 4, invalid_check) == FAILURE) {
+		return FAILURE;
+	} else {
+		printf("%d" EOL, new_fault);
+
+		switch (new_fault) {
+		case 1:
+			adt7420_set_fault_queue(device, ADT7420_FAULT_QUEUE_1_FAULT);
+			break;
+		case 2:
+			adt7420_set_fault_queue(device, ADT7420_FAULT_QUEUE_2_FAULTS);
+			break;
+		case 3:
+			adt7420_set_fault_queue(device, ADT7420_FAULT_QUEUE_3_FAULTS);
+			break;
+		case 4:
+			adt7420_set_fault_queue(device, ADT7420_FAULT_QUEUE_4_FAULTS);
+			break;
+		default:
+			printf("Invalid option" EOL);
+			break;
+		}
+		return SUCCESS;
+	}
+}
+
+/*******************************************************************************
+ * @brief	- Set INT/CT Outputs pins to Comparator or Interrupt mode
+ *
+ * @param None
+ *
+ * @return	- Return SUCCESS/FAILURE flags
+ *******************************************************************************/
+static uint8_t set_ct_int_config()
+{
+	int new_polarity = 0;
+	int new_mode, invalid_check = 0;
+
+	printf("  Choose INT/CT mode:" EOL);
+	printf("    1- Interrupt (default) " EOL);
+	printf("    2- Comparator " EOL);
+	printf("  Select a mode: ");
+	invalid_check = scanf("%d", &new_mode);
+	if (input_check(new_mode, 1, 2, invalid_check) == FAILURE) {
+		return FAILURE;
+	} else {
+		printf("%d" EOL, new_mode);
+		new_mode = (new_mode == 1) ? 0 : 1;
+		adt7420_set_ct_int_mode(device, new_mode);
+	}
+
+	printf(EOL " Set output polarity for Critical and Over/Under Temperature pin:"
+	       EOL);
+	printf("   (Feature available only for internal sensors)." EOL);
+
+	if(init_params.interface_init.i2c_init.slave_address == INT_I2C_ADDRESS ||
+	    init_params.interface_init.spi_init.chip_select == SPI_CS) {
+
+		printf("    1- Active Low (default) " EOL);
+		printf("    2- Active High" EOL);
+		printf("  Select a mode: ");
+
+		invalid_check = scanf("%d", &new_polarity);
+		if (input_check(new_polarity, 1, 2, invalid_check) == FAILURE) {
+			return FAILURE;
+		} else {
+			printf("%d" EOL, new_polarity);
+			new_polarity = (new_polarity == 1) ? 0 : 1;
+			adt7420_set_ct_int_polarity(device, new_polarity);
+		}
+	}
+	return SUCCESS;
+}
+
+/*******************************************************************************
+ * @brief Reset microcontroller
+ *
+ * @param None
+ *
+ * @return None.
+ *******************************************************************************/
+static void microcontroller_reset()
+{
+	NVIC_SystemReset();
+}
+
+/*******************************************************************************
+ * @brief Prints the active device every time the main menu is redrawn
+ *
+ * @param external_internal_selection - External or Internal Chip Selected
+ *
+ * @return None.
+ *******************************************************************************/
+static void print_active_device(int external_internal_selection)
+{
+	const char* devices[7] = {EOL EOL "   Active Device: ADT7410 I2C",
+				  EOL EOL "   Active Device: ADT7420 I2C",
+				  EOL EOL "   Active Device: ADT7422 I2C",
+				  EOL EOL "   Active Device: ADT7310 SPI",
+				  EOL EOL "   Active Device: ADT7311 SPI",
+				  EOL EOL "   Active Device: ADT7312 SPI",
+				  EOL EOL "   Active Device: ADT7320 SPI"
+				 };
+
+	const char* external_internal_print[] = {" - Internal Chip " EOL,
+						 " - External Chip " EOL
+						};
+
+	printf("%s %s", devices[init_params.active_device],
+	       external_internal_print[external_internal_selection - 1]);
+}
+
+/*******************************************************************************
+ * @brief Checks is an input is a digit and within valid range
+ *
+ * @param input_val - Value inputed by user
+ * @param lowest_accepted_val - Lowest acceptable value
+ * @param highest_accepted_val - Highest acceptable value
+ * @param invalid_check - Checks if unexpected type of data was entered in scanf
+ *
+ * @return SUCCESS/FAILURE Flags.
+ *******************************************************************************/
+static int input_check(int input_val,
+		       int lowest_accepted_val,
+		       int highest_accepted_val,
+		       int invalid_check)
+{
+	if(invalid_check == 0 || input_val < lowest_accepted_val
+	    || input_val > highest_accepted_val) {
+		printf(EOL EOL "*****   Invalid entry: No changes made *****" EOL );
+		mdelay(WAIT_MENU_TIME);
+		return FAILURE;
+	}
+	return SUCCESS;
+}
diff -r 0228e21af1f0 -r a3472d023b12 app/mbed_platform_drivers.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/mbed_platform_drivers.lib	Thu Sep 23 12:40:39 2021 +0530
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/AnalogDevices/code/platform_drivers/#af1f2416dd26
\ No newline at end of file
diff -r 0228e21af1f0 -r a3472d023b12 app/no-OS.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/no-OS.lib	Thu Sep 23 12:40:39 2021 +0530
@@ -0,0 +1,1 @@
+https://github.com/analogdevicesinc/no-OS/#fa40d58aa19a2116731c4b568bf47b27f30daca7
diff -r 0228e21af1f0 -r a3472d023b12 app_config.h
--- a/app_config.h	Mon Dec 09 17:54:51 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,127 +0,0 @@
-/*************************************************************************//**
- *   @file   app_config.h
- *   @brief  Configuration file of AD5686 firmware example program
- *   @author ssmith (sean.smith@analog.com)
-******************************************************************************
-* 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.
-* 
-* 20180927-7CBSD SLA
-*****************************************************************************/
-
-#ifndef _APP_CONFIG_H_
-#define _APP_CONFIG_H_
-
-#include <stdint.h>
-#include "PinNames.h"
-
-#include "platform_drivers.h"
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-#ifdef __cplusplus
-#include "adt7420.h"
-}
-#endif
-
-
-#ifndef ACTIVE_DEVICE
-/** 
-   #define your chosen device here from the 
-   adt7420_type (adt7420.h) enum
-*/
-#define ACTIVE_DEVICE ID_ADT7320
-#endif // !
-
-/**
-   ADT7420 is a 7-bit I2C address 
-   MBED API uses 8-bit addresses
-*/
-#define EXTERNAL_I2C  0x49<<1
-#define INTERNAL_I2C  0x48<<1
-
-/**
-   ChipSelect index definition for 
-   PinName array in main.cpp
-*/
-#define EXTERNAL_SPI 1
-#define INTERNAL_SPI 0
-
-/**
-  Add a line-ending constant as different emulators 
-  implement it in various ways - simple to change it here
-*/
-#define EOL "\r\n"
-/**
-  The ADI SDP_K1 can be used with both arduino headers
-  or the 120-pin SDP connector found on ADI evaluation
-  boards. The default is the SDP connector
-
-  Uncomment the ARDUINO #define above to enable the ARDUINO connector
-*/
-
-#define  ARDUINO
-
-#ifdef ARDUINO
-	#define I2C_SCL     D15
-	#define I2C_SDA     D14
-
-	#define SPI_CS		D10
-	#define SPI_MISO	D12
-	#define SPI_MOSI	D11
-	#define SPI_SCK		D13
-
-	#define SPI_CSE 	D9 
-	
-#else
-	
-	#define I2C_SCL     SDP_I2C_SCL
-	#define I2C_SDA     SDP_I2C_SDA
-
-	#define SPI_CS		SDP_SPI_CS_A
-	#define SPI_MISO	SDP_SPI_MISO
-	#define SPI_MOSI	SDP_SPI_MOSI
-	#define SPI_SCK		SDP_SPI_SCK
-
-	#define SPI_CSE 	SDP_SPI_CS_B
-	
-#endif
-
-#endif //_APP_CONFIG_H_
\ No newline at end of file
diff -r 0228e21af1f0 -r a3472d023b12 main.cpp
--- a/main.cpp	Mon Dec 09 17:54:51 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,778 +0,0 @@
-/*************************************************************************//**
- *   @file   main.cpp
- *   @brief  Main application code for EVAL-TempSense-ARDZ mbed example program
- *   @author ssmith (sean.smith@analog.com)
-******************************************************************************
-* 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.
-* 
-* 20180927-7CBSD SLA
-*****************************************************************************/
-#include <cstdio>
-#include <mbed.h>
-#include "app_config.h"
-#include <cmath>
-
-#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
-
-#define TEMP_MIN                -40
-#define TEMP_MAX                150
-#define MAX_HYST_TEMP           15
-#define MIN_HYST_TEMP           0
-
-#define RESET_DELAY             500
-#define WAIT_MENU_TIME          1
-#define NOT_USED                0
-
-static void print_title(void);
-static void print_prompt(void);
-static uint8_t select_device();
-static void print_active_device(int ext_int_value);
-static int get_menu_select(uint8_t *menu_select);
-static uint8_t read_temperature();
-static uint8_t set_resolution();
-static uint8_t set_op_mode();
-static uint8_t bunch_of_temps();
-static uint8_t readback_reg();
-static uint8_t reset_interface();
-static uint8_t write_to_setpoint_reg();
-static uint8_t set_fault_queue();
-static uint8_t set_ct_int_config();
-static void microcontroller_reset();
-static int input_check(int input_val,
-                       int lowest_accepted_val,
-                       int highest_accepted_val, 
-                       int invalid_check);
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-#include "adt7420.h"
-#ifdef __cplusplus
-}				  
-#endif // __cplusplus
-
-
-/******************************************************************************/
-/************************** Variables Declarations ****************************/
-/******************************************************************************/
-
-/**
-	The following definitions are a requirement for the platform_driver
-	Pin are changed if required in the app_config.h file
- ***/
-PinName slave_selects[MAX_SLAVE_SELECTS] = { SPI_CS, SPI_CSE };
-mbed::SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK);
-mbed::I2C i2c(I2C_SDA, I2C_SCL);
-
-
-i2c_init_param i2c_params = {
-	GENERIC_I2C,     // i2c type
-    NOT_USED,	     // i2c id
-	100000, 		 // i2c max speed (hz)
-	INTERNAL_I2C,    // i2c slave address (defined in app_config.h)
-}; 
-
-spi_init_param spi_params = {
-	MBED,			 //For future ADI use
-	GENERIC_SPI,	 //For future ADI use
-	NOT_USED,		 //id 
-	1000000,		 //SPI frequency (Hz)
-	SPI_MODE_3,		 //CPOL/CPHA settings for your device
-	INTERNAL_SPI,	 //CS index for PinName (defined in app_config.h)
-};
-
-adt7420_init_param init_params = {
-	i2c_params, 	// I2C parameters 
-	spi_params, 	// SPI parameters 
-	NOT_USED,		//Resolution setting
-    ACTIVE_DEVICE, //Set this in app_config.h
-};
-
-adt7420_dev *device;
-
-registers_e registers;
-
-
-int32_t connected = -1;
-uint8_t device_id = 0;
-
-//Configure and instantiate the UART - PB10/11
-Serial pc(USBTX, USBRX, 115200);
-
-
-
-int main()
-{
-	uint8_t menu_select = 0;
-
-   	print_title();
-
-    device_id = select_device();
-       
-	connected = adt7420_init(&device, init_params);
-
-    if (connected != SUCCESS) {
-        pc.printf(EOL EOL "  Connection to device failed :(" EOL);
-        pc.printf("  ...Restarting application...  " EOL);
-        wait(WAIT_MENU_TIME);
-        microcontroller_reset();
-    } else {
-        pc.printf(EOL EOL "  Connection to device succeeded!" EOL);
-    }
-    
-    while (connected == SUCCESS) {
-        menu_select = 0;
-        print_active_device(device_id);
-		print_prompt();
-
-		if (get_menu_select(&menu_select) == FAILURE)
-            pc.printf(EOL "*****   Returning to main menu   *****" EOL);
-		else {
-			switch (menu_select) {
-			case 1:
-				read_temperature();
-				break;  
-			case 2:
-				set_resolution();
-				break;
-			case 3:
-				set_op_mode();
-				break;
-			case 4:
-				bunch_of_temps();
-				break;
-			case 5:
-				readback_reg();
-				break;
-			case 6:
-				reset_interface();
-				break;
-			case 7:
-				write_to_setpoint_reg();
-				break;
-            case 8:
-                set_fault_queue();
-                break;
-            case 9:
-                set_ct_int_config();
-                break;
-            case 10:
-				/*Restore device registers to default values before restarting microcontroller*/
-                reset_interface();
-                microcontroller_reset();
-                break;
-			default:
-				pc.printf("Invalid option" EOL);
-				break;
-			}
-        }
-		wait(WAIT_MENU_TIME); //wait 1 second
-	}
-}
-
-
-/***************************************************************************//**
- * @brief	Prints the title block.
- *******************************************************************************/
-void print_title()
-{
-	pc.printf("*****************************************************************" EOL);
-	pc.printf("* EVAL-TempeSense-ARDZ Demonstration Program -- (mbed)          *" EOL);
-	pc.printf("*                                                               *" EOL);
-	pc.printf("* This program demonstrates communication with the ADT7xx       *" EOL);
-	pc.printf("* High-Accuracy digital temperature sensor family               *" EOL);
-	pc.printf("* It will also work with both SPI & I2C versions                *" EOL);
-	pc.printf("*                                                               *" EOL);
-	pc.printf("* Set the baud rate to 115200 select the newline terminator.    *" EOL);
-	pc.printf("*****************************************************************" EOL);
-}
-
-/***************************************************************************//**
- * @brief	Prints the "main menu" prompt to the console.
- *******************************************************************************/
-void print_prompt()
-{
-	pc.printf(EOL EOL "Command Summary:" EOL);
-	pc.printf("  1  -Read temperature" EOL);
-	pc.printf("  2  -Set resolution" EOL);
-	pc.printf("  3  -Set operation mode" EOL);
-	pc.printf("  4  -Poll temperature" EOL);
-	pc.printf("  5  -Read a register" EOL);
-	pc.printf("  6  -Reset the interface" EOL);
-	pc.printf("  7  -Write to a setpoint register" EOL);
-    pc.printf("  8  -Set Fault Queue configuration" EOL);
-    pc.printf("  9  -Set CT/INT polarity and mode" EOL);
-    pc.printf("  10 -Full System Reset" EOL);
-	pc.printf(EOL);
-}
-
-static int get_menu_select(uint8_t *menu_select) 
-{
-    int invalid_check = pc.scanf("%d",(int *) menu_select);
-    return input_check(*menu_select, 1, 10, invalid_check);
-}
-
-/***************************************************************************//**
- * @brief 	- Select the serial interface (SPI/I2C) and device 
- *				based on the part family.
- *		  	- Only one device and interface can be active. 
- *						Example: ADT7320 - SPI (Internal or Remote device)
- *								 ADT7420 - I2C (Internal or Remote device)
- *
- * @param 	None
- *
- * @return 	new_dev - Return device selected  
- *				 	  Example: 1  - Internal(Main PCB) 
- *							   2  - Remote (External PCB)
- *******************************************************************************/
-uint8_t select_device()
-{
-    pc.printf("Please select interface by choosing a device:" EOL);
-	pc.printf("    1- ADT7320 (SPI)" EOL);
-	pc.printf("    2- ADT7420 (I2C)" EOL);
-	pc.printf("  Select an option: ");
-    
-    int invalid_check, new_interface = 0;
-    invalid_check = pc.scanf("%d", &new_interface);
-	
-	//Prompts for user input while correct interface is not selected
-    while (input_check(new_interface, 1, 2, invalid_check) == FAILURE) {
-        pc.printf("Please select interface by choosing a device:" EOL);
-	    pc.printf("    1- ADT7320 (SPI)" EOL);
-	    pc.printf("    2- ADT7420 (I2C)" EOL);
-	    pc.printf("  Select an option: ");
-        invalid_check = pc.scanf("%d", &new_interface);
-	}
-    pc.printf("%d", new_interface);
-
-    switch (new_interface) {
-	case 1:
-		pc.printf("  ADT7320 sensor selected!" EOL EOL);
-		init_params.act_device = ID_ADT7320;
-		break;
-	case 2:
-		pc.printf(" ADT7420 sensor selected!" EOL EOL);
-		init_params.act_device = ID_ADT7420;
-		break;
-	}
-
-    pc.printf("Available devices:" EOL);
-	pc.printf("    1- Internal (Main PCB)" EOL);
-	pc.printf("    2- Remote   (External PCB)" EOL);
-	pc.printf("  Select an option: ");
-    
-    int new_dev = 0;
-    invalid_check = pc.scanf("%d", &new_dev);
-	
-	//Prompts for user input while correct device is not selected
-    while (input_check(new_dev, 1, 2, invalid_check) == FAILURE) {
-        pc.printf("Device select:" EOL);
-	    pc.printf("    1- Internal (Main PCB)" EOL);
-	    pc.printf("    2- Remote   (External PCB)" EOL);
-	    pc.printf("  Select an option: ");
-        invalid_check = pc.scanf("%d", &new_dev);
-	}
-
-    pc.printf("%d", new_dev);
-    
-	switch (new_dev) {
-	case 1:
-		pc.printf("  Internal sensor selected!");
-		init_params.mbed_i2c_init.slave_address = INTERNAL_I2C;
-		init_params.mbed_spi_init.chip_select = INTERNAL_SPI;
-        break;
-	case 2:
-		pc.printf("  External sensor selected!");
-		init_params.mbed_i2c_init.slave_address = EXTERNAL_I2C;
-		init_params.mbed_spi_init.chip_select = EXTERNAL_SPI;
-		break;
-	}
-    
-     return new_dev;
-}
-
-/***************************************************************************//**
- * @brief	- Reads and prints the temperature in Celsius Degree
- *
- * @param None
- *
- * @return	- Return SUCCESS flag - currently unused.
- *******************************************************************************/
-static uint8_t read_temperature()
-{
-	float temp = adt7420_get_temperature(device);
-
-	pc.printf("Current temperature:%.3f C", temp);
-	return SUCCESS;
-}
-
-/***************************************************************************//**
- * @brief	-Set the device resolution for 13 or 16 bits 
- *
- * @param None
- *
- * @return	- Return SUCCESS/FAILURE flags 
- *******************************************************************************/
-static uint8_t set_resolution()
-{
-	pc.printf("  Available resolutions:" EOL);
-	pc.printf("    1- 13-bit" EOL);
-	pc.printf("    2- 16-bit" EOL);
-	pc.printf("  Select an option: ");
-
-	int new_res, invalid_check = 0;
-    invalid_check = pc.scanf("%d", &new_res);
-    
-    if (input_check(new_res, 1, 2, invalid_check) == FAILURE) {
-		return FAILURE;
-	} else {
-        pc.printf("%d" EOL, new_res);
-        new_res = (new_res == 1) ? 0 : 1;
-        adt7420_set_resolution(device, new_res);
-        pc.printf("Set resolution to %d-bit", (13 + 3 * new_res));
-        return SUCCESS;
-    }
-}
-
-/***************************************************************************//**
- * @brief	- Set the device operation mode
- *			  (Continuous conversion, One-shot, SPS, Shutdown). 
- *			- Consult datasheet for more information.
- *
- * @param None
- *
- * @return - Return SUCCESS/FAILURE flags 
- *******************************************************************************/
-static uint8_t set_op_mode()
-{
-	pc.printf("  Available operation modes:" EOL);
-	pc.printf("    1- Continuous conversion mode (default)" EOL);
-	pc.printf("    2- One-shot mode" EOL);
-	pc.printf("    3- 1 SPS mode" EOL);
-	pc.printf("    4- Shutdown" EOL);
-	pc.printf("  Select a mode: ");
-
-	int new_mode, invalid_check = 0;
-	invalid_check = pc.scanf("%d", &new_mode);
-    if (input_check(new_mode, 1, 4, invalid_check) == FAILURE) {
-		return FAILURE;
-	} else { 
-	pc.printf("%d" EOL, new_mode);
-	switch (new_mode) {
-        case 1:
-            adt7420_set_operation_mode(device, ADT7420_OP_MODE_CONT_CONV);
-            break;
-        case 2:
-        /*When One shot mode is set completes one conversion and immediately goes to shutdown mode*/
-            adt7420_set_operation_mode(device, ADT7420_OP_MODE_ONE_SHOT);
-            pc.printf( EOL"       One Shot mode enabled, device will enter shutdown mode once a conversion is complete." EOL);
-            pc.printf("         See page 10 in datasheet for details." EOL);
-            break;
-        case 3:
-            adt7420_set_operation_mode(device, ADT7420_OP_MODE_1_SPS);
-            break;
-        case 4:
-            adt7420_set_operation_mode(device, ADT7420_OP_MODE_SHUTDOWN);
-            break;
-        default:
-            pc.printf("Invalid option" EOL);
-            break;
-	    }
-	return SUCCESS;
-    }
-}
-
-/***************************************************************************//**
- * @brief	- Prints poll of temperature based on the frequency of readings and
- *			  number of samples. 
- *			
- *
- * @param None
- *
- * @return	- Return SUCCESS/FAILURE flags
- *******************************************************************************/
-static uint8_t bunch_of_temps()
-{
-	pc.printf("  Enter number of desired samples: ");
-	int num_samples, invalid_check = 1;
-
-    invalid_check = pc.scanf("%d", &num_samples);
-    if (input_check(num_samples, 1, 2000000, invalid_check) == FAILURE) {
-		return FAILURE;
-	}
-    pc.printf("%d" EOL, num_samples);
-
-	pc.printf("  Enter a desired frequency in samples/sec (max 10): ");
-	int sample_freq = 1;
-    invalid_check = pc.scanf("%d", &sample_freq);
-    if (input_check(sample_freq, 1, 10, invalid_check) == FAILURE) {
-		return FAILURE;
-	}    
-	sample_freq = constrain(sample_freq, 1, 10);
-	pc.printf("%d", sample_freq);
-
-	uint32_t delay_sec = 1000000 / sample_freq;
-       
-	pc.printf("  Gathering %d seconds of samples" EOL, num_samples/sample_freq);
-    pc.printf("Press enter to continue and then press again to quit" EOL);
-	getchar();
-
-    for (int i = 0; i < num_samples; i++) {
-        if(pc.readable()) {
-            return SUCCESS; 
-        } else {
-            pc.printf("  Sample:%d: Temperature:", i + 1);
-            float temp = adt7420_get_temperature(device);
-            pc.printf("%.4f" EOL, temp);
-            wait_us(delay_sec);
-        } 
-    }
-	return SUCCESS;
-}
-
-/***************************************************************************//**
- * @brief	- Reads back data store in device registers
- *
- * @param None
- *
- * @return	- Return SUCCESS/FAILURE flags
- *******************************************************************************/
-
-static uint8_t readback_reg()
-{
-	pc.printf("  Available registers:" EOL);
-	pc.printf("    1- Status" EOL);
-	pc.printf("    2- Configuration" EOL);
-	pc.printf("    3- Temperature" EOL);
-	pc.printf("    4- ID" EOL);
-	pc.printf("    5- Critical Temperature setpoint" EOL);
-	pc.printf("    6- Hysteresis Temperature setpoint" EOL);
-	pc.printf("    7- Temperature high setpoint" EOL);
-	pc.printf("    8- Temperature low setpoint" EOL);
-	pc.printf("  Select a mode: ");
-
-	uint16_t read_value = 0;
-	int new_mode, invalid_check = 0;
-	invalid_check = pc.scanf("%d", &new_mode);
-    if (input_check(new_mode, 1, 8, invalid_check) == FAILURE) {
-		return FAILURE;
-	}
-	pc.printf("%d" EOL, new_mode);
-
-	switch (new_mode) {
-	case 1:
-		read_value = get_register_value(device, REG_STATUS);
-		break;
-	case 2:
-		read_value = get_register_value(device, REG_CONFIG);
-		break;
-	case 3:
-		read_value = get_register_value(device, REG_TEMP);
-		break;
-	case 4:
-		read_value = get_register_value(device, REG_ID);
-		break;
-	case 5:
-		read_value = get_register_value(device, REG_T_CRIT);
-		break;
-	case 6:
-		read_value = get_register_value(device, REG_HIST);
-		break;
-	case 7:
-		read_value = get_register_value(device, REG_T_HIGH);
-		break;
-	case 8:
-		read_value = get_register_value(device, REG_T_LOW);
-		break;
-	default:
-		break;
-	}
-	pc.printf("Read value: 0x%x" EOL, read_value);
-
-	return SUCCESS;
-}
-
-/***************************************************************************//**
- * @brief	- Resets device interface (SPI/I2C) (power-on reset)
- *
- * @param None
- *
- * @return	- Return SUCCESS flag - currently unused.
- *******************************************************************************/
-static uint8_t reset_interface()
-{
-	pc.printf("  Resetting interface..." EOL);
-	adt7420_reset_interface(device);
-    wait_us(RESET_DELAY);
-    return SUCCESS;
-}
-
-/***************************************************************************//**
- * @brief	- Write to setpoint registers THIGH, TLOW, TCRIT and THYST.
-			- Values entered in Celsius and rounded to a near integer value.
- *
- * @param None
- *
- * @return	- Return SUCCESS/FAILURE flags
- *******************************************************************************/
-static uint8_t write_to_setpoint_reg()
-{
-	pc.printf("  Available registers:" EOL);
-	pc.printf("    1- Critical setpoint" EOL);
-	pc.printf("    2- Hystersis setpoint" EOL);
-	pc.printf("    3- Temperature high setpoint" EOL);
-	pc.printf("    4- Temperature low setpoint" EOL);
-	pc.printf("  Select a mode: ");
-
-	int new_mode, invalid_check = 0;
-	invalid_check = pc.scanf("%d", &new_mode);
-    if (input_check(new_mode, 1, 4, invalid_check) == FAILURE) {
-		return FAILURE;
-	}
-	pc.printf("%d" EOL, new_mode);
-    
-    float temp_c;
-
-    if(new_mode == 2) {
-        pc.printf("Enter value to write (0 to 15) Celsius:");
-        invalid_check = pc.scanf("%f", &temp_c);
-        if(input_check(temp_c, MIN_HYST_TEMP, MAX_HYST_TEMP, invalid_check) == FAILURE) {
-            return FAILURE;
-        }
-    } else {
-        pc.printf("Enter value to write (in Celsius):");
-        invalid_check = pc.scanf("%f", &temp_c);
-        if(input_check(temp_c, TEMP_MIN, TEMP_MAX, invalid_check) == FAILURE){
-            return FAILURE;
-        }
-    }
-	    
-    pc.printf(" %.2f", temp_c);
-	
-    int16_t write_value;
-
-    if(new_mode == 2) 
-        write_value = round(temp_c);
-    else 
-        write_value = round(128 * temp_c);
-
-	switch (new_mode) {
-	case 1:
-		if (adt7420_wr_setpoint_reg(device, REG_T_CRIT, write_value) == SUCCESS)
-			pc.printf(EOL "0x%x successfuly written" EOL, write_value);
-		else
-			pc.printf(EOL "0x%x NOT successfuly written" EOL, write_value);
-		break;
-	case 2:
-		if (adt7420_wr_setpoint_reg(device, REG_HIST, write_value) == SUCCESS)
-			pc.printf(EOL "0x%x successfuly written (bits 7:4 are fixed at 0)" EOL, write_value);
-		else
-			pc.printf(EOL "0x%x NOT successfuly written" EOL, write_value);
-		break;
-	case 3:
-		if (adt7420_wr_setpoint_reg(device, REG_T_HIGH, write_value) == SUCCESS)
-			pc.printf(EOL "0x%x successfuly written" EOL, write_value);
-		else
-			pc.printf(EOL "0x%x NOT successfuly written" EOL, write_value);
-		break;
-	case 4:
-		if (adt7420_wr_setpoint_reg(device, REG_T_LOW, write_value) == SUCCESS)
-			pc.printf(EOL "0x%x successfuly written" EOL, write_value);
-		else
-			pc.printf(EOL "0x%x NOT successfuly written" EOL, write_value);
-		break;
-	default:
-		pc.printf("Invalid selection - try again." EOL);
-		wait(2);
-		break;
-	}
-	return SUCCESS;
-}
-
-/***************************************************************************//**
- * @brief	- Set the number of undertemperature/overtemperature faults 
- *			that can occur before setting the INT and CT output pins
- *
- * @param None
- *
- * @return	- Return SUCCESS/FAILURE flags
- *******************************************************************************/
-static uint8_t set_fault_queue()
-{
-    pc.printf("  Available fault queue options:" EOL);
-	pc.printf("    1- 1 fault (default) " EOL);
-	pc.printf("    2- 2 faults" EOL);
-	pc.printf("    3- 3 faults" EOL);
-	pc.printf("    4- 4 faults" EOL);
-	pc.printf("  Select a mode: ");
-
-	int new_fault, invalid_check = 0;
-	invalid_check = pc.scanf("%d", &new_fault);
-    if (input_check(new_fault, 1, 4, invalid_check) == FAILURE) {
-		return FAILURE;
-	} else {
-	pc.printf("%d" EOL, new_fault);
-
- 	switch (new_fault)
-	     {
-        case 1:
-            adt7420_set_fault_queue(device, ADT7420_FAULT_QUEUE_1_FAULT);
-            break;
-        case 2:
-            adt7420_set_fault_queue(device, ADT7420_FAULT_QUEUE_2_FAULTS);
-            break;
-        case 3:
-            adt7420_set_fault_queue(device, ADT7420_FAULT_QUEUE_3_FAULTS);
-            break;
-        case 4:
-            adt7420_set_fault_queue(device, ADT7420_FAULT_QUEUE_4_FAULTS);
-            break;
-        default:
-            pc.printf("Invalid option" EOL);
-            break;
-	    }   return SUCCESS;
-    } 
-}
-
-/***************************************************************************//**
- * @brief	- Set INT/CT Outputs pins to Comparator or Interrupt mode
- *
- * @param None
- *
- * @return	- Return SUCCESS/FAILURE flags
- *******************************************************************************/
-static uint8_t set_ct_int_config()
-{
-    int new_polarity = 0;
-    int new_mode, invalid_check = 0;
-
-    pc.printf("  Choose INT/CT mode:" EOL);
-    pc.printf("    1- Interrupt (default) " EOL);
-    pc.printf("    2- Comparator " EOL);
-    pc.printf("  Select a mode: ");
-    invalid_check = pc.scanf("%d", &new_mode);
-    if (input_check(new_mode, 1, 2, invalid_check) == FAILURE) {
-        return FAILURE;
-    } else {
-        pc.printf("%d" EOL, new_mode);
-        new_mode = (new_mode == 1) ? 0 : 1;
-        adt7420_set_ct_int_mode(device, new_mode);    
-    }
-
-    pc.printf(EOL " Set output polarity for Critical and Over/Under Temperature pin:" EOL);
-    pc.printf("   (Feature available only for internal sensors)." EOL);
-
-    if(init_params.mbed_i2c_init.slave_address == INTERNAL_I2C ||
-        init_params.mbed_spi_init.chip_select == INTERNAL_SPI) {
-
-        pc.printf("    1- Active Low (default) " EOL);
-        pc.printf("    2- Active High" EOL);
-        pc.printf("  Select a mode: ");
-        
-        invalid_check = pc.scanf("%d", &new_polarity);
-        if (input_check(new_polarity, 1, 2, invalid_check) == FAILURE) {
-            return FAILURE;
-        } else {
-            pc.printf("%d" EOL, new_polarity);
-            new_polarity = (new_polarity == 1) ? 0 : 1;
-            adt7420_set_ct_int_polarity(device, new_polarity);
-        }
-    }
-    return SUCCESS;    
-}
-
-/***************************************************************************//**
- * @brief Reset microcontroller
- *
- * @param None
- *
- * @return None.
- *******************************************************************************/
-static void microcontroller_reset()
-{
-    NVIC_SystemReset();    
-}   
-       
-/***************************************************************************//**
- * @brief Prints the active device every time the main menu is redrawn
- *
- * @param external_internal_selection - External or Internal Chip Selected
- *
- * @return None.
- *******************************************************************************/
-static void print_active_device(int external_internal_selection)
-{
-    const char* devices[7] = {EOL EOL "   Active Device: ADT7410 I2C" ,
-                        EOL EOL "   Active Device: ADT7420 I2C",
-                        EOL EOL "   Active Device: ADT7422 I2C",
-                        EOL EOL "   Active Device: ADT7310 SPI",
-                        EOL EOL "   Active Device: ADT7311 SPI",
-                        EOL EOL "   Active Device: ADT7312 SPI",
-                        EOL EOL "   Active Device: ADT7320 SPI"};
-
-    const char* external_internal_print[] = {" - Internal Chip " EOL,
-                                             " - External Chip " EOL };
-
-    pc.printf("%s %s", devices[init_params.act_device], external_internal_print[external_internal_selection - 1]);
-}
-
-/***************************************************************************//**
- * @brief Checks is an input is a digit and within valid range
- *
- * @param input_val - Value inputed by user
- * @param lowest_accepted_val - Lowest acceptable value
- * @param highest_accepted_val - Highest acceptable value
- * @param invalid_check - Checks if unexpected type of data was entered in scanf
- *
- * @return SUCCESS/FAILURE Flags.
- *******************************************************************************/
- static int input_check(int input_val, 
-                        int lowest_accepted_val,
-                        int highest_accepted_val, 
-                        int invalid_check)
- {
-        if(invalid_check == 0 || input_val < lowest_accepted_val || input_val > highest_accepted_val) {
-            pc.printf(EOL EOL "*****   Invalid entry: No changes made *****" EOL );
-            wait(WAIT_MENU_TIME);
-            return FAILURE;
-        } 
-        return SUCCESS;
-}
\ No newline at end of file
diff -r 0228e21af1f0 -r a3472d023b12 mbed-os.lib
--- a/mbed-os.lib	Mon Dec 09 17:54:51 2019 +0000
+++ b/mbed-os.lib	Thu Sep 23 12:40:39 2021 +0530
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#9cab58358b338a3a7d7de258090bf0b500b2be97
+https://github.com/ARMmbed/mbed-os/#a2ada74770f043aff3e61e29d164a8e78274fcd4
\ No newline at end of file
diff -r 0228e21af1f0 -r a3472d023b12 mbed_app.json
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json	Thu Sep 23 12:40:39 2021 +0530
@@ -0,0 +1,15 @@
+{
+    "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"],
+    "target_overrides": {
+        "*": {
+            "platform.default-serial-baud-rate": 115200,
+            "target.printf_lib": "std"
+        }
+    }
+}
\ No newline at end of file
diff -r 0228e21af1f0 -r a3472d023b12 platform_drivers.lib
--- a/platform_drivers.lib	Mon Dec 09 17:54:51 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/teams/AnalogDevices/code/platform_drivers/#efb143ea4191