IoAbstraction
Functions
wireHelpers.h File Reference

a series of wire helper functions that make dealing with device register IO simpler More...

Go to the source code of this file.

Functions

void write4BitToReg8 (WireType wireImpl, uint8_t i2cAddress, uint8_t reg, bool lowBits, uint8_t val)
 
void toggleBitInRegister16 (WireType wireType, uint8_t addr, uint8_t regAddr, uint8_t theBit, bool value)
 
void toggleBitInRegister8 (WireType wireType, uint8_t addr, uint8_t regAddr, uint8_t theBit, bool value)
 
bool wireWriteReg8 (WireType wireType, uint8_t addr, uint8_t reg, uint8_t command)
 
bool wireWriteReg16 (WireType wireType, uint8_t addr, uint8_t reg, uint16_t command)
 
uint8_t wireReadReg8 (WireType wireType, uint8_t addr, uint8_t reg)
 
uint16_t wireReadReg16 (WireType wireType, uint8_t addr, uint8_t reg)
 

Detailed Description

a series of wire helper functions that make dealing with device register IO simpler

Function Documentation

◆ write4BitToReg8()

void write4BitToReg8 ( WireType  wireImpl,
uint8_t  i2cAddress,
uint8_t  reg,
bool  lowBits,
uint8_t  val 
)

Writes a 4 bit value into an 8 bit register preserving the other 4 bits.

Parameters
wireImplthe wire implementation to use.
i2cAddressthe i2c address
regthe register to write to
lowBitsif the low or high bits are to be modified
valthe new value between 0..15

◆ toggleBitInRegister16()

void toggleBitInRegister16 ( WireType  wireType,
uint8_t  addr,
uint8_t  regAddr,
uint8_t  theBit,
bool  value 
)

Toggles a bit in a 16 bit register to the new value

Parameters
wireTypethe wire implementation to use
addrthe i2c address
regAddrthe register to write to
theBitthe bit to change
valuethe new value

◆ toggleBitInRegister8()

void toggleBitInRegister8 ( WireType  wireType,
uint8_t  addr,
uint8_t  regAddr,
uint8_t  theBit,
bool  value 
)

Toggles a bit in an 8 bit register to the new value

Parameters
wireTypethe wire implementation to use
addrthe i2c address
regAddrthe register to write to
theBitthe bit to change
valuethe new value

◆ wireWriteReg8()

bool wireWriteReg8 ( WireType  wireType,
uint8_t  addr,
uint8_t  reg,
uint8_t  command 
)

Writes an 8 bit value to a register

Parameters
wireTypethe wire implementation
addrthe i2c address
regthe register to change
commandthe value for the register
Returns
true if success

◆ wireWriteReg16()

bool wireWriteReg16 ( WireType  wireType,
uint8_t  addr,
uint8_t  reg,
uint16_t  command 
)

Writes a 16 bit value to a register

Parameters
wireTypethe wire implementation
addrthe i2c address
regthe register to change
commandthe value for the register
Returns
true if success

◆ wireReadReg8()

uint8_t wireReadReg8 ( WireType  wireType,
uint8_t  addr,
uint8_t  reg 
)

Reads an 8 bit value from a given register

Parameters
wireTypethe wire implementation
addrthe i2c address
regthe register to read
Returns
the register value

◆ wireReadReg16()

uint16_t wireReadReg16 ( WireType  wireType,
uint8_t  addr,
uint8_t  reg 
)

Reads a 16 bit value from a given register

Parameters
wireTypethe wire implementation
addrthe i2c address
regthe register to read
Returns
the register value