forked from espressif/arduino-esp32
Update IDF and Camera
This commit is contained in:
@ -1,33 +0,0 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/gpio_types.h"
|
||||
#include "hal/rtc_io_ll.h"
|
||||
#include "hal/rtc_cntl_ll.h"
|
||||
|
||||
#define rtc_hal_ext1_get_wakeup_pins() rtc_cntl_ll_ext1_get_wakeup_pins()
|
||||
|
||||
#define rtc_hal_ext1_set_wakeup_pins(mask, mode) rtc_cntl_ll_ext1_set_wakeup_pins(mask, mode)
|
||||
|
||||
#define rtc_hal_ext1_clear_wakeup_pins() rtc_cntl_ll_ext1_clear_wakeup_pins()
|
||||
|
||||
#define rtc_hal_set_wakeup_timer(ticks) rtc_cntl_ll_set_wakeup_timer(ticks)
|
||||
|
||||
/*
|
||||
* Enable wakeup from ULP coprocessor.
|
||||
*/
|
||||
#define rtc_hal_ulp_wakeup_enable() rtc_cntl_ll_ulp_wakeup_enable()
|
||||
|
91
tools/sdk/esp32s2/include/soc/include/hal/sha_hal.h
Normal file
91
tools/sdk/esp32s2/include/soc/include/hal/sha_hal.h
Normal file
@ -0,0 +1,91 @@
|
||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "soc/sha_caps.h"
|
||||
#include "soc/lldesc.h"
|
||||
#include "hal/sha_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Hashes a single message block
|
||||
*
|
||||
* @param sha_type SHA algorithm to hash with
|
||||
* @param data_block Input message to be hashed
|
||||
* @param block_word_len Length of the input message
|
||||
* @param first_block Is this the first block in a message or a continuation?
|
||||
*/
|
||||
void sha_hal_hash_block(esp_sha_type sha_type, const void *data_block, size_t block_word_len, bool first_block);
|
||||
|
||||
/**
|
||||
* @brief Polls and waits until the SHA engine is idle
|
||||
*
|
||||
*/
|
||||
void sha_hal_wait_idle(void);
|
||||
|
||||
/**
|
||||
* @brief Reads the current message digest from the SHA engine
|
||||
*
|
||||
* @param sha_type SHA algorithm used
|
||||
* @param digest_state Output buffer to which to read message digest to
|
||||
*/
|
||||
void sha_hal_read_digest(esp_sha_type sha_type, void *digest_state);
|
||||
|
||||
#if SOC_SHA_SUPPORT_RESUME
|
||||
/**
|
||||
* @brief Writes the message digest to the SHA engine
|
||||
*
|
||||
* @param sha_type The SHA algorithm type
|
||||
* @param digest_state Message digest to be written to SHA engine
|
||||
*/
|
||||
void sha_hal_write_digest(esp_sha_type sha_type, void *digest_state);
|
||||
#endif
|
||||
|
||||
#if SOC_SHA_SUPPORT_DMA
|
||||
/**
|
||||
* @brief Hashes a number of message blocks using DMA
|
||||
*
|
||||
* @param sha_type SHA algorithm to hash with
|
||||
* @param input Input message to be hashed
|
||||
* @param num_blocks Number of blocks to hash
|
||||
* @param first_block Is this the first block in a message or a continuation?
|
||||
*/
|
||||
void sha_hal_hash_dma(esp_sha_type sha_type, lldesc_t *input, size_t num_blocks, bool first_block);
|
||||
#endif
|
||||
|
||||
#if SOC_SHA_SUPPORT_SHA512_T
|
||||
/**
|
||||
* @brief Calculates and sets the initial digiest for SHA512_t
|
||||
*
|
||||
* @param t_string
|
||||
* @param t_len
|
||||
*/
|
||||
void sha_hal_sha512_init_hash(uint32_t t_string, uint8_t t_len);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
77
tools/sdk/esp32s2/include/soc/soc/esp32s2/i2c_saradc.h
Normal file
77
tools/sdk/esp32s2/include/soc/soc/esp32s2/i2c_saradc.h
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright 2019-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file i2c_sar.h
|
||||
* @brief Register definitions for analog to calibrate initial code for getting a more precise voltage of SAR ADC.
|
||||
*
|
||||
* This file lists register fields of SAR, located on an internal configuration
|
||||
* bus. These definitions are used via macros defined in i2c_rtc_clk.h, by
|
||||
* function in adc_ll.h.
|
||||
*/
|
||||
|
||||
#define I2C_SAR_ADC 0X69
|
||||
#define I2C_SAR_ADC_HOSTID 0
|
||||
|
||||
#define ADC_ANA_CONFIG2_REG 0x6000E048
|
||||
|
||||
#define ADC_SAR1_ENCAL_GND_ADDR 0x7
|
||||
#define ADC_SAR1_ENCAL_GND_ADDR_MSB 5
|
||||
#define ADC_SAR1_ENCAL_GND_ADDR_LSB 5
|
||||
|
||||
#define ADC_SAR2_ENCAL_GND_ADDR 0x7
|
||||
#define ADC_SAR2_ENCAL_GND_ADDR_MSB 7
|
||||
#define ADC_SAR2_ENCAL_GND_ADDR_LSB 7
|
||||
|
||||
#define ADC_SAR1_INITIAL_CODE_HIGH_ADDR 0x1
|
||||
#define ADC_SAR1_INITIAL_CODE_HIGH_ADDR_MSB 0x3
|
||||
#define ADC_SAR1_INITIAL_CODE_HIGH_ADDR_LSB 0x0
|
||||
|
||||
#define ADC_SAR1_INITIAL_CODE_LOW_ADDR 0x0
|
||||
#define ADC_SAR1_INITIAL_CODE_LOW_ADDR_MSB 0x7
|
||||
#define ADC_SAR1_INITIAL_CODE_LOW_ADDR_LSB 0x0
|
||||
|
||||
#define ADC_SAR2_INITIAL_CODE_HIGH_ADDR 0x4
|
||||
#define ADC_SAR2_INITIAL_CODE_HIGH_ADDR_MSB 0x3
|
||||
#define ADC_SAR2_INITIAL_CODE_HIGH_ADDR_LSB 0x0
|
||||
|
||||
#define ADC_SAR2_INITIAL_CODE_LOW_ADDR 0x3
|
||||
#define ADC_SAR2_INITIAL_CODE_LOW_ADDR_MSB 0x7
|
||||
#define ADC_SAR2_INITIAL_CODE_LOW_ADDR_LSB 0x0
|
||||
|
||||
#define ADC_SAR1_DREF_ADDR 0x2
|
||||
#define ADC_SAR1_DREF_ADDR_MSB 0x6
|
||||
#define ADC_SAR1_DREF_ADDR_LSB 0x4
|
||||
|
||||
#define ADC_SAR2_DREF_ADDR 0x5
|
||||
#define ADC_SAR2_DREF_ADDR_MSB 0x6
|
||||
#define ADC_SAR2_DREF_ADDR_LSB 0x4
|
||||
|
||||
#define ADC_SAR1_SAMPLE_CYCLE_ADDR 0x2
|
||||
#define ADC_SAR1_SAMPLE_CYCLE_ADDR_MSB 0x2
|
||||
#define ADC_SAR1_SAMPLE_CYCLE_ADDR_LSB 0x0
|
||||
|
||||
#define ADC_SARADC_DTEST_RTC_ADDR 0x7
|
||||
#define ADC_SARADC_DTEST_RTC_ADDR_MSB 1
|
||||
#define ADC_SARADC_DTEST_RTC_ADDR_LSB 0
|
||||
|
||||
#define ADC_SARADC_ENT_TSENS_ADDR 0x7
|
||||
#define ADC_SARADC_ENT_TSENS_ADDR_MSB 2
|
||||
#define ADC_SARADC_ENT_TSENS_ADDR_LSB 2
|
||||
|
||||
#define ADC_SARADC_ENT_RTC_ADDR 0x7
|
||||
#define ADC_SARADC_ENT_RTC_ADDR_MSB 3
|
||||
#define ADC_SARADC_ENT_RTC_ADDR_LSB 3
|
@ -1,142 +0,0 @@
|
||||
// Copyright 2010-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _SOC_CPU_H
|
||||
#define _SOC_CPU_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include "xtensa/corebits.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* C macros for xtensa special register read/write/exchange */
|
||||
|
||||
#define RSR(reg, curval) asm volatile ("rsr %0, " #reg : "=r" (curval));
|
||||
#define WSR(reg, newval) asm volatile ("wsr %0, " #reg : : "r" (newval));
|
||||
#define XSR(reg, swapval) asm volatile ("xsr %0, " #reg : "+r" (swapval));
|
||||
|
||||
/** @brief Read current stack pointer address
|
||||
*
|
||||
*/
|
||||
static inline void *get_sp(void)
|
||||
{
|
||||
void *sp;
|
||||
asm volatile ("mov %0, sp;" : "=r" (sp));
|
||||
return sp;
|
||||
}
|
||||
|
||||
/* Functions to set page attributes for Region Protection option in the CPU.
|
||||
* See Xtensa ISA Reference manual for explanation of arguments (section 4.6.3.2).
|
||||
*/
|
||||
|
||||
static inline void cpu_write_dtlb(uint32_t vpn, unsigned attr)
|
||||
{
|
||||
asm volatile ("wdtlb %1, %0; dsync\n" :: "r" (vpn), "r" (attr));
|
||||
}
|
||||
|
||||
|
||||
static inline void cpu_write_itlb(unsigned vpn, unsigned attr)
|
||||
{
|
||||
asm volatile ("witlb %1, %0; isync\n" :: "r" (vpn), "r" (attr));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure memory region protection
|
||||
*
|
||||
* Make page 0 access raise an exception.
|
||||
* Also protect some other unused pages so we can catch weirdness.
|
||||
* Useful attribute values:
|
||||
* 0 — cached, RW
|
||||
* 2 — bypass cache, RWX (default value after CPU reset)
|
||||
* 15 — no access, raise exception
|
||||
*/
|
||||
|
||||
static inline void cpu_configure_region_protection(void)
|
||||
{
|
||||
const uint32_t pages_to_protect[] = {0x00000000, 0x80000000, 0xa0000000, 0xc0000000, 0xe0000000};
|
||||
for (int i = 0; i < sizeof(pages_to_protect)/sizeof(pages_to_protect[0]); ++i) {
|
||||
cpu_write_dtlb(pages_to_protect[i], 0xf);
|
||||
cpu_write_itlb(pages_to_protect[i], 0xf);
|
||||
}
|
||||
cpu_write_dtlb(0x20000000, 0);
|
||||
cpu_write_itlb(0x20000000, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Stall CPU using RTC controller
|
||||
* @param cpu_id ID of the CPU to stall (0 = PRO, 1 = APP)
|
||||
*/
|
||||
void esp_cpu_stall(int cpu_id);
|
||||
|
||||
/**
|
||||
* @brief Un-stall CPU using RTC controller
|
||||
* @param cpu_id ID of the CPU to un-stall (0 = PRO, 1 = APP)
|
||||
*/
|
||||
void esp_cpu_unstall(int cpu_id);
|
||||
|
||||
/**
|
||||
* @brief Reset CPU using RTC controller
|
||||
* @param cpu_id ID of the CPU to reset (0 = PRO, 1 = APP)
|
||||
*/
|
||||
void esp_cpu_reset(int cpu_id);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Returns true if a JTAG debugger is attached to CPU
|
||||
* OCD (on chip debug) port.
|
||||
*
|
||||
* @note If "Make exception and panic handlers JTAG/OCD aware"
|
||||
* is disabled, this function always returns false.
|
||||
*/
|
||||
bool esp_cpu_in_ocd_debug_mode(void);
|
||||
|
||||
/**
|
||||
* @brief Convert the PC register value to its true address
|
||||
*
|
||||
* The address of the current instruction is not stored as an exact uint32_t
|
||||
* representation in PC register. This function will convert the value stored in
|
||||
* the PC register to a uint32_t address.
|
||||
*
|
||||
* @param pc_raw The PC as stored in register format.
|
||||
*
|
||||
* @return Address in uint32_t format
|
||||
*/
|
||||
static inline uint32_t esp_cpu_process_stack_pc(uint32_t pc)
|
||||
{
|
||||
if (pc & 0x80000000) {
|
||||
//Top two bits of a0 (return address) specify window increment. Overwrite to map to address space.
|
||||
pc = (pc & 0x3fffffff) | 0x40000000;
|
||||
}
|
||||
//Minus 3 to get PC of previous instruction (i.e. instruction executed before return address)
|
||||
return pc - 3;
|
||||
}
|
||||
|
||||
typedef uint32_t esp_cpu_ccount_t;
|
||||
|
||||
static inline esp_cpu_ccount_t esp_cpu_get_ccount(void)
|
||||
{
|
||||
uint32_t result;
|
||||
RSR(CCOUNT, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -917,12 +917,24 @@ extern "C" {
|
||||
#define EFUSE_SPI_PAD_CONF_1_S 0
|
||||
|
||||
#define EFUSE_RD_MAC_SPI_SYS_3_REG (DR_REG_EFUSE_BASE + 0x050)
|
||||
/* EFUSE_SYS_DATA_PART0_0 : RO ;bitpos:[31:18] ;default: 14'h0 ; */
|
||||
/*description: Stores the fist 14 bits of the zeroth part of system data.*/
|
||||
#define EFUSE_SYS_DATA_PART0_0 0x00003FFF
|
||||
/* EFUSE_SYS_DATA_PART0_0 : RO ;bitpos:[31:25] ;default: 7'h0 ; */
|
||||
/*description: Stores the fist 7 bits of the zeroth part of system data.*/
|
||||
#define EFUSE_SYS_DATA_PART0_0 0x0000007F
|
||||
#define EFUSE_SYS_DATA_PART0_0_M ((EFUSE_SYS_DATA_PART0_0_V)<<(EFUSE_SYS_DATA_PART0_0_S))
|
||||
#define EFUSE_SYS_DATA_PART0_0_V 0x3FFF
|
||||
#define EFUSE_SYS_DATA_PART0_0_S 18
|
||||
#define EFUSE_SYS_DATA_PART0_0_V 0x7F
|
||||
#define EFUSE_SYS_DATA_PART0_0_S 25
|
||||
/* EFUSE_PKG_VERSION : RO ;bitpos:[24:21] ;default: 4'h0 ; */
|
||||
/*description: Package version 0:ESP32-S2, 1:ESP32-S2FH16, 2:ESP32-S2FH32 */
|
||||
#define EFUSE_PKG_VERSION 0x0000000F
|
||||
#define EFUSE_PKG_VERSION_M ((EFUSE_PKG_VERSION_V)<<(EFUSE_PKG_VERSION_S))
|
||||
#define EFUSE_PKG_VERSION_V 0xF
|
||||
#define EFUSE_PKG_VERSION_S 21
|
||||
/* EFUSE_WAFER_VERSION : RO ;bitpos:[20:18] ;default: 3'h0 ; */
|
||||
/*description: WAFER version 0:A */
|
||||
#define EFUSE_WAFER_VERSION 0x00000007
|
||||
#define EFUSE_WAFER_VERSION_M ((EFUSE_WAFER_VERSION_V)<<(EFUSE_WAFER_VERSION_S))
|
||||
#define EFUSE_WAFER_VERSION_V 0x7
|
||||
#define EFUSE_WAFER_VERSION_S 18
|
||||
/* EFUSE_SPI_PAD_CONF_2 : RO ;bitpos:[17:0] ;default: 18'h0 ; */
|
||||
/*description: Stores the second part of SPI_PAD_CONF.*/
|
||||
#define EFUSE_SPI_PAD_CONF_2 0x0003FFFF
|
||||
|
@ -18,7 +18,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SOC_CP_DMA_MAX_BUFFER_SIZE (4095) /*!< Maximum size of the buffer that can be attached to descriptor */
|
||||
|
||||
#define SOC_RSA_MAX_BIT_LEN (4096)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Max amount of bytes in a single DMA operation is 4095,
|
||||
for SHA this means that the biggest safe amount of bytes is
|
||||
31 blocks of 128 bytes = 3968
|
||||
*/
|
||||
#define SOC_SHA_DMA_MAX_BUFFER_SIZE (3968)
|
||||
#define SOC_SHA_SUPPORT_DMA (1)
|
||||
|
||||
/* ESP32 style SHA engine, where multiple states can be stored in parallel */
|
||||
#define SOC_SHA_SUPPORT_PARALLEL_ENG (0)
|
||||
|
||||
/* The SHA engine is able to resume hashing from a user */
|
||||
#define SOC_SHA_SUPPORT_RESUME (1)
|
||||
|
||||
/* Has "crypto DMA", which is shared with AES */
|
||||
#define SOC_SHA_CRYPTO_DMA (1)
|
||||
|
||||
/* Has a centralized DMA, which is shared with all peripherals */
|
||||
#define SOC_SHA_GENERAL_DMA (0)
|
||||
|
||||
/* Supported HW algorithms */
|
||||
#define SOC_SHA_SUPPORT_SHA1 (1)
|
||||
#define SOC_SHA_SUPPORT_SHA224 (1)
|
||||
#define SOC_SHA_SUPPORT_SHA256 (1)
|
||||
#define SOC_SHA_SUPPORT_SHA384 (1)
|
||||
#define SOC_SHA_SUPPORT_SHA256 (1)
|
||||
#define SOC_SHA_SUPPORT_SHA512 (1)
|
||||
#define SOC_SHA_SUPPORT_SHA512_224 (1)
|
||||
#define SOC_SHA_SUPPORT_SHA512_256 (1)
|
||||
#define SOC_SHA_SUPPORT_SHA512_T (1)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -270,6 +270,8 @@
|
||||
#define SOC_EXTRAM_DATA_LOW 0x3F500000
|
||||
#define SOC_EXTRAM_DATA_HIGH 0x3FF80000
|
||||
|
||||
#define SOC_EXTRAM_DATA_SIZE (SOC_EXTRAM_DATA_HIGH - SOC_EXTRAM_DATA_LOW)
|
||||
|
||||
//First and last words of the D/IRAM region, for both the DRAM address as well as the IRAM alias.
|
||||
#define SOC_DIRAM_IRAM_LOW 0x40020000
|
||||
#define SOC_DIRAM_IRAM_HIGH 0x40070000
|
||||
|
@ -6,7 +6,10 @@
|
||||
#pragma once
|
||||
|
||||
#define SOC_TWAI_SUPPORTED 1
|
||||
#define SOC_CP_DMA_SUPPORTED 1
|
||||
#define SOC_CPU_CORES_NUM 1
|
||||
#define SOC_SUPPORTS_SECURE_DL_MODE 1
|
||||
#define SOC_RISCV_COPROC_SUPPORTED 1
|
||||
#define SOC_USB_SUPPORTED 1
|
||||
|
||||
#define SOC_CACHE_SUPPORT_WRAP 1
|
@ -17,6 +17,7 @@
|
||||
#include "i2c_apll.h"
|
||||
#include "i2c_bbpll.h"
|
||||
#include "i2c_ulp.h"
|
||||
#include "i2c_saradc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -31,26 +32,27 @@ extern "C" {
|
||||
/* Clear to enable BBPLL */
|
||||
#define I2C_BBPLL_M (BIT(17))
|
||||
|
||||
/* ROM functions which read/write internal control bus */
|
||||
uint8_t rom_i2c_readReg(uint8_t block, uint8_t host_id, uint8_t reg_add);
|
||||
uint8_t rom_i2c_readReg_Mask(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t msb, uint8_t lsb);
|
||||
void rom_i2c_writeReg(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t data);
|
||||
void rom_i2c_writeReg_Mask(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t msb, uint8_t lsb, uint8_t data);
|
||||
/* Read/Write internal control bus */
|
||||
uint8_t i2c_rtc_read_reg(uint8_t block, uint8_t host_id, uint8_t reg_add);
|
||||
uint8_t i2c_rtc_read_reg_mask(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t msb, uint8_t lsb);
|
||||
void i2c_rtc_write_reg(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t data);
|
||||
void i2c_rtc_write_reg_mask(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t msb, uint8_t lsb, uint8_t data);
|
||||
void i2c_rtc_init(void);
|
||||
|
||||
/* Convenience macros for the above functions, these use register definitions
|
||||
* from i2c_apll.h/i2c_bbpll.h header files.
|
||||
*/
|
||||
#define I2C_WRITEREG_MASK_RTC(block, reg_add, indata) \
|
||||
rom_i2c_writeReg_Mask(block, block##_HOSTID, reg_add, reg_add##_MSB, reg_add##_LSB, indata)
|
||||
i2c_rtc_write_reg_mask(block, block##_HOSTID, reg_add, reg_add##_MSB, reg_add##_LSB, indata)
|
||||
|
||||
#define I2C_READREG_MASK_RTC(block, reg_add) \
|
||||
rom_i2c_readReg_Mask(block, block##_HOSTID, reg_add, reg_add##_MSB, reg_add##_LSB)
|
||||
i2c_rtc_read_reg_mask(block, block##_HOSTID, reg_add, reg_add##_MSB, reg_add##_LSB)
|
||||
|
||||
#define I2C_WRITEREG_RTC(block, reg_add, indata) \
|
||||
rom_i2c_writeReg(block, block##_HOSTID, reg_add, indata)
|
||||
i2c_rtc_write_reg(block, block##_HOSTID, reg_add, indata)
|
||||
|
||||
#define I2C_READREG_RTC(block, reg_add) \
|
||||
rom_i2c_readReg(block, block##_HOSTID, reg_add)
|
||||
i2c_rtc_read_reg(block, block##_HOSTID, reg_add)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,76 +0,0 @@
|
||||
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in hal/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for DAC (esp32s2 specific part)
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/dac_ll.h"
|
||||
#include "hal/dac_types.h"
|
||||
|
||||
#include_next "hal/dac_hal.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Digital controller setting
|
||||
---------------------------------------------------------------*/
|
||||
/**
|
||||
* Digital controller initialization.
|
||||
*/
|
||||
void dac_hal_digi_init(void);
|
||||
|
||||
/**
|
||||
* Digital controller deinitialization.
|
||||
*/
|
||||
void dac_hal_digi_deinit(void);
|
||||
|
||||
/**
|
||||
* Setting the DAC digital controller.
|
||||
*
|
||||
* @param cfg Pointer to digital controller paramter.
|
||||
*/
|
||||
void dac_hal_digi_controller_config(const dac_digi_config_t *cfg);
|
||||
|
||||
/**
|
||||
* DAC digital controller start output voltage.
|
||||
*/
|
||||
void dac_hal_digi_start(void);
|
||||
|
||||
/**
|
||||
* DAC digital controller stop output voltage.
|
||||
*/
|
||||
void dac_hal_digi_stop(void);
|
||||
|
||||
/**
|
||||
* Reset DAC digital controller FIFO.
|
||||
*/
|
||||
#define dac_hal_digi_fifo_reset() dac_ll_digi_fifo_reset()
|
||||
|
||||
/**
|
||||
* Reset DAC digital controller.
|
||||
*/
|
||||
#define dac_hal_digi_reset() dac_ll_digi_reset()
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,453 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define RTCSLOW_MEMORY_SIZE 0x00002000
|
||||
|
||||
/**
|
||||
* ========================================================================================
|
||||
* === PeriBus1 common
|
||||
* ========================================================================================
|
||||
*/
|
||||
//PeriBus1 interrupt status bitmasks
|
||||
#define PERI1_INTR_ST_OP_TYPE_BIT BIT(4) //0: non-atomic, 1: atomic
|
||||
#define PERI1_INTR_ST_OP_HIGH_BITS BIT(5) //0: high bits = unchanged, 1: high bits = 0x03F40000
|
||||
#define PERI1_INTR_ST_FAULTADDR_M 0x03FFFFC0 //(bits 25:6 in the reg)
|
||||
#define PERI1_INTR_ST_FAULTADDR_S 0x4 //(bits 21:2 of real address)
|
||||
|
||||
static inline void esp_memprot_peri1_clear_intr(void)
|
||||
{
|
||||
DPORT_SET_PERI_REG_MASK(DPORT_PMS_PRO_DPORT_6_REG, DPORT_PMS_PRO_DPORT_ILG_CLR);
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri1_get_intr_source_num(void)
|
||||
{
|
||||
return ETS_PMS_PRO_DPORT_ILG_INTR_SOURCE;
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri1_intr_ena(bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
DPORT_SET_PERI_REG_MASK(DPORT_PMS_PRO_DPORT_6_REG, DPORT_PMS_PRO_DPORT_ILG_EN);
|
||||
} else {
|
||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_PMS_PRO_DPORT_6_REG, DPORT_PMS_PRO_DPORT_ILG_EN);
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri1_get_ctrl_reg(void)
|
||||
{
|
||||
return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DPORT_6_REG);
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri1_get_fault_reg(void)
|
||||
{
|
||||
return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DPORT_7_REG);
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri1_get_fault_op_type(uint32_t *op_type, uint32_t *op_subtype)
|
||||
{
|
||||
uint32_t status_bits = esp_memprot_peri1_get_fault_reg();
|
||||
//*op_type = (uint32_t)status_bits & PERI1_INTR_ST_OP_RW_BIT;
|
||||
*op_type = 0;
|
||||
//! DPORT_PMS_PRO_DPORT_7_REG is missing op_type bit
|
||||
*op_subtype = (uint32_t)status_bits & PERI1_INTR_ST_OP_TYPE_BIT;
|
||||
}
|
||||
|
||||
static inline bool esp_memprot_peri1_is_assoc_intr(void)
|
||||
{
|
||||
return DPORT_GET_PERI_REG_MASK(DPORT_PMS_PRO_DPORT_7_REG, DPORT_PMS_PRO_DPORT_ILG_INTR) > 0;
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri1_get_intr_ena_bit(void)
|
||||
{
|
||||
return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DPORT_6_REG, DPORT_PMS_PRO_DPORT_ILG_EN);
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri1_get_intr_on_bit(void)
|
||||
{
|
||||
return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DPORT_6_REG, DPORT_PMS_PRO_DPORT_ILG_INTR);
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri1_get_intr_clr_bit(void)
|
||||
{
|
||||
return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DPORT_6_REG, DPORT_PMS_PRO_DPORT_ILG_CLR);
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri1_get_lock_reg(void)
|
||||
{
|
||||
return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DPORT_0_REG);
|
||||
}
|
||||
|
||||
//resets automatically on CPU restart
|
||||
static inline void esp_memprot_peri1_set_lock(void)
|
||||
{
|
||||
DPORT_WRITE_PERI_REG(DPORT_PMS_PRO_DPORT_0_REG, DPORT_PMS_PRO_DPORT_LOCK);
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri1_get_lock_bit(void)
|
||||
{
|
||||
return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DPORT_0_REG, DPORT_PMS_PRO_DPORT_LOCK);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ========================================================================================
|
||||
* === PeriBus1 RTC SLOW
|
||||
* ========================================================================================
|
||||
*/
|
||||
#define PERI1_RTCSLOW_ADDRESS_BASE 0x3F421000
|
||||
#define PERI1_RTCSLOW_ADDRESS_LOW PERI1_RTCSLOW_ADDRESS_BASE
|
||||
#define PERI1_RTCSLOW_ADDRESS_HIGH PERI1_RTCSLOW_ADDRESS_LOW + RTCSLOW_MEMORY_SIZE
|
||||
#define PERI1_RTCSLOW_INTR_ST_FAULTADDR_HI_0 0x3F400000
|
||||
|
||||
|
||||
static inline uint32_t *esp_memprot_peri1_rtcslow_get_fault_address(void)
|
||||
{
|
||||
uint32_t status_bits = esp_memprot_peri1_get_fault_reg();
|
||||
uint32_t fault_address = (status_bits & PERI1_INTR_ST_FAULTADDR_M) >> PERI1_INTR_ST_FAULTADDR_S;
|
||||
uint32_t high_bits = (status_bits & PERI1_INTR_ST_OP_HIGH_BITS) ? PERI1_RTCSLOW_INTR_ST_FAULTADDR_HI_0 : 0;
|
||||
return (uint32_t *)(fault_address | high_bits);
|
||||
}
|
||||
|
||||
static inline bool esp_memprot_peri1_rtcslow_is_intr_mine(void)
|
||||
{
|
||||
if (esp_memprot_dram0_is_assoc_intr()) {
|
||||
uint32_t *faulting_address = esp_memprot_peri1_rtcslow_get_fault_address();
|
||||
return (uint32_t)faulting_address >= PERI1_RTCSLOW_ADDRESS_LOW && (uint32_t)faulting_address <= PERI1_RTCSLOW_ADDRESS_HIGH;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri1_rtcslow_set_prot(uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr)
|
||||
{
|
||||
uint32_t addr = (uint32_t)split_addr;
|
||||
|
||||
//check split address is WORD aligned
|
||||
uint32_t reg_split_addr = addr >> 2;
|
||||
assert(addr == (reg_split_addr << 2));
|
||||
reg_split_addr &= DPORT_PMS_PRO_DPORT_RTCSLOW_SPLTADDR_M;
|
||||
|
||||
//prepare high & low permission mask
|
||||
uint32_t permission_mask = 0;
|
||||
if (lw) {
|
||||
permission_mask |= DPORT_PMS_PRO_DPORT_RTCSLOW_L_W;
|
||||
}
|
||||
if (lr) {
|
||||
permission_mask |= DPORT_PMS_PRO_DPORT_RTCSLOW_L_R;
|
||||
}
|
||||
if (hw) {
|
||||
permission_mask |= DPORT_PMS_PRO_DPORT_RTCSLOW_H_W;
|
||||
}
|
||||
if (hr) {
|
||||
permission_mask |= DPORT_PMS_PRO_DPORT_RTCSLOW_H_R;
|
||||
}
|
||||
|
||||
//write PERIBUS1 RTC SLOW cfg register
|
||||
DPORT_WRITE_PERI_REG(DPORT_PMS_PRO_DPORT_1_REG, reg_split_addr | permission_mask);
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri1_rtcslow_get_split_sgnf_bits(bool *lw, bool *lr, bool *hw, bool *hr)
|
||||
{
|
||||
*lw = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DPORT_1_REG, DPORT_PMS_PRO_DPORT_RTCSLOW_L_W);
|
||||
*lr = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DPORT_1_REG, DPORT_PMS_PRO_DPORT_RTCSLOW_L_R);
|
||||
*hw = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DPORT_1_REG, DPORT_PMS_PRO_DPORT_RTCSLOW_H_W);
|
||||
*hr = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DPORT_1_REG, DPORT_PMS_PRO_DPORT_RTCSLOW_H_R);
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri1_rtcslow_set_read_perm(bool lr, bool hr)
|
||||
{
|
||||
DPORT_REG_SET_FIELD(DPORT_PMS_PRO_DPORT_1_REG, DPORT_PMS_PRO_DPORT_RTCSLOW_L_R, lr ? 1 : 0);
|
||||
DPORT_REG_SET_FIELD(DPORT_PMS_PRO_DPORT_1_REG, DPORT_PMS_PRO_DPORT_RTCSLOW_H_R, hr ? 1 : 0);
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri1_rtcslow_set_write_perm(bool lw, bool hw)
|
||||
{
|
||||
DPORT_REG_SET_FIELD(DPORT_PMS_PRO_DPORT_1_REG, DPORT_PMS_PRO_DPORT_RTCSLOW_L_W, lw ? 1 : 0);
|
||||
DPORT_REG_SET_FIELD(DPORT_PMS_PRO_DPORT_1_REG, DPORT_PMS_PRO_DPORT_RTCSLOW_H_W, hw ? 1 : 0);
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri1_rtcslow_get_conf_reg(void)
|
||||
{
|
||||
return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DPORT_1_REG);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ========================================================================================
|
||||
* === PeriBus2 common
|
||||
* ========================================================================================
|
||||
*/
|
||||
//PeriBus2 interrupt status bitmasks
|
||||
#define PERI2_INTR_ST_OP_TYPE_BIT BIT(1) //instruction: 0, data: 1
|
||||
#define PERI2_INTR_ST_OP_RW_BIT BIT(0) //read: 0, write: 1
|
||||
#define PERI2_INTR_ST_FAULTADDR_M 0xFFFFFFFC //(bits 31:2 in the reg)
|
||||
|
||||
static inline void esp_memprot_peri2_clear_intr(void)
|
||||
{
|
||||
DPORT_SET_PERI_REG_MASK(DPORT_PMS_PRO_AHB_3_REG, DPORT_PMS_PRO_AHB_ILG_CLR);
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri2_get_intr_source_num(void)
|
||||
{
|
||||
return ETS_PMS_PRO_AHB_ILG_INTR_SOURCE;
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri2_intr_ena(bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
DPORT_SET_PERI_REG_MASK(DPORT_PMS_PRO_AHB_3_REG, DPORT_PMS_PRO_AHB_ILG_EN);
|
||||
} else {
|
||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_PMS_PRO_AHB_3_REG, DPORT_PMS_PRO_AHB_ILG_EN);
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri2_get_ctrl_reg(void)
|
||||
{
|
||||
return DPORT_READ_PERI_REG(DPORT_PMS_PRO_AHB_3_REG);
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri2_get_fault_reg(void)
|
||||
{
|
||||
return DPORT_READ_PERI_REG(DPORT_PMS_PRO_AHB_4_REG);
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri2_get_fault_op_type(uint32_t *op_type, uint32_t *op_subtype)
|
||||
{
|
||||
uint32_t status_bits = esp_memprot_peri2_get_fault_reg();
|
||||
*op_type = (uint32_t)status_bits & PERI2_INTR_ST_OP_RW_BIT;
|
||||
*op_subtype = (uint32_t)status_bits & PERI2_INTR_ST_OP_TYPE_BIT;
|
||||
}
|
||||
|
||||
static inline bool esp_memprot_peri2_is_assoc_intr(void)
|
||||
{
|
||||
return DPORT_GET_PERI_REG_MASK(DPORT_PMS_PRO_AHB_3_REG, DPORT_PMS_PRO_AHB_ILG_INTR) > 0;
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri2_get_intr_ena_bit(void)
|
||||
{
|
||||
return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_3_REG, DPORT_PMS_PRO_AHB_ILG_EN);
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri2_get_intr_on_bit(void)
|
||||
{
|
||||
return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_3_REG, DPORT_PMS_PRO_AHB_ILG_INTR);
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri2_get_intr_clr_bit(void)
|
||||
{
|
||||
return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_3_REG, DPORT_PMS_PRO_AHB_ILG_CLR);
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri2_get_lock_reg(void)
|
||||
{
|
||||
return DPORT_READ_PERI_REG(DPORT_PMS_PRO_AHB_0_REG);
|
||||
}
|
||||
|
||||
//resets automatically on CPU restart
|
||||
static inline void esp_memprot_peri2_set_lock(void)
|
||||
{
|
||||
DPORT_WRITE_PERI_REG(DPORT_PMS_PRO_AHB_0_REG, DPORT_PMS_PRO_AHB_LOCK);
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri2_get_lock_bit(void)
|
||||
{
|
||||
return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_0_REG, DPORT_PMS_PRO_AHB_LOCK);
|
||||
}
|
||||
|
||||
static inline uint32_t *esp_memprot_peri2_rtcslow_get_fault_address(void)
|
||||
{
|
||||
uint32_t status_bits = esp_memprot_peri2_get_fault_reg();
|
||||
return (uint32_t *)(status_bits & PERI2_INTR_ST_FAULTADDR_M);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ========================================================================================
|
||||
* === PeriBus2 RTC SLOW 0 (AHB0)
|
||||
* ========================================================================================
|
||||
*/
|
||||
#define PERI2_RTCSLOW_0_ADDRESS_BASE 0x50000000
|
||||
#define PERI2_RTCSLOW_0_ADDRESS_LOW PERI2_RTCSLOW_0_ADDRESS_BASE
|
||||
#define PERI2_RTCSLOW_0_ADDRESS_HIGH PERI2_RTCSLOW_0_ADDRESS_LOW + RTCSLOW_MEMORY_SIZE
|
||||
|
||||
static inline bool esp_memprot_peri2_rtcslow_0_is_intr_mine(void)
|
||||
{
|
||||
if (esp_memprot_peri2_is_assoc_intr()) {
|
||||
uint32_t *faulting_address = esp_memprot_peri2_rtcslow_get_fault_address();
|
||||
return (uint32_t)faulting_address >= PERI2_RTCSLOW_0_ADDRESS_LOW && (uint32_t)faulting_address <= PERI2_RTCSLOW_0_ADDRESS_HIGH;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri2_rtcslow_0_set_prot(uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx)
|
||||
{
|
||||
uint32_t addr = (uint32_t)split_addr;
|
||||
|
||||
//check split address is WORD aligned
|
||||
uint32_t reg_split_addr = addr >> 2;
|
||||
assert(addr == (reg_split_addr << 2));
|
||||
reg_split_addr &= DPORT_PMS_PRO_AHB_RTCSLOW_0_SPLTADDR_M;
|
||||
|
||||
//prepare high & low permission mask
|
||||
uint32_t permission_mask = 0;
|
||||
if (lw) {
|
||||
permission_mask |= DPORT_PMS_PRO_AHB_RTCSLOW_0_L_W;
|
||||
}
|
||||
if (lr) {
|
||||
permission_mask |= DPORT_PMS_PRO_AHB_RTCSLOW_0_L_R;
|
||||
}
|
||||
if (lx) {
|
||||
permission_mask |= DPORT_PMS_PRO_AHB_RTCSLOW_0_L_F;
|
||||
}
|
||||
if (hw) {
|
||||
permission_mask |= DPORT_PMS_PRO_AHB_RTCSLOW_0_H_W;
|
||||
}
|
||||
if (hr) {
|
||||
permission_mask |= DPORT_PMS_PRO_AHB_RTCSLOW_0_H_R;
|
||||
}
|
||||
if (hx) {
|
||||
permission_mask |= DPORT_PMS_PRO_AHB_RTCSLOW_0_H_F;
|
||||
}
|
||||
|
||||
//write PERIBUS1 RTC SLOW cfg register
|
||||
DPORT_WRITE_PERI_REG(DPORT_PMS_PRO_AHB_1_REG, reg_split_addr | permission_mask);
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri2_rtcslow_0_get_split_sgnf_bits(bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx)
|
||||
{
|
||||
*lw = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_L_W);
|
||||
*lr = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_L_R);
|
||||
*lx = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_L_F);
|
||||
*hw = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_H_W);
|
||||
*hr = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_H_R);
|
||||
*hx = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_H_F);
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri2_rtcslow_0_set_read_perm(bool lr, bool hr)
|
||||
{
|
||||
DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_L_R, lr ? 1 : 0);
|
||||
DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_H_R, hr ? 1 : 0);
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri2_rtcslow_0_set_write_perm(bool lw, bool hw)
|
||||
{
|
||||
DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_L_W, lw ? 1 : 0);
|
||||
DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_H_W, hw ? 1 : 0);
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri2_rtcslow_0_set_exec_perm(bool lx, bool hx)
|
||||
{
|
||||
DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_L_F, lx ? 1 : 0);
|
||||
DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_H_F, hx ? 1 : 0);
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri2_rtcslow_0_get_conf_reg(void)
|
||||
{
|
||||
return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DPORT_1_REG);
|
||||
}
|
||||
|
||||
/**
|
||||
* ========================================================================================
|
||||
* === PeriBus2 RTC SLOW 1 (AHB1)
|
||||
* ========================================================================================
|
||||
*/
|
||||
#define PERI2_RTCSLOW_1_ADDRESS_BASE 0x60021000
|
||||
#define PERI2_RTCSLOW_1_ADDRESS_LOW PERI2_RTCSLOW_1_ADDRESS_BASE
|
||||
#define PERI2_RTCSLOW_1_ADDRESS_HIGH PERI2_RTCSLOW_1_ADDRESS_LOW + RTCSLOW_MEMORY_SIZE
|
||||
|
||||
|
||||
static inline bool esp_memprot_peri2_rtcslow_1_is_intr_mine(void)
|
||||
{
|
||||
if (esp_memprot_peri2_is_assoc_intr()) {
|
||||
uint32_t *faulting_address = esp_memprot_peri2_rtcslow_get_fault_address();
|
||||
return (uint32_t)faulting_address >= PERI2_RTCSLOW_1_ADDRESS_LOW && (uint32_t)faulting_address <= PERI2_RTCSLOW_1_ADDRESS_HIGH;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri2_rtcslow_1_set_prot(uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx)
|
||||
{
|
||||
uint32_t addr = (uint32_t)split_addr;
|
||||
|
||||
//check split address is WORD aligned
|
||||
uint32_t reg_split_addr = addr >> 2;
|
||||
assert(addr == (reg_split_addr << 2));
|
||||
reg_split_addr &= DPORT_PMS_PRO_AHB_RTCSLOW_1_SPLTADDR_M;
|
||||
|
||||
//prepare high & low permission mask
|
||||
uint32_t permission_mask = 0;
|
||||
if (lw) {
|
||||
permission_mask |= DPORT_PMS_PRO_AHB_RTCSLOW_1_L_W;
|
||||
}
|
||||
if (lr) {
|
||||
permission_mask |= DPORT_PMS_PRO_AHB_RTCSLOW_1_L_R;
|
||||
}
|
||||
if (lx) {
|
||||
permission_mask |= DPORT_PMS_PRO_AHB_RTCSLOW_1_L_F;
|
||||
}
|
||||
if (hw) {
|
||||
permission_mask |= DPORT_PMS_PRO_AHB_RTCSLOW_1_H_W;
|
||||
}
|
||||
if (hr) {
|
||||
permission_mask |= DPORT_PMS_PRO_AHB_RTCSLOW_1_H_R;
|
||||
}
|
||||
if (hx) {
|
||||
permission_mask |= DPORT_PMS_PRO_AHB_RTCSLOW_1_H_F;
|
||||
}
|
||||
|
||||
//write PERIBUS1 RTC SLOW cfg register
|
||||
DPORT_WRITE_PERI_REG(DPORT_PMS_PRO_AHB_2_REG, reg_split_addr | permission_mask);
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri2_rtcslow_1_get_split_sgnf_bits(bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx)
|
||||
{
|
||||
*lw = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_L_W);
|
||||
*lr = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_L_R);
|
||||
*lx = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_L_F);
|
||||
*hw = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_H_W);
|
||||
*hr = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_H_R);
|
||||
*hx = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_H_F);
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri2_rtcslow_1_set_read_perm(bool lr, bool hr)
|
||||
{
|
||||
DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_L_R, lr ? 1 : 0);
|
||||
DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_H_R, hr ? 1 : 0);
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri2_rtcslow_1_set_write_perm(bool lw, bool hw)
|
||||
{
|
||||
DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_L_W, lw ? 1 : 0);
|
||||
DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_H_W, hw ? 1 : 0);
|
||||
}
|
||||
|
||||
static inline void esp_memprot_peri2_rtcslow_1_set_exec_perm(bool lx, bool hx)
|
||||
{
|
||||
DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_L_F, lx ? 1 : 0);
|
||||
DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_H_F, hx ? 1 : 0);
|
||||
}
|
||||
|
||||
static inline uint32_t esp_memprot_peri2_rtcslow_1_get_conf_reg(void)
|
||||
{
|
||||
return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DPORT_2_REG);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user