diff options
Diffstat (limited to 'i2c.h')
-rw-r--r-- | i2c.h | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -3,12 +3,36 @@ #include <stdint.h> +#include "interrupt.h" + class I2C { + friend void interrupt<Interrupt::I2C1_EV>(); + friend void interrupt<Interrupt::I2C1_ER>(); + + private: + static I2C* self; + + volatile uint8_t addr; + volatile uint8_t writing; + volatile uint8_t reading; + volatile uint8_t* write_p; + volatile uint8_t* read_p; + + volatile bool busy; + + void irq_ev(); + void irq_er(); + void handle_error(); + public: + I2C() { + self = this; + } + void enable(); - void write_reg(uint8_t addr, uint8_t reg, uint8_t data); - void read_reg(uint8_t addr, uint8_t reg, uint8_t len, uint8_t* buf); + void write_reg(uint8_t addr_, uint8_t reg, uint8_t data); + void read_reg(uint8_t addr_, uint8_t reg, uint8_t len, uint8_t* buf); }; |