Merge tag 'pull-loongarch-20241016' of https://gitlab.com/gaosong/qemu into staging
[qemu/armbru.git] / include / hw / i2c / bitbang_i2c.h
bloba079e6d70f99fcd2341b2d1729d8c4cbf6f938aa
1 #ifndef BITBANG_I2C_H
2 #define BITBANG_I2C_H
4 #include "hw/i2c/i2c.h"
6 #define TYPE_GPIO_I2C "gpio_i2c"
8 typedef struct bitbang_i2c_interface bitbang_i2c_interface;
10 #define BITBANG_I2C_SDA 0
11 #define BITBANG_I2C_SCL 1
13 typedef enum bitbang_i2c_state {
14 STOPPED = 0,
15 SENDING_BIT7,
16 SENDING_BIT6,
17 SENDING_BIT5,
18 SENDING_BIT4,
19 SENDING_BIT3,
20 SENDING_BIT2,
21 SENDING_BIT1,
22 SENDING_BIT0,
23 WAITING_FOR_ACK,
24 RECEIVING_BIT7,
25 RECEIVING_BIT6,
26 RECEIVING_BIT5,
27 RECEIVING_BIT4,
28 RECEIVING_BIT3,
29 RECEIVING_BIT2,
30 RECEIVING_BIT1,
31 RECEIVING_BIT0,
32 SENDING_ACK,
33 SENT_NACK
34 } bitbang_i2c_state;
36 struct bitbang_i2c_interface {
37 I2CBus *bus;
38 bitbang_i2c_state state;
39 int last_data;
40 int last_clock;
41 int device_out;
42 uint8_t buffer;
43 int current_addr;
46 /**
47 * bitbang_i2c_init: in-place initialize the bitbang_i2c_interface struct
49 void bitbang_i2c_init(bitbang_i2c_interface *s, I2CBus *bus);
50 int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level);
52 #endif