Example program for EVAL-AD5770R
Dependencies: adi_console_menu platform_drivers
app/ad5770r_console_app.c@1:63c505e13da4, 2020-03-30 (annotated)
- Committer:
- mbradley
- Date:
- Mon Mar 30 16:52:24 2020 +0000
- Revision:
- 1:63c505e13da4
- Child:
- 3:8a6aa77aba73
Initial Version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbradley | 1:63c505e13da4 | 1 | /*! |
mbradley | 1:63c505e13da4 | 2 | ***************************************************************************** |
mbradley | 1:63c505e13da4 | 3 | @file: ad5770r_console_app.c |
mbradley | 1:63c505e13da4 | 4 | |
mbradley | 1:63c505e13da4 | 5 | @brief: Implementation for the menu functions that handle the AD5770R |
mbradley | 1:63c505e13da4 | 6 | |
mbradley | 1:63c505e13da4 | 7 | @details: |
mbradley | 1:63c505e13da4 | 8 | ----------------------------------------------------------------------------- |
mbradley | 1:63c505e13da4 | 9 | * |
mbradley | 1:63c505e13da4 | 10 | Copyright (c) 2020 Analog Devices, Inc. All Rights Reserved. |
mbradley | 1:63c505e13da4 | 11 | |
mbradley | 1:63c505e13da4 | 12 | This software is proprietary to Analog Devices, Inc. and its licensors. |
mbradley | 1:63c505e13da4 | 13 | By using this software you agree to the terms of the associated |
mbradley | 1:63c505e13da4 | 14 | Analog Devices Software License Agreement. |
mbradley | 1:63c505e13da4 | 15 | ******************************************************************************/ |
mbradley | 1:63c505e13da4 | 16 | |
mbradley | 1:63c505e13da4 | 17 | /* includes */ |
mbradley | 1:63c505e13da4 | 18 | #include <stdio.h> |
mbradley | 1:63c505e13da4 | 19 | #include <stdlib.h> |
mbradley | 1:63c505e13da4 | 20 | #include <string.h> |
mbradley | 1:63c505e13da4 | 21 | #include <stdbool.h> |
mbradley | 1:63c505e13da4 | 22 | #include <stdint.h> |
mbradley | 1:63c505e13da4 | 23 | #include <assert.h> |
mbradley | 1:63c505e13da4 | 24 | |
mbradley | 1:63c505e13da4 | 25 | #include "app_config.h" |
mbradley | 1:63c505e13da4 | 26 | |
mbradley | 1:63c505e13da4 | 27 | #include "platform_drivers.h" |
mbradley | 1:63c505e13da4 | 28 | #include "platform_support.h" |
mbradley | 1:63c505e13da4 | 29 | #include "ad5770r.h" |
mbradley | 1:63c505e13da4 | 30 | |
mbradley | 1:63c505e13da4 | 31 | #include "ad5770r_console_app.h" |
mbradley | 1:63c505e13da4 | 32 | #include "ad5770r_user_config.h" |
mbradley | 1:63c505e13da4 | 33 | #include "ad5770r_reset_config.h" |
mbradley | 1:63c505e13da4 | 34 | |
mbradley | 1:63c505e13da4 | 35 | /* defines */ |
mbradley | 1:63c505e13da4 | 36 | #define TOGGLE_MUX_BUFFER 1000 |
mbradley | 1:63c505e13da4 | 37 | #define TOGGLE_DIODE_EXT_BIAS 1001 |
mbradley | 1:63c505e13da4 | 38 | #define MENU_CHANNEL_OFFSET 100 |
mbradley | 1:63c505e13da4 | 39 | |
mbradley | 1:63c505e13da4 | 40 | /* Private Variables */ |
mbradley | 1:63c505e13da4 | 41 | static struct ad5770r_dev * pAd5770r_dev = NULL; |
mbradley | 1:63c505e13da4 | 42 | |
mbradley | 1:63c505e13da4 | 43 | static struct ad5770r_channel_switches sw_ldac_shadow; |
mbradley | 1:63c505e13da4 | 44 | |
mbradley | 1:63c505e13da4 | 45 | // GPIO descriptor and init parameters for the HW LDACB pin |
mbradley | 1:63c505e13da4 | 46 | static gpio_desc * hw_ldacb_desc = NULL; |
mbradley | 1:63c505e13da4 | 47 | static gpio_init_param hw_ldacb_init_param = { HW_LDACB, NULL }; |
mbradley | 1:63c505e13da4 | 48 | |
mbradley | 1:63c505e13da4 | 49 | |
mbradley | 1:63c505e13da4 | 50 | // Forward Declaration |
mbradley | 1:63c505e13da4 | 51 | static console_menu general_configuration_menu; |
mbradley | 1:63c505e13da4 | 52 | static console_menu monitor_setup_menu; |
mbradley | 1:63c505e13da4 | 53 | static console_menu dac_channel_configuration_menu; |
mbradley | 1:63c505e13da4 | 54 | static console_menu dac_operations_menu; |
mbradley | 1:63c505e13da4 | 55 | |
mbradley | 1:63c505e13da4 | 56 | // Public Functions |
mbradley | 1:63c505e13da4 | 57 | |
mbradley | 1:63c505e13da4 | 58 | /*! |
mbradley | 1:63c505e13da4 | 59 | * @brief Initialize the AD7124 device and the SPI port as required |
mbradley | 1:63c505e13da4 | 60 | * |
mbradley | 1:63c505e13da4 | 61 | * @details This resets and then writes the default register map value to |
mbradley | 1:63c505e13da4 | 62 | * the device. A call to init the SPI port is made, but may not |
mbradley | 1:63c505e13da4 | 63 | * actually do very much, depending on the platform |
mbradley | 1:63c505e13da4 | 64 | */ |
mbradley | 1:63c505e13da4 | 65 | int32_t ad5770r_app_initialize(void) |
mbradley | 1:63c505e13da4 | 66 | { |
mbradley | 1:63c505e13da4 | 67 | |
mbradley | 1:63c505e13da4 | 68 | // Create a new descriptor for HW LDACB |
mbradley | 1:63c505e13da4 | 69 | if(gpio_get(&hw_ldacb_desc, &hw_ldacb_init_param) == FAILURE) { |
mbradley | 1:63c505e13da4 | 70 | return FAILURE; |
mbradley | 1:63c505e13da4 | 71 | } |
mbradley | 1:63c505e13da4 | 72 | |
mbradley | 1:63c505e13da4 | 73 | // Set the direction of HW LDACB |
mbradley | 1:63c505e13da4 | 74 | if((gpio_direction_output(hw_ldacb_desc, GPIO_OUT)) == FAILURE) { |
mbradley | 1:63c505e13da4 | 75 | return FAILURE; |
mbradley | 1:63c505e13da4 | 76 | } |
mbradley | 1:63c505e13da4 | 77 | |
mbradley | 1:63c505e13da4 | 78 | // Set the default output state of HW LDACB |
mbradley | 1:63c505e13da4 | 79 | if((gpio_set_value(hw_ldacb_desc, GPIO_HIGH)) == FAILURE) { |
mbradley | 1:63c505e13da4 | 80 | return FAILURE; |
mbradley | 1:63c505e13da4 | 81 | } |
mbradley | 1:63c505e13da4 | 82 | |
mbradley | 1:63c505e13da4 | 83 | return(ad5770r_init(&pAd5770r_dev, &ad5770r_user_param)); |
mbradley | 1:63c505e13da4 | 84 | } |
mbradley | 1:63c505e13da4 | 85 | |
mbradley | 1:63c505e13da4 | 86 | // Private Functions |
mbradley | 1:63c505e13da4 | 87 | |
mbradley | 1:63c505e13da4 | 88 | /** |
mbradley | 1:63c505e13da4 | 89 | * Performs a software reset. |
mbradley | 1:63c505e13da4 | 90 | * @param dev - The device structure. |
mbradley | 1:63c505e13da4 | 91 | * @return SUCCESS in case of success, negative error code otherwise. |
mbradley | 1:63c505e13da4 | 92 | */ |
mbradley | 1:63c505e13da4 | 93 | int32_t ad5770r_software_reset(struct ad5770r_dev *dev) |
mbradley | 1:63c505e13da4 | 94 | { |
mbradley | 1:63c505e13da4 | 95 | int32_t ret; |
mbradley | 1:63c505e13da4 | 96 | |
mbradley | 1:63c505e13da4 | 97 | if (!dev) |
mbradley | 1:63c505e13da4 | 98 | return FAILURE; |
mbradley | 1:63c505e13da4 | 99 | |
mbradley | 1:63c505e13da4 | 100 | ret = ad5770r_spi_reg_write(dev, |
mbradley | 1:63c505e13da4 | 101 | AD5770R_INTERFACE_CONFIG_A, |
mbradley | 1:63c505e13da4 | 102 | AD5770R_INTERFACE_CONFIG_A_SW_RESET_MSK | |
mbradley | 1:63c505e13da4 | 103 | AD5770R_INTERFACE_CONFIG_A_ADDR_ASCENSION_MSB( |
mbradley | 1:63c505e13da4 | 104 | dev->dev_spi_settings.addr_ascension)); |
mbradley | 1:63c505e13da4 | 105 | |
mbradley | 1:63c505e13da4 | 106 | if (ret) |
mbradley | 1:63c505e13da4 | 107 | return ret; |
mbradley | 1:63c505e13da4 | 108 | |
mbradley | 1:63c505e13da4 | 109 | // Save the spi_desc pointer field |
mbradley | 1:63c505e13da4 | 110 | spi_desc * spi_interface = dev->spi_desc; |
mbradley | 1:63c505e13da4 | 111 | // Copy over the reset state of the device |
mbradley | 1:63c505e13da4 | 112 | memcpy(dev, &ad5770r_dev_reset, sizeof(ad5770r_dev_reset)); |
mbradley | 1:63c505e13da4 | 113 | // Restore the spi_desc pointer field |
mbradley | 1:63c505e13da4 | 114 | dev->spi_desc = spi_interface; |
mbradley | 1:63c505e13da4 | 115 | |
mbradley | 1:63c505e13da4 | 116 | return ret; |
mbradley | 1:63c505e13da4 | 117 | } |
mbradley | 1:63c505e13da4 | 118 | |
mbradley | 1:63c505e13da4 | 119 | /* |
mbradley | 1:63c505e13da4 | 120 | * @brief Sends a reset command on the SPI to reset the device |
mbradley | 1:63c505e13da4 | 121 | * |
mbradley | 1:63c505e13da4 | 122 | * @details |
mbradley | 1:63c505e13da4 | 123 | */ |
mbradley | 1:63c505e13da4 | 124 | static int32_t do_software_reset(uint32_t id) |
mbradley | 1:63c505e13da4 | 125 | { |
mbradley | 1:63c505e13da4 | 126 | int32_t ret; |
mbradley | 1:63c505e13da4 | 127 | |
mbradley | 1:63c505e13da4 | 128 | if ((ret = ad5770r_software_reset(pAd5770r_dev)) == SUCCESS) { |
mbradley | 1:63c505e13da4 | 129 | printf(EOL " --- Software Reset Succeeded ---" EOL); |
mbradley | 1:63c505e13da4 | 130 | } else { |
mbradley | 1:63c505e13da4 | 131 | printf(EOL " *** Software Reset Failure: %d ***" EOL, ret); |
mbradley | 1:63c505e13da4 | 132 | } |
mbradley | 1:63c505e13da4 | 133 | adi_press_any_key_to_continue(); |
mbradley | 1:63c505e13da4 | 134 | return(MENU_CONTINUE); |
mbradley | 1:63c505e13da4 | 135 | } |
mbradley | 1:63c505e13da4 | 136 | |
mbradley | 1:63c505e13da4 | 137 | /* |
mbradley | 1:63c505e13da4 | 138 | * @brief Creates and initializes a device with user configuration |
mbradley | 1:63c505e13da4 | 139 | * |
mbradley | 1:63c505e13da4 | 140 | * @details |
mbradley | 1:63c505e13da4 | 141 | */ |
mbradley | 1:63c505e13da4 | 142 | static int32_t do_device_init(uint32_t id) |
mbradley | 1:63c505e13da4 | 143 | { |
mbradley | 1:63c505e13da4 | 144 | |
mbradley | 1:63c505e13da4 | 145 | if (ad5770r_init(&pAd5770r_dev, &ad5770r_user_param) == SUCCESS) { |
mbradley | 1:63c505e13da4 | 146 | } else { |
mbradley | 1:63c505e13da4 | 147 | printf("\n\r *** Error device init ***\n\r"); |
mbradley | 1:63c505e13da4 | 148 | } |
mbradley | 1:63c505e13da4 | 149 | |
mbradley | 1:63c505e13da4 | 150 | adi_press_any_key_to_continue(); |
mbradley | 1:63c505e13da4 | 151 | return(MENU_CONTINUE); |
mbradley | 1:63c505e13da4 | 152 | } |
mbradley | 1:63c505e13da4 | 153 | |
mbradley | 1:63c505e13da4 | 154 | /* |
mbradley | 1:63c505e13da4 | 155 | * @brief Removes the device from memory |
mbradley | 1:63c505e13da4 | 156 | * |
mbradley | 1:63c505e13da4 | 157 | * @details |
mbradley | 1:63c505e13da4 | 158 | */ |
mbradley | 1:63c505e13da4 | 159 | static int32_t do_device_remove(uint32_t id) |
mbradley | 1:63c505e13da4 | 160 | { |
mbradley | 1:63c505e13da4 | 161 | if (ad5770r_remove(pAd5770r_dev) == SUCCESS) { |
mbradley | 1:63c505e13da4 | 162 | } else { |
mbradley | 1:63c505e13da4 | 163 | printf("\n\r *** Error doing device remove ***\n\r"); |
mbradley | 1:63c505e13da4 | 164 | } |
mbradley | 1:63c505e13da4 | 165 | |
mbradley | 1:63c505e13da4 | 166 | adi_press_any_key_to_continue(); |
mbradley | 1:63c505e13da4 | 167 | return(MENU_CONTINUE); |
mbradley | 1:63c505e13da4 | 168 | } |
mbradley | 1:63c505e13da4 | 169 | |
mbradley | 1:63c505e13da4 | 170 | /*! |
mbradley | 1:63c505e13da4 | 171 | * @brief toggles the int/ext ref resistor option |
mbradley | 1:63c505e13da4 | 172 | * |
mbradley | 1:63c505e13da4 | 173 | * @details |
mbradley | 1:63c505e13da4 | 174 | */ |
mbradley | 1:63c505e13da4 | 175 | static int32_t do_toggle_ref_resistor(uint32_t id) |
mbradley | 1:63c505e13da4 | 176 | { |
mbradley | 1:63c505e13da4 | 177 | int32_t status; |
mbradley | 1:63c505e13da4 | 178 | |
mbradley | 1:63c505e13da4 | 179 | if ((status = ad5770r_set_reference(pAd5770r_dev, |
mbradley | 1:63c505e13da4 | 180 | !pAd5770r_dev->external_reference, |
mbradley | 1:63c505e13da4 | 181 | pAd5770r_dev->reference_selector)) != SUCCESS) { |
mbradley | 1:63c505e13da4 | 182 | printf(EOL " *** Error toggling ref resistor setting: %d" EOL, status); |
mbradley | 1:63c505e13da4 | 183 | adi_press_any_key_to_continue(); |
mbradley | 1:63c505e13da4 | 184 | } |
mbradley | 1:63c505e13da4 | 185 | |
mbradley | 1:63c505e13da4 | 186 | return(MENU_CONTINUE); |
mbradley | 1:63c505e13da4 | 187 | } |
mbradley | 1:63c505e13da4 | 188 | |
mbradley | 1:63c505e13da4 | 189 | |
mbradley | 1:63c505e13da4 | 190 | /*! |
mbradley | 1:63c505e13da4 | 191 | * @brief sets the int/ext refer configuration options |
mbradley | 1:63c505e13da4 | 192 | * |
mbradley | 1:63c505e13da4 | 193 | * @details |
mbradley | 1:63c505e13da4 | 194 | */ |
mbradley | 1:63c505e13da4 | 195 | static int32_t do_set_reference(uint32_t ref_option) |
mbradley | 1:63c505e13da4 | 196 | { |
mbradley | 1:63c505e13da4 | 197 | int32_t status; |
mbradley | 1:63c505e13da4 | 198 | |
mbradley | 1:63c505e13da4 | 199 | if ((status = ad5770r_set_reference(pAd5770r_dev, |
mbradley | 1:63c505e13da4 | 200 | pAd5770r_dev->external_reference, |
mbradley | 1:63c505e13da4 | 201 | (enum ad5770r_reference_voltage)ref_option)) != SUCCESS) { |
mbradley | 1:63c505e13da4 | 202 | printf(EOL " *** Error toggling ref resistor setting: %d" EOL, status); |
mbradley | 1:63c505e13da4 | 203 | adi_press_any_key_to_continue(); |
mbradley | 1:63c505e13da4 | 204 | } |
mbradley | 1:63c505e13da4 | 205 | |
mbradley | 1:63c505e13da4 | 206 | return(MENU_CONTINUE); |
mbradley | 1:63c505e13da4 | 207 | } |
mbradley | 1:63c505e13da4 | 208 | |
mbradley | 1:63c505e13da4 | 209 | /*! |
mbradley | 1:63c505e13da4 | 210 | * @brief Sets the Alarm Menu option bits |
mbradley | 1:63c505e13da4 | 211 | * |
mbradley | 1:63c505e13da4 | 212 | * @details |
mbradley | 1:63c505e13da4 | 213 | */ |
mbradley | 1:63c505e13da4 | 214 | static int32_t do_set_alarm(uint32_t alarm_id) |
mbradley | 1:63c505e13da4 | 215 | { |
mbradley | 1:63c505e13da4 | 216 | int32_t status; |
mbradley | 1:63c505e13da4 | 217 | struct ad5770r_alarm_cfg alarm_config; |
mbradley | 1:63c505e13da4 | 218 | |
mbradley | 1:63c505e13da4 | 219 | alarm_config = pAd5770r_dev->alarm_config; |
mbradley | 1:63c505e13da4 | 220 | |
mbradley | 1:63c505e13da4 | 221 | switch(alarm_id) { |
mbradley | 1:63c505e13da4 | 222 | case AD5770R_ALARM_CONFIG_OPEN_DRAIN_EN(1): |
mbradley | 1:63c505e13da4 | 223 | alarm_config.open_drain_en = !alarm_config.open_drain_en; |
mbradley | 1:63c505e13da4 | 224 | break; |
mbradley | 1:63c505e13da4 | 225 | case AD5770R_ALARM_CONFIG_THERMAL_SHUTDOWN_EN(1): |
mbradley | 1:63c505e13da4 | 226 | alarm_config.thermal_shutdown_en = !alarm_config.thermal_shutdown_en; |
mbradley | 1:63c505e13da4 | 227 | break; |
mbradley | 1:63c505e13da4 | 228 | case AD5770R_ALARM_CONFIG_BACKGROUND_CRC_EN(1): |
mbradley | 1:63c505e13da4 | 229 | alarm_config.background_crc_en = !alarm_config.background_crc_en; |
mbradley | 1:63c505e13da4 | 230 | break; |
mbradley | 1:63c505e13da4 | 231 | case AD5770R_ALARM_CONFIG_TEMP_WARNING_ALARM_MASK(1): |
mbradley | 1:63c505e13da4 | 232 | alarm_config.temp_warning_msk = !alarm_config.temp_warning_msk; |
mbradley | 1:63c505e13da4 | 233 | break; |
mbradley | 1:63c505e13da4 | 234 | case AD5770R_ALARM_CONFIG_OVER_TEMP_ALARM_MASK(1): |
mbradley | 1:63c505e13da4 | 235 | alarm_config.over_temp_msk = !alarm_config.over_temp_msk; |
mbradley | 1:63c505e13da4 | 236 | break; |
mbradley | 1:63c505e13da4 | 237 | case AD5770R_ALARM_CONFIG_NEGATIVE_CHANNEL0_ALARM_MASK(1): |
mbradley | 1:63c505e13da4 | 238 | alarm_config.neg_ch0_msk = !alarm_config.neg_ch0_msk; |
mbradley | 1:63c505e13da4 | 239 | break; |
mbradley | 1:63c505e13da4 | 240 | case AD5770R_ALARM_CONFIG_IREF_FAULT_ALARM_MASK(1): |
mbradley | 1:63c505e13da4 | 241 | alarm_config.iref_fault_msk = !alarm_config.iref_fault_msk; |
mbradley | 1:63c505e13da4 | 242 | break; |
mbradley | 1:63c505e13da4 | 243 | case AD5770R_ALARM_CONFIG_BACKGROUND_CRC_ALARM_MASK(1): |
mbradley | 1:63c505e13da4 | 244 | alarm_config.background_crc_msk = !alarm_config.background_crc_msk; |
mbradley | 1:63c505e13da4 | 245 | break; |
mbradley | 1:63c505e13da4 | 246 | default: |
mbradley | 1:63c505e13da4 | 247 | // not a supported menu option |
mbradley | 1:63c505e13da4 | 248 | assert(false); |
mbradley | 1:63c505e13da4 | 249 | } |
mbradley | 1:63c505e13da4 | 250 | |
mbradley | 1:63c505e13da4 | 251 | if ((status = ad5770r_set_alarm(pAd5770r_dev, |
mbradley | 1:63c505e13da4 | 252 | &alarm_config)) != SUCCESS) { |
mbradley | 1:63c505e13da4 | 253 | printf(EOL " *** Error setting alarm config: %d" EOL, status); |
mbradley | 1:63c505e13da4 | 254 | adi_press_any_key_to_continue(); |
mbradley | 1:63c505e13da4 | 255 | } |
mbradley | 1:63c505e13da4 | 256 | |
mbradley | 1:63c505e13da4 | 257 | return(MENU_CONTINUE); |
mbradley | 1:63c505e13da4 | 258 | } |
mbradley | 1:63c505e13da4 | 259 | |
mbradley | 1:63c505e13da4 | 260 | /*! |
mbradley | 1:63c505e13da4 | 261 | * @brief Sets the Channel Configuration option bits |
mbradley | 1:63c505e13da4 | 262 | * |
mbradley | 1:63c505e13da4 | 263 | * @details |
mbradley | 1:63c505e13da4 | 264 | */ |
mbradley | 1:63c505e13da4 | 265 | static void ch_switches_toggle(struct ad5770r_channel_switches *ch_switches, |
mbradley | 1:63c505e13da4 | 266 | uint32_t channel_id) |
mbradley | 1:63c505e13da4 | 267 | { |
mbradley | 1:63c505e13da4 | 268 | switch(channel_id) { |
mbradley | 1:63c505e13da4 | 269 | case AD5770R_CHANNEL_CONFIG_CH0_SHUTDOWN_B(1): |
mbradley | 1:63c505e13da4 | 270 | ch_switches->en0 = !ch_switches->en0; |
mbradley | 1:63c505e13da4 | 271 | break; |
mbradley | 1:63c505e13da4 | 272 | case AD5770R_CHANNEL_CONFIG_CH1_SHUTDOWN_B(1): |
mbradley | 1:63c505e13da4 | 273 | ch_switches->en1 = !ch_switches->en1; |
mbradley | 1:63c505e13da4 | 274 | break; |
mbradley | 1:63c505e13da4 | 275 | case AD5770R_CHANNEL_CONFIG_CH2_SHUTDOWN_B(1): |
mbradley | 1:63c505e13da4 | 276 | ch_switches->en2 = !ch_switches->en2; |
mbradley | 1:63c505e13da4 | 277 | break; |
mbradley | 1:63c505e13da4 | 278 | case AD5770R_CHANNEL_CONFIG_CH3_SHUTDOWN_B(1): |
mbradley | 1:63c505e13da4 | 279 | ch_switches->en3 = !ch_switches->en3; |
mbradley | 1:63c505e13da4 | 280 | break; |
mbradley | 1:63c505e13da4 | 281 | case AD5770R_CHANNEL_CONFIG_CH4_SHUTDOWN_B(1): |
mbradley | 1:63c505e13da4 | 282 | ch_switches->en4 = !ch_switches->en4; |
mbradley | 1:63c505e13da4 | 283 | break; |
mbradley | 1:63c505e13da4 | 284 | case AD5770R_CHANNEL_CONFIG_CH5_SHUTDOWN_B(1): |
mbradley | 1:63c505e13da4 | 285 | ch_switches->en5 = !ch_switches->en5; |
mbradley | 1:63c505e13da4 | 286 | break; |
mbradley | 1:63c505e13da4 | 287 | case AD5770R_CHANNEL_CONFIG_CH0_SINK_EN(1): |
mbradley | 1:63c505e13da4 | 288 | ch_switches->sink0 = !ch_switches->sink0; |
mbradley | 1:63c505e13da4 | 289 | break; |
mbradley | 1:63c505e13da4 | 290 | default: |
mbradley | 1:63c505e13da4 | 291 | // not a supported menu option |
mbradley | 1:63c505e13da4 | 292 | assert(false); |
mbradley | 1:63c505e13da4 | 293 | } |
mbradley | 1:63c505e13da4 | 294 | } |
mbradley | 1:63c505e13da4 | 295 | |
mbradley | 1:63c505e13da4 | 296 | /*! |
mbradley | 1:63c505e13da4 | 297 | * @brief Sets the Channel Configuration option bits |
mbradley | 1:63c505e13da4 | 298 | * |
mbradley | 1:63c505e13da4 | 299 | * @details |
mbradley | 1:63c505e13da4 | 300 | */ |
mbradley | 1:63c505e13da4 | 301 | static int32_t do_channel_config(uint32_t channel_id) |
mbradley | 1:63c505e13da4 | 302 | { |
mbradley | 1:63c505e13da4 | 303 | int32_t status; |
mbradley | 1:63c505e13da4 | 304 | struct ad5770r_channel_switches channel_config; |
mbradley | 1:63c505e13da4 | 305 | |
mbradley | 1:63c505e13da4 | 306 | channel_config = pAd5770r_dev->channel_config; |
mbradley | 1:63c505e13da4 | 307 | |
mbradley | 1:63c505e13da4 | 308 | ch_switches_toggle(&channel_config, channel_id); |
mbradley | 1:63c505e13da4 | 309 | |
mbradley | 1:63c505e13da4 | 310 | if ((status = ad5770r_channel_config(pAd5770r_dev, |
mbradley | 1:63c505e13da4 | 311 | &channel_config)) != SUCCESS) { |
mbradley | 1:63c505e13da4 | 312 | printf(EOL " *** Error setting channel config: %d" EOL, status); |
mbradley | 1:63c505e13da4 | 313 | adi_press_any_key_to_continue(); |
mbradley | 1:63c505e13da4 | 314 | } |
mbradley | 1:63c505e13da4 | 315 | |
mbradley | 1:63c505e13da4 | 316 | return(MENU_CONTINUE); |
mbradley | 1:63c505e13da4 | 317 | } |
mbradley | 1:63c505e13da4 | 318 | |
mbradley | 1:63c505e13da4 | 319 | /*! |
mbradley | 1:63c505e13da4 | 320 | * @brief prompts user for value to write to input register on channel |
mbradley | 1:63c505e13da4 | 321 | * |
mbradley | 1:63c505e13da4 | 322 | * @details |
mbradley | 1:63c505e13da4 | 323 | */ |
mbradley | 1:63c505e13da4 | 324 | static int32_t do_input_value(uint32_t channel_id) |
mbradley | 1:63c505e13da4 | 325 | { |
mbradley | 1:63c505e13da4 | 326 | int32_t status; |
mbradley | 1:63c505e13da4 | 327 | uint16_t value; |
mbradley | 1:63c505e13da4 | 328 | |
mbradley | 1:63c505e13da4 | 329 | printf(EOL "Enter Input register value (hex) for channel %d: " EOL, |
mbradley | 1:63c505e13da4 | 330 | channel_id); |
mbradley | 1:63c505e13da4 | 331 | value = adi_get_hex_integer(4); |
mbradley | 1:63c505e13da4 | 332 | |
mbradley | 1:63c505e13da4 | 333 | /* Channels are 14-bits, mask off top 2 bits*/ |
mbradley | 1:63c505e13da4 | 334 | value &= 0x3FFF; |
mbradley | 1:63c505e13da4 | 335 | |
mbradley | 1:63c505e13da4 | 336 | if ((status = |
mbradley | 1:63c505e13da4 | 337 | ad5770r_set_dac_input(pAd5770r_dev, value, |
mbradley | 1:63c505e13da4 | 338 | (enum ad5770r_channels) channel_id)) != SUCCESS) { |
mbradley | 1:63c505e13da4 | 339 | printf(EOL " *** Error writing DAC Input register: %d" EOL, status); |
mbradley | 1:63c505e13da4 | 340 | adi_press_any_key_to_continue(); |
mbradley | 1:63c505e13da4 | 341 | } |
mbradley | 1:63c505e13da4 | 342 | |
mbradley | 1:63c505e13da4 | 343 | return(MENU_CONTINUE); |
mbradley | 1:63c505e13da4 | 344 | } |
mbradley | 1:63c505e13da4 | 345 | |
mbradley | 1:63c505e13da4 | 346 | /*! |
mbradley | 1:63c505e13da4 | 347 | * @brief prompts user for value to write to input register on channel |
mbradley | 1:63c505e13da4 | 348 | * |
mbradley | 1:63c505e13da4 | 349 | * @details |
mbradley | 1:63c505e13da4 | 350 | */ |
mbradley | 1:63c505e13da4 | 351 | static int32_t do_dac_value(uint32_t channel_id) |
mbradley | 1:63c505e13da4 | 352 | { |
mbradley | 1:63c505e13da4 | 353 | int32_t status; |
mbradley | 1:63c505e13da4 | 354 | uint16_t value; |
mbradley | 1:63c505e13da4 | 355 | |
mbradley | 1:63c505e13da4 | 356 | printf(EOL "Enter DAC register value (hex) for channel %d: " EOL, channel_id); |
mbradley | 1:63c505e13da4 | 357 | value = adi_get_hex_integer(4); |
mbradley | 1:63c505e13da4 | 358 | |
mbradley | 1:63c505e13da4 | 359 | /* Channels are 14-bits, mask off top 2 bits*/ |
mbradley | 1:63c505e13da4 | 360 | value &= 0x3FFF; |
mbradley | 1:63c505e13da4 | 361 | |
mbradley | 1:63c505e13da4 | 362 | if ((status = |
mbradley | 1:63c505e13da4 | 363 | ad5770r_set_dac_value(pAd5770r_dev, value, |
mbradley | 1:63c505e13da4 | 364 | (enum ad5770r_channels) channel_id)) != SUCCESS) { |
mbradley | 1:63c505e13da4 | 365 | printf(EOL " *** Error writing DAC value register: %d" EOL, status); |
mbradley | 1:63c505e13da4 | 366 | adi_press_any_key_to_continue(); |
mbradley | 1:63c505e13da4 | 367 | } |
mbradley | 1:63c505e13da4 | 368 | |
mbradley | 1:63c505e13da4 | 369 | return(MENU_CONTINUE); |
mbradley | 1:63c505e13da4 | 370 | } |
mbradley | 1:63c505e13da4 | 371 | |
mbradley | 1:63c505e13da4 | 372 | /*! |
mbradley | 1:63c505e13da4 | 373 | * @brief updating shadow SW LDAC, by toggling the channel bit |
mbradley | 1:63c505e13da4 | 374 | * |
mbradley | 1:63c505e13da4 | 375 | * @details |
mbradley | 1:63c505e13da4 | 376 | */ |
mbradley | 1:63c505e13da4 | 377 | static int32_t do_sw_ldac(uint32_t channel_id) |
mbradley | 1:63c505e13da4 | 378 | { |
mbradley | 1:63c505e13da4 | 379 | ch_switches_toggle(&sw_ldac_shadow, channel_id); |
mbradley | 1:63c505e13da4 | 380 | |
mbradley | 1:63c505e13da4 | 381 | return(MENU_CONTINUE); |
mbradley | 1:63c505e13da4 | 382 | } |
mbradley | 1:63c505e13da4 | 383 | |
mbradley | 1:63c505e13da4 | 384 | /*! |
mbradley | 1:63c505e13da4 | 385 | * @brief Writing SW LDAC to device |
mbradley | 1:63c505e13da4 | 386 | * |
mbradley | 1:63c505e13da4 | 387 | * @details |
mbradley | 1:63c505e13da4 | 388 | */ |
mbradley | 1:63c505e13da4 | 389 | static int32_t do_sw_ldac_write(uint32_t id) |
mbradley | 1:63c505e13da4 | 390 | { |
mbradley | 1:63c505e13da4 | 391 | int32_t status; |
mbradley | 1:63c505e13da4 | 392 | |
mbradley | 1:63c505e13da4 | 393 | if ((status = ad5770r_set_sw_ldac(pAd5770r_dev, |
mbradley | 1:63c505e13da4 | 394 | &sw_ldac_shadow)) != SUCCESS) { |
mbradley | 1:63c505e13da4 | 395 | printf(EOL " *** Error writing SW LDAC: %d" EOL, status); |
mbradley | 1:63c505e13da4 | 396 | adi_press_any_key_to_continue(); |
mbradley | 1:63c505e13da4 | 397 | } |
mbradley | 1:63c505e13da4 | 398 | |
mbradley | 1:63c505e13da4 | 399 | return(MENU_CONTINUE); |
mbradley | 1:63c505e13da4 | 400 | } |
mbradley | 1:63c505e13da4 | 401 | |
mbradley | 1:63c505e13da4 | 402 | /*! |
mbradley | 1:63c505e13da4 | 403 | * @brief Toggles HW LDAC |
mbradley | 1:63c505e13da4 | 404 | * |
mbradley | 1:63c505e13da4 | 405 | * @details This toggles the LDAC pin on the device, but is independent to the driver |
mbradley | 1:63c505e13da4 | 406 | * Therefore this does not update dac_values from input values. |
mbradley | 1:63c505e13da4 | 407 | */ |
mbradley | 1:63c505e13da4 | 408 | static int32_t do_hw_ldac_toggle(uint32_t id) |
mbradley | 1:63c505e13da4 | 409 | { |
mbradley | 1:63c505e13da4 | 410 | int32_t status; |
mbradley | 1:63c505e13da4 | 411 | |
mbradley | 1:63c505e13da4 | 412 | do { |
mbradley | 1:63c505e13da4 | 413 | if ((status = gpio_set_value(hw_ldacb_desc, GPIO_LOW)) == FAILURE) { |
mbradley | 1:63c505e13da4 | 414 | break; |
mbradley | 1:63c505e13da4 | 415 | } |
mbradley | 1:63c505e13da4 | 416 | mdelay(1); |
mbradley | 1:63c505e13da4 | 417 | if ((status = gpio_set_value(hw_ldacb_desc, GPIO_HIGH)) == FAILURE) { |
mbradley | 1:63c505e13da4 | 418 | break; |
mbradley | 1:63c505e13da4 | 419 | } |
mbradley | 1:63c505e13da4 | 420 | } while (0); |
mbradley | 1:63c505e13da4 | 421 | |
mbradley | 1:63c505e13da4 | 422 | if (status == SUCCESS) { |
mbradley | 1:63c505e13da4 | 423 | printf(EOL " --- HW LDAC toggled ---" EOL); |
mbradley | 1:63c505e13da4 | 424 | } else { |
mbradley | 1:63c505e13da4 | 425 | printf(EOL " *** Error toggling HW LDACB ***" EOL); |
mbradley | 1:63c505e13da4 | 426 | } |
mbradley | 1:63c505e13da4 | 427 | |
mbradley | 1:63c505e13da4 | 428 | |
mbradley | 1:63c505e13da4 | 429 | adi_press_any_key_to_continue(); |
mbradley | 1:63c505e13da4 | 430 | |
mbradley | 1:63c505e13da4 | 431 | return(MENU_CONTINUE); |
mbradley | 1:63c505e13da4 | 432 | } |
mbradley | 1:63c505e13da4 | 433 | |
mbradley | 1:63c505e13da4 | 434 | /*! |
mbradley | 1:63c505e13da4 | 435 | * @brief displays general device configuration state |
mbradley | 1:63c505e13da4 | 436 | * |
mbradley | 1:63c505e13da4 | 437 | * @details |
mbradley | 1:63c505e13da4 | 438 | */ |
mbradley | 1:63c505e13da4 | 439 | static void display_gen_config(void) |
mbradley | 1:63c505e13da4 | 440 | { |
mbradley | 1:63c505e13da4 | 441 | printf("\tRef Resistor: %s\t\tRef Voltage: %d" EOL, |
mbradley | 1:63c505e13da4 | 442 | pAd5770r_dev->external_reference == true ? "External" : "Internal", |
mbradley | 1:63c505e13da4 | 443 | pAd5770r_dev->reference_selector); |
mbradley | 1:63c505e13da4 | 444 | |
mbradley | 1:63c505e13da4 | 445 | printf("\tAlarms\tBgCRC Msk: %d\tIRef: %d\tneg: %d\tOT: %d " EOL \ |
mbradley | 1:63c505e13da4 | 446 | "\t\tT Warn: %d\tBgCRC En: %d\tT Shdn: %d\tOD: %d" EOL, |
mbradley | 1:63c505e13da4 | 447 | pAd5770r_dev->alarm_config.background_crc_msk, |
mbradley | 1:63c505e13da4 | 448 | pAd5770r_dev->alarm_config.iref_fault_msk, |
mbradley | 1:63c505e13da4 | 449 | pAd5770r_dev->alarm_config.neg_ch0_msk, |
mbradley | 1:63c505e13da4 | 450 | pAd5770r_dev->alarm_config.over_temp_msk, |
mbradley | 1:63c505e13da4 | 451 | pAd5770r_dev->alarm_config.temp_warning_msk, |
mbradley | 1:63c505e13da4 | 452 | pAd5770r_dev->alarm_config.background_crc_en, |
mbradley | 1:63c505e13da4 | 453 | pAd5770r_dev->alarm_config.thermal_shutdown_en, |
mbradley | 1:63c505e13da4 | 454 | pAd5770r_dev->alarm_config.open_drain_en); |
mbradley | 1:63c505e13da4 | 455 | } |
mbradley | 1:63c505e13da4 | 456 | |
mbradley | 1:63c505e13da4 | 457 | /*! |
mbradley | 1:63c505e13da4 | 458 | * @brief displays general device configuration state |
mbradley | 1:63c505e13da4 | 459 | * |
mbradley | 1:63c505e13da4 | 460 | * @details |
mbradley | 1:63c505e13da4 | 461 | */ |
mbradley | 1:63c505e13da4 | 462 | static void print_channel_switches(struct ad5770r_channel_switches *ch_switches, |
mbradley | 1:63c505e13da4 | 463 | char * prefix, bool include_sink) |
mbradley | 1:63c505e13da4 | 464 | { |
mbradley | 1:63c505e13da4 | 465 | if (include_sink) { |
mbradley | 1:63c505e13da4 | 466 | printf("\t%s - en0: %d sink0: %d en1: %d en2: %d " \ |
mbradley | 1:63c505e13da4 | 467 | "en3: %d en4: %d en5: %d" EOL, prefix, |
mbradley | 1:63c505e13da4 | 468 | ch_switches->en0, ch_switches->sink0, ch_switches->en1, |
mbradley | 1:63c505e13da4 | 469 | ch_switches->en2, ch_switches->en3, ch_switches->en4, |
mbradley | 1:63c505e13da4 | 470 | ch_switches->en5); |
mbradley | 1:63c505e13da4 | 471 | } else { |
mbradley | 1:63c505e13da4 | 472 | printf("\t%s - ch0: %d ch1: %d ch2: %d " \ |
mbradley | 1:63c505e13da4 | 473 | "ch3: %d ch4: %d ch5: %d" EOL, prefix, |
mbradley | 1:63c505e13da4 | 474 | ch_switches->en0, ch_switches->en1, ch_switches->en2, |
mbradley | 1:63c505e13da4 | 475 | ch_switches->en3, ch_switches->en4, ch_switches->en5); |
mbradley | 1:63c505e13da4 | 476 | } |
mbradley | 1:63c505e13da4 | 477 | } |
mbradley | 1:63c505e13da4 | 478 | |
mbradley | 1:63c505e13da4 | 479 | /*! |
mbradley | 1:63c505e13da4 | 480 | * @brief displays general device configuration state |
mbradley | 1:63c505e13da4 | 481 | * |
mbradley | 1:63c505e13da4 | 482 | * @details |
mbradley | 1:63c505e13da4 | 483 | */ |
mbradley | 1:63c505e13da4 | 484 | static void display_dac_channel_configuration_header(void) |
mbradley | 1:63c505e13da4 | 485 | { |
mbradley | 1:63c505e13da4 | 486 | print_channel_switches(&pAd5770r_dev->channel_config, "Ch Configs", true); |
mbradley | 1:63c505e13da4 | 487 | } |
mbradley | 1:63c505e13da4 | 488 | |
mbradley | 1:63c505e13da4 | 489 | /*! |
mbradley | 1:63c505e13da4 | 490 | * @brief displays the SW LDAC shadown and other channel output values |
mbradley | 1:63c505e13da4 | 491 | * |
mbradley | 1:63c505e13da4 | 492 | * @details |
mbradley | 1:63c505e13da4 | 493 | */ |
mbradley | 1:63c505e13da4 | 494 | static void display_dac_operations_header(void) |
mbradley | 1:63c505e13da4 | 495 | { |
mbradley | 1:63c505e13da4 | 496 | for (uint8_t i = 0; i < 6 ; i++) { |
mbradley | 1:63c505e13da4 | 497 | printf("\tCh %i - Input: 0x%04X \t\tDAC: 0x%04X" EOL, i, |
mbradley | 1:63c505e13da4 | 498 | pAd5770r_dev->input_value[i], pAd5770r_dev->dac_value[i]); |
mbradley | 1:63c505e13da4 | 499 | } |
mbradley | 1:63c505e13da4 | 500 | |
mbradley | 1:63c505e13da4 | 501 | printf(EOL); |
mbradley | 1:63c505e13da4 | 502 | print_channel_switches(&sw_ldac_shadow, "SW LDAC shadow", false); |
mbradley | 1:63c505e13da4 | 503 | } |
mbradley | 1:63c505e13da4 | 504 | /*! |
mbradley | 1:63c505e13da4 | 505 | * @brief prints the provided monitor config to the terminal |
mbradley | 1:63c505e13da4 | 506 | * |
mbradley | 1:63c505e13da4 | 507 | * @details |
mbradley | 1:63c505e13da4 | 508 | * @param ad5770R_monitor_config monitor_config - struct for the monitor config to be displayed |
mbradley | 1:63c505e13da4 | 509 | * @return SUCCESS in case of success, negative error otherwise |
mbradley | 1:63c505e13da4 | 510 | */ |
mbradley | 1:63c505e13da4 | 511 | static void print_monitor_setup(const struct ad5770r_monitor_setup * mon_setup) |
mbradley | 1:63c505e13da4 | 512 | { |
mbradley | 1:63c505e13da4 | 513 | printf("\tMonitor: "); |
mbradley | 1:63c505e13da4 | 514 | switch (mon_setup->monitor_function) { |
mbradley | 1:63c505e13da4 | 515 | case AD5770R_DISABLE: { |
mbradley | 1:63c505e13da4 | 516 | printf("Disabled "); |
mbradley | 1:63c505e13da4 | 517 | break; |
mbradley | 1:63c505e13da4 | 518 | } |
mbradley | 1:63c505e13da4 | 519 | case AD5770R_VOLTAGE_MONITORING: { |
mbradley | 1:63c505e13da4 | 520 | printf("Voltage Ch %d", mon_setup->monitor_channel); |
mbradley | 1:63c505e13da4 | 521 | break; |
mbradley | 1:63c505e13da4 | 522 | } |
mbradley | 1:63c505e13da4 | 523 | case AD5770R_CURRENT_MONITORING: { |
mbradley | 1:63c505e13da4 | 524 | printf("Current Ch %d", mon_setup->monitor_channel); |
mbradley | 1:63c505e13da4 | 525 | break; |
mbradley | 1:63c505e13da4 | 526 | } |
mbradley | 1:63c505e13da4 | 527 | case AD5770R_TEMPERATURE_MONITORING: { |
mbradley | 1:63c505e13da4 | 528 | printf("Temperature"); |
mbradley | 1:63c505e13da4 | 529 | break; |
mbradley | 1:63c505e13da4 | 530 | } |
mbradley | 1:63c505e13da4 | 531 | } |
mbradley | 1:63c505e13da4 | 532 | |
mbradley | 1:63c505e13da4 | 533 | printf("\tBuffer: "); |
mbradley | 1:63c505e13da4 | 534 | if (mon_setup->mux_buffer == true) { |
mbradley | 1:63c505e13da4 | 535 | printf("On"); |
mbradley | 1:63c505e13da4 | 536 | } else { |
mbradley | 1:63c505e13da4 | 537 | printf("Off"); |
mbradley | 1:63c505e13da4 | 538 | } |
mbradley | 1:63c505e13da4 | 539 | |
mbradley | 1:63c505e13da4 | 540 | printf("\tIB_Ext: "); |
mbradley | 1:63c505e13da4 | 541 | if (mon_setup->ib_ext_en == true) { |
mbradley | 1:63c505e13da4 | 542 | printf("On"); |
mbradley | 1:63c505e13da4 | 543 | } else { |
mbradley | 1:63c505e13da4 | 544 | printf("Off"); |
mbradley | 1:63c505e13da4 | 545 | } |
mbradley | 1:63c505e13da4 | 546 | printf(EOL); |
mbradley | 1:63c505e13da4 | 547 | } |
mbradley | 1:63c505e13da4 | 548 | |
mbradley | 1:63c505e13da4 | 549 | /*! |
mbradley | 1:63c505e13da4 | 550 | * @brief configure the Mux Monitor setup |
mbradley | 1:63c505e13da4 | 551 | * |
mbradley | 1:63c505e13da4 | 552 | * @details |
mbradley | 1:63c505e13da4 | 553 | */ |
mbradley | 1:63c505e13da4 | 554 | static void display_monitor_setup_header(void) |
mbradley | 1:63c505e13da4 | 555 | { |
mbradley | 1:63c505e13da4 | 556 | print_monitor_setup(&pAd5770r_dev->mon_setup); |
mbradley | 1:63c505e13da4 | 557 | } |
mbradley | 1:63c505e13da4 | 558 | |
mbradley | 1:63c505e13da4 | 559 | /*! |
mbradley | 1:63c505e13da4 | 560 | * @brief configure the Mux Monitor setup |
mbradley | 1:63c505e13da4 | 561 | * |
mbradley | 1:63c505e13da4 | 562 | * @details |
mbradley | 1:63c505e13da4 | 563 | */ |
mbradley | 1:63c505e13da4 | 564 | static int32_t do_monitor_setup(uint32_t id) |
mbradley | 1:63c505e13da4 | 565 | { |
mbradley | 1:63c505e13da4 | 566 | int32_t status; |
mbradley | 1:63c505e13da4 | 567 | struct ad5770r_monitor_setup monitor_setup; |
mbradley | 1:63c505e13da4 | 568 | |
mbradley | 1:63c505e13da4 | 569 | monitor_setup = pAd5770r_dev->mon_setup; |
mbradley | 1:63c505e13da4 | 570 | |
mbradley | 1:63c505e13da4 | 571 | switch(id) { |
mbradley | 1:63c505e13da4 | 572 | case AD5770R_DISABLE: |
mbradley | 1:63c505e13da4 | 573 | monitor_setup.monitor_function = AD5770R_DISABLE; |
mbradley | 1:63c505e13da4 | 574 | break; |
mbradley | 1:63c505e13da4 | 575 | case AD5770R_VOLTAGE_MONITORING: |
mbradley | 1:63c505e13da4 | 576 | monitor_setup.monitor_function = AD5770R_VOLTAGE_MONITORING; |
mbradley | 1:63c505e13da4 | 577 | break; |
mbradley | 1:63c505e13da4 | 578 | case AD5770R_CURRENT_MONITORING: |
mbradley | 1:63c505e13da4 | 579 | monitor_setup.monitor_function = AD5770R_CURRENT_MONITORING; |
mbradley | 1:63c505e13da4 | 580 | break; |
mbradley | 1:63c505e13da4 | 581 | case AD5770R_TEMPERATURE_MONITORING: |
mbradley | 1:63c505e13da4 | 582 | monitor_setup.monitor_function = AD5770R_TEMPERATURE_MONITORING; |
mbradley | 1:63c505e13da4 | 583 | break; |
mbradley | 1:63c505e13da4 | 584 | case TOGGLE_MUX_BUFFER: |
mbradley | 1:63c505e13da4 | 585 | monitor_setup.mux_buffer = !monitor_setup.mux_buffer; |
mbradley | 1:63c505e13da4 | 586 | break; |
mbradley | 1:63c505e13da4 | 587 | case TOGGLE_DIODE_EXT_BIAS: |
mbradley | 1:63c505e13da4 | 588 | monitor_setup.ib_ext_en = !monitor_setup.ib_ext_en; |
mbradley | 1:63c505e13da4 | 589 | break; |
mbradley | 1:63c505e13da4 | 590 | default: |
mbradley | 1:63c505e13da4 | 591 | // ensure the id is valid. |
mbradley | 1:63c505e13da4 | 592 | assert(( id >= AD5770R_CH0 + MENU_CHANNEL_OFFSET ) |
mbradley | 1:63c505e13da4 | 593 | && (id <= AD5770R_CH5 + MENU_CHANNEL_OFFSET)); |
mbradley | 1:63c505e13da4 | 594 | monitor_setup.monitor_channel = (enum ad5770r_channels)( |
mbradley | 1:63c505e13da4 | 595 | id - MENU_CHANNEL_OFFSET); |
mbradley | 1:63c505e13da4 | 596 | } |
mbradley | 1:63c505e13da4 | 597 | |
mbradley | 1:63c505e13da4 | 598 | if ((status = ad5770r_set_monitor_setup(pAd5770r_dev, |
mbradley | 1:63c505e13da4 | 599 | &monitor_setup)) != SUCCESS) { |
mbradley | 1:63c505e13da4 | 600 | printf(EOL " *** Error setting monitor setup: %d" EOL, status); |
mbradley | 1:63c505e13da4 | 601 | adi_press_any_key_to_continue(); |
mbradley | 1:63c505e13da4 | 602 | } |
mbradley | 1:63c505e13da4 | 603 | |
mbradley | 1:63c505e13da4 | 604 | return(MENU_CONTINUE); |
mbradley | 1:63c505e13da4 | 605 | } |
mbradley | 1:63c505e13da4 | 606 | |
mbradley | 1:63c505e13da4 | 607 | /*! |
mbradley | 1:63c505e13da4 | 608 | * @brief displays several pieces of status information above main menu |
mbradley | 1:63c505e13da4 | 609 | * |
mbradley | 1:63c505e13da4 | 610 | * @details |
mbradley | 1:63c505e13da4 | 611 | */ |
mbradley | 1:63c505e13da4 | 612 | static void display_main_menu_header(void) |
mbradley | 1:63c505e13da4 | 613 | { |
mbradley | 1:63c505e13da4 | 614 | int32_t ret; |
mbradley | 1:63c505e13da4 | 615 | uint8_t device_status = 0, interface_status = 0, scratchpad = 0; |
mbradley | 1:63c505e13da4 | 616 | |
mbradley | 1:63c505e13da4 | 617 | if (pAd5770r_dev == NULL) { |
mbradley | 1:63c505e13da4 | 618 | printf(EOL " *** Device Not Initialized ***" EOL); |
mbradley | 1:63c505e13da4 | 619 | return; |
mbradley | 1:63c505e13da4 | 620 | } |
mbradley | 1:63c505e13da4 | 621 | |
mbradley | 1:63c505e13da4 | 622 | do { |
mbradley | 1:63c505e13da4 | 623 | if ((ret = ad5770r_get_status(pAd5770r_dev, &device_status)) != SUCCESS) { |
mbradley | 1:63c505e13da4 | 624 | break; |
mbradley | 1:63c505e13da4 | 625 | } |
mbradley | 1:63c505e13da4 | 626 | if ((ret = ad5770r_get_interface_status(pAd5770r_dev, |
mbradley | 1:63c505e13da4 | 627 | &interface_status)) != SUCCESS) { |
mbradley | 1:63c505e13da4 | 628 | break; |
mbradley | 1:63c505e13da4 | 629 | } |
mbradley | 1:63c505e13da4 | 630 | if ((ret = ad5770r_spi_reg_read(pAd5770r_dev, AD5770R_SCRATCH_PAD, |
mbradley | 1:63c505e13da4 | 631 | &scratchpad)) != SUCCESS) { |
mbradley | 1:63c505e13da4 | 632 | break; |
mbradley | 1:63c505e13da4 | 633 | } |
mbradley | 1:63c505e13da4 | 634 | |
mbradley | 1:63c505e13da4 | 635 | } while(0); |
mbradley | 1:63c505e13da4 | 636 | |
mbradley | 1:63c505e13da4 | 637 | if (ret != SUCCESS) { |
mbradley | 1:63c505e13da4 | 638 | printf(EOL " *** Error in display state: %d **" EOL, ret); |
mbradley | 1:63c505e13da4 | 639 | } |
mbradley | 1:63c505e13da4 | 640 | |
mbradley | 1:63c505e13da4 | 641 | printf(EOL "\tInterface Status = 0x%02X\t\tDevice Status = 0x%02X" |
mbradley | 1:63c505e13da4 | 642 | EOL "\tScratchpad = 0x%02X" EOL, |
mbradley | 1:63c505e13da4 | 643 | interface_status, device_status, scratchpad); |
mbradley | 1:63c505e13da4 | 644 | print_monitor_setup(&pAd5770r_dev->mon_setup); |
mbradley | 1:63c505e13da4 | 645 | |
mbradley | 1:63c505e13da4 | 646 | // Increment the scratchpad by 1 to show a +1 delta in footer |
mbradley | 1:63c505e13da4 | 647 | if((ret = ad5770r_spi_reg_write(pAd5770r_dev, AD5770R_SCRATCH_PAD, |
mbradley | 1:63c505e13da4 | 648 | scratchpad + 1)) != SUCCESS) { |
mbradley | 1:63c505e13da4 | 649 | printf(EOL " *** Error writing scratchpad + 1 : %d **" EOL, ret); |
mbradley | 1:63c505e13da4 | 650 | } |
mbradley | 1:63c505e13da4 | 651 | } |
mbradley | 1:63c505e13da4 | 652 | |
mbradley | 1:63c505e13da4 | 653 | /*! |
mbradley | 1:63c505e13da4 | 654 | * @brief displays several pieces of status information below main menu |
mbradley | 1:63c505e13da4 | 655 | * |
mbradley | 1:63c505e13da4 | 656 | * @details |
mbradley | 1:63c505e13da4 | 657 | */ |
mbradley | 1:63c505e13da4 | 658 | static void display_main_menu_footer(void) |
mbradley | 1:63c505e13da4 | 659 | { |
mbradley | 1:63c505e13da4 | 660 | int32_t ret; |
mbradley | 1:63c505e13da4 | 661 | uint8_t scratchpad; |
mbradley | 1:63c505e13da4 | 662 | |
mbradley | 1:63c505e13da4 | 663 | if (pAd5770r_dev == NULL) { |
mbradley | 1:63c505e13da4 | 664 | printf(EOL " *** Device Not Initialized ***" EOL); |
mbradley | 1:63c505e13da4 | 665 | return; |
mbradley | 1:63c505e13da4 | 666 | } |
mbradley | 1:63c505e13da4 | 667 | |
mbradley | 1:63c505e13da4 | 668 | if ((ret = ad5770r_spi_reg_read(pAd5770r_dev, AD5770R_SCRATCH_PAD, |
mbradley | 1:63c505e13da4 | 669 | &scratchpad)) != SUCCESS) { |
mbradley | 1:63c505e13da4 | 670 | printf(EOL " *** Error reading scratchpad: %d **" EOL, ret); |
mbradley | 1:63c505e13da4 | 671 | } |
mbradley | 1:63c505e13da4 | 672 | |
mbradley | 1:63c505e13da4 | 673 | printf(EOL "\tScratchpad = 0x%02X" EOL, scratchpad); |
mbradley | 1:63c505e13da4 | 674 | } |
mbradley | 1:63c505e13da4 | 675 | |
mbradley | 1:63c505e13da4 | 676 | /*! |
mbradley | 1:63c505e13da4 | 677 | * @brief calls the general configuration menu |
mbradley | 1:63c505e13da4 | 678 | */ |
mbradley | 1:63c505e13da4 | 679 | static int32_t do_general_configuration_menu(uint32_t id) |
mbradley | 1:63c505e13da4 | 680 | { |
mbradley | 1:63c505e13da4 | 681 | return adi_do_console_menu(&general_configuration_menu); |
mbradley | 1:63c505e13da4 | 682 | } |
mbradley | 1:63c505e13da4 | 683 | |
mbradley | 1:63c505e13da4 | 684 | /*! |
mbradley | 1:63c505e13da4 | 685 | * @brief calls the monitor setup menu |
mbradley | 1:63c505e13da4 | 686 | */ |
mbradley | 1:63c505e13da4 | 687 | static int32_t do_monitor_setup_menu(uint32_t id) |
mbradley | 1:63c505e13da4 | 688 | { |
mbradley | 1:63c505e13da4 | 689 | return adi_do_console_menu(&monitor_setup_menu); |
mbradley | 1:63c505e13da4 | 690 | } |
mbradley | 1:63c505e13da4 | 691 | |
mbradley | 1:63c505e13da4 | 692 | /*! |
mbradley | 1:63c505e13da4 | 693 | * @brief calls the DAC channel confguration menu |
mbradley | 1:63c505e13da4 | 694 | */ |
mbradley | 1:63c505e13da4 | 695 | static int32_t do_dac_channel_configuration_menu(uint32_t id) |
mbradley | 1:63c505e13da4 | 696 | { |
mbradley | 1:63c505e13da4 | 697 | return adi_do_console_menu(&dac_channel_configuration_menu); |
mbradley | 1:63c505e13da4 | 698 | } |
mbradley | 1:63c505e13da4 | 699 | |
mbradley | 1:63c505e13da4 | 700 | /*! |
mbradley | 1:63c505e13da4 | 701 | * @brief calls the DAC channel confguration menu |
mbradley | 1:63c505e13da4 | 702 | */ |
mbradley | 1:63c505e13da4 | 703 | static int32_t do_dac_operations_menu(uint32_t id) |
mbradley | 1:63c505e13da4 | 704 | { |
mbradley | 1:63c505e13da4 | 705 | return adi_do_console_menu(&dac_operations_menu); |
mbradley | 1:63c505e13da4 | 706 | } |
mbradley | 1:63c505e13da4 | 707 | |
mbradley | 1:63c505e13da4 | 708 | /* |
mbradley | 1:63c505e13da4 | 709 | * DAC Operations Menu |
mbradley | 1:63c505e13da4 | 710 | */ |
mbradley | 1:63c505e13da4 | 711 | static console_menu_item dac_operations_menu_items[] = { |
mbradley | 1:63c505e13da4 | 712 | {"\tSet Input Channel 0", 'Q', do_input_value, 0}, |
mbradley | 1:63c505e13da4 | 713 | {"\tSet Input Channel 1", 'W', do_input_value, 1}, |
mbradley | 1:63c505e13da4 | 714 | {"\tSet Input Channel 2", 'E', do_input_value, 2}, |
mbradley | 1:63c505e13da4 | 715 | {"\tSet Input Channel 3", 'R', do_input_value, 3}, |
mbradley | 1:63c505e13da4 | 716 | {"\tSet Input Channel 4", 'T', do_input_value, 4}, |
mbradley | 1:63c505e13da4 | 717 | {"\tSet Input Channel 5", 'Y', do_input_value, 5}, |
mbradley | 1:63c505e13da4 | 718 | {""}, |
mbradley | 1:63c505e13da4 | 719 | {"\tToggle Channel 0 SW LDAC Shadow", '0', do_sw_ldac, AD5770R_HW_LDAC_MASK_CH(1, 0)}, |
mbradley | 1:63c505e13da4 | 720 | {"\tToggle Channel 1 SW LDAC Shadow", '1', do_sw_ldac, AD5770R_HW_LDAC_MASK_CH(1, 1)}, |
mbradley | 1:63c505e13da4 | 721 | {"\tToggle Channel 2 SW LDAC Shadow", '2', do_sw_ldac, AD5770R_HW_LDAC_MASK_CH(1, 2)}, |
mbradley | 1:63c505e13da4 | 722 | {"\tToggle Channel 3 SW LDAC Shadow", '3', do_sw_ldac, AD5770R_HW_LDAC_MASK_CH(1, 3)}, |
mbradley | 1:63c505e13da4 | 723 | {"\tToggle Channel 4 SW LDAC Shadow", '4', do_sw_ldac, AD5770R_HW_LDAC_MASK_CH(1, 4)}, |
mbradley | 1:63c505e13da4 | 724 | {"\tToggle Channel 5 SW LDAC Shadow", '5', do_sw_ldac, AD5770R_HW_LDAC_MASK_CH(1, 5)}, |
mbradley | 1:63c505e13da4 | 725 | {"\tWrite SW LDAC Shadow ", 'U', do_sw_ldac_write}, |
mbradley | 1:63c505e13da4 | 726 | {""}, |
mbradley | 1:63c505e13da4 | 727 | {"\tToggle HW LDAC digital input", 'J', do_hw_ldac_toggle}, |
mbradley | 1:63c505e13da4 | 728 | {""}, |
mbradley | 1:63c505e13da4 | 729 | {"\tSet DAC Channel 0", 'A', do_dac_value, 0}, |
mbradley | 1:63c505e13da4 | 730 | {"\tSet DAC Channel 1", 'S', do_dac_value, 1}, |
mbradley | 1:63c505e13da4 | 731 | {"\tSet DAC Channel 2", 'D', do_dac_value, 2}, |
mbradley | 1:63c505e13da4 | 732 | {"\tSet DAC Channel 3", 'F', do_dac_value, 3}, |
mbradley | 1:63c505e13da4 | 733 | {"\tSet DAC Channel 4", 'G', do_dac_value, 4}, |
mbradley | 1:63c505e13da4 | 734 | {"\tSet DAC Channel 5", 'H', do_dac_value, 5}, |
mbradley | 1:63c505e13da4 | 735 | }; |
mbradley | 1:63c505e13da4 | 736 | |
mbradley | 1:63c505e13da4 | 737 | static console_menu dac_operations_menu = { |
mbradley | 1:63c505e13da4 | 738 | .title = "DAC Operations", |
mbradley | 1:63c505e13da4 | 739 | .items = dac_operations_menu_items, |
mbradley | 1:63c505e13da4 | 740 | .itemCount = ARRAY_SIZE(dac_operations_menu_items), |
mbradley | 1:63c505e13da4 | 741 | .headerItem = display_dac_operations_header, |
mbradley | 1:63c505e13da4 | 742 | .footerItem = NULL, |
mbradley | 1:63c505e13da4 | 743 | .enableEscapeKey = true |
mbradley | 1:63c505e13da4 | 744 | }; |
mbradley | 1:63c505e13da4 | 745 | |
mbradley | 1:63c505e13da4 | 746 | /* |
mbradley | 1:63c505e13da4 | 747 | * Monitor Setup Menu |
mbradley | 1:63c505e13da4 | 748 | */ |
mbradley | 1:63c505e13da4 | 749 | static console_menu_item dac_channel_configuration_menu_items[] = { |
mbradley | 1:63c505e13da4 | 750 | {"\tToggle Channel 0 Enable", '0', do_channel_config, AD5770R_CHANNEL_CONFIG_CH0_SHUTDOWN_B(1)}, |
mbradley | 1:63c505e13da4 | 751 | {"\tToggle Channel 0 Sink Enable", 'S', do_channel_config, AD5770R_CHANNEL_CONFIG_CH0_SINK_EN(1)}, |
mbradley | 1:63c505e13da4 | 752 | {"\tToggle Channel 1 Enable", '1', do_channel_config, AD5770R_CHANNEL_CONFIG_CH1_SHUTDOWN_B(1)}, |
mbradley | 1:63c505e13da4 | 753 | {"\tToggle Channel 2 Enable", '2', do_channel_config, AD5770R_CHANNEL_CONFIG_CH2_SHUTDOWN_B(1)}, |
mbradley | 1:63c505e13da4 | 754 | {"\tToggle Channel 3 Enable", '3', do_channel_config, AD5770R_CHANNEL_CONFIG_CH3_SHUTDOWN_B(1)}, |
mbradley | 1:63c505e13da4 | 755 | {"\tToggle Channel 4 Enable", '4', do_channel_config, AD5770R_CHANNEL_CONFIG_CH4_SHUTDOWN_B(1)}, |
mbradley | 1:63c505e13da4 | 756 | {"\tToggle Channel 5 Enable", '5', do_channel_config, AD5770R_CHANNEL_CONFIG_CH5_SHUTDOWN_B(1)} |
mbradley | 1:63c505e13da4 | 757 | }; |
mbradley | 1:63c505e13da4 | 758 | |
mbradley | 1:63c505e13da4 | 759 | static console_menu dac_channel_configuration_menu = { |
mbradley | 1:63c505e13da4 | 760 | .title = "DAC Channel Configuration", |
mbradley | 1:63c505e13da4 | 761 | .items = dac_channel_configuration_menu_items, |
mbradley | 1:63c505e13da4 | 762 | .itemCount = ARRAY_SIZE(dac_channel_configuration_menu_items), |
mbradley | 1:63c505e13da4 | 763 | .headerItem = display_dac_channel_configuration_header, |
mbradley | 1:63c505e13da4 | 764 | .footerItem = NULL, |
mbradley | 1:63c505e13da4 | 765 | .enableEscapeKey = true |
mbradley | 1:63c505e13da4 | 766 | }; |
mbradley | 1:63c505e13da4 | 767 | |
mbradley | 1:63c505e13da4 | 768 | /* |
mbradley | 1:63c505e13da4 | 769 | * Monitor Setup Menu |
mbradley | 1:63c505e13da4 | 770 | */ |
mbradley | 1:63c505e13da4 | 771 | static console_menu_item monitor_setup_menu_items[] = { |
mbradley | 1:63c505e13da4 | 772 | {"Disable Monitoring", 'Q', do_monitor_setup, AD5770R_DISABLE}, |
mbradley | 1:63c505e13da4 | 773 | {"Enable Voltage Monitoring", 'W', do_monitor_setup, AD5770R_VOLTAGE_MONITORING}, |
mbradley | 1:63c505e13da4 | 774 | {"Enable Current Monitoring", 'E', do_monitor_setup, AD5770R_CURRENT_MONITORING}, |
mbradley | 1:63c505e13da4 | 775 | {"Enable Temperature Monitoring", 'R', do_monitor_setup, AD5770R_TEMPERATURE_MONITORING}, |
mbradley | 1:63c505e13da4 | 776 | {"", '\00', NULL}, |
mbradley | 1:63c505e13da4 | 777 | {"Toggle Mux Buffer", 'M', do_monitor_setup, TOGGLE_MUX_BUFFER}, |
mbradley | 1:63c505e13da4 | 778 | {"Toggle Diode External Bias", 'X', do_monitor_setup, TOGGLE_DIODE_EXT_BIAS}, |
mbradley | 1:63c505e13da4 | 779 | {"", '\00', NULL}, |
mbradley | 1:63c505e13da4 | 780 | {"\tSelect Channel 0", '0', do_monitor_setup, AD5770R_CH0 + MENU_CHANNEL_OFFSET}, |
mbradley | 1:63c505e13da4 | 781 | {"\tSelect Channel 1", '1', do_monitor_setup, AD5770R_CH1 + MENU_CHANNEL_OFFSET}, |
mbradley | 1:63c505e13da4 | 782 | {"\tSelect Channel 2", '2', do_monitor_setup, AD5770R_CH2 + MENU_CHANNEL_OFFSET}, |
mbradley | 1:63c505e13da4 | 783 | {"\tSelect Channel 3", '3', do_monitor_setup, AD5770R_CH3 + MENU_CHANNEL_OFFSET}, |
mbradley | 1:63c505e13da4 | 784 | {"\tSelect Channel 4", '4', do_monitor_setup, AD5770R_CH4 + MENU_CHANNEL_OFFSET}, |
mbradley | 1:63c505e13da4 | 785 | {"\tSelect Channel 5", '5', do_monitor_setup, AD5770R_CH5 + MENU_CHANNEL_OFFSET}, |
mbradley | 1:63c505e13da4 | 786 | }; |
mbradley | 1:63c505e13da4 | 787 | |
mbradley | 1:63c505e13da4 | 788 | static console_menu monitor_setup_menu = { |
mbradley | 1:63c505e13da4 | 789 | .title = "Monitor Setup", |
mbradley | 1:63c505e13da4 | 790 | .items = monitor_setup_menu_items, |
mbradley | 1:63c505e13da4 | 791 | .itemCount = ARRAY_SIZE(monitor_setup_menu_items), |
mbradley | 1:63c505e13da4 | 792 | .headerItem = display_monitor_setup_header, |
mbradley | 1:63c505e13da4 | 793 | .footerItem = NULL, |
mbradley | 1:63c505e13da4 | 794 | .enableEscapeKey = true |
mbradley | 1:63c505e13da4 | 795 | }; |
mbradley | 1:63c505e13da4 | 796 | |
mbradley | 1:63c505e13da4 | 797 | /* |
mbradley | 1:63c505e13da4 | 798 | * General Configuration Menu |
mbradley | 1:63c505e13da4 | 799 | */ |
mbradley | 1:63c505e13da4 | 800 | static console_menu_item general_configuration_menu_items[] = { |
mbradley | 1:63c505e13da4 | 801 | {"Select Int/External Reference Resistor", 'R', do_toggle_ref_resistor}, |
mbradley | 1:63c505e13da4 | 802 | {""}, |
mbradley | 1:63c505e13da4 | 803 | {"Set Ext 2.50V Reference", 'A', do_set_reference, AD5770R_EXT_REF_2_5_V}, |
mbradley | 1:63c505e13da4 | 804 | {"Set Int 1.25V Reference, Vout: ON", 'S', do_set_reference, AD5770R_INT_REF_1_25_V_OUT_ON}, |
mbradley | 1:63c505e13da4 | 805 | {"Set Ext 1.25V Reference", 'D', do_set_reference, AD5770R_EXT_REF_1_25_V}, |
mbradley | 1:63c505e13da4 | 806 | {"Set Int 1.25V Reference, Vout: OFF", 'F', do_set_reference, AD5770R_INT_REF_1_25_V_OUT_OFF}, |
mbradley | 1:63c505e13da4 | 807 | {""}, |
mbradley | 1:63c505e13da4 | 808 | {" --Toggle Alarm Configuration bits --"}, |
mbradley | 1:63c505e13da4 | 809 | {"\tOpen Drain Enable", '0', do_set_alarm, AD5770R_ALARM_CONFIG_OPEN_DRAIN_EN(1)}, |
mbradley | 1:63c505e13da4 | 810 | {"\tThermal Shutdown Enable", '1', do_set_alarm, AD5770R_ALARM_CONFIG_THERMAL_SHUTDOWN_EN(1)}, |
mbradley | 1:63c505e13da4 | 811 | {"\tBackground CRC Enable", '2', do_set_alarm, AD5770R_ALARM_CONFIG_BACKGROUND_CRC_EN(1)}, |
mbradley | 1:63c505e13da4 | 812 | {"\tTemperature Warning Alarm Mask", '3', do_set_alarm, AD5770R_ALARM_CONFIG_TEMP_WARNING_ALARM_MASK(1)}, |
mbradley | 1:63c505e13da4 | 813 | {"\tOver Temperature Alarm Mask", '4', do_set_alarm, AD5770R_ALARM_CONFIG_OVER_TEMP_ALARM_MASK(1)}, |
mbradley | 1:63c505e13da4 | 814 | {"\tNegative Channel 0 Mask", '5', do_set_alarm, AD5770R_ALARM_CONFIG_NEGATIVE_CHANNEL0_ALARM_MASK(1)}, |
mbradley | 1:63c505e13da4 | 815 | {"\tIREF Fault Alarm Mask", '6', do_set_alarm, AD5770R_ALARM_CONFIG_IREF_FAULT_ALARM_MASK(1)}, |
mbradley | 1:63c505e13da4 | 816 | {"\tBackground CRC Alarm Mask", '7', do_set_alarm, AD5770R_ALARM_CONFIG_BACKGROUND_CRC_ALARM_MASK(1)}, |
mbradley | 1:63c505e13da4 | 817 | }; |
mbradley | 1:63c505e13da4 | 818 | |
mbradley | 1:63c505e13da4 | 819 | static console_menu general_configuration_menu = { |
mbradley | 1:63c505e13da4 | 820 | .title = "General Configuration", |
mbradley | 1:63c505e13da4 | 821 | .items = general_configuration_menu_items, |
mbradley | 1:63c505e13da4 | 822 | .itemCount = ARRAY_SIZE(general_configuration_menu_items), |
mbradley | 1:63c505e13da4 | 823 | .headerItem = display_gen_config, |
mbradley | 1:63c505e13da4 | 824 | .footerItem = NULL, |
mbradley | 1:63c505e13da4 | 825 | .enableEscapeKey = true |
mbradley | 1:63c505e13da4 | 826 | }; |
mbradley | 1:63c505e13da4 | 827 | |
mbradley | 1:63c505e13da4 | 828 | /* |
mbradley | 1:63c505e13da4 | 829 | * Definition of the Main Menu Items and menu itself |
mbradley | 1:63c505e13da4 | 830 | */ |
mbradley | 1:63c505e13da4 | 831 | static console_menu_item main_menu_items[] = { |
mbradley | 1:63c505e13da4 | 832 | {"Initialize Device to User Configuration", 'I', do_device_init}, |
mbradley | 1:63c505e13da4 | 833 | {"Remove Device", 'X', do_device_remove}, |
mbradley | 1:63c505e13da4 | 834 | {""}, |
mbradley | 1:63c505e13da4 | 835 | {"Do Software Reset", 'R', do_software_reset}, |
mbradley | 1:63c505e13da4 | 836 | {""}, |
mbradley | 1:63c505e13da4 | 837 | {"General Configuration...", 'G', do_general_configuration_menu}, |
mbradley | 1:63c505e13da4 | 838 | {"Monitor Setup...", 'M', do_monitor_setup_menu}, |
mbradley | 1:63c505e13da4 | 839 | {""}, |
mbradley | 1:63c505e13da4 | 840 | {"DAC Channel Configuration...", 'C', do_dac_channel_configuration_menu}, |
mbradley | 1:63c505e13da4 | 841 | {"DAC Operations...", 'D', do_dac_operations_menu}, |
mbradley | 1:63c505e13da4 | 842 | }; |
mbradley | 1:63c505e13da4 | 843 | |
mbradley | 1:63c505e13da4 | 844 | console_menu ad5770r_main_menu = { |
mbradley | 1:63c505e13da4 | 845 | #if ACTIVE_DEVICE==GENERIC_AD5770R |
mbradley | 1:63c505e13da4 | 846 | .title = "AD5770R Console App", |
mbradley | 1:63c505e13da4 | 847 | #elif ACTIVE_DEVICE==GENERIC_AD5772R |
mbradley | 1:63c505e13da4 | 848 | .title = "AD5772R Terminal App", |
mbradley | 1:63c505e13da4 | 849 | #else |
mbradley | 1:63c505e13da4 | 850 | #error "Unsupported device" |
mbradley | 1:63c505e13da4 | 851 | #endif |
mbradley | 1:63c505e13da4 | 852 | .items = main_menu_items, |
mbradley | 1:63c505e13da4 | 853 | .itemCount = ARRAY_SIZE(main_menu_items), |
mbradley | 1:63c505e13da4 | 854 | .headerItem = display_main_menu_header, |
mbradley | 1:63c505e13da4 | 855 | .footerItem = display_main_menu_footer, |
mbradley | 1:63c505e13da4 | 856 | .enableEscapeKey = false |
mbradley | 1:63c505e13da4 | 857 | }; |