Вы про бит чтения.запись? Там получается что у устройства адрес 1101000 семи разрядный + бит этот получается 11010000=0xd0 Я на основе примера из CodeVisin пытался сделать там часы работают
i2c_start(); i2c_write(0xd0); i2c_write(0); i2c_start(); i2c_write(0xd1); *sec=bcd2bin(i2c_read(1)); *min=bcd2bin(i2c_read(1)); *hour=bcd2bin(i2c_read(0)); i2c_stop();
А вот как это с функциями из avrlib это проделать не знаю что то упускаю пробовал вот так
i2cSetBitrate(100); i2cInit();
i2cSendStart();
i2cSendByte(0xD0);
i2cSendByte(0);
i2cSendStop();
i2cSendStart();
i2cSendByte(0xD1);
sek=i2cGetReceivedByte();
i2cSendStop();
Но где то ошибка есть =(((
Вот функции которые есть в avrlib
// functions
//! Initialize I2C (TWI) interface void i2cInit(void);
//! Set the I2C transaction bitrate (in KHz) void i2cSetBitrate(u16 bitrateKHz);
// I2C setup and configurations commands //! Set the local (AVR processor's) I2C device address void i2cSetLocalDeviceAddr(u08 deviceAddr, u08 genCallEn);
//! Set the user function which handles receiving (incoming) data as a slave void i2cSetSlaveReceiveHandler(void (*i2cSlaveRx_func)(u08 receiveDataLength, u08* recieveData)); //! Set the user function which handles transmitting (outgoing) data as a slave void i2cSetSlaveTransmitHandler(u08 (*i2cSlaveTx_func)(u08 transmitDataLengthMax, u08* transmitData));
// Low-level I2C transaction commands //! Send an I2C start condition in Master mode void i2cSendStart(void); //! Send an I2C stop condition in Master mode void i2cSendStop(void); //! Wait for current I2C operation to complete void i2cWaitForComplete(void); //! Send an (address|R/W) combination or a data byte over I2C void i2cSendByte(u08 data); //! Receive a data byte over I2C // ackFlag = TRUE if recevied data should be ACK'ed // ackFlag = FALSE if recevied data should be NACK'ed void i2cReceiveByte(u08 ackFlag); //! Pick up the data that was received with i2cReceiveByte() u08 i2cGetReceivedByte(void); //! Get current I2c bus status from TWSR u08 i2cGetStatus(void);
// high-level I2C transaction commands
//! send I2C data to a device on the bus void i2cMasterSend(u08 deviceAddr, u08 length, u08 *data); //! receive I2C data from a device on the bus void i2cMasterReceive(u08 deviceAddr, u08 length, u08* data);
//! send I2C data to a device on the bus (non-interrupt based) u08 i2cMasterSendNI(u08 deviceAddr, u08 length, u08* data); //! receive I2C data from a device on the bus (non-interrupt based) u08 i2cMasterReceiveNI(u08 deviceAddr, u08 length, u08 *data);
//! Get the current high-level state of the I2C interface eI2cStateType i2cGetState(void);
#endif
|