주요 내용으로 건너뛰기

I2C

platform/driver/i2c/I2C.hpp

Platform independent interface for I2C drivers.

Public Functions

I2C(uint8_t ch)
Initializes a new instance of the I2C class.
virtual voidinit() =0
Initializes the I2C driver.
virtual boolreadRegister(uint8_t addr, uint8_t reg, uint8_t * data, uint32_t cnt) =0
Reads the specified register on the device with the specified address.
virtual boolwriteRegister(uint8_t addr, uint8_t reg, uint8_t val) =0
Writes the specified value in a register.
virtual ~I2C()
Finalizes an instance of the I2C class.

Protected Attributes

uint8_tchannel
I2c channel is stored in order to initialize and recover a specific I2C channel.

Public Functions Documentation

I2C

I2C(uint8_tch)

Initializes a new instance of the I2C class.

Stores the channel of the I2C bus to be configured.

Parameters:
chI2C channel.

init

virtual void init()=0

Initializes the I2C driver.

readRegister

virtual bool readRegister(uint8_taddr ,=0
uint8_treg ,=0
uint8_t *data ,=0
uint32_tcnt=0
)=0

Reads the specified register on the device with the specified address.

Parameters:
addrThe I2C device address.
regThe register.
dataPointer to buffer in which to place the result.
cntSize of buffer in bytes.
Returns:

true on success, false otherwise.

writeRegister

virtual bool writeRegister(uint8_taddr ,=0
uint8_treg ,=0
uint8_tval=0
)=0

Writes the specified value in a register.

Parameters:
addrThe I2C device address.
regThe register.
valThe new value.
Returns:

true on success, false otherwise.

~I2C

virtual ~I2C()

Finalizes an instance of the I2C class.

Protected Attributes Documentation

channel

uint8_t channel

I2c channel is stored in order to initialize and recover a specific I2C channel.