printing complete status infos
This commit is contained in:
@@ -71,7 +71,7 @@ void i2c_send_addr_r(uint8_t slave_address) {
|
||||
// }
|
||||
}
|
||||
|
||||
void i2c_write(unsigned char data) {
|
||||
void i2c_write(uint8_t data) {
|
||||
if (i2c_status == STOP) {
|
||||
return;
|
||||
}
|
||||
@@ -85,18 +85,20 @@ void i2c_write(unsigned char data) {
|
||||
// }
|
||||
}
|
||||
|
||||
void i2c_read(void) {
|
||||
uint8_t i2c_read(void) {
|
||||
if (i2c_status == STOP) {
|
||||
return;
|
||||
}
|
||||
// TWDR = data; // 22.9.4 : (Data Register) load data into TWDR register
|
||||
// TWCR = SEND_CONTINUE_TRANSMISSION; // p225 example code : Load DATA into TWDR Register. Clear TWINT bit in TWCR to start transmission of data
|
||||
// while (!(TEST(TWCR, TWINT))); // p225 example code : Wait for TWINT Flag set. This indicates that the DATA has been transmitted, and ACK/NACK has been received
|
||||
|
||||
TWCR = SEND_CONTINUE_TRANSMISSION; // 22.7.1 : Master Transmitter Mode
|
||||
while (!(TEST(TWCR, TWINT))); // 22.7.1 : Wait for TWINT Flag set. This indicates that the SLA+R/W has been transmitted, and ACK/NACK has been received
|
||||
|
||||
// uint8_t status = TWSR & 0b11111000; // p225 example code : Check status for Receiver mode. Mask prescaler bits. If status different from MT_DATA_ACK go to ERROR
|
||||
// if (status != TW_MT_DATA_ACK) {
|
||||
// return i2c_stop();
|
||||
// }
|
||||
|
||||
return TWDR; // 22.9.4 : (Data Register) load data into TWDR register
|
||||
}
|
||||
|
||||
void i2c_stop(void) {
|
||||
|
||||
Reference in New Issue
Block a user