Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_i2c

Driver for I2C bus. More...

Data Structures

struct  bc_i2c_transfer_t
 I2C transfer parameters. More...
 
struct  bc_i2c_memory_transfer_t
 I2C memory transfer parameters. More...
 

Macros

#define BC_I2C_MEMORY_ADDRESS_16_BIT   0x80000000
 This flag extends I2C memory transfer address from 8-bit to 16-bit.
 

Enumerations

enum  bc_i2c_channel_t {
  BC_I2C_I2C0 = 0,
  BC_I2C_I2C1 = 1,
  BC_I2C_I2C_1W = 2
}
 I2C channels. More...
 
enum  bc_i2c_speed_t {
  BC_I2C_SPEED_100_KHZ = 0,
  BC_I2C_SPEED_400_KHZ = 1
}
 I2C communication speed. More...
 

Functions

void bc_i2c_init (bc_i2c_channel_t channel, bc_i2c_speed_t speed)
 Initialize I2C channel. More...
 
void bc_i2c_deinit (bc_i2c_channel_t channel)
 Deitialize I2C channel. More...
 
bc_i2c_speed_t bc_i2c_get_speed (bc_i2c_channel_t channel)
 Get speed I2C channel. More...
 
void bc_i2c_set_speed (bc_i2c_channel_t channel, bc_i2c_speed_t speed)
 Set I2C channel speed. More...
 
bool bc_i2c_write (bc_i2c_channel_t channel, const bc_i2c_transfer_t *transfer)
 Write to I2C channel. More...
 
bool bc_i2c_read (bc_i2c_channel_t channel, const bc_i2c_transfer_t *transfer)
 Read from I2C channel. More...
 
bool bc_i2c_memory_write (bc_i2c_channel_t channel, const bc_i2c_memory_transfer_t *transfer)
 Memory write to I2C channel. More...
 
bool bc_i2c_memory_read (bc_i2c_channel_t channel, const bc_i2c_memory_transfer_t *transfer)
 Memory read from I2C channel. More...
 
bool bc_i2c_memory_write_8b (bc_i2c_channel_t channel, uint8_t device_address, uint32_t memory_address, uint8_t data)
 Memory write 1 byte to I2C channel. More...
 
bool bc_i2c_memory_write_16b (bc_i2c_channel_t channel, uint8_t device_address, uint32_t memory_address, uint16_t data)
 Memory write 2 bytes to I2C channel. More...
 
bool bc_i2c_memory_read_8b (bc_i2c_channel_t channel, uint8_t device_address, uint32_t memory_address, uint8_t *data)
 Memory read 1 byte from I2C channel. More...
 
bool bc_i2c_memory_read_16b (bc_i2c_channel_t channel, uint8_t device_address, uint32_t memory_address, uint16_t *data)
 Memory read 2 bytes from I2C channel. More...
 

Detailed Description

Driver for I2C bus.

Enumeration Type Documentation

I2C channels.

Enumerator
BC_I2C_I2C0 

I2C channel I2C0.

BC_I2C_I2C1 

I2C channel I2C1.

BC_I2C_I2C_1W 

I2C channel 1wire.

Definition at line 15 of file bc_i2c.h.

I2C communication speed.

Enumerator
BC_I2C_SPEED_100_KHZ 

I2C communication speed is 100 kHz.

BC_I2C_SPEED_400_KHZ 

I2C communication speed is 400 kHz.

Definition at line 30 of file bc_i2c.h.

Function Documentation

void bc_i2c_deinit ( bc_i2c_channel_t  channel)

Deitialize I2C channel.

Parameters
[in]channelI2C channel

Definition at line 139 of file bc_i2c.c.

Referenced by bc_zssc3123_deinit().

Here is the call graph for this function:

Here is the caller graph for this function:

bc_i2c_speed_t bc_i2c_get_speed ( bc_i2c_channel_t  channel)

Get speed I2C channel.

Parameters
[in]channelI2C channel
Returns
I2C communication speed

Definition at line 189 of file bc_i2c.c.

void bc_i2c_init ( bc_i2c_channel_t  channel,
bc_i2c_speed_t  speed 
)

Initialize I2C channel.

Parameters
[in]channelI2C channel
[in]speedI2C communication speed

Definition at line 54 of file bc_i2c.c.

Referenced by bc_atsha204_init(), bc_cy8cmbr3102_init(), bc_hdc2080_init(), bc_hts221_init(), bc_lis2dh12_init(), bc_module_infra_grid_init(), bc_mpl3115a2_init(), bc_opt3001_init(), bc_sam_m8q_init(), bc_sc16is740_init(), bc_sgp30_init(), bc_sgpc3_init(), bc_sht20_init(), bc_sht30_init(), bc_ssd1306_init(), bc_tag_nfc_init(), bc_tca9534a_init(), bc_tmp112_init(), and bc_zssc3123_init().

Here is the call graph for this function:

Here is the caller graph for this function:

bool bc_i2c_memory_read ( bc_i2c_channel_t  channel,
const bc_i2c_memory_transfer_t transfer 
)

Memory read from I2C channel.

Parameters
[in]channelI2C channel
[in]transferPointer to I2C memory transfer parameters instance
Returns
true On success
false On failure

Definition at line 365 of file bc_i2c.c.

