-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathi2c_machine.h
50 lines (43 loc) · 1.44 KB
/
i2c_machine.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
/*
* Copyright Brian Starkey 2014 <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __I2C_MACHINE__
#define __I2C_MACHINE__
#include <stdint.h>
#include "i2c_slave_defs.h"
/* Initialise the USI and I2C state machine */
void i2c_init(void);
/*
* Check for and handle a stop condition.
* Returns non-zero if any registers have been changed
*/
uint8_t i2c_check_stop(void);
/*
* Return non-zero if a transaction is ongoing
* A transaction is considered ongoing if the slave address has
* been matched, but a stop has not been received yet.
*/
uint8_t i2c_transaction_ongoing(void);
/*
* These need to be instantiated somewhere in your application.
* I2C_N_REG should be defined in i2c_slave_defs.h
*/
extern volatile uint8_t i2c_reg[I2C_N_REG];
#if !defined(I2C_GLOBAL_WRITE_MASK)
/* See i2c_slave_defs.h */
extern const uint8_t i2c_w_mask[I2C_N_REG];
#endif
#endif /* __I2C_MACHINE__ */