mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
move esp32 chip specific includes to esp32/xxx.h
This commit is contained in:
parent
f1e9078cb0
commit
956c25dedd
@ -15,7 +15,7 @@
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_app_trace_util.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////// TIMEOUT /////////////////////////////////////
|
||||
|
@ -67,7 +67,7 @@ Revision: $Rev: 3734 $
|
||||
#include "esp_app_trace.h"
|
||||
#include "esp_app_trace_util.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
|
||||
extern const SEGGER_SYSVIEW_OS_API SYSVIEW_X_OS_TraceAPI;
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "esp_coexist_internal.h"
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "malloc.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "esp_attr.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_dport_access.h"
|
||||
#include "esp32/dport_access.h"
|
||||
|
||||
void esp_cache_err_int_init()
|
||||
{
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "esp_clk_internal.h"
|
||||
#include "rom/ets_sys.h"
|
||||
#include "rom/uart.h"
|
||||
|
@ -49,23 +49,23 @@
|
||||
#include "esp_spi_flash.h"
|
||||
#include "esp_ipc.h"
|
||||
#include "esp_crosscore_int.h"
|
||||
#include "esp_dport_access.h"
|
||||
#include "esp32/dport_access.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_vfs_dev.h"
|
||||
#include "esp_newlib.h"
|
||||
#include "esp_brownout.h"
|
||||
#include "esp32/brownout.h"
|
||||
#include "esp_int_wdt.h"
|
||||
#include "esp_task.h"
|
||||
#include "esp_task_wdt.h"
|
||||
#include "esp_phy_init.h"
|
||||
#include "esp_cache_err_int.h"
|
||||
#include "esp32/cache_err_int.h"
|
||||
#include "esp_coexist_internal.h"
|
||||
#include "esp_panic.h"
|
||||
#include "esp_core_dump.h"
|
||||
#include "esp_app_trace.h"
|
||||
#include "esp_dbg_stubs.h"
|
||||
#include "esp_efuse.h"
|
||||
#include "esp_spiram.h"
|
||||
#include "esp32/spiram.h"
|
||||
#include "esp_clk_internal.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_pm.h"
|
||||
|
@ -14,10 +14,10 @@
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_spiram.h"
|
||||
#include "esp32/spiram.h"
|
||||
#include "rom/cache.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_himem.h"
|
||||
#include "esp32/himem.h"
|
||||
#include "soc/soc.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
@ -161,7 +161,7 @@ void __attribute__((constructor)) esp_himem_init()
|
||||
free(s_range_descriptor);
|
||||
return;
|
||||
}
|
||||
ESP_EARLY_LOGI(TAG, "Initialized. Using last %d 32KB address blocks for bank switching on %d KB of physical memory.",
|
||||
ESP_EARLY_LOGI(TAG, "Initialized. Using last %d 32KB address blocks for bank switching on %d KB of physical memory.",
|
||||
SPIRAM_BANKSWITCH_RESERVE, (paddr_end - paddr_start)/1024);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "esp_attr.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "esp_timer_impl.h"
|
||||
#include "soc/frc_timer_reg.h"
|
||||
#include "soc/rtc.h"
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#include "esp_attr.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "soc/wdev_reg.h"
|
||||
#include "freertos/FreeRTOSConfig.h"
|
||||
#include "xtensa/core-macros.h"
|
||||
|
87
components/esp32/include/esp32/clk.h
Normal file
87
components/esp32/include/esp32/clk.h
Normal file
@ -0,0 +1,87 @@
|
||||
// Copyright 2015-2017 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 <stdint.h>
|
||||
|
||||
/**
|
||||
* @file esp32/clk.h
|
||||
*
|
||||
* This file contains declarations of clock related functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Get the calibration value of RTC slow clock
|
||||
*
|
||||
* The value is in the same format as returned by rtc_clk_cal (microseconds,
|
||||
* in Q13.19 fixed-point format).
|
||||
*
|
||||
* @return the calibration value obtained using rtc_clk_cal, at startup time
|
||||
*/
|
||||
uint32_t esp_clk_slowclk_cal_get();
|
||||
|
||||
/**
|
||||
* @brief Update the calibration value of RTC slow clock
|
||||
*
|
||||
* The value has to be in the same format as returned by rtc_clk_cal (microseconds,
|
||||
* in Q13.19 fixed-point format).
|
||||
* This value is used by timekeeping functions (such as gettimeofday) to
|
||||
* calculate current time based on RTC counter value.
|
||||
* @param value calibration value obtained using rtc_clk_cal
|
||||
*/
|
||||
void esp_clk_slowclk_cal_set(uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Return current CPU clock frequency
|
||||
* When frequency switching is performed, this frequency may change.
|
||||
* However it is guaranteed that the frequency never changes with a critical
|
||||
* section.
|
||||
*
|
||||
* @return CPU clock frequency, in Hz
|
||||
*/
|
||||
int esp_clk_cpu_freq(void);
|
||||
|
||||
/**
|
||||
* @brief Return current APB clock frequency
|
||||
*
|
||||
* When frequency switching is performed, this frequency may change.
|
||||
* However it is guaranteed that the frequency never changes with a critical
|
||||
* section.
|
||||
*
|
||||
* @return APB clock frequency, in Hz
|
||||
*/
|
||||
int esp_clk_apb_freq(void);
|
||||
|
||||
/**
|
||||
* @brief Return frequency of the main XTAL
|
||||
*
|
||||
* Frequency of the main XTAL can be either auto-detected or set at compile
|
||||
* time (see CONFIG_ESP32_XTAL_FREQ_SEL sdkconfig option). In both cases, this
|
||||
* function returns the actual value at run time.
|
||||
*
|
||||
* @return XTAL frequency, in Hz
|
||||
*/
|
||||
int esp_clk_xtal_freq(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Read value of RTC counter, converting it to microseconds
|
||||
* @attention The value returned by this function may change abruptly when
|
||||
* calibration value of RTC counter is updated via esp_clk_slowclk_cal_set
|
||||
* function. This should not happen unless application calls esp_clk_slowclk_cal_set.
|
||||
* In ESP-IDF, esp_clk_slowclk_cal_set is only called in startup code.
|
||||
*
|
||||
* @return Value or RTC counter, expressed in microseconds
|
||||
*/
|
||||
uint64_t esp_clk_rtc_time();
|
152
components/esp32/include/esp32/himem.h
Normal file
152
components/esp32/include/esp32/himem.h
Normal file
@ -0,0 +1,152 @@
|
||||
// Copyright 2018 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 <stddef.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//Opaque pointers as handles for ram/range data
|
||||
typedef struct esp_himem_ramdata_t *esp_himem_handle_t;
|
||||
typedef struct esp_himem_rangedata_t *esp_himem_rangehandle_t;
|
||||
|
||||
//ESP32 MMU block size
|
||||
#define ESP_HIMEM_BLKSZ (0x8000)
|
||||
|
||||
#define ESP_HIMEM_MAPFLAG_RO 1 /*!< Indicates that a mapping will only be read from. Note that this is unused for now. */
|
||||
|
||||
/**
|
||||
* @brief Allocate a block in high memory
|
||||
*
|
||||
* @param size Size of the to-be-allocated block, in bytes. Note that this needs to be
|
||||
* a multiple of the external RAM mmu block size (32K).
|
||||
* @param[out] handle_out Handle to be returned
|
||||
* @returns - ESP_OK if succesful
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_ERR_INVALID_SIZE if size is not a multiple of 32K
|
||||
*/
|
||||
esp_err_t esp_himem_alloc(size_t size, esp_himem_handle_t *handle_out);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Allocate a memory region to map blocks into
|
||||
*
|
||||
* This allocates a contiguous CPU memory region that can be used to map blocks
|
||||
* of physical memory into.
|
||||
*
|
||||
* @param size Size of the range to be allocated. Note this needs to be a multiple of
|
||||
* the external RAM mmu block size (32K).
|
||||
* @param[out] handle_out Handle to be returned
|
||||
* @returns - ESP_OK if succesful
|
||||
* - ESP_ERR_NO_MEM if out of memory or address space
|
||||
* - ESP_ERR_INVALID_SIZE if size is not a multiple of 32K
|
||||
*/
|
||||
esp_err_t esp_himem_alloc_map_range(size_t size, esp_himem_rangehandle_t *handle_out);
|
||||
|
||||
/**
|
||||
* @brief Map a block of high memory into the CPUs address space
|
||||
*
|
||||
* This effectively makes the block available for read/write operations.
|
||||
*
|
||||
* @note The region to be mapped needs to have offsets and sizes that are aligned to the
|
||||
* SPI RAM MMU block size (32K)
|
||||
*
|
||||
* @param handle Handle to the block of memory, as given by esp_himem_alloc
|
||||
* @param range Range handle to map the memory in
|
||||
* @param ram_offset Offset into the block of physical memory of the block to map
|
||||
* @param range_offset Offset into the address range where the block will be mapped
|
||||
* @param len Length of region to map
|
||||
* @param flags One of ESP_HIMEM_MAPFLAG_*
|
||||
* @param[out] out_ptr Pointer to variable to store resulting memory pointer in
|
||||
* @returns - ESP_OK if the memory could be mapped
|
||||
* - ESP_ERR_INVALID_ARG if offset, range or len aren't MMU-block-aligned (32K)
|
||||
* - ESP_ERR_INVALID_SIZE if the offsets/lengths don't fit in the allocated memory or range
|
||||
* - ESP_ERR_INVALID_STATE if a block in the selected ram offset/length is already mapped, or
|
||||
* if a block in the selected range offset/length already has a mapping.
|
||||
*/
|
||||
esp_err_t esp_himem_map(esp_himem_handle_t handle, esp_himem_rangehandle_t range, size_t ram_offset, size_t range_offset, size_t len, int flags, void **out_ptr);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Free a block of physical memory
|
||||
*
|
||||
* This clears out the associated handle making the memory available for re-allocation again.
|
||||
* This will only succeed if none of the memory blocks currently have a mapping.
|
||||
*
|
||||
* @param handle Handle to the block of memory, as given by esp_himem_alloc
|
||||
* @returns - ESP_OK if the memory is succesfully freed
|
||||
* - ESP_ERR_INVALID_ARG if the handle still is (partially) mapped
|
||||
*/
|
||||
esp_err_t esp_himem_free(esp_himem_handle_t handle);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Free a mapping range
|
||||
*
|
||||
* This clears out the associated handle making the range available for re-allocation again.
|
||||
* This will only succeed if none of the range blocks currently are used for a mapping.
|
||||
*
|
||||
* @param handle Handle to the range block, as given by esp_himem_alloc_map_range
|
||||
* @returns - ESP_OK if the memory is succesfully freed
|
||||
* - ESP_ERR_INVALID_ARG if the handle still is (partially) mapped to
|
||||
*/
|
||||
esp_err_t esp_himem_free_map_range(esp_himem_rangehandle_t handle);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Unmap a region
|
||||
*
|
||||
* @param range Range handle
|
||||
* @param ptr Pointer returned by esp_himem_map
|
||||
* @param len Length of the block to be unmapped. Must be aligned to the SPI RAM MMU blocksize (32K)
|
||||
* @returns - ESP_OK if the memory is succesfully unmapped,
|
||||
* - ESP_ERR_INVALID_ARG if ptr or len are invalid.
|
||||
*/
|
||||
esp_err_t esp_himem_unmap(esp_himem_rangehandle_t range, void *ptr, size_t len);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get total amount of memory under control of himem API
|
||||
*
|
||||
* @returns Amount of memory, in bytes
|
||||
*/
|
||||
size_t esp_himem_get_phys_size();
|
||||
|
||||
/**
|
||||
* @brief Get free amount of memory under control of himem API
|
||||
*
|
||||
* @returns Amount of free memory, in bytes
|
||||
*/
|
||||
size_t esp_himem_get_free_size();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get amount of SPI memory address space needed for bankswitching
|
||||
*
|
||||
* @note This is also weakly defined in esp32/spiram.c and returns 0 there, so
|
||||
* if no other function in this file is used, no memory is reserved.
|
||||
*
|
||||
* @returns Amount of reserved area, in bytes
|
||||
*/
|
||||
size_t esp_himem_reserved_area_size();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
116
components/esp32/include/esp32/spiram.h
Normal file
116
components/esp32/include/esp32/spiram.h
Normal file
@ -0,0 +1,116 @@
|
||||
// Copyright 2015-2017 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 __ESP_SPIRAM_H
|
||||
#define __ESP_SPIRAM_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
typedef enum {
|
||||
ESP_SPIRAM_SIZE_16MBITS = 0, /*!< SPI RAM size is 16 MBits */
|
||||
ESP_SPIRAM_SIZE_32MBITS = 1, /*!< SPI RAM size is 32 MBits */
|
||||
ESP_SPIRAM_SIZE_64MBITS = 2, /*!< SPI RAM size is 64 MBits */
|
||||
ESP_SPIRAM_SIZE_INVALID, /*!< SPI RAM size is invalid */
|
||||
} esp_spiram_size_t;
|
||||
|
||||
/**
|
||||
* @brief get SPI RAM size
|
||||
* @return
|
||||
* - ESP_SPIRAM_SIZE_INVALID if SPI RAM not enabled or not valid
|
||||
* - SPI RAM size
|
||||
*/
|
||||
esp_spiram_size_t esp_spiram_get_chip_size();
|
||||
|
||||
/**
|
||||
* @brief Initialize spiram interface/hardware. Normally called from cpu_start.c.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_spiram_init();
|
||||
|
||||
/**
|
||||
* @brief Configure Cache/MMU for access to external SPI RAM.
|
||||
*
|
||||
* Normally this function is called from cpu_start, if CONFIG_SPIRAM_BOOT_INIT
|
||||
* option is enabled. Applications which need to enable SPI RAM at run time
|
||||
* can disable CONFIG_SPIRAM_BOOT_INIT, and call this function later.
|
||||
*
|
||||
* @attention this function must be called with flash cache disabled.
|
||||
*/
|
||||
void esp_spiram_init_cache();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Memory test for SPI RAM. Should be called after SPI RAM is initialized and
|
||||
* (in case of a dual-core system) the app CPU is online. This test overwrites the
|
||||
* memory with crap, so do not call after e.g. the heap allocator has stored important
|
||||
* stuff in SPI RAM.
|
||||
*
|
||||
* @return true on success, false on failed memory test
|
||||
*/
|
||||
bool esp_spiram_test();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add the initialized SPI RAM to the heap allocator.
|
||||
*/
|
||||
esp_err_t esp_spiram_add_to_heapalloc();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the size of the attached SPI RAM chip selected in menuconfig
|
||||
*
|
||||
* @return Size in bytes, or 0 if no external RAM chip support compiled in.
|
||||
*/
|
||||
size_t esp_spiram_get_size();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Force a writeback of the data in the SPI RAM cache. This is to be called whenever
|
||||
* cache is disabled, because disabling cache on the ESP32 discards the data in the SPI
|
||||
* RAM cache.
|
||||
*
|
||||
* This is meant for use from within the SPI flash code.
|
||||
*/
|
||||
void esp_spiram_writeback_cache();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reserve a pool of internal memory for specific DMA/internal allocations
|
||||
*
|
||||
* @param size Size of reserved pool in bytes
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NO_MEM when no memory available for pool
|
||||
*/
|
||||
esp_err_t esp_spiram_reserve_dma_pool(size_t size);
|
||||
|
||||
|
||||
/**
|
||||
* @brief If SPI RAM(PSRAM) has been initialized
|
||||
*
|
||||
* @return
|
||||
* - true SPI RAM has been initialized successfully
|
||||
* - false SPI RAM hasn't been initialized or initialized failed
|
||||
*/
|
||||
bool esp_spiram_is_initialized(void);
|
||||
|
||||
|
||||
#endif
|
@ -1,87 +1,2 @@
|
||||
// Copyright 2015-2017 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 <stdint.h>
|
||||
|
||||
/**
|
||||
* @file esp_clk.h
|
||||
*
|
||||
* This file contains declarations of clock related functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Get the calibration value of RTC slow clock
|
||||
*
|
||||
* The value is in the same format as returned by rtc_clk_cal (microseconds,
|
||||
* in Q13.19 fixed-point format).
|
||||
*
|
||||
* @return the calibration value obtained using rtc_clk_cal, at startup time
|
||||
*/
|
||||
uint32_t esp_clk_slowclk_cal_get();
|
||||
|
||||
/**
|
||||
* @brief Update the calibration value of RTC slow clock
|
||||
*
|
||||
* The value has to be in the same format as returned by rtc_clk_cal (microseconds,
|
||||
* in Q13.19 fixed-point format).
|
||||
* This value is used by timekeeping functions (such as gettimeofday) to
|
||||
* calculate current time based on RTC counter value.
|
||||
* @param value calibration value obtained using rtc_clk_cal
|
||||
*/
|
||||
void esp_clk_slowclk_cal_set(uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Return current CPU clock frequency
|
||||
* When frequency switching is performed, this frequency may change.
|
||||
* However it is guaranteed that the frequency never changes with a critical
|
||||
* section.
|
||||
*
|
||||
* @return CPU clock frequency, in Hz
|
||||
*/
|
||||
int esp_clk_cpu_freq(void);
|
||||
|
||||
/**
|
||||
* @brief Return current APB clock frequency
|
||||
*
|
||||
* When frequency switching is performed, this frequency may change.
|
||||
* However it is guaranteed that the frequency never changes with a critical
|
||||
* section.
|
||||
*
|
||||
* @return APB clock frequency, in Hz
|
||||
*/
|
||||
int esp_clk_apb_freq(void);
|
||||
|
||||
/**
|
||||
* @brief Return frequency of the main XTAL
|
||||
*
|
||||
* Frequency of the main XTAL can be either auto-detected or set at compile
|
||||
* time (see CONFIG_ESP32_XTAL_FREQ_SEL sdkconfig option). In both cases, this
|
||||
* function returns the actual value at run time.
|
||||
*
|
||||
* @return XTAL frequency, in Hz
|
||||
*/
|
||||
int esp_clk_xtal_freq(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Read value of RTC counter, converting it to microseconds
|
||||
* @attention The value returned by this function may change abruptly when
|
||||
* calibration value of RTC counter is updated via esp_clk_slowclk_cal_set
|
||||
* function. This should not happen unless application calls esp_clk_slowclk_cal_set.
|
||||
* In ESP-IDF, esp_clk_slowclk_cal_set is only called in startup code.
|
||||
*
|
||||
* @return Value or RTC counter, expressed in microseconds
|
||||
*/
|
||||
uint64_t esp_clk_rtc_time();
|
||||
#warning esp_clk.h has been replaced by esp32/clk.h, please include esp32/clk.h instead
|
||||
#include "esp32/clk.h"
|
||||
|
@ -1,152 +1,2 @@
|
||||
// Copyright 2018 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 <stddef.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//Opaque pointers as handles for ram/range data
|
||||
typedef struct esp_himem_ramdata_t *esp_himem_handle_t;
|
||||
typedef struct esp_himem_rangedata_t *esp_himem_rangehandle_t;
|
||||
|
||||
//ESP32 MMU block size
|
||||
#define ESP_HIMEM_BLKSZ (0x8000)
|
||||
|
||||
#define ESP_HIMEM_MAPFLAG_RO 1 /*!< Indicates that a mapping will only be read from. Note that this is unused for now. */
|
||||
|
||||
/**
|
||||
* @brief Allocate a block in high memory
|
||||
*
|
||||
* @param size Size of the to-be-allocated block, in bytes. Note that this needs to be
|
||||
* a multiple of the external RAM mmu block size (32K).
|
||||
* @param[out] handle_out Handle to be returned
|
||||
* @returns - ESP_OK if succesful
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_ERR_INVALID_SIZE if size is not a multiple of 32K
|
||||
*/
|
||||
esp_err_t esp_himem_alloc(size_t size, esp_himem_handle_t *handle_out);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Allocate a memory region to map blocks into
|
||||
*
|
||||
* This allocates a contiguous CPU memory region that can be used to map blocks
|
||||
* of physical memory into.
|
||||
*
|
||||
* @param size Size of the range to be allocated. Note this needs to be a multiple of
|
||||
* the external RAM mmu block size (32K).
|
||||
* @param[out] handle_out Handle to be returned
|
||||
* @returns - ESP_OK if succesful
|
||||
* - ESP_ERR_NO_MEM if out of memory or address space
|
||||
* - ESP_ERR_INVALID_SIZE if size is not a multiple of 32K
|
||||
*/
|
||||
esp_err_t esp_himem_alloc_map_range(size_t size, esp_himem_rangehandle_t *handle_out);
|
||||
|
||||
/**
|
||||
* @brief Map a block of high memory into the CPUs address space
|
||||
*
|
||||
* This effectively makes the block available for read/write operations.
|
||||
*
|
||||
* @note The region to be mapped needs to have offsets and sizes that are aligned to the
|
||||
* SPI RAM MMU block size (32K)
|
||||
*
|
||||
* @param handle Handle to the block of memory, as given by esp_himem_alloc
|
||||
* @param range Range handle to map the memory in
|
||||
* @param ram_offset Offset into the block of physical memory of the block to map
|
||||
* @param range_offset Offset into the address range where the block will be mapped
|
||||
* @param len Length of region to map
|
||||
* @param flags One of ESP_HIMEM_MAPFLAG_*
|
||||
* @param[out] out_ptr Pointer to variable to store resulting memory pointer in
|
||||
* @returns - ESP_OK if the memory could be mapped
|
||||
* - ESP_ERR_INVALID_ARG if offset, range or len aren't MMU-block-aligned (32K)
|
||||
* - ESP_ERR_INVALID_SIZE if the offsets/lengths don't fit in the allocated memory or range
|
||||
* - ESP_ERR_INVALID_STATE if a block in the selected ram offset/length is already mapped, or
|
||||
* if a block in the selected range offset/length already has a mapping.
|
||||
*/
|
||||
esp_err_t esp_himem_map(esp_himem_handle_t handle, esp_himem_rangehandle_t range, size_t ram_offset, size_t range_offset, size_t len, int flags, void **out_ptr);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Free a block of physical memory
|
||||
*
|
||||
* This clears out the associated handle making the memory available for re-allocation again.
|
||||
* This will only succeed if none of the memory blocks currently have a mapping.
|
||||
*
|
||||
* @param handle Handle to the block of memory, as given by esp_himem_alloc
|
||||
* @returns - ESP_OK if the memory is succesfully freed
|
||||
* - ESP_ERR_INVALID_ARG if the handle still is (partially) mapped
|
||||
*/
|
||||
esp_err_t esp_himem_free(esp_himem_handle_t handle);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Free a mapping range
|
||||
*
|
||||
* This clears out the associated handle making the range available for re-allocation again.
|
||||
* This will only succeed if none of the range blocks currently are used for a mapping.
|
||||
*
|
||||
* @param handle Handle to the range block, as given by esp_himem_alloc_map_range
|
||||
* @returns - ESP_OK if the memory is succesfully freed
|
||||
* - ESP_ERR_INVALID_ARG if the handle still is (partially) mapped to
|
||||
*/
|
||||
esp_err_t esp_himem_free_map_range(esp_himem_rangehandle_t handle);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Unmap a region
|
||||
*
|
||||
* @param range Range handle
|
||||
* @param ptr Pointer returned by esp_himem_map
|
||||
* @param len Length of the block to be unmapped. Must be aligned to the SPI RAM MMU blocksize (32K)
|
||||
* @returns - ESP_OK if the memory is succesfully unmapped,
|
||||
* - ESP_ERR_INVALID_ARG if ptr or len are invalid.
|
||||
*/
|
||||
esp_err_t esp_himem_unmap(esp_himem_rangehandle_t range, void *ptr, size_t len);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get total amount of memory under control of himem API
|
||||
*
|
||||
* @returns Amount of memory, in bytes
|
||||
*/
|
||||
size_t esp_himem_get_phys_size();
|
||||
|
||||
/**
|
||||
* @brief Get free amount of memory under control of himem API
|
||||
*
|
||||
* @returns Amount of free memory, in bytes
|
||||
*/
|
||||
size_t esp_himem_get_free_size();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get amount of SPI memory address space needed for bankswitching
|
||||
*
|
||||
* @note This is also weakly defined in esp32/spiram.c and returns 0 there, so
|
||||
* if no other function in this file is used, no memory is reserved.
|
||||
*
|
||||
* @returns Amount of reserved area, in bytes
|
||||
*/
|
||||
size_t esp_himem_reserved_area_size();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#warning esp_himem.h has been replaced by esp32/himem.h, please include esp32/himem.h instead
|
||||
#include "esp32/himem.h"
|
||||
|
@ -1,116 +1,2 @@
|
||||
// Copyright 2015-2017 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 __ESP_SPIRAM_H
|
||||
#define __ESP_SPIRAM_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
typedef enum {
|
||||
ESP_SPIRAM_SIZE_16MBITS = 0, /*!< SPI RAM size is 16 MBits */
|
||||
ESP_SPIRAM_SIZE_32MBITS = 1, /*!< SPI RAM size is 32 MBits */
|
||||
ESP_SPIRAM_SIZE_64MBITS = 2, /*!< SPI RAM size is 64 MBits */
|
||||
ESP_SPIRAM_SIZE_INVALID, /*!< SPI RAM size is invalid */
|
||||
} esp_spiram_size_t;
|
||||
|
||||
/**
|
||||
* @brief get SPI RAM size
|
||||
* @return
|
||||
* - ESP_SPIRAM_SIZE_INVALID if SPI RAM not enabled or not valid
|
||||
* - SPI RAM size
|
||||
*/
|
||||
esp_spiram_size_t esp_spiram_get_chip_size();
|
||||
|
||||
/**
|
||||
* @brief Initialize spiram interface/hardware. Normally called from cpu_start.c.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_spiram_init();
|
||||
|
||||
/**
|
||||
* @brief Configure Cache/MMU for access to external SPI RAM.
|
||||
*
|
||||
* Normally this function is called from cpu_start, if CONFIG_SPIRAM_BOOT_INIT
|
||||
* option is enabled. Applications which need to enable SPI RAM at run time
|
||||
* can disable CONFIG_SPIRAM_BOOT_INIT, and call this function later.
|
||||
*
|
||||
* @attention this function must be called with flash cache disabled.
|
||||
*/
|
||||
void esp_spiram_init_cache();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Memory test for SPI RAM. Should be called after SPI RAM is initialized and
|
||||
* (in case of a dual-core system) the app CPU is online. This test overwrites the
|
||||
* memory with crap, so do not call after e.g. the heap allocator has stored important
|
||||
* stuff in SPI RAM.
|
||||
*
|
||||
* @return true on success, false on failed memory test
|
||||
*/
|
||||
bool esp_spiram_test();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add the initialized SPI RAM to the heap allocator.
|
||||
*/
|
||||
esp_err_t esp_spiram_add_to_heapalloc();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the size of the attached SPI RAM chip selected in menuconfig
|
||||
*
|
||||
* @return Size in bytes, or 0 if no external RAM chip support compiled in.
|
||||
*/
|
||||
size_t esp_spiram_get_size();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Force a writeback of the data in the SPI RAM cache. This is to be called whenever
|
||||
* cache is disabled, because disabling cache on the ESP32 discards the data in the SPI
|
||||
* RAM cache.
|
||||
*
|
||||
* This is meant for use from within the SPI flash code.
|
||||
*/
|
||||
void esp_spiram_writeback_cache();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reserve a pool of internal memory for specific DMA/internal allocations
|
||||
*
|
||||
* @param size Size of reserved pool in bytes
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NO_MEM when no memory available for pool
|
||||
*/
|
||||
esp_err_t esp_spiram_reserve_dma_pool(size_t size);
|
||||
|
||||
|
||||
/**
|
||||
* @brief If SPI RAM(PSRAM) has been initialized
|
||||
*
|
||||
* @return
|
||||
* - true SPI RAM has been initialized successfully
|
||||
* - false SPI RAM hasn't been initialized or initialized failed
|
||||
*/
|
||||
bool esp_spiram_is_initialized(void);
|
||||
|
||||
|
||||
#endif
|
||||
#warning esp_spiram.h has been replaced by esp32/spiram.h, please include esp32/spiram.h instead
|
||||
#include "esp32/spiram.h"
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include "esp_err.h"
|
||||
#include "esp_core_dump.h"
|
||||
#include "esp_spi_flash.h"
|
||||
#include "esp_cache_err_int.h"
|
||||
#include "esp32/cache_err_int.h"
|
||||
#include "esp_app_trace.h"
|
||||
#include "esp_system_internal.h"
|
||||
#include "sdkconfig.h"
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "esp_pm.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_crosscore_int.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
|
||||
#include "soc/rtc.h"
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_timer_impl.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "esp_newlib.h"
|
||||
#include "esp_spi_flash.h"
|
||||
#include "rom/cache.h"
|
||||
|
@ -24,7 +24,7 @@ we add more types of external RAM memory, this can be made into a more intellige
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_spiram.h"
|
||||
#include "esp32/spiram.h"
|
||||
#include "spiram_psram.h"
|
||||
#include "esp_log.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
@ -34,7 +34,7 @@ we add more types of external RAM memory, this can be made into a more intellige
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "rom/cache.h"
|
||||
#include "esp_himem.h"
|
||||
#include "esp32/himem.h"
|
||||
|
||||
#if CONFIG_FREERTOS_UNICORE
|
||||
#define PSRAM_MODE PSRAM_VADDR_MODE_NORMAL
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "esp_types.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "esp_types.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "esp_system.h"
|
||||
#include "rom/cache.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_himem.h"
|
||||
#include "esp32/himem.h"
|
||||
|
||||
#if CONFIG_SPIRAM_BANKSWITCH_ENABLE
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <sys/param.h>
|
||||
#include "unity.h"
|
||||
#include "esp_pm.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "esp_types.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_heap_caps.h"
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/param.h>
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "driver/rtc_io.h"
|
||||
#include "soc/gpio_reg.h"
|
||||
#include "soc/rtc.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "soc/uart_reg.h"
|
||||
#include "soc/io_mux_reg.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "esp_core_dump_priv.h"
|
||||
|
||||
const static DRAM_ATTR char TAG[] __attribute__((unused)) = "esp_core_dump_uart";
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include "esp_eth.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_pm.h"
|
||||
#include "esp_spiram.h"
|
||||
#include "esp32/spiram.h"
|
||||
|
||||
#include "driver/periph_ctrl.h"
|
||||
|
||||
|
@ -34,7 +34,7 @@ that are implemented in C.
|
||||
#endif
|
||||
|
||||
#include "xtensa_rtos.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
|
||||
#ifdef XT_RTOS_TIMER_INT
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "freertos/semphr.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "esp_system.h"
|
||||
#include "test_utils.h"
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <rom/rtc.h>
|
||||
#include "esp_attr.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "esp_timer.h"
|
||||
#include "soc/soc.h"
|
||||
#include "soc/rtc.h"
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_attr.h"
|
||||
#include "esp_dport_access.h"
|
||||
#include "esp32/dport_access.h"
|
||||
#include "soc.h"
|
||||
#include "uart_reg.h"
|
||||
#include "xtensa/xtruntime.h"
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "../esp_clk_internal.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "esp_flash_encrypt.h"
|
||||
#include "esp_log.h"
|
||||
#include "cache_utils.h"
|
||||
#include "esp_spiram.h"
|
||||
#include "esp32/spiram.h"
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Enable built-in checks in queue.h in debug builds
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "esp_attr.h"
|
||||
#include "esp_spi_flash.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "esp_flash_partitions.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "cache_utils.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "esp_attr.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "esp32/ulp.h"
|
||||
|
||||
#include "soc/soc.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "unity.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "rom/uart.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "soc/cpu.h"
|
||||
|
||||
static uint32_t s_test_start, s_test_stop;
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "freertos/portable.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "soc/cpu.h"
|
||||
|
||||
TEST_CASE("wl_unmount doesn't leak memory", "[wear_levelling]")
|
||||
|
@ -152,7 +152,7 @@ INPUT = \
|
||||
../../components/heap/include/esp_heap_caps_init.h \
|
||||
../../components/heap/include/multi_heap.h \
|
||||
## Himem
|
||||
../../components/esp32/include/esp_himem.h \
|
||||
../../components/esp32/include/esp32/himem.h \
|
||||
## Interrupt Allocation
|
||||
../../components/esp32/include/esp_intr_alloc.h \
|
||||
## Watchdogs
|
||||
|
@ -30,4 +30,4 @@ An example doing a simple memory test of the high memory range is available in e
|
||||
API Reference
|
||||
-------------
|
||||
|
||||
.. include:: /_build/inc/esp_himem.inc
|
||||
.. include:: /_build/inc/himem.inc
|
||||
|
@ -15,10 +15,10 @@
|
||||
#include "esp_system.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "esp_spiram.h"
|
||||
#include "esp32/spiram.h"
|
||||
#include "rom/cache.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_himem.h"
|
||||
#include "esp32/himem.h"
|
||||
|
||||
|
||||
//Fill memory with pseudo-random data generated from the given seed.
|
||||
|
Loading…
Reference in New Issue
Block a user