diff --git a/i2c.hpp b/i2c.hpp index 00ada38..0b48f40 100644 --- a/i2c.hpp +++ b/i2c.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include "hardware.hpp" @@ -30,6 +31,17 @@ struct I2c { return Driver::template read(); } + template + static void readBytes(uint8_t *buffer) + { + static_assert(Bytes > 0, "Must read at least 1 byte"); + + for (size_t i = 0; i < Bytes - 1; ++i) { + buffer[i] = read(); + } + buffer[Bytes - 1] = read(); + } + static void stop() { Driver::stop();