-
Notifications
You must be signed in to change notification settings - Fork 7k
/
i2c_struct.h
396 lines (391 loc) · 12.3 KB
/
i2c_struct.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
typedef volatile struct {
union {
struct {
uint32_t period: 9;
uint32_t reserved9: 23;
};
uint32_t val;
} scl_low_period;
union {
struct {
uint32_t sda_force_out: 1;
uint32_t scl_force_out: 1;
uint32_t sample_scl_level: 1;
uint32_t rx_full_ack_level: 1;
uint32_t ms_mode: 1;
uint32_t trans_start: 1;
uint32_t tx_lsb_first: 1;
uint32_t rx_lsb_first: 1;
uint32_t clk_en: 1;
uint32_t arbitration_en: 1;
uint32_t fsm_rst: 1;
uint32_t conf_upgate: 1;
uint32_t slv_tx_auto_start_en: 1;
uint32_t reserved13: 19;
};
uint32_t val;
} ctr;
union {
struct {
uint32_t resp_rec: 1;
uint32_t slave_rw: 1;
uint32_t reserved2: 1;
uint32_t arb_lost: 1;
uint32_t bus_busy: 1;
uint32_t slave_addressed: 1;
uint32_t reserved6: 1;
uint32_t reserved7: 1;
uint32_t rx_fifo_cnt: 6;
uint32_t stretch_cause: 2;
uint32_t reserved16: 2;
uint32_t tx_fifo_cnt: 6;
uint32_t scl_main_state_last: 3;
uint32_t reserved27: 1;
uint32_t scl_state_last: 3;
uint32_t reserved31: 1;
};
uint32_t val;
} status_reg;
union {
struct {
uint32_t time_out_value: 5;
uint32_t time_out_en: 1;
uint32_t reserved6: 26;
};
uint32_t val;
} timeout;
union {
struct {
uint32_t addr: 15;
uint32_t reserved15: 16;
uint32_t en_10bit: 1;
};
uint32_t val;
} slave_addr;
union {
struct {
uint32_t rx_fifo_raddr: 5;
uint32_t rx_fifo_waddr: 5;
uint32_t tx_fifo_raddr: 5;
uint32_t tx_fifo_waddr: 5;
uint32_t reserved20: 1;
uint32_t reserved21: 1;
uint32_t slave_rw_point: 8;
uint32_t reserved30: 2;
};
uint32_t val;
} fifo_st;
union {
struct {
uint32_t rx_fifo_wm_thrhd: 5;
uint32_t tx_fifo_wm_thrhd: 5;
uint32_t nonfifo_en: 1;
uint32_t fifo_addr_cfg_en: 1;
uint32_t rx_fifo_rst: 1;
uint32_t tx_fifo_rst: 1;
uint32_t fifo_prt_en: 1;
uint32_t reserved15: 5;
uint32_t reserved20: 6;
uint32_t reserved26: 1;
uint32_t reserved27: 5;
};
uint32_t val;
} fifo_conf;
union {
struct {
uint32_t data;
};
uint32_t val;
} fifo_data;
union {
struct {
uint32_t rx_fifo_wm: 1;
uint32_t tx_fifo_wm: 1;
uint32_t rx_fifo_ovf: 1;
uint32_t end_detect: 1;
uint32_t byte_trans_done: 1;
uint32_t arbitration_lost: 1;
uint32_t mst_tx_fifo_udf: 1;
uint32_t trans_complete: 1;
uint32_t time_out: 1;
uint32_t trans_start: 1;
uint32_t nack: 1;
uint32_t tx_fifo_ovf: 1;
uint32_t rx_fifo_udf: 1;
uint32_t scl_st_to: 1;
uint32_t scl_main_st_to: 1;
uint32_t det_start: 1;
uint32_t slave_stretch: 1;
uint32_t reserved17: 15;
};
uint32_t val;
} int_raw;
union {
struct {
uint32_t rx_fifo_wm: 1;
uint32_t tx_fifo_wm: 1;
uint32_t rx_fifo_ovf: 1;
uint32_t end_detect: 1;
uint32_t byte_trans_done: 1;
uint32_t arbitration_lost: 1;
uint32_t mst_tx_fifo_udf: 1;
uint32_t trans_complete: 1;
uint32_t time_out: 1;
uint32_t trans_start: 1;
uint32_t nack: 1;
uint32_t tx_fifo_ovf: 1;
uint32_t rx_fifo_udf: 1;
uint32_t scl_st_to: 1;
uint32_t scl_main_st_to: 1;
uint32_t det_start: 1;
uint32_t slave_stretch: 1;
uint32_t reserved17: 15;
};
uint32_t val;
} int_clr;
union {
struct {
uint32_t rx_fifo_wm: 1;
uint32_t tx_fifo_wm: 1;
uint32_t rx_fifo_ovf: 1;
uint32_t end_detect: 1;
uint32_t byte_trans_done: 1;
uint32_t arbitration_lost: 1;
uint32_t mst_tx_fifo_udf: 1;
uint32_t trans_complete: 1;
uint32_t time_out: 1;
uint32_t trans_start: 1;
uint32_t nack: 1;
uint32_t tx_fifo_ovf: 1;
uint32_t rx_fifo_udf: 1;
uint32_t scl_st_to: 1;
uint32_t scl_main_st_to: 1;
uint32_t det_start: 1;
uint32_t slave_stretch: 1;
uint32_t reserved17: 15;
};
uint32_t val;
} int_ena;
union {
struct {
uint32_t rx_fifo_wm: 1;
uint32_t tx_fifo_wm: 1;
uint32_t rx_fifo_ovf: 1;
uint32_t end_detect: 1;
uint32_t byte_trans_done: 1;
uint32_t arbitration_lost: 1;
uint32_t mst_tx_fifo_udf: 1;
uint32_t trans_complete: 1;
uint32_t time_out: 1;
uint32_t trans_start: 1;
uint32_t nack: 1;
uint32_t tx_fifo_ovf: 1;
uint32_t rx_fifo_udf: 1;
uint32_t scl_st_to: 1;
uint32_t scl_main_st_to: 1;
uint32_t det_start: 1;
uint32_t slave_stretch: 1;
uint32_t reserved17: 15;
};
uint32_t val;
} int_status;
union {
struct {
uint32_t time: 9;
uint32_t reserved9: 23;
};
uint32_t val;
} sda_hold;
union {
struct {
uint32_t time: 9;
uint32_t reserved9: 23;
};
uint32_t val;
} sda_sample;
union {
struct {
uint32_t period: 9;
uint32_t scl_wait_high_period: 7;
uint32_t reserved16: 16;
};
uint32_t val;
} scl_high_period;
uint32_t reserved_3c;
union {
struct {
uint32_t time: 9;
uint32_t reserved9: 23;
};
uint32_t val;
} scl_start_hold;
union {
struct {
uint32_t time: 9;
uint32_t reserved9: 23;
};
uint32_t val;
} scl_rstart_setup;
union {
struct {
uint32_t time: 9;
uint32_t reserved9: 23;
};
uint32_t val;
} scl_stop_hold;
union {
struct {
uint32_t time: 9;
uint32_t reserved9: 23;
};
uint32_t val;
} scl_stop_setup;
union {
struct {
uint32_t scl_thres: 4;
uint32_t sda_thres: 4;
uint32_t scl_en: 1;
uint32_t sda_en: 1;
uint32_t reserved10: 22;
};
uint32_t val;
} filter_cfg;
union {
struct {
uint32_t sclk_div_num: 8;
uint32_t sclk_div_a: 6;
uint32_t sclk_div_b: 6;
uint32_t sclk_sel: 1;
uint32_t sclk_active: 1;
uint32_t reserved22: 10;
};
uint32_t val;
} clk_conf;
union {
struct {
uint32_t command0: 14;
uint32_t reserved14: 17;
uint32_t done: 1;
};
uint32_t val;
} command[8];
union {
struct {
uint32_t scl_st_to: 5; /*no more than 23*/
uint32_t reserved5: 27;
};
uint32_t val;
} scl_st_time_out;
union {
struct {
uint32_t scl_main_st_to: 5; /*no more than 23*/
uint32_t reserved5: 27;
};
uint32_t val;
} scl_main_st_time_out;
union {
struct {
uint32_t scl_rst_slv_en: 1;
uint32_t scl_rst_slv_num: 5;
uint32_t scl_pd_en: 1;
uint32_t sda_pd_en: 1;
uint32_t reserved8: 24;
};
uint32_t val;
} scl_sp_conf;
union {
struct {
uint32_t stretch_protect_num: 10;
uint32_t slave_scl_stretch_en: 1;
uint32_t slave_scl_stretch_clr: 1;
uint32_t reserved12: 20;
};
uint32_t val;
} scl_stretch_conf;
uint32_t reserved_88;
uint32_t reserved_8c;
uint32_t reserved_90;
uint32_t reserved_94;
uint32_t reserved_98;
uint32_t reserved_9c;
uint32_t reserved_a0;
uint32_t reserved_a4;
uint32_t reserved_a8;
uint32_t reserved_ac;
uint32_t reserved_b0;
uint32_t reserved_b4;
uint32_t reserved_b8;
uint32_t reserved_bc;
uint32_t reserved_c0;
uint32_t reserved_c4;
uint32_t reserved_c8;
uint32_t reserved_cc;
uint32_t reserved_d0;
uint32_t reserved_d4;
uint32_t reserved_d8;
uint32_t reserved_dc;
uint32_t reserved_e0;
uint32_t reserved_e4;
uint32_t reserved_e8;
uint32_t reserved_ec;
uint32_t reserved_f0;
uint32_t reserved_f4;
uint32_t date; /**/
uint32_t reserved_fc;
uint32_t txfifo_start_addr; /**/
uint32_t reserved_104;
uint32_t reserved_108;
uint32_t reserved_10c;
uint32_t reserved_110;
uint32_t reserved_114;
uint32_t reserved_118;
uint32_t reserved_11c;
uint32_t reserved_120;
uint32_t reserved_124;
uint32_t reserved_128;
uint32_t reserved_12c;
uint32_t reserved_130;
uint32_t reserved_134;
uint32_t reserved_138;
uint32_t reserved_13c;
uint32_t reserved_140;
uint32_t reserved_144;
uint32_t reserved_148;
uint32_t reserved_14c;
uint32_t reserved_150;
uint32_t reserved_154;
uint32_t reserved_158;
uint32_t reserved_15c;
uint32_t reserved_160;
uint32_t reserved_164;
uint32_t reserved_168;
uint32_t reserved_16c;
uint32_t reserved_170;
uint32_t reserved_174;
uint32_t reserved_178;
uint32_t reserved_17c;
uint32_t fifo_start_addr; /**/
} i2c_dev_t;
extern i2c_dev_t I2C0;
extern i2c_dev_t I2C1;
#ifdef __cplusplus
}
#endif