You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
#ifndef _I2C_HPP_
|
|
#define _I2C_HPP_
|
|
|
|
#include <stdint.h>
|
|
|
|
template <typename Derived>
|
|
struct I2C
|
|
{
|
|
uint8_t readByte(const uint8_t& address, const uint8_t& reg)
|
|
{
|
|
return static_cast<Derived*>(this)->readByteImpl(address, reg);
|
|
}
|
|
|
|
uint16_t readWord(const uint8_t& address, const uint8_t& reg)
|
|
{
|
|
return static_cast<Derived*>(this)->readWordImpl(address,reg);
|
|
}
|
|
|
|
uint8_t writeByte(const uint8_t& address, const uint8_t& data)
|
|
{
|
|
return static_cast<Derived*>(this)->writeByteImpl(address,data);
|
|
}
|
|
|
|
uint8_t writeWord(const uint8_t& address, const uint8_t& reg, const uint8_t& data)
|
|
{
|
|
return static_cast<Derived*>(this)->writeWordImpl(address, reg, data);
|
|
}
|
|
|
|
void writeBuffer(const uint8_t& address, const uint8_t* buffer, uint8_t len)
|
|
{
|
|
static_cast<Derived*>(this)->writeBufferImpl(address, buffer, len);
|
|
}
|
|
|
|
void readBuffer(const uint8_t& address, const uint8_t* buffer, uint8_t len)
|
|
{
|
|
static_cast<Derived*>(this)->readBufferImpl(address, buffer, len);
|
|
}
|
|
};
|
|
|
|
#endif // _I2C_HPP_
|