diff --git a/components/esp_timer/src/esp_timer_impl_systimer.c b/components/esp_timer/src/esp_timer_impl_systimer.c index 21f60c3b46..13656c4235 100644 --- a/components/esp_timer/src/esp_timer_impl_systimer.c +++ b/components/esp_timer/src/esp_timer_impl_systimer.c @@ -91,17 +91,11 @@ void esp_timer_impl_advance(int64_t time_us) esp_err_t esp_timer_impl_early_init(void) { - systimer_hal_init(&systimer_hal); + systimer_hal_init(); -#if !SOC_SYSTIMER_FIXED_TICKS_US - assert(rtc_clk_xtal_freq_get() == 40 && "update the step for xtal to support other XTAL:APB frequency ratios"); - systimer_hal_set_steps_per_tick(&systimer_hal, 0, 2); // for xtal - systimer_hal_set_steps_per_tick(&systimer_hal, 1, 1); // for pll -#endif - - systimer_hal_enable_counter(&systimer_hal, SYSTIMER_LL_COUNTER_CLOCK); - systimer_hal_select_alarm_mode(&systimer_hal, SYSTIMER_LL_ALARM_CLOCK, SYSTIMER_ALARM_MODE_ONESHOT); - systimer_hal_connect_alarm_counter(&systimer_hal, SYSTIMER_LL_ALARM_CLOCK, SYSTIMER_LL_COUNTER_CLOCK); + systimer_hal_enable_counter(SYSTIMER_COUNTER_0); + systimer_hal_select_alarm_mode(SYSTIMER_ALARM_2, SYSTIMER_ALARM_MODE_ONESHOT); + systimer_hal_connect_alarm_counter(SYSTIMER_ALARM_2, SYSTIMER_COUNTER_0); return ESP_OK; } diff --git a/components/spi_flash/flash_ops.c b/components/spi_flash/flash_ops.c index 544860b7e1..5a8c689c2d 100644 --- a/components/spi_flash/flash_ops.c +++ b/components/spi_flash/flash_ops.c @@ -50,6 +50,7 @@ #include "esp_flash.h" #include "esp_attr.h" #include "bootloader_flash.h" +#include "esp_compiler.h" esp_rom_spiflash_result_t IRAM_ATTR spi_flash_write_encrypted_chip(size_t dest_addr, const void *src, size_t size); @@ -230,7 +231,9 @@ static inline void IRAM_ATTR spi_flash_guard_op_unlock(void) static void IRAM_ATTR spi_flash_os_yield(void) { #ifdef CONFIG_SPI_FLASH_YIELD_DURING_ERASE - vTaskDelay(CONFIG_SPI_FLASH_ERASE_YIELD_TICKS); + if (likely(xTaskGetSchedulerState() == taskSCHEDULER_RUNNING)) { + vTaskDelay(CONFIG_SPI_FLASH_ERASE_YIELD_TICKS); + } #endif } diff --git a/components/spi_flash/spi_flash_os_func_app.c b/components/spi_flash/spi_flash_os_func_app.c index f3ea7c8fab..2cdce6c2c4 100644 --- a/components/spi_flash/spi_flash_os_func_app.c +++ b/components/spi_flash/spi_flash_os_func_app.c @@ -1,16 +1,8 @@ -// 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include #include //For max/min @@ -24,7 +16,7 @@ #include "hal/spi_types.h" #include "sdkconfig.h" #include "esp_log.h" - +#include "esp_compiler.h" #include "esp_rom_sys.h" #include "driver/spi_common_internal.h" @@ -140,11 +132,13 @@ static IRAM_ATTR esp_err_t spi1_flash_os_check_yield(void *arg, uint32_t chip_st static IRAM_ATTR esp_err_t spi1_flash_os_yield(void *arg, uint32_t* out_status) { + if (likely(xTaskGetSchedulerState() == taskSCHEDULER_RUNNING)) { #ifdef CONFIG_SPI_FLASH_ERASE_YIELD_TICKS - vTaskDelay(CONFIG_SPI_FLASH_ERASE_YIELD_TICKS); + vTaskDelay(CONFIG_SPI_FLASH_ERASE_YIELD_TICKS); #else - vTaskDelay(1); + vTaskDelay(1); #endif + } on_spi1_yielded((spi1_app_func_arg_t*)arg); return ESP_OK; }