54 #define EEPROM_PAGE_SIZE 16 // EEPROM Page size in bytes 55 #define EEPROM_DATA_SIZE 256 // EEPROM size in bytes 80 Serial.print(F(
"\n*****************************************************************\n"));
81 Serial.print(F(
"* QuikEval Demo Board EEPROM Reader *\n"));
82 Serial.print(F(
"* *\n"));
83 Serial.print(F(
"* This program will read the ID string from a QuikEval *\n"));
84 Serial.print(F(
"* compatible demo board using the Arduino's Hardware I2C port. *\n"));
85 Serial.print(F(
"* *\n"));
86 Serial.print(F(
"* Input Data Format : *\n"));
87 Serial.print(F(
"* decimal : 1024 *\n"));
88 Serial.print(F(
"* hex : 0x400 *\n"));
89 Serial.print(F(
"* octal : 02000 (leading 0 'Zero') *\n"));
90 Serial.print(F(
"* binary : B10000000000 *\n"));
91 Serial.print(F(
"* float : 1024.0 *\n"));
92 Serial.print(F(
"* *\n"));
93 Serial.print(F(
"* Set the baud rate to 115200 select the newline terminator. *\n"));
94 Serial.print(F(
"* *\n"));
100 Serial.print(F(
"*****************************************************************\n"));
101 Serial.println(
"Present Values:");
103 Serial.print(
" I2C Address: 0x");
106 Serial.print(
" EEPROM Address: 0x");
109 Serial.print(
" Buffer Read Terminator: 0x");
112 Serial.print(
" Buffer Read Count: ");
115 Serial.println(
"\nCommand Summary:");
116 Serial.println(
" 0-Buffer Read");
117 Serial.println(
" 1-Buffer Read with Terminator");
118 Serial.println(
" 2-Byte Read");
119 Serial.println(
" 3-Buffer Write");
120 Serial.println(
" 4-Byte Write");
121 Serial.println(
" 5-Set I2C Address");
122 Serial.println(
" 6-Set EEPROM Address");
123 Serial.println(
" 7-Set Terminator");
124 Serial.println(
" 8-Set Read Count");
125 Serial.println(
" 9-Integer Write");
126 Serial.println(
" 10-Integer Read");
127 Serial.println(
" 11-Long Write");
128 Serial.println(
" 12-Long Read");
129 Serial.println(
" 13-Float Write");
130 Serial.println(
" 14-Float Read");
131 Serial.println(
" 15-Clear Calibration Settings On Demo Boards");
133 Serial.print(
"Enter a command: ");
140 Serial.begin(115200);
150 if (Serial.available())
153 Serial.println(user_command);
154 switch (user_command)
161 Serial.print(
"Data Received: ");
165 Serial.println(
"Error: No Data Received");
172 Serial.print(
"Data Received: ");
176 Serial.println(
"Error: No Data Received");
181 Serial.println(
"test");
184 Serial.print(
"Byte Received: 0x");
185 Serial.print(data, HEX);
191 Serial.println(
"Error: No Data Received");
195 Serial.print(
"Enter string to Write to EEPROM: ");
203 Serial.println(
"Data Write Error");
207 Serial.print(
"Enter Data Byte to Write to EEPROM: ");
213 Serial.println(data, HEX);
216 Serial.println(
"Data Write Error");
220 Serial.print(
"Enter I2C Address: ");
226 Serial.print(
"Enter EEPROM Address: ");
233 Serial.print(
"Enter Terminator: ");
239 Serial.print(
"Enter Read Count: ");
245 Serial.print(
"Enter Integer To Write (-32,768 to 32,767): ");
253 Serial.println(
"Data Write Error");
260 Serial.print(
"Integer Read From EEPROM:");
264 Serial.println(
"Data Read Error");
268 Serial.print(
"Enter Long To Write (-2,147,483,648 to 2,147,483,647): ");
276 Serial.println(
"Data Write Error");
283 Serial.print(
"Long Read From EEPROM:");
287 Serial.println(
"Data Read Error");
291 Serial.print(
"Enter Float To Write: ");
299 Serial.println(
"Data Write Error");
306 Serial.print(
"Float Read From EEPROM: ");
310 Serial.println(
"Data Read Error");
314 Serial.println(
"Do You Want to Clear Calibration on the Demo Board?");
315 Serial.println(
"1-Clear Calibration\n");
316 Serial.println(
"0-Keep Calibration\n");
317 Serial.print(
"Enter a Command: ");
320 if (user_command == 1)
323 for (
int i = 0;
i < 0x7FF;
i++)
325 Serial.print(
"Calibration Cleared\n");
329 Serial.print(
"Calibration NOT Cleared\n");
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.
Header File for Linduino Libraries and Demo Code.
static uint8_t i2c_address
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_int32(uint8_t i2c_address, int32_t write_data, uint16_t address)
Write the 4 byte long data to the EEPROM starting at address.
static void print_prompt()
void i2c_enable()
i2c_enable or quikeval_I2C_init must be called before using any of the other I2C routines.
union LT_union_int32_4bytes data
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...
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_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_byte(uint8_t i2c_address, char *data, uint16_t address)
Read a data byte at address from the EEPROM with i2c_address.
unsigned char id_string_size
#define EEPROM_CAL_STATUS_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 ...
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
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 uint16_t eeprom_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...
char ui_buffer[UI_BUFFER_SIZE]
static void print_title()