1
6
7
8
14
15
16
17
18
19
20
21
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
49
50
51
52
58
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
140
141
142
143
144
145
146
147
148
149
150
159
160
161
167
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/* ... */
#pragma once
#include <stdint.h>
#include "esp_err.h"
#include "driver/i2c_types.h"
#include "hal/gpio_types.h"
#include "soc/soc_caps.h"
#include "sdkconfig.h"6 includes
#ifdef __cplusplus
extern "C" {
#endif
#if !CONFIG_I2C_ENABLE_SLAVE_DRIVER_VERSION_2
/* ... */
typedef struct {
i2c_port_num_t i2c_port;
gpio_num_t sda_io_num;
gpio_num_t scl_io_num;
i2c_clock_source_t clk_source;
uint32_t send_buf_depth;
uint16_t slave_addr;
i2c_addr_bit_len_t addr_bit_len;
int intr_priority;
struct {
#if SOC_I2C_SLAVE_CAN_GET_STRETCH_CAUSE
uint32_t stretch_en: 1;
#endif
#if SOC_I2C_SLAVE_SUPPORT_BROADCAST
uint32_t broadcast_en: 1;
#endif
#if SOC_I2C_SLAVE_SUPPORT_I2CRAM_ACCESS
uint32_t access_ram_en: 1;
#endif
#if SOC_I2C_SLAVE_SUPPORT_SLAVE_UNMATCH
uint32_t slave_unmatch_en: 1;
#endif
uint32_t allow_pd: 1;
/* ... */
}{ ... } flags;
}{ ... } i2c_slave_config_t;
/* ... */
typedef struct {
#if SOC_I2C_SLAVE_CAN_GET_STRETCH_CAUSE
i2c_slave_stretch_callback_t on_stretch_occur;
#endif
i2c_slave_received_callback_t on_recv_done;
}{ ... } i2c_slave_event_callbacks_t;
/* ... */
esp_err_t i2c_slave_receive(i2c_slave_dev_handle_t i2c_slave, uint8_t *data, size_t buffer_size);
/* ... */
esp_err_t i2c_slave_transmit(i2c_slave_dev_handle_t i2c_slave, const uint8_t *data, int size, int xfer_timeout_ms);
#if SOC_I2C_SLAVE_SUPPORT_I2CRAM_ACCESS
/* ... */
esp_err_t i2c_slave_read_ram(i2c_slave_dev_handle_t i2c_slave, uint8_t ram_address, uint8_t *data, size_t receive_size);
/* ... */
esp_err_t i2c_slave_write_ram(i2c_slave_dev_handle_t i2c_slave, uint8_t ram_address, const uint8_t *data, size_t size);
/* ... */
#endif
/* ... */
#elif CONFIG_I2C_ENABLE_SLAVE_DRIVER_VERSION_2 || __DOXYGEN__
/* ... */
typedef struct {
i2c_port_num_t i2c_port;
gpio_num_t sda_io_num;
gpio_num_t scl_io_num;
i2c_clock_source_t clk_source;
uint32_t send_buf_depth;
uint32_t receive_buf_depth;
uint16_t slave_addr;
i2c_addr_bit_len_t addr_bit_len;
int intr_priority;
struct {
uint32_t allow_pd: 1;
/* ... */
uint32_t enable_internal_pullup: 1;
#if SOC_I2C_SLAVE_SUPPORT_BROADCAST
uint32_t broadcast_en: 1;
#endif
}{...} flags;
}{...} i2c_slave_config_t;
/* ... */
typedef struct {
i2c_slave_request_callback_t on_request;
i2c_slave_received_callback_t on_receive;
}{...} i2c_slave_event_callbacks_t;
/* ... */
esp_err_t i2c_slave_write(i2c_slave_dev_handle_t i2c_slave, const uint8_t *data, uint32_t len, uint32_t *write_len, int timeout_ms);
/* ... */
#endif
/* ... */
esp_err_t i2c_new_slave_device(const i2c_slave_config_t *slave_config, i2c_slave_dev_handle_t *ret_handle);
/* ... */
esp_err_t i2c_slave_register_event_callbacks(i2c_slave_dev_handle_t i2c_slave, const i2c_slave_event_callbacks_t *cbs, void *user_data);
/* ... */
esp_err_t i2c_del_slave_device(i2c_slave_dev_handle_t i2c_slave);
#ifdef __cplusplus
}{...}
#endif