app_i2c.c里i2c_read_from()函数里i2c_master_buffer_length = length - 1;但是中断函数里
/* address sent, ack received */
if(event & RB_I2C_ADDR) {
/* ack if more bytes are expected, otherwise nack */
if (i2c_master_buffer_index + 1 < i2c_master_buffer_length) {
I2C_AcknowledgeConfig(ENABLE);
I2C_DBG(" address sent\n");
I2C_DBG(" ACK next\n");
} else {
//XXX: Should not delay too match before NACK
I2C_AcknowledgeConfig(DISABLE);
is_nack_sent = true;
I2C_DBG(" address sent\n");
I2C_DBG(" NACK next\n");
}
}
判断条件是i2c_master_buffer_index + 1 < i2c_master_buffer_length,也就是说接收1字节和2字节都是马上I2C_AcknowledgeConfig(DISABLE);3字节开始才I2C_AcknowledgeConfig(ENABLE);
这里的ACK和NACK没有错误吗?我觉得2字节开始就应该要I2C_AcknowledgeConfig(ENABLE);