oled 1.0
OLED Graphics Control Library
Loading...
Searching...
No Matches
twi.h
Go to the documentation of this file.
1
19
20#ifndef TWI_H_
21#define TWI_H_
22
23 #ifndef F_PER
31 #define F_PER 10000000UL
32 #endif
33
34 #ifndef F_TWI
42 #define F_TWI 100000UL
43 #endif
44
45 #ifndef T_RISE
46 #define T_RISE 1/(float)10000000.0
47 #endif
48
49 #ifndef TWI_BITRATE
59 #define TWI_BITRATE (unsigned char)(((float)F_PER)/(float)((F_TWI<<1)) - 5UL - ((unsigned int)(F_PER * (T_RISE))>>1))
60 #endif
61
62 #ifndef TWI_ADDRESS
72 #define TWI_ADDRESS 0x42
73 #endif
74
75 #ifndef TWI_BROADCAST
85 #define TWI_BROADCAST 0x00
86 #endif
87
88 #ifndef TWI_TIMEOUT
104 #define TWI_TIMEOUT TWI_TIMEOUT_DISABLED_gc
105 #endif
106
107 #ifndef TWI_PORTMUX
122 #define TWI_PORTMUX PORTMUX_TWI0_ALT2_gc
123 #endif
124
125 #ifndef TWI_TWIE
137 // #define TWI_TWIE
138 #endif
139
140 #include <avr/io.h>
141
142 #ifndef TWI_TWIE
143 #include <avr/interrupt.h>
144 #endif
145
148
149 unsigned char twi_init(void);
150 void twi_disable(void);
151 unsigned char twi_status(void);
152
153 #ifndef TWI_TWIE
154 TWI_Error twi_start(void);
155 void twi_stop(void);
156 TWI_Error twi_address(unsigned char address, TWI_Operation operation);
157 TWI_Error twi_set(unsigned char data);
158 TWI_Error twi_get(unsigned char *data, TWI_Acknowledge acknowledge);
159 #endif
160
161#endif /* TWI_H_ */
Macro definitions for TWI/I2C communication flags and operations.
Enumerations for TWI/I2C interface modes, operations, acknowledgment, and error codes.
enum TWI_Acknowledge_t TWI_Acknowledge
Alias for enum TWI_Acknowledge_t representing TWI acknowledge mode.
Definition TWI_enums.h:66
enum TWI_Operation_t TWI_Operation
Alias for enum TWI_Operation_t representing TWI operation modes.
Definition TWI_enums.h:48
enum TWI_Error_t TWI_Error
Alias for enum TWI_Error_t representing TWI error status.
Definition TWI_enums.h:89
TWI_Error twi_address(unsigned char address, TWI_Operation operation)
Send a TWI (I2C) slave address combined with the read/write operation bit.
Definition twi.c:145
void twi_disable(void)
Disable the TWI (I2C) interface.
Definition twi.c:56
unsigned char twi_init(void)
Initialize the TWI (I2C) hardware interface in master mode.
Definition twi.c:36
unsigned char twi_status(void)
Retrieves the current TWI status byte.
Definition twi.c:78
TWI_Error twi_set(unsigned char data)
Transmit a data byte over the TWI (I2C) bus.
Definition twi.c:168
void twi_stop(void)
Stop the TWI (I2C) transmission by generating a stop condition.
Definition twi.c:120
TWI_Error twi_get(unsigned char *data, TWI_Acknowledge acknowledge)
Receive a data byte from the TWI (I2C) bus.
Definition twi.c:210
TWI_Error twi_start(void)
Initiates a TWI (I2C) (repeated) start condition on the bus.
Definition twi.c:96