Subversion Repositories group.electronics

Rev

Rev 40 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 40 Rev 60
Line 5... Line 5...
5
 
5
 
6
void i2c_master(void);
6
void i2c_master(void);
7
void i2c_slave(uint8_t address);
7
void i2c_slave(uint8_t address);
8
void i2c_beginTransmission(uint8_t address);
8
void i2c_beginTransmission(uint8_t address);
9
uint8_t i2c_endTransmission(uint8_t sentStop);
9
uint8_t i2c_endTransmission(uint8_t sentStop);
10
uint8_t writeByte(uint8_t data);
10
uint8_t i2c_writeByte(uint8_t data);
11
uint8_t writeBytes(uint8_t *data, uint8_t bytes);
11
uint8_t i2c_writeBytes(uint8_t *data, uint8_t bytes);
12
void i2c_onReceiveService(uint8_t* inBytes, int numBytes);
12
void i2c_onReceiveService(uint8_t* inBytes, int numBytes);
13
void i2c_onRequestService(void);
13
void i2c_onRequestService(void);
14
void i2c_onReceive( void(*function)(uint8_t));
14
void i2c_onReceive( void(*function)(uint8_t));
15
void i2c_onRequest( void(*function)(void));
15
void i2c_onRequest( void(*function)(void));
16
 
16
 
17
 
17
 
18
struct {
18
struct {
19
        uint8_t rxBuffer[MAX_BUFFER];
19
	uint8_t rxBuffer[MAX_BUFFER];
-
 
20
 
-
 
21
	// Save 8 bytes. Maximum buffer size is 15
-
 
22
	union {
-
 
23
		uint8_t rxMeta;
-
 
24
		struct {
20
        uint8_t rxBufferIndex;
25
			uint8_t rxBufferIndex:4;
21
        uint8_t rxBufferLength;
26
			uint8_t rxBufferLength:4;
-
 
27
		};
-
 
28
	};
22
 
29
 
23
        uint8_t txAddress;
30
	uint8_t txAddress;
24
        uint8_t txBuffer[MAX_BUFFER];
31
	uint8_t txBuffer[MAX_BUFFER];
-
 
32
 
-
 
33
	union {
-
 
34
		uint8_t txMeta;
-
 
35
		struct {
25
        uint8_t txBufferIndex;
36
			uint8_t txBufferIndex:4;
26
        uint8_t txBufferLength;
37
			uint8_t txBufferLength:4;
-
 
38
		};
-
 
39
	};
27
 
40
 
28
        void    (*user_onRequest)(void);
41
	void    (*user_onRequest)(void);
29
        void    (*user_onReceive)(uint8_t);
42
	void    (*user_onReceive)(uint8_t);
30
 
43
 
31
        union {
44
	union {
32
                uint8_t internal;
45
		uint8_t internal;
33
                struct {
46
		struct {
34
                        uint8_t transmitting:1;
47
			uint8_t transmitting:1;
35
                        uint8_t rved:7;
48
			uint8_t reserved:7;
36
                };
49
		};
37
        };
50
	};
38
} wire;
51
} wire;
39
 
52
 
40
#endif
53
#endif