mirror of
https://git.proxmox.com/git/qemu
synced 2025-07-09 08:42:32 +00:00
bitbang_i2c: Fix spurious slave read after NACK
After NACKing a read operation, a raising SCL should not trigger a new read from the slave. Introduce a new state which just waits for a stop or start condition after NACK. Signed-off-by: Marcus Comstedt <marcus@mc.pp.se> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
This commit is contained in:
parent
42a623c7db
commit
2eb9f24182
@ -38,7 +38,8 @@ typedef enum bitbang_i2c_state {
|
|||||||
RECEIVING_BIT2,
|
RECEIVING_BIT2,
|
||||||
RECEIVING_BIT1,
|
RECEIVING_BIT1,
|
||||||
RECEIVING_BIT0,
|
RECEIVING_BIT0,
|
||||||
SENDING_ACK
|
SENDING_ACK,
|
||||||
|
SENT_NACK
|
||||||
} bitbang_i2c_state;
|
} bitbang_i2c_state;
|
||||||
|
|
||||||
struct bitbang_i2c_interface {
|
struct bitbang_i2c_interface {
|
||||||
@ -115,6 +116,7 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
|
|||||||
}
|
}
|
||||||
switch (i2c->state) {
|
switch (i2c->state) {
|
||||||
case STOPPED:
|
case STOPPED:
|
||||||
|
case SENT_NACK:
|
||||||
return bitbang_i2c_ret(i2c, 1);
|
return bitbang_i2c_ret(i2c, 1);
|
||||||
|
|
||||||
case SENDING_BIT7 ... SENDING_BIT0:
|
case SENDING_BIT7 ... SENDING_BIT0:
|
||||||
@ -155,6 +157,7 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
|
|||||||
i2c->state = RECEIVING_BIT7;
|
i2c->state = RECEIVING_BIT7;
|
||||||
if (data != 0) {
|
if (data != 0) {
|
||||||
DPRINTF("NACKED\n");
|
DPRINTF("NACKED\n");
|
||||||
|
i2c->state = SENT_NACK;
|
||||||
i2c_nack(i2c->bus);
|
i2c_nack(i2c->bus);
|
||||||
} else {
|
} else {
|
||||||
DPRINTF("ACKED\n");
|
DPRINTF("ACKED\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user