Subversion Repositories group.electronics

Rev

Rev 56 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
42 pfowler 1
#ifndef wire_h
2
#define wire_h
3
 
4
#define	MAX_BUFFER	4
5
 
6
void i2c_master(void);
7
void i2c_slave(uint8_t address);
8
void i2c_beginTransmission(uint8_t address);
9
uint8_t i2c_endTransmission(uint8_t sentStop);
10
uint8_t i2c_writeByte(uint8_t data);
11
uint8_t i2c_writeBytes(uint8_t *data, uint8_t bytes);
12
void i2c_onReceiveService(uint8_t* inBytes, int numBytes);
13
void i2c_onRequestService(void);
14
void i2c_onReceive( void(*function)(uint8_t));
15
void i2c_onRequest( void(*function)(void));
16
 
17
 
18
struct {
19
        uint8_t rxBuffer[MAX_BUFFER];
20
        uint8_t rxBufferIndex;
21
        uint8_t rxBufferLength;
22
 
23
        uint8_t txAddress;
24
        uint8_t txBuffer[MAX_BUFFER];
25
        uint8_t txBufferIndex;
26
        uint8_t txBufferLength;
27
 
28
        void    (*user_onRequest)(void);
29
        void    (*user_onReceive)(uint8_t);
30
 
31
        union {
32
                uint8_t internal;
33
                struct {
34
                        uint8_t transmitting:1;
35
                        uint8_t rved:7;
36
                };
37
        };
38
} wire;
39
 
40
#endif