Subversion Repositories group.electronics

Rev

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

Rev 123 Rev 124
Line 17... Line 17...
17
#define	INTCAP	0x08	// GPIO value at interrupt (RO)
17
#define	INTCAP	0x08	// GPIO value at interrupt (RO)
18
#define	GPIO	0x09	// Read value of pins
18
#define	GPIO	0x09	// Read value of pins
19
#define OLAT	0x0a	// Latch pins (write)
19
#define OLAT	0x0a	// Latch pins (write)
20
 
20
 
21
void mio_init() {
21
void mio_init() {
22
  mio.i2c_addr = 0x20;
22
  mio_init_addr(0x20);
23
}
23
}
24
 
24
 
25
void mio_init_addr(uint8_t i2c_addr) {
25
void mio_init_addr(uint8_t i2c_addr) {
26
  mio.i2c_addr = i2c_addr;
26
  mio.i2c_addr = i2c_addr;
-
 
27
  i2c_beginTransmission(mio.i2c_addr);
-
 
28
  i2c_writeByte(IODIR);		// Start at 0x00
-
 
29
  i2c_writeByte(0xFF);		// Set IODIR to all inputs
-
 
30
  i2c_writeByte(0x00);		// Everything else default 0x00
-
 
31
  i2c_writeByte(0x00);
-
 
32
  i2c_writeByte(0x00);
-
 
33
  i2c_writeByte(0x00);
-
 
34
  i2c_writeByte(0x00);
-
 
35
  i2c_writeByte(0x00);
-
 
36
  i2c_writeByte(0x00);
-
 
37
  i2c_writeByte(0x00);
-
 
38
  i2c_writeByte(0x00);
-
 
39
  i2c_endTransmission(1);
-
 
40
 
27
}
41
}
28
 
42
 
29
inline uint8_t mio_readPin(uint8_t pin) {
43
inline uint8_t mio_readPin(uint8_t pin) {
30
    return rbi(mio_read(), pin);
44
    return rbi(mio_read(), pin);
31
}
45
}