About manage I2C from deep sleep wake stub
Posted: Tue Sep 11, 2018 10:53 am
Hello!
I have a case where I need to speak with a I2C I/O Multiplexer before to wake up the device (other wise the device will not wake up correctly). To solve this my intention or what I'm trying is to set up a wake stub function to speak with the I/O multiplexer via I2C before the wake up.
Inside of the wake stub I tried to work with soc/rtc_i2c_reg.h and soc/i2c_reg.h registers, reading-writing-reading the registers to check the interaction with them. See code in ANEX1.
Just RTC_I2C registers changed:
RTC_SCLL: 0
SCLL: 0
RTC_SCLL: 40
SCLL: 0
So I guess that I must work with RTC registers (we are in deep sleep so it should be the normal) but I want to be sure and know if there is some restriction to work with this kind of registers such as 'only available for ULP'. Or maybe I'm wrong and I must work with soc/i2c_reg.h registers. So the first question that arises to me is which register set should I use to manage the I2C from deep sleep?
To place the data to be send via I2C I found information about the use of I2C_DATA_APB_REG, I2C_NONFIFO_EN to 0 for soc/i2c_reg.h, but in case of work with RTC_I2C registers I'm trying to understand where the data must be placed, I want to write 2 byte (1 I2C address with write bit + 1 I/O bitmask). According to the description, RTC_I2C_DATA_REG registers seems that is used to receive bytes, but where to place data to write using the RTC_I2C?
From my opinion ULP is not an option since this is not a sensor to be read during the time, is to modify the configuration of a TPS connected to the I/O multiplexer before to wake up the device. I'm open to ideas (but no to carry out hw modifications if there is no other option).
Thanks you in advance and sorry for disturb.
ANNEX1:
I have a case where I need to speak with a I2C I/O Multiplexer before to wake up the device (other wise the device will not wake up correctly). To solve this my intention or what I'm trying is to set up a wake stub function to speak with the I/O multiplexer via I2C before the wake up.
Inside of the wake stub I tried to work with soc/rtc_i2c_reg.h and soc/i2c_reg.h registers, reading-writing-reading the registers to check the interaction with them. See code in ANEX1.
Just RTC_I2C registers changed:
RTC_SCLL: 0
SCLL: 0
RTC_SCLL: 40
SCLL: 0
So I guess that I must work with RTC registers (we are in deep sleep so it should be the normal) but I want to be sure and know if there is some restriction to work with this kind of registers such as 'only available for ULP'. Or maybe I'm wrong and I must work with soc/i2c_reg.h registers. So the first question that arises to me is which register set should I use to manage the I2C from deep sleep?
To place the data to be send via I2C I found information about the use of I2C_DATA_APB_REG, I2C_NONFIFO_EN to 0 for soc/i2c_reg.h, but in case of work with RTC_I2C registers I'm trying to understand where the data must be placed, I want to write 2 byte (1 I2C address with write bit + 1 I/O bitmask). According to the description, RTC_I2C_DATA_REG registers seems that is used to receive bytes, but where to place data to write using the RTC_I2C?
From my opinion ULP is not an option since this is not a sensor to be read during the time, is to modify the configuration of a TPS connected to the I/O multiplexer before to wake up the device. I'm open to ideas (but no to carry out hw modifications if there is no other option).
Thanks you in advance and sorry for disturb.
ANNEX1:
Code: Select all
uint32_t rtc_val = 0;
uint32_t val = 0;
rtc_val = READ_PERI_REG(RTC_I2C_SCL_LOW_PERIOD_REG); //low half period in rtc_fast_clk cycles
val = READ_PERI_REG(I2C_SCL_LOW_PERIOD_REG(0)); //low half period in rtc_fast_clk cycles
ets_printf(RTC_SCLL,rtc_val);
ets_printf(SCLL,val);
// Wait for UART to end transmitting.
while (REG_GET_FIELD(UART_STATUS_REG(0), UART_ST_UTX_OUT)) {
;
}
WRITE_PERI_REG(RTC_I2C_SCL_LOW_PERIOD_REG,40); //low half period in rtc_fast_clk cycles
WRITE_PERI_REG(I2C_SCL_LOW_PERIOD_REG(0),40); //low half period in rtc_fast_clk cycles
rtc_val = READ_PERI_REG(RTC_I2C_SCL_LOW_PERIOD_REG); //low half period in rtc_fast_clk cycles
val = READ_PERI_REG(I2C_SCL_LOW_PERIOD_REG(0)); //low half period in rtc_fast_clk cycles
ets_printf(RTC_SCLL,rtc_val);
ets_printf(SCLL,val);
// Wait for UART to end transmitting.
while (REG_GET_FIELD(UART_STATUS_REG(0), UART_ST_UTX_OUT)) {
;
}