Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_i2c.h
1 #ifndef _BC_I2C_H
2 #define _BC_I2C_H
3 
4 #include <bc_common.h>
5 
9 
11 #define BC_I2C_MEMORY_ADDRESS_16_BIT 0x80000000
12 
14 
15 typedef enum
16 {
19 
22 
25 
27 
29 
30 typedef enum
31 {
34 
37 
39 
41 
42 typedef struct
43 {
45  uint8_t device_address;
46 
48  void *buffer;
49 
51  size_t length;
52 
54 
56 
57 typedef struct
58 {
60  uint8_t device_address;
61 
63  uint32_t memory_address;
64 
66  void *buffer;
67 
69  size_t length;
70 
72 
76 
77 void bc_i2c_init(bc_i2c_channel_t channel, bc_i2c_speed_t speed);
78 
81 
82 void bc_i2c_deinit(bc_i2c_channel_t channel);
83 
87 
89 
93 
95 
101 
102 bool bc_i2c_write(bc_i2c_channel_t channel, const bc_i2c_transfer_t *transfer);
103 
109 
110 bool bc_i2c_read(bc_i2c_channel_t channel, const bc_i2c_transfer_t *transfer);
111 
117 
118 bool bc_i2c_memory_write(bc_i2c_channel_t channel, const bc_i2c_memory_transfer_t *transfer);
119 
125 
126 bool bc_i2c_memory_read(bc_i2c_channel_t channel, const bc_i2c_memory_transfer_t *transfer);
127 
133 
134 bool bc_i2c_memory_write_8b(bc_i2c_channel_t channel, uint8_t device_address, uint32_t memory_address, uint8_t data);
135 
141 
142 bool bc_i2c_memory_write_16b(bc_i2c_channel_t channel, uint8_t device_address, uint32_t memory_address, uint16_t data);
143 
149 
150 bool bc_i2c_memory_read_8b(bc_i2c_channel_t channel, uint8_t device_address, uint32_t memory_address, uint8_t *data);
151 
157 
158 bool bc_i2c_memory_read_16b(bc_i2c_channel_t channel, uint8_t device_address, uint32_t memory_address, uint16_t *data);
159 
161 
162 #endif // _BC_I2C_H
void * buffer
Pointer to buffer which is being written or read.
Definition: bc_i2c.h:66
I2C transfer parameters.
Definition: bc_i2c.h:42
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.
Definition: bc_i2c.c:414
I2C communication speed is 400 kHz.
Definition: bc_i2c.h:36
I2C channel I2C0.
Definition: bc_i2c.h:18
bc_i2c_speed_t bc_i2c_get_speed(bc_i2c_channel_t channel)
Get speed I2C channel.
Definition: bc_i2c.c:189
uint8_t device_address
7-bit I2C device address
Definition: bc_i2c.h:45
bool bc_i2c_memory_read(bc_i2c_channel_t channel, const bc_i2c_memory_transfer_t *transfer)
Memory read from I2C channel.
Definition: bc_i2c.c:365
bool bc_i2c_read(bc_i2c_channel_t channel, const bc_i2c_transfer_t *transfer)
Read from I2C channel.
Definition: bc_i2c.c:283
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.
Definition: bc_i2c.c:431
void bc_i2c_init(bc_i2c_channel_t channel, bc_i2c_speed_t speed)
Initialize I2C channel.
Definition: bc_i2c.c:54
void bc_i2c_deinit(bc_i2c_channel_t channel)
Deitialize I2C channel.
Definition: bc_i2c.c:139
I2C communication speed is 100 kHz.
Definition: bc_i2c.h:33
void * buffer
Pointer to buffer which is being written or read.
Definition: bc_i2c.h:48
bool bc_i2c_write(bc_i2c_channel_t channel, const bc_i2c_transfer_t *transfer)
Write to I2C channel.
Definition: bc_i2c.c:237
uint32_t memory_address
8-bit I2C memory address (it can be extended to 16-bit format if OR-ed with BC_I2C_MEMORY_ADDRESS_16_...
Definition: bc_i2c.h:63
uint8_t device_address
7-bit I2C device address
Definition: bc_i2c.h:60
I2C memory transfer parameters.
Definition: bc_i2c.h:57
bc_i2c_channel_t
I2C channels.
Definition: bc_i2c.h:15
void bc_i2c_set_speed(bc_i2c_channel_t channel, bc_i2c_speed_t speed)
Set I2C channel speed.
Definition: bc_i2c.c:194
size_t length
Length of buffer which is being written or read.
Definition: bc_i2c.h:51
bc_i2c_speed_t
I2C communication speed.
Definition: bc_i2c.h:30
I2C channel I2C1.
Definition: bc_i2c.h:21
size_t length
Length of buffer which is being written or read.
Definition: bc_i2c.h:69
bool bc_i2c_memory_write(bc_i2c_channel_t channel, const bc_i2c_memory_transfer_t *transfer)
Memory write to I2C channel.
Definition: bc_i2c.c:327
I2C channel 1wire.
Definition: bc_i2c.h:24
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.
Definition: bc_i2c.c:443
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.
Definition: bc_i2c.c:402