| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LT_I2C.cpp
Go to the documentation of this file.
1
2 /*!
3 LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
4
5 @verbatim
6
7 LT_I2C contains the low level routines to communicate with devices using the
8 ATMega328's onboard hardware I2C port. Each routine checks the Two Wire Status
9 Register (TWSR) at the end of the transaction and returns 0 if successful and 1
10 if not successful.
11
12 I2C Frequency = (CPU Clock frequency)/(16+2(TWBR)*Prescaler)
13
14 TWBR-Two Wire Bit Rate Register
15 TWCR=Two Wire Control Register (TWINT TWEA TWSTA TWSTO TWWC TWEN - TWIE)
16 TWSR=Two Wire Status Register
17
18 Prescaler Values:
19 TWSR1 TWSR0 Prescaler
20 0 0 1
21 0 1 4
22 1 0 16
23 1 1 64
24
25 Examples:
26 CPU Frequency = 16Mhz on Arduino Uno
27 I2C Frequency Prescaler TWSR1 TWSR0 TWBR
28 1khz 64 1 1 125
29 10khz 64 1 1 12
30 50khz 16 1 0 10
31 100khz 4 0 1 18
32 400khz 1 0 0 12
33
34 @endverbatim
35
36
37 Copyright 2018(c) Analog Devices, Inc.
38
39 All rights reserved.
40
41 Redistribution and use in source and binary forms, with or without
42 modification, are permitted provided that the following conditions are met:
43 - Redistributions of source code must retain the above copyright
44 notice, this list of conditions and the following disclaimer.
45 - Redistributions in binary form must reproduce the above copyright
46 notice, this list of conditions and the following disclaimer in
47 the documentation and/or other materials provided with the
48 distribution.
49 - Neither the name of Analog Devices, Inc. nor the names of its
50 contributors may be used to endorse or promote products derived
51 from this software without specific prior written permission.
52 - The use of this software may or may not infringe the patent rights
53 of one or more patent holders. This license does not release you
54 from the requirement that you obtain separate licenses from these
55 patent holders to use this software.
56 - Use of the software either in source or binary form, must be run
57 on or directly connected to an Analog Devices Inc. component.
58
59 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
60 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
61 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
62 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
63 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
64 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
65 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
66 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
67 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
68 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
69 */
70
71 //! @ingroup Linduino
72 //! @{
73 //! @defgroup LT_I2C LT_I2C: Routines to Communicate With ATmega328P's hardware I2C port.
74 //! @}
75
76 /*! @file
77 @ingroup LT_I2C
78 Library for LT_I2C: Routines to Communicate With ATmega328P's hardware I2C port.
79 */
80
81 #include <Arduino.h>
82 #include <stdint.h>
83 #include <util/delay.h>
84 #include "Linduino.h"
85 #include "LT_I2C.h"
86
87 //! CPU master clock frequency
88 #ifndef F_CPU
89 #define F_CPU 16000000UL
90 #endif
91
92 // Read a byte, store in "value".
93 int8_t i2c_read_byte(uint8_t address, uint8_t *value)
94 {
95 uint8_t ret=0;
96 if (i2c_start()!=0) //I2C START
97 return(1); //Stop and return 0 if START fail
98 ret |= i2c_write((address<<1)|I2C_READ_BIT); // Write the I2C 7-bit address with R bit
99 if (ret != 0) // Returns 1 if failed
100 return(1);
101
102 *value = i2c_read(WITH_NACK); // Read byte from I2C Bus with NAK
103 i2c_stop(); //I2C STOP
104 return(0); // Return success
105
106 }
107
108 // Write "value" byte to device at "address"
109 int8_t i2c_write_byte(uint8_t address, uint8_t value)
110 {
111 int8_t ret= 0 ;
112
113 if (i2c_start()!=0) //I2C START
114 return(1); //Stop and return 0 if START fail
115 ret |= i2c_write((address<<1)|I2C_WRITE_BIT); //Write the I2C 7 bit address with W bit
116 ret |= i2c_write(value); //Write value
117 i2c_stop(); //I2C STOP
118 if (ret!=0) // Returns 1 if failed
119 return(1);
120 return(0); // Returns 0 if success
121 }
122
123 // Read a byte of data at register specified by "command", store in "value"
124 int8_t i2c_read_byte_data(uint8_t address, uint8_t command, uint8_t *value)
125 {
126 int8_t ret = 0;
127 if (i2c_start()!=0) //I2C START
128 return(1); //Stop and return 0 if START fail
129 ret |= i2c_write((address<<1)|I2C_WRITE_BIT); // Write 7 bit address with W bit
130 if (ret!=0) //If NACK return 1
131 {
132 i2c_stop(); //I2C STOP
133 return(1);
134 }
135 ret|= i2c_write(command); // Set register to be read to command
136 if (ret!=0) //If NACK return 1
137 {
138 i2c_stop(); //I2C STOP
139 return(1);
140 }
141 if (i2c_start()!=0) //I2C repeated START
142 {
143 i2c_stop(); //Attempt to issue I2C STOP
144 return(1); //Stop and return 0 if START fail
145 }
146 ret |= i2c_write((address<<1)|I2C_READ_BIT); // Write 7 bit address with R bit
147 *value = i2c_read(WITH_NACK); // Read byte from buffer with NAK
148 i2c_stop(); // I2C STOP
149 if (ret!=0) //If there was a NAK return 1
150 return(1);
151 return(0); // Return success
152 }
153
154 // Write a byte of data to register specified by "command"
155 int8_t i2c_write_byte_data(uint8_t address, uint8_t command, uint8_t value)
156 {
157 int8_t ret = 0;
158
159 if (i2c_start()!=0) //I2C START
160 return(1); //Stop and return 0 if START fail
161 ret |= i2c_write((address<<1)|I2C_WRITE_BIT); // Write 7 bit address with W bit
162 ret|= i2c_write(command); // Set register to be read to command
163 ret|= i2c_write(value);
164 i2c_stop(); // I2C STOP
165
166 if (ret!=0) //If there was a NAK return 1
167 return(1);
168 return(0); // Return success
169 }
170
171 // Read a 16-bit word of data from register specified by "command"
172 int8_t i2c_read_word_data(uint8_t address, uint8_t command, uint16_t *value)
173 {
174 int8_t ret = 0;
175
176 union
177 {
178 uint8_t b[2];
179 uint16_t w;
180 } data;
181
182
183 if (i2c_start()!=0) //I2C START
184 return(1); //Stop and return 0 if START fail
185 ret |= i2c_write((address<<1)|I2C_WRITE_BIT); // Write 7 bit address with W bit
186 if (ret!=0) //If NACK return 1
187 {
188 i2c_stop(); //I2C STOP
189 return(1);
190 }
191 ret |= i2c_write(command); // Set register to be read to command
192 if (ret!=0) //If NACK return 1
193 {
194 i2c_stop(); //I2C STOP
195 return(1);
196 }
197 if (i2c_start()!=0) //I2C START
198 {
199 i2c_stop(); //Attempt to issue I2C STOP
200 return(1); //Stop and return 0 if START fail
201 }
202 ret |= i2c_write((address<<1)|I2C_READ_BIT); // Write 7 bit address with R bit
203
204 data.b[1] = i2c_read(WITH_ACK); // Read MSB from buffer
205 data.b[0] = i2c_read(WITH_NACK); // Read LSB from buffer
206 i2c_stop(); //I2C STOP
207
208 *value = data.w;
209
210 if (ret!=0) //If NAK
211 return (1); //return 1
212 return(0); // Return success
213 }
214
215 // Write a 16-bit word of data to register specified by "command"
216 int8_t i2c_write_word_data(uint8_t address, uint8_t command, uint16_t value)
217 {
218 int8_t ret=0;
219
220 union
221 {
222 uint8_t b[2];
223 uint16_t w;
224 } data;
225 data.w = value;
226
227 if (i2c_start()!=0) //I2C START
228 return(1); //Stop and return 0 if START fail
229 ret |= i2c_write((address<<1)|I2C_WRITE_BIT); // Write 7 bit address with W bit
230 ret|= i2c_write(command); // Set register to be read to command
231 ret|= i2c_write(data.b[1]); //Write MSB
232 ret|= i2c_write(data.b[0]); //Write LSB;
233
234 i2c_stop(); // I2C STOP
235
236 if (ret!=0) //If there was a NAK return 1
237 return(1);
238 return(0);
239
240
241 }
242
243 // Read a block of data, starting at register specified by "command" and ending at (command + length - 1)
244 int8_t i2c_read_block_data(uint8_t address, uint8_t command, uint8_t length, uint8_t *values)
245 {
246 uint8_t i = (length-1);
247 int8_t ret = 0;
248
249 if (i2c_start()!=0) //I2C START
250 return(1); //Stop and return 0 if START fail
251 ret |= i2c_write((address<<1)|I2C_WRITE_BIT); //Write 7-bit address with W bit
252 if (ret!=0) //If NACK return 1
253 {
254 i2c_stop(); //I2C STOP
255 return(1);
256 }
257 ret|= i2c_write(command); //Write 8 bit command word
258 if (ret!=0) //If NACK return 1
259 {
260 i2c_stop(); //I2C STOP
261 return(1);
262 }
263 if (i2c_start()!=0) //I2C repeated START
264 {
265 i2c_stop(); //Attempt to issue I2C STOP
266 return(1); //Stop and return 0 if START fail
267 }
268 ret |= i2c_write((address<<1)|I2C_READ_BIT); //Write 7-bit address with R bit
269
270 if (ret!=0) //If NACK return 1
271 {
272 i2c_stop(); //I2C STOP
273 return(1);
274 }
275 while (i>0) //Begin read loop
276 {
277 values[i] = i2c_read(WITH_ACK); //Read from bus with ACK
278 i--;
279 }
280
281 values[0] = i2c_read(WITH_NACK); //Read from bus with NACK for the last one;
282
283 i2c_stop(); //I2C STOP
284
285
286 return(0); // Success!
287 }
288
289
290 // Read a block of data, no command byte, reads length number of bytes and stores it in values.
291 int8_t i2c_read_block_data(uint8_t address, uint8_t length, uint8_t *values)
292 {
293 uint8_t i = (length-1);
294 int8_t ret = 0;
295
296 if (i2c_start()!=0) //I2C START
297 return(1); //Stop and return 0 if START fail
298 ret |= i2c_write((address<<1)|I2C_READ_BIT); //Write 7-bit address with R bit
299
300 if (ret!=0) //If NACK return 1
301 {
302 i2c_stop(); //I2C STOP
303 return(1);
304 }
305 while (i>0) //Begin read loop
306 {
307 values[i] = i2c_read(WITH_ACK); //Read from bus with ACK
308 i--;
309 }
310
311 values[0] = i2c_read(WITH_NACK); //Read from bus with NACK for the last one;
312
313 i2c_stop(); //I2C STOP
314
315
316 return(0); // Success!
317 }
318
319
320 // Write a block of data, starting at register specified by "command" and ending at (command + length - 1)
321 int8_t i2c_write_block_data(uint8_t address, uint8_t command, uint8_t length, uint8_t *values)
322 {
323 int8_t i = length-1;
324 int8_t ret = 0;
325
326 if (i2c_start()!=0) //I2C START
327 return(1); //Stop and return 0 if START fail
328 ret |= i2c_write((address<<1)|I2C_WRITE_BIT); // Write 7 bit address with W bit
329 ret|= i2c_write(command); // Set register to be read to command
330
331 while (i>=0)
332 {
333 ret|= i2c_write(values[i]); //Write Value
334 i--;
335 }
336 i2c_stop(); // I2C STOP
337
338 if (ret!=0)
339 return(1);
340 else
341 return(0); // Success!
342 }
343
344 // Write two command bytes, then receive a block of data
345 int8_t i2c_two_byte_command_read_block(uint8_t address, uint16_t command, uint8_t length, uint8_t *values)
346 {
347
348 int8_t ret = 0;
349
350 union
351 {
352 uint8_t b[2];
353 uint16_t w;
354 } comm;
355 comm.w = command;
356
357 uint8_t i = (length-1);
358
359
360 if (i2c_start()!=0) //I2C START
361 return(1); //Stop and return 0 if START fail
362 ret |= i2c_write((address<<1)|I2C_WRITE_BIT); //Write 7-bit address with W bit
363 ret |= i2c_write(comm.b[1]); //Write MSB command word
364 ret |= i2c_write(comm.b[0]); // Write LSB of command
365 if (i2c_start()!=0) //I2C repeated START
366 {
367 i2c_stop(); //Attempt to issue I2C STOP
368 return(1); //Stop and return 0 if START fail
369 }
370 ret |= i2c_write((address<<1)|I2C_READ_BIT); //Write 7-bit address with R bit
371 if (ret!=0) //If NACK return 1
372 {
373 i2c_stop();
374 return(1);
375 }
376 while (i> 0) //Begin read loop
377 {
378 values[i] = i2c_read(WITH_ACK); //Read from bus with ACK
379 i--;
380 }
381
382 values[0] = i2c_read(WITH_NACK); //Read from bus with NACK for the last one;
383 i2c_stop(); //I2C STOP
384
385
386 return(0); // Success!
387
388 }
389
390 // Initializes Linduino I2C port.
391 // Before communicating to the I2C port throught the QuikEval connector, you must also run
392 // quikeval_I2C_connect to connect the I2C port to the QuikEval connector throught the
393 // QuikEval MUX (and disconnect SPI).
394 void quikeval_I2C_init(void)
395 {
396 i2c_enable(); //! 1) Enable the I2C port;
397 }
398
399 // Switch MUX to connect I2C pins to QuikEval connector.
400 // This will disconnect SPI pins.
401 void quikeval_I2C_connect(void)
402 {
403 // Enable I2C
404 pinMode(QUIKEVAL_MUX_MODE_PIN, OUTPUT); //! 1) Set Mux pin as an output
405 if (digitalRead(QUIKEVAL_MUX_MODE_PIN) == LOW) //! 2) If pin is already high, do nothing
406 {
407 digitalWrite(QUIKEVAL_MUX_MODE_PIN, HIGH); //! 3) Set the Mux pin to high
408 delay(55); //! 4) And wait for LTC4315 to connect (required for rev B)
409 }
410 }
411
412 // Setup the hardware I2C interface.
413 // i2c_enable or quikeval_I2C_init must be called before using any of the other I2C routines.
414 void i2c_enable()
415 {
416 // set these for 100KHz to match the DC590
417 TWSR = (HARDWARE_I2C_PRESCALER_4 & 0x03); //! 1) set the prescaler bits
418 TWBR = 18; //! 2) set the bit rate
419
420 }
421
422
423 // Write start bit to the hardware I2C port
424 // return 0 if successful, 1 if not successful
425 int8_t i2c_start()
426 {
427 uint8_t result;
428 uint16_t timeout;
429 TWCR=(1<<TWINT) | (1<<TWSTA) | (1<<TWEN); //! 1) I2C start
430 for (timeout = 0; timeout < HW_I2C_TIMEOUT; timeout++) //! 2) START the timeout loop
431 {
432 _delay_us(1);
433 if (TWCR & (1 << TWINT)) break; //! 3) Check the TWINT bit in TWCR
434 }
435 result=(TWSR & 0xF8); //! 4) Mask the status
436 if ((result == STATUS_START) || (result == STATUS_REPEATED_START))
437 return(0); //! 5) Return status
438 else
439 return(1);
440 }
441
442 // Write a repeat start bit to the hardware I2C port
443 // return 0 if successful, 1 if not successful
444 int8_t i2c_repeated_start()
445 {
446 uint8_t result;
447 uint16_t timeout;
448 TWCR=(1<<TWINT) | (1<<TWSTA) | (1<<TWEN); //! 1) I2C repeated start
449 for (timeout = 0; timeout < HW_I2C_TIMEOUT; timeout++) //! 2) START the timeout loop
450 {
451 _delay_us(1);
452 if (TWCR & (1 << TWINT)) break; //! 3) Check the TWINT bit in TWCR
453 }
454 result=(TWSR & 0xF8); //! 4) Mask the status
455 if (result == STATUS_REPEATED_START)
456 return(0); //! 5) Return status
457 else
458 return(1);
459 }
460
461 // Write stop bit to the hardware I2C port
462 void i2c_stop()
463 {
464 TWCR=(1<<TWINT) | (1<<TWEN) | (1<<TWSTO); //! 1) I2C stop
465 while (TWCR & (1<<TWSTO)); //! 2) Wait for stop to complete
466 }
467
468 // Send a data byte to hardware I2C port
469 // return 0 if successful, 1 if not successful
470 int8_t i2c_write(uint8_t data)
471 {
472 uint8_t result;
473 uint16_t timeout;
474 TWDR = data; //! 1) Load data register
475 TWCR =(1<<TWINT) | (1<<TWEN); //! 2) START transaction
476 for (timeout = 0; timeout < HW_I2C_TIMEOUT; timeout++) //! 3) START the timeout loop
477 {
478 _delay_us(1);
479 if (TWCR & (1 << TWINT)) break; //! 4) Check the TWINT bit in TWCR
480 }
481 result=(TWSR & 0xF8); //! 5) Update status
482 // For a generic write, need to consider all three of these cases (processor specific, some may not be this detailed.)
483 if ((result == STATUS_WRITE_ACK) || (result == STATUS_ADDRESS_WRITE_ACK) || (result == STATUS_ADDRESS_READ_ACK))
484 return(0); //! 6) Return status
485 else
486 return(1);
487 }
488
489 // Read a data byte from the hardware I2C port.
490 // Returns the data byte read.
491 uint8_t i2c_read(int8_t ack)
492 {
493 uint8_t result;
494 uint8_t return_value = 1;
495 uint16_t timeout;
496 uint8_t data;
497 if (ack == 0)
498 {
499 TWCR=(1<<TWINT) | (1<<TWEN) | (1<<TWEA); //! 1) START transaction with ack
500 for (timeout = 0; timeout < HW_I2C_TIMEOUT; timeout++) //! 2) START timeout loop
501 {
502 _delay_us(1);
503 if (TWCR & (1 << TWINT)) break; //! 3) Check the TWINT bit in TWCR
504 }
505 data = TWDR; //! 4) Get data
506 result = TWSR & 0xF8; //! 5) Update status
507 if (result == STATUS_READ_ACK) return_value = 0;
508 }
509 else
510 {
511 TWCR=(1<<TWINT) | (1<<TWEN); //! 6) START transaction with NACK
512 for (timeout = 0; timeout < HW_I2C_TIMEOUT; timeout++)
513 {
514 _delay_us(1);
515 if (TWCR & (1 << TWINT)) break; //! 7) Check the TWINT bit in TWCR
516 }
517 data = TWDR; //! 8) Get data
518 result = TWSR & 0xF8; //! 9) Update status
519 if (result == STATUS_READ_NACK) return_value = 0;
520 }
521 return(data);
522 }
523
524 // Poll the I2C port and look for an acknowledge
525 // Returns 0 if successful, 1 if not successful
526 int8_t i2c_poll(uint8_t i2c_address)
527
528 {
529 int8_t ack=0;
530 ack |= i2c_start(); //! 1) I2C start
531 ack |= i2c_write((i2c_address<<1) | I2C_WRITE_BIT); //! 2) I2C address + !write
532 i2c_stop(); //! 3) I2C stop
533 return(ack); //! 4) Return ack status
534 }
STATUS_READ_NACK
#define STATUS_READ_NACK
Definition: LT_I2C.h:79
I2C_WRITE_BIT
#define I2C_WRITE_BIT
Definition: LT_I2C.h:64
ret
long ret
Definition: EVAL-AD7124-8.ino:145
STATUS_START
#define STATUS_START
Definition: LT_I2C.h:69
i2c_address
uint8_t i2c_address
i2c_write_byte
int8_t i2c_write_byte(uint8_t address, uint8_t value)
Write "value" byte to device at "address".
Definition: LT_I2C.cpp:109
i2c_read_block_data
int8_t i2c_read_block_data(uint8_t address, uint8_t command, uint8_t length, uint8_t *values)
Read a block of data, starting at register specified by "command" and ending at (command + length - 1...
Definition: LT_I2C.cpp:244
i2c_read_byte_data
int8_t i2c_read_byte_data(uint8_t address, uint8_t command, uint8_t *value)
Read a byte of data at register specified by "command", store in "value".
Definition: LT_I2C.cpp:124
Linduino.h
Header File for Linduino Libraries and Demo Code.
HW_I2C_TIMEOUT
#define HW_I2C_TIMEOUT
Definition: LT_I2C.h:85
QUIKEVAL_MUX_MODE_PIN
#define QUIKEVAL_MUX_MODE_PIN
QUIKEVAL_MUX_MODE_PIN defines the control pin for the QuikEval MUX.
Definition: Linduino.h:58
i2c_stop
void i2c_stop()
Write stop bit to the hardware I2C port.
Definition: LT_I2C.cpp:462
HARDWARE_I2C_PRESCALER_4
#define HARDWARE_I2C_PRESCALER_4
Definition: LT_I2C.h:54
i2c_enable
void i2c_enable()
i2c_enable or quikeval_I2C_init must be called before using any of the other I2C routines.
Definition: LT_I2C.cpp:414
i2c_start
int8_t i2c_start()
Write start bit to the hardware I2C port.
Definition: LT_I2C.cpp:425
address
static uint8_t address
Definition: DC2091A.ino:83
data
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
WITH_NACK
#define WITH_NACK
Use with i2c_read(WITH_NACK) to read without an acknowledge.
Definition: LT_I2C.h:91
i2c_two_byte_command_read_block
int8_t i2c_two_byte_command_read_block(uint8_t address, uint16_t command, uint8_t length, uint8_t *values)
Write a two command bytes, then receive a block of data.
Definition: LT_I2C.cpp:345
_delay_us
#define _delay_us
Definition: QuikEval_EEPROM_Wire.cpp:78
i2c_write_word_data
int8_t i2c_write_word_data(uint8_t address, uint8_t command, uint16_t value)
Write a 16-bit word of data to register specified by "command".
Definition: LT_I2C.cpp:216
STATUS_WRITE_ACK
#define STATUS_WRITE_ACK
Definition: LT_I2C.h:73
i2c_write
int8_t i2c_write(uint8_t data)
Send a data byte to hardware I2C port.
Definition: LT_I2C.cpp:470
i2c_write_byte_data
int8_t i2c_write_byte_data(uint8_t address, uint8_t command, uint8_t value)
Write a byte of data to register specified by "command".
Definition: LT_I2C.cpp:155
STATUS_ADDRESS_READ_ACK
#define STATUS_ADDRESS_READ_ACK
Definition: LT_I2C.h:76
STATUS_READ_ACK
#define STATUS_READ_ACK
Definition: LT_I2C.h:78
I2C_READ_BIT
#define I2C_READ_BIT
Definition: LT_I2C.h:63
STATUS_ADDRESS_WRITE_ACK
#define STATUS_ADDRESS_WRITE_ACK
Definition: LT_I2C.h:71
timeout
long timeout
Definition: EVAL-AD7124-8.ino:144
i2c_read_word_data
int8_t i2c_read_word_data(uint8_t address, uint8_t command, uint16_t *value)
Read a 16-bit word of data from register specified by "command".
Definition: LT_I2C.cpp:172
LT_I2C.h
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
i2c_write_block_data
int8_t i2c_write_block_data(uint8_t address, uint8_t command, uint8_t length, uint8_t *values)
Write a block of data, starting at register specified by "command" and ending at (command + length - ...
Definition: LT_I2C.cpp:321
i2c_repeated_start
int8_t i2c_repeated_start()
Write a repeat start bit to the hardware I2C port.
Definition: LT_I2C.cpp:444
i2c_read
uint8_t i2c_read(int8_t ack)
Read a data byte from the hardware I2C port.
Definition: LT_I2C.cpp:491
quikeval_I2C_init
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
quikeval_I2C_connect
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
Definition: LT_I2C.cpp:401
i
static int i
Definition: DC2430A.ino:184
WITH_ACK
#define WITH_ACK
Use with i2c_read(WITH_ACK) to read with an acknowledge.
Definition: LT_I2C.h:90
STATUS_REPEATED_START
#define STATUS_REPEATED_START
Definition: LT_I2C.h:70
i2c_read_byte
int8_t i2c_read_byte(uint8_t address, uint8_t *value)
Read a byte, store in "value".
Definition: LT_I2C.cpp:93
values
static uint8_t values[4]
Definition: DC2218A.ino:117
i2c_poll
int8_t i2c_poll(uint8_t i2c_address)
Poll the I2C port and look for an acknowledge.
Definition: LT_I2C.cpp:526