]> granicus.if.org Git - esp-idf/blob - components/esp32/brownout.c
Merge branch 'test/clean_ci_fails' into 'master'
[esp-idf] / components / esp32 / brownout.c
1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15
16 #include <stdint.h>
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <stdbool.h>
20 #include "sdkconfig.h"
21 #include "soc/soc.h"
22 #include "soc/rtc_cntl_reg.h"
23
24
25 #if CONFIG_BROWNOUT_DET
26 /*
27 This file is included in esp-idf, but the menuconfig option for this is disabled because a silicon bug
28 prohibits the brownout detector from functioning correctly on the ESP32.
29 */
30
31 void esp_brownout_init() {
32     WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 
33             RTC_CNTL_BROWN_OUT_ENA | (CONFIG_BROWNOUT_DET_LVL << RTC_CNTL_DBROWN_OUT_THRES_S) |
34             RTC_CNTL_BROWN_OUT_RST_ENA | (((CONFIG_BROWNOUT_DET_RESETDELAY*150)/1000) << RTC_CNTL_BROWN_OUT_RST_WAIT_S) |
35             RTC_CNTL_BROWN_OUT_PD_RF_ENA|RTC_CNTL_BROWN_OUT_CLOSE_FLASH_ENA);
36
37 }
38
39 #endif