Referenced by bc_i2c_memory_read_16b(), bc_i2c_memory_read_8b(), bc_module_infra_grid_read_values(), bc_sc16is740_read(), bc_tag_nfc_init(), and bc_tag_nfc_memory_read().

Here is the call graph for this function:

Here is the caller graph for this function:

bool bc_i2c_memory_read_16b ( bc_i2c_channel_t  channel,
uint8_t  device_address,
uint32_t  memory_address,
uint16_t *  data 
)

Memory read 2 bytes from I2C channel.

Parameters
[in]channelI2C channel
[in]device_address7-bit I2C device address
[in]memory_address8-bit I2C memory address (it can be extended to 16-bit format if OR-ed with BC_I2C_MEMORY_ADDRESS_16_BIT)
[out]dataOutput data which have been read (MSB first)

Definition at line 443 of file bc_i2c.c.

Referenced by bc_cy8cmbr3102_get_proximity().

Here is the call graph for this function:

Here is the caller graph for this function:

bool bc_i2c_memory_read_8b ( bc_i2c_channel_t  channel,
uint8_t  device_address,
uint32_t  memory_address,
uint8_t *  data 
)

Memory read 1 byte from I2C channel.

Parameters
[in]channelI2C channel
[in]device_address7-bit I2C device address
[in]memory_address8-bit I2C memory address (it can be extended to 16-bit format if OR-ed with BC_I2C_MEMORY_ADDRESS_16_BIT)
[out]dataOutput data which have been read

Definition at line 431 of file bc_i2c.c.

Referenced by bc_cy8cmbr3102_is_touch(), bc_module_infra_grid_read_thermistor(), bc_sc16is740_available(), bc_sc16is740_get_spaces_available(), bc_tca9534a_init(), and bc_tca9534a_read_port().

Here is the call graph for this function:

Here is the caller graph for this function:

bool bc_i2c_memory_write ( bc_i2c_channel_t  channel,
const bc_i2c_memory_transfer_t transfer 
)

Memory write to I2C channel.

Parameters
[in]channelI2C channel
[in]transferPointer to I2C memory transfer parameters instance
Returns
true On success
false On failure

Definition at line 327 of file bc_i2c.c.

Referenced by bc_i2c_memory_write_16b(), bc_i2c_memory_write_8b(), bc_sc16is740_write(), bc_tag_nfc_init(), and bc_tag_nfc_memory_write().

Here is the call graph for this function:

Here is the caller graph for this function:

bool bc_i2c_memory_write_16b ( bc_i2c_channel_t  channel,
uint8_t  device_address,
uint32_t  memory_address,
uint16_t  data 
)

Memory write 2 bytes to I2C channel.

Parameters
[in]channelI2C channel
[in]device_address7-bit I2C device address
[in]memory_address8-bit I2C memory address (it can be extended to 16-bit format if OR-ed with BC_I2C_MEMORY_ADDRESS_16_BIT)
[in]dataInput data to be written (MSB first)

Definition at line 414 of file bc_i2c.c.

Referenced by bc_tmp112_deinit(), bc_zssc3123_eeprom_read(), bc_zssc3123_eeprom_write(), bc_zssc3123_end_cm(), bc_zssc3123_start_cm(), and bc_zssc3123_unlock_eeprom().

Here is the call graph for this function:

Here is the caller graph for this function:

bool bc_i2c_memory_write_8b ( bc_i2c_channel_t  channel,
uint8_t  device_address,
uint32_t  memory_address,
uint8_t  data 
)

Memory write 1 byte to I2C channel.

Parameters
[in]channelI2C channel
[in]device_address7-bit I2C device address
[in]memory_address8-bit I2C memory address (it can be extended to 16-bit format if OR-ed with BC_I2C_MEMORY_ADDRESS_16_BIT)
[in]dataInput data to be written

Definition at line 402 of file bc_i2c.c.

Referenced by bc_lis2dh12_set_alarm(), bc_sc16is740_init(), bc_sc16is740_reset_fifo(), bc_tca9534a_set_port_direction(), and bc_tca9534a_write_port().

Here is the call graph for this function:

Here is the caller graph for this function:

bool bc_i2c_read ( bc_i2c_channel_t  channel,
const bc_i2c_transfer_t transfer 
)

Read from I2C channel.

Parameters
[in]channelI2C channel
[in]transferPointer to I2C transfer parameters instance
Returns
true On success
false On failure

Definition at line 283 of file bc_i2c.c.

Referenced by bc_zssc3123_eeprom_read().

Here is the call graph for this function:

Here is the caller graph for this function:

void bc_i2c_set_speed ( bc_i2c_channel_t  channel,
bc_i2c_speed_t  speed 
)

Set I2C channel speed.

Parameters
[in]channelI2C channel
[in]speedI2C communication speed

Definition at line 194 of file bc_i2c.c.

Referenced by bc_i2c_init().

Here is the call graph for this function:

Here is the caller graph for this function:

bool bc_i2c_write ( bc_i2c_channel_t  channel,
const bc_i2c_transfer_t transfer 
)

Write to I2C channel.

Parameters
[in]channelI2C channel
[in]transferPointer to I2C transfer parameters instance
Returns
true On success
false On failure

Definition at line 237 of file bc_i2c.c.

Here is the call graph for this function: