Example program for AD717x and AD411x family of products.

Dependencies:   adi_console_menu platform_drivers

Revision:
3:6c7324997606
Parent:
1:48914f9593f1
Child:
4:4592cc69bfa6
--- a/app/ad717x_menu_defines.h	Tue Mar 31 11:25:12 2020 +0000
+++ b/app/ad717x_menu_defines.h	Tue Apr 14 18:14:29 2020 +0000
@@ -41,6 +41,10 @@
 int32_t menu_read_write_device_regs(uint32_t menu_id);
 int32_t menu_channels_enable_disable(uint32_t action);
 int32_t menu_analog_input_connect(uint32_t user_analog_input);
+int32_t menu_input_type_selection(uint32_t input_type_id);
+int32_t menu_select_chn_pair(uint32_t user_channel_pair);
+int32_t menu_select_input_pair(uint32_t user_input_pair);
+int32_t menu_open_wire_detection(uint32_t menu_id);
 int32_t menu_rw_ad717x_register(uint32_t rw_id);
 int32_t menu_single_conversion(uint32_t channel_id);
 int32_t menu_continuous_conversion_tabular(uint32_t channel_id);
@@ -51,7 +55,7 @@
 int32_t menu_odr_select(uint32_t user_input_odr_val);
 int32_t menu_polarity_select(uint32_t user_input_polarity);
 int32_t menu_reference_source_select(uint32_t user_input_reference);
-int32_t  menu_ref_buffer_enable_disable(uint32_t user_action);
+int32_t menu_ref_buffer_enable_disable(uint32_t user_action);
 int32_t menu_input_buffer_enable_disable(uint32_t user_action);
 
 
@@ -300,6 +304,14 @@
 #define VIN_PAIR_OFFSET			5
 
 
+// Channels define for the AD717x/AD414x devices
+#define ADC_CHN(x)	(x)
+
+// Offset to form Channel pairs
+#define CHN_PAIR_OFFSET		4
+#define CHN_PAIR_MASK		0x0F
+
+
 // Device register read/write identifiers
 #define DEVICE_REG_READ_ID		(uint32_t)1
 #define DEVICE_REG_WRITE_ID		(uint32_t)2
@@ -308,6 +320,10 @@
 #define SELECT_DISBLE			(uint32_t)0
 #define SELECT_ENABLE			(uint32_t)1
 
+// Input Type selection identifiers
+#define SINGLE_ENDED_INPUT		(uint32_t)0
+#define DIFF_ENDED_INPUT		(uint32_t)1
+
 // Analog input select identifiers
 #define ANALOG_INP_PAIR_SELECT	(uint32_t)0
 #define POS_ANALOG_INP_SELECT	(uint32_t)1
