Petaluma (MAXREFDES30#) Code Documentation  V01.00
16-Bit, 8-Ch, +/-10V input, Simultaneous-Sampling Analog Front End
 All Data Structures Files Functions Variables Macros Pages
menu.c
Go to the documentation of this file.
1 
29 /*
30  * Copyright (C) 2012 Maxim Integrated Products, Inc., All Rights Reserved.
31  *
32  * Permission is hereby granted, free of charge, to any person obtaining a
33  * copy of this software and associated documentation files (the "Software"),
34  * to deal in the Software without restriction, including without limitation
35  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
36  * and/or sell copies of the Software, and to permit persons to whom the
37  * Software is furnished to do so, subject to the following conditions:
38  *
39  * The above copyright notice and this permission notice shall be included
40  * in all copies or substantial portions of the Software.
41  *
42  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
43  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45  * IN NO EVENT SHALL MAXIM INTEGRATED PRODUCTS BE LIABLE FOR ANY CLAIM, DAMAGES
46  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
47  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
48  * OTHER DEALINGS IN THE SOFTWARE.
49  *
50  * Except as contained in this notice, the name of Maxim Integrated Products
51  * shall not be used except as stated in the Maxim Integrated Products
52  * Branding Policy.
53  *
54  * The mere transfer of this software does not imply any licenses
55  * of trade secrets, proprietary technology, copyrights, patents,
56  * trademarks, maskwork rights, or any other form of intellectual
57  * property whatsoever. Maxim Integrated Products retains all ownership rights.
58  *
59  ***************************************************************************/
60 
61 #include <stdio.h>
62 #include "platform.h"
63 #include "xparameters.h"
64 #include "utilities.h"
65 #include "string.h"
66 #include "MAXREFDES30.h"
68 #include "menu.h"
69 
70 void menu_cls()
78 {
79  // The following code will cause a clear screen event on Hyperterminal and many other terminal emulators
80  printf("\033[2J");
81 }
82 
83 
92 {
93  printf( "\r\n");
94  printf( "///////////////////////////////////////////////////////////////////\r\n");
95  printf( "// _____ _____ //\r\n");
96  printf( "// / __ \\ / __ \\ //\r\n");
97  printf( "// | | \\/ / / | | //\r\n");
98  printf( "// | | / / | | //\r\n");
99  printf( "// | | / \\ | | //\r\n");
100  printf( "// | | / /\\ \\ | | //\r\n");
101  printf( "// |_| /_/ \\_\\ |_| //\r\n");
102  printf( "// //\r\n");
103  printf( "///////////////////////////////////////////////////////////////////\r\n");
104  printf("\r\n");
105 }
106 
107 
116 {
117  printf( "\r\n");
118  printf( "///////////////////////////////////////////////////////////////////\r\n");
119  printf( "// ### ### //\r\n");
120  printf( "// ## ## //\r\n");
121  printf( "// //\r\n");
122  printf( "// ## _____ _____ ## //\r\n");
123  printf( "// / __ \\ / __ \\ //\r\n");
124  printf( "// ## | | \\/ / / | | ## //\r\n");
125  printf( "// | | / / | | //\r\n");
126  printf( "// | | / \\ | | //\r\n");
127  printf( "// ## | | / /\\ \\ | | ## //\r\n");
128  printf( "// |_| /_/ \\_\\ |_| //\r\n");
129  printf( "// ## ## //\r\n");
130  printf( "// //\r\n");
131  printf( "// ## ## //\r\n");
132  printf( "// ### ### //\r\n");
133  printf( "// //\r\n");
134  printf( "// M A X I M I N T E G R A T E D //\r\n");
135  printf( "// //\r\n");
136  printf( "///////////////////////////////////////////////////////////////////\r\n");
137 
138  printf("\r\n\r\n");
139 }
140 
149 {
150  printf("\r\n>> ");
151  fflush(stdout);
152 }
153 
154 
163 {
164  printf("----------------------------------------------------\r\n\r\n");
165 }
166 
167 
168 u8 menu_retrieve_keypress(u32 nUartAddress)
181 {
182  u8 uchInput;
183 
184  uchInput = getUartByte(nUartAddress);
185 
186  if(uchInput==27) // Escape sequence (likely an arrow key)
187  {
188  uchInput = getUartByte(nUartAddress);
189  if(uchInput==91) // Left bracket (part #2 of the 3 part escape sequence)
190  {
191  uchInput = getUartByte(nUartAddress);
192  if(uchInput==65)
193  uchInput = KEYPRESS_ARROW_UP-10;
194  if(uchInput==66)
195  uchInput = KEYPRESS_ARROW_DOWN-10;
196  if(uchInput==67)
197  uchInput = KEYPRESS_ARROW_RIGHT-10;
198  if(uchInput==68)
199  uchInput = KEYPRESS_ARROW_LEFT-10;
200  if(uchInput==75)
201  uchInput = KEYPRESS_END - 10;
202  }
203  }
204  else if(uchInput>=48 && uchInput <=57) // digits 0..9
205  uchInput -=48; // subtract 48 to get the real number converted from the ASCII digit
206  else if(uchInput>=97 && uchInput<=122)
207  uchInput -=32; // convert lowercase to uppercase
208 
209  return(uchInput);
210 }
211 
219 {
221 
222  printf("Press a number to select sampling mode:\r\n");
223 
224  printf("{0} Continuous Sampling \n"\
225  "{1} Block Sampling\n");
227 }
228 
230 {
232 
233  printf("Press a number to select analog input channel:\r\n");
234 
235  printf("{0} Channel 0 \n"\
236  "{1} Channel 1\n"\
237  "{2} Channel 2\n"\
238  "{3} Channel 3\n"\
239  "{4} Channel 4\n"\
240  "{5} Channel 5\n"\
241  "{6} Channel 6\n"\
242  "{7} Channel 7\n"\
243  "{8} All 8 channels\n");
245 }
246 
254 {
256 
257  printf("Press a number to select the sample rate:\r\n");
258 
259  printf("{0} 1ksps\n"\
260  "{1} 10ksps\n"\
261  "{2} 20ksps\n"\
262  "{3} 50ksps\n"\
263  "{4} 100ksps\n"\
264  "{5} 250ksps\n");
266 }
267 
275 {
277 
278  printf("Press a key/number to select the sample size:\r\n");
279 
280  printf("{0} 65536\n"\
281  "{1} 131072\n"\
282  "{2} 524288\n"\
283  "{3} 1048576\n");
285 }