brownout_hal.c 768 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "hal/brownout_hal.h"
  7. #include "soc/rtc_cntl_struct.h"
  8. #include "esp_attr.h"
  9. void brownout_hal_config(const brownout_hal_config_t *cfg)
  10. {
  11. typeof(RTCCNTL.brown_out) brown_out_reg = {
  12. .close_flash_ena = cfg->flash_power_down,
  13. .pd_rf_ena = cfg->rf_power_down,
  14. .rst_wait = 0x3ff,
  15. .rst_ena = cfg->reset_enabled,
  16. .thres = cfg->threshold,
  17. .ena = cfg->enabled,
  18. };
  19. RTCCNTL.brown_out = brown_out_reg;
  20. }
  21. void brownout_hal_intr_enable(bool enable)
  22. {
  23. RTCCNTL.int_ena.rtc_brown_out = enable;
  24. }
  25. IRAM_ATTR void brownout_hal_intr_clear(void)
  26. {
  27. RTCCNTL.int_clr.rtc_brown_out = 1;
  28. }