ad7124_console_app.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. /*!
  2. *****************************************************************************
  3. @file: ad7124_console_app.c
  4. @brief: Implementation for the menu functions that handle the AD7124
  5. @details:
  6. -----------------------------------------------------------------------------
  7. Copyright (c) 2019 Analog Devices, Inc. All rights reserved.
  8. Redistribution and use in source and binary forms, with or without modification,
  9. are permitted provided that the following conditions are met:
  10. - Redistributions of source code must retain the above copyright notice,
  11. this list of conditions and the following disclaimer.
  12. - Redistributions in binary form must reproduce the above copyright notice,
  13. this list of conditions and the following disclaimer in the documentation
  14. and/or other materials provided with the distribution.
  15. - Modified versions of the software must be conspicuously marked as such.
  16. - This software is licensed solely and exclusively for use with processors/
  17. products manufactured by or for Analog Devices, Inc.
  18. - This software may not be combined or merged with other code in any manner
  19. that would cause the software to become subject to terms and conditions
  20. which differ from those listed here.
  21. - Neither the name of Analog Devices, Inc. nor the names of its contributors
  22. may be used to endorse or promote products derived from this software without
  23. specific prior written permission.
  24. - The use of this software may or may not infringe the patent rights of one
  25. or more patent holders. This license does not release you from the
  26. requirement that you obtain separate licenses from these patent holders
  27. to use this software.
  28. THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS"
  29. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-
  30. INFRINGEMENT, TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE
  32. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR
  33. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF
  34. CLAIMS OF INTELLECTUAL PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF
  35. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  36. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  37. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  38. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  39. POSSIBILITY OF SUCH DAMAGE.
  40. 20180927-7CBSD SLA
  41. *****************************************************************************/
  42. /* includes */
  43. #include <stdio.h>
  44. #include <string.h>
  45. #include <stdbool.h>
  46. #include "platform_support.h"
  47. #include "spi.h"
  48. #include "error.h"
  49. #include "ad7124.h"
  50. #include "ad7124_regs.h"
  51. #include "ad7124_support.h"
  52. #include "ad7124_regs_configs.h"
  53. #include "ad7124_console_app.h"
  54. /* defines */
  55. #define AD7124_CHANNEL_COUNT 16
  56. #define SHOW_ALL_CHANNELS false
  57. #define SHOW_ENABLED_CHANNELS true
  58. #define DISPLAY_DATA_TABULAR 0
  59. #define DISPLAY_DATA_STREAM 1
  60. /* Private Variables */
  61. /*
  62. * This is the 'live' AD7124 register map that is used by the driver
  63. * the other 'default' configs are used to populate this at init time
  64. */
  65. static struct ad7124_st_reg ad7124_register_map[AD7124_REG_NO];
  66. // Pointer to the struct representing the AD7124 device
  67. static struct ad7124_dev * pAd7124_dev = NULL;
  68. // Last Sampled values for All ADC channels
  69. static uint32_t channel_samples[AD7124_CHANNEL_COUNT] = {0};
  70. // How many times a given channel is sampled in total for one sample run
  71. static uint32_t channel_samples_count[AD7124_CHANNEL_COUNT] = {0};
  72. // Public Functions
  73. /*!
  74. * @brief Initialize the AD7124 device and the SPI port as required
  75. *
  76. * @details This resets and then writes the default register map value to
  77. * the device. A call to init the SPI port is made, but may not
  78. * actually do very much, depending on the platform
  79. */
  80. int32_t ad7124_app_initialize(uint8_t configID)
  81. {
  82. /*
  83. * Copy one of the default/user configs to the live register memory map
  84. * Requirement, not checked here, is that all the configs are the same size
  85. */
  86. switch(configID) {
  87. case AD7124_CONFIG_A:
  88. {
  89. memcpy(ad7124_register_map, ad7124_regs_config_a, sizeof(ad7124_register_map));
  90. break;
  91. }
  92. case AD7124_CONFIG_B:
  93. {
  94. memcpy(ad7124_register_map, ad7124_regs_config_b, sizeof(ad7124_register_map));
  95. break;
  96. }
  97. default:
  98. // Not a defined configID
  99. return(FAILURE);
  100. }
  101. // Used to create the ad7124 device
  102. struct ad7124_init_param sAd7124_init =
  103. {
  104. // spi_init_param type
  105. {
  106. 2500000, // Max SPI Speed
  107. 0, // Chip Select
  108. SPI_MODE_3, // CPOL = 1, CPHA =1
  109. NULL
  110. },
  111. ad7124_register_map,
  112. 10000 // Retry count for polling
  113. };
  114. return(ad7124_setup(&pAd7124_dev, sAd7124_init));
  115. }
  116. // Private Functions
  117. /*!
  118. * @brief determines if the Escape key was pressed
  119. *
  120. * @details
  121. */
  122. static bool was_escape_key_pressed(void)
  123. {
  124. char rxChar;
  125. bool wasPressed = false;
  126. // Check for Escape key pressed
  127. if ((rxChar = getchar_nonblocking()) > 0) {
  128. if (rxChar == ESCAPE_KEY_CODE) {
  129. wasPressed = true;
  130. }
  131. }
  132. return (wasPressed);
  133. }
  134. /*!
  135. * @brief reads and displays the status register on the AD7124
  136. *
  137. * @details
  138. */
  139. static void read_status_register(void)
  140. {
  141. if (ad7124_read_register(pAd7124_dev, &ad7124_register_map[AD7124_Status]) < 0) {
  142. printf("\r\nError Encountered reading Status register\r\n");
  143. } else {
  144. uint32_t status_value = (uint32_t)ad7124_register_map[AD7124_Status].value;
  145. printf("\r\nRead Status Register = 0x%02lx\r\n", status_value);
  146. }
  147. }
  148. /*!
  149. * @brief displays the current sample value for a ADC channels
  150. *
  151. * @details
  152. *
  153. * @param showOnlyEnabledChannels only channels that are enabled are displayed
  154. *
  155. */
  156. static void dislay_channel_samples(bool showOnlyEnabledChannels, uint8_t console_mode)
  157. {
  158. switch(console_mode) {
  159. case DISPLAY_DATA_TABULAR:
  160. {
  161. printf("\tCh\tValue\t\tCount\t\tVoltage\r\n");
  162. for (uint8_t i = 0; i < AD7124_CHANNEL_COUNT; i++) {
  163. // if showing all channels, or channel is enabled
  164. if ((showOnlyEnabledChannels == false) || (ad7124_register_map[AD7124_Channel_0 + i].value & AD7124_CH_MAP_REG_CH_ENABLE) ) {
  165. printf("\t%-2d\t%-10ld\t%ld\t\t% .6f\r\n", \
  166. i, channel_samples[i], channel_samples_count[i],
  167. ad7124_convert_sample_to_voltage(pAd7124_dev, i, channel_samples[i]) );
  168. }
  169. }
  170. break;
  171. }
  172. case DISPLAY_DATA_STREAM:
  173. {
  174. // Output a CSV list of the sampled channels as voltages on a single line
  175. bool channel_printed = false;
  176. for (uint8_t i = 0; i < AD7124_CHANNEL_COUNT; i++) {
  177. // if showing all channels, or channel is enabled
  178. if ((showOnlyEnabledChannels == false) || (ad7124_register_map[AD7124_Channel_0 + i].value & AD7124_CH_MAP_REG_CH_ENABLE) ) {
  179. /*
  180. * add the comma before we output the next channel but
  181. * only if at least one channel has been printed
  182. */
  183. if (channel_printed) {
  184. printf(", ");
  185. }
  186. printf("%.6f", \
  187. ad7124_convert_sample_to_voltage(pAd7124_dev, i, channel_samples[i]) );
  188. channel_printed = true;
  189. }
  190. }
  191. printf("\r\n");
  192. break;
  193. }
  194. default:
  195. {
  196. // ASSERT(false);
  197. }
  198. }
  199. }
  200. /*!
  201. * @brief resets the channelSampleCounts to zero
  202. *
  203. * @details
  204. */
  205. static void clear_channel_samples(void)
  206. {
  207. for (uint8_t i = 0; i < AD7124_CHANNEL_COUNT; i++) {
  208. channel_samples[i] = 0;
  209. channel_samples_count[i] = 0;
  210. }
  211. }
  212. /*!
  213. * @brief Continuously acquires samples in Continuous Conversion mode
  214. *
  215. * @details The ADC is run in continuous mode, and all samples are acquired
  216. * and assigned to the channel they come from. Escape key an be used
  217. * to exit the loop
  218. */
  219. static int32_t do_continuous_conversion(uint8_t display_mode)
  220. {
  221. int32_t error_code;
  222. int32_t sample_data;
  223. // Clear the ADC CTRL MODE bits, has the effect of selecting continuous mode
  224. ad7124_register_map[AD7124_ADC_Control].value &= ~(AD7124_ADC_CTRL_REG_MODE(0xf));
  225. if ( (error_code = ad7124_write_register(pAd7124_dev, ad7124_register_map[AD7124_ADC_Control]) ) < 0) {
  226. printf("Error (%ld) setting AD7124 Continuous conversion mode.\r\n", error_code);
  227. adi_press_any_key_to_continue();
  228. return(MENU_CONTINUE);
  229. }
  230. clear_channel_samples();
  231. /*
  232. * If displaying data in stream form, want to output a channel header
  233. */
  234. if (display_mode == DISPLAY_DATA_STREAM)
  235. {
  236. bool channel_printed = false;
  237. for (uint8_t i = 0; i < AD7124_CHANNEL_COUNT; i++) {
  238. // if showing all channels, or channel is enabled
  239. if (ad7124_register_map[AD7124_Channel_0 + i].value & AD7124_CH_MAP_REG_CH_ENABLE) {
  240. /*
  241. * add the comma before we output the next channel but
  242. * only if at least one channel has been printed
  243. */
  244. if (channel_printed) {
  245. printf(", ");
  246. }
  247. printf("%d", i);
  248. }
  249. channel_printed = true;
  250. }
  251. printf("\r\n");
  252. }
  253. // Continuously read the channels, and store sample values
  254. while (was_escape_key_pressed() != true) {
  255. toggle_activity_led();
  256. if (display_mode == DISPLAY_DATA_TABULAR) {
  257. adi_clear_console();
  258. printf("Running continuous conversion mode...\r\nPress Escape to stop\r\n\r\n");
  259. }
  260. /*
  261. * this polls the status register READY/ bit to determine when conversion is done
  262. * this also ensures the STATUS register value is up to date and contains the
  263. * channel that was sampled as well.
  264. * Generally, no need to read STATUS separately, but for faster sampling
  265. * enabling the DATA_STATUS bit means that status is appended to ADC data read
  266. * so the channel being sampled is read back (and updated) as part of the same frame
  267. */
  268. if ( (error_code = ad7124_wait_for_conv_ready(pAd7124_dev, 10000)) < 0) {
  269. printf("Error/Timeout waiting for conversion ready %ld\r\n", error_code);
  270. continue;
  271. }
  272. if ( (error_code = ad7124_read_data(pAd7124_dev, &sample_data)) < 0) {
  273. printf("Error reading ADC Data (%ld).\r\n", error_code);
  274. continue;
  275. }
  276. /*
  277. * No error, need to process the sample, what channel has been read? update that channelSample
  278. */
  279. uint8_t channel_read = ad7124_register_map[AD7124_Status].value & 0x0000000F;
  280. if (channel_read < AD7124_CHANNEL_COUNT) {
  281. channel_samples[channel_read] = sample_data;
  282. channel_samples_count[channel_read]++;
  283. } else {
  284. printf("Channel Read was %d, which is not < AD7124_CHANNEL_COUNT\r\n", channel_read);
  285. }
  286. dislay_channel_samples(SHOW_ENABLED_CHANNELS, display_mode);
  287. }
  288. // All done, ADC put into standby mode
  289. ad7124_register_map[AD7124_ADC_Control].value &= ~(AD7124_ADC_CTRL_REG_MODE(0xf));
  290. // 2 = sleep/standby mode
  291. ad7124_register_map[AD7124_ADC_Control].value |= AD7124_ADC_CTRL_REG_MODE(2);
  292. if ( (error_code = ad7124_write_register(pAd7124_dev, ad7124_register_map[AD7124_ADC_Control]) ) < 0) {
  293. printf("Error (%ld) setting AD7124 ADC into standby mode.\r\n", error_code);
  294. adi_press_any_key_to_continue();
  295. }
  296. return(MENU_CONTINUE);
  297. }
  298. /*!
  299. * @brief Samples all enabled channels and displays in tabular form
  300. *
  301. * @details
  302. */
  303. static int32_t menu_continuous_conversion_tabular(void)
  304. {
  305. do_continuous_conversion(DISPLAY_DATA_TABULAR);
  306. adi_clear_console();
  307. printf("Continuous Conversion completed...\r\n\r\n");
  308. dislay_channel_samples(SHOW_ALL_CHANNELS, DISPLAY_DATA_TABULAR);
  309. adi_press_any_key_to_continue();
  310. return(MENU_CONTINUE);
  311. }
  312. /*!
  313. * @brief Samples all enabled channels and displays on the console
  314. *
  315. * @details
  316. */
  317. static int32_t menu_continuous_conversion_stream(void)
  318. {
  319. do_continuous_conversion(DISPLAY_DATA_STREAM);
  320. printf("Continuous Conversion completed...\r\n\r\n");
  321. adi_press_any_key_to_continue();
  322. return(MENU_CONTINUE);
  323. }
  324. /*!
  325. * @brief Samples all enabled channels once in Single Conversion mode
  326. *
  327. * @details This stores all channels that are enabled in a bitmask, and then
  328. * runs the ADC in single conversion mode, which acquires one channel
  329. * of data at a time. After capture, that channel is disabled, and
  330. * single conversion run again, until no channels are enabled.
  331. * The original enable state of each channel is then restored.
  332. */
  333. static int32_t menu_single_conversion(void)
  334. {
  335. int32_t error_code;
  336. uint16_t channel_enable_mask = 0;
  337. uint8_t channel_count = 0;
  338. int32_t sample_data;
  339. // Need to store which channels are enabled in this config so it can be restored
  340. for (uint8_t i = 0; i < AD7124_CHANNEL_COUNT; i++) {
  341. if (ad7124_register_map[AD7124_Channel_0 + i].value & AD7124_CH_MAP_REG_CH_ENABLE) {
  342. channel_enable_mask |= (1 << i);
  343. channel_count++;
  344. }
  345. }
  346. clear_channel_samples();
  347. adi_clear_console();
  348. printf("Running Single conversion mode...\r\nPress Escape to stop\r\n\r\n");
  349. // Clear the ADC CTRL MODE bits, selecting continuous mode
  350. ad7124_register_map[AD7124_ADC_Control].value &= ~(AD7124_ADC_CTRL_REG_MODE(0xf));
  351. // read the channels, and store sample values
  352. for (uint8_t loopCount = 0; ((was_escape_key_pressed()!= true ) && (loopCount < channel_count)) ; loopCount++) {
  353. toggle_activity_led();
  354. // 1 = single conversion mode
  355. ad7124_register_map[AD7124_ADC_Control].value |= AD7124_ADC_CTRL_REG_MODE(1);
  356. if ( (error_code = ad7124_write_register(pAd7124_dev, ad7124_register_map[AD7124_ADC_Control]) ) < 0) {
  357. printf("Error (%ld) setting AD7124 Single conversion mode.\r\n", error_code);
  358. adi_press_any_key_to_continue();
  359. continue;
  360. }
  361. /*
  362. * this polls the status register READY/ bit to determine when conversion is done
  363. * this also ensures the STATUS register value is up to date and contains the
  364. * channel that was sampled as well. No need to read STATUS separately
  365. */
  366. if ( (error_code = ad7124_wait_for_conv_ready(pAd7124_dev, 10000)) < 0) {
  367. printf("Error/Timeout waiting for conversion ready %ld\r\n", error_code);
  368. continue;
  369. }
  370. if ( (error_code = ad7124_read_data(pAd7124_dev, &sample_data)) < 0) {
  371. printf("Error reading ADC Data (%ld).\r\n", error_code);
  372. continue;
  373. }
  374. /*
  375. * No error, need to process the sample, what channel has been read? update that channelSample
  376. */
  377. uint8_t channelRead = ad7124_register_map[AD7124_Status].value & 0x0000000F;
  378. if (channelRead < AD7124_CHANNEL_COUNT) {
  379. channel_samples[channelRead] = sample_data;
  380. channel_samples_count[channelRead]++;
  381. /* also need to clear the channel enable bit so the next single conversion cycle will sample the next channel */
  382. ad7124_register_map[AD7124_Channel_0 + channelRead].value &= ~AD7124_CH_MAP_REG_CH_ENABLE;
  383. if ( (error_code = ad7124_write_register(pAd7124_dev, ad7124_register_map[AD7124_Channel_0 + channelRead]) ) < 0) {
  384. printf("Error (%ld) Clearing channel %d Enable bit.\r\n", error_code, channelRead);
  385. adi_press_any_key_to_continue();
  386. continue;
  387. }
  388. } else {
  389. printf("Channel Read was %d, which is not < AD7124_CHANNEL_COUNT\r\n", channelRead);
  390. }
  391. }
  392. // All done, ADC put into standby mode
  393. ad7124_register_map[AD7124_ADC_Control].value &= ~(AD7124_ADC_CTRL_REG_MODE(0xf));
  394. // 2 = sleep/standby mode
  395. ad7124_register_map[AD7124_ADC_Control].value |= AD7124_ADC_CTRL_REG_MODE(2);
  396. // Need to restore the channels that were disabled during acquisition
  397. for (uint8_t i = 0; i < AD7124_CHANNEL_COUNT; i++) {
  398. if (channel_enable_mask & (1 << i)) {
  399. ad7124_register_map[AD7124_Channel_0 + i].value |= AD7124_CH_MAP_REG_CH_ENABLE;
  400. if ( (error_code = ad7124_write_register(pAd7124_dev, ad7124_register_map[AD7124_Channel_0 + i]) ) < 0) {
  401. printf("Error (%ld) Setting channel %d Enable bit.\r\r\n", error_code, i);
  402. adi_press_any_key_to_continue();
  403. return(MENU_CONTINUE);
  404. }
  405. }
  406. }
  407. printf("Single Conversion completed...\r\n\r\n");
  408. dislay_channel_samples(SHOW_ENABLED_CHANNELS, DISPLAY_DATA_TABULAR);
  409. adi_press_any_key_to_continue();
  410. return(MENU_CONTINUE);
  411. }
  412. /*!
  413. * @brief menu item that reads the status register the AD7124
  414. *
  415. * @details
  416. */
  417. static int32_t menu_read_status(void)
  418. {
  419. read_status_register();
  420. adi_press_any_key_to_continue();
  421. return(MENU_CONTINUE);
  422. }
  423. /*!
  424. * @brief reads the ID register on the AD7124
  425. *
  426. * @details
  427. */
  428. static int32_t menu_read_id(void)
  429. {
  430. if (ad7124_read_register(pAd7124_dev, &ad7124_register_map[AD7124_ID]) < 0) {
  431. printf("\r\nError Encountered reading ID register\r\n");
  432. } else {
  433. printf("\r\nRead ID Register = 0x%02lx\r\n",
  434. (uint32_t)ad7124_register_map[AD7124_ID].value );
  435. }
  436. adi_press_any_key_to_continue();
  437. return(MENU_CONTINUE);
  438. }
  439. /*!
  440. * @brief Initialize the part with a specific configuration
  441. *
  442. * @details
  443. */
  444. static void init_with_configuration(uint8_t configID)
  445. {
  446. int32_t status = 0;
  447. do {
  448. if ((status = ad7124_remove(pAd7124_dev)) < 0) {
  449. break;
  450. }
  451. if ((status = ad7124_app_initialize(configID)) < 0) {
  452. break;
  453. }
  454. } while(0);
  455. if (status < 0) {
  456. printf("\r\n\r\n Error setting Configuration %c \r\n\r\n", (char)(configID + 'A'));
  457. } else {
  458. printf("\r\n\r\n Configuration %c Set\r\n\r\n", (char)(configID + 'A'));
  459. }
  460. adi_press_any_key_to_continue();
  461. }
  462. /*
  463. * @brief Sends a reset command on the SPI to reset the AD7124
  464. *
  465. * @details
  466. */
  467. static int32_t menu_reset(void)
  468. {
  469. if (ad7124_reset(pAd7124_dev) < 0)
  470. {
  471. printf("\r\n\r\n Error performing Reset\r\n\r\n");
  472. } else
  473. {
  474. // Need to set the live register map to defaults as well
  475. memcpy(ad7124_register_map, ad7124_regs, sizeof(ad7124_register_map));
  476. printf("\r\n\r\n Reset Complete\r\n\r\n");
  477. }
  478. adi_press_any_key_to_continue();
  479. return(MENU_CONTINUE);
  480. }
  481. /*!
  482. * @brief Reset and set the ad7124 with configuration A
  483. *
  484. * @details
  485. */
  486. static int32_t menu_reset_to_configuration_a(void)
  487. {
  488. init_with_configuration(AD7124_CONFIG_A);
  489. return(MENU_CONTINUE);
  490. }
  491. /*!
  492. * @brief Reset and the ad7124 with configuration B
  493. *
  494. * @details
  495. */
  496. static int32_t menu_reset_to_configuration_b(void)
  497. {
  498. init_with_configuration(AD7124_CONFIG_B);
  499. return(MENU_CONTINUE);
  500. }
  501. /*
  502. * Definition of the Sampling Menu Items and menu itself
  503. */
  504. static console_menu_item acquisition_menu_items[] = {
  505. {"Single Conversion Mode", 'S', menu_single_conversion},
  506. {"Continuous Conversion Mode - Table View", 'T', menu_continuous_conversion_tabular},
  507. {"Continuous Conversion Mode - Stream Data", 'C', menu_continuous_conversion_stream},
  508. };
  509. static console_menu acquisition_menu = {
  510. "Data Acquisition Menu",
  511. acquisition_menu_items,
  512. ARRAY_SIZE(acquisition_menu_items),
  513. true
  514. };
  515. /*!
  516. * @brief displays and handles the Sample Channel menu
  517. *
  518. * @details
  519. */
  520. static int32_t menu_sample_channels(void)
  521. {
  522. return(adi_do_console_menu(&acquisition_menu));
  523. }
  524. /*
  525. * Definition of the Main Menu Items and menu itself
  526. */
  527. console_menu_item main_menu_items[] = {
  528. {"Reset to Default Configuration", 'R', menu_reset},
  529. {"Reset to Configuration A", 'A', menu_reset_to_configuration_a},
  530. {"Reset to Configuration B", 'B', menu_reset_to_configuration_b},
  531. {"", '\00', NULL},
  532. {"Read ID Register", 'I', menu_read_id},
  533. {"Read Status Register", 'T', menu_read_status},
  534. {"", '\00', NULL},
  535. {"Sample Channels...", 'S', menu_sample_channels},
  536. };
  537. console_menu ad7124_main_menu = {
  538. "AD7124 Main Menu",
  539. main_menu_items,
  540. ARRAY_SIZE(main_menu_items),
  541. false
  542. };