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.

69 lines
940 B

#ifndef _I2C_HPP_
#define _I2C_HPP_
#include <stdint.h>
#include <unistd.h>
#include <iostream>
#include <memory>
namespace hw
{
// i2c channels
enum i2c_ch
{
i2c_ch0,
i2c_ch1
};
//
// template
//
template<i2c_ch>
class I2C
{
public:
I2C();
void writeByte(uint8_t address, uint8_t byte);
private:
};
//
// implementation CH0
//
template<>
I2C<i2c_ch0>::I2C()
{
std::cout << "i2c_ch0 has been created" << std::endl;
}
template<>
void I2C<i2c_ch0>::writeByte(uint8_t address, uint8_t byte)
{
std::cout << "wrtiteByte() of i2c CH0 has been called!" << std::endl;
}
//
// implementation CH1
//
template<>
I2C<i2c_ch1>::I2C()
{
std::cout << "i2c_ch1 has been created" << std::endl;
}
template<>
void I2C<i2c_ch1>::writeByte(uint8_t address, uint8_t byte)
{
std::cout << "wrtiteByte() of i2c CH1 has been called!" << std::endl;
}
}; // namespace hw
#endif // _I2C_HPP_