Skip to content

Commit 867745a

Browse files
Merge branch 'feature/ulp-rtc-i2c-driver-support' into 'master'
ulp: Added support for RTC I2C driver for ULP RISC-V on esp32s2 and esp32s3 Closes IDF-1715 and IDF-5798 See merge request espressif/esp-idf!19549
2 parents daa5cc6 + 4fde033 commit 867745a

21 files changed

+1560
-303
lines changed

components/soc/esp32c3/include/soc/rtc_i2c_struct.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,11 @@ typedef volatile struct rtc_i2c_dev_s {
165165
} fifo_data;
166166
union {
167167
struct {
168-
uint32_t command0: 14; /*command0*/
168+
uint32_t byte_num: 8;
169+
uint32_t ack_en: 1;
170+
uint32_t ack_exp: 1;
171+
uint32_t ack_val: 1;
172+
uint32_t op_code: 3;
169173
uint32_t reserved14: 17;
170174
uint32_t done: 1; /*command0_done*/
171175
};

components/soc/esp32s2/include/soc/rtc_i2c_struct.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,13 @@ typedef volatile struct rtc_i2c_dev_s {
166166
} fifo_data;
167167
union {
168168
struct {
169-
uint32_t command0: 14; /*command0*/
169+
uint32_t byte_num: 8;
170+
uint32_t ack_en: 1;
171+
uint32_t ack_exp: 1;
172+
uint32_t ack_val: 1;
173+
uint32_t op_code: 3;
170174
uint32_t reserved14: 17;
171-
uint32_t done: 1; /*command0_done*/
175+
uint32_t done: 1;
172176
};
173177
uint32_t val;
174178
} command[16];

components/soc/esp32s2/ld/esp32s2.peripherals.ld

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ PROVIDE ( SDM = 0x3f404f00 );
1111
PROVIDE ( RTCCNTL = 0x3f408000 );
1212
PROVIDE ( RTCIO = 0x3f408400 );
1313
PROVIDE ( SENS = 0x3f408800 );
14+
PROVIDE ( RTC_I2C = 0x3f408C00 );
1415
PROVIDE ( HINF = 0x3f40B000 );
1516
PROVIDE ( I2S0 = 0x3f40F000 );
1617
PROVIDE ( UART1 = 0x3f410000 );

components/soc/esp32s3/include/soc/rtc_i2c_struct.h

Lines changed: 18 additions & 299 deletions
Original file line numberDiff line numberDiff line change
@@ -190,294 +190,27 @@ typedef union {
190190
uint32_t val;
191191
} rtc_i2c_data_reg_t;
192192

193-
/** Type of i2c_cmd0 register
194-
* i2c commond0 register
193+
/** Type of i2c_cmd register
194+
* i2c command register
195195
*/
196196
typedef union {
197197
struct {
198-
/** i2c_command0 : R/W; bitpos: [13:0]; default: 2307;
199-
* command0
200-
*/
201-
uint32_t i2c_command0:14;
202-
uint32_t reserved_14:17;
203-
/** i2c_command0_done : RO; bitpos: [31]; default: 0;
198+
/** i2c_command : R/W; bitpos: [13:0]; default: 2307;
199+
* command
200+
*/
201+
uint32_t i2c_byte_num:8;
202+
uint32_t i2c_ack_en:1;
203+
uint32_t i2c_ack_exp:1;
204+
uint32_t i2c_ack_val:1;
205+
uint32_t i2c_op_code:3;
206+
uint32_t reserved14:17;
207+
/** i2c_command_done : RO; bitpos: [31]; default: 0;
204208
* command0_done
205209
*/
206-
uint32_t i2c_command0_done:1;
207-
};
208-
uint32_t val;
209-
} rtc_i2c_cmd0_reg_t;
210-
211-
/** Type of i2c_cmd1 register
212-
* i2c commond1 register
213-
*/
214-
typedef union {
215-
struct {
216-
/** i2c_command1 : R/W; bitpos: [13:0]; default: 6401;
217-
* command1
218-
*/
219-
uint32_t i2c_command1:14;
220-
uint32_t reserved_14:17;
221-
/** i2c_command1_done : RO; bitpos: [31]; default: 0;
222-
* command1_done
223-
*/
224-
uint32_t i2c_command1_done:1;
225-
};
226-
uint32_t val;
227-
} rtc_i2c_cmd1_reg_t;
228-
229-
/** Type of i2c_cmd2 register
230-
* i2c commond2 register
231-
*/
232-
typedef union {
233-
struct {
234-
/** i2c_command2 : R/W; bitpos: [13:0]; default: 2306;
235-
* command2
236-
*/
237-
uint32_t i2c_command2:14;
238-
uint32_t reserved_14:17;
239-
/** i2c_command2_done : RO; bitpos: [31]; default: 0;
240-
* command2_done
241-
*/
242-
uint32_t i2c_command2_done:1;
243-
};
244-
uint32_t val;
245-
} rtc_i2c_cmd2_reg_t;
246-
247-
/** Type of i2c_cmd3 register
248-
* i2c commond3 register
249-
*/
250-
typedef union {
251-
struct {
252-
/** i2c_command3 : R/W; bitpos: [13:0]; default: 257;
253-
* command3
254-
*/
255-
uint32_t i2c_command3:14;
256-
uint32_t reserved_14:17;
257-
/** i2c_command3_done : RO; bitpos: [31]; default: 0;
258-
* command3_done
259-
*/
260-
uint32_t i2c_command3_done:1;
261-
};
262-
uint32_t val;
263-
} rtc_i2c_cmd3_reg_t;
264-
265-
/** Type of i2c_cmd4 register
266-
* i2c commond4 register
267-
*/
268-
typedef union {
269-
struct {
270-
/** i2c_command4 : R/W; bitpos: [13:0]; default: 2305;
271-
* command4
272-
*/
273-
uint32_t i2c_command4:14;
274-
uint32_t reserved_14:17;
275-
/** i2c_command4_done : RO; bitpos: [31]; default: 0;
276-
* command4_done
277-
*/
278-
uint32_t i2c_command4_done:1;
279-
};
280-
uint32_t val;
281-
} rtc_i2c_cmd4_reg_t;
282-
283-
/** Type of i2c_cmd5 register
284-
* i2c commond5_register
285-
*/
286-
typedef union {
287-
struct {
288-
/** i2c_command5 : R/W; bitpos: [13:0]; default: 5889;
289-
* command5
290-
*/
291-
uint32_t i2c_command5:14;
292-
uint32_t reserved_14:17;
293-
/** i2c_command5_done : RO; bitpos: [31]; default: 0;
294-
* command5_done
295-
*/
296-
uint32_t i2c_command5_done:1;
297-
};
298-
uint32_t val;
299-
} rtc_i2c_cmd5_reg_t;
300-
301-
/** Type of i2c_cmd6 register
302-
* i2c commond6 register
303-
*/
304-
typedef union {
305-
struct {
306-
/** i2c_command6 : R/W; bitpos: [13:0]; default: 6401;
307-
* command6
308-
*/
309-
uint32_t i2c_command6:14;
310-
uint32_t reserved_14:17;
311-
/** i2c_command6_done : RO; bitpos: [31]; default: 0;
312-
* command6_done
313-
*/
314-
uint32_t i2c_command6_done:1;
315-
};
316-
uint32_t val;
317-
} rtc_i2c_cmd6_reg_t;
318-
319-
/** Type of i2c_cmd7 register
320-
* i2c commond7 register
321-
*/
322-
typedef union {
323-
struct {
324-
/** i2c_command7 : R/W; bitpos: [13:0]; default: 2308;
325-
* command7
326-
*/
327-
uint32_t i2c_command7:14;
328-
uint32_t reserved_14:17;
329-
/** i2c_command7_done : RO; bitpos: [31]; default: 0;
330-
* command7_done
331-
*/
332-
uint32_t i2c_command7_done:1;
333-
};
334-
uint32_t val;
335-
} rtc_i2c_cmd7_reg_t;
336-
337-
/** Type of i2c_cmd8 register
338-
* i2c commond8 register
339-
*/
340-
typedef union {
341-
struct {
342-
/** i2c_command8 : R/W; bitpos: [13:0]; default: 6401;
343-
* command8
344-
*/
345-
uint32_t i2c_command8:14;
346-
uint32_t reserved_14:17;
347-
/** i2c_command8_done : RO; bitpos: [31]; default: 0;
348-
* command8_done
349-
*/
350-
uint32_t i2c_command8_done:1;
351-
};
352-
uint32_t val;
353-
} rtc_i2c_cmd8_reg_t;
354-
355-
/** Type of i2c_cmd9 register
356-
* i2c commond9 register
357-
*/
358-
typedef union {
359-
struct {
360-
/** i2c_command9 : R/W; bitpos: [13:0]; default: 2307;
361-
* command9
362-
*/
363-
uint32_t i2c_command9:14;
364-
uint32_t reserved_14:17;
365-
/** i2c_command9_done : RO; bitpos: [31]; default: 0;
366-
* command9_done
367-
*/
368-
uint32_t i2c_command9_done:1;
210+
uint32_t i2c_command_done:1;
369211
};
370212
uint32_t val;
371-
} rtc_i2c_cmd9_reg_t;
372-
373-
/** Type of i2c_cmd10 register
374-
* i2c commond10 register
375-
*/
376-
typedef union {
377-
struct {
378-
/** i2c_command10 : R/W; bitpos: [13:0]; default: 257;
379-
* command10
380-
*/
381-
uint32_t i2c_command10:14;
382-
uint32_t reserved_14:17;
383-
/** i2c_command10_done : RO; bitpos: [31]; default: 0;
384-
* command10_done
385-
*/
386-
uint32_t i2c_command10_done:1;
387-
};
388-
uint32_t val;
389-
} rtc_i2c_cmd10_reg_t;
390-
391-
/** Type of i2c_cmd11 register
392-
* i2c commond11 register
393-
*/
394-
typedef union {
395-
struct {
396-
/** i2c_command11 : R/W; bitpos: [13:0]; default: 2305;
397-
* command11
398-
*/
399-
uint32_t i2c_command11:14;
400-
uint32_t reserved_14:17;
401-
/** i2c_command11_done : RO; bitpos: [31]; default: 0;
402-
* command11_done
403-
*/
404-
uint32_t i2c_command11_done:1;
405-
};
406-
uint32_t val;
407-
} rtc_i2c_cmd11_reg_t;
408-
409-
/** Type of i2c_cmd12 register
410-
* i2c commond12 register
411-
*/
412-
typedef union {
413-
struct {
414-
/** i2c_command12 : R/W; bitpos: [13:0]; default: 5889;
415-
* command12
416-
*/
417-
uint32_t i2c_command12:14;
418-
uint32_t reserved_14:17;
419-
/** i2c_command12_done : RO; bitpos: [31]; default: 0;
420-
* command12_done
421-
*/
422-
uint32_t i2c_command12_done:1;
423-
};
424-
uint32_t val;
425-
} rtc_i2c_cmd12_reg_t;
426-
427-
/** Type of i2c_cmd13 register
428-
* i2c commond13 register
429-
*/
430-
typedef union {
431-
struct {
432-
/** i2c_command13 : R/W; bitpos: [13:0]; default: 6401;
433-
* command13
434-
*/
435-
uint32_t i2c_command13:14;
436-
uint32_t reserved_14:17;
437-
/** i2c_command13_done : RO; bitpos: [31]; default: 0;
438-
* command13_done
439-
*/
440-
uint32_t i2c_command13_done:1;
441-
};
442-
uint32_t val;
443-
} rtc_i2c_cmd13_reg_t;
444-
445-
/** Type of i2c_cmd14 register
446-
* i2c commond14 register
447-
*/
448-
typedef union {
449-
struct {
450-
/** i2c_command14 : R/W; bitpos: [13:0]; default: 0;
451-
* command14
452-
*/
453-
uint32_t i2c_command14:14;
454-
uint32_t reserved_14:17;
455-
/** i2c_command14_done : RO; bitpos: [31]; default: 0;
456-
* command14_done
457-
*/
458-
uint32_t i2c_command14_done:1;
459-
};
460-
uint32_t val;
461-
} rtc_i2c_cmd14_reg_t;
462-
463-
/** Type of i2c_cmd15 register
464-
* i2c commond15 register
465-
*/
466-
typedef union {
467-
struct {
468-
/** i2c_command15 : R/W; bitpos: [13:0]; default: 0;
469-
* command15
470-
*/
471-
uint32_t i2c_command15:14;
472-
uint32_t reserved_14:17;
473-
/** i2c_command15_done : RO; bitpos: [31]; default: 0;
474-
* command15_done
475-
*/
476-
uint32_t i2c_command15_done:1;
477-
};
478-
uint32_t val;
479-
} rtc_i2c_cmd15_reg_t;
480-
213+
} rtc_i2c_cmd_reg_t;
481214

