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