1 #define F_CPU 8000000UL
3 #include <avr/interrupt.h>
4 #include <util/delay.h>
7 #include "USI_TWI_Master.h"
14 void MAX1164x_config(uint8_t setup,uint8_t config){
16 I2c_WriteByte (0b01101100);
17 I2c_WriteByte (setup|0x80);
18 I2c_WriteByte (config);
22 int16_t MAX1164x_read() {
25 I2c_WriteByte (0b01101101);
26 //DDR_USI&=~(1<<PIN_USI_SCL);
27 //while ((PIN_USI&(1<<PIN_USI_SCL))==0);
28 //DDR_USI|=(1<<PIN_USI_SCL);
30 res=((int16_t)(I2c_ReadByte(ACK)&0x0F))<<8;
31 res|=I2c_ReadByte(NO_ACK);
40 int16_t MAX1164x_read8() {
43 I2c_WriteByte (0b01101101);
44 //DDR_USI&=~(1<<PIN_USI_SCL);
45 //while ((PIN_USI&(1<<PIN_USI_SCL))==0);
46 //DDR_USI|=(1<<PIN_USI_SCL);
48 res=((int16_t)(I2c_ReadByte(ACK)&0x0F))<<8;
49 res|=I2c_ReadByte(NO_ACK);