40 #ifndef I2C_H_INCLUDED
41 #define I2C_H_INCLUDED
51 #define I2C_SLAVE_INTERRUPT_OPERATION 1
54 #define I2C_WAIT_BEFORE_STA_US 4
56 #define I2C_MAX_RETRYS 3
57 #define I2C_RETRY_WAIT_US 30
59 #define I2C_MAX_STA_WAIT_CYCLES 250
60 #define I2C_STA_RETRY_WAIT_US 5
62 #define I2C_MAX_TIMEOUT_WAIT_CYCLES 250
63 #define I2C_TIMEOUT_RETRY_WAIT_US 1
65 #define I2C_RESET_BUS_ON_ERROR 1
70 #define I2C_MASTER_BUFFER_LENGTH 10
71 #define I2C_SLAVE_BUFFER_LENGTH 7
75 #define I2C_SCL_FREQ 100000
78 #define I2C_SLAVE_ADDRESS 0xaa
81 #define I2C_MAX_PRESCALER_1 255
82 #define I2C_MAX_PRESCALER_4 1020
83 #define I2C_MAX_PRESCALER_16 4080
84 #define I2C_MAX_PRESCALER_64 16320
87 #define I2C_SCL_SET_SUCC 0
91 #define I2C_IO_SUCC 0xd0
92 #define I2C_IO_NUM_ERROR 0xd1
93 #define I2C_IO_BLOCK_ERROR 0xd2
94 #define I2C_STA_ERROR 0xd3
95 #define I2C_TIMEOUT_ERROR 0xd4
96 #define I2C_IO_BUS_ERROR 0xd5
97 #define I2C_IO_ERROR 0xd6
100 #define I2C_START_COND_TRANS 0x08
101 #define I2C_RSTART_COND_TRANS 0x10
102 #define I2C_SLAW_TRANS 0x18
103 #define I2C_SLAR_TRANS 0x40
104 #define I2C_M_NOACK_SLAW 0x20
105 #define I2C_M_NOACK_SLAR 0x48
106 #define I2C_DATA_TRANS 0x28
107 #define I2C_DATA_RCV_ACK 0x50
108 #define I2C_DATA_RCV_NACK 0x58
109 #define I2C_M_NOACK_DATA_SEND 0x30
110 #define I2C_M_ARB_LOST 0x38
112 #define I2C_BUS_ERROR 0x00
115 #define I2C_SLAW_ACK_RCVD 0x60
116 #define I2C_SLAW_ACK_ARB_LOST 0x68
117 #define I2C_GCA_ACK_RCVD 0x70
118 #define I2C_GCA_ACK_ARB_LOST 0x78
119 #define I2C_DATA_ACK_RCVD 0x80
120 #define I2C_DATA_NOACK_RCVD 0x88
121 #define I2C_GCA_DATA_ACK_RCVD 0x90
122 #define I2C_GCA_DATA_NOACK_RCVD 0x98
123 #define I2C_STO_REPSTART_COND 0xa0
125 #define I2C_SLAR_ACK_RCVD 0xa8
126 #define I2C_SLAR_ACK_ARB_LOST 0xb0
127 #define I2C_DATA_ACK_TRANS 0xb8
128 #define I2C_DATA_NOACK_TRANS 0xc0
129 #define I2C_LAST_DATA_ACK_TRANS 0xc8
131 #define I2C_REGISTER_ERROR_VALUE 0xff
134 #define I2C_SLAVE_MODE_CONTINUE 0
135 #define I2C_SLAVE_MODE_END 1
136 #define I2C_SLAVE_MODE_ABORT 2
149 #if I2C_SLAVE_INTERRUPT_OPERATION == 1
150 uint8_t
i2c_slave_data_io(
volatile uint8_t*,
volatile uint8_t*,
volatile uint8_t);
156 #endif // I2C_H_INCLUDED