summaryrefslogtreecommitdiff
path: root/i2csensor.h
diff options
context:
space:
mode:
Diffstat (limited to 'i2csensor.h')
-rw-r--r--i2csensor.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/i2csensor.h b/i2csensor.h
new file mode 100644
index 0000000..1878e16
--- /dev/null
+++ b/i2csensor.h
@@ -0,0 +1,26 @@
+#ifndef I2CSENSOR_H
+#define I2CSENSOR_H
+
+#include <stdint.h>
+
+#include <ch.h>
+#include <hal.h>
+
+class I2CSensor {
+ private:
+ static I2CSlaveConfig i2c_slave_conf;
+
+ public:
+ static void enable_bus();
+
+ protected:
+ uint8_t i2c_address;
+
+ void write(uint8_t reg, uint8_t value);
+ void read(uint8_t reg, size_t len);
+
+ static uint8_t rxdata[8];
+ static uint8_t txdata[2];
+};
+
+#endif