mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-06-25 18:01:33 +02:00
69 lines
1.8 KiB
C
69 lines
1.8 KiB
C
// Copyright 2015-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.
|
|
|
|
#include "sdkconfig.h"
|
|
#include "esp32-hal-misc.h"
|
|
#include "esp32-hal.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "esp_attr.h"
|
|
#include "nvs_flash.h"
|
|
#include "nvs.h"
|
|
#include "esp_partition.h"
|
|
#include "esp_log.h"
|
|
#include "esp_timer.h"
|
|
#ifdef CONFIG_BT_ENABLED
|
|
#include "esp_bt.h"
|
|
#endif //CONFIG_BT_ENABLED
|
|
#include <sys/time.h>
|
|
#include "soc/rtc.h"
|
|
#include "soc/rtc_cntl_reg.h"
|
|
#include "soc/apb_ctrl_reg.h"
|
|
#include "esp_task_wdt.h"
|
|
|
|
#include "esp_system.h"
|
|
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
|
|
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
|
|
#include "esp32/rom/rtc.h"
|
|
#elif CONFIG_IDF_TARGET_ESP32S2
|
|
#include "esp32s2/rom/rtc.h"
|
|
#else
|
|
#error Target CONFIG_IDF_TARGET is not supported
|
|
#endif
|
|
#else // ESP32 Before IDF 4.0
|
|
#include "rom/rtc.h"
|
|
#endif
|
|
|
|
unsigned long ARDUINO_ISR_ATTR micros()
|
|
{
|
|
return (unsigned long) (esp_timer_get_time());
|
|
}
|
|
|
|
void ARDUINO_ISR_ATTR delayMicroseconds(uint32_t us)
|
|
{
|
|
uint32_t m = micros();
|
|
if(us){
|
|
uint32_t e = (m + us);
|
|
if(m > e){ //overflow
|
|
while(micros() > e){
|
|
NOP();
|
|
}
|
|
}
|
|
while(micros() < e){
|
|
NOP();
|
|
}
|
|
}
|
|
}
|
|
|