initial commit
This commit is contained in:
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
.vscode
|
||||||
|
.idea
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
components/**/build
|
||||||
|
components/**/sdkconfig
|
||||||
|
components/**/sdkconfig.old
|
||||||
|
|
||||||
|
build
|
||||||
|
|
||||||
|
dependenceies
|
||||||
|
|
||||||
|
sdkconfig
|
||||||
17
CMakeLists.txt
Normal file
17
CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
include(cfg.cmake)
|
||||||
|
|
||||||
|
if (NOT DEFINED ENV{IDF_TARGET})
|
||||||
|
file(WRITE "cfg.cmake" "set(ENV{ESPPORT} \"COM3\")\nset(ENV{IDF_TARGET} \"esp32\")")
|
||||||
|
MESSAGE(FATAL_ERROR "THERE ARE NO CONFIG; CREATE NEW CONFIG.")
|
||||||
|
endif ()
|
||||||
|
if (NOT DEFINED ENV{ESPPORT})
|
||||||
|
MESSAGE(WARNING "PORT IS NOT DEFINED.")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
MESSAGE($ENV{ESPPORT})
|
||||||
|
MESSAGE($ENV{IDF_PATH})
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(esp32-counter-example)
|
||||||
2
cfg.cmake
Normal file
2
cfg.cmake
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
set(ENV{ESPPORT} "/dev/ttyUSB0")
|
||||||
|
set(ENV{IDF_TARGET} "esp32")
|
||||||
13
main/CMakeLists.txt
Normal file
13
main/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
set(srcs "src/main.cpp")
|
||||||
|
#list(APPEND srcs "src/function/touch_graph.cpp")
|
||||||
|
#list(APPEND srcs "src/function/server_clock.cpp")
|
||||||
|
#list(APPEND srcs "src/connection/connect.cpp")
|
||||||
|
#list(APPEND srcs "src/function/sd_rw.cpp")
|
||||||
|
|
||||||
|
idf_component_register(
|
||||||
|
SRCS ${srcs}
|
||||||
|
#INCLUDE_DIRS "include" "include/function"
|
||||||
|
#REQUIRES "driver" "ssd1306" "esp_wifi" "nvs_flash" "esp-tls" "esp_http_client" "json" "sdmmc" "vfs"
|
||||||
|
)
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
target_compile_options(${COMPONENT_LIB} PRIVATE -std=gnu++11)
|
||||||
40
main/src/main.cpp
Normal file
40
main/src/main.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "driver/timer.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
|
||||||
|
static void IRAM_ATTR timer_g0_t0_isr(void *arg) {
|
||||||
|
|
||||||
|
timer_group_clr_intr_status_in_isr(TIMER_GROUP_0, TIMER_0);
|
||||||
|
|
||||||
|
timer_group_enable_alarm_in_isr(TIMER_GROUP_0, TIMER_0);
|
||||||
|
|
||||||
|
esp_rom_printf("Hello From ISR 20sec\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void app_main() {
|
||||||
|
|
||||||
|
timer_config_t config = {
|
||||||
|
.alarm_en = TIMER_ALARM_EN,
|
||||||
|
.counter_en = TIMER_PAUSE,
|
||||||
|
.counter_dir = TIMER_COUNT_UP,
|
||||||
|
.auto_reload = TIMER_AUTORELOAD_EN,
|
||||||
|
.divider = 80,
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned long long interval_sec = 10;
|
||||||
|
|
||||||
|
timer_init(TIMER_GROUP_0, TIMER_0, &config);
|
||||||
|
|
||||||
|
timer_set_counter_value(TIMER_GROUP_0, TIMER_0, 0x00000000ULL);
|
||||||
|
timer_set_alarm_value(TIMER_GROUP_0, TIMER_0, interval_sec * 1000000ULL);
|
||||||
|
|
||||||
|
timer_enable_intr(TIMER_GROUP_0, TIMER_0);
|
||||||
|
|
||||||
|
timer_isr_register(TIMER_GROUP_0, TIMER_0, timer_g0_t0_isr, NULL, ESP_INTR_FLAG_IRAM, NULL);
|
||||||
|
|
||||||
|
timer_start(TIMER_GROUP_0, TIMER_0);
|
||||||
|
|
||||||
|
while (true) { vTaskDelay(pdMS_TO_TICKS(10000)); }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user