Debian Codegraph @

libraries/Wire/src/utility/twi.h

raw
1 /*
2 twi.h - TWI/I2C library for Wiring & Arduino
3 Copyright (c) 2006 Nicholas Zambetti. All right reserved.
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Modified 2020 by Greyson Christoforo ([email protected]) to implement timeouts
20 */
21
22 #ifndef twi_h
23 #define twi_h
24
25 #include <inttypes.h>
26
27 //#define ATMEGA8
28
29 #ifndef TWI_FREQ
30 #define TWI_FREQ 100000L
31 #endif
32
33 #ifndef TWI_BUFFER_LENGTH
34 #define TWI_BUFFER_LENGTH 32
35 #endif
36
37 #define TWI_READY 0
38 #define TWI_MRX 1
39 #define TWI_MTX 2
40 #define TWI_SRX 3
41 #define TWI_STX 4
42
43 void twi_init(void);
44 void twi_disable(void);
45 void twi_setAddress(uint8_t);
46 void twi_setFrequency(uint32_t);
47 uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t);
48 uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t);
49 uint8_t twi_transmit(const uint8_t*, uint8_t);
50 void twi_attachSlaveRxEvent( void (*)(uint8_t*, int) );
51 void twi_attachSlaveTxEvent( void (*)(void) );
52 void twi_reply(uint8_t);
53 void twi_stop(void);
54 void twi_releaseBus(void);
55 void twi_setTimeoutInMicros(uint32_t, bool);
56 void twi_handleTimeout(bool);
57 bool twi_manageTimeoutFlag(bool);
58
59 #endif