mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-07 20:00:53 +00:00
BOD: Bringup for ESP32C6
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "hal/brownout_hal.h"
|
||||
#include "soc/rtc_cntl_struct.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "i2c_pmu.h"
|
||||
#include "esp_attr.h"
|
||||
#include "hal/regi2c_ctrl.h"
|
||||
#include "soc/regi2c_brownout.h"
|
||||
|
||||
|
||||
void brownout_hal_config(const brownout_hal_config_t *cfg)
|
||||
{
|
||||
REGI2C_WRITE_MASK(I2C_PMU, I2C_PMU_OC_DREF_LVDET, cfg->threshold);
|
||||
typeof(RTCCNTL.brown_out) brown_out_reg = {
|
||||
.close_flash_ena = cfg->flash_power_down,
|
||||
.pd_rf_ena = cfg->rf_power_down,
|
||||
.rst_wait = 0x3ff,
|
||||
.rst_ena = cfg->reset_enabled,
|
||||
.ena = cfg->enabled,
|
||||
.rst_sel = 1,
|
||||
};
|
||||
RTCCNTL.brown_out = brown_out_reg;
|
||||
}
|
||||
|
||||
void brownout_hal_intr_enable(bool enable)
|
||||
{
|
||||
RTCCNTL.int_ena.rtc_brown_out = enable;
|
||||
}
|
||||
|
||||
IRAM_ATTR void brownout_hal_intr_clear(void)
|
||||
{
|
||||
RTCCNTL.int_clr.rtc_brown_out = 1;
|
||||
}
|
111
components/hal/esp32h4/include/hal/brownout_ll.h
Normal file
111
components/hal/esp32h4/include/hal/brownout_ll.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The ll is not public api, don't use in application code.
|
||||
* See readme.md in hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
#include "soc/rtc_cntl_struct.h"
|
||||
#include "hal/regi2c_ctrl.h"
|
||||
#include "soc/regi2c_brownout.h"
|
||||
#include "i2c_pmu.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief power down the flash when a brown out happens.
|
||||
*
|
||||
* @param enable true: power down flash. false: not power down
|
||||
*/
|
||||
static inline void brownout_ll_enable_flash_power_down(bool enable)
|
||||
{
|
||||
RTCCNTL.brown_out.close_flash_ena = enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief power down the RF circuits when a brown out happens
|
||||
*
|
||||
* @param enable true: power down. false: not power done.
|
||||
*/
|
||||
static inline void brownout_ll_enable_rf_power_down(bool enable)
|
||||
{
|
||||
RTCCNTL.brown_out.pd_rf_ena = enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable this to reset brown out
|
||||
*
|
||||
* @note: If brown out interrupt is used, this should be disabled.
|
||||
*
|
||||
* @param reset_ena true: enable reset. false: disable reset.
|
||||
* @param reset_wait brown out reset wait cycles
|
||||
* @param select 1: chip reset, 0: system reset
|
||||
*/
|
||||
static inline void brownout_ll_reset_config(bool reset_ena, uint32_t reset_wait, uint8_t select)
|
||||
{
|
||||
RTCCNTL.brown_out.rst_wait = reset_wait;
|
||||
RTCCNTL.brown_out.rst_ena = reset_ena;
|
||||
RTCCNTL.brown_out.rst_sel = select;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set brown out threshold
|
||||
*
|
||||
* @param threshold brownout threshold
|
||||
*/
|
||||
static inline void brownout_ll_set_threshold(uint8_t threshold)
|
||||
{
|
||||
REGI2C_WRITE_MASK(I2C_PMU, I2C_PMU_OC_DREF_LVDET, threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set this bit to enable the brown out detection
|
||||
*
|
||||
* @param bod_enable true: enable, false: disable
|
||||
*/
|
||||
static inline void brownout_ll_bod_enable(bool bod_enable)
|
||||
{
|
||||
RTCCNTL.brown_out.ena = bod_enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief configure the waiting cycles before sending an interrupt
|
||||
*
|
||||
* @param cycle waiting cycles.
|
||||
*/
|
||||
static inline void brownout_ll_set_intr_wait_cycles(uint8_t cycle)
|
||||
{
|
||||
// Not supported on ESP32H4
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable brown out interrupt
|
||||
*
|
||||
* @param enable true: enable, false: disable
|
||||
*/
|
||||
static inline void brownout_ll_intr_enable(bool enable)
|
||||
{
|
||||
RTCCNTL.int_ena.rtc_brown_out = enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear interrupt bits.
|
||||
*/
|
||||
__attribute__((always_inline))
|
||||
static inline void brownout_ll_intr_clear(void)
|
||||
{
|
||||
RTCCNTL.int_clr.rtc_brown_out = 1;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user