i2c/i2c.hpp

40 lines
511 B
C++
Raw Normal View History

2019-08-05 21:21:14 +02:00
#pragma once
2019-08-05 21:43:06 +02:00
#include <stdint.h>
#include "hardware.hpp"
namespace i2c {
template <class Driver>
2019-08-05 21:43:06 +02:00
struct I2c {
static void init()
{
Driver::init();
}
template <uint8_t Addr>
static bool start(bool read)
{
return Driver::template start<Addr>(read);
}
static bool write(uint8_t data)
{
return Driver::write(data);
}
template <bool LastByte = false>
static uint8_t read()
{
return Driver::template read<LastByte>();
}
static void stop()
{
Driver::stop();
}
2019-08-05 21:43:06 +02:00
};
} // namespace i2c