diff options
author | Daniel Friesel <derf@finalrewind.org> | 2018-01-15 10:16:13 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2018-01-15 10:16:13 +0100 |
commit | 7b8c37d235c77d881db4184a798fc4b72a1fa279 (patch) | |
tree | 974caf26a3964f1650285ae80f6c924d29474abd /include | |
parent | c374e91391d3e58295375f439b15fe888bcdb3bd (diff) |
Add Software I2C implementation
Diffstat (limited to 'include')
-rw-r--r-- | include/driver/soft_i2c.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/driver/soft_i2c.h b/include/driver/soft_i2c.h new file mode 100644 index 0000000..aff63e3 --- /dev/null +++ b/include/driver/soft_i2c.h @@ -0,0 +1,26 @@ +#ifndef SOFTI2C_H +#define SOFTI2C_H + +class SoftI2C { + private: + SoftI2C(const SoftI2C ©); + + unsigned char sda, scl; + + void start(); + void stop(); + bool tx(unsigned char byte); + unsigned char rx(bool send_ack); + + public: + SoftI2C(unsigned char sda, unsigned char scl) : sda(sda), scl(scl) {} + signed char setup(); + void scan(unsigned int *results); + signed char xmit(unsigned char address, + unsigned char tx_len, unsigned char *tx_buf, + unsigned char rx_len, unsigned char *rx_buf); +}; + +extern SoftI2C i2c; + +#endif |