Skip to content

Commit

Permalink
Restore ~50uA sleep consumption.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiw committed Dec 26, 2022
1 parent 61f5111 commit c7b59d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 15 additions & 3 deletions firmware/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,19 +236,25 @@ void App::onTaskSleep_()
TLV320_RESET_GPIO };
for (auto& gpio : tlv320Gpios)
{
rtc_gpio_isolate(gpio);
rtc_gpio_init(gpio);
rtc_gpio_set_direction(gpio, RTC_GPIO_MODE_INPUT_ONLY);
rtc_gpio_set_direction_in_sleep(gpio, RTC_GPIO_MODE_INPUT_ONLY);
rtc_gpio_pulldown_en(gpio);
rtc_gpio_pullup_dis(gpio);
rtc_gpio_hold_en(gpio);
}

/* Shut off peripheral power. */
rtc_gpio_init(GPIO_NUM_17);
rtc_gpio_hold_dis(GPIO_NUM_17);
rtc_gpio_set_direction(GPIO_NUM_17, RTC_GPIO_MODE_OUTPUT_ONLY);
rtc_gpio_set_direction_in_sleep(GPIO_NUM_17, RTC_GPIO_MODE_OUTPUT_ONLY);
rtc_gpio_set_level(GPIO_NUM_17, false);
rtc_gpio_hold_en(GPIO_NUM_17);

/* Isolate GPIO 0 as it has a weak pullup by default. This should be
good for a few more uA of sleep current savings. */
rtc_gpio_isolate(GPIO_NUM_0);
//rtc_gpio_isolate(GPIO_NUM_0);

esp_err_t err = ulp_riscv_load_binary(ulp_main_bin_start, (ulp_main_bin_end - ulp_main_bin_start));
ESP_ERROR_CHECK(err);
Expand Down Expand Up @@ -297,13 +303,19 @@ extern "C" void app_main()
TLV320_RESET_GPIO };
for (auto& gpio : tlv320Gpios)
{
rtc_gpio_isolate(gpio);
rtc_gpio_init(gpio);
rtc_gpio_set_direction(gpio, RTC_GPIO_MODE_INPUT_ONLY);
rtc_gpio_set_direction_in_sleep(gpio, RTC_GPIO_MODE_INPUT_ONLY);
rtc_gpio_pulldown_en(gpio);
rtc_gpio_pullup_dis(gpio);
rtc_gpio_hold_en(gpio);
}

// Enable peripheral power (required for v0.4+). This will automatically
// power down once we switch to the ULP processor on shutdown, reducing
// "off" current considerably.
rtc_gpio_init(GPIO_NUM_17);
rtc_gpio_hold_dis(GPIO_NUM_17);
rtc_gpio_set_direction(GPIO_NUM_17, RTC_GPIO_MODE_OUTPUT_ONLY);
rtc_gpio_set_level(GPIO_NUM_17, true);
rtc_gpio_hold_en(GPIO_NUM_17);
Expand Down
2 changes: 2 additions & 0 deletions firmware/main/driver/TLV320.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ void TLV320::onTaskSleep_()
{
// Stop reading from I2S.
i2s_channel_disable(i2sRxDevice_);
i2s_del_channel(i2sRxDevice_);
i2s_channel_disable(i2sTxDevice_);
i2s_del_channel(i2sTxDevice_);
i2sRxDevice_ = nullptr;
i2sTxDevice_ = nullptr;

Expand Down

0 comments on commit c7b59d2

Please sign in to comment.