Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
QuikEval_EEPROM.h
Go to the documentation of this file.
1 /*!
2 QuikEval EEPROM Library
3 
4 
5 Copyright 2018(c) Analog Devices, Inc.
6 
7 All rights reserved.
8 
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
11  - Redistributions of source code must retain the above copyright
12  notice, this list of conditions and the following disclaimer.
13  - Redistributions in binary form must reproduce the above copyright
14  notice, this list of conditions and the following disclaimer in
15  the documentation and/or other materials provided with the
16  distribution.
17  - Neither the name of Analog Devices, Inc. nor the names of its
18  contributors may be used to endorse or promote products derived
19  from this software without specific prior written permission.
20  - The use of this software may or may not infringe the patent rights
21  of one or more patent holders. This license does not release you
22  from the requirement that you obtain separate licenses from these
23  patent holders to use this software.
24  - Use of the software either in source or binary form, must be run
25  on or directly connected to an Analog Devices Inc. component.
26 
27 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
28 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
29 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
30 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
31 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
33 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 */
38 
39 /*! @file
40  @ingroup QuikEval
41  Header file for QuikEval EEPROM library
42 */
43 
44 #ifndef QUIKEVAL_H
45 #define QUIKEVAL_H
46 
47 #include <stdint.h>
48 
49 //! Historical length of the ID string. There are 256 bytes
50 //! in the 24LC024 EEPROM, the rest is free for user data.
51 #define QUIKEVAL_ID_SIZE 50
52 
53 //! 0x0A terminates the ID String
54 #define QUIKEVAL_ID_TERMINATOR 0x0A
55 
56 //!@name EEPROM constants
57 //!@{
58 #define EEPROM_CAL_STATUS_ADDRESS 0x40 //! QuikEval EEPROM calibration start address
59 #define EEPROM_CAL_KEY 0x1234 //! Value to indicate calibration has occurred
60 #define EEPROM_I2C_ADDRESS 0xA0 //! EEPROM I2C address
61 #define EEPROM_PAGE_SIZE 16 //! EEPROM Page size in bytes
62 #define EEPROM_DATA_SIZE 256 //! EEPROM size in bytes
63 #define EEPROM_TIMEOUT 10 //! EEPROM timeout in ms
64 //!@}
65 
66 //! Structure to hold parsed information from
67 //! ID string - example: LTC2654-L16,Cls,D2636,01,01,DC,DC1678A-A,-------
69 {
70  char product_name[15]; //!< LTC Product (LTC2654-L16)
71  char name[15]; //!< Demo Circuit number (DC1678)
72  char option; //!< Demo Circuit option (A)
73 };
74 
75 //! Instantiate demo board structure
77 
78 //! Read the id string from the EEPROM, then parse the
79 //! product name, demo board name, and demo board option
80 //! from the id string into the global demo_board variable.
81 //! Returns the number of characters read from the information string.
82 uint8_t read_quikeval_id_string(char *buffer);
83 
84 //! Read the ID string from the EEPROM and determine if the correct board is connected.
85 //! Returns 1 if successful, 0 if not successful
86 int8_t discover_demo_board(char *demo_name);
87 
88 //! Determine if the EEPROM is ready for communication by writing
89 //! the address+!write byte and looking for an acknowledge. This is
90 //! repeated every 1ms until an acknowledge occurs, or a timeout occurs.
91 //! If a timeout occurs, an I2C stop is generated.
92 //! Returns 0 if an acknowledge is generated and 1 if not.
93 int8_t eeprom_poll(uint8_t i2c_address);
94 
95 //! Wait for the eeprom write cycle to complete by executing
96 //! the acknowledge polling loop.
97 //! Returns 0 if an acknowledge is generated and 1 if not.
98 int8_t eeprom_write_poll(uint8_t i2c_address);
99 
100 //! Write the data byte to the EEPROM with i2c_address starting at EEPROM address.
101 //! Returns the total number of bytes written
102 uint8_t eeprom_write_byte(uint8_t i2c_address, char data, uint16_t address);
103 
104 //! Write the data byte array to the EEPROM with i2c_address starting at EEPROM address.
105 //!! Returns the total number of bytes written
106 uint8_t eeprom_write_byte_array(uint8_t i2c_address, char data[], uint16_t address, uint8_t num_bytes);
107 
108 //! Write the buffer to the EEPROM with i2c_address starting at EEPROM address in blocks of EEPROM_PAGE_SIZE bytes.
109 //! Returns the total number of byte written
110 uint8_t eeprom_write_buffer(uint8_t i2c_address, char *buffer, uint16_t address);
111 
112 //! Read a data byte at address from the EEPROM with i2c_address.
113 //! Returns the number of bytes read.
114 uint8_t eeprom_read_byte(uint8_t i2c_address, char *data, uint16_t address);
115 
116 //! Read a data byte at address from the EEPROM with i2c_address.
117 //! Returns the number of bytes read.
118 uint8_t eeprom_read_byte_array(uint8_t i2c_address, char *data, uint16_t address, uint8_t num_bytes);
119 
120 //! Read data bytes from the EEPROM starting at address until number bytes read equals count. A null terminator is
121 //! added to the end of the buffer.
122 //! Returns the number of bytes read.
123 uint8_t eeprom_read_buffer(uint8_t i2c_address, char *buffer, uint16_t address, uint8_t count);
124 
125 //! Read data bytes from the EEPROM starting at address until the terminator is read
126 //! or the number bytes read equals count. A null terminator is placed at the end of the buffer.
127 //! Returns the number of bytes read.
128 uint8_t eeprom_read_buffer_with_terminator(uint8_t i2c_address, char *buffer, uint16_t address, char terminator, uint8_t count);
129 
130 //! Write the 2 byte integer data to the EEPROM starting at address. Use the eeprom_write_byte
131 //! routine to avoid keeping track of page boundaries with the eeprom_write_buffer routine.
132 //! Returns the total number of bytes written.
133 uint8_t eeprom_write_int16(uint8_t i2c_address, int16_t write_data, uint16_t address);
134 
135 //! Read the two byte integer data from the EEPROM starting at address.
136 //! Returns the total number of bytes read.
137 uint8_t eeprom_read_int16(uint8_t i2c_address, int16_t *read_data, uint16_t address);
138 
139 //! Write the 4 byte float data to the EEPROM starting at address. Use the eeprom_write_byte
140 //! routine to avoid keeping track of page boundaries with the eeprom_write_buffer routine.
141 //! Returns the total number of bytes written.
142 uint8_t eeprom_write_float(uint8_t i2c_address, float write_data, uint16_t address);
143 
144 //! Read the four byte float data from the EEPROM starting at address.
145 //! Returns the total number of bytes written
146 uint8_t eeprom_read_float(uint8_t i2c_address, float *read_data, uint16_t address);
147 
148 //! Write the 4 byte long data to the EEPROM starting at address. Use the eeprom_write_byte
149 //! routine to avoid keeping track of page boundaries with the eeprom_write_buffer routine.
150 //! Returns the total number of bytes written.
151 uint8_t eeprom_write_int32(uint8_t i2c_address, int32_t write_data, uint16_t address);
152 
153 //! Read the four byte long data from the EEPROM starting at address.
154 //! Returns the total number of bytes written
155 uint8_t eeprom_read_int32(uint8_t i2c_address, int32_t *read_data, uint16_t address);
156 
157 //! Functions to set and clear the calibration key. Useful for swtiching between
158 //! calibrated operation and default operation, without actually clearing the stored
159 //! calibration numbers.
160 
161 //! Enable calibration key
162 uint8_t enable_calibration();
163 //! Disable calibration key
164 uint8_t disable_calibration();
165 
166 #endif
167 
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...
char option
Demo Circuit option (A)
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 i2c_address
uint8_t read_data()
uint8_t enable_calibration()
Functions to set and clear the calibration key.
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,----—.
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.
static uint8_t address
Definition: DC2091A.ino:83
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
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.
int8_t eeprom_write_poll(uint8_t i2c_address)
Wait for the eeprom write cycle to complete by executing the acknowledge polling loop.
demo_board_type demo_board
Instantiate demo board structure.
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.
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.
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_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 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.
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 ...
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1880A.ino:97
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 product_name[15]
LTC Product (LTC2654-L16)
byte terminator
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 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.
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...
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
uint8_t disable_calibration()
Disable calibration key.
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...