PU2CLR BK108X Arduino Library 1.0.2
This is an Arduino Library to control the BK108X device
|
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. | |
About I2C Address on BK1086/88 and Arduino platform.
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.
IMPORTANT: For stable communication, the rising edge time of SCLK should be less than 200ns.
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.
i2c_addr |
Definition at line 43 of file BK108X.cpp.
void BK108X::i2cInit | ( | int | pin_sdio, |
int | pin_sclk | ||
) |
Sets the MCU pins connected to the I2C bus.
Configures the I2C bus for BK108X
pin_sdio | SDA/SDIO MCU/Arduino pin |
pin_sclk | CLK/SCLK MCU/Arduino pin |
Definition at line 56 of file BK108X.cpp.
Referenced by BK108X::setup().
void BK108X::i2cBeginTransaction | ( | ) |
Starts the I2C bus transaction.
Definition at line 66 of file BK108X.cpp.
Referenced by BK108X::readRegister(), and BK108X::writeRegister().
void BK108X::i2cEndTransaction | ( | ) |
Finish the I2C bus transaction.
Definition at line 85 of file BK108X.cpp.
Referenced by BK108X::readRegister(), and BK108X::writeRegister().
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.
Definition at line 105 of file BK108X.cpp.
Referenced by BK108X::readRegister().
void BK108X::i2cNack | ( | ) |
Sends Not Acknowledge (ACK)
Definition at line 121 of file BK108X.cpp.
Referenced by BK108X::readRegister().
uint8_t BK108X::i2cReceiveAck | ( | ) |
void BK108X::i2cWriteByte | ( | uint8_t | data | ) |
Sends a Byte to the slave device.
data | to be sent to the slave device |
Definition at line 161 of file BK108X.cpp.
uint8_t BK108X::i2cReadByte | ( | ) |
Gets a Byte from the slave device.
Definition at line 184 of file BK108X.cpp.
void BK108X::writeRegister | ( | uint8_t | reg, |
uint16_t | value | ||
) |
Sends an array of values to a BK108X given register.
reg | register to be written |
value | content to be stored into the register |
Definition at line 211 of file BK108X.cpp.
References BK108X::deviceAddress, BK108X::i2cBeginTransaction(), and BK108X::i2cEndTransaction().
uint16_t BK108X::readRegister | ( | uint8_t | reg | ) |
Gets an array of values from a BK108X given register.
reg | register to be read |
Definition at line 240 of file BK108X.cpp.
References BK108X::deviceAddress, BK108X::i2cAck(), BK108X::i2cBeginTransaction(), BK108X::i2cEndTransaction(), and BK108X::i2cNack().