@@ -577,6 +593,112 @@
 
 
 /*
+ * Definition of the open wire detect inputs type menu items and menu itself
+ */
+console_menu_item open_wire_detect_input_type_items[] = {
+	{ "Single Ended Input",			'S', menu_input_type_selection, SINGLE_ENDED_INPUT },
+	{ "Differential Ended Input",	'D', menu_input_type_selection, DIFF_ENDED_INPUT },
+};
+
+console_menu open_wire_detect_input_type_menu = {
+	.title = "Select Analog Input Type",
+	.items = open_wire_detect_input_type_items,
+	.itemCount = ARRAY_SIZE(open_wire_detect_input_type_items),
+	.headerItem = NULL,
+	.footerItem = NULL,
+	.enableEscapeKey = true
+};
+
+
+/*
+ * Definition of the open wire detect single ended input channel pair menu items and menu itself
+ */
+console_menu_item open_wire_detect_se_channel_items[] = {
+	{ "CHN0, CHN15",	'A', menu_select_chn_pair, ((ADC_CHN(0) << CHN_PAIR_OFFSET)  | ADC_CHN(15)) },
+	{ "CHN1, CHN2",		'B', menu_select_chn_pair, ((ADC_CHN(1) << CHN_PAIR_OFFSET)  | ADC_CHN(2))  },
+	{ "CHN3, CHN4",		'C', menu_select_chn_pair, ((ADC_CHN(3) << CHN_PAIR_OFFSET)  | ADC_CHN(4))  },
+	{ "CHN5, CHN6",		'D', menu_select_chn_pair, ((ADC_CHN(5) << CHN_PAIR_OFFSET)  | ADC_CHN(6))  },
+	{ "CHN7, CHN8",		'E', menu_select_chn_pair, ((ADC_CHN(7) << CHN_PAIR_OFFSET)  | ADC_CHN(8))  },
+	{ "CHN9, CHN10",	'F', menu_select_chn_pair, ((ADC_CHN(9) << CHN_PAIR_OFFSET)  | ADC_CHN(10)) },
+	{ "CHN11, CHN12",	'G', menu_select_chn_pair, ((ADC_CHN(11) << CHN_PAIR_OFFSET) | ADC_CHN(12)) },
+	{ "CHN13, CHN14",	'H', menu_select_chn_pair, ((ADC_CHN(13) << CHN_PAIR_OFFSET) | ADC_CHN(14)) },
+};
+
+console_menu open_wire_detect_se_channel_menu = {
+	.title = "Select Channel Pair",
+	.items = open_wire_detect_se_channel_items,
+	.itemCount = ARRAY_SIZE(open_wire_detect_se_channel_items),
+	.headerItem = NULL,
+	.footerItem = NULL,
+	.enableEscapeKey = true
+};
+
+
+/*
+ * Definition of the open wire detect differential ended input channel pair menu items and menu itself
+ */
+console_menu_item open_wire_detect_de_channel_items[] = {
+	{ "CHN1, CHN2",		'A', menu_select_chn_pair, ((ADC_CHN(1) << CHN_PAIR_OFFSET)  | ADC_CHN(2))  },
+	{ "CHN5, CHN6",		'B', menu_select_chn_pair, ((ADC_CHN(5) << CHN_PAIR_OFFSET)  | ADC_CHN(6))  },
+	{ "CHN9, CHN10",	'C', menu_select_chn_pair, ((ADC_CHN(9) << CHN_PAIR_OFFSET)  | ADC_CHN(10)) },
+	{ "CHN13, CHN14",	'D', menu_select_chn_pair, ((ADC_CHN(13) << CHN_PAIR_OFFSET) | ADC_CHN(14)) },
+};
+
+console_menu open_wire_detect_de_channel_menu = {
+	.title = "Select Channel Pair",
+	.items = open_wire_detect_de_channel_items,
+	.itemCount = ARRAY_SIZE(open_wire_detect_de_channel_items),
+	.headerItem = NULL,
+	.footerItem = NULL,
+	.enableEscapeKey = true
+};
+
+
+/*
+ * Definition of the open wire detect single ended analog inputs menu items and menu itself
+ */
+console_menu_item open_wire_detect_se_analog_input_items[] = {
+	{ "VIN0, VINCOM",	'A', menu_select_input_pair, ((VIN0_INPUT_BITS << VIN_PAIR_OFFSET) | VINCOM_INPUT_BITS) },
+	{ "VIN1, VINCOM",	'B', menu_select_input_pair, ((VIN1_INPUT_BITS << VIN_PAIR_OFFSET) | VINCOM_INPUT_BITS) },
+	{ "VIN2, VINCOM",	'C', menu_select_input_pair, ((VIN2_INPUT_BITS << VIN_PAIR_OFFSET) | VINCOM_INPUT_BITS) },
+	{ "VIN3, VINCOM",	'D', menu_select_input_pair, ((VIN3_INPUT_BITS << VIN_PAIR_OFFSET) | VINCOM_INPUT_BITS) },
+	{ "VIN4, VINCOM",	'E', menu_select_input_pair, ((VIN4_INPUT_BITS << VIN_PAIR_OFFSET) | VINCOM_INPUT_BITS) },
+	{ "VIN5, VINCOM",	'F', menu_select_input_pair, ((VIN5_INPUT_BITS << VIN_PAIR_OFFSET) | VINCOM_INPUT_BITS) },
+	{ "VIN6, VINCOM",	'G', menu_select_input_pair, ((VIN6_INPUT_BITS << VIN_PAIR_OFFSET) | VINCOM_INPUT_BITS) },
+	{ "VIN7, VINCOM",	'H', menu_select_input_pair, ((VIN7_INPUT_BITS << VIN_PAIR_OFFSET) | VINCOM_INPUT_BITS) },
+};
+
+console_menu open_wire_detect_se_analog_input_menu = {
+	.title = "Select Analog Inputs",
+	.items = open_wire_detect_se_analog_input_items,
+	.itemCount = ARRAY_SIZE(open_wire_detect_se_analog_input_items),
+	.headerItem = NULL,
+	.footerItem = NULL,
+	.enableEscapeKey = true
+};
+
+
+/*
+ * Definition of the open wire detect differential ended analog inputs menu items and menu itself
+ */
+console_menu_item open_wire_detect_de_analog_input_items[] = {
+	{ "VIN0, VIN1", 'A', menu_select_input_pair, ((VIN0_INPUT_BITS << VIN_PAIR_OFFSET) | VIN1_INPUT_BITS) },
+	{ "VIN2, VIN3", 'B', menu_select_input_pair, ((VIN2_INPUT_BITS << VIN_PAIR_OFFSET) | VIN3_INPUT_BITS) },
+	{ "VIN4, VIN5", 'C', menu_select_input_pair, ((VIN4_INPUT_BITS << VIN_PAIR_OFFSET) | VIN5_INPUT_BITS) },
+	{ "VIN6, VIN7", 'D', menu_select_input_pair, ((VIN6_INPUT_BITS << VIN_PAIR_OFFSET) | VIN7_INPUT_BITS) },
+};
+
+console_menu open_wire_detect_de_analog_input_menu = {
+	.title = "Select Analog Inputs",
+	.items = open_wire_detect_de_analog_input_items,
+	.itemCount = ARRAY_SIZE(open_wire_detect_de_analog_input_items),
+	.headerItem = NULL,
+	.footerItem = NULL,
+	.enableEscapeKey = true
+};
+
+
+/*
  * Definition of the adc register read/write menu items and menu itself
  */
 console_menu_item reg_read_write_items[] = {
@@ -897,7 +1019,11 @@
 	{ "" },
 	{ "Calibrate ADC (Internal)",				'I',	menu_calibrate_adc },
 	{ "" },
-	{ "Read/Write Device Registers",			'J',	menu_read_write_device_regs },
+#if defined(DEV_AD4111)
+	{ "Open Wire Detection",					'J',	menu_open_wire_detection },
+	{ "" },
+#endif
+	{ "Read/Write Device Registers",			'K',	menu_read_write_device_regs },
 };
 
 console_menu ad717x_main_menu = {