Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
DC1954A.ino
Go to the documentation of this file.
1 /*!
2 DC1954A
3 LTC6954: Low Phase Noise, Triple Output Clock Distribution Divider/Driver
4 
5 @verbatim
6 
7  Setup:
8  Set the terminal baud rate to 115200 and select the newline terminator.
9  Refer to Demo Manual DC1954A.
10  Ensure all jumpers are installed in the factory default positions.
11  One 3.3V power supplies ia needed for this demo board
12  An input signal is also needed for this demo board, refer to the
13  DC1954 Demo Manual for details.
14 
15 
16 Command Description:
17 
18  *****Main Menu*****
19  1- Load Default Settings- Loads the SPI map that is identical to file
20  LTC6954.6954set that is supplied with the LTC6954_GUI and mentioned
21  in the DC1954A user's manual.
22 
23  2- READ/WRITE to Registers Addresses- Selecting this option will cause all the registers to
24  be read, stored to variables, and displayed. The user will then have the option
25  to write to one register address at a time.
26 
27  3- READ/WRITE to Registers Fields- Selecting this option will allow the user
28  to read or write to one register field name at a time.
29 
30  4- This function stores the current SPI settings in the demo boards EEPROM
31 
32  5- This function loads SPI settings from the demo boards EEPROM to the device
33 
34 
35 USER INPUT DATA FORMAT:
36  decimal : 1024
37  hex : 0x400
38  octal : 02000 (leading 0 "zero")
39  binary : B10000000000
40  float : 1024.0
41 
42 @endverbatim
43 
44 http://www.linear.com/product/LTC6954
45 
46 http://www.linear.com/product/LTC6954#demoboards
47 
48 
49 Copyright 2018(c) Analog Devices, Inc.
50 
51 All rights reserved.
52 
53 Redistribution and use in source and binary forms, with or without
54 modification, are permitted provided that the following conditions are met:
55  - Redistributions of source code must retain the above copyright
56  notice, this list of conditions and the following disclaimer.
57  - Redistributions in binary form must reproduce the above copyright
58  notice, this list of conditions and the following disclaimer in
59  the documentation and/or other materials provided with the
60  distribution.
61  - Neither the name of Analog Devices, Inc. nor the names of its
62  contributors may be used to endorse or promote products derived
63  from this software without specific prior written permission.
64  - The use of this software may or may not infringe the patent rights
65  of one or more patent holders. This license does not release you
66  from the requirement that you obtain separate licenses from these
67  patent holders to use this software.
68  - Use of the software either in source or binary form, must be run
69  on or directly connected to an Analog Devices Inc. component.
70 
71 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
72 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
73 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
74 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
75 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
76 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
77 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
78 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
79 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
80 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
81 */
82 
83 /*! @file
84  @ingroup LTC6954
85 */
86 
87 #include <Arduino.h>
88 #include <stdint.h>
89 #include "Linduino.h"
90 #include "LT_SPI.h"
91 #include "UserInterface.h"
92 #include "LT_I2C.h"
93 #include "QuikEval_EEPROM.h"
94 #include "LTC6954.h"
95 #include <SPI.h>
96 #include <Wire.h>
97 
98 // Function Declaration
99 void print_title(); // Print the title block
100 void print_prompt(); // Print the main menu
101 void menu_1_load_default_settings(); // Sub-menus
104 void menu_4_store_settings();
106 
107 // Global Variables
108 static uint8_t ref_out = 0; //!< Used to keep track of reference out status
109 static int8_t demo_board_connected; //!< Demo Board Name stored in QuikEval EEPROM
110 uint8_t First_Run=0; //!< if first time through loop = 0, otherwise=1
111 
112 
113 /* ------------------------------------------------------------------------- */
114 //! Initialize Linduino
115 //! @return void
116 void setup()
117 {
118  char demo_name[] = "DC1954"; // Demo Board Name stored in QuikEval EEPROM
119  uint8_t data;
120 
121  quikeval_SPI_init(); //! Configure the spi port for 4MHz SCK
122  quikeval_SPI_connect(); //! Connect SPI to main data port
123  quikeval_I2C_init(); //! Configure the EEPROM I2C port for 100kHz
124  Serial.begin(115200); //! Initialize the serial port to the PC
125  LTC6954_init();
126  print_title();
127 
128  demo_board_connected = discover_demo_board(demo_name); //! Checks if correct demo board is connected.
129 
131  while (1); //! Does nothing if the demo board is not connected
132 
133  Serial.print(demo_board.name);
134  Serial.println(F(" was found"));
135 
136  print_prompt();
137 } // end of setup()
138 
139 
140 /* ------------------------------------------------------------------------- */
141 //! Repeats Linduino loop
142 //! @return void
143 void loop()
144 {
145  uint16_t user_command; // User input command
146 
147  if (Serial.available()) // Check for user input
148  {
149  if (First_Run==0)
150  {
151  First_Run=1;
152  }
153 
154  user_command = read_int(); //! Reads the user command
155  if (user_command != 'm')
156  Serial.println(user_command);
157 
158  switch (user_command) //! Prints the appropriate submenu
159  {
160  case 1:
162  break;
163 
164  case 2:
166  break;
167 
168  case 3:
170  break;
171 
172  case 4:
174  break;
175 
176  case 5:
178  break;
179  default:
180  Serial.println(F("Incorrect Option"));
181  break;
182  } // end of switch statement
183  Serial.println(F("\n*****************************************************************"));
184  print_prompt();
185  } // end of if statement
186 } // end of loop()
187 
188 // Function Definitions
189 /* ------------------------------------------------------------------------- */
190 //! Menu 1: Load Default SPI Register Settings
191 //! This function identifies which of the 4 LTC6954 frequency versions are connected.
192 //! Based on the version connected, this function loads the register settings referenced
193 //! in the DC1954A demo manual's quick start section.
194 //! The register settings loaded are the same as the LTC6954_GUI 6954set files
195 //! LTC6954.6954set.
196 //! The setting loaded with this function assume the DC1954A's loop filter has
197 //! not been modified.
198 //! @return void
200 {
201 
202 // select which default register setting to load based on part number
203  if (demo_board.product_name[8]=='1') // if this is a LTC6954-1
204  set_LTC6954_ALLREGS(LTC6954_CS,0x00,0x80,0x04,0x80,0x04,0x80,0x04);
205  else if (demo_board.product_name[8]=='2') // if this is a LTC6954-2
206  set_LTC6954_ALLREGS(LTC6954_CS,0x00,0x80,0x04,0x80,0x04,0x80,0x04);
207  else if (demo_board.product_name[8]=='3') // if this is a LTC6954-3
208  set_LTC6954_ALLREGS(LTC6954_CS,0x00,0x80,0x04,0x80,0x04,0x80,0x04);
209  else if (demo_board.product_name[8]=='4') // if this is a LTC6954-4
210  set_LTC6954_ALLREGS(LTC6954_CS,0x00,0x80,0x04,0x80,0x04,0x80,0x04);
211  else
212  {
213  Serial.print("No default file for this board: ");
214  Serial.println(demo_board.product_name);
215  } // end if-then-else statement
216 
217  Serial.println(F("Registers Have Been Written"));
218 } // end menu_1_load_default_settings function
219 
220 
221 /* ------------------------------------------------------------------------- */
222 //! Menu 2: Reads and/or Writes the SPI register address
223 //! This function reads and displays all SPI register address settings in HEX format.
224 //! It then provides an option to modify(write to) individual registers one at time
225 //!
226 //! EXAMPLE:
227 //! - 0- ADDR00 = 0x00
228 //! - 1- ADDR01 = 0x08
229 //! - ....
230 //! - 6- ADDR06 = 0x04
231 //! - 7- ADDR07 = 0x21 (read only)
232 //! - -1 - Return to Main Menu
233 //! - Enter a command (0-6 to modify register, or '-1' to return to Main Menu):
234 //! @return void
236 {
237  uint8_t i, regval, user_regval, num_regs;
238  uint16_t user_address; // User input command
239 
240  num_regs = get_LTC6954_REGSIZE();
241 // Read/Write loop, can exit loop by choosing '0'
242  user_address=99;
243  while (user_address != -1)
244  {
245  Serial.println(F("\n*****************************************************************"));
246  // Read All Registers and display results
247  for (i=0; i<num_regs; i++)
248  {
249  regval = LTC6954_read(LTC6954_CS,i);
250  Serial.print(i);
251  if (i<16)
252  Serial.print(F("- ADDR0"));
253  else
254  Serial.print(F("- ADDR"));
255  Serial.print(i, HEX);
256  Serial.print(F(" = 0x"));
257  if (regval<16) Serial.print(F("0"));
258  Serial.print(regval, HEX);
259  if (i==(num_regs-1)) Serial.print(" (read only) ");
260  Serial.println("");
261  } // end for loop
262  Serial.print("-1 - Return to Main Menu\n\n");
263  // User input: Select which register to modify, or return to main menu
264  Serial.print("Enter a command (0-6 to modify register, or '-1' to return to Main Menu): ");
265  user_address = read_int(); //! Reads the user command
266  Serial.println(user_address);
267 
268  // User input: enter new setting for selected register
269  if (user_address >=0 && user_address<(num_regs-1))
270  {
271  Serial.print("What value should ADDR");
272  Serial.print(user_address);
273  Serial.print(" be set to (ex: HEX format 0xff): ");
274  user_regval = read_int(); //! Reads the user command
275  Serial.println(user_regval);
276 
277  // writes new setting to part
278  LTC6954_write(LTC6954_CS, (uint8_t)user_address, user_regval);
279  } // end if statement
280  } // end while loop
281 } // end menu_2_RW_to_reg_addresss
282 
283 
284 /* ------------------------------------------------------------------------- */
285 //! Support function for function menu_3_RW_to_reg_field
286 //! displays current state of select field
287 //! provides user the option to write to that field or return to menu
288 //! @return field value (user input) that will be written to part
289 long field_menu_RW(long field_val, //!< current state of the selected field
290  char field_name[], //!< SPI Field name selected
291  uint8_t f //!< SPI field identifier identifies selected fields information in SPI MAP arrays
292  )
293 {
294  long usr_field_val;
295  uint8_t field_size, i;
296  long max_num=1, pow2=1;
297 
298  Serial.print("CURRENT STATE (HEX): ");
299  Serial.print(field_name);
300  Serial.print("= 0x");
301  Serial.println(field_val, HEX);
302 
303  if (get_LTC6954_SPI_FIELD_RW(f)==0)
304  {
305  field_size=get_LTC6954_SPI_FIELD_NUMBITS(f);
306  for (i=1; i<field_size; i++)
307  {
308  pow2=pow2*2;
309  max_num=max_num + pow2;
310  }
311 
312  Serial.print("What value should ");
313  Serial.print(field_name);
314  Serial.print(" be set to or type '-1' to exit: (ex: HEX format 0x00 to 0x");
315  Serial.print(max_num, HEX);
316  Serial.print(")");
317  usr_field_val = read_int(); //! Reads the user command
318 
319  if (usr_field_val>=0 && usr_field_val<=max_num)
320  {
321  Serial.println(usr_field_val);
322  return usr_field_val;
323  }
324  else
325  {
326  return field_val;
327  } // end of if statement
328  } // end of if statement
329 } // end of field_menu_RW
330 
331 
332 /* ------------------------------------------------------------------------- */
333 //! Menu 3: Reads and/or Writes individual SPI fields
334 //! This function provides the user with a list of all SPI fields.
335 //! The user can select a SPI field to read its current value.
336 //! Then the user will be provided with an option to write to that field
337 //! or return to the selection menu.
338 //!
339 //! EXAMPLE:
340 //! - 1-CMSINV0 9-LVCS2 17-PD_DIV2
341 //! - 2-CMSINV1 10-M0 18-PD_OUT0
342 //! - ....
343 //! - 7-LVCS0 15-PD_DIV0 23-SYNC_EN1
344 //! - 8-LVCS1 16-PD_DIV1 24-SYNC_EN2
345 //! - 0 - Return to Main Menu
346 //! - * = READ ONLY FIELD
347 //! - Enter a command (1-24 to modify register, or '0' to return to Main Menu):
348 //! @return void
350 {
351  uint8_t field_num;
352  long field_val;
353 
354 // Read/Write loop, can exit loop by choosing 'm'
355  field_num=1;
356  while (field_num != 0)
357  {
358  Serial.println(F("\n*****************************************************************"));
359  // Select Fields to read and write to
360  Serial.print(F("1-CMSINV0 9-LVCS2 17-PD_DIV2\n"));
361  Serial.print(F("2-CMSINV1 10-M0 18-PD_OUT0\n"));
362  Serial.print(F("3-CMSINV2 11-M1 19-PD_OUT1\n"));
363  Serial.print(F("4-DEL0 12-M2 20-PD_OUT2\n"));
364  Serial.print(F("5-DEL1 13-PART * 21-REV *\n"));
365  Serial.print(F("6-DEL2 14-PDALL 22-SYNC_EN0\n"));
366  Serial.print(F("7-LVCS0 15-PD_DIV0 23-SYNC_EN1\n"));
367  Serial.print(F("8-LVCS1 16-PD_DIV1 24-SYNC_EN2\n"));
368  Serial.print("0 - Return to Main Menu\n");
369  Serial.print("* = READ ONLY FIELD\n\n");
370 
371  Serial.print("Enter a command (1-24 to modify register, or '0' to return to Main Menu): ");
372  field_num = read_int(); //! Reads the user command
373  Serial.println(field_num);
374 
375  // User input: enter new setting for selected register
376  if (field_num > 0)
377  {
378  switch (field_num) //! Prints the appropriate submenu
379  {
380  case LTC6954_CMSINV0:
381  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_CMSINV0); // reads selected field
382  field_val=field_menu_RW(field_val,"CMSINV0",LTC6954_CMSINV0); // user interface control and printout
383  if (field_val>-1)
384  {
385  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_CMSINV0, field_val); // updates selected field
386  }
387  break;
388 
389  case LTC6954_CMSINV1:
390  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_CMSINV1); // reads selected field
391  field_val=field_menu_RW(field_val,"CMSINV1",LTC6954_CMSINV1); // user interface control and printout
392  if (field_val>-1)
393  {
394  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_CMSINV1, field_val); // updates selected field
395  }
396  break;
397 
398  case LTC6954_CMSINV2:
399  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_CMSINV2); // reads selected field
400  field_val=field_menu_RW(field_val,"CMSINV2",LTC6954_CMSINV2); // user interface control and printout
401  if (field_val>-1)
402  {
403  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_CMSINV2, field_val); // updates selected field
404  }
405  break;
406 
407  case LTC6954_DEL0:
408  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_DEL0); // reads selected field
409  field_val=field_menu_RW(field_val,"DEL0",LTC6954_DEL0); // user interface control and printout
410  if (field_val>-1)
411  {
412  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_DEL0, field_val); // updates selected field
413  }
414  break;
415 
416  case LTC6954_DEL1:
417  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_DEL1); // reads selected field
418  field_val=field_menu_RW(field_val,"DEL1",LTC6954_DEL1); // user interface control and printout
419  if (field_val>-1)
420  {
421  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_DEL1, field_val); // updates selected field
422  }
423  break;
424 
425  case LTC6954_DEL2:
426  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_DEL2); // reads selected field
427  field_val=field_menu_RW(field_val,"DEL2",LTC6954_DEL2); // user interface control and printout
428  if (field_val>-1)
429  {
430  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_DEL2, field_val); // updates selected field
431  }
432  break;
433 
434  case LTC6954_LVCS0:
435  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_LVCS0); // reads selected field
436  field_val=field_menu_RW(field_val,"LVCS0",LTC6954_LVCS0); // user interface control and printout
437  if (field_val>-1)
438  {
439  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_LVCS0, field_val); // updates selected field
440  }
441  break;
442 
443  case LTC6954_LVCS1:
444  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_LVCS1); // reads selected field
445  field_val=field_menu_RW(field_val,"LVCS1",LTC6954_LVCS1); // user interface control and printout
446  if (field_val>-1)
447  {
448  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_LVCS1, field_val); // updates selected field
449  }
450  break;
451 
452  case LTC6954_LVCS2:
453  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_LVCS2); // reads selected field
454  field_val=field_menu_RW(field_val,"LVCS2",LTC6954_LVCS2); // user interface control and printout
455  if (field_val>-1)
456  {
457  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_LVCS2, field_val); // updates selected field
458  }
459  break;
460 
461  case LTC6954_M0:
462  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_M0); // reads selected field
463  field_val=field_menu_RW(field_val,"M0",LTC6954_M0); // user interface control and printout
464  if (field_val>-1)
465  {
466  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_M0, field_val); // updates selected field
467  }
468  break;
469 
470  case LTC6954_M1:
471  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_M1); // reads selected field
472  field_val=field_menu_RW(field_val,"M1",LTC6954_M1); // user interface control and printout
473  if (field_val>-1)
474  {
475  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_M1, field_val); // updates selected field
476  }
477  break;
478 
479  case LTC6954_M2:
480  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_M2); // reads selected field
481  field_val=field_menu_RW(field_val,"M2",LTC6954_M2); // user interface control and printout
482  if (field_val>-1)
483  {
484  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_M2, field_val); // updates selected field
485  }
486  break;
487 
488  case LTC6954_PART:
489  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_PART); // reads selected field
490  field_val=field_menu_RW(field_val,"PART",LTC6954_PART); // user interface control and printout
491  if (field_val>-1)
492  {
493  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_PART, field_val); // updates selected field
494  }
495  break;
496 
497  case LTC6954_PDALL:
498  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_PDALL); // reads selected field
499  field_val=field_menu_RW(field_val,"PDALL",LTC6954_PDALL); // user interface control and printout
500  if (field_val>-1)
501  {
502  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_PDALL, field_val); // updates selected field
503  }
504  break;
505 
506  case LTC6954_PD_DIV0:
507  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_PD_DIV0); // reads selected field
508  field_val=field_menu_RW(field_val,"PD_DIV0",LTC6954_PD_DIV0); // user interface control and printout
509  if (field_val>-1)
510  {
511  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_PD_DIV0, field_val); // updates selected field
512  }
513  break;
514 
515  case LTC6954_PD_DIV1:
516  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_PD_DIV1); // reads selected field
517  field_val=field_menu_RW(field_val,"PD_DIV1",LTC6954_PD_DIV1); // user interface control and printout
518  if (field_val>-1)
519  {
520  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_PD_DIV1, field_val); // updates selected field
521  }
522  break;
523 
524  case LTC6954_PD_DIV2:
525  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_PD_DIV2); // reads selected field
526  field_val=field_menu_RW(field_val,"PD_DIV2",LTC6954_PD_DIV2); // user interface control and printout
527  if (field_val>-1)
528  {
529  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_PD_DIV2, field_val); // updates selected field
530  }
531  break;
532 
533  case LTC6954_PD_OUT0:
534  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_PD_OUT0); // reads selected field
535  field_val=field_menu_RW(field_val,"PD_OUT0",LTC6954_PD_OUT0); // user interface control and printout
536  if (field_val>-1)
537  {
538  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_PD_OUT0, field_val); // updates selected field
539  }
540  break;
541 
542  case LTC6954_PD_OUT1:
543  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_PD_OUT1); // reads selected field
544  field_val=field_menu_RW(field_val,"PD_OUT1",LTC6954_PD_OUT1); // user interface control and printout
545  if (field_val>-1)
546  {
547  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_PD_OUT1, field_val); // updates selected field
548  }
549  break;
550 
551  case LTC6954_PD_OUT2:
552  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_PD_OUT2); // reads selected field
553  field_val=field_menu_RW(field_val,"PD_OUT2",LTC6954_PD_OUT2); // user interface control and printout
554  if (field_val>-1)
555  {
556  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_PD_OUT2, field_val); // updates selected field
557  }
558  break;
559 
560  case LTC6954_REV:
561  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_REV); // reads selected field
562  field_val=field_menu_RW(field_val,"REV",LTC6954_REV); // user interface control and printout
563  if (field_val>-1)
564  {
565  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_REV, field_val); // updates selected field
566  }
567  break;
568 
569  case LTC6954_SYNC_EN0:
570  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_SYNC_EN0); // reads selected field
571  field_val=field_menu_RW(field_val,"SYNC_EN0",LTC6954_SYNC_EN0); // user interface control and printout
572  if (field_val>-1)
573  {
574  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_SYNC_EN0, field_val); // updates selected field
575  }
576  break;
577 
578  case LTC6954_SYNC_EN1:
579  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_SYNC_EN1); // reads selected field
580  field_val=field_menu_RW(field_val,"SYNC_EN1",LTC6954_SYNC_EN1); // user interface control and printout
581  if (field_val>-1)
582  {
583  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_SYNC_EN1, field_val); // updates selected field
584  }
585  break;
586 
587  case LTC6954_SYNC_EN2:
588  field_val=get_LTC6954_SPI_FIELD(LTC6954_CS,LTC6954_SYNC_EN2); // reads selected field
589  field_val=field_menu_RW(field_val,"SYNC_EN2",LTC6954_SYNC_EN2); // user interface control and printout
590  if (field_val>-1)
591  {
592  set_LTC6954_SPI_FIELD(LTC6954_CS, LTC6954_SYNC_EN2, field_val); // updates selected field
593  }
594  break;
595  } // end of switch statement
596  } // end if user_command != 0 statement
597  } // end while loop
598 } // end menu_3_RW_to_reg_field function
599 
600 /* ------------------------------------------------------------------------- */
601 //! Store PLL settings to nonvolatile EEPROM on demo board
602 //! @return void
604 {
605 // Store the PLL Settings to the EEPROM
606  uint8_t regval;
607 
608  uint8_t addr_offset;
609  uint8_t num_reg;
610 
611  addr_offset=2;
612  num_reg = get_LTC6954_REGSIZE();
613 
615 
616  for (uint8_t i = 0; i <= num_reg ; i++)
617  {
618  regval = LTC6954_read(LTC6954_CS,i);
620  }
621  Serial.println(F("PLL Settings Stored to EEPROM"));
622 
623 }
624 
625 
626 /* ------------------------------------------------------------------------- */
627 //! Read stored PLL settings from nonvolatile EEPROM on demo board
628 //! @return void
630 {
631 // Read the PLL settings from EEPROM
632  int16_t cal_key;
633  uint8_t regval;
634  uint8_t user_address;
635 
636  uint8_t addr_offset;
637  uint8_t num_reg;
638 
639  addr_offset=2;
640  num_reg = get_LTC6954_REGSIZE();
641 
642 // read the cal key from the EEPROM
644  if (cal_key == EEPROM_CAL_KEY)
645  {
646  // PLL Settings has been stored, read PLL Settings
647  user_address=2;
648  for (uint8_t i = 0; i <= num_reg ; i++)
649  {
650  eeprom_read_byte(EEPROM_I2C_ADDRESS,(char *) &regval, EEPROM_CAL_STATUS_ADDRESS + i+addr_offset);
651  LTC6954_write(LTC6954_CS, (uint8_t)i, regval);
652  user_address++;
653  }
654  Serial.println(F("PLL Settings Restored"));
655  }
656  else
657  {
658  Serial.println(F("PLL Settings not found"));
659  }
660 
661 }
662 
663 /* ------------------------------------------------------------------------- */
664 //! Prints the title block when program first starts.
666 {
667 
668  Serial.println(F("*****************************************************************"));
669  Serial.println(F("* DC1954 Demonstration Program *"));
670  Serial.println(F("* *"));
671  Serial.println(F("* This program demonstrates how to send data to the LTC6954 *"));
672  Serial.println(F("* Low Phase Noise, Triple Output Clock Distribution *"));
673  Serial.println(F("* Divider/Driver. *"));
674  Serial.println(F("* Set the baud rate to 115200 and select the newline terminator.*"));
675  Serial.println(F("* *"));
676  Serial.println(F("*****************************************************************"));
677  Serial.println();
678 } // end of print_title
679 
680 
681 /* ------------------------------------------------------------------------- */
682 //! Prints main menu.
684 {
685 
686  Serial.println(F("\nCommand Summary:"));
687  Serial.println(F(" 1-Load Default Settings (same as the LTC6954 GUI's LTC6954.6954set settings)"));
688  Serial.println(F(" 2-READ/WRITE to Registers Addresses"));
689  Serial.println(F(" 3-READ/WRITE to Registers Fields"));
690  Serial.println(F(" 4-Store LTC6954 SPI settings to the DC1954's EEPROM"));
691  Serial.println(F(" 5-Restore LTC6954 SPI settings from the DC1954's EEPROM"));
692  Serial.println("");
693  Serial.print(F("Enter a command: "));
694 } // end of print_prompt
695 
696 
struct demo_board_type demo_board
Instantiate demo board structure.
static void print_title()
Prints the title block when program first starts.
Definition: DC1954A.ino:665
static void menu_4_store_settings()
Store PLL settings to nonvolatile EEPROM on demo board.
Definition: DC1954A.ino:603
uint8_t eeprom_read_int16(uint8_t i2c_address, int16_t *read_data, uint16_t address)
Read the two byte integer data from the EEPROM starting at address.
unsigned char user_command
#define EEPROM_I2C_ADDRESS
uint8_t eeprom_write_byte(uint8_t i2c_address, char data, uint16_t address)
Write the data byte to the EEPROM with i2c_address starting at EEPROM address.
uint8_t LTC6954_read(uint8_t cs, int8_t address)
LTC6954 Read Single Address reads 8 bit Data field to LTC6954.
Definition: LTC6954.cpp:105
char name[15]
Demo Circuit number (DC1678)
#define LTC6954_PD_DIV1
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:96
#define LTC6954_PDALL
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:94
static void menu_1_load_default_settings()
Menu 1: Load Default SPI Register Settings This function identifies which of the 4 LTC6954 frequency ...
Definition: DC1954A.ino:199
#define LTC6954_SYNC_EN0
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:102
#define LTC6954_M2
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:92
LTC6954: Low Phase Noise, Triple Output Clock Distribution Divider/Driver.
Header File for Linduino Libraries and Demo Code.
static void menu_5_restore_settings()
Read stored PLL settings from nonvolatile EEPROM on demo board.
Definition: DC1954A.ino:629
#define LTC6954_PD_OUT0
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:98
#define LTC6954_LVCS1
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:88
#define LTC6954_SYNC_EN1
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:103
#define LTC6954_LVCS2
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:89
static void print_prompt()
Prints main menu.
Definition: DC1954A.ino:683
#define LTC6954_PART
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:93
void LTC6954_init()
Initializes the SPI MAP arrays The values set in initialization are used all the LTC6954 SPI/WRITE an...
Definition: LTC6954.cpp:304
static void loop()
Repeats Linduino loop.
Definition: DC1954A.ino:143
#define LTC6954_CMSINV0
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:81
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
uint8_t get_LTC6954_REGSIZE()
returns # of addresses in parts register map (array size)
Definition: LTC6954.cpp:239
#define LTC6954_PD_OUT2
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:100
#define LTC6954_DEL1
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:85
static uint8_t First_Run
if first time through loop = 0, otherwise=1
Definition: DC1954A.ino:110
long field_menu_RW(long field_val, char field_name[], uint8_t f)
Support function for function menu_3_RW_to_reg_field displays current state of select field provides ...
Definition: DC1954A.ino:289
uint8_t eeprom_write_int16(uint8_t i2c_address, int16_t write_data, uint16_t address)
Write the 2 byte integer data to the EEPROM starting at address.
uint8_t get_LTC6954_SPI_FIELD_RW(uint8_t f)
returns if the given field name is (0)read/write or (1)read_only field
Definition: LTC6954.cpp:259
uint8_t eeprom_read_byte(uint8_t i2c_address, char *data, uint16_t address)
Read a data byte at address from the EEPROM with i2c_address.
QuikEval EEPROM Library.
#define LTC6954_PD_DIV2
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:97
long get_LTC6954_SPI_FIELD(uint8_t cs, uint8_t f)
Gets the LTC6954 SPI field value calls function LTC6954_read_field, which reads specific address loca...
Definition: LTC6954.cpp:161
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
Definition: LT_SPI.cpp:151
#define LTC6954_M1
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:91
#define LTC6954_PD_OUT1
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:99
#define EEPROM_CAL_STATUS_ADDRESS
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
#define LTC6954_CS
Define the SPI CS pin.
Definition: LTC6954.h:76
#define LTC6954_SYNC_EN2
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:104
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
static void setup()
Initialize Linduino.
Definition: DC1954A.ino:116
void set_LTC6954_SPI_FIELD(uint8_t cs, uint8_t f, long field_data)
Sets the LTC6954 SPI field value calls function LTC6954_read_field, which reads specific address/fiel...
Definition: LTC6954.cpp:272
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1880A.ino:97
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
Definition: LT_SPI.cpp:138
int32_t read_int()
static uint8_t ref_out
Used to keep track of reference out status.
Definition: DC1954A.ino:108
void LTC6954_write(uint8_t cs, uint8_t address, uint8_t Data)
LTC6954 Write Single Address writes 8 bit Data field to LTC6954.
Definition: LTC6954.cpp:172
#define LTC6954_PD_DIV0
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:95
static void menu_2_RW_to_reg_addresss()
Menu 2: Reads and/or Writes the SPI register address This function reads and displays all SPI registe...
Definition: DC1954A.ino:235
char product_name[15]
LTC Product (LTC2654-L16)
#define LTC6954_DEL0
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:84
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
static void menu_3_RW_to_reg_field()
Menu 3: Reads and/or Writes individual SPI fields This function provides the user with a list of all ...
Definition: DC1954A.ino:349
#define LTC6954_REV
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:101
static int i
Definition: DC2430A.ino:184
void set_LTC6954_ALLREGS(uint8_t cs, uint8_t reg00, uint8_t reg01, uint8_t reg02, uint8_t reg03, uint8_t reg04, uint8_t reg05, uint8_t reg06)
Writes values to ALL LTC6954 RW address.
Definition: LTC6954.cpp:282
static int8_t demo_board_connected
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1954A.ino:109
#define LTC6954_CMSINV1
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:82
#define LTC6954_LVCS0
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:87
#define EEPROM_CAL_KEY
#define LTC6954_DEL2
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:86
uint8_t get_LTC6954_SPI_FIELD_NUMBITS(uint8_t f)
returns the number of bits for a given field name in the SPI map
Definition: LTC6954.cpp:249
#define LTC6954_M0
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:90
#define LTC6954_CMSINV2
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6954.h:83