Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
QuikEval_EEPROM_Wire.cpp
Go to the documentation of this file.
1 /*!
2 QuikEval EEPROM Library
3 
4 Routines to read and parse the ID string from the EEPROM
5 on a QuikEval-compatible demo board.
6 
7 The QuikEval ID string has the following 50 byte format :
8 @verbatim
9 LTCxxxx,cls,Dxxxx,xx,yy,DC,DCxxxx--------------,\n\0
10 Example: LTC2309,Cls,D1859,01,01,DC,DC1337A-A,------------\n\0
11 @endverbatim
12 
13 Also included are the routines to communicate with an external serial I2C EEPROM
14 such as the 24LC025 found on all LTC QuikEval compatible demo boards. The routines
15 use the ATMega328 hardware I2C port. The routines require the use of the hardware I2C
16 routines found in LT_I2C.h
17 
18 
19 Copyright 2018(c) Analog Devices, Inc.
20 
21 All rights reserved.
22 
23 Redistribution and use in source and binary forms, with or without
24 modification, are permitted provided that the following conditions are met:
25  - Redistributions of source code must retain the above copyright
26  notice, this list of conditions and the following disclaimer.
27  - Redistributions in binary form must reproduce the above copyright
28  notice, this list of conditions and the following disclaimer in
29  the documentation and/or other materials provided with the
30  distribution.
31  - Neither the name of Analog Devices, Inc. nor the names of its
32  contributors may be used to endorse or promote products derived
33  from this software without specific prior written permission.
34  - The use of this software may or may not infringe the patent rights
35  of one or more patent holders. This license does not release you
36  from the requirement that you obtain separate licenses from these
37  patent holders to use this software.
38  - Use of the software either in source or binary form, must be run
39  on or directly connected to an Analog Devices Inc. component.
40 
41 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
42 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
43 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
45 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
47 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
48 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51 */
52 
53 //! @ingroup Linduino
54 //! @{
55 //! @defgroup QuikEval QuikEval EEPROM library
56 //! @}
57 
58 /*! @file
59  @ingroup QuikEval
60  Library for reading from and writing to the EEPROM on QuikEval-compatible demo boards.
61 */
62 
63 #include <Arduino.h>
64 #include <stdint.h>
65 //#include <util/delay.h>
66 #include "Linduino.h"
67 #include "LT_I2C_Wire.h"
68 #include "UserInterface.h"
69 #include "QuikEval_EEPROM_Wire.h"
70 #include <Wire.h>
71 
72 #if defined(ARDUINO_AVR_UNO)
73 #include <util/delay.h>
74 #elif defined(ARDUINO_SAM_DUE)
75 #define _delay_us delayMicroseconds
76 #else
77 #include <delay.h>
78 #define _delay_us delayMicroseconds
79 #endif
80 
81 //#define Wire Wire1
82 
84 
85 // Read the id string from the EEPROM, then parse the
86 // product name, demo board name, and demo board option
87 // from the id string into the global demo_board variable.
88 // Returns the number of characters read from the information string.
89 uint8_t read_quikeval_id_string(char *buffer)
90 {
91  uint8_t i, j; // Iteration variables
92  uint8_t comma_position[8] = {0}; // Contains the position of the commas in the buffer
93  uint8_t comma_count = 0; // The number of commas found in the buffer
94  uint8_t buffer_count; // The number of characters read
95  int8_t option; // Temporary demo board option
96  // read the id string from the demo board EEPROM
97  // starting EEPROM address=0, terminator=0x0a, max buffer length=52 bytes
98  // Enable I2C
99  pinMode(QUIKEVAL_MUX_MODE_PIN, OUTPUT); // Configure MUX to disconnect I2C pins on QuikEval connector. Remember EEPROM has its own I2C pins on the the connector.
100  int8_t QUIKEVAL_MUX_MODE_PIN_state;
101  QUIKEVAL_MUX_MODE_PIN_state = digitalRead(QUIKEVAL_MUX_MODE_PIN);
102  digitalWrite(QUIKEVAL_MUX_MODE_PIN, LOW);
104  //buffer_count = eeprom_read_buffer(EEPROM_I2C_ADDRESS, buffer, 0, QUIKEVAL_ID_SIZE+2);
105  Serial.print(buffer);
106  digitalWrite(QUIKEVAL_MUX_MODE_PIN, QUIKEVAL_MUX_MODE_PIN_state); // Restore the QUIKEVAL_MUX_MODE_PIN (8) to its previous state. (But, it will be left as output.)
107  if (buffer_count == 0) return(0); // quit if no data read
108  // find comma positions
109  for (i = 0; i < buffer_count; i++)
110  {
111  if (buffer[i] == ',') comma_position[comma_count++]=i;
112  }
113 
114  if (comma_position[6] < comma_position[5])// comma_position[6]=strlen(buffer); // some demo boards are missing the last comma
115  {
116  for (i = buffer_count - 2; i > comma_position[5]; i--)
117  {
118  if (buffer[i] != '-')
119  {
120  comma_position[6] = i+1;
121  break;
122  }
123  }
124  }
125 
126 
127 
128  // get product name. All characters before the 1st comma.
129  for (i = 0; i < comma_position[0]; i++)
130  {
131  demo_board.product_name[i]=buffer[i];
132  }
133  demo_board.product_name[i]='\0'; // add terminator
134  // Get demo board name between the 5th and 6th comma
135  j = 0;
136 
137  for (i = comma_position[5]+1; i < comma_position[6]; i++)
138  {
139  demo_board.name[j++]=buffer[i];
140  }
141  demo_board.name[j]='\0'; // add terminator
142  // get demo board option from the demo board name
143  for (i = 0; i < strlen(demo_board.name); i++)
144  {
145  if (demo_board.name[i] == '-') option = demo_board.name[i+1];
146  }
147  if ((option >= 0x41) && (option <= 0x5A)) demo_board.option = option;
148  // final demo board name is 6 characters without the option
149  demo_board.name[6]='\0';
150  return(buffer_count);
151 }
152 
153 // Read the ID string from the EEPROM and determine if the correct board is connected.
154 // Returns 1 if successful, 0 if not successful
156 {
157  int8_t connected;
158  connected = 1;
159  // read the ID from the serial EEPROM on the board
160  // reuse the buffer declared in UserInterface
161  if (read_quikeval_id_string(&ui_buffer[0]) == 0) connected = 0;
162  // make sure it is the correct demo board
163  if (strcmp(demo_board.name, demo_name) != 0) connected = 0;
164  if (connected != 0)
165  {
166  Serial.print("Demo Board Name: ");
167  Serial.println(demo_board.name);
168  Serial.print("Product Name: ");
169  Serial.println(demo_board.product_name);
170  if (demo_board.option)
171  {
172  Serial.print("Demo Board Option: ");
173  Serial.println(demo_board.option);
174  }
175  }
176  else
177  {
178  Serial.print("Demo board ");
179  Serial.print(demo_name);
180  Serial.print(" not found, \nfound ");
181  Serial.print(demo_board.name);
182  Serial.println(" instead. \nConnect the correct demo board, then press the reset button.");
183  }
184  return(connected);
185 }
186 
187 
188 
189 // Determine if the EEPROM is ready for communication by writing
190 // the address+!write byte and looking for an acknowledge. This is
191 // repeated every 1ms until an acknowledge occurs, or a timeout occurs.
192 // If a timeout occurs, an I2C stop is generated.
193 // Returns 0 if an acknowledge is generated and 1 if not.
194 int8_t eeprom_poll(uint8_t i2c_address)
195 {
196 
197  uint8_t timer_count;
198  int8_t ack = 1;
199 
200  for (timer_count = 0; timer_count < EEPROM_TIMEOUT; timer_count++)
201  {
202  Wire.beginTransmission(i2c_address >> 1);
203  ack = Wire.endTransmission(false);
204 
205  if (ack == 0)
206  {
207  return 0; // If the EEPROM acknowledges, jump out of delay loop
208  }
209  else
210  {
211  Wire.endTransmission();
212  delay(1);
213  }
214  }
215  return 1;
216 }
217 
218 // Wait for the EEPROM write cycle to complete by executing
219 // the acknowledge polling loop.
220 // Returns 0 if an acknowledge is generated and 1 if not.
222 {
223  _delay_us(10);
224  return(eeprom_poll(i2c_address));
225 }
226 
227 // Write the data byte to the EEPROM with i2c_address starting at EEPROM address.
228 // Returns the total number of bytes written
229 uint8_t eeprom_write_byte(uint8_t i2c_address, char data, uint16_t address)
230 {
231  uint8_t byte_count = 0;
232  if (address < EEPROM_DATA_SIZE) // Make sure the address is in bounds
233  {
234  if (!eeprom_poll(i2c_address)) // Check if EEPROM is ready
235  {
236  Wire.beginTransmission(i2c_address >> 1);
237  if (EEPROM_DATA_SIZE > 0x100)
238  Wire.write(byte(address>>8)); // Send upper byte of address if size > 256 bytes
239  Wire.write(address); // Send lower byte of address
240  Wire.write(data); // Send byte to EEPROM
241  Wire.endTransmission(); // I2C stop
242  byte_count = 1;
243  }
244  }
245  return(byte_count);
246 }
247 
248 // Write the data byte array to the EEPROM with i2c_address starting at EEPROM address.
249 // Returns the total number of bytes written
250 uint8_t eeprom_write_byte_array(uint8_t i2c_address, char data[], uint16_t address, uint8_t num_bytes)
251 {
252  uint8_t i;
253  for (i = 0; i < num_bytes; i++)
254  {
255  if (eeprom_write_byte(i2c_address, data[i], address+i) != 1) break;
256  }
257  return (i);
258 }
259 
260 // Write the buffer to the EEPROM with i2c_address starting at EEPROM address in blocks of EEPROM_PAGE_SIZE bytes.
261 // Returns the total number of byte written
262 uint8_t eeprom_write_buffer(uint8_t i2c_address, char *buffer, uint16_t address)
263 {
264  uint8_t i, j;
265  uint8_t index = 0;
266  uint8_t page_count;
267  uint8_t byte_count;
268  page_count=((strlen(buffer)-1)/EEPROM_PAGE_SIZE)+1; // Calculate page count
269  if (address < EEPROM_DATA_SIZE) // Make sure the address is in bounds
270  {
271  for (i = 0; i < page_count; i++)
272  {
273  if (!eeprom_poll(i2c_address)) // Check if EEPROM is ready
274  {
275  Wire.beginTransmission(i2c_address);
276  if (EEPROM_DATA_SIZE > 0x100)
277  Wire.write(byte(address>>8)); // Send upper byte of address if size > 256 bytes
278  Wire.write(address); // Send lower byte of address
279  byte_count = strlen(buffer)-index; // Calculate the remaining byte count
280  if (byte_count > EEPROM_PAGE_SIZE) // Limit to EEPROM_PAGE_SIZE
281  byte_count = EEPROM_PAGE_SIZE;
282  for (j = 0; j < byte_count; j++)
283  {
284  if (address >= EEPROM_DATA_SIZE) break; // Quit if the address is at the end
285  Wire.write(buffer[index++]); // Write byte to EEPROM
286  address++; // Increment the EEPROM address
287  }
288  Wire.endTransmission(); // The stop bit starts the write process
289  }
290  else
291  break;
292  }
293  }
294  return(index); // Return the number of bytes written
295 }
296 
297 // Read a data byte at address from the EEPROM with i2c_address.
298 // Returns the number of bytes read.
299 uint8_t eeprom_read_byte(uint8_t i2c_address, char *data, uint16_t address)
300 {
301  uint8_t byte_count = 0;
302  if (address < EEPROM_DATA_SIZE) // Make sure the address is in bounds
303  {
304  if (!eeprom_poll(i2c_address)) // Check if EEPROM is ready
305  {
306  Wire.beginTransmission(i2c_address >> 1);
307  if (EEPROM_DATA_SIZE > 0x100)
308  Wire.write(address>>8); // Send upper byte of address if size > 256 bytes
309  Wire.write(address); // Send lower byte of address
310  if (Wire.endTransmission(false)) // endTransmission(false) is a repeated start
311  {
312  // endTransmission returns zero on success
313  Wire.endTransmission();
314  return(0);
315  }
316  Wire.requestFrom((uint8_t)(i2c_address >> 1), (uint8_t)1, (uint8_t)true);
317  while (Wire.available())
318  {
319  *data = Wire.read(); // Read last byte from EEPROM with NACK
320  byte_count = 1;
321  }
322  Wire.endTransmission();
323  }
324  }
325  return(byte_count);
326 }
327 
328 // Read a data byte at address from the EEPROM with i2c_address.
329 // Returns the number of bytes read.
330 uint8_t eeprom_read_byte_array(uint8_t i2c_address, char *data, uint16_t address, uint8_t num_bytes)
331 {
332  uint8_t i;
333  for (i = 0; i < num_bytes; i++)
334  {
335  if (eeprom_read_byte(i2c_address, data+i, address+i) != 1) break;
336  }
337  return (i);
338 }
339 
340 // Read data bytes from the EEPROM starting at address until number bytes read equals count. A null terminator is
341 // added to the end of the buffer.
342 // Returns the number of bytes read.
343 uint8_t eeprom_read_buffer(uint8_t i2c_address, char *buffer, uint16_t address, uint8_t count)
344 {
345  uint8_t i = 0;
346  uint8_t data;
347  *buffer='\0'; // Initialize buffer with null
348  if (!eeprom_poll(i2c_address)) // Check if the EEPROM is ready
349  {
350  Wire.beginTransmission(i2c_address >> 1);
351  if (EEPROM_DATA_SIZE > 0x100)
352  Wire.write(byte(address>>8)); // Send upper byte of address if size > 256 bytes
353  Wire.write(address); // Send lower byte of address
354  if (Wire.endTransmission(false)) // endTransmission(false) is a repeated start
355  {
356  // endTransmission returns zero on success
357  Wire.endTransmission();
358  return(0);
359  }
360 
361  Wire.requestFrom((uint8_t)(i2c_address >> 1), (uint8_t)count, (uint8_t)true);
362  while (Wire.available())
363  {
364  data = Wire.read();
365  *buffer++ = data;
366  if (i == (count-1))
367  {
368  *buffer = 0; // Place null terminator at end of buffer
369  break;
370  }
371  i++;
372  }
373  Wire.endTransmission();
374  return(i);
375  }
376  return(0);
377 }
378 
379 // Read data bytes from the EEPROM starting at address until the terminator is read
380 // or the number bytes read equals count. A null terminator is placed at the end of the buffer.
381 // Returns the number of bytes read.
382 uint8_t eeprom_read_buffer_with_terminator(uint8_t i2c_address, char *buffer, uint16_t address, char terminator, uint8_t count)
383 {
384  uint8_t i = 0;
385  uint8_t data;
386  *buffer='\0'; // Initialize buffer with null
387  if (eeprom_poll(i2c_address) == 0) // Check if the EEPROM is ready
388  {
389  Wire.beginTransmission(i2c_address >> 1);
390  if (EEPROM_DATA_SIZE > 0x100)
391  Wire.write(byte(address>>8)); // Send upper byte of address if size > 256 bytes
392  Wire.write(address); // Send lower byte of address
393  if (Wire.endTransmission(false)) // endTransmission(false) is a repeated start
394  {
395  // endTransmission returns zero on success
396  Wire.endTransmission();
397  return(0);
398  }
399 
400  Wire.requestFrom((uint8_t)(i2c_address >> 1), (uint8_t)count, (uint8_t)true);
401  while (Wire.available())
402  {
403  data = Wire.read();
404  *buffer++ = data;
405  if ((data == terminator) || (i == (count-1)))
406  {
407  *buffer = 0; // Place null terminator at end of buffer
408  break;
409  }
410  i++;
411  }
412  Wire.endTransmission();
413  return(i);
414  }
415  return(0);
416 }
417 
418 // Write the 2 byte integer data to the EEPROM starting at address. Use the eeprom_write_byte
419 // routine to avoid keeping track of page boundaries with the eeprom_write_buffer routine.
420 // Returns the total number of bytes written.
421 uint8_t eeprom_write_int16(uint8_t i2c_address, int16_t write_data, uint16_t address)
422 {
423  union
424  {
425  int16_t a;
426  int8_t b[2];
427  } data;
428  uint8_t byte_count;
429  data.a = write_data; // get the data
430  byte_count = eeprom_write_byte(i2c_address, data.b[0], address++); // write the LSB to EEPROM
431  if (eeprom_write_poll(i2c_address)) return(0); // poll EEPROM until complete
432  byte_count+=eeprom_write_byte(i2c_address, data.b[1], address); // write the MSB to EEPROM
433  if (eeprom_write_poll(i2c_address)) return(1); // poll EEPROM until complete
434  return(byte_count);
435 }
436 
437 // Read the two byte integer data from the EEPROM starting at address.
438 // Returns the total number of bytes read.
439 uint8_t eeprom_read_int16(uint8_t i2c_address, int16_t *read_data, uint16_t address)
440 {
441  union
442  {
443  int16_t a;
444  char b[2];
445  } data;
446  uint8_t byte_count = 0;
447  byte_count = eeprom_read_byte(i2c_address, &data.b[0], address++); // read the LSB from EEPROM
448  byte_count+=eeprom_read_byte(i2c_address, &data.b[1], address++); // read the MSB from EEPROM
449  *read_data = data.a;
450  return(byte_count);
451 }
452 
453 // Write the 4 byte float data to the EEPROM starting at address. Use the eeprom_write_byte
454 // routine to avoid keeping track of page boundaries with the eeprom_write_buffer routine.
455 // Returns the total number of bytes written.
456 uint8_t eeprom_write_float(uint8_t i2c_address, float write_data, uint16_t address)
457 {
458  union
459  {
460  float a;
461  char b[4];
462  } data;
463  uint8_t byte_count;
464 
465  data.a = write_data;
466  byte_count = eeprom_write_byte(i2c_address, data.b[0], address++);
467  if (eeprom_write_poll(i2c_address)) return(0);
468  byte_count+=eeprom_write_byte(i2c_address, data.b[1], address++);
469  if (eeprom_write_poll(i2c_address)) return(1);
470  byte_count+=eeprom_write_byte(i2c_address, data.b[2], address++);
471  if (eeprom_write_poll(i2c_address)) return(2);
472  byte_count+=eeprom_write_byte(i2c_address, data.b[3], address);
473  if (eeprom_write_poll(i2c_address)) return(3);
474  return(byte_count);
475 }
476 
477 // Read the four byte float data from the EEPROM starting at address.
478 // Returns the total number of bytes written
479 uint8_t eeprom_read_float(uint8_t i2c_address, float *read_data, uint16_t address)
480 {
481  union
482  {
483  float a;
484  char b[4];
485  } data;
486  uint8_t byte_count = 0;
487 
488  byte_count = eeprom_read_byte(i2c_address, &data.b[0], address++);
489  byte_count+=eeprom_read_byte(i2c_address, &data.b[1], address++);
490  byte_count+=eeprom_read_byte(i2c_address, &data.b[2], address++);
491  byte_count+=eeprom_read_byte(i2c_address, &data.b[3], address++);
492  *read_data = data.a;
493  return(byte_count);
494 }
495 
496 // Write the 4 byte int32 data to the EEPROM starting at address. Use the eeprom_write_byte
497 // routine to avoid keeping track of page boundaries with the eeprom_write_buffer routine.
498 // Returns the total number of bytes written.
499 uint8_t eeprom_write_int32(uint8_t i2c_address, int32_t write_data, uint16_t address)
500 {
501  union
502  {
503  int32_t a;
504  char b[4];
505  } data;
506  uint8_t byte_count;
507 
508  data.a = write_data;
509  byte_count = eeprom_write_byte(i2c_address, data.b[0], address++);
510  if (eeprom_write_poll(i2c_address)) return(0);
511  byte_count+=eeprom_write_byte(i2c_address, data.b[1], address++);
512  if (eeprom_write_poll(i2c_address)) return(1);
513  byte_count+=eeprom_write_byte(i2c_address, data.b[2], address++);
514  if (eeprom_write_poll(i2c_address)) return(2);
515  byte_count+=eeprom_write_byte(i2c_address, data.b[3], address);
516  if (eeprom_write_poll(i2c_address)) return(3);
517  return(byte_count);
518 }
519 
520 // Read the four byte int32 data from the EEPROM starting at address.
521 // Returns the total number of bytes written
522 uint8_t eeprom_read_int32(uint8_t i2c_address, int32_t *read_data, uint16_t address)
523 {
524  union
525  {
526  int32_t a;
527  char b[4];
528  } data;
529  uint8_t byte_count = 0;
530 
531  byte_count = eeprom_read_byte(i2c_address, &data.b[0], address++);
532  byte_count+=eeprom_read_byte(i2c_address, &data.b[1], address++);
533  byte_count+=eeprom_read_byte(i2c_address, &data.b[2], address++);
534  byte_count+=eeprom_read_byte(i2c_address, &data.b[3], address++);
535  *read_data = data.a;
536  return(byte_count);
537 }
538 
539 // Write Cal Key back
541 {
543 }
544 
545 // Reset key to default value
547 {
548  return(eeprom_write_int16(EEPROM_I2C_ADDRESS, 0xFFFF, EEPROM_CAL_STATUS_ADDRESS)); // Wipe Cal key
549 }
550 
551 
552 // Read data bytes from the EEPROM starting at address until the terminator is read
553 // or the number bytes read equals count. A null terminator is placed at the end of the buffer.
554 // Returns the number of bytes read.
555 /*uint8_t eeprom_read_buffer_with_terminator(uint8_t i2c_address, char *buffer, uint16_t address, char terminator, uint8_t count)
556 {
557  uint8_t timer_count;
558  int8_t ack = 1;
559  uint8_t i = (count-1);
560 
561  i2c_address = i2c_address >> 1;
562  for (timer_count = 0; timer_count < EEPROM_TIMEOUT; timer_count++)
563  {
564  Wire.beginTransmission(i2c_address);
565  if (EEPROM_DATA_SIZE > 0x100)
566  Wire.write(byte(address>>8)); // Send upper byte of address if size > 256 bytes
567  Wire.write(byte(address)); // Send lower byte of address
568  ack = Wire.endTransmission(false);
569  if (ack == 0)
570  break; // If the EEPROM acknowledges, jump out of delay loop
571  else
572  {
573  Wire.endTransmission();
574  delay(1);
575  }
576  }
577 
578  if(ack)
579  {
580  return 0;
581  }
582  else
583  {
584  Wire.requestFrom(i2c_address, count, (uint8_t)true);
585  while (Wire.available())
586  {
587  buffer[i] = Wire.read();
588  if ((i == 0) || (buffer[i] == terminator))
589  break;
590  i--;
591  }
592  delay(100);
593  if(Wire.endTransmission()) // stop transmitting
594  { // endTransmission returns zero on success
595  return(1);
596  }
597  return(0);
598  }
599 }*/
char option
Demo Circuit option (A)
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.
uint8_t i2c_address
uint8_t eeprom_read_buffer(uint8_t i2c_address, char *buffer, uint16_t address, uint8_t count)
Read data bytes from the EEPROM starting at address until number bytes read equals count...
uint8_t read_data()
#define EEPROM_I2C_ADDRESS
QuikEval EEPROM Library.
uint8_t eeprom_read_buffer_with_terminator(uint8_t i2c_address, char *buffer, uint16_t address, char terminator, uint8_t count)
Read data bytes from the EEPROM starting at address until the terminator is read or the number bytes ...
uint8_t eeprom_read_float(uint8_t i2c_address, float *read_data, uint16_t address)
Read the four byte float data from the EEPROM starting at address.
char name[15]
Demo Circuit number (DC1678)
Structure to hold parsed information from ID string - example: LTC2654-L16,Cls,D2636,01,01,DC,DC1678A-A,----—.
#define EEPROM_DATA_SIZE
uint8_t eeprom_write_int32(uint8_t i2c_address, int32_t write_data, uint16_t address)
Write the 4 byte long data to the EEPROM starting at address.
Header File for Linduino Libraries and Demo Code.
uint8_t read_quikeval_id_string(char *buffer)
Read the id string from the EEPROM, then parse the product name, demo board name, and demo board opti...
struct demo_board_type demo_board
Instantiate demo board structure.
uint8_t eeprom_read_int32(uint8_t i2c_address, int32_t *read_data, uint16_t address)
Read the four byte long data from the EEPROM starting at address.
#define QUIKEVAL_MUX_MODE_PIN
QUIKEVAL_MUX_MODE_PIN defines the control pin for the QuikEval MUX.
Definition: Linduino.h:58
static int32_t connected
Definition: CN-0413.ino:69
uint8_t eeprom_write_byte_array(uint8_t i2c_address, char data[], uint16_t address, uint8_t num_bytes)
Write the data byte array to the EEPROM with i2c_address starting at EEPROM address.
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
int8_t eeprom_poll(uint8_t i2c_address)
Determine if the EEPROM is ready for communication by writing the address+!write byte and looking for...
static uint8_t address
Definition: DC2091A.ino:83
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
#define EEPROM_TIMEOUT
#define _delay_us
uint8_t enable_calibration()
Functions to set and clear the calibration key.
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
uint8_t disable_calibration()
Disable calibration key.
#define EEPROM_CAL_STATUS_ADDRESS
#define EEPROM_PAGE_SIZE
int8_t eeprom_write_poll(uint8_t i2c_address)
Wait for the eeprom write cycle to complete by executing the acknowledge polling loop.
#define QUIKEVAL_ID_TERMINATOR
0x0A terminates the ID String
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 eeprom_write_buffer(uint8_t i2c_address, char *buffer, uint16_t address)
Write the buffer to the EEPROM with i2c_address starting at EEPROM address in blocks of EEPROM_PAGE_S...
#define QUIKEVAL_ID_SIZE
Historical length of the ID string.
uint8_t eeprom_read_byte_array(uint8_t i2c_address, char *data, uint16_t address, uint8_t num_bytes)
Read a data byte at address from the EEPROM with i2c_address.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1880A.ino:97
static int index
uint8_t eeprom_write_float(uint8_t i2c_address, float write_data, uint16_t address)
Write the 4 byte float data to the EEPROM starting at address.
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.
char product_name[15]
LTC Product (LTC2654-L16)
byte terminator
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.
static int i
Definition: DC2430A.ino:184
#define EEPROM_CAL_KEY
char ui_buffer[UI_BUFFER_SIZE]