precision-converters-firmware
Macros | Functions | Variables
ad5592r_console_app.c File Reference

AD5592R console application interfaces. More...

#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include "app_config.h"
#include "ad5592r_configs.h"
#include "mbed_platform_support.h"
#include "no_os_error.h"
#include "no_os_gpio.h"
#include "no_os_i2c.h"
#include "no_os_spi.h"
#include "mbed_spi.h"
#include "mbed_i2c.h"
#include "ad5592r-base.h"
#include "ad5592r.h"
#include "ad5593r.h"
#include "ad5592r_console_app.h"
Include dependency graph for ad5592r_console_app.c:

Macros

#define EXTERNAL_VREF_VOLTAGE   2.5
 
#define AD5592R_CHANNEL(N)   (N)
 
#define AD5592R_REG_ADC_SEQ_INCL(x)   NO_OS_BIT(x)
 
#define AD5592R_REG_PD_CHANNEL(x)   NO_OS_BIT(x)
 
#define AD5592R_GPIO(x)   NO_OS_BIT(x)
 
#define TEMP_SAMPLE_SIZE   5
 
#define CLEAR_CHANNEL_SELECTION   1000
 
#define MDELAY_TO_DISPLAY_INSTRUCTION   1000
 
#define TEMPERATURE_READBACK_CHANNEL   8
 
#define MAX_ADC_CODE   4095.0
 
#define ADC_GAIN_LOW_CONVERSION_VALUE   2.654
 
#define ADC_GAIN_HIGH_CONVERSION_VALUE   1.327
 

Functions

int32_t ad5592r_app_initalization (void)
 Initialize AD5592/3R. ACTIVE_DEVICE defined in app_config.h. More...
 

Variables

float vref_voltage = EXTERNAL_VREF_VOLTAGE
 
console_menu power_down_pin_select_menu
 
console_menu config_channels_menu
 
console_menu general_settings_menu
 
console_menu dac_menu
 
console_menu gpio_menu
 
console_menu adc_menu
 
console_menu_item gpio_menu_items []
 
console_menu_item adc_menu_items []
 
console_menu_item dac_menu_items []
 
console_menu_item general_settings_menu_items []
 
console_menu_item config_channels_menu_items []
 
console_menu_item main_menu_items []
 
console_menu ad5592r_main_menu
 

Detailed Description

AD5592R console application interfaces.

This file is specific to ad5592r and ad5593r console menu application handle. The functions defined in this file performs the action based on user selected console menu.


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.

Macro Definition Documentation

◆ AD5592R_CHANNEL

#define AD5592R_CHANNEL (   N)    (N)

◆ AD5592R_GPIO

#define AD5592R_GPIO (   x)    NO_OS_BIT(x)

◆ AD5592R_REG_ADC_SEQ_INCL

#define AD5592R_REG_ADC_SEQ_INCL (   x)    NO_OS_BIT(x)

◆ AD5592R_REG_PD_CHANNEL

#define AD5592R_REG_PD_CHANNEL (   x)    NO_OS_BIT(x)

◆ ADC_GAIN_HIGH_CONVERSION_VALUE

#define ADC_GAIN_HIGH_CONVERSION_VALUE   1.327

◆ ADC_GAIN_LOW_CONVERSION_VALUE

#define ADC_GAIN_LOW_CONVERSION_VALUE   2.654

◆ CLEAR_CHANNEL_SELECTION

#define CLEAR_CHANNEL_SELECTION   1000

◆ EXTERNAL_VREF_VOLTAGE

#define EXTERNAL_VREF_VOLTAGE   2.5

◆ MAX_ADC_CODE

#define MAX_ADC_CODE   4095.0

◆ MDELAY_TO_DISPLAY_INSTRUCTION

#define MDELAY_TO_DISPLAY_INSTRUCTION   1000

◆ TEMP_SAMPLE_SIZE

#define TEMP_SAMPLE_SIZE   5

◆ TEMPERATURE_READBACK_CHANNEL

#define TEMPERATURE_READBACK_CHANNEL   8

Function Documentation

◆ ad5592r_app_initalization()

int32_t ad5592r_app_initalization ( void  )

Initialize AD5592/3R. ACTIVE_DEVICE defined in app_config.h.

The device initialization varies depending on what ACTIVE_DEVICE is defined. Device is reset and default register map values written. SPI or I2C initialization occurs.

Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

Variable Documentation

◆ ad5592r_main_menu

console_menu ad5592r_main_menu
Initial value:
= {
.title = "AD5592R Main Menu",
.items = main_menu_items,
.itemCount = ARRAY_SIZE(main_menu_items),
.headerItem = display_main_menu_header,
.footerItem = NULL,
.enableEscapeKey = NULL
}
console_menu_item main_menu_items[]
Definition: ad5592r_console_app.c:1057
#define ARRAY_SIZE(x)
Definition: adi_console_menu.h:49

◆ adc_menu

console_menu adc_menu
Initial value:
= {
.title = "ADC Configuration Settings",
.items = adc_menu_items,
.itemCount = ARRAY_SIZE(adc_menu_items),
.headerItem = display_adc_menu_header,
.footerItem = NULL,
.enableEscapeKey = true
}
console_menu_item adc_menu_items[]
Definition: ad5592r_console_app.c:915

◆ adc_menu_items

console_menu_item adc_menu_items[]
Initial value:
= {
{ "Select channels:" },
{ "Channel 0", 'A', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(0) },
{ "Channel 1", 'S', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(1) },
{ "Channel 2", 'D', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(2) },
{ "Channel 3", 'F', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(3) },
{ "Channel 4", 'G', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(4) },
{ "Channel 5", 'H', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(5) },
{ "Channel 6", 'J', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(6) },
{ "Channel 7", 'K', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(7) },
{ "", '\00', NULL, NULL},
{ "Toggle Channels in Sequence", 'Q', do_toggle_incl_in_seq },
{ "Read ADC Sequence", 'W', do_read_adc_sequence},
}
#define AD5592R_CHANNEL(N)
Definition: ad5592r_console_app.c:50

◆ config_channels_menu

console_menu config_channels_menu
Initial value:
= {
.title = "Configure IO Channels",
.headerItem = display_channel_selection_header,
.footerItem = NULL,
.enableEscapeKey = true
}
console_menu_item config_channels_menu_items[]
Definition: ad5592r_console_app.c:1018

◆ config_channels_menu_items

console_menu_item config_channels_menu_items[]
Initial value:
= {
{ "Select Channels:"},
{ "Channel 0", 'A', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(0) },
{ "Channel 1", 'S', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(1) },
{ "Channel 2", 'D', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(2) },
{ "Channel 3", 'F', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(3) },
{ "Channel 4", 'G', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(4) },
{ "Channel 5", 'H', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(5) },
{ "Channel 6", 'J', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(6) },
{ "Channel 7", 'K', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(7) },
{ "", '\00', NULL },
{ "DAC", 'Q', do_mode_selection, NULL, CH_MODE_DAC },
{ "ADC", 'W', do_mode_selection, NULL, CH_MODE_ADC },
{ "ADC + DAC", 'E', do_mode_selection, NULL, CH_MODE_DAC_AND_ADC },
{ "GPI", 'R', do_mode_selection, NULL, CH_MODE_GPI },
{ "GPO", 'T', do_mode_selection, NULL, CH_MODE_GPO },
{ "Unused", 'Y', do_mode_selection, NULL, CH_MODE_UNUSED },
{ "Restore Default Modes", 'U', do_reset_channel_modes, NULL },
{ "", '\00', NULL },
{ "Pulldown", 'Z', do_offstate_selection, NULL, CH_OFFSTATE_PULLDOWN },
{ "Output Low", 'X', do_offstate_selection, NULL, CH_OFFSTATE_OUT_LOW },
{ "Output High", 'C', do_offstate_selection, NULL, CH_OFFSTATE_OUT_HIGH },
{ "Tristate", 'V', do_offstate_selection, NULL, CH_OFFSTATE_OUT_TRISTATE },
{ "", '\00', NULL },
{ "Channel 7 as ADC conversion indicator (AD5592R)", 'M', do_channel_7_adc_indicator, NULL },
}

◆ dac_menu

console_menu dac_menu
Initial value:
= {
.title = "DAC Menu",
.items = dac_menu_items,
.itemCount = ARRAY_SIZE(dac_menu_items),
.headerItem = display_dac_menu_header,
.footerItem = NULL,
.enableEscapeKey = true
}
console_menu_item dac_menu_items[]
Definition: ad5592r_console_app.c:942

◆ dac_menu_items

console_menu_item dac_menu_items[]
Initial value:
= {
{ "Select Channels:"},
{ "Channel 0", 'A', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(0) },
{ "Channel 1", 'S', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(1) },
{ "Channel 2", 'D', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(2) },
{ "Channel 3", 'F', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(3) },
{ "Channel 4", 'G', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(4) },
{ "Channel 5", 'H', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(5) },
{ "Channel 6", 'J', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(6) },
{ "Channel 7", 'K', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(7) },
{ "", '\00', NULL },
{ "Write voltage to selected DAC channels", 'Q', do_write_dac_value, NULL, 0},
{ "Toggle Power Down selected DAC channels", 'W', do_toggle_dac_powerdown, NULL, 0},
{ "Write Input Reg to DAC output", 'E', do_dac_input_reg_to_output, NULL, 0},
{ "Toggle LDAC mode", 'R', do_toggle_ldac_mode, NULL, 0},
}

◆ general_settings_menu

console_menu general_settings_menu
Initial value:
= {
.title = "General Configuration Settings",
.headerItem = display_general_setting_header,
.footerItem = NULL,
.enableEscapeKey = true
}
console_menu_item general_settings_menu_items[]
Definition: ad5592r_console_app.c:971

◆ general_settings_menu_items

console_menu_item general_settings_menu_items[]

◆ gpio_menu

console_menu gpio_menu
Initial value:
= {
.title = "GPIO Menu" EOL,
.items = gpio_menu_items,
.itemCount = ARRAY_SIZE(gpio_menu_items),
.headerItem = display_gpio_menu_header,
.footerItem = NULL,
.enableEscapeKey = true
}
console_menu_item gpio_menu_items[]
Definition: ad5592r_console_app.c:887
#define EOL
Definition: app_config.h:47

◆ gpio_menu_items

console_menu_item gpio_menu_items[]
Initial value:
= {
{ "Select Channel", '\00', NULL, NULL },
{ "Channel 0", 'A', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(0) },
{ "Channel 1", 'S', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(1) },
{ "Channel 2", 'D', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(2) },
{ "Channel 3", 'F', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(3) },
{ "Channel 4", 'G', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(4) },
{ "Channel 5", 'H', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(5) },
{ "Channel 6", 'J', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(6) },
{ "Channel 7", 'K', do_toggle_channel_selection, NULL, AD5592R_CHANNEL(7) },
{ "", '\00', NULL, NULL },
{ "Set as GPIO Input", 'Z', do_set_gpio_input, NULL, 0},
{ "Set as GPIO Output", 'X', do_set_gpio_output, NULL, 0},
{ "Toggle Output Value", 'C', do_toggle_gpio_output, NULL, 0},
}

◆ main_menu_items

console_menu_item main_menu_items[]
Initial value:
= {
{ "Software Reset", 'Q', do_software_reset, NULL },
{ "Read ADC die temp", 'W', do_read_die_temp, NULL },
{ "", '\00', NULL },
{ "Configure Channels", 'A', menu_config_channels, NULL },
{ "General Settings", 'S', menu_general_settings, NULL },
{ "DAC Menu", 'D', menu_dac, NULL },
{ "ADC Menu", 'F', menu_adc, NULL },
{ "GPIO Menu", 'G', menu_gpio, NULL },
}

◆ power_down_pin_select_menu

console_menu power_down_pin_select_menu
extern

◆ vref_voltage

float vref_voltage = EXTERNAL_VREF_VOLTAGE