This is an forked repository to push changes related to no-OS repository adoption

Dependencies:   adi_console_menu platform_drivers

Committer:
EndaKilgarriff
Date:
Mon Jun 15 14:34:32 2020 +0000
Revision:
1:e84d8d51cd51
Child:
4:242c10fbdbb8
Initial Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
EndaKilgarriff 1:e84d8d51cd51 1 /*!
EndaKilgarriff 1:e84d8d51cd51 2 *****************************************************************************
EndaKilgarriff 1:e84d8d51cd51 3 * @file ad5592r_console_app.c
EndaKilgarriff 1:e84d8d51cd51 4 * @brief AD5592R console application interfaces
EndaKilgarriff 1:e84d8d51cd51 5 * @details This file is specific to ad5592r and ad5593r console menu application handle.
EndaKilgarriff 1:e84d8d51cd51 6 * The functions defined in this file performs the action
EndaKilgarriff 1:e84d8d51cd51 7 * based on user selected console menu.
EndaKilgarriff 1:e84d8d51cd51 8 *
EndaKilgarriff 1:e84d8d51cd51 9 -----------------------------------------------------------------------------
EndaKilgarriff 1:e84d8d51cd51 10 Copyright (c) 2020 Analog Devices, Inc.
EndaKilgarriff 1:e84d8d51cd51 11 All rights reserved.
EndaKilgarriff 1:e84d8d51cd51 12
EndaKilgarriff 1:e84d8d51cd51 13 This software is proprietary to Analog Devices, Inc. and its licensors.
EndaKilgarriff 1:e84d8d51cd51 14 By using this software you agree to the terms of the associated
EndaKilgarriff 1:e84d8d51cd51 15 Analog Devices Software License Agreement.
EndaKilgarriff 1:e84d8d51cd51 16 *****************************************************************************/
EndaKilgarriff 1:e84d8d51cd51 17
EndaKilgarriff 1:e84d8d51cd51 18 /******************************************************************************/
EndaKilgarriff 1:e84d8d51cd51 19 /***************************** Include Files **********************************/
EndaKilgarriff 1:e84d8d51cd51 20 /******************************************************************************/
EndaKilgarriff 1:e84d8d51cd51 21 #include <stdio.h>
EndaKilgarriff 1:e84d8d51cd51 22 #include <string.h>
EndaKilgarriff 1:e84d8d51cd51 23 #include <stdbool.h>
EndaKilgarriff 1:e84d8d51cd51 24
EndaKilgarriff 1:e84d8d51cd51 25 #include "app_config.h"
EndaKilgarriff 1:e84d8d51cd51 26 #include "ad5592r_configs.h"
EndaKilgarriff 1:e84d8d51cd51 27
EndaKilgarriff 1:e84d8d51cd51 28 #include "platform_support.h"
EndaKilgarriff 1:e84d8d51cd51 29 #include "platform_drivers.h"
EndaKilgarriff 1:e84d8d51cd51 30 #include "spi_extra.h"
EndaKilgarriff 1:e84d8d51cd51 31 #include "i2c_extra.h"
EndaKilgarriff 1:e84d8d51cd51 32
EndaKilgarriff 1:e84d8d51cd51 33 #include "ad5592r-base.h"
EndaKilgarriff 1:e84d8d51cd51 34 #include "ad5592r.h"
EndaKilgarriff 1:e84d8d51cd51 35 #include "ad5593r.h"
EndaKilgarriff 1:e84d8d51cd51 36
EndaKilgarriff 1:e84d8d51cd51 37 #include "ad5592r_console_app.h"
EndaKilgarriff 1:e84d8d51cd51 38
EndaKilgarriff 1:e84d8d51cd51 39 /******************************************************************************/
EndaKilgarriff 1:e84d8d51cd51 40 /************************* Macros & Constant Definitions **********************/
EndaKilgarriff 1:e84d8d51cd51 41 /******************************************************************************/
EndaKilgarriff 1:e84d8d51cd51 42 // vref_voltage can be defined as EXTERNAL_VREF_VOLTAGE or INTERNAL_VREF_VOLTAGE
EndaKilgarriff 1:e84d8d51cd51 43 // Change EXTERNAL_VREF_VOLTAGE if using supply other than 2.5V
EndaKilgarriff 1:e84d8d51cd51 44 #define EXTERNAL_VREF_VOLTAGE 2.5
EndaKilgarriff 1:e84d8d51cd51 45 float vref_voltage = EXTERNAL_VREF_VOLTAGE;
EndaKilgarriff 1:e84d8d51cd51 46
EndaKilgarriff 1:e84d8d51cd51 47 #define AD5592R_CHANNEL(N) (N)
EndaKilgarriff 1:e84d8d51cd51 48 #define AD5592R_REG_ADC_SEQ_INCL(x) BIT(x)
EndaKilgarriff 1:e84d8d51cd51 49 #define AD5592R_REG_PD_CHANNEL(x) BIT(x)
EndaKilgarriff 1:e84d8d51cd51 50 #define AD5592R_GPIO(x) BIT(x)
EndaKilgarriff 1:e84d8d51cd51 51
EndaKilgarriff 1:e84d8d51cd51 52 #define TEMP_SAMPLE_SIZE 5
EndaKilgarriff 1:e84d8d51cd51 53 #define CLEAR_CHANNEL_SELECTION 1000
EndaKilgarriff 1:e84d8d51cd51 54 #define MDELAY_TO_DISPLAY_INSTRUCTION 1000
EndaKilgarriff 1:e84d8d51cd51 55 #define TEMPERATURE_READBACK_CHANNEL 8
EndaKilgarriff 1:e84d8d51cd51 56
EndaKilgarriff 1:e84d8d51cd51 57 #define MAX_ADC_CODE 4095.0
EndaKilgarriff 1:e84d8d51cd51 58 #define ADC_GAIN_LOW_CONVERSION_VALUE 2.654
EndaKilgarriff 1:e84d8d51cd51 59 #define ADC_GAIN_HIGH_CONVERSION_VALUE 1.327
EndaKilgarriff 1:e84d8d51cd51 60
EndaKilgarriff 1:e84d8d51cd51 61 /* Private Variables */
EndaKilgarriff 1:e84d8d51cd51 62 static struct ad5592r_dev sAd5592r_dev;
EndaKilgarriff 1:e84d8d51cd51 63
EndaKilgarriff 1:e84d8d51cd51 64 static const char *mode_names[] = {
EndaKilgarriff 1:e84d8d51cd51 65 "Unused",
EndaKilgarriff 1:e84d8d51cd51 66 "ADC\t",
EndaKilgarriff 1:e84d8d51cd51 67 "DAC\t",
EndaKilgarriff 1:e84d8d51cd51 68 "ADC+DAC",
EndaKilgarriff 1:e84d8d51cd51 69 "GPI\t",
EndaKilgarriff 1:e84d8d51cd51 70 "GPO\t",
EndaKilgarriff 1:e84d8d51cd51 71 };
EndaKilgarriff 1:e84d8d51cd51 72 static const char *offstate_names[] = {
EndaKilgarriff 1:e84d8d51cd51 73 "Pulldown",
EndaKilgarriff 1:e84d8d51cd51 74 "Low\t",
EndaKilgarriff 1:e84d8d51cd51 75 "High\t",
EndaKilgarriff 1:e84d8d51cd51 76 "Tristate"
EndaKilgarriff 1:e84d8d51cd51 77 };
EndaKilgarriff 1:e84d8d51cd51 78 static bool active_channel_selections[NUM_CHANNELS] = {
EndaKilgarriff 1:e84d8d51cd51 79 false,
EndaKilgarriff 1:e84d8d51cd51 80 false,
EndaKilgarriff 1:e84d8d51cd51 81 false,
EndaKilgarriff 1:e84d8d51cd51 82 false,
EndaKilgarriff 1:e84d8d51cd51 83 false,
EndaKilgarriff 1:e84d8d51cd51 84 false,
EndaKilgarriff 1:e84d8d51cd51 85 false,
EndaKilgarriff 1:e84d8d51cd51 86 false
EndaKilgarriff 1:e84d8d51cd51 87 };
EndaKilgarriff 1:e84d8d51cd51 88
EndaKilgarriff 1:e84d8d51cd51 89 static uint16_t adc_channels_in_seq = AD5592R_REG_ADC_SEQ_TEMP_READBACK;
EndaKilgarriff 1:e84d8d51cd51 90
EndaKilgarriff 1:e84d8d51cd51 91 /******************************************************************************/
EndaKilgarriff 1:e84d8d51cd51 92 /***************************** Function Declarations **************************/
EndaKilgarriff 1:e84d8d51cd51 93 /******************************************************************************/
EndaKilgarriff 1:e84d8d51cd51 94 static int32_t do_software_reset(uint32_t id);
EndaKilgarriff 1:e84d8d51cd51 95 static int32_t do_read_die_temp(uint32_t id);
EndaKilgarriff 1:e84d8d51cd51 96 static float die_temp_calculation(uint16_t adc_temp_code, bool adc_gain);
EndaKilgarriff 1:e84d8d51cd51 97 static void do_set_channel_modes(void);
EndaKilgarriff 1:e84d8d51cd51 98 static int32_t do_toggle_channel_selection(uint32_t channel);
EndaKilgarriff 1:e84d8d51cd51 99 static int32_t do_mode_selection(uint32_t mode);
EndaKilgarriff 1:e84d8d51cd51 100 static int32_t do_reset_channel_modes(uint32_t id);
EndaKilgarriff 1:e84d8d51cd51 101 static int32_t do_offstate_selection(uint32_t mode);
EndaKilgarriff 1:e84d8d51cd51 102 static int32_t do_channel_7_adc_indicator(uint32_t id);
EndaKilgarriff 1:e84d8d51cd51 103 static int32_t do_general_settings_toggle(uint32_t reg_bit_id);
EndaKilgarriff 1:e84d8d51cd51 104 static int32_t do_write_dac_value(uint32_t id);
EndaKilgarriff 1:e84d8d51cd51 105 static int32_t do_dac_input_reg_to_output(uint32_t id);
EndaKilgarriff 1:e84d8d51cd51 106 static int32_t do_toggle_ldac_mode(uint32_t id);
EndaKilgarriff 1:e84d8d51cd51 107 static int32_t do_toggle_dac_powerdown(uint32_t id);
EndaKilgarriff 1:e84d8d51cd51 108 static int32_t do_toggle_incl_in_seq(uint32_t id);
EndaKilgarriff 1:e84d8d51cd51 109 static int32_t do_read_adc_sequence(uint32_t id);
EndaKilgarriff 1:e84d8d51cd51 110
EndaKilgarriff 1:e84d8d51cd51 111 extern console_menu power_down_pin_select_menu;
EndaKilgarriff 1:e84d8d51cd51 112 extern console_menu config_channels_menu;
EndaKilgarriff 1:e84d8d51cd51 113 extern console_menu general_settings_menu;
EndaKilgarriff 1:e84d8d51cd51 114 extern console_menu dac_menu;
EndaKilgarriff 1:e84d8d51cd51 115 extern console_menu gpio_menu;
EndaKilgarriff 1:e84d8d51cd51 116 extern console_menu adc_menu;
EndaKilgarriff 1:e84d8d51cd51 117
EndaKilgarriff 1:e84d8d51cd51 118 /******************************************************************************/
EndaKilgarriff 1:e84d8d51cd51 119 /***************************** Function Definitions ***************************/
EndaKilgarriff 1:e84d8d51cd51 120 /******************************************************************************/
EndaKilgarriff 1:e84d8d51cd51 121
EndaKilgarriff 1:e84d8d51cd51 122 /*!
EndaKilgarriff 1:e84d8d51cd51 123 * @brief Initialize AD5592/3R. ACTIVE_DEVICE defined in app_config.h
EndaKilgarriff 1:e84d8d51cd51 124 *@details The device initialization varies depending on what ACTIVE_DEVICE is defined.
EndaKilgarriff 1:e84d8d51cd51 125 * Device is reset and default register map values written.
EndaKilgarriff 1:e84d8d51cd51 126 * SPI or I2C initialization occurs.
EndaKilgarriff 1:e84d8d51cd51 127 * @return SUCCESS (0), FAILURE (negative)
EndaKilgarriff 1:e84d8d51cd51 128 */
EndaKilgarriff 1:e84d8d51cd51 129 int32_t ad5592r_app_initalization(void)
EndaKilgarriff 1:e84d8d51cd51 130 {
EndaKilgarriff 1:e84d8d51cd51 131 memcpy(&sAd5592r_dev, &ad5592r_dev_user, sizeof(ad5592r_dev_user));
EndaKilgarriff 1:e84d8d51cd51 132 int32_t status;
EndaKilgarriff 1:e84d8d51cd51 133 if (ACTIVE_DEVICE == ID_AD5593R) {
EndaKilgarriff 1:e84d8d51cd51 134 sAd5592r_dev.i2c = &i2c_user_descr;
EndaKilgarriff 1:e84d8d51cd51 135 i2c_init(&sAd5592r_dev.i2c, &i2c_user_params);
EndaKilgarriff 1:e84d8d51cd51 136 status = ad5593r_init(&sAd5592r_dev, &ad5592r_user_param);
EndaKilgarriff 1:e84d8d51cd51 137 } else {
EndaKilgarriff 1:e84d8d51cd51 138 sAd5592r_dev.spi = &spi_user_descr;
EndaKilgarriff 1:e84d8d51cd51 139 spi_init(&sAd5592r_dev.spi, &spi_user_params);
EndaKilgarriff 1:e84d8d51cd51 140 status = ad5592r_init(&sAd5592r_dev, &ad5592r_user_param);
EndaKilgarriff 1:e84d8d51cd51 141 }
EndaKilgarriff 1:e84d8d51cd51 142 return status;
EndaKilgarriff 1:e84d8d51cd51 143 }
EndaKilgarriff 1:e84d8d51cd51 144
EndaKilgarriff 1:e84d8d51cd51 145 /*!
EndaKilgarriff 1:e84d8d51cd51 146 * @brief Performs software reset
EndaKilgarriff 1:e84d8d51cd51 147 * @details Writes to the reset register. Resets sAd5592r_dev configuration using
EndaKilgarriff 1:e84d8d51cd51 148 * configuration from ad5592r_reset_config.c SPI, I2C and ops are stored
EndaKilgarriff 1:e84d8d51cd51 149 * and restored after the reset.
EndaKilgarriff 1:e84d8d51cd51 150 * @return MENU_CONTINUE
EndaKilgarriff 1:e84d8d51cd51 151 */
EndaKilgarriff 1:e84d8d51cd51 152 static int32_t do_software_reset(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 153 {
EndaKilgarriff 1:e84d8d51cd51 154 int32_t status;
EndaKilgarriff 1:e84d8d51cd51 155
EndaKilgarriff 1:e84d8d51cd51 156 if ((status = ad5592r_software_reset(&sAd5592r_dev)) == SUCCESS) {
EndaKilgarriff 1:e84d8d51cd51 157 // Save spi_desc field, i2c_desc and device ops settings as it is not reset
EndaKilgarriff 1:e84d8d51cd51 158 spi_desc *spi_interface = sAd5592r_dev.spi;
EndaKilgarriff 1:e84d8d51cd51 159 i2c_desc *i2c_interface = sAd5592r_dev.i2c;
EndaKilgarriff 1:e84d8d51cd51 160 const struct ad5592r_rw_ops *dev_ops = sAd5592r_dev.ops;
EndaKilgarriff 1:e84d8d51cd51 161 // Copy over the reset state of the device
EndaKilgarriff 1:e84d8d51cd51 162 memcpy(&sAd5592r_dev, &ad5592r_dev_reset, sizeof(ad5592r_dev_reset));
EndaKilgarriff 1:e84d8d51cd51 163
EndaKilgarriff 1:e84d8d51cd51 164 // Restore device ops
EndaKilgarriff 1:e84d8d51cd51 165 sAd5592r_dev.ops = dev_ops;
EndaKilgarriff 1:e84d8d51cd51 166 if (ACTIVE_DEVICE == ID_AD5592R) {
EndaKilgarriff 1:e84d8d51cd51 167 // Restore the spi_desc pointer field
EndaKilgarriff 1:e84d8d51cd51 168 sAd5592r_dev.spi = spi_interface;
EndaKilgarriff 1:e84d8d51cd51 169 printf(EOL " --- AD5592R Software Reset Successful---" EOL);
EndaKilgarriff 1:e84d8d51cd51 170 } else {
EndaKilgarriff 1:e84d8d51cd51 171 // Restore the i2c_desc pointer field
EndaKilgarriff 1:e84d8d51cd51 172 sAd5592r_dev.i2c = i2c_interface;
EndaKilgarriff 1:e84d8d51cd51 173 printf(EOL " --- AD5593R Reset Request Successful---" EOL);
EndaKilgarriff 1:e84d8d51cd51 174 }
EndaKilgarriff 1:e84d8d51cd51 175 } else {
EndaKilgarriff 1:e84d8d51cd51 176 printf(EOL " *** Software Reset Failure: %d ***" EOL, status);
EndaKilgarriff 1:e84d8d51cd51 177 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 178 }
EndaKilgarriff 1:e84d8d51cd51 179
EndaKilgarriff 1:e84d8d51cd51 180 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 181 return (MENU_CONTINUE);
EndaKilgarriff 1:e84d8d51cd51 182 }
EndaKilgarriff 1:e84d8d51cd51 183
EndaKilgarriff 1:e84d8d51cd51 184 /*!
EndaKilgarriff 1:e84d8d51cd51 185 * @brief Prints the temperature of the die
EndaKilgarriff 1:e84d8d51cd51 186 * @details Sets the devices to perform a temperature readback.
EndaKilgarriff 1:e84d8d51cd51 187 * Performs a number of samples based on TEMP_SAMPLE_SIZE
EndaKilgarriff 1:e84d8d51cd51 188 * @return MENU_CONTINUE
EndaKilgarriff 1:e84d8d51cd51 189 */
EndaKilgarriff 1:e84d8d51cd51 190 static int32_t do_read_die_temp(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 191 {
EndaKilgarriff 1:e84d8d51cd51 192 uint16_t readback_reg[1] = { 0 };
EndaKilgarriff 1:e84d8d51cd51 193 int32_t status = 0, ch_state = 0;
EndaKilgarriff 1:e84d8d51cd51 194 float result = 0;
EndaKilgarriff 1:e84d8d51cd51 195
EndaKilgarriff 1:e84d8d51cd51 196 ch_state = sAd5592r_dev.channel_modes[7];
EndaKilgarriff 1:e84d8d51cd51 197 sAd5592r_dev.channel_modes[7] = CH_MODE_ADC;
EndaKilgarriff 1:e84d8d51cd51 198 do_set_channel_modes();
EndaKilgarriff 1:e84d8d51cd51 199
EndaKilgarriff 1:e84d8d51cd51 200 do {
EndaKilgarriff 1:e84d8d51cd51 201
EndaKilgarriff 1:e84d8d51cd51 202 for (int8_t i = 0; i < TEMP_SAMPLE_SIZE; i++) {
EndaKilgarriff 1:e84d8d51cd51 203 do {
EndaKilgarriff 1:e84d8d51cd51 204 status = sAd5592r_dev.ops->read_adc(&sAd5592r_dev,
EndaKilgarriff 1:e84d8d51cd51 205 AD5592R_CHANNEL(8),
EndaKilgarriff 1:e84d8d51cd51 206 readback_reg);
EndaKilgarriff 1:e84d8d51cd51 207 } while (0);
EndaKilgarriff 1:e84d8d51cd51 208 if (status != SUCCESS) {
EndaKilgarriff 1:e84d8d51cd51 209 // Break out of for loop if not successful
EndaKilgarriff 1:e84d8d51cd51 210 break;
EndaKilgarriff 1:e84d8d51cd51 211 }
EndaKilgarriff 1:e84d8d51cd51 212 result += die_temp_calculation(readback_reg[0],
EndaKilgarriff 1:e84d8d51cd51 213 (AD5592R_REG_CTRL_ADC_RANGE & sAd5592r_dev.cached_gp_ctrl));
EndaKilgarriff 1:e84d8d51cd51 214 }
EndaKilgarriff 1:e84d8d51cd51 215
EndaKilgarriff 1:e84d8d51cd51 216 result /= TEMP_SAMPLE_SIZE;
EndaKilgarriff 1:e84d8d51cd51 217
EndaKilgarriff 1:e84d8d51cd51 218 if (status == SUCCESS) {
EndaKilgarriff 1:e84d8d51cd51 219 // Print average of samples
EndaKilgarriff 1:e84d8d51cd51 220 printf(EOL " --- Temperature: %.1f*C --- " EOL, result);
EndaKilgarriff 1:e84d8d51cd51 221 } else {
EndaKilgarriff 1:e84d8d51cd51 222 printf(EOL " *** Error reading die temperature: %d **" EOL, status);
EndaKilgarriff 1:e84d8d51cd51 223 break;
EndaKilgarriff 1:e84d8d51cd51 224 }
EndaKilgarriff 1:e84d8d51cd51 225 } while (0);
EndaKilgarriff 1:e84d8d51cd51 226
EndaKilgarriff 1:e84d8d51cd51 227 sAd5592r_dev.channel_modes[7] = ch_state;
EndaKilgarriff 1:e84d8d51cd51 228 do_set_channel_modes();
EndaKilgarriff 1:e84d8d51cd51 229
EndaKilgarriff 1:e84d8d51cd51 230 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 231 return (MENU_CONTINUE);
EndaKilgarriff 1:e84d8d51cd51 232 }
EndaKilgarriff 1:e84d8d51cd51 233
EndaKilgarriff 1:e84d8d51cd51 234 /*!
EndaKilgarriff 1:e84d8d51cd51 235 * @brief Calculates the die temperature
EndaKilgarriff 1:e84d8d51cd51 236 * @details Based on conversion equation, die temperature is estimated
EndaKilgarriff 1:e84d8d51cd51 237 * @param adc_temp_code - data read from ADC readback frame
EndaKilgarriff 1:e84d8d51cd51 238 * adc_gain - status of adc_gain
EndaKilgarriff 1:e84d8d51cd51 239 * @return result
EndaKilgarriff 1:e84d8d51cd51 240 */
EndaKilgarriff 1:e84d8d51cd51 241 static float die_temp_calculation(uint16_t adc_temp_code, bool adc_gain)
EndaKilgarriff 1:e84d8d51cd51 242 {
EndaKilgarriff 1:e84d8d51cd51 243 float result = 0;
EndaKilgarriff 1:e84d8d51cd51 244
EndaKilgarriff 1:e84d8d51cd51 245 // use different equation depending on gain
EndaKilgarriff 1:e84d8d51cd51 246 if(adc_gain) {
EndaKilgarriff 1:e84d8d51cd51 247 result = 25 + ((AD5592R_REG_ADC_SEQ_CODE_MSK(adc_temp_code) -
EndaKilgarriff 1:e84d8d51cd51 248 ((0.5 / (2 * vref_voltage)) * MAX_ADC_CODE)) /
EndaKilgarriff 1:e84d8d51cd51 249 (ADC_GAIN_HIGH_CONVERSION_VALUE * (2.5 / vref_voltage)));
EndaKilgarriff 1:e84d8d51cd51 250 } else {
EndaKilgarriff 1:e84d8d51cd51 251 result = 25 + ((AD5592R_REG_ADC_SEQ_CODE_MSK(adc_temp_code) -
EndaKilgarriff 1:e84d8d51cd51 252 ((0.5 / vref_voltage) * MAX_ADC_CODE)) /
EndaKilgarriff 1:e84d8d51cd51 253 (ADC_GAIN_LOW_CONVERSION_VALUE * (2.5 / vref_voltage)));
EndaKilgarriff 1:e84d8d51cd51 254 }
EndaKilgarriff 1:e84d8d51cd51 255 return result;
EndaKilgarriff 1:e84d8d51cd51 256 }
EndaKilgarriff 1:e84d8d51cd51 257
EndaKilgarriff 1:e84d8d51cd51 258 /*!
EndaKilgarriff 1:e84d8d51cd51 259 * @brief Set channel modes
EndaKilgarriff 1:e84d8d51cd51 260 *
EndaKilgarriff 1:e84d8d51cd51 261 *@details The channels modes are set by passing the altered device
EndaKilgarriff 1:e84d8d51cd51 262 * struct into the ad5592r_set_channel_modes function. There the channels are
EndaKilgarriff 1:e84d8d51cd51 263 * set to desired modes.
EndaKilgarriff 1:e84d8d51cd51 264 */
EndaKilgarriff 1:e84d8d51cd51 265 static void do_set_channel_modes(void)
EndaKilgarriff 1:e84d8d51cd51 266 {
EndaKilgarriff 1:e84d8d51cd51 267 int32_t status;
EndaKilgarriff 1:e84d8d51cd51 268 if ((status = ad5592r_set_channel_modes(&sAd5592r_dev)) != SUCCESS) {
EndaKilgarriff 1:e84d8d51cd51 269 printf(EOL "Error configuring Channels (%d)" EOL, status);
EndaKilgarriff 1:e84d8d51cd51 270 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 271 }
EndaKilgarriff 1:e84d8d51cd51 272 }
EndaKilgarriff 1:e84d8d51cd51 273
EndaKilgarriff 1:e84d8d51cd51 274 /*!
EndaKilgarriff 1:e84d8d51cd51 275 * @brief Toggle channels currently selected
EndaKilgarriff 1:e84d8d51cd51 276 * @details The channels the user has currently selected are set here.
EndaKilgarriff 1:e84d8d51cd51 277 * These are the channels that will be altered by mode or offstate selection
EndaKilgarriff 1:e84d8d51cd51 278 * @param channel - A channel that the user wants to add to the currently selected channels
EndaKilgarriff 1:e84d8d51cd51 279 * @return (MENU_CONTINUE)
EndaKilgarriff 1:e84d8d51cd51 280 */
EndaKilgarriff 1:e84d8d51cd51 281 static int32_t do_toggle_channel_selection(uint32_t channel)
EndaKilgarriff 1:e84d8d51cd51 282 {
EndaKilgarriff 1:e84d8d51cd51 283 if (channel == CLEAR_CHANNEL_SELECTION) {
EndaKilgarriff 1:e84d8d51cd51 284 for (uint8_t i = 0; i < sAd5592r_dev.num_channels; i++) {
EndaKilgarriff 1:e84d8d51cd51 285
EndaKilgarriff 1:e84d8d51cd51 286 active_channel_selections[i] = false;
EndaKilgarriff 1:e84d8d51cd51 287 }
EndaKilgarriff 1:e84d8d51cd51 288 } else {
EndaKilgarriff 1:e84d8d51cd51 289 active_channel_selections[channel] = !active_channel_selections[channel];
EndaKilgarriff 1:e84d8d51cd51 290 }
EndaKilgarriff 1:e84d8d51cd51 291
EndaKilgarriff 1:e84d8d51cd51 292 return (MENU_CONTINUE);
EndaKilgarriff 1:e84d8d51cd51 293 }
EndaKilgarriff 1:e84d8d51cd51 294
EndaKilgarriff 1:e84d8d51cd51 295 /*!
EndaKilgarriff 1:e84d8d51cd51 296 * @brief Mode selection
EndaKilgarriff 1:e84d8d51cd51 297 * @details The mode the users wishes to apply to the currently selected channels
EndaKilgarriff 1:e84d8d51cd51 298 * are selected here. do_set_channel_modes is called which sets the channels
EndaKilgarriff 1:e84d8d51cd51 299 * on the device.
EndaKilgarriff 1:e84d8d51cd51 300 * @param mode -The mode that the user wishes to apply to the selected channels
EndaKilgarriff 1:e84d8d51cd51 301 * @return (MENU_CONTINUE)
EndaKilgarriff 1:e84d8d51cd51 302 */
EndaKilgarriff 1:e84d8d51cd51 303 static int32_t do_mode_selection(uint32_t mode)
EndaKilgarriff 1:e84d8d51cd51 304 {
EndaKilgarriff 1:e84d8d51cd51 305 for (uint8_t i = 0; i < sAd5592r_dev.num_channels; i++) {
EndaKilgarriff 1:e84d8d51cd51 306 if (active_channel_selections[i] == true) {
EndaKilgarriff 1:e84d8d51cd51 307 sAd5592r_dev.channel_modes[i] = mode;
EndaKilgarriff 1:e84d8d51cd51 308 }
EndaKilgarriff 1:e84d8d51cd51 309 }
EndaKilgarriff 1:e84d8d51cd51 310 do_set_channel_modes();
EndaKilgarriff 1:e84d8d51cd51 311 do_toggle_channel_selection(CLEAR_CHANNEL_SELECTION);
EndaKilgarriff 1:e84d8d51cd51 312 return (MENU_CONTINUE);
EndaKilgarriff 1:e84d8d51cd51 313 }
EndaKilgarriff 1:e84d8d51cd51 314
EndaKilgarriff 1:e84d8d51cd51 315 /*!
EndaKilgarriff 1:e84d8d51cd51 316 * @brief Offstate selection
EndaKilgarriff 1:e84d8d51cd51 317 * @details The offstate the users wishes to apply to the currently selected channels
EndaKilgarriff 1:e84d8d51cd51 318 * are selected here. do_set_channel_modes is called which sets the channels
EndaKilgarriff 1:e84d8d51cd51 319 * on the device.
EndaKilgarriff 1:e84d8d51cd51 320 * @param The offstate that the user wishes to apply to the selected channels
EndaKilgarriff 1:e84d8d51cd51 321 * @return (MENU_CONTINUE)
EndaKilgarriff 1:e84d8d51cd51 322 */
EndaKilgarriff 1:e84d8d51cd51 323 static int32_t do_offstate_selection(uint32_t mode)
EndaKilgarriff 1:e84d8d51cd51 324 {
EndaKilgarriff 1:e84d8d51cd51 325 for (uint8_t i = 0; i < sAd5592r_dev.num_channels; i++) {
EndaKilgarriff 1:e84d8d51cd51 326 if (active_channel_selections[i] == true) {
EndaKilgarriff 1:e84d8d51cd51 327 sAd5592r_dev.channel_offstate[i] = mode;
EndaKilgarriff 1:e84d8d51cd51 328 }
EndaKilgarriff 1:e84d8d51cd51 329 }
EndaKilgarriff 1:e84d8d51cd51 330 do_set_channel_modes();
EndaKilgarriff 1:e84d8d51cd51 331 do_toggle_channel_selection(CLEAR_CHANNEL_SELECTION);
EndaKilgarriff 1:e84d8d51cd51 332 return (MENU_CONTINUE);
EndaKilgarriff 1:e84d8d51cd51 333 }
EndaKilgarriff 1:e84d8d51cd51 334
EndaKilgarriff 1:e84d8d51cd51 335 /*!
EndaKilgarriff 1:e84d8d51cd51 336 * @brief Reset Channel Modes
EndaKilgarriff 1:e84d8d51cd51 337 * @details This resets all channel modes to unused.
EndaKilgarriff 1:e84d8d51cd51 338 * @return (MENU_CONTINUE)
EndaKilgarriff 1:e84d8d51cd51 339 *
EndaKilgarriff 1:e84d8d51cd51 340 */
EndaKilgarriff 1:e84d8d51cd51 341 static int32_t do_reset_channel_modes(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 342 {
EndaKilgarriff 1:e84d8d51cd51 343 ad5592r_reset_channel_modes(&sAd5592r_dev);
EndaKilgarriff 1:e84d8d51cd51 344 do_toggle_channel_selection(CLEAR_CHANNEL_SELECTION);
EndaKilgarriff 1:e84d8d51cd51 345 return (MENU_CONTINUE);
EndaKilgarriff 1:e84d8d51cd51 346 }
EndaKilgarriff 1:e84d8d51cd51 347
EndaKilgarriff 1:e84d8d51cd51 348 /*!
EndaKilgarriff 1:e84d8d51cd51 349 * @brief Sets Channel 7 as ADC conversion indicator
EndaKilgarriff 1:e84d8d51cd51 350 * @details Channel 7 is set as a GPIO and the NOT BUSY bit is set in the GPIO
EndaKilgarriff 1:e84d8d51cd51 351 * write configuration register enabling channel 7 to be used as an indicator
EndaKilgarriff 1:e84d8d51cd51 352 * when ADC conversion are occurring. Channel 7 will go LOW when a conversion
EndaKilgarriff 1:e84d8d51cd51 353 * is occurring.
EndaKilgarriff 1:e84d8d51cd51 354 * ***NOTE*** After selecting this Channel 7 will appear as GPO.
EndaKilgarriff 1:e84d8d51cd51 355 * ***NOTE*** Ensure this is the last channel to be configured in order to
EndaKilgarriff 1:e84d8d51cd51 356 * ensure preference will no be overwritten
EndaKilgarriff 1:e84d8d51cd51 357 * @return (MENU_CONTINUE)
EndaKilgarriff 1:e84d8d51cd51 358 */
EndaKilgarriff 1:e84d8d51cd51 359 static int32_t do_channel_7_adc_indicator(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 360 {
EndaKilgarriff 1:e84d8d51cd51 361 sAd5592r_dev.channel_modes[AD5592R_CHANNEL(7)] =
EndaKilgarriff 1:e84d8d51cd51 362 ((sAd5592r_dev.channel_modes[AD5592R_CHANNEL(7)] == CH_MODE_UNUSED)
EndaKilgarriff 1:e84d8d51cd51 363 ? CH_MODE_GPO : CH_MODE_UNUSED);
EndaKilgarriff 1:e84d8d51cd51 364 do_set_channel_modes();
EndaKilgarriff 1:e84d8d51cd51 365 do_general_settings_toggle(((AD5592R_REG_GPIO_OUT_EN << 12)
EndaKilgarriff 1:e84d8d51cd51 366 | AD5592R_REG_GPIO_OUT_EN_ADC_NOT_BUSY));
EndaKilgarriff 1:e84d8d51cd51 367 do_toggle_channel_selection(CLEAR_CHANNEL_SELECTION);
EndaKilgarriff 1:e84d8d51cd51 368 return (MENU_CONTINUE);
EndaKilgarriff 1:e84d8d51cd51 369 }
EndaKilgarriff 1:e84d8d51cd51 370
EndaKilgarriff 1:e84d8d51cd51 371 /*!
EndaKilgarriff 1:e84d8d51cd51 372 * @brief Toggle general setting
EndaKilgarriff 1:e84d8d51cd51 373 * @details Setting (reg_bit) in register (reg) is toggled
EndaKilgarriff 1:e84d8d51cd51 374 * @param reg_bit_id - Combined value containing register address and bit to toggle
EndaKilgarriff 1:e84d8d51cd51 375 * @return (MENU_CONTINUE)
EndaKilgarriff 1:e84d8d51cd51 376 */
EndaKilgarriff 1:e84d8d51cd51 377 static int32_t do_general_settings_toggle(uint32_t reg_bit_id)
EndaKilgarriff 1:e84d8d51cd51 378 {
EndaKilgarriff 1:e84d8d51cd51 379 uint8_t reg = (reg_bit_id >> 12);
EndaKilgarriff 1:e84d8d51cd51 380 uint16_t reg_bit = (reg_bit_id & 0xFFF), readback_reg;
EndaKilgarriff 1:e84d8d51cd51 381 int32_t status;
EndaKilgarriff 1:e84d8d51cd51 382
EndaKilgarriff 1:e84d8d51cd51 383 if ((status = ad5592r_base_reg_read(&sAd5592r_dev, reg,
EndaKilgarriff 1:e84d8d51cd51 384 &readback_reg)) != SUCCESS) {
EndaKilgarriff 1:e84d8d51cd51 385 printf(" *** Error Reading Setting Status (%x) *** " EOL, reg);
EndaKilgarriff 1:e84d8d51cd51 386 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 387 } else if ((status = ad5592r_base_reg_write(&sAd5592r_dev, reg,
EndaKilgarriff 1:e84d8d51cd51 388 (reg_bit ^ readback_reg))) != SUCCESS) {
EndaKilgarriff 1:e84d8d51cd51 389 printf(" *** Error Toggling Setting (%x) *** " EOL, reg);
EndaKilgarriff 1:e84d8d51cd51 390 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 391 }
EndaKilgarriff 1:e84d8d51cd51 392
EndaKilgarriff 1:e84d8d51cd51 393 if (reg == AD5592R_REG_PD && reg_bit == AD5592R_REG_PD_EN_REF) {
EndaKilgarriff 1:e84d8d51cd51 394 if ((AD5592R_REG_PD_EN_REF & (reg_bit ^ readback_reg))) {
EndaKilgarriff 1:e84d8d51cd51 395 vref_voltage = INTERNAL_VREF_VOLTAGE;
EndaKilgarriff 1:e84d8d51cd51 396 } else {
EndaKilgarriff 1:e84d8d51cd51 397 vref_voltage = EXTERNAL_VREF_VOLTAGE;
EndaKilgarriff 1:e84d8d51cd51 398 }
EndaKilgarriff 1:e84d8d51cd51 399 }
EndaKilgarriff 1:e84d8d51cd51 400 return (MENU_CONTINUE);
EndaKilgarriff 1:e84d8d51cd51 401 }
EndaKilgarriff 1:e84d8d51cd51 402
EndaKilgarriff 1:e84d8d51cd51 403 /*!
EndaKilgarriff 1:e84d8d51cd51 404 * @brief displays the general settings header
EndaKilgarriff 1:e84d8d51cd51 405 */
EndaKilgarriff 1:e84d8d51cd51 406 static void display_general_setting_header(void)
EndaKilgarriff 1:e84d8d51cd51 407 {
EndaKilgarriff 1:e84d8d51cd51 408
EndaKilgarriff 1:e84d8d51cd51 409 int32_t status = 0;
EndaKilgarriff 1:e84d8d51cd51 410 uint16_t ctrl_reg_data = 0, pd_reg_data = 0;
EndaKilgarriff 1:e84d8d51cd51 411
EndaKilgarriff 1:e84d8d51cd51 412 do {
EndaKilgarriff 1:e84d8d51cd51 413 if ((status = ad5592r_base_reg_read(&sAd5592r_dev, AD5592R_REG_CTRL,
EndaKilgarriff 1:e84d8d51cd51 414 &ctrl_reg_data)) == SUCCESS) {
EndaKilgarriff 1:e84d8d51cd51 415 sAd5592r_dev.cached_gp_ctrl = ctrl_reg_data;
EndaKilgarriff 1:e84d8d51cd51 416 } else {
EndaKilgarriff 1:e84d8d51cd51 417 printf(" *** Error reading register (%x) *** " EOL, AD5592R_REG_CTRL);
EndaKilgarriff 1:e84d8d51cd51 418 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 419 break;
EndaKilgarriff 1:e84d8d51cd51 420 }
EndaKilgarriff 1:e84d8d51cd51 421
EndaKilgarriff 1:e84d8d51cd51 422 if ((status = ad5592r_base_reg_read(&sAd5592r_dev, AD5592R_REG_PD,
EndaKilgarriff 1:e84d8d51cd51 423 &pd_reg_data)) == SUCCESS) {
EndaKilgarriff 1:e84d8d51cd51 424 } else {
EndaKilgarriff 1:e84d8d51cd51 425 printf(" *** Error reading register (%x) *** " EOL, AD5592R_REG_PD);
EndaKilgarriff 1:e84d8d51cd51 426 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 427 break;
EndaKilgarriff 1:e84d8d51cd51 428 }
EndaKilgarriff 1:e84d8d51cd51 429 } while(0);
EndaKilgarriff 1:e84d8d51cd51 430
EndaKilgarriff 1:e84d8d51cd51 431 printf("\tSetting \tEnabled\t\tSetting \tEnabled"EOL);
EndaKilgarriff 1:e84d8d51cd51 432 printf("\tEn Ref\t\t%s\t\tADC Gain\t%s"EOL,
EndaKilgarriff 1:e84d8d51cd51 433 (AD5592R_REG_PD_EN_REF & pd_reg_data)?"X":"\00",
EndaKilgarriff 1:e84d8d51cd51 434 (AD5592R_REG_CTRL_ADC_RANGE & ctrl_reg_data)?"X":"\00");
EndaKilgarriff 1:e84d8d51cd51 435 printf("\tPC Buff\t\t%s\t\tPD All\t\t%s"EOL,
EndaKilgarriff 1:e84d8d51cd51 436 (AD5592R_REG_CTRL_ADC_PC_BUFF & ctrl_reg_data)?"X":"\00",
EndaKilgarriff 1:e84d8d51cd51 437 (AD5592R_REG_PD_PD_ALL & pd_reg_data) ? "X" : "\00");
EndaKilgarriff 1:e84d8d51cd51 438 printf("\tBuff\t\t%s\t\tDAC Gain\t%s"EOL,
EndaKilgarriff 1:e84d8d51cd51 439 (AD5592R_REG_CTRL_ADC_BUFF_EN & ctrl_reg_data)?"X":"\00",
EndaKilgarriff 1:e84d8d51cd51 440 (AD5592R_REG_CTRL_DAC_RANGE & ctrl_reg_data)?"X":"\00");
EndaKilgarriff 1:e84d8d51cd51 441 printf("\tLock Config\t%s\t\tWr All\t\t%s"EOL,
EndaKilgarriff 1:e84d8d51cd51 442 (AD5592R_REG_CTRL_CONFIG_LOCK & ctrl_reg_data)?"X":"\00",
EndaKilgarriff 1:e84d8d51cd51 443 (AD5592R_REG_CTRL_W_ALL_DACS & ctrl_reg_data)?"X":"\00");
EndaKilgarriff 1:e84d8d51cd51 444
EndaKilgarriff 1:e84d8d51cd51 445 }
EndaKilgarriff 1:e84d8d51cd51 446
EndaKilgarriff 1:e84d8d51cd51 447 /*!
EndaKilgarriff 1:e84d8d51cd51 448 * @brief DAC input register to DAC output
EndaKilgarriff 1:e84d8d51cd51 449 * @details Writes the data from the DAC input register to the DAC output.
EndaKilgarriff 1:e84d8d51cd51 450 * The LDAC mode is returned to write data to the input register only.
EndaKilgarriff 1:e84d8d51cd51 451 * @return (MENU_CONTINUE)
EndaKilgarriff 1:e84d8d51cd51 452 */
EndaKilgarriff 1:e84d8d51cd51 453 static int32_t do_dac_input_reg_to_output(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 454 {
EndaKilgarriff 1:e84d8d51cd51 455 int32_t status;
EndaKilgarriff 1:e84d8d51cd51 456 if ((status = ad5592r_base_reg_write(&sAd5592r_dev, AD5592R_REG_LDAC,
EndaKilgarriff 1:e84d8d51cd51 457 AD5592R_REG_LDAC_INPUT_REG_OUT)) != SUCCESS) {
EndaKilgarriff 1:e84d8d51cd51 458 printf("*** Error setting LDAC to write to output (%d) *** ", status);
EndaKilgarriff 1:e84d8d51cd51 459 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 460 }
EndaKilgarriff 1:e84d8d51cd51 461 sAd5592r_dev.ldac_mode = AD5592R_REG_LDAC_INPUT_REG_ONLY;
EndaKilgarriff 1:e84d8d51cd51 462 return (MENU_CONTINUE);
EndaKilgarriff 1:e84d8d51cd51 463 }
EndaKilgarriff 1:e84d8d51cd51 464
EndaKilgarriff 1:e84d8d51cd51 465 /*!
EndaKilgarriff 1:e84d8d51cd51 466 * @brief User dac code
EndaKilgarriff 1:e84d8d51cd51 467 * @details Generate dac code that can be written to device from voltage provided by user
EndaKilgarriff 1:e84d8d51cd51 468 * @param user_voltage - float value provided by user for voltage value to be set
EndaKilgarriff 1:e84d8d51cd51 469 * @return dac code value
EndaKilgarriff 1:e84d8d51cd51 470 */
EndaKilgarriff 1:e84d8d51cd51 471 static uint16_t user_dac_code(float user_voltage)
EndaKilgarriff 1:e84d8d51cd51 472 {
EndaKilgarriff 1:e84d8d51cd51 473 return (uint16_t) (((user_voltage) * MAX_ADC_CODE) / vref_voltage);
EndaKilgarriff 1:e84d8d51cd51 474 }
EndaKilgarriff 1:e84d8d51cd51 475
EndaKilgarriff 1:e84d8d51cd51 476 /*!
EndaKilgarriff 1:e84d8d51cd51 477 * @brief Code values to voltage
EndaKilgarriff 1:e84d8d51cd51 478 * @details Generate voltage based on code value
EndaKilgarriff 1:e84d8d51cd51 479 * @param code - integer value used to generate voltage value
EndaKilgarriff 1:e84d8d51cd51 480 * @return float voltage value
EndaKilgarriff 1:e84d8d51cd51 481 */
EndaKilgarriff 1:e84d8d51cd51 482 static float code_to_volts(int16_t code)
EndaKilgarriff 1:e84d8d51cd51 483 {
EndaKilgarriff 1:e84d8d51cd51 484 return ((code / MAX_ADC_CODE) * vref_voltage);
EndaKilgarriff 1:e84d8d51cd51 485 }
EndaKilgarriff 1:e84d8d51cd51 486
EndaKilgarriff 1:e84d8d51cd51 487 /*!
EndaKilgarriff 1:e84d8d51cd51 488 * @brief Write DAC Values
EndaKilgarriff 1:e84d8d51cd51 489 * @details Write value specified by user to Channels selected by user in the DAC menu
EndaKilgarriff 1:e84d8d51cd51 490 * @return (MENU_CONTINUE)
EndaKilgarriff 1:e84d8d51cd51 491 */
EndaKilgarriff 1:e84d8d51cd51 492 static int32_t do_write_dac_value(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 493 {
EndaKilgarriff 1:e84d8d51cd51 494 int32_t status;
EndaKilgarriff 1:e84d8d51cd51 495 uint16_t user_code = 0;
EndaKilgarriff 1:e84d8d51cd51 496 float user_voltage = 2.5;
EndaKilgarriff 1:e84d8d51cd51 497
EndaKilgarriff 1:e84d8d51cd51 498 printf(EOL "\tEnter voltage to write to selected DACs (0 - Vref) : " EOL);
EndaKilgarriff 1:e84d8d51cd51 499 user_voltage = adi_get_decimal_float(5);
EndaKilgarriff 1:e84d8d51cd51 500 user_code = user_dac_code(user_voltage);
EndaKilgarriff 1:e84d8d51cd51 501
EndaKilgarriff 1:e84d8d51cd51 502 for (uint8_t i = 0; i < NUM_CHANNELS; i++) {
EndaKilgarriff 1:e84d8d51cd51 503 if (active_channel_selections[i]) {
EndaKilgarriff 1:e84d8d51cd51 504 if ((status = sAd5592r_dev.ops->write_dac(&sAd5592r_dev, i,
EndaKilgarriff 1:e84d8d51cd51 505 user_code)) != SUCCESS) {
EndaKilgarriff 1:e84d8d51cd51 506 printf("*** Error writing DAC value to channel %d (%d) ***" EOL, i, status);
EndaKilgarriff 1:e84d8d51cd51 507 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 508 }
EndaKilgarriff 1:e84d8d51cd51 509 sAd5592r_dev.cached_dac[i] = user_code;
EndaKilgarriff 1:e84d8d51cd51 510 }
EndaKilgarriff 1:e84d8d51cd51 511 }
EndaKilgarriff 1:e84d8d51cd51 512 return (MENU_CONTINUE);
EndaKilgarriff 1:e84d8d51cd51 513 }
EndaKilgarriff 1:e84d8d51cd51 514
EndaKilgarriff 1:e84d8d51cd51 515 /*!
EndaKilgarriff 1:e84d8d51cd51 516 * @brief Toggle LDAC Modes
EndaKilgarriff 1:e84d8d51cd51 517 * @details Toggles the LDAC mode variable between Immediate write to output
EndaKilgarriff 1:e84d8d51cd51 518 * and write values to input register
EndaKilgarriff 1:e84d8d51cd51 519 * @return (MENU_CONTINUE)
EndaKilgarriff 1:e84d8d51cd51 520 */
EndaKilgarriff 1:e84d8d51cd51 521 static int32_t do_toggle_ldac_mode(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 522 {
EndaKilgarriff 1:e84d8d51cd51 523 if (sAd5592r_dev.ldac_mode == AD5592R_REG_LDAC_INPUT_REG_ONLY) {
EndaKilgarriff 1:e84d8d51cd51 524 sAd5592r_dev.ldac_mode = AD5592R_REG_LDAC_IMMEDIATE_OUT;
EndaKilgarriff 1:e84d8d51cd51 525 } else {
EndaKilgarriff 1:e84d8d51cd51 526 sAd5592r_dev.ldac_mode = AD5592R_REG_LDAC_INPUT_REG_ONLY;
EndaKilgarriff 1:e84d8d51cd51 527 }
EndaKilgarriff 1:e84d8d51cd51 528 return (MENU_CONTINUE);
EndaKilgarriff 1:e84d8d51cd51 529 }
EndaKilgarriff 1:e84d8d51cd51 530
EndaKilgarriff 1:e84d8d51cd51 531 /*!
EndaKilgarriff 1:e84d8d51cd51 532 * @brief Toggle DAC channels to power-down
EndaKilgarriff 1:e84d8d51cd51 533 * @details Toggles DAC channels that are powered down based on user selection
EndaKilgarriff 1:e84d8d51cd51 534 * @return (MENU_CONTINUE)
EndaKilgarriff 1:e84d8d51cd51 535 */
EndaKilgarriff 1:e84d8d51cd51 536 static int32_t do_toggle_dac_powerdown(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 537 {
EndaKilgarriff 1:e84d8d51cd51 538 int32_t status;
EndaKilgarriff 1:e84d8d51cd51 539 uint16_t powerdown = 0;
EndaKilgarriff 1:e84d8d51cd51 540
EndaKilgarriff 1:e84d8d51cd51 541 if ((status = ad5592r_base_reg_read(&sAd5592r_dev, AD5592R_REG_PD,
EndaKilgarriff 1:e84d8d51cd51 542 &powerdown)) != SUCCESS) {
EndaKilgarriff 1:e84d8d51cd51 543 printf("*** Error Reading Power Down Config (%d)***" EOL, status);
EndaKilgarriff 1:e84d8d51cd51 544 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 545 }
EndaKilgarriff 1:e84d8d51cd51 546
EndaKilgarriff 1:e84d8d51cd51 547 for (uint8_t i = 0; i < NUM_CHANNELS; i++) {
EndaKilgarriff 1:e84d8d51cd51 548 if (active_channel_selections[i]) {
EndaKilgarriff 1:e84d8d51cd51 549 powerdown ^= AD5592R_REG_PD_CHANNEL(i);
EndaKilgarriff 1:e84d8d51cd51 550 }
EndaKilgarriff 1:e84d8d51cd51 551 }
EndaKilgarriff 1:e84d8d51cd51 552
EndaKilgarriff 1:e84d8d51cd51 553 if ((status = ad5592r_base_reg_write(&sAd5592r_dev, AD5592R_REG_PD,
EndaKilgarriff 1:e84d8d51cd51 554 powerdown)) != SUCCESS) {
EndaKilgarriff 1:e84d8d51cd51 555 printf("*** Error writing Power Down Config (%d)***" EOL, status);
EndaKilgarriff 1:e84d8d51cd51 556 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 557 }
EndaKilgarriff 1:e84d8d51cd51 558
EndaKilgarriff 1:e84d8d51cd51 559 return (MENU_CONTINUE);
EndaKilgarriff 1:e84d8d51cd51 560 }
EndaKilgarriff 1:e84d8d51cd51 561
EndaKilgarriff 1:e84d8d51cd51 562 /*!
EndaKilgarriff 1:e84d8d51cd51 563 * @brief Toggle Channels to include in ADC Sequence
EndaKilgarriff 1:e84d8d51cd51 564 * @details Toggles channels that are included in the ADC conversion sequence
EndaKilgarriff 1:e84d8d51cd51 565 * @return MENU_CONTINUE
EndaKilgarriff 1:e84d8d51cd51 566 */
EndaKilgarriff 1:e84d8d51cd51 567 static int32_t do_toggle_incl_in_seq(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 568 {
EndaKilgarriff 1:e84d8d51cd51 569 for (uint8_t i = 0; i < NUM_CHANNELS; i++) {
EndaKilgarriff 1:e84d8d51cd51 570 if (active_channel_selections[i]) {
EndaKilgarriff 1:e84d8d51cd51 571 adc_channels_in_seq ^= AD5592R_REG_ADC_SEQ_INCL(i);
EndaKilgarriff 1:e84d8d51cd51 572 }
EndaKilgarriff 1:e84d8d51cd51 573 }
EndaKilgarriff 1:e84d8d51cd51 574 return (MENU_CONTINUE);
EndaKilgarriff 1:e84d8d51cd51 575 }
EndaKilgarriff 1:e84d8d51cd51 576
EndaKilgarriff 1:e84d8d51cd51 577 /*!
EndaKilgarriff 1:e84d8d51cd51 578 * @brief Read ADC Sequence
EndaKilgarriff 1:e84d8d51cd51 579 * @details The channels that are included in an ADC conversion sequence are read.
EndaKilgarriff 1:e84d8d51cd51 580 * For the number of channels in the sequence, the data is parsed, converted
EndaKilgarriff 1:e84d8d51cd51 581 * and printed.
EndaKilgarriff 1:e84d8d51cd51 582 * @return SUCCESS OR FAILURE
EndaKilgarriff 1:e84d8d51cd51 583 */
EndaKilgarriff 1:e84d8d51cd51 584 int32_t do_read_adc_sequence(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 585 {
EndaKilgarriff 1:e84d8d51cd51 586 int32_t status;
EndaKilgarriff 1:e84d8d51cd51 587 uint16_t adc_seq_data[9] = {0,0,0,0,0,0,0,0,0}, adc_code;
EndaKilgarriff 1:e84d8d51cd51 588 uint8_t chan;
EndaKilgarriff 1:e84d8d51cd51 589 float temperature = 0, voltage = 0;
EndaKilgarriff 1:e84d8d51cd51 590 size_t samples;
EndaKilgarriff 1:e84d8d51cd51 591
EndaKilgarriff 1:e84d8d51cd51 592 samples = hweight8(adc_channels_in_seq);
EndaKilgarriff 1:e84d8d51cd51 593
EndaKilgarriff 1:e84d8d51cd51 594 if ((status = sAd5592r_dev.ops->multi_read_adc(&sAd5592r_dev,
EndaKilgarriff 1:e84d8d51cd51 595 adc_channels_in_seq, adc_seq_data)) != SUCCESS) {
EndaKilgarriff 1:e84d8d51cd51 596 printf("*** Error reading adc_sequencer (%d)***" EOL, status);
EndaKilgarriff 1:e84d8d51cd51 597 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 598 return FAILURE;
EndaKilgarriff 1:e84d8d51cd51 599 }
EndaKilgarriff 1:e84d8d51cd51 600
EndaKilgarriff 1:e84d8d51cd51 601 printf("\tCh \tCode \tVoltage \tTemp" EOL);
EndaKilgarriff 1:e84d8d51cd51 602
EndaKilgarriff 1:e84d8d51cd51 603 for (uint8_t i = 0; i < samples; i++) {
EndaKilgarriff 1:e84d8d51cd51 604 temperature = 0;
EndaKilgarriff 1:e84d8d51cd51 605
EndaKilgarriff 1:e84d8d51cd51 606 adc_code = AD5592R_REG_ADC_SEQ_CODE_MSK(adc_seq_data[i]);
EndaKilgarriff 1:e84d8d51cd51 607 chan = ((adc_seq_data[i] & 0xF000) >> 12);
EndaKilgarriff 1:e84d8d51cd51 608
EndaKilgarriff 1:e84d8d51cd51 609 voltage = code_to_volts(adc_code);
EndaKilgarriff 1:e84d8d51cd51 610
EndaKilgarriff 1:e84d8d51cd51 611 if (chan == TEMPERATURE_READBACK_CHANNEL) {
EndaKilgarriff 1:e84d8d51cd51 612 temperature = die_temp_calculation(adc_code,
EndaKilgarriff 1:e84d8d51cd51 613 (AD5592R_REG_CTRL_ADC_RANGE &
EndaKilgarriff 1:e84d8d51cd51 614 sAd5592r_dev.cached_gp_ctrl));
EndaKilgarriff 1:e84d8d51cd51 615 // Invalid data on temperature read back frame
EndaKilgarriff 1:e84d8d51cd51 616 voltage = 0;
EndaKilgarriff 1:e84d8d51cd51 617 adc_code = 0;
EndaKilgarriff 1:e84d8d51cd51 618 }
EndaKilgarriff 1:e84d8d51cd51 619 printf("\t%d \t%x \t%.2f \t\t%.1f" EOL,
EndaKilgarriff 1:e84d8d51cd51 620 chan,
EndaKilgarriff 1:e84d8d51cd51 621 adc_code,
EndaKilgarriff 1:e84d8d51cd51 622 voltage,
EndaKilgarriff 1:e84d8d51cd51 623 temperature
EndaKilgarriff 1:e84d8d51cd51 624 );
EndaKilgarriff 1:e84d8d51cd51 625 }
EndaKilgarriff 1:e84d8d51cd51 626 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 627 return SUCCESS;
EndaKilgarriff 1:e84d8d51cd51 628 }
EndaKilgarriff 1:e84d8d51cd51 629
EndaKilgarriff 1:e84d8d51cd51 630 /*!
EndaKilgarriff 1:e84d8d51cd51 631 * @brief Set GPI
EndaKilgarriff 1:e84d8d51cd51 632 * @details GPIO channels that are selected, with the selection being stored in
EndaKilgarriff 1:e84d8d51cd51 633 * active_channel_selections array are set to GPIO Inputs. The selection is then cleared.
EndaKilgarriff 1:e84d8d51cd51 634 * @return (MENU_CONTINUE)
EndaKilgarriff 1:e84d8d51cd51 635 */
EndaKilgarriff 1:e84d8d51cd51 636 static int32_t do_set_gpio_input(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 637 {
EndaKilgarriff 1:e84d8d51cd51 638 int32_t status;
EndaKilgarriff 1:e84d8d51cd51 639
EndaKilgarriff 1:e84d8d51cd51 640 for (uint8_t i = 0; i < NUM_CHANNELS; i++) {
EndaKilgarriff 1:e84d8d51cd51 641 if (active_channel_selections[i] == true) {
EndaKilgarriff 1:e84d8d51cd51 642 sAd5592r_dev.channel_modes[i] = CH_MODE_GPI;
EndaKilgarriff 1:e84d8d51cd51 643 if ((status = ad5592r_gpio_direction_input
EndaKilgarriff 1:e84d8d51cd51 644 (&sAd5592r_dev, AD5592R_CHANNEL(i) )) != SUCCESS) {
EndaKilgarriff 1:e84d8d51cd51 645 printf(" *** Error Setting GPIO Input on Channel %d (%d) ***" EOL, i, status);
EndaKilgarriff 1:e84d8d51cd51 646 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 647 }
EndaKilgarriff 1:e84d8d51cd51 648 }
EndaKilgarriff 1:e84d8d51cd51 649 }
EndaKilgarriff 1:e84d8d51cd51 650 do_toggle_channel_selection(CLEAR_CHANNEL_SELECTION);
EndaKilgarriff 1:e84d8d51cd51 651 return (MENU_CONTINUE);
EndaKilgarriff 1:e84d8d51cd51 652 }
EndaKilgarriff 1:e84d8d51cd51 653
EndaKilgarriff 1:e84d8d51cd51 654 /*!
EndaKilgarriff 1:e84d8d51cd51 655 * @brief Set GPO
EndaKilgarriff 1:e84d8d51cd51 656 * @details GPIO channels that are selected, with the selection being stored in
EndaKilgarriff 1:e84d8d51cd51 657 * active_channel_selections array are set to GPIO Outputs with their
EndaKilgarriff 1:e84d8d51cd51 658 * output set LOW. The selection is then cleared.
EndaKilgarriff 1:e84d8d51cd51 659 * @return (MENU_CONTINUE)
EndaKilgarriff 1:e84d8d51cd51 660 */
EndaKilgarriff 1:e84d8d51cd51 661 static int32_t do_set_gpio_output(uint32_t value)
EndaKilgarriff 1:e84d8d51cd51 662 {
EndaKilgarriff 1:e84d8d51cd51 663 int32_t status;
EndaKilgarriff 1:e84d8d51cd51 664
EndaKilgarriff 1:e84d8d51cd51 665 for (uint8_t i = 0; i < NUM_CHANNELS; i++) {
EndaKilgarriff 1:e84d8d51cd51 666 if (active_channel_selections[i] == true) {
EndaKilgarriff 1:e84d8d51cd51 667 sAd5592r_dev.channel_modes[i] = CH_MODE_GPO;
EndaKilgarriff 1:e84d8d51cd51 668 if ((status = ad5592r_gpio_direction_output
EndaKilgarriff 1:e84d8d51cd51 669 (&sAd5592r_dev, AD5592R_CHANNEL(i), GPIO_LOW)) != SUCCESS) {
EndaKilgarriff 1:e84d8d51cd51 670 printf(" *** Error Setting GPIO Output on channel %d (%d) ***" EOL, i,status);
EndaKilgarriff 1:e84d8d51cd51 671 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 672 }
EndaKilgarriff 1:e84d8d51cd51 673 }
EndaKilgarriff 1:e84d8d51cd51 674 }
EndaKilgarriff 1:e84d8d51cd51 675 do_toggle_channel_selection(CLEAR_CHANNEL_SELECTION);
EndaKilgarriff 1:e84d8d51cd51 676 return (MENU_CONTINUE);
EndaKilgarriff 1:e84d8d51cd51 677 }
EndaKilgarriff 1:e84d8d51cd51 678
EndaKilgarriff 1:e84d8d51cd51 679 /*!
EndaKilgarriff 1:e84d8d51cd51 680 * @brief Toggle GPO
EndaKilgarriff 1:e84d8d51cd51 681 * @details GPIO channels that are selected, with the selection being stored in
EndaKilgarriff 1:e84d8d51cd51 682 * active_channel_selections array are set to GPIO Outputs with their
EndaKilgarriff 1:e84d8d51cd51 683 * output set toggled HIGH and LOW. The selection is then cleared.
EndaKilgarriff 1:e84d8d51cd51 684 * @return (MENU_CONTINUE)
EndaKilgarriff 1:e84d8d51cd51 685 */
EndaKilgarriff 1:e84d8d51cd51 686 static int32_t do_toggle_gpio_output(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 687 {
EndaKilgarriff 1:e84d8d51cd51 688 int32_t status;
EndaKilgarriff 1:e84d8d51cd51 689
EndaKilgarriff 1:e84d8d51cd51 690 for (uint8_t i = 0; i < NUM_CHANNELS; i++) {
EndaKilgarriff 1:e84d8d51cd51 691 if (active_channel_selections[i] == true) {
EndaKilgarriff 1:e84d8d51cd51 692 if ((status = ad5592r_gpio_set(&sAd5592r_dev,
EndaKilgarriff 1:e84d8d51cd51 693 AD5592R_CHANNEL(i),
EndaKilgarriff 1:e84d8d51cd51 694 !ad5592r_gpio_get(&sAd5592r_dev, AD5592R_CHANNEL(i))) != SUCCESS)) {
EndaKilgarriff 1:e84d8d51cd51 695 printf(" *** Error Toggling GPIO Output on Channel %d (%d) ***", i, status);
EndaKilgarriff 1:e84d8d51cd51 696 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 697 }
EndaKilgarriff 1:e84d8d51cd51 698 }
EndaKilgarriff 1:e84d8d51cd51 699 }
EndaKilgarriff 1:e84d8d51cd51 700 do_toggle_channel_selection(CLEAR_CHANNEL_SELECTION);
EndaKilgarriff 1:e84d8d51cd51 701 return (MENU_CONTINUE);
EndaKilgarriff 1:e84d8d51cd51 702 }
EndaKilgarriff 1:e84d8d51cd51 703
EndaKilgarriff 1:e84d8d51cd51 704
EndaKilgarriff 1:e84d8d51cd51 705 /*!
EndaKilgarriff 1:e84d8d51cd51 706 * @brief calls the general configuration menu
EndaKilgarriff 1:e84d8d51cd51 707 */
EndaKilgarriff 1:e84d8d51cd51 708 static int32_t menu_general_settings(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 709 {
EndaKilgarriff 1:e84d8d51cd51 710 return adi_do_console_menu(&general_settings_menu);
EndaKilgarriff 1:e84d8d51cd51 711 }
EndaKilgarriff 1:e84d8d51cd51 712
EndaKilgarriff 1:e84d8d51cd51 713 /*!
EndaKilgarriff 1:e84d8d51cd51 714 * @brief calls the DAC configuration menu
EndaKilgarriff 1:e84d8d51cd51 715 */
EndaKilgarriff 1:e84d8d51cd51 716 static int32_t menu_dac(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 717 {
EndaKilgarriff 1:e84d8d51cd51 718 return adi_do_console_menu(&dac_menu);
EndaKilgarriff 1:e84d8d51cd51 719 }
EndaKilgarriff 1:e84d8d51cd51 720
EndaKilgarriff 1:e84d8d51cd51 721 /*!
EndaKilgarriff 1:e84d8d51cd51 722 * @brief calls the channel configuration menu
EndaKilgarriff 1:e84d8d51cd51 723 */
EndaKilgarriff 1:e84d8d51cd51 724 static int32_t menu_config_channels(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 725 {
EndaKilgarriff 1:e84d8d51cd51 726 return adi_do_console_menu(&config_channels_menu);
EndaKilgarriff 1:e84d8d51cd51 727 }
EndaKilgarriff 1:e84d8d51cd51 728
EndaKilgarriff 1:e84d8d51cd51 729 /*!
EndaKilgarriff 1:e84d8d51cd51 730 * @brief calls the ADC configuration menu
EndaKilgarriff 1:e84d8d51cd51 731 */
EndaKilgarriff 1:e84d8d51cd51 732 static int32_t menu_adc(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 733 {
EndaKilgarriff 1:e84d8d51cd51 734 return adi_do_console_menu(&adc_menu);
EndaKilgarriff 1:e84d8d51cd51 735 }
EndaKilgarriff 1:e84d8d51cd51 736
EndaKilgarriff 1:e84d8d51cd51 737 /*!
EndaKilgarriff 1:e84d8d51cd51 738 * @brief calls the menu to select GPIO pins to toggle
EndaKilgarriff 1:e84d8d51cd51 739 */
EndaKilgarriff 1:e84d8d51cd51 740 static int32_t menu_gpio(uint32_t id)
EndaKilgarriff 1:e84d8d51cd51 741 {
EndaKilgarriff 1:e84d8d51cd51 742 return adi_do_console_menu(&gpio_menu);
EndaKilgarriff 1:e84d8d51cd51 743 }
EndaKilgarriff 1:e84d8d51cd51 744
EndaKilgarriff 1:e84d8d51cd51 745 /*!
EndaKilgarriff 1:e84d8d51cd51 746 * @brief displays the channel configuration header
EndaKilgarriff 1:e84d8d51cd51 747 */
EndaKilgarriff 1:e84d8d51cd51 748 static void display_channel_selection_header(void)
EndaKilgarriff 1:e84d8d51cd51 749 {
EndaKilgarriff 1:e84d8d51cd51 750 printf(" Configuration Lock: %s" EOL,
EndaKilgarriff 1:e84d8d51cd51 751 (AD5592R_REG_CTRL_CONFIG_LOCK & sAd5592r_dev.cached_gp_ctrl)
EndaKilgarriff 1:e84d8d51cd51 752 ?"Enabled":"Disabled");
EndaKilgarriff 1:e84d8d51cd51 753
EndaKilgarriff 1:e84d8d51cd51 754 printf("\tCh\tMode\t\tOffstate\tSelected" EOL);
EndaKilgarriff 1:e84d8d51cd51 755 for (uint8_t i = 0; i < sAd5592r_dev.num_channels; i++) {
EndaKilgarriff 1:e84d8d51cd51 756 printf("\t%d \t%s \t%s \t\t%s" EOL,
EndaKilgarriff 1:e84d8d51cd51 757 i,
EndaKilgarriff 1:e84d8d51cd51 758 mode_names[sAd5592r_dev.channel_modes[i]],
EndaKilgarriff 1:e84d8d51cd51 759 offstate_names[sAd5592r_dev.channel_offstate[i]],
EndaKilgarriff 1:e84d8d51cd51 760 active_channel_selections[i]?"X":"\00" );
EndaKilgarriff 1:e84d8d51cd51 761 }
EndaKilgarriff 1:e84d8d51cd51 762 }
EndaKilgarriff 1:e84d8d51cd51 763
EndaKilgarriff 1:e84d8d51cd51 764 /*!
EndaKilgarriff 1:e84d8d51cd51 765 * @brief displays the gpio menu header
EndaKilgarriff 1:e84d8d51cd51 766 */
EndaKilgarriff 1:e84d8d51cd51 767 static void display_gpio_menu_header(void)
EndaKilgarriff 1:e84d8d51cd51 768 {
EndaKilgarriff 1:e84d8d51cd51 769 printf("\tCh\tDir \tValue\tSelected" EOL);
EndaKilgarriff 1:e84d8d51cd51 770
EndaKilgarriff 1:e84d8d51cd51 771 for (uint8_t i = 0; i < sAd5592r_dev.num_channels; i++) {
EndaKilgarriff 1:e84d8d51cd51 772
EndaKilgarriff 1:e84d8d51cd51 773 printf("\t%d \t%s%s \t%s \t%s" EOL,
EndaKilgarriff 1:e84d8d51cd51 774 i,
EndaKilgarriff 1:e84d8d51cd51 775 (sAd5592r_dev.gpio_in & AD5592R_GPIO(i)) ? "In " : "",
EndaKilgarriff 1:e84d8d51cd51 776 (sAd5592r_dev.gpio_out & AD5592R_GPIO(i)) ? "Out " : "",
EndaKilgarriff 1:e84d8d51cd51 777 ad5592r_gpio_get(&sAd5592r_dev, AD5592R_CHANNEL(i)) ? "High" : "Low",
EndaKilgarriff 1:e84d8d51cd51 778 active_channel_selections[i] ? "X" : "\00"
EndaKilgarriff 1:e84d8d51cd51 779 );
EndaKilgarriff 1:e84d8d51cd51 780 }
EndaKilgarriff 1:e84d8d51cd51 781 }
EndaKilgarriff 1:e84d8d51cd51 782
EndaKilgarriff 1:e84d8d51cd51 783 /*!
EndaKilgarriff 1:e84d8d51cd51 784 * @brief displays the DAC menu header
EndaKilgarriff 1:e84d8d51cd51 785 */
EndaKilgarriff 1:e84d8d51cd51 786 static void display_dac_menu_header(void)
EndaKilgarriff 1:e84d8d51cd51 787 {
EndaKilgarriff 1:e84d8d51cd51 788 int32_t status;
EndaKilgarriff 1:e84d8d51cd51 789 float voltage;
EndaKilgarriff 1:e84d8d51cd51 790 uint16_t powerdown_read;
EndaKilgarriff 1:e84d8d51cd51 791 char *dac_channel_state = "";
EndaKilgarriff 1:e84d8d51cd51 792
EndaKilgarriff 1:e84d8d51cd51 793 printf("\tLDAC mode: %s" EOL EOL,
EndaKilgarriff 1:e84d8d51cd51 794 sAd5592r_dev.ldac_mode ? "Write to Input Register": "Immediate Output");
EndaKilgarriff 1:e84d8d51cd51 795
EndaKilgarriff 1:e84d8d51cd51 796 printf("\tCH \tConfig \tCode \tVoltage \tSelected" EOL);
EndaKilgarriff 1:e84d8d51cd51 797
EndaKilgarriff 1:e84d8d51cd51 798 if ((status = ad5592r_base_reg_read(&sAd5592r_dev,
EndaKilgarriff 1:e84d8d51cd51 799 AD5592R_REG_PD,
EndaKilgarriff 1:e84d8d51cd51 800 &powerdown_read)) != SUCCESS) {
EndaKilgarriff 1:e84d8d51cd51 801 printf("*** Error checking Power Down status (%d) ***" EOL, status);
EndaKilgarriff 1:e84d8d51cd51 802 adi_press_any_key_to_continue();
EndaKilgarriff 1:e84d8d51cd51 803 }
EndaKilgarriff 1:e84d8d51cd51 804
EndaKilgarriff 1:e84d8d51cd51 805 for (uint8_t i = 0; i < NUM_CHANNELS; i++) {
EndaKilgarriff 1:e84d8d51cd51 806 voltage = 0;
EndaKilgarriff 1:e84d8d51cd51 807 switch (sAd5592r_dev.channel_modes[i]) {
EndaKilgarriff 1:e84d8d51cd51 808 case CH_MODE_DAC:
EndaKilgarriff 1:e84d8d51cd51 809 case CH_MODE_DAC_AND_ADC:
EndaKilgarriff 1:e84d8d51cd51 810 if (powerdown_read & AD5592R_REG_PD_CHANNEL(i)) {
EndaKilgarriff 1:e84d8d51cd51 811 dac_channel_state = "PD";
EndaKilgarriff 1:e84d8d51cd51 812 } else {
EndaKilgarriff 1:e84d8d51cd51 813 dac_channel_state = "DAC";
EndaKilgarriff 1:e84d8d51cd51 814 voltage = code_to_volts(sAd5592r_dev.cached_dac[i]);
EndaKilgarriff 1:e84d8d51cd51 815 }
EndaKilgarriff 1:e84d8d51cd51 816 break;
EndaKilgarriff 1:e84d8d51cd51 817 default:
EndaKilgarriff 1:e84d8d51cd51 818 dac_channel_state = "-";
EndaKilgarriff 1:e84d8d51cd51 819 // Channel no longer set as DAC - Clear cached value
EndaKilgarriff 1:e84d8d51cd51 820 sAd5592r_dev.cached_dac[i] = 0;
EndaKilgarriff 1:e84d8d51cd51 821 break;
EndaKilgarriff 1:e84d8d51cd51 822 }
EndaKilgarriff 1:e84d8d51cd51 823
EndaKilgarriff 1:e84d8d51cd51 824 printf("\t%d \t%s \t%x \t%.2fV \t\t%s" EOL,
EndaKilgarriff 1:e84d8d51cd51 825 i,
EndaKilgarriff 1:e84d8d51cd51 826 dac_channel_state,
EndaKilgarriff 1:e84d8d51cd51 827 sAd5592r_dev.cached_dac[i],
EndaKilgarriff 1:e84d8d51cd51 828 voltage,
EndaKilgarriff 1:e84d8d51cd51 829 active_channel_selections[i]?"X":"\00");
EndaKilgarriff 1:e84d8d51cd51 830 }
EndaKilgarriff 1:e84d8d51cd51 831 }
EndaKilgarriff 1:e84d8d51cd51 832
EndaKilgarriff 1:e84d8d51cd51 833 /*!
EndaKilgarriff 1:e84d8d51cd51 834 * @brief displays the Main menu header
EndaKilgarriff 1:e84d8d51cd51 835 */
EndaKilgarriff 1:e84d8d51cd51 836 static void display_main_menu_header(void)
EndaKilgarriff 1:e84d8d51cd51 837 {
EndaKilgarriff 1:e84d8d51cd51 838 printf("\tCurrent Channel Configuration:" EOL);
EndaKilgarriff 1:e84d8d51cd51 839 printf("\tCH \tMode " EOL);
EndaKilgarriff 1:e84d8d51cd51 840 for (uint8_t i = 0; i < NUM_CHANNELS; i++) {
EndaKilgarriff 1:e84d8d51cd51 841 printf("\t%d \t%s" EOL,
EndaKilgarriff 1:e84d8d51cd51 842 i,
EndaKilgarriff 1:e84d8d51cd51 843 mode_names[sAd5592r_dev.channel_modes[i]]);
EndaKilgarriff 1:e84d8d51cd51 844 }
EndaKilgarriff 1:e84d8d51cd51 845 }
EndaKilgarriff 1:e84d8d51cd51 846
EndaKilgarriff 1:e84d8d51cd51 847 /*!
EndaKilgarriff 1:e84d8d51cd51 848 * @brief displays the ADC menu header
EndaKilgarriff 1:e84d8d51cd51 849 */
EndaKilgarriff 1:e84d8d51cd51 850 static void display_adc_menu_header(void)
EndaKilgarriff 1:e84d8d51cd51 851 {
EndaKilgarriff 1:e84d8d51cd51 852 char *adc_channel_state = "";
EndaKilgarriff 1:e84d8d51cd51 853
EndaKilgarriff 1:e84d8d51cd51 854 printf("\tCh \tMode \tIncl \tSelected" EOL);
EndaKilgarriff 1:e84d8d51cd51 855
EndaKilgarriff 1:e84d8d51cd51 856 for (uint8_t i = 0; i < NUM_CHANNELS; i++) {
EndaKilgarriff 1:e84d8d51cd51 857 switch (sAd5592r_dev.channel_modes[i]) {
EndaKilgarriff 1:e84d8d51cd51 858 case CH_MODE_ADC:
EndaKilgarriff 1:e84d8d51cd51 859 case CH_MODE_DAC_AND_ADC:
EndaKilgarriff 1:e84d8d51cd51 860 adc_channel_state = "ADC";
EndaKilgarriff 1:e84d8d51cd51 861
EndaKilgarriff 1:e84d8d51cd51 862 break;
EndaKilgarriff 1:e84d8d51cd51 863 default:
EndaKilgarriff 1:e84d8d51cd51 864 adc_channel_state = "-";
EndaKilgarriff 1:e84d8d51cd51 865 break;
EndaKilgarriff 1:e84d8d51cd51 866 }
EndaKilgarriff 1:e84d8d51cd51 867
EndaKilgarriff 1:e84d8d51cd51 868 printf("\t%d \t%s \t%s \t%s" EOL,
EndaKilgarriff 1:e84d8d51cd51 869 i,
EndaKilgarriff 1:e84d8d51cd51 870 adc_channel_state,
EndaKilgarriff 1:e84d8d51cd51 871 (adc_channels_in_seq & AD5592R_REG_ADC_SEQ_INCL(i)) ?"X":"",
EndaKilgarriff 1:e84d8d51cd51 872 active_channel_selections[i]?"X":""
EndaKilgarriff 1:e84d8d51cd51 873 );
EndaKilgarriff 1:e84d8d51cd51 874 }
EndaKilgarriff 1:e84d8d51cd51 875 }
EndaKilgarriff 1:e84d8d51cd51 876
EndaKilgarriff 1:e84d8d51cd51 877 /*
EndaKilgarriff 1:e84d8d51cd51 878 * Definition of the menu of pins to include in adc sequence and menu itself
EndaKilgarriff 1:e84d8d51cd51 879 */
EndaKilgarriff 1:e84d8d51cd51 880 console_menu_item gpio_menu_items[] = {
EndaKilgarriff 1:e84d8d51cd51 881 { "Select Channel", '\00', NULL },
EndaKilgarriff 1:e84d8d51cd51 882 { "Channel 0", 'A', do_toggle_channel_selection, AD5592R_CHANNEL(0) },
EndaKilgarriff 1:e84d8d51cd51 883 { "Channel 1", 'S', do_toggle_channel_selection, AD5592R_CHANNEL(1) },
EndaKilgarriff 1:e84d8d51cd51 884 { "Channel 2", 'D', do_toggle_channel_selection, AD5592R_CHANNEL(2) },
EndaKilgarriff 1:e84d8d51cd51 885 { "Channel 3", 'F', do_toggle_channel_selection, AD5592R_CHANNEL(3) },
EndaKilgarriff 1:e84d8d51cd51 886 { "Channel 4", 'G', do_toggle_channel_selection, AD5592R_CHANNEL(4) },
EndaKilgarriff 1:e84d8d51cd51 887 { "Channel 5", 'H', do_toggle_channel_selection, AD5592R_CHANNEL(5) },
EndaKilgarriff 1:e84d8d51cd51 888 { "Channel 6", 'J', do_toggle_channel_selection, AD5592R_CHANNEL(6) },
EndaKilgarriff 1:e84d8d51cd51 889 { "Channel 7", 'K', do_toggle_channel_selection, AD5592R_CHANNEL(7) },
EndaKilgarriff 1:e84d8d51cd51 890 { "", '\00', NULL },
EndaKilgarriff 1:e84d8d51cd51 891 { "Set as GPIO Input", 'Z', do_set_gpio_input },
EndaKilgarriff 1:e84d8d51cd51 892 { "Set as GPIO Output", 'X', do_set_gpio_output },
EndaKilgarriff 1:e84d8d51cd51 893 { "Toggle Output Value", 'C', do_toggle_gpio_output},
EndaKilgarriff 1:e84d8d51cd51 894 };
EndaKilgarriff 1:e84d8d51cd51 895
EndaKilgarriff 1:e84d8d51cd51 896 console_menu gpio_menu = {
EndaKilgarriff 1:e84d8d51cd51 897 .title = "GPIO Menu" EOL,
EndaKilgarriff 1:e84d8d51cd51 898 .items = gpio_menu_items,
EndaKilgarriff 1:e84d8d51cd51 899 .itemCount = ARRAY_SIZE(gpio_menu_items),
EndaKilgarriff 1:e84d8d51cd51 900 .headerItem = display_gpio_menu_header,
EndaKilgarriff 1:e84d8d51cd51 901 .footerItem = NULL,
EndaKilgarriff 1:e84d8d51cd51 902 .enableEscapeKey = true
EndaKilgarriff 1:e84d8d51cd51 903 };
EndaKilgarriff 1:e84d8d51cd51 904
EndaKilgarriff 1:e84d8d51cd51 905 /*
EndaKilgarriff 1:e84d8d51cd51 906 * Definition of the ADC config menu and menu itself
EndaKilgarriff 1:e84d8d51cd51 907 */
EndaKilgarriff 1:e84d8d51cd51 908 console_menu_item adc_menu_items[] = {
EndaKilgarriff 1:e84d8d51cd51 909 { "Select channels:" },
EndaKilgarriff 1:e84d8d51cd51 910 { "Channel 0", 'A', do_toggle_channel_selection, AD5592R_CHANNEL(0) },
EndaKilgarriff 1:e84d8d51cd51 911 { "Channel 1", 'S', do_toggle_channel_selection, AD5592R_CHANNEL(1) },
EndaKilgarriff 1:e84d8d51cd51 912 { "Channel 2", 'D', do_toggle_channel_selection, AD5592R_CHANNEL(2) },
EndaKilgarriff 1:e84d8d51cd51 913 { "Channel 3", 'F', do_toggle_channel_selection, AD5592R_CHANNEL(3) },
EndaKilgarriff 1:e84d8d51cd51 914 { "Channel 4", 'G', do_toggle_channel_selection, AD5592R_CHANNEL(4) },
EndaKilgarriff 1:e84d8d51cd51 915 { "Channel 5", 'H', do_toggle_channel_selection, AD5592R_CHANNEL(5) },
EndaKilgarriff 1:e84d8d51cd51 916 { "Channel 6", 'J', do_toggle_channel_selection, AD5592R_CHANNEL(6) },
EndaKilgarriff 1:e84d8d51cd51 917 { "Channel 7", 'K', do_toggle_channel_selection, AD5592R_CHANNEL(7) },
EndaKilgarriff 1:e84d8d51cd51 918 { "", '\00', NULL },
EndaKilgarriff 1:e84d8d51cd51 919 { "Toggle Channels in Sequence", 'Q', do_toggle_incl_in_seq },
EndaKilgarriff 1:e84d8d51cd51 920 { "Read ADC Sequence", 'W', do_read_adc_sequence},
EndaKilgarriff 1:e84d8d51cd51 921 };
EndaKilgarriff 1:e84d8d51cd51 922
EndaKilgarriff 1:e84d8d51cd51 923 console_menu adc_menu = {
EndaKilgarriff 1:e84d8d51cd51 924 .title = "ADC Configuration Settings",
EndaKilgarriff 1:e84d8d51cd51 925 .items = adc_menu_items,
EndaKilgarriff 1:e84d8d51cd51 926 .itemCount = ARRAY_SIZE(adc_menu_items),
EndaKilgarriff 1:e84d8d51cd51 927 .headerItem = display_adc_menu_header,
EndaKilgarriff 1:e84d8d51cd51 928 .footerItem = NULL,
EndaKilgarriff 1:e84d8d51cd51 929 .enableEscapeKey = true
EndaKilgarriff 1:e84d8d51cd51 930 };
EndaKilgarriff 1:e84d8d51cd51 931
EndaKilgarriff 1:e84d8d51cd51 932
EndaKilgarriff 1:e84d8d51cd51 933 /*
EndaKilgarriff 1:e84d8d51cd51 934 * Definition of the DAC menu and menu itself
EndaKilgarriff 1:e84d8d51cd51 935 */
EndaKilgarriff 1:e84d8d51cd51 936 console_menu_item dac_menu_items[] = {
EndaKilgarriff 1:e84d8d51cd51 937 { "Select Channels:"},
EndaKilgarriff 1:e84d8d51cd51 938 { "Channel 0", 'A', do_toggle_channel_selection, AD5592R_CHANNEL(0) },
EndaKilgarriff 1:e84d8d51cd51 939 { "Channel 1", 'S', do_toggle_channel_selection, AD5592R_CHANNEL(1) },
EndaKilgarriff 1:e84d8d51cd51 940 { "Channel 2", 'D', do_toggle_channel_selection, AD5592R_CHANNEL(2) },
EndaKilgarriff 1:e84d8d51cd51 941 { "Channel 3", 'F', do_toggle_channel_selection, AD5592R_CHANNEL(3) },
EndaKilgarriff 1:e84d8d51cd51 942 { "Channel 4", 'G', do_toggle_channel_selection, AD5592R_CHANNEL(4) },
EndaKilgarriff 1:e84d8d51cd51 943 { "Channel 5", 'H', do_toggle_channel_selection, AD5592R_CHANNEL(5) },
EndaKilgarriff 1:e84d8d51cd51 944 { "Channel 6", 'J', do_toggle_channel_selection, AD5592R_CHANNEL(6) },
EndaKilgarriff 1:e84d8d51cd51 945 { "Channel 7", 'K', do_toggle_channel_selection, AD5592R_CHANNEL(7) },
EndaKilgarriff 1:e84d8d51cd51 946 { "", '\00', NULL },
EndaKilgarriff 1:e84d8d51cd51 947 { "Write voltage to selected DAC channels", 'Q', do_write_dac_value },
EndaKilgarriff 1:e84d8d51cd51 948 { "Toggle Power Down selected DAC channels", 'W', do_toggle_dac_powerdown },
EndaKilgarriff 1:e84d8d51cd51 949 { "Write Input Reg to DAC output", 'E', do_dac_input_reg_to_output },
EndaKilgarriff 1:e84d8d51cd51 950 { "Toggle LDAC mode", 'R', do_toggle_ldac_mode },
EndaKilgarriff 1:e84d8d51cd51 951 };
EndaKilgarriff 1:e84d8d51cd51 952
EndaKilgarriff 1:e84d8d51cd51 953 console_menu dac_menu = {
EndaKilgarriff 1:e84d8d51cd51 954 .title = "DAC Menu",
EndaKilgarriff 1:e84d8d51cd51 955 .items = dac_menu_items,
EndaKilgarriff 1:e84d8d51cd51 956 .itemCount = ARRAY_SIZE(dac_menu_items),
EndaKilgarriff 1:e84d8d51cd51 957 .headerItem = display_dac_menu_header,
EndaKilgarriff 1:e84d8d51cd51 958 .footerItem = NULL,
EndaKilgarriff 1:e84d8d51cd51 959 .enableEscapeKey = true
EndaKilgarriff 1:e84d8d51cd51 960 };
EndaKilgarriff 1:e84d8d51cd51 961
EndaKilgarriff 1:e84d8d51cd51 962 /*
EndaKilgarriff 1:e84d8d51cd51 963 * Definition of the General Settings menu and menu itself
EndaKilgarriff 1:e84d8d51cd51 964 */
EndaKilgarriff 1:e84d8d51cd51 965 console_menu_item general_settings_menu_items[] = {
EndaKilgarriff 1:e84d8d51cd51 966 {
EndaKilgarriff 1:e84d8d51cd51 967 "Toggle Internal Voltage Ref (En Ref)", 'A', do_general_settings_toggle,
EndaKilgarriff 1:e84d8d51cd51 968 ((AD5592R_REG_PD << 12) | AD5592R_REG_PD_EN_REF)
EndaKilgarriff 1:e84d8d51cd51 969 },
EndaKilgarriff 1:e84d8d51cd51 970 {
EndaKilgarriff 1:e84d8d51cd51 971 "Toggle ADC PreCharge Buffer (PC Buff)", 'S', do_general_settings_toggle,
EndaKilgarriff 1:e84d8d51cd51 972 ((AD5592R_REG_CTRL << 12) | AD5592R_REG_CTRL_ADC_PC_BUFF)
EndaKilgarriff 1:e84d8d51cd51 973 },
EndaKilgarriff 1:e84d8d51cd51 974 {
EndaKilgarriff 1:e84d8d51cd51 975 "Toggle ADC Buffer (Buff)", 'D', do_general_settings_toggle,
EndaKilgarriff 1:e84d8d51cd51 976 ((AD5592R_REG_CTRL << 12) | AD5592R_REG_CTRL_ADC_BUFF_EN)
EndaKilgarriff 1:e84d8d51cd51 977 },
EndaKilgarriff 1:e84d8d51cd51 978 {
EndaKilgarriff 1:e84d8d51cd51 979 "Toggle Lock Channel Config (Lock Config)", 'F', do_general_settings_toggle,
EndaKilgarriff 1:e84d8d51cd51 980 ((AD5592R_REG_CTRL << 12) | AD5592R_REG_CTRL_CONFIG_LOCK)
EndaKilgarriff 1:e84d8d51cd51 981 },
EndaKilgarriff 1:e84d8d51cd51 982 {
EndaKilgarriff 1:e84d8d51cd51 983 "Toggle PD All DACs and Internal Ref", 'G', do_general_settings_toggle,
EndaKilgarriff 1:e84d8d51cd51 984 ((AD5592R_REG_PD << 12) | AD5592R_REG_PD_PD_ALL)
EndaKilgarriff 1:e84d8d51cd51 985 },
EndaKilgarriff 1:e84d8d51cd51 986 {
EndaKilgarriff 1:e84d8d51cd51 987 "Toggle ADC Gain Range (ADC Gain)", 'H', do_general_settings_toggle,
EndaKilgarriff 1:e84d8d51cd51 988 ((AD5592R_REG_CTRL << 12) | AD5592R_REG_CTRL_ADC_RANGE)
EndaKilgarriff 1:e84d8d51cd51 989 },
EndaKilgarriff 1:e84d8d51cd51 990 {
EndaKilgarriff 1:e84d8d51cd51 991 "Toggle DAC Gain Range (DAC Gain)", 'J', do_general_settings_toggle,
EndaKilgarriff 1:e84d8d51cd51 992 ((AD5592R_REG_CTRL << 12) | AD5592R_REG_CTRL_DAC_RANGE)
EndaKilgarriff 1:e84d8d51cd51 993 },
EndaKilgarriff 1:e84d8d51cd51 994 {
EndaKilgarriff 1:e84d8d51cd51 995 "Toggle Write All DACS (Wr All)", 'K', do_general_settings_toggle,
EndaKilgarriff 1:e84d8d51cd51 996 ((AD5592R_REG_CTRL << 12) | AD5592R_REG_CTRL_W_ALL_DACS)
EndaKilgarriff 1:e84d8d51cd51 997 },
EndaKilgarriff 1:e84d8d51cd51 998 };
EndaKilgarriff 1:e84d8d51cd51 999
EndaKilgarriff 1:e84d8d51cd51 1000 console_menu general_settings_menu = {
EndaKilgarriff 1:e84d8d51cd51 1001 .title = "General Configuration Settings",
EndaKilgarriff 1:e84d8d51cd51 1002 .items = general_settings_menu_items,
EndaKilgarriff 1:e84d8d51cd51 1003 .itemCount = ARRAY_SIZE(general_settings_menu_items),
EndaKilgarriff 1:e84d8d51cd51 1004 .headerItem = display_general_setting_header,
EndaKilgarriff 1:e84d8d51cd51 1005 .footerItem = NULL,
EndaKilgarriff 1:e84d8d51cd51 1006 .enableEscapeKey = true
EndaKilgarriff 1:e84d8d51cd51 1007 };
EndaKilgarriff 1:e84d8d51cd51 1008
EndaKilgarriff 1:e84d8d51cd51 1009 /*
EndaKilgarriff 1:e84d8d51cd51 1010 * Definition of the Channel mode selection menu and menu itself
EndaKilgarriff 1:e84d8d51cd51 1011 */
EndaKilgarriff 1:e84d8d51cd51 1012 console_menu_item config_channels_menu_items[] = {
EndaKilgarriff 1:e84d8d51cd51 1013 { "Select Channels:"},
EndaKilgarriff 1:e84d8d51cd51 1014 { "Channel 0", 'A', do_toggle_channel_selection, AD5592R_CHANNEL(0) },
EndaKilgarriff 1:e84d8d51cd51 1015 { "Channel 1", 'S', do_toggle_channel_selection, AD5592R_CHANNEL(1) },
EndaKilgarriff 1:e84d8d51cd51 1016 { "Channel 2", 'D', do_toggle_channel_selection, AD5592R_CHANNEL(2) },
EndaKilgarriff 1:e84d8d51cd51 1017 { "Channel 3", 'F', do_toggle_channel_selection, AD5592R_CHANNEL(3) },
EndaKilgarriff 1:e84d8d51cd51 1018 { "Channel 4", 'G', do_toggle_channel_selection, AD5592R_CHANNEL(4) },
EndaKilgarriff 1:e84d8d51cd51 1019 { "Channel 5", 'H', do_toggle_channel_selection, AD5592R_CHANNEL(5) },
EndaKilgarriff 1:e84d8d51cd51 1020 { "Channel 6", 'J', do_toggle_channel_selection, AD5592R_CHANNEL(6) },
EndaKilgarriff 1:e84d8d51cd51 1021 { "Channel 7", 'K', do_toggle_channel_selection, AD5592R_CHANNEL(7) },
EndaKilgarriff 1:e84d8d51cd51 1022 { "", '\00', NULL },
EndaKilgarriff 1:e84d8d51cd51 1023 { "DAC", 'Q', do_mode_selection, CH_MODE_DAC },
EndaKilgarriff 1:e84d8d51cd51 1024 { "ADC", 'W', do_mode_selection, CH_MODE_ADC },
EndaKilgarriff 1:e84d8d51cd51 1025 { "ADC + DAC", 'E', do_mode_selection, CH_MODE_DAC_AND_ADC },
EndaKilgarriff 1:e84d8d51cd51 1026 { "GPI", 'R', do_mode_selection, CH_MODE_GPI },
EndaKilgarriff 1:e84d8d51cd51 1027 { "GPO", 'T', do_mode_selection, CH_MODE_GPO },
EndaKilgarriff 1:e84d8d51cd51 1028 { "Unused", 'Y', do_mode_selection, CH_MODE_UNUSED },
EndaKilgarriff 1:e84d8d51cd51 1029 { "Restore Default Modes", 'U', do_reset_channel_modes },
EndaKilgarriff 1:e84d8d51cd51 1030 { "", '\00', NULL },
EndaKilgarriff 1:e84d8d51cd51 1031 { "Pulldown", 'Z', do_offstate_selection, CH_OFFSTATE_PULLDOWN },
EndaKilgarriff 1:e84d8d51cd51 1032 { "Output Low", 'X', do_offstate_selection, CH_OFFSTATE_OUT_LOW },
EndaKilgarriff 1:e84d8d51cd51 1033 { "Output High",'C', do_offstate_selection, CH_OFFSTATE_OUT_HIGH },
EndaKilgarriff 1:e84d8d51cd51 1034 { "Tristate", 'V', do_offstate_selection, CH_OFFSTATE_OUT_TRISTATE },
EndaKilgarriff 1:e84d8d51cd51 1035 { "", '\00', NULL },
EndaKilgarriff 1:e84d8d51cd51 1036 { "Channel 7 as ADC conversion indicator (AD5592R)", 'M', do_channel_7_adc_indicator },
EndaKilgarriff 1:e84d8d51cd51 1037 };
EndaKilgarriff 1:e84d8d51cd51 1038
EndaKilgarriff 1:e84d8d51cd51 1039 console_menu config_channels_menu = {
EndaKilgarriff 1:e84d8d51cd51 1040 .title = "Configure IO Channels",
EndaKilgarriff 1:e84d8d51cd51 1041 .items = config_channels_menu_items,
EndaKilgarriff 1:e84d8d51cd51 1042 .itemCount = ARRAY_SIZE(config_channels_menu_items),
EndaKilgarriff 1:e84d8d51cd51 1043 .headerItem = display_channel_selection_header,
EndaKilgarriff 1:e84d8d51cd51 1044 .footerItem = NULL,
EndaKilgarriff 1:e84d8d51cd51 1045 .enableEscapeKey = true
EndaKilgarriff 1:e84d8d51cd51 1046 };
EndaKilgarriff 1:e84d8d51cd51 1047
EndaKilgarriff 1:e84d8d51cd51 1048 /*
EndaKilgarriff 1:e84d8d51cd51 1049 * Definition of the Main Menu Items and menu itself
EndaKilgarriff 1:e84d8d51cd51 1050 */
EndaKilgarriff 1:e84d8d51cd51 1051 console_menu_item main_menu_items[] = {
EndaKilgarriff 1:e84d8d51cd51 1052 { "Software Reset", 'Q', do_software_reset },
EndaKilgarriff 1:e84d8d51cd51 1053 { "Read ADC die temp", 'W', do_read_die_temp},
EndaKilgarriff 1:e84d8d51cd51 1054 { "", '\00', NULL },
EndaKilgarriff 1:e84d8d51cd51 1055 { "Configure Channels", 'A', menu_config_channels},
EndaKilgarriff 1:e84d8d51cd51 1056 { "General Settings", 'S', menu_general_settings },
EndaKilgarriff 1:e84d8d51cd51 1057 { "DAC Menu", 'D', menu_dac },
EndaKilgarriff 1:e84d8d51cd51 1058 { "ADC Menu", 'F', menu_adc },
EndaKilgarriff 1:e84d8d51cd51 1059 { "GPIO Menu", 'G', menu_gpio},
EndaKilgarriff 1:e84d8d51cd51 1060 };
EndaKilgarriff 1:e84d8d51cd51 1061
EndaKilgarriff 1:e84d8d51cd51 1062 console_menu ad5592r_main_menu = {
EndaKilgarriff 1:e84d8d51cd51 1063 .title = "AD5592R/AD5593R Main Menu",
EndaKilgarriff 1:e84d8d51cd51 1064 .items = main_menu_items,
EndaKilgarriff 1:e84d8d51cd51 1065 .itemCount = ARRAY_SIZE(main_menu_items),
EndaKilgarriff 1:e84d8d51cd51 1066 .headerItem = display_main_menu_header,
EndaKilgarriff 1:e84d8d51cd51 1067 .footerItem = NULL,
EndaKilgarriff 1:e84d8d51cd51 1068 .enableEscapeKey = NULL
EndaKilgarriff 1:e84d8d51cd51 1069 };