482215
/** Group: status register */
483216
/** Type of i2c_status register
@@ -750,29 +483,15 @@ typedef struct {
750483
volatile rtc_i2c_int_st_reg_t i2c_int_st;
751484
volatile rtc_i2c_int_ena_reg_t i2c_int_ena;
752485
volatile rtc_i2c_data_reg_t i2c_data;
753-
volatile rtc_i2c_cmd0_reg_t i2c_cmd0;
754-
volatile rtc_i2c_cmd1_reg_t i2c_cmd1;
755-
volatile rtc_i2c_cmd2_reg_t i2c_cmd2;
756-
volatile rtc_i2c_cmd3_reg_t i2c_cmd3;
757-
volatile rtc_i2c_cmd4_reg_t i2c_cmd4;
758-
volatile rtc_i2c_cmd5_reg_t i2c_cmd5;
759-
volatile rtc_i2c_cmd6_reg_t i2c_cmd6;
760-
volatile rtc_i2c_cmd7_reg_t i2c_cmd7;
761-
volatile rtc_i2c_cmd8_reg_t i2c_cmd8;
762-
volatile rtc_i2c_cmd9_reg_t i2c_cmd9;
763-
volatile rtc_i2c_cmd10_reg_t i2c_cmd10;
764-
volatile rtc_i2c_cmd11_reg_t i2c_cmd11;
765-
volatile rtc_i2c_cmd12_reg_t i2c_cmd12;
766-
volatile rtc_i2c_cmd13_reg_t i2c_cmd13;
767-
volatile rtc_i2c_cmd14_reg_t i2c_cmd14;
768-
volatile rtc_i2c_cmd15_reg_t i2c_cmd15;
486+
volatile rtc_i2c_cmd_reg_t i2c_cmd[16];
769487
uint32_t reserved_078[33];
770488
volatile rtc_i2c_date_reg_t i2c_date;
771-
} rtc_dev_t;
489+
} rtc_i2c_dev_t;
490+
extern rtc_i2c_dev_t RTC_I2C;
772491

773492

774493
#ifndef __cplusplus
775-
_Static_assert(sizeof(rtc_dev_t) == 0x100, "Invalid size of rtc_dev_t structure");
494+
_Static_assert(sizeof(rtc_i2c_dev_t) == 0x100, "Invalid size of rtc_i2c_dev_t structure");
776495
#endif
777496

778497
#ifdef __cplusplus

components/soc/esp32s3/ld/esp32s3.peripherals.ld

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ PROVIDE ( EFUSE = 0x60007000 );
1212
PROVIDE ( RTCCNTL = 0x60008000 );
1313
PROVIDE ( RTCIO = 0x60008400 );
1414
PROVIDE ( SENS = 0x60008800 );
15+
PROVIDE ( RTC_I2C = 0x60008C00 );
1516
PROVIDE ( HINF = 0x6000B000 );
1617
PROVIDE ( I2S0 = 0x6000F000 );
1718
PROVIDE ( I2S1 = 0x6002D000 );

components/ulp/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ if(CONFIG_SOC_ULP_SUPPORTED OR CONFIG_SOC_RISCV_COPROC_SUPPORTED)
2525
list(APPEND srcs
2626
"ulp_riscv/ulp_riscv.c"
2727
"ulp_riscv/ulp_riscv_lock.c"
28-
"ulp_riscv/ulp_riscv_adc.c")
28+
"ulp_riscv/ulp_riscv_adc.c"
29+
"ulp_riscv/ulp_riscv_i2c.c")
2930

3031
list(APPEND includes
3132
ulp_riscv/include

0 commit comments

Comments
 (0)