-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathusi_i2c_slave.h
51 lines (46 loc) · 1.81 KB
/
usi_i2c_slave.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*-----------------------------------------------------*\
| USI I2C Slave Driver |
| |
| This library provides a robust, interrupt-driven I2C |
| slave implementation built on the ATTiny Universal |
| Serial Interface (USI) hardware. Slave operation is |
| implemented as a register bank, where each 'register' |
| is a pointer to an 8-bit variable in the main code. |
| This was chosen to make I2C integration transparent |
| to the mainline code and making I2C reads simple. |
| This library also works well with the Linux I2C-Tools |
| utilities i2cdetect, i2cget, i2cset, and i2cdump. |
| |
| Adam Honse (GitHub: CalcProgrammer1) - 7/29/2012 |
\*-----------------------------------------------------*/
#ifndef USI_I2C_SLAVE_H
#define USI_I2C_SLAVE_H
#include <avr/io.h>
#include <avr/interrupt.h>
//Microcontroller Dependent Definitions
#if defined (__AVR_ATtiny24__) | \
defined (__AVR_ATtiny44__) | \
defined (__AVR_ATtiny84__)
#define DDR_USI DDRA
#define PORT_USI PORTA
#define PIN_USI PINA
#define PORT_USI_SDA PA6
#define PORT_USI_SCL PA4
#define PIN_USI_SDA PINA6
#define PIN_USI_SCL PINA4
#endif
#if defined(__AVR_AT90Tiny2313__) | \
defined(__AVR_ATtiny2313__)
#define DDR_USI DDRB
#define PORT_USI PORTB
#define PIN_USI PINB
#define PORT_USI_SDA PB5
#define PORT_USI_SCL PB7
#define PIN_USI_SDA PINB5
#define PIN_USI_SCL PINB7
#endif
//USI I2C Initialize
// address - If slave, this parameter is the slave address
void USI_I2C_Init(char address);
#endif