40 lines
511 B
C++
40 lines
511 B
C++
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "hardware.hpp"
|
|
|
|
namespace i2c {
|
|
|
|
template <class Driver>
|
|
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();
|
|
}
|
|
};
|
|
|
|
} // namespace i2c
|