PU2CLR BK108X Arduino Library 1.0.2
This is an Arduino Library to control the BK108X device
Loading...
Searching...
No Matches
BEKEN I2C BUS

About I2C Address on BK1086/88 and Arduino platform. More...

Functions

void BK108X::setI2C (uint8_t i2c_addr=I2C_DEVICE_ADDR)
 Sets I2C bus address.
 
void BK108X::i2cInit (int pin_sdio, int pin_sclk)
 Sets the MCU pins connected to the I2C bus.
 
void BK108X::i2cBeginTransaction ()
 Starts the I2C bus transaction.
 
void BK108X::i2cEndTransaction ()
 Finish the I2C bus transaction.
 
void BK108X::i2cAck ()
 Sends Acknowledge (ACK)
 
void BK108X::i2cNack ()
 Sends Not Acknowledge (ACK)
 
uint8_t BK108X::i2cReceiveAck ()
 Gets Acknowledge (ACK)
 
void BK108X::i2cWriteByte (uint8_t data)
 Sends a Byte to the slave device.
 
uint8_t BK108X::i2cReadByte ()
 Gets a Byte from the slave device.
 
void BK108X::writeRegister (uint8_t reg, uint16_t vakue)
 Sends an array of values to a BK108X given register.
 
uint16_t BK108X::readRegister (uint8_t reg)
 Gets an array of values from a BK108X given register.
 

Detailed Description

About I2C Address on BK1086/88 and Arduino platform.

I2C

The BK1086/88 Datasheet says that the I2C buss address is 0x80. However, the Wire (I2C) Arduino library does not find the device on 0x80. Actually the Arduino finds the device on 0x40. This must be due to the internal conversion of the address from 8 bits to 7 bits. (0x80 = 0b10000000; 0x40 = 0b01000000) After a few unsuccessful attempts at using the Arduino I2C library, I decided to write the necessary I2C routines to deal with BK1086/88 device.

See also
setI2C, i2cInit, i2cStart, i2cEndTransaction(), i2cAck, i2cNack, i2cReceiveAck, i2cWriteByte, i2cReadByte, writeRegister, readRegister

IMPORTANT: For stable communication, the rising edge time of SCLK should be less than 200ns.

Function Documentation

◆ setI2C()

void BK108X::setI2C ( uint8_t  i2c_addr = I2C_DEVICE_ADDR)

Sets I2C bus address.

Useful if some release of BEKEN device is different of 0x80.

Parameters
i2c_addr

Definition at line 43 of file BK108X.cpp.

◆ i2cInit()

void BK108X::i2cInit ( int  pin_sdio,
int  pin_sclk 
)

Sets the MCU pins connected to the I2C bus.

Configures the I2C bus for BK108X

Parameters
pin_sdioSDA/SDIO MCU/Arduino pin
pin_sclkCLK/SCLK MCU/Arduino pin

Definition at line 56 of file BK108X.cpp.

Referenced by BK108X::setup().

◆ i2cBeginTransaction()

void BK108X::i2cBeginTransaction ( )

Starts the I2C bus transaction.

Definition at line 66 of file BK108X.cpp.

Referenced by BK108X::readRegister(), and BK108X::writeRegister().

◆ i2cEndTransaction()

void BK108X::i2cEndTransaction ( )

Finish the I2C bus transaction.

Definition at line 85 of file BK108X.cpp.

Referenced by BK108X::readRegister(), and BK108X::writeRegister().

◆ i2cAck()

void BK108X::i2cAck ( )

Sends Acknowledge (ACK)

Each byte of data (including the address byte) have to be followed by one ACK bit from the receiver.

The ACK bit allows the receiver to communicate to the transmitter.

See also
https://www.ti.com/lit/an/slva704/slva704.pdf

Definition at line 105 of file BK108X.cpp.

Referenced by BK108X::readRegister().

◆ i2cNack()

void BK108X::i2cNack ( )

Sends Not Acknowledge (ACK)

See also
https://www.ti.com/lit/an/slva704/slva704.pdf

Definition at line 121 of file BK108X.cpp.

Referenced by BK108X::readRegister().

◆ i2cReceiveAck()

uint8_t BK108X::i2cReceiveAck ( )

Gets Acknowledge (ACK)

See also
https://www.ti.com/lit/an/slva704/slva704.pdf
Returns
ack value

Definition at line 139 of file BK108X.cpp.

◆ i2cWriteByte()

void BK108X::i2cWriteByte ( uint8_t  data)

Sends a Byte to the slave device.

Parameters
datato be sent to the slave device

Definition at line 161 of file BK108X.cpp.

◆ i2cReadByte()

uint8_t BK108X::i2cReadByte ( )

Gets a Byte from the slave device.

Returns
value read from the device

Definition at line 184 of file BK108X.cpp.

◆ writeRegister()

void BK108X::writeRegister ( uint8_t  reg,
uint16_t  value 
)

Sends an array of values to a BK108X given register.

Parameters
regregister to be written
valuecontent to be stored into the register

Definition at line 211 of file BK108X.cpp.

References BK108X::deviceAddress, BK108X::i2cBeginTransaction(), and BK108X::i2cEndTransaction().

◆ readRegister()

uint16_t BK108X::readRegister ( uint8_t  reg)

Gets an array of values from a BK108X given register.

Parameters
regregister to be read
Returns
register content

Definition at line 240 of file BK108X.cpp.

References BK108X::deviceAddress, BK108X::i2cAck(), BK108X::i2cBeginTransaction(), BK108X::i2cEndTransaction(), and BK108X::i2cNack().