1.1 --- a/pkg/devices/lib/i2c/include/i2c-jz4730.h Sun Jan 31 22:47:14 2021 +0100
1.2 +++ b/pkg/devices/lib/i2c/include/i2c-jz4730.h Tue Feb 16 22:53:31 2021 +0100
1.3 @@ -31,6 +31,22 @@
1.4 #include <l4/devices/cpm-jz4730.h>
1.5 #include <l4/devices/hw_mmio_register_block.h>
1.6
1.7 +
1.8 +
1.9 +// State machine states.
1.10 +
1.11 +enum I2c_jz4730_state
1.12 +{
1.13 + I2c_jz4730_end = 0,
1.14 + I2c_jz4730_pre_start,
1.15 + I2c_jz4730_start_read,
1.16 + I2c_jz4730_perform_read,
1.17 + I2c_jz4730_perform_write,
1.18 + I2c_jz4730_stop_write
1.19 +};
1.20 +
1.21 +
1.22 +
1.23 // I2C channel.
1.24
1.25 class I2c_jz4730_channel
1.26 @@ -54,6 +70,21 @@
1.27 protected:
1.28 void set_frequency();
1.29
1.30 + // State machine activities.
1.31 +
1.32 + unsigned int _nread, _nwritten, _length, _limit;
1.33 + uint8_t _address;
1.34 + uint8_t *_buf;
1.35 + bool _read;
1.36 +
1.37 + void communicate();
1.38 +
1.39 + enum I2c_jz4730_state pre_start();
1.40 + enum I2c_jz4730_state start_read();
1.41 + enum I2c_jz4730_state perform_read();
1.42 + enum I2c_jz4730_state perform_write();
1.43 + enum I2c_jz4730_state stop_write();
1.44 +
1.45 // Transaction control.
1.46
1.47 bool set_address(uint8_t address, bool read);