Add writeBytes function to allow writing multiple bytes

This commit is contained in:
BlackMark 2020-05-16 16:57:06 +02:00
parent ff131d92a1
commit 8af5afd00d

11
i2c.hpp
View File

@ -25,6 +25,17 @@ struct I2c {
return Driver::write(data); return Driver::write(data);
} }
template <size_t Bytes>
static bool writeBytes(const uint8_t *buffer)
{
for (size_t i = 0; i < Bytes; ++i) {
if (!write(buffer[i]))
return false;
}
return true;
}
template <bool LastByte = false> template <bool LastByte = false>
static uint8_t read() static uint8_t read()
{ {