7 #define F_CPU 16000000UL
16 // Address location defines (Keymap should be last, as it's size is dynamic)
17 #define I2C_BACKLIT_START 0x00
18 // Need 4 bytes for RGB (32 bit)
19 #define I2C_RGB_START 0x01
20 #define I2C_KEYMAP_START 0x06
22 // Slave buffer (8bit per)
23 // Rows per hand + backlit space + rgb space
24 // TODO : Make this dynamically sized
25 #define SLAVE_BUFFER_SIZE 0x20
27 // i2c SCL clock frequency
28 #define SCL_CLOCK 400000L
30 // Support 8bits right now (8 cols) will need to edit to take higher (code exists in delta split?)
31 extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
33 void i2c_master_init(void);
34 uint8_t i2c_master_start(uint8_t address);
35 void i2c_master_stop(void);
36 uint8_t i2c_master_write(uint8_t data);
37 uint8_t i2c_master_write_data(void *const TXdata, uint8_t dataLen);
38 uint8_t i2c_master_read(int);
39 void i2c_reset_state(void);
40 void i2c_slave_init(uint8_t address);
43 static inline unsigned char i2c_start_read(unsigned char addr) {
44 return i2c_master_start((addr << 1) | I2C_READ);
47 static inline unsigned char i2c_start_write(unsigned char addr) {
48 return i2c_master_start((addr << 1) | I2C_WRITE);
51 // from SSD1306 scrips
52 extern unsigned char i2c_rep_start(unsigned char addr);
53 extern void i2c_start_wait(unsigned char addr);
54 extern unsigned char i2c_readAck(void);
55 extern unsigned char i2c_readNak(void);
56 extern unsigned char i2c_read(unsigned char ack);
58 #define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak();