diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a7a9db2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +.config +*.o +*.pyc + +# gtags +GTAGS +GRTAGS +GPATH + +# emacs +.dir-locals.el + + +# eclipse setting +.settings + +# MacOS directory files +.DS_Store + +# Example project files +# example/**/sdkconfig +example/**/sdkconfig.old +example/**/build + +# gcov coverage reports +*.gcda +*.gcno +coverage.info +coverage_report/ + +# VS Code Settings +.vscode/ diff --git a/.gitmodules b/.gitmodules index c270ffc..f85a63f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ -[submodule "components"] - path = components - url = https://github.com/jason-mao/awtk.git [submodule "esp-idf"] path = esp-idf url = https://github.com/espressif/esp-idf.git +[submodule "components/awtk"] + path = components/awtk + url = https://github.com/jason-mao/awtk.git diff --git a/README.md b/README.md index 7e195f1..74eb9df 100644 --- a/README.md +++ b/README.md @@ -6,5 +6,7 @@ # Todo list -- [ ] Porting awtk to support ESP32 -- [ ] Support touch events +- [x] Porting awtk to support ESP32 +- [x] Running first demo on ESP-WROVER-KIT +- [ ] Support touch input events +- [ ] Implement framebuffer to improve speed diff --git a/components b/components deleted file mode 160000 index 1b173c6..0000000 --- a/components +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1b173c6790e633bc8693b63b08c2453e0ad036b8 diff --git a/components/awtk b/components/awtk new file mode 160000 index 0000000..cd002a0 --- /dev/null +++ b/components/awtk @@ -0,0 +1 @@ +Subproject commit cd002a018ceab415be8b6e6652178507c1d0dba7 diff --git a/components/esp32-port/.clang-format b/components/esp32-port/.clang-format new file mode 100644 index 0000000..47b492e --- /dev/null +++ b/components/esp32-port/.clang-format @@ -0,0 +1,116 @@ +--- +Language: Cpp +# BasedOnStyle: Google +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: false +AllowShortIfStatementsOnASingleLine: true +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: true +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 100 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeCategories: + - Regex: '^' + Priority: 2 + - Regex: '^<.*\.h>' + Priority: 1 + - Regex: '^<.*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 2 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: false +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 100 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +RawStringFormats: + - Delimiter: pb + Language: TextProto + BasedOnStyle: google +ReflowComments: true +SortIncludes: false +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Auto +TabWidth: 2 +UseTab: Never +... + diff --git a/components/esp32-port/CMakeLists.txt b/components/esp32-port/CMakeLists.txt new file mode 100644 index 0000000..1c42a24 --- /dev/null +++ b/components/esp32-port/CMakeLists.txt @@ -0,0 +1,4 @@ +set(COMPONENT_SRCS "lcd_esp32_raw.c" "main_loop_esp32_raw.c" "platform.c") +set(COMPONENT_ADD_INCLUDEDIRS "awtk_config.h") + +register_component() diff --git a/components/esp32-port/awtk_config.h b/components/esp32-port/awtk_config.h new file mode 100644 index 0000000..38adf36 --- /dev/null +++ b/components/esp32-port/awtk_config.h @@ -0,0 +1,89 @@ + +/** + * File: awtk_config.h + * Author: AWTK Develop Team + * Brief: config + * + * Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License file for more details. + * + */ + +/** + * History: + * ================================================================ + * 2018-09-12 Li XianJing created + * + */ + +#ifndef AWTK_CONFIG_H +#define AWTK_CONFIG_H + +/** + * 嵌入式系统有自己的main函数时,请定义本宏。 + * + */ +#define USE_GUI_MAIN 1 + +/** + * 如果需要支持预先解码的图片,请定义本宏。一般只在RAM极小时,才启用本宏。 + */ +#define WITH_BITMAP_FONT 1 + +/** + * 如果不需输入法,请定义本宏 + * + */ +#define WITH_NULL_IM 1 + +/** + * 如果支持极速模式,请定义本宏。极速模式不支持控件透明半透明效果,只有在CPU配置极低时启用。 + * + * #define USE_FAST_MODE 1 + */ + +/** + * 如果有标准的malloc/free/calloc等函数,请定义本宏 + * + */ +// #define HAS_STD_MALLOC 1 + +/** + * 如果有标准的fopen/fclose等函数,请定义本宏 + * + */ +#define HAS_STDIO 1 + +/** + * 如果有优化版本的memcpy函数,请定义本宏 + * + */ +#define HAS_FAST_MEMCPY 1 + +/** + * 如果禁用控件动画,请定义本宏 + * + */ +#define WITHOUT_WIDGET_ANIMATORS 1 + +/** + * 如果禁用窗口动画,请定义本宏 + * + */ +#define WITHOUT_WINDOW_ANIMATORS 1 + +/** + * 如果对话框高亮策略,请定义本宏 + * + */ +#define WITHOUT_DIALOG_HIGHLIGHTER 1 + +#define WITHOUT_EXT_WIDGETS 1 + +#define FRAGMENT_FRAME_BUFFER_SIZE 32 * 1024 + +#endif/*AWTK_CONFIG_H*/ diff --git a/components/esp32-port/component.mk b/components/esp32-port/component.mk new file mode 100644 index 0000000..5c92de5 --- /dev/null +++ b/components/esp32-port/component.mk @@ -0,0 +1,7 @@ +# +# "main" pseudo-component makefile. +# +# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) + +COMPONENT_ADD_INCLUDEDIRS := ./ +COMPONENT_SRCDIRS := ./ diff --git a/components/esp32-port/format.sh b/components/esp32-port/format.sh new file mode 100644 index 0000000..bcf0c2f --- /dev/null +++ b/components/esp32-port/format.sh @@ -0,0 +1,2 @@ +find . -name \*.c -exec clang-format -i {} \; + diff --git a/components/esp32-port/lcd_esp32_raw.c b/components/esp32-port/lcd_esp32_raw.c new file mode 100644 index 0000000..2624203 --- /dev/null +++ b/components/esp32-port/lcd_esp32_raw.c @@ -0,0 +1,54 @@ +/** + * File: lcd_stm32_raw.c + * Author: AWTK Develop Team + * Brief: stm32_raw implemented lcd interface + * + * Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License file for more details. + * + */ + +/** + * History: + * ================================================================ + * 2018-02-16 Li XianJing created + * + */ + +#include "ili9341.h" + +#include "lcd/lcd_reg.h" +#include "stdio.h" +typedef uint16_t pixel_t; + +#define LCD_FORMAT BITMAP_FMT_BGR565 +#define pixel_from_rgb(r, g, b) ((((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3)) +#define pixel_to_rgba(p) {(0xff & ((p >> 11) << 3)), (0xff & ((p >> 5) << 2)), (0xff & (p << 3))} + +extern ili9341_lcd_t *lcd; +extern void write_data_func(uint16_t dat); +extern void set_window_func(uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end); + +void write_data_func(uint16_t dat) +{ + ili9341_start_pixels(lcd); + ili9341_write_pixel(lcd, dat); + ili9341_end_pixels(lcd); +} +void set_window_func(uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end) +{ + uint16_t w = (x_end - x_start + 1); + uint16_t h = (y_end - y_start + 1); + ESP_LOGI("LCD_SET_W", "%d-%d, %d-%d, w:%d,h:%d", x_start, x_end, y_start, y_end, w,h ); + ili9341_start_pixels(lcd); + ili9341_set_window(lcd, x_start, y_start, w, h); + ili9341_end_pixels(lcd); +} + +#include "base/pixel.h" +#include "blend/pixel_ops.inc" +#include "lcd/lcd_reg.inc" diff --git a/components/esp32-port/main_loop_esp32_raw.c b/components/esp32-port/main_loop_esp32_raw.c new file mode 100644 index 0000000..6814c65 --- /dev/null +++ b/components/esp32-port/main_loop_esp32_raw.c @@ -0,0 +1,328 @@ +/** + * file: main_loop_aworks_raw.c + * Author: AWTK Develop Team + * brief: main loop for aworks + * + * copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd. + * + * this program is distributed in the hope that it will be useful, + * but without any warranty; without even the implied warranty of + * merchantability or fitness for a particular purpose. see the + * license file for more details. + * + */ + +/** + * history: + * ================================================================ + * 2018-05-23 li xianjing created + * + */ + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "esp_log.h" +#include "base/idle.h" +#include "base/timer.h" +#include "lcd/lcd_reg.h" +#include "lcd/lcd_mem_bgr565.h" +#include "main_loop/main_loop_simple.h" + +/*----------------------------------------------------------------------------*/ +/* 触摸屏输入消息分派 */ +/*----------------------------------------------------------------------------*/ + +// static struct aw_ts_state s_ts_state = {0}; +typedef struct { + int x; + int y; + int pressed; +} touch_info_t; + +static lcd_t* platform_create_lcd(wh_t w, wh_t h) { + return lcd_reg_create(w, h); +} +#define TS_STACK_SIZE 2 * 1024 +static void __awtk_loop_task_entry(void *p_arg) +{ + int tsret = 0; + touch_info_t ts_state; + while (1) { + memset(&ts_state, 0x00, sizeof(ts_state)); + // tsret = aw_ts_exec(p_arg, &ts_state, 1); + // TODO: get the touch pad information + if (tsret >= 0) { + // s_ts_state = ts_state; + if (ts_state.pressed) { + main_loop_post_pointer_event(main_loop(), ts_state.pressed, ts_state.x, + ts_state.y); + } else { + main_loop_post_pointer_event(main_loop(), ts_state.pressed, ts_state.x, + ts_state.y); + } + } + + if (ts_state.pressed) { + vTaskDelay(2); + } else { + vTaskDelay(10); + } + } +} +ret_t platform_disaptch_input(main_loop_t* l) { + return RET_OK; +} + +// ret_t platform_disaptch_input(main_loop_t* loop) { +// static TaskHandle_t loop_handle = NULL; +// if(loop_handle==NULL) { +// if (xTaskCreatePinnedToCore(__awtk_loop_task_entry, +// "awtk_loop_task_entry", +// 4096, +// NULL, +// 5, +// &loop_handle, 0) != pdTRUE) { +// ESP_LOGE("TAG", "Error create AWTK main loop task"); +// } + +// } + +// return RET_OK; +// } + +/*----------------------------------------------------------------------------*/ +/* frame buffer刷新操作 */ +/*----------------------------------------------------------------------------*/ +// #define SUPPORT_FRAME_BUFFER 0 +#if 0 + +extern uint32_t* aworks_get_online_fb(void); +extern uint32_t* aworks_get_offline_fb(void); +extern aw_emwin_fb_info_t* aworks_get_fb(void); +extern int aworks_get_fb_size(); +static lcd_flush_t s_lcd_flush_default = NULL; + +static ret_t lcd_aworks_fb_flush(lcd_t* lcd) { +#if 0 // 是否等待垂直同步 + // aw_emwin_fb_vram_addr_set 与 aw_cache_flush 配合用效果最好,但有等待时间 + aw_emwin_fb_vram_addr_set(aworks_get_fb(), aworks_get_online_fb()); // max 13ms wait +#endif + + if (s_lcd_flush_default != NULL) { + s_lcd_flush_default(lcd); + } + + // 单用 aw_cache_flush 能极大改善干扰线问题,但不能完全去除 + aw_cache_flush(aworks_get_online_fb(), aworks_get_fb_size()); // max 2ms wait + return RET_OK; +} + +#ifndef WITH_THREE_FB + +/*----------------------------------------------------------------------------*/ +/* 双缓冲模式 */ +/*----------------------------------------------------------------------------*/ + +static ret_t lcd_aworks_begin_frame(lcd_t* lcd, rect_t* dirty_rect) { + if (lcd_is_swappable(lcd)) { + lcd_mem_t* mem = (lcd_mem_t*)lcd; + (void)mem; + +#if 0 // 拷贝上一屏数据到offline fb作为背景, begin_frame之后只绘制脏矩形区域 + // 当前的awtk脏矩形实现机制: 每帧begin_frame时的脏矩形是与上一帧的脏矩形合并一次 + // 这样, 当前帧绘制时也会把上一帧的脏区域也绘制一次, 这样就无需执行这里的memcpy(拷贝上一屏数据到offline fb作为背景) + // 但如果以后awtk修改了这个机制, 就必须执行这里的memcpy了 + memcpy(mem->offline_fb, mem->online_fb, aworks_get_fb_size()); +#endif + +#if 0 // 测试用代码, offline fb 填充空白, 这样可以观察每次绘制的脏矩形 + memset(mem->offline_fb, 0, aworks_get_fb_size()); +#endif + } + + return RET_OK; +} + +static ret_t lcd_aworks_swap(lcd_t* lcd) { + lcd_mem_t* mem = (lcd_mem_t*)lcd; + + uint8_t* next_online_fb = mem->offline_fb; + mem->offline_fb = mem->online_fb; + mem->online_fb = next_online_fb; + + aw_cache_flush(next_online_fb, aworks_get_fb_size()); // max 2ms wait + aw_emwin_fb_vram_addr_set(aworks_get_fb(), (uintptr_t)next_online_fb); // max 13ms wait, 等待垂直同步并交换fb + return RET_OK; +} + +lcd_t* platform_create_lcd(wh_t w, wh_t h) { + lcd_t* lcd = lcd_mem_bgr565_create_double_fb(w, h, (uint8_t*) aworks_get_online_fb(), + (uint8_t*) aworks_get_offline_fb()); + + if (lcd != NULL) { + // 改进flush机制, 每次flush后加入cache_flush (旋转屏幕方向后进入flush流程) + s_lcd_flush_default = lcd->flush; + lcd->flush = lcd_aworks_fb_flush; + + // 使用swap机制(正常屏幕方向进入swap流程) + lcd->begin_frame = lcd_aworks_begin_frame; + lcd->swap = lcd_aworks_swap; + } + + return lcd; +} + +#else // WITH_THREE_FB + +/*----------------------------------------------------------------------------*/ +/* 三缓冲模式 */ +/*----------------------------------------------------------------------------*/ + +AW_MUTEX_DECL(__lock_fblist); +static uint32_t* s_fblist_readys = NULL; +static uint32_t* s_fblist_frees = NULL; +static uint8_t* s_dirty_offline = NULL; // 指向mem->offline_fb, 代表当前offline缓冲是否已经被写脏 + +static uint32_t* aworks_fblist_pop_ready() { + AW_MUTEX_LOCK( __lock_fblist, AW_SEM_WAIT_FOREVER ); + uint32_t* fb = s_fblist_readys; + s_fblist_readys = NULL; + AW_MUTEX_UNLOCK(__lock_fblist); + return fb; +} + +static void aworks_fblist_push_ready(uint32_t* fb) { + AW_MUTEX_LOCK( __lock_fblist, AW_SEM_WAIT_FOREVER ); + assert(s_fblist_readys == NULL); + s_fblist_readys = fb; + AW_MUTEX_UNLOCK(__lock_fblist); +} + +static uint32_t* aworks_fblist_pop_free() { + AW_MUTEX_LOCK( __lock_fblist, AW_SEM_WAIT_FOREVER ); + uint32_t* fb = s_fblist_frees; + s_fblist_frees = NULL; + AW_MUTEX_UNLOCK(__lock_fblist); + return fb; +} + +static void aworks_fblist_push_free(uint32_t* fb) { + AW_MUTEX_LOCK( __lock_fblist, AW_SEM_WAIT_FOREVER ); + assert(s_fblist_frees == NULL); + s_fblist_frees = fb; + AW_MUTEX_UNLOCK(__lock_fblist); +} + +#define SWAP_STACK_SIZE 1 * 1024 +aw_local void __swap_task_entry(void *p_arg) +{ + uint32_t* current_vram = (uint32_t*)p_arg; + + while (1) { + uint32_t* ready = aworks_fblist_pop_ready(); + if (ready) { + uint32_t* last_online = current_vram; + aw_emwin_fb_vram_addr_set(aworks_get_fb(), (uintptr_t)(current_vram = ready)); + aworks_fblist_push_free(last_online); + } else { + aw_mdelay(2); + } + } +} + +static ret_t __swap_idle_entry(const idle_info_t* idle) { + lcd_mem_t* mem = (lcd_mem_t*)idle->ctx; + + // 检查是否有脏的offline滞留, 如果有, 则强制更新到ready, 下一次循环把最新的帧刷新到online + // 并且将mem->offline_fb指向最新的free区域 + if (s_dirty_offline) { + uint32_t* freefb = aworks_fblist_pop_free(); + if (freefb) { + aw_cache_flush(mem->offline_fb, aworks_get_fb_size()); + aworks_fblist_push_ready((uint32_t*)mem->offline_fb); + + mem->offline_fb = (uint8_t*)freefb; + s_dirty_offline = NULL; + } + } + return RET_REPEAT; +} + +static void aworks_fblist_init(lcd_t* lcd) { + lcd_mem_t* mem = (lcd_mem_t*)lcd; + uint32_t* frame_buffer = (uint32_t*)mem->online_fb; + uint32_t* next_frame_buffer = (uint32_t*)mem->next_fb; + int fb_size = aworks_get_fb_size(); + + assert(frame_buffer && next_frame_buffer); + memset(next_frame_buffer, 0x00, fb_size); + + AW_MUTEX_INIT(__lock_fblist, AW_SEM_INVERSION_SAFE); + s_fblist_frees = next_frame_buffer; + s_fblist_readys = NULL; + s_dirty_offline = NULL; + + AW_TASK_DECL_STATIC(swap_task, SWAP_STACK_SIZE); + AW_TASK_INIT(swap_task, /* 任务实体 */ + "swap_task", /* 任务名字 */ + 1, /* 任务优先级 */ + SWAP_STACK_SIZE, /* 任务堆栈大小 */ + __swap_task_entry, /* 任务入口函数 */ + frame_buffer); /* 任务入口参数 */ + AW_TASK_STARTUP(swap_task); /* 启动任务 */ + + // 创建idle任务(同gui线程), 检查是否有滞留的脏offline缓冲, 并刷新到online + idle_add(__swap_idle_entry, lcd); +} + +static ret_t lcd_aworks_begin_frame(lcd_t* lcd, rect_t* dirty_rect) { + if (lcd_is_swappable(lcd)) { + lcd_mem_t* mem = (lcd_mem_t*)lcd; + (void)mem; + s_dirty_offline = NULL; // 新的一帧开始绘制 + } + return RET_OK; +} + +static ret_t lcd_aworks_swap(lcd_t* lcd) { + lcd_mem_t* mem = (lcd_mem_t*)lcd; + + uint32_t* freefb = aworks_fblist_pop_free(); + if (freefb) { + aw_cache_flush(mem->offline_fb, aworks_get_fb_size()); + aworks_fblist_push_ready((uint32_t*)mem->offline_fb); + + mem->offline_fb = (uint8_t*)freefb; + } else { + // 当前帧已经被更新到offline, 但由于没有可切换的free缓冲器(正在swap过程中) + // 所以当前offline没有被及时更新到ready区, 会导致最后一帧内容滞留在offline中 + // 需要swap线程检测出来并强制将最新的offline放回ready, 保证最新的内容更新到online + // + s_dirty_offline = mem->offline_fb; + } + return RET_OK; +} + +lcd_t* platform_create_lcd(wh_t w, wh_t h) { + lcd_t* lcd = lcd_mem_bgr565_create_three_fb(w, h, (uint8_t*) aworks_get_online_fb(), + (uint8_t*) aworks_get_offline_fb(), aw_mem_align(aworks_get_fb_size(), AW_CACHE_LINE_SIZE)); + + if (lcd != NULL) { + // 改进flush机制, 每次flush后加入cache_flush (旋转屏幕方向后进入flush流程) + s_lcd_flush_default = lcd->flush; + lcd->flush = lcd_aworks_fb_flush; + + // 使用swap机制(正常屏幕方向进入swap流程) + lcd->begin_frame = lcd_aworks_begin_frame; + lcd->swap = lcd_aworks_swap; + } + + aworks_fblist_init(lcd); + return lcd; +} + +#endif // WITH_THREE_FB + +#endif // SUPPORT_FRAME_BUFFER + +#include "main_loop/main_loop_raw.inc" diff --git a/components/esp32-port/platform.c b/components/esp32-port/platform.c new file mode 100644 index 0000000..24bde36 --- /dev/null +++ b/components/esp32-port/platform.c @@ -0,0 +1,41 @@ +/** + * File: platform.c + * Author: AWTK Develop Team + * Brief: platform dependent function of stm32 + * + * Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd. + * + * this program is distributed in the hope that it will be useful, + * but without any warranty; without even the implied warranty of + * merchantability or fitness for a particular purpose. see the + * license file for more details. + * + */ + +/** + * history: + * ================================================================ + * 2018-10-20 li xianjing created + * + */ + +#include "tkc/mem.h" +#include "base/timer.h" +#include "tkc/types_def.h" + +#include "freertos/FreeRTOS.h" +#include "freertos/semphr.h" +#include "freertos/task.h" +#include + + +static bool_t s_inited = FALSE; +static uint32_t s_heam_mem[4096]; + +ret_t platform_prepare(void) { + if(!s_inited) { + s_inited = TRUE; + tk_mem_init(s_heam_mem, sizeof(s_heam_mem)); + } + return RET_OK; +} diff --git a/components/lcd_driver/CMakeLists.txt b/components/lcd_driver/CMakeLists.txt new file mode 100644 index 0000000..9dc385c --- /dev/null +++ b/components/lcd_driver/CMakeLists.txt @@ -0,0 +1,4 @@ +set(COMPONENT_SRCS "esp32-spi.c" "ili9341.c") +set(COMPONENT_ADD_INCLUDEDIRS "ili9341.h" "esp32-spi.h") + +register_component() diff --git a/components/lcd_driver/component.mk b/components/lcd_driver/component.mk new file mode 100644 index 0000000..5c92de5 --- /dev/null +++ b/components/lcd_driver/component.mk @@ -0,0 +1,7 @@ +# +# "main" pseudo-component makefile. +# +# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) + +COMPONENT_ADD_INCLUDEDIRS := ./ +COMPONENT_SRCDIRS := ./ diff --git a/components/lcd_driver/esp32-spi.c b/components/lcd_driver/esp32-spi.c new file mode 100644 index 0000000..e142aab --- /dev/null +++ b/components/lcd_driver/esp32-spi.c @@ -0,0 +1,627 @@ +// 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 +#include "esp32-spi.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/semphr.h" +#include "rom/ets_sys.h" +#include "esp_attr.h" +#include "esp_intr.h" +#include "rom/gpio.h" +#include "soc/spi_reg.h" +#include "soc/spi_struct.h" +#include "soc/io_mux_reg.h" +#include "soc/gpio_sig_map.h" +#include "soc/dport_reg.h" +#include "soc/rtc.h" + + +#define SPI_CLK_IDX(p) ((p==0)?SPICLK_OUT_IDX:((p==1)?SPICLK_OUT_IDX:((p==2)?HSPICLK_OUT_IDX:((p==3)?VSPICLK_OUT_IDX:0)))) +#define SPI_MISO_IDX(p) ((p==0)?SPIQ_OUT_IDX:((p==1)?SPIQ_OUT_IDX:((p==2)?HSPIQ_OUT_IDX:((p==3)?VSPIQ_OUT_IDX:0)))) +#define SPI_MOSI_IDX(p) ((p==0)?SPID_IN_IDX:((p==1)?SPID_IN_IDX:((p==2)?HSPID_IN_IDX:((p==3)?VSPID_IN_IDX:0)))) + +#define SPI_SPI_SS_IDX(n) ((n==0)?SPICS0_OUT_IDX:((n==1)?SPICS1_OUT_IDX:((n==2)?SPICS2_OUT_IDX:SPICS0_OUT_IDX))) +#define SPI_HSPI_SS_IDX(n) ((n==0)?HSPICS0_OUT_IDX:((n==1)?HSPICS1_OUT_IDX:((n==2)?HSPICS2_OUT_IDX:HSPICS0_OUT_IDX))) +#define SPI_VSPI_SS_IDX(n) ((n==0)?VSPICS0_OUT_IDX:((n==1)?VSPICS1_OUT_IDX:((n==2)?VSPICS2_OUT_IDX:VSPICS0_OUT_IDX))) +#define SPI_SS_IDX(p, n) ((p==0)?SPI_SPI_SS_IDX(n):((p==1)?SPI_SPI_SS_IDX(n):((p==2)?SPI_HSPI_SS_IDX(n):((p==3)?SPI_VSPI_SS_IDX(n):0)))) + +#define SPI_INUM(u) (2) +#define SPI_INTR_SOURCE(u) ((u==0)?ETS_SPI0_INTR_SOURCE:((u==1)?ETS_SPI1_INTR_SOURCE:((u==2)?ETS_SPI2_INTR_SOURCE:((p==3)?ETS_SPI3_INTR_SOURCE:0)))) + +struct spi_struct_t { + spi_dev_t * dev; + uint8_t num; + uint32_t tmp[16]; +}; + +static spi_t _spi_bus_array[4] = { + {(volatile spi_dev_t *)(DR_REG_SPI0_BASE), 0, {0,}}, + {(volatile spi_dev_t *)(DR_REG_SPI1_BASE), 1, {0,}}, + {(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 2, {0,}}, + {(volatile spi_dev_t *)(DR_REG_SPI3_BASE), 3, {0,}} +}; + +typedef union { + uint32_t value; + struct { + uint32_t clkcnt_l: 6; /*it must be equal to spi_clkcnt_N.*/ + uint32_t clkcnt_h: 6; /*it must be floor((spi_clkcnt_N+1)/2-1).*/ + uint32_t clkcnt_n: 6; /*it is the divider of spi_clk. So spi_clk frequency is system/(spi_clkdiv_pre+1)/(spi_clkcnt_N+1)*/ + uint32_t clkdiv_pre: 13; /*it is pre-divider of spi_clk.*/ + uint32_t clk_equ_sysclk: 1; /*1: spi_clk is eqaul to system 0: spi_clk is divided from system clock.*/ + }; +} spiClk_t; + +#define ClkRegToFreq(reg) (apb_freq / (((reg)->clkdiv_pre + 1) * ((reg)->clkcnt_n + 1))) + +uint32_t spi_frequency_to_div(uint32_t freq) +{ + uint32_t apb_freq = 80000000UL; + + if(freq >= apb_freq) { + return SPI_CLK_EQU_SYSCLK; + } + + const spiClk_t minFreqReg = { 0x7FFFF000 }; + uint32_t minFreq = ClkRegToFreq((spiClk_t*) &minFreqReg); + if(freq < minFreq) { + return minFreqReg.value; + } + + uint8_t calN = 1; + spiClk_t bestReg = { 0 }; + int32_t bestFreq = 0; + + while(calN <= 0x3F) { + spiClk_t reg = { 0 }; + int32_t calFreq; + int32_t calPre; + int8_t calPreVari = -2; + + reg.clkcnt_n = calN; + + while(calPreVari++ <= 1) { + calPre = (((apb_freq / (reg.clkcnt_n + 1)) / freq) - 1) + calPreVari; + if(calPre > 0x1FFF) { + reg.clkdiv_pre = 0x1FFF; + } else if(calPre <= 0) { + reg.clkdiv_pre = 0; + } else { + reg.clkdiv_pre = calPre; + } + reg.clkcnt_l = ((reg.clkcnt_n + 1) / 2); + calFreq = ClkRegToFreq(®); + if(calFreq == (int32_t) freq) { + memcpy(&bestReg, ®, sizeof(bestReg)); + break; + } else if(calFreq < (int32_t) freq) { + if(abs(freq - calFreq) < abs(freq - bestFreq)) { + bestFreq = calFreq; + memcpy(&bestReg, ®, sizeof(bestReg)); + } + } + } + if(calFreq == (int32_t) freq) { + break; + } + calN++; + } + return bestReg.value; +} + +static void pinMode(int8_t pin, gpio_mode_t mode) +{ + gpio_config_t conf = { + .pin_bit_mask = 1LL << pin, + .mode = mode, + .pull_up_en = GPIO_PULLDOWN_DISABLE, + .pull_down_en = GPIO_PULLDOWN_DISABLE, + .intr_type = GPIO_INTR_DISABLE + }; + gpio_config(&conf); +} + + +void spi_init(uint8_t spi_num, int8_t sck, int8_t miso, int8_t mosi, uint32_t freq, uint8_t dataMode, uint8_t bitOrder) +{ + if(spi_num > 3){ + return; + } + + spi_t * spi = &_spi_bus_array[spi_num]; + + if(spi_num == HSPI) { + DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI_CLK_EN); + DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI_RST); + } else if(spi_num == VSPI) { + DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI_CLK_EN_2); + DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI_RST_2); + } else { + DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI_CLK_EN_1); + DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI_RST_1); + } + + spi->dev->slave.trans_done = 0; + spi->dev->slave.slave_mode = 0; + spi->dev->pin.val = 0; + spi->dev->user.val = 0; + spi->dev->user1.val = 0; + spi->dev->ctrl.val = 0; + spi->dev->ctrl1.val = 0; + spi->dev->ctrl2.val = 0; + spi->dev->clock.val = 0; + + switch (dataMode) { + case SPI_MODE1: + spi->dev->pin.ck_idle_edge = 0; + spi->dev->user.ck_out_edge = 1; + break; + case SPI_MODE2: + spi->dev->pin.ck_idle_edge = 1; + spi->dev->user.ck_out_edge = 1; + break; + case SPI_MODE3: + spi->dev->pin.ck_idle_edge = 1; + spi->dev->user.ck_out_edge = 0; + break; + case SPI_MODE0: + default: + spi->dev->pin.ck_idle_edge = 0; + spi->dev->user.ck_out_edge = 0; + break; + } + + if (SPI_MSBFIRST == bitOrder) { + spi->dev->ctrl.wr_bit_order = 0; + spi->dev->ctrl.rd_bit_order = 0; + } else if (SPI_LSBFIRST == bitOrder) { + spi->dev->ctrl.wr_bit_order = 1; + spi->dev->ctrl.rd_bit_order = 1; + } + + spi->dev->clock.val = spi_frequency_to_div(freq); + + spi->dev->user.usr_mosi = 1;//mosi >= 0; + spi->dev->user.usr_miso = 1;//miso >= 0; + spi->dev->user.doutdin = 1;//(mosi >= 0) && (miso >= 0); + + int i; + for(i=0; i<16; i++) { + spi->dev->data_buf[i] = 0x00000000; + } + + if (sck >= 0) { + pinMode(sck, GPIO_MODE_OUTPUT); + gpio_matrix_out(sck, SPI_CLK_IDX(spi_num), false, false); + } + + if (mosi >= 0) { + pinMode(mosi, GPIO_MODE_OUTPUT); + gpio_matrix_out(mosi, SPI_MOSI_IDX(spi_num), false, false); + } + + if (miso >= 0) { + pinMode(miso, GPIO_MODE_INPUT); + gpio_matrix_in(miso, SPI_MISO_IDX(spi_num), false); + } + + return; +} + +#define SPI_MUTEX_LOCK() //do {} while (xSemaphoreTake(spi->lock, portMAX_DELAY) != pdPASS) +#define SPI_MUTEX_UNLOCK() //xSemaphoreGive(spi->lock) + +void spi_begin_transaction(uint8_t spi_num, uint32_t clockDiv, uint8_t dataMode, uint8_t bitOrder) +{ + if(spi_num > 3){ + return; + } + + spi_t * spi = &_spi_bus_array[spi_num]; + SPI_MUTEX_LOCK(); + spi->dev->clock.val = clockDiv; + switch (dataMode) { + case SPI_MODE1: + spi->dev->pin.ck_idle_edge = 0; + spi->dev->user.ck_out_edge = 1; + break; + case SPI_MODE2: + spi->dev->pin.ck_idle_edge = 1; + spi->dev->user.ck_out_edge = 1; + break; + case SPI_MODE3: + spi->dev->pin.ck_idle_edge = 1; + spi->dev->user.ck_out_edge = 0; + break; + case SPI_MODE0: + default: + spi->dev->pin.ck_idle_edge = 0; + spi->dev->user.ck_out_edge = 0; + break; + } + if (SPI_MSBFIRST == bitOrder) { + spi->dev->ctrl.wr_bit_order = 0; + spi->dev->ctrl.rd_bit_order = 0; + } else if (SPI_LSBFIRST == bitOrder) { + spi->dev->ctrl.wr_bit_order = 1; + spi->dev->ctrl.rd_bit_order = 1; + } +} + +void spi_end_transaction(uint8_t spi_num) +{ + if(spi_num > 3){ + return; + } + + spi_t * spi = &_spi_bus_array[spi_num]; + SPI_MUTEX_UNLOCK(); +} + +uint8_t spi_transfer_byte(uint8_t spi_num, uint8_t data) +{ + if(spi_num > 3){ + return 0xFF; + } + + spi_t * spi = &_spi_bus_array[spi_num]; + spi->dev->user.usr_mosi = 1; + spi->dev->user.usr_miso = 1; + spi->dev->user.doutdin = 1; + spi->dev->mosi_dlen.usr_mosi_dbitlen = 7; + spi->dev->miso_dlen.usr_miso_dbitlen = 7; + spi->dev->data_buf[0] = data; + spi->dev->cmd.usr = 1; + while(spi->dev->cmd.usr); + data = spi->dev->data_buf[0] & 0xFF; + return data; +} + +void spi_write_byte(uint8_t spi_num, uint8_t data) +{ + if(spi_num > 3){ + return; + } + + spi_t * spi = &_spi_bus_array[spi_num]; + spi->dev->user.usr_mosi = 1; + spi->dev->user.usr_miso = 0; + spi->dev->user.doutdin = 0; + spi->dev->mosi_dlen.usr_mosi_dbitlen = 7; + spi->dev->miso_dlen.usr_miso_dbitlen = 0; + spi->dev->data_buf[0] = data; + spi->dev->cmd.usr = 1; + while(spi->dev->cmd.usr); + spi->dev->user.usr_mosi = 1; + spi->dev->user.usr_miso = 1; + spi->dev->user.doutdin = 1; +} + +#define MSB_16_SET(var, val) { (var) = (((val) & 0xFF00) >> 8) | (((val) & 0xFF) << 8); } +void spi_write_short(uint8_t spi_num, uint16_t data) +{ + if(spi_num > 3){ + return; + } + + spi_t * spi = &_spi_bus_array[spi_num]; + spi->dev->user.usr_mosi = 1; + spi->dev->user.usr_miso = 0; + spi->dev->user.doutdin = 0; + if(!spi->dev->ctrl.wr_bit_order){ + MSB_16_SET(data, data); + } + spi->dev->mosi_dlen.usr_mosi_dbitlen = 15; + spi->dev->miso_dlen.usr_miso_dbitlen = 0; + spi->dev->data_buf[0] = data; + spi->dev->cmd.usr = 1; + while(spi->dev->cmd.usr); + spi->dev->user.usr_mosi = 1; + spi->dev->user.usr_miso = 1; + spi->dev->user.doutdin = 1; +} + +#define MSB_32_SET(var, val) { uint8_t * d = (uint8_t *)&(val); (var) = d[3] | (d[2] << 8) | (d[1] << 16) | (d[0] << 24); } +void spi_write_long(uint8_t spi_num, uint32_t data) +{ + if(spi_num > 3){ + return; + } + + spi_t * spi = &_spi_bus_array[spi_num]; + spi->dev->user.usr_mosi = 1; + spi->dev->user.usr_miso = 0; + spi->dev->user.doutdin = 0; + if(!spi->dev->ctrl.wr_bit_order){ + MSB_32_SET(data, data); + } + spi->dev->mosi_dlen.usr_mosi_dbitlen = 31; + spi->dev->miso_dlen.usr_miso_dbitlen = 0; + spi->dev->data_buf[0] = data; + spi->dev->cmd.usr = 1; + while(spi->dev->cmd.usr); + spi->dev->user.usr_mosi = 1; + spi->dev->user.usr_miso = 1; + spi->dev->user.doutdin = 1; +} + +void spi_write(uint8_t spi_num, const void * data_in, size_t len){ + if(spi_num > 3){ + return; + } + + spi_t * spi = &_spi_bus_array[spi_num]; + + uint32_t * data = (uint32_t*)data_in; + size_t longs = len >> 2; + if(len & 3){ + longs++; + } + + spi->dev->user.usr_mosi = 1; + spi->dev->user.usr_miso = 0; + spi->dev->user.doutdin = 0; + spi->dev->miso_dlen.usr_miso_dbitlen = 0; + + if(len > 64) { + spi->dev->mosi_dlen.usr_mosi_dbitlen = 511; + while(len > 64){ + for (int i=0; i<16; i++) { + spi->dev->data_buf[i] = data[i]; + } + spi->dev->cmd.usr = 1; + data += 16; + longs -= 16; + len -= 64; + while(spi->dev->cmd.usr); + } + } + + if(len){ + spi->dev->mosi_dlen.usr_mosi_dbitlen = (len*8)-1; + for (int i=0; idev->data_buf[i] = data[i]; + } + spi->dev->cmd.usr = 1; + while(spi->dev->cmd.usr); + } + + spi->dev->user.usr_mosi = 1; + spi->dev->user.usr_miso = 1; + spi->dev->user.doutdin = 1; +} + +void spi_read(uint8_t spi_num, void * data_out, size_t len){ + if(spi_num > 3){ + return; + } + + spi_t * spi = &_spi_bus_array[spi_num]; + + uint32_t * data = (uint32_t*)data_out; + uint32_t temp = 0; + size_t longs = len >> 2; + if(len & 3){ + longs++; + } + + spi->dev->user.usr_mosi = 0; + spi->dev->user.usr_miso = 1; + spi->dev->user.doutdin = 0; + spi->dev->mosi_dlen.usr_mosi_dbitlen = 0; + + if(len > 64) { + spi->dev->miso_dlen.usr_miso_dbitlen = 511; + while(len > 64){ + spi->dev->cmd.usr = 1; + while(spi->dev->cmd.usr); + for (int i=0; i<16; i++) { + data[i] = spi->dev->data_buf[i]; + } + data += 16; + longs -= 16; + len -= 64; + } + } + + if(len){ + spi->dev->miso_dlen.usr_miso_dbitlen = (len*8)-1; + spi->dev->cmd.usr = 1; + while(spi->dev->cmd.usr); + for (int i=0; idev->data_buf[i]; + memcpy(&data[i], &temp, len & 3); + } else { + data[i] = spi->dev->data_buf[i]; + } + } + } + + spi->dev->user.usr_mosi = 1; + spi->dev->user.usr_miso = 1; + spi->dev->user.doutdin = 1; +} + +void spi_transfer(uint8_t spi_num, const void * data_in, void * data_out, size_t len){ + if(spi_num > 3 || len == 0 || (data_in == NULL && data_out == NULL)){ + return; + } + + if(data_in == NULL){ + return spi_read(spi_num, data_out, len); + } else if(data_out == NULL){ + return spi_write(spi_num, data_in, len); + } + + spi_t * spi = &_spi_bus_array[spi_num]; + + uint32_t * data_o = (uint32_t*)data_out; + uint32_t * data_i = (uint32_t*)data_in; + uint32_t temp = 0; + size_t longs = len >> 2; + if(len & 3){ + longs++; + } + + spi->dev->user.usr_mosi = 1; + spi->dev->user.usr_miso = 1; + spi->dev->user.doutdin = 1; + + if(len > 64) { + spi->dev->miso_dlen.usr_miso_dbitlen = 511; + spi->dev->mosi_dlen.usr_mosi_dbitlen = 511; + while(len > 64){ + for (int i=0; i<16; i++) { + spi->dev->data_buf[i] = data_i[i]; + } + spi->dev->cmd.usr = 1; + while(spi->dev->cmd.usr); + for (int i=0; i<16; i++) { + data_o[i] = spi->dev->data_buf[i]; + } + data_o += 16; + data_i += 16; + longs -= 16; + len -= 64; + } + } + + if(len){ + spi->dev->miso_dlen.usr_miso_dbitlen = (len*8)-1; + spi->dev->mosi_dlen.usr_mosi_dbitlen = (len*8)-1; + for (int i=0; idev->data_buf[i] = data_i[i]; + } + spi->dev->cmd.usr = 1; + while(spi->dev->cmd.usr); + for (int i=0; idev->data_buf[i]; + memcpy(&data_o[i], &temp, len & 3); + } else { + data_o[i] = spi->dev->data_buf[i]; + } + } + } +} + +#define MSB_PIX_SET(var, val) { uint8_t * d = (uint8_t *)&(val); (var) = d[1] | (d[0] << 8) | (d[3] << 16) | (d[2] << 24); } + +void spi_write_pixels(uint8_t spi_num, const void * data_in, size_t len){ + if(spi_num > 3){ + return; + } + len *= 2; + + spi_t * spi = &_spi_bus_array[spi_num]; + uint32_t * data = (uint32_t*)data_in; + + size_t longs = len >> 2; + if(len & 3){ + longs++; + } + while(spi->dev->cmd.usr); + + spi->dev->user.usr_mosi = 1; + spi->dev->user.usr_miso = 0; + spi->dev->user.doutdin = 0; + spi->dev->miso_dlen.usr_miso_dbitlen = 0; + + if(len > 64) { + spi->dev->mosi_dlen.usr_mosi_dbitlen = 511; + while(len > 64){ + for (int i=0; i<16; i++) { + MSB_PIX_SET(spi->tmp[i], data[i]); + } + data += 16; + longs -= 16; + len -= 64; + while(spi->dev->cmd.usr); + for (int i=0; i<16; i++) { + spi->dev->data_buf[i] = spi->tmp[i]; + } + spi->dev->cmd.usr = 1; + } + } + + if(len){ + for (int i=0; itmp[i], data[i]); + } + while(spi->dev->cmd.usr); + spi->dev->mosi_dlen.usr_mosi_dbitlen = (len*8)-1; + for (int i=0; idev->data_buf[i] = spi->tmp[i]; + } + spi->dev->cmd.usr = 1; + } + while(spi->dev->cmd.usr); + + spi->dev->user.usr_mosi = 1; + spi->dev->user.usr_miso = 1; + spi->dev->user.doutdin = 1; +} + +void spi_write_color(uint8_t spi_num, uint16_t color, size_t len){ + if(spi_num > 3){ + return; + } + len *= 2; + color = color >> 8 | color << 8; + + spi_t * spi = &_spi_bus_array[spi_num]; + uint32_t data = color << 16 | color; + size_t longs = len >> 2; + if(len & 3){ + longs++; + } + + spi->dev->user.usr_mosi = 1; + spi->dev->user.usr_miso = 0; + spi->dev->user.doutdin = 0; + spi->dev->miso_dlen.usr_miso_dbitlen = 0; + + if(len > 64) { + spi->dev->mosi_dlen.usr_mosi_dbitlen = 511; + while(len > 64){ + for (int i=0; i<16; i++) { + spi->dev->data_buf[i] = data; + } + spi->dev->cmd.usr = 1; + longs -= 16; + len -= 64; + while(spi->dev->cmd.usr); + } + } + + if(len){ + spi->dev->mosi_dlen.usr_mosi_dbitlen = (len*8)-1; + for (int i=0; idev->data_buf[i] = data; + } + spi->dev->cmd.usr = 1; + while(spi->dev->cmd.usr); + } + + spi->dev->user.usr_mosi = 1; + spi->dev->user.usr_miso = 1; + spi->dev->user.doutdin = 1; +} + +//Select DMA channel. +// DPORT_SET_PERI_REG_BITS(DPORT_SPI_DMA_CHAN_SEL_REG, 3, dma_chan, ((host - 1) * 2)); + diff --git a/components/lcd_driver/esp32-spi.h b/components/lcd_driver/esp32-spi.h new file mode 100644 index 0000000..427bf49 --- /dev/null +++ b/components/lcd_driver/esp32-spi.h @@ -0,0 +1,64 @@ +// 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. + +#ifndef _ESP32_SPI_H_ +#define _ESP32_SPI_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "esp_types.h" + +#define FSPI 1 //SPI bus attached to the flash (can use the same data lines but different SS) +#define HSPI 2 //SPI bus normally mapped to pins 12 - 15, but can be matrixed to any pins +#define VSPI 3 //SPI bus normally attached to pins 5, 18, 19 and 23, but can be matrixed to any pins + +#define SPI_MODE0 0 +#define SPI_MODE1 1 +#define SPI_MODE2 2 +#define SPI_MODE3 3 + +#define SPI_LSBFIRST 0 +#define SPI_MSBFIRST 1 + +struct spi_struct_t; +typedef struct spi_struct_t spi_t; + +void spi_init(uint8_t spi_num, int8_t sck, int8_t miso, int8_t mosi, uint32_t freq, uint8_t dataMode, uint8_t bitOrder); + +void spi_begin_transaction(uint8_t spi_num, uint32_t clockDiv, uint8_t dataMode, uint8_t bitOrder); +void spi_end_transaction(uint8_t spi_num); + +void spi_write(uint8_t spi_num, const void * data, size_t len); +void spi_read(uint8_t spi_num, void * data, size_t len); +void spi_transfer(uint8_t spi_num, const void * data_in, void * data_out, size_t len); + +uint8_t spi_transfer_byte(uint8_t spi_num, uint8_t data); +void spi_write_byte(uint8_t spi_num, uint8_t data); +void spi_write_short(uint8_t spi_num, uint16_t data); +void spi_write_long(uint8_t spi_num, uint32_t data); + +void spi_write_pixels(uint8_t spi_num, const void * data, size_t len); +void spi_write_color(uint8_t spi_num, uint16_t color, size_t len); + +uint32_t spi_frequency_to_div(uint32_t freq); + +#ifdef __cplusplus +} +#endif + +#endif /* _ESP32_SPI_H_ */ diff --git a/components/lcd_driver/ili9341.c b/components/lcd_driver/ili9341.c new file mode 100644 index 0000000..f12e562 --- /dev/null +++ b/components/lcd_driver/ili9341.c @@ -0,0 +1,290 @@ +// 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 +#include +#include +#include +#include "sdkconfig.h" +#include "rom/ets_sys.h" +#include "rom/gpio.h" +#include "soc/gpio_reg.h" +#include "soc/gpio_sig_map.h" +#include "soc/gpio_struct.h" +#include "soc/io_mux_reg.h" +#include "soc/spi_reg.h" +#include "soc/spi_struct.h" +#include "freertos/FreeRTOS.h" +#include "freertos/semphr.h" +#include "freertos/task.h" +#include "ili9341.h" + +const uint8_t ili9341_init_data[] = { + 0xEF, 3, 0x03,0x80,0x02, + 0xCF, 3, 0x00,0XC1,0X30, + 0xED, 4, 0x64,0x03,0X12,0X81, + 0xE8, 3, 0x85,0x00,0x78, + 0xCB, 5, 0x39,0x2C,0x00,0x34,0x02, + 0xF7, 1, 0x20, + 0xEA, 2, 0x00,0x00, + 0xC0, 1, 0x23, + 0xC1, 1, 0x10, + 0xC5, 2, 0x3e,0x28, + 0xC7, 1, 0x86, + 0x36, 1, 0x48, + 0x3A, 1, 0x55, + 0xB1, 2, 0x00,0x18, + 0xB6, 3, 0x08,0x82,0x27, + 0xF2, 1, 0x00, + 0x26, 1, 0x01, + 0xE0, 15, 0x0F,0x31,0x2B,0x0C,0x0E,0x08,0x4E,0xF1,0x37,0x07,0x10,0x03,0x0E,0x09,0x00, + 0xE1, 15, 0x00,0x0E,0x14,0x03,0x11,0x07,0x31,0xC1,0x48,0x08,0x0F,0x0C,0x31,0x36,0x0F, + 0x00 +}; + +const uint8_t st7789v_init_data[] = { + 0x36, 1, 0, + 0x3A, 1, 0x55, + 0xB2, 5, 0x0C,0x0C,0x00,0x33,0x33, + 0xB7, 1, 0x35, + 0xBB, 1, 0x2B, + 0xC0, 1, 0x2C, + 0xC2, 2, 0x01,0xFF, + 0xC3, 1, 0x11, + 0xC4, 1, 0x20, + 0xC6, 1, 0x0F, + 0xD0, 2, 0xA4,0xA1, + 0xE0, 14, 0xD0,0x00,0x05,0x0E,0x15,0x0D,0x37,0x43,0x47,0x09,0x15,0x12,0x16,0x19, + 0xE1, 14, 0xD0,0x00,0x05,0x0D,0x0C,0x06,0x2D,0x44,0x40,0x0E,0x1C,0x18,0x16,0x19, + 0x00 +}; + +typedef struct ili9341_lcd_s { + uint32_t id; + struct { + uint8_t cs; + uint8_t dc; + uint8_t reset; + uint8_t backlight; + } pins; + uint8_t spi; + uint32_t spi_div; + uint16_t width; + uint16_t height; + uint8_t rotation; +} ili9341_lcd_t; + +static void _ili9341_command(ili9341_lcd_t * lcd, const uint8_t cmd){ + gpio_set_level((gpio_num_t)lcd->pins.dc, 0); + spi_write_byte(lcd->spi, cmd); + gpio_set_level((gpio_num_t)lcd->pins.dc, 1); +} + +static void _ili9341_write_init(ili9341_lcd_t * lcd, const uint8_t * data){ + uint8_t cmd, len, i; + while(true){ + cmd = *data++; + if(!cmd){ //END + return; + } + len = *data++; + _ili9341_command(lcd, cmd); + for(i=0;ispi, *data++); + } + } +} + +void ili9341_set_window(ili9341_lcd_t * lcd, const uint16_t x, const uint16_t y, const uint16_t width, const uint16_t height){ + _ili9341_command(lcd, 0x2A); + spi_write_long(lcd->spi, ((uint32_t)x << 16) | (x+width-1)); + _ili9341_command(lcd, 0x2B); + spi_write_long(lcd->spi, ((uint32_t)y << 16) | (y+height-1)); + _ili9341_command(lcd, 0x2C); +} + +void ili9341_write_pixel(ili9341_lcd_t * lcd, const uint16_t color){ + spi_write_short(lcd->spi, color); +} + +void ili9341_write_pixels(ili9341_lcd_t * lcd, const uint16_t * data, size_t length){ + spi_write_pixels(lcd->spi, data , length); +} + +void ili9341_write_color(ili9341_lcd_t * lcd, const uint16_t color, size_t length){ + size_t blen = (length > 128)?128:length; + uint16_t temp[blen]; + uint8_t tlen = 0; + + for (int t=0; tblen)?blen:length; + spi_write_pixels(lcd->spi, temp, tlen); + length -= tlen; + } +} + +void ili9341_start_pixels(ili9341_lcd_t * lcd){ + spi_begin_transaction(lcd->spi, lcd->spi_div, SPI_MODE0, SPI_MSBFIRST); + gpio_set_level((gpio_num_t)lcd->pins.cs, 0); +} + +void ili9341_end_pixels(ili9341_lcd_t * lcd){ + gpio_set_level((gpio_num_t)lcd->pins.cs, 1); + spi_end_transaction(lcd->spi); +} + +uint32_t _ili9341_read_id(ili9341_lcd_t * lcd) { + uint32_t read_div = spi_frequency_to_div(24000000); + uint32_t old_div = lcd->spi_div; + lcd->spi_div = read_div; + + ili9341_start_pixels(lcd); + + _ili9341_command(lcd, 0xD9); + spi_write_byte(lcd->spi, 0x10); + _ili9341_command(lcd, 0x04); + uint32_t r = spi_transfer_byte(lcd->spi, 0) << 16; + r |= spi_transfer_byte(lcd->spi, 0) << 8; + r |= spi_transfer_byte(lcd->spi, 0); + ili9341_end_pixels(lcd); + lcd->spi_div = old_div; + + //log_i("LCD ID: 0x%06X", r); + return r; +} + +static void ili9341_init_lcd(ili9341_lcd_t * lcd) +{ + ili9341_start_pixels(lcd); + _ili9341_write_init(lcd, (lcd->id)?st7789v_init_data:ili9341_init_data); + _ili9341_command(lcd, 0x11); //Exit Sleep + vTaskDelay(100 / portTICK_PERIOD_MS); + _ili9341_command(lcd, 0x29); //Display on + vTaskDelay(100 / portTICK_PERIOD_MS); + ili9341_end_pixels(lcd); +} + +static void pinMode(int8_t pin, gpio_mode_t mode) +{ + gpio_config_t conf = { + .pin_bit_mask = 1LL << pin, + .mode = mode, + .pull_up_en = GPIO_PULLDOWN_DISABLE, + .pull_down_en = GPIO_PULLDOWN_DISABLE, + .intr_type = GPIO_INTR_DISABLE + }; + gpio_config(&conf); +} + +ili9341_lcd_t * ili9341_init(uint8_t spi_num, uint32_t frequency, uint8_t cs, uint8_t dc, uint8_t reset, uint8_t backlight) +{ + ili9341_lcd_t * lcd = (ili9341_lcd_t *)malloc(sizeof(ili9341_lcd_t)); + if(!lcd){ + return NULL; + } + + lcd->spi = spi_num; + lcd->spi_div = spi_frequency_to_div(frequency); + lcd->pins.cs = cs; + lcd->pins.dc = dc; + lcd->pins.reset = reset; + lcd->pins.backlight = backlight; + lcd->width = 320; + lcd->height = 240; + lcd->rotation = 0; + + pinMode(lcd->pins.cs, GPIO_MODE_OUTPUT); + gpio_set_level((gpio_num_t)lcd->pins.cs, 1); + + pinMode(lcd->pins.dc, GPIO_MODE_OUTPUT); + gpio_set_level((gpio_num_t)lcd->pins.dc, 0); + + if(lcd->pins.backlight < 34){ + pinMode(lcd->pins.backlight, GPIO_MODE_OUTPUT); + //gpio_set_level((gpio_num_t)lcd->pins.backlight, 1); + gpio_set_level((gpio_num_t)lcd->pins.backlight, 0); + } + + if(lcd->pins.reset < 34){ + pinMode(lcd->pins.reset, GPIO_MODE_OUTPUT); + gpio_set_level((gpio_num_t)lcd->pins.reset, 1); + vTaskDelay(100 / portTICK_PERIOD_MS); + gpio_set_level((gpio_num_t)lcd->pins.reset, 0); + vTaskDelay(200 / portTICK_PERIOD_MS); + gpio_set_level((gpio_num_t)lcd->pins.reset, 1); + vTaskDelay(200 / portTICK_PERIOD_MS); + } + + lcd->id = _ili9341_read_id(lcd); + if(lcd->id == 0xFFFFFF){ + lcd->id = 0; + } + + ili9341_init_lcd(lcd); + + return lcd; +} + +#define MADCTL_MY 0x80 +#define MADCTL_MX 0x40 +#define MADCTL_MV 0x20 +#define MADCTL_ML 0x10 +#define MADCTL_RGB 0x00 +#define MADCTL_BGR 0x08 +#define MADCTL_MH 0x04 + +typedef struct { + uint8_t madctl; + uint8_t bmpctl; + uint16_t width; + uint16_t height; +} rotation_data_t; + +const rotation_data_t ili9341_rotations[4] = { + {(MADCTL_BGR),(MADCTL_MX|MADCTL_MY|MADCTL_BGR),ILI9341_WIDTH,ILI9341_HEIGHT}, + {(MADCTL_MV|MADCTL_BGR),(MADCTL_MV|MADCTL_MX|MADCTL_BGR),ILI9341_HEIGHT,ILI9341_WIDTH}, + {(MADCTL_MY|MADCTL_MX|MADCTL_BGR),(MADCTL_BGR),ILI9341_WIDTH,ILI9341_HEIGHT}, + {(MADCTL_MX|MADCTL_MY|MADCTL_MV|MADCTL_BGR),(MADCTL_MY|MADCTL_MV|MADCTL_BGR),ILI9341_HEIGHT,ILI9341_WIDTH} +}; + +const rotation_data_t st7789v_rotations[4] = { + {0,MADCTL_MY,ILI9341_WIDTH,ILI9341_HEIGHT}, + {(MADCTL_MV|MADCTL_MX),MADCTL_MV,ILI9341_HEIGHT,ILI9341_WIDTH}, + {(MADCTL_MY|MADCTL_MX),MADCTL_MX,ILI9341_WIDTH,ILI9341_HEIGHT}, + {(MADCTL_MY|MADCTL_MV),(MADCTL_MX|MADCTL_MY|MADCTL_MV),ILI9341_HEIGHT,ILI9341_WIDTH} +}; + +void ili9341_set_rotation(ili9341_lcd_t * lcd, uint8_t m) +{ + lcd->rotation = m % 4; // can't be higher than 3 + + if(lcd->id){ + m = st7789v_rotations[lcd->rotation].madctl; + lcd->width = st7789v_rotations[lcd->rotation].width; + lcd->height = st7789v_rotations[lcd->rotation].height; + } else { + m = ili9341_rotations[lcd->rotation].madctl; + lcd->width = ili9341_rotations[lcd->rotation].width; + lcd->height = ili9341_rotations[lcd->rotation].height; + } + + ili9341_start_pixels(lcd); + _ili9341_command(lcd, 0x36); + spi_write_byte(lcd->spi, m); + ili9341_end_pixels(lcd); +} diff --git a/components/lcd_driver/ili9341.h b/components/lcd_driver/ili9341.h new file mode 100644 index 0000000..44eb473 --- /dev/null +++ b/components/lcd_driver/ili9341.h @@ -0,0 +1,67 @@ +// 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. +#ifndef _ILI9341_H_ +#define _ILI9341_H_ +#include +#include "esp32-spi.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define ILI9341_WIDTH 320 +#define ILI9341_HEIGHT 240 + +// Color definitions +#define ILI9341_BLACK 0x0000 /* 0, 0, 0 */ +#define ILI9341_NAVY 0x000F /* 0, 0, 128 */ +#define ILI9341_DARKGREEN 0x03E0 /* 0, 128, 0 */ +#define ILI9341_DARKCYAN 0x03EF /* 0, 128, 128 */ +#define ILI9341_MAROON 0x7800 /* 128, 0, 0 */ +#define ILI9341_PURPLE 0x780F /* 128, 0, 128 */ +#define ILI9341_OLIVE 0x7BE0 /* 128, 128, 0 */ +#define ILI9341_LIGHTGREY 0xC618 /* 192, 192, 192 */ +#define ILI9341_DARKGREY 0x7BEF /* 128, 128, 128 */ +#define ILI9341_BLUE 0x001F /* 0, 0, 255 */ +#define ILI9341_GREEN 0x07E0 /* 0, 255, 0 */ +#define ILI9341_CYAN 0x07FF /* 0, 255, 255 */ +#define ILI9341_RED 0xF800 /* 255, 0, 0 */ +#define ILI9341_MAGENTA 0xF81F /* 255, 0, 255 */ +#define ILI9341_YELLOW 0xFFE0 /* 255, 255, 0 */ +#define ILI9341_WHITE 0xFFFF /* 255, 255, 255 */ +#define ILI9341_ORANGE 0xFD20 /* 255, 165, 0 */ +#define ILI9341_GREENYELLOW 0xAFE5 /* 173, 255, 47 */ +#define ILI9341_PINK 0xF81F + +#define ili9341_rgb565(r,g,b) ((uint16_t)((((uint16_t)(r) & 0xF8) << 8) | (((uint16_t)(g) & 0xFC) << 3) | ((uint8_t)(b) >> 3))) + +struct ili9341_lcd_s; +typedef struct ili9341_lcd_s ili9341_lcd_t; + +ili9341_lcd_t * ili9341_init(uint8_t spi_num, uint32_t frequency, uint8_t cs, uint8_t dc, uint8_t reset, uint8_t backlight); + +void ili9341_set_rotation (ili9341_lcd_t * lcd, uint8_t rotation);//0&2 portrait, 1%3 landscape +void ili9341_start_pixels (ili9341_lcd_t * lcd); +void ili9341_set_window (ili9341_lcd_t * lcd, const uint16_t x, const uint16_t y, const uint16_t width, const uint16_t height); +void ili9341_write_pixel (ili9341_lcd_t * lcd, const uint16_t color); +void ili9341_write_pixels (ili9341_lcd_t * lcd, const uint16_t * data, size_t length); +void ili9341_write_color (ili9341_lcd_t * lcd, const uint16_t color, size_t length); +void ili9341_end_pixels (ili9341_lcd_t * lcd); + +#ifdef __cplusplus +} +#endif + +#endif /* _ILI9341_H_ */ diff --git a/esp-idf b/esp-idf index 2e6398a..90af68b 160000 --- a/esp-idf +++ b/esp-idf @@ -1 +1 @@ -Subproject commit 2e6398affaeeac2f7ce40457a881f2dda57ad11f +Subproject commit 90af68bd3c1941d9f5513bee22a12de7250208d7 diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt new file mode 100644 index 0000000..cfe7084 --- /dev/null +++ b/example/CMakeLists.txt @@ -0,0 +1,6 @@ +# The following lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(video-play) diff --git a/example/Makefile b/example/Makefile new file mode 100644 index 0000000..524a475 --- /dev/null +++ b/example/Makefile @@ -0,0 +1,12 @@ +# +# This is a project Makefile. It is assumed the directory this Makefile resides in is a +# project subdirectory. +# + +PROJECT_NAME := esp32_awtk_demo + +EXTRA_COMPONENT_DIRS += ../components/ +include $(IDF_PATH)/make/project.mk + +# include $(ADF_PATH)/project.mk + diff --git a/example/esp32-awtk-partitions.csv b/example/esp32-awtk-partitions.csv new file mode 100644 index 0000000..cf521ac --- /dev/null +++ b/example/esp32-awtk-partitions.csv @@ -0,0 +1,9 @@ +# Espressif ESP32 Partition Table +# +# Note: if you change the phy_init or app partition offset +# make sure to change the offset in Kconfig.projbuild +# +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x9000, 0x6000, +phy_init, data, phy, 0xf000, 0x1000, +factory, app, factory, 0x10000, 2000000, diff --git a/example/main/CMakeLists.txt b/example/main/CMakeLists.txt new file mode 100644 index 0000000..54e927c --- /dev/null +++ b/example/main/CMakeLists.txt @@ -0,0 +1,4 @@ +set(COMPONENT_SRCS "video_play.c") +set(COMPONENT_ADD_INCLUDEDIRS "") + +register_component() diff --git a/example/main/component.mk b/example/main/component.mk new file mode 100644 index 0000000..dc6dc4f --- /dev/null +++ b/example/main/component.mk @@ -0,0 +1,6 @@ +# +# "main" pseudo-component makefile. +# +# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) + +COMPONENT_EMBED_TXTFILES := rgb565_piexl diff --git a/example/main/esp32_awtk_main.c b/example/main/esp32_awtk_main.c new file mode 100644 index 0000000..994f1b9 --- /dev/null +++ b/example/main/esp32_awtk_main.c @@ -0,0 +1,99 @@ +/* Hello World Example + + This example code is in the Public Domain (or CC0 licensed, at your option.) + + Unless required by applicable law or agreed to in writing, this + software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + CONDITIONS OF ANY KIND, either express or implied. +*/ +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "esp_system.h" +#include "esp_spi_flash.h" +#include +#include "esp_log.h" + +#include "ili9341.h" +#define LCD_SPI_NUM HSPI +#define LCD_SPI_FREQ 80000000 +#define LCD_SPI_MODE SPI_MODE0 +#define LCD_SPI_ORDER SPI_MSBFIRST + +// Wrover-Kit +#define LCD_SPI_SCK 19 +#define LCD_SPI_MISO 25 +#define LCD_SPI_MOSI 23 +#define LCD_SPI_CS 22 +#define LCD_SPI_DC 21 +#define LCD_SPI_RST 18 +#define LCD_SPI_BL 5 + +#define VIDEO_FRAME_SIZE (320*240*2) +#define LCD_RENDER_TASK_STACK (3*1024) +#define LCD_RENDER_TASK_PRIO (21) + +#define PIEXL_READ_TASK_STACK (3*1024) +#define PIEXL_READ_TASK_PRIO (21) + +ili9341_lcd_t * lcd; + +extern const uint8_t rgb565_piexl_start[] asm("_binary_rgb565_piexl_start"); +extern const uint8_t rgb565_piexl_end[] asm("_binary_rgb565_piexl_end"); + +static const char *TAG = "PLAY_RGB565_EXAMPLE"; + +void setup_ili9341() { + spi_init(LCD_SPI_NUM, LCD_SPI_SCK, LCD_SPI_MISO, LCD_SPI_MOSI, LCD_SPI_FREQ, LCD_SPI_MODE, LCD_SPI_ORDER); + lcd = ili9341_init(LCD_SPI_NUM, LCD_SPI_FREQ, LCD_SPI_CS, LCD_SPI_DC, LCD_SPI_RST, LCD_SPI_BL); + ili9341_set_rotation(lcd, 3); + +} + +extern int gui_app_start(int lcd_w, int lcd_h); + +static void __awtk_task_entry(void *p_arg) { + ESP_LOGI(TAG, "__awtk_task_entry started"); + gui_app_start(320, 240); + ESP_LOGI(TAG, "__awtk_task_entry deleted"); + vTaskDelete(NULL); +} + +static void _lcd_render_task(void *pv) +{ + ESP_LOGI(TAG, "Start LCD render task"); + setup_ili9341(); + if (xTaskCreatePinnedToCore(__awtk_task_entry, + "__awtk_task_entry", + 4096, + NULL, + 5, + NULL, 0) != pdTRUE) { + ESP_LOGE(TAG, "Error create LCD render task"); + } + uint16_t * esp32_frame = (uint16_t *)heap_caps_malloc(VIDEO_FRAME_SIZE, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); + memcpy(esp32_frame, rgb565_piexl_start, rgb565_piexl_end - rgb565_piexl_start); + + ili9341_start_pixels(lcd); + ili9341_set_window(lcd, 0, 0, 320, 240); + ili9341_write_pixels(lcd, esp32_frame, 320*240); + ili9341_end_pixels(lcd); + ESP_LOGE(TAG, "__lcd_render_task started,lcd:%p", lcd); + while (1) { + vTaskDelay(3000 / portTICK_PERIOD_MS); + } + + vTaskDelete(NULL); +} + +void app_main() +{ + if (xTaskCreatePinnedToCore(_lcd_render_task, + "_lcd_render_task", + LCD_RENDER_TASK_STACK, + NULL, + LCD_RENDER_TASK_PRIO, + NULL, 1) != pdTRUE) { + ESP_LOGE(TAG, "Error create LCD render task"); + } +} diff --git a/example/main/rgb565_piexl b/example/main/rgb565_piexl new file mode 100644 index 0000000..2961345 Binary files /dev/null and b/example/main/rgb565_piexl differ diff --git a/example/main/test_file/sony.mp3 b/example/main/test_file/sony.mp3 new file mode 100644 index 0000000..8316f82 Binary files /dev/null and b/example/main/test_file/sony.mp3 differ diff --git a/example/main/test_file/sony.rgb b/example/main/test_file/sony.rgb new file mode 100644 index 0000000..e15838f Binary files /dev/null and b/example/main/test_file/sony.rgb differ diff --git a/example/sdkconfig b/example/sdkconfig new file mode 100644 index 0000000..74b3f2e --- /dev/null +++ b/example/sdkconfig @@ -0,0 +1,713 @@ +# +# Automatically generated file; DO NOT EDIT. +# Espressif IoT Development Framework Configuration +# +CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000 + +# +# SDK tool configuration +# +CONFIG_TOOLPREFIX="xtensa-esp32-elf-" +CONFIG_PYTHON="python" +CONFIG_MAKE_WARN_UNDEFINED_VARIABLES=y + +# +# Bootloader config +# +CONFIG_LOG_BOOTLOADER_LEVEL_NONE= +CONFIG_LOG_BOOTLOADER_LEVEL_ERROR= +CONFIG_LOG_BOOTLOADER_LEVEL_WARN= +CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y +CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG= +CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE= +CONFIG_LOG_BOOTLOADER_LEVEL=3 +CONFIG_BOOTLOADER_SPI_WP_PIN=7 +CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y +CONFIG_BOOTLOADER_FACTORY_RESET= +CONFIG_BOOTLOADER_APP_TEST= +CONFIG_BOOTLOADER_WDT_ENABLE=y +CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE= +CONFIG_BOOTLOADER_WDT_TIME_MS=9000 + +# +# Security features +# +CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT= +CONFIG_SECURE_BOOT_ENABLED= +CONFIG_FLASH_ENCRYPTION_ENABLED= + +# +# Serial flasher config +# +CONFIG_ESPTOOLPY_PORT="/dev/ttyUSB0" +CONFIG_ESPTOOLPY_BAUD_115200B= +CONFIG_ESPTOOLPY_BAUD_230400B= +CONFIG_ESPTOOLPY_BAUD_921600B= +CONFIG_ESPTOOLPY_BAUD_2MB=y +CONFIG_ESPTOOLPY_BAUD_OTHER= +CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 +CONFIG_ESPTOOLPY_BAUD=2000000 +CONFIG_ESPTOOLPY_COMPRESSED=y +CONFIG_FLASHMODE_QIO=y +CONFIG_FLASHMODE_QOUT= +CONFIG_FLASHMODE_DIO= +CONFIG_FLASHMODE_DOUT= +CONFIG_ESPTOOLPY_FLASHMODE="dio" +CONFIG_ESPTOOLPY_FLASHFREQ_80M=y +CONFIG_ESPTOOLPY_FLASHFREQ_40M= +CONFIG_ESPTOOLPY_FLASHFREQ_26M= +CONFIG_ESPTOOLPY_FLASHFREQ_20M= +CONFIG_ESPTOOLPY_FLASHFREQ="80m" +CONFIG_ESPTOOLPY_FLASHSIZE_1MB= +CONFIG_ESPTOOLPY_FLASHSIZE_2MB= +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_FLASHSIZE_8MB= +CONFIG_ESPTOOLPY_FLASHSIZE_16MB= +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" +CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y +CONFIG_ESPTOOLPY_BEFORE_RESET=y +CONFIG_ESPTOOLPY_BEFORE_NORESET= +CONFIG_ESPTOOLPY_BEFORE="default_reset" +CONFIG_ESPTOOLPY_AFTER_RESET=y +CONFIG_ESPTOOLPY_AFTER_NORESET= +CONFIG_ESPTOOLPY_AFTER="hard_reset" +CONFIG_MONITOR_BAUD_9600B= +CONFIG_MONITOR_BAUD_57600B= +CONFIG_MONITOR_BAUD_115200B=y +CONFIG_MONITOR_BAUD_230400B= +CONFIG_MONITOR_BAUD_921600B= +CONFIG_MONITOR_BAUD_2MB= +CONFIG_MONITOR_BAUD_OTHER= +CONFIG_MONITOR_BAUD_OTHER_VAL=115200 +CONFIG_MONITOR_BAUD=115200 + +# +# Partition Table +# +CONFIG_PARTITION_TABLE_SINGLE_APP= +CONFIG_PARTITION_TABLE_TWO_OTA= +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="esp32-awtk-partitions.csv" +CONFIG_PARTITION_TABLE_FILENAME="esp32-awtk-partitions.csv" +CONFIG_PARTITION_TABLE_OFFSET=0x8000 +CONFIG_PARTITION_TABLE_MD5=y + +# +# Compiler options +# +CONFIG_OPTIMIZATION_LEVEL_DEBUG= +CONFIG_OPTIMIZATION_LEVEL_RELEASE=y +CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y +CONFIG_OPTIMIZATION_ASSERTIONS_SILENT= +CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED= +CONFIG_CXX_EXCEPTIONS= +CONFIG_STACK_CHECK_NONE=y +CONFIG_STACK_CHECK_NORM= +CONFIG_STACK_CHECK_STRONG= +CONFIG_STACK_CHECK_ALL= +CONFIG_STACK_CHECK= +CONFIG_WARN_WRITE_STRINGS= +CONFIG_DISABLE_GCC8_WARNINGS= + +# +# Component config +# + +# +# Application Level Tracing +# +CONFIG_ESP32_APPTRACE_DEST_TRAX= +CONFIG_ESP32_APPTRACE_DEST_NONE=y +CONFIG_ESP32_APPTRACE_ENABLE= +CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y +CONFIG_AWS_IOT_SDK= + +# +# Bluetooth +# +CONFIG_BT_ENABLED= +CONFIG_BTDM_CONTROLLER_BR_EDR_SCO_DATA_PATH_EFF=0 +CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN_EFF=0 +CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_EFF=0 +CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_EFF=0 +CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE=0 +CONFIG_BT_RESERVE_DRAM=0 + +# +# Driver configurations +# + +# +# ADC configuration +# +CONFIG_ADC_FORCE_XPD_FSM= +CONFIG_ADC2_DISABLE_DAC=y + +# +# SPI configuration +# +CONFIG_SPI_MASTER_IN_IRAM= +CONFIG_SPI_MASTER_ISR_IN_IRAM=y +CONFIG_SPI_SLAVE_IN_IRAM= +CONFIG_SPI_SLAVE_ISR_IN_IRAM=y + +# +# ESP32-specific +# +CONFIG_ESP32_REV_MIN_0=y +CONFIG_ESP32_REV_MIN_1= +CONFIG_ESP32_REV_MIN_2= +CONFIG_ESP32_REV_MIN_3= +CONFIG_ESP32_REV_MIN=0 +CONFIG_ESP32_DPORT_WORKAROUND=y +CONFIG_ESP32_DEFAULT_CPU_FREQ_80= +CONFIG_ESP32_DEFAULT_CPU_FREQ_160= +CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y +CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240 +CONFIG_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +CONFIG_SPIRAM_BOOT_INIT=y +CONFIG_SPIRAM_IGNORE_NOTFOUND= +CONFIG_SPIRAM_USE_MEMMAP= +CONFIG_SPIRAM_USE_CAPS_ALLOC= +CONFIG_SPIRAM_USE_MALLOC=y +CONFIG_SPIRAM_TYPE_AUTO=y +CONFIG_SPIRAM_TYPE_ESPPSRAM32= +CONFIG_SPIRAM_TYPE_ESPPSRAM64= +CONFIG_SPIRAM_SIZE=-1 +CONFIG_SPIRAM_SPEED_40M= +CONFIG_SPIRAM_SPEED_80M=y +CONFIG_SPIRAM_MEMTEST=y +CONFIG_SPIRAM_CACHE_WORKAROUND=y +CONFIG_SPIRAM_BANKSWITCH_ENABLE=y +CONFIG_SPIRAM_BANKSWITCH_RESERVE=8 +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384 +CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST= +CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768 +CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY= +CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY= +CONFIG_SPIRAM_OCCUPY_HSPI_HOST= +CONFIG_SPIRAM_OCCUPY_VSPI_HOST=y + +# +# PSRAM clock and cs IO for ESP32-DOWD +# +CONFIG_D0WD_PSRAM_CLK_IO=17 +CONFIG_D0WD_PSRAM_CS_IO=16 + +# +# PSRAM clock and cs IO for ESP32-D2WD +# +CONFIG_D2WD_PSRAM_CLK_IO=9 +CONFIG_D2WD_PSRAM_CS_IO=10 + +# +# PSRAM clock and cs IO for ESP32-PICO +# +CONFIG_PICO_PSRAM_CS_IO=10 +CONFIG_MEMMAP_TRACEMEM= +CONFIG_MEMMAP_TRACEMEM_TWOBANKS= +CONFIG_ESP32_TRAX= +CONFIG_TRACEMEM_RESERVE_DRAM=0x0 +CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH= +CONFIG_ESP32_ENABLE_COREDUMP_TO_UART= +CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y +CONFIG_ESP32_ENABLE_COREDUMP= +CONFIG_TWO_UNIVERSAL_MAC_ADDRESS= +CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS=y +CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS=4 +CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 +CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 +CONFIG_MAIN_TASK_STACK_SIZE=3584 +CONFIG_IPC_TASK_STACK_SIZE=1024 +CONFIG_TIMER_TASK_STACK_SIZE=3584 +CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y +CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF= +CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR= +CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF= +CONFIG_NEWLIB_STDIN_LINE_ENDING_LF= +CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y +CONFIG_NEWLIB_NANO_FORMAT= +CONFIG_CONSOLE_UART_DEFAULT=y +CONFIG_CONSOLE_UART_CUSTOM= +CONFIG_CONSOLE_UART_NONE= +CONFIG_CONSOLE_UART_NUM=0 +CONFIG_CONSOLE_UART_BAUDRATE=115200 +CONFIG_ULP_COPROC_ENABLED= +CONFIG_ULP_COPROC_RESERVE_MEM=0 +CONFIG_ESP32_PANIC_PRINT_HALT= +CONFIG_ESP32_PANIC_PRINT_REBOOT= +CONFIG_ESP32_PANIC_SILENT_REBOOT= +CONFIG_ESP32_PANIC_GDBSTUB=y +CONFIG_ESP32_DEBUG_OCDAWARE=y +CONFIG_ESP32_DEBUG_STUBS_ENABLE=y +CONFIG_INT_WDT=y +CONFIG_INT_WDT_TIMEOUT_MS=300 +CONFIG_INT_WDT_CHECK_CPU1=y +CONFIG_TASK_WDT=y +CONFIG_TASK_WDT_PANIC= +CONFIG_TASK_WDT_TIMEOUT_S=5 +CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y +CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y +CONFIG_BROWNOUT_DET=y +CONFIG_BROWNOUT_DET_LVL_SEL_0=y +CONFIG_BROWNOUT_DET_LVL_SEL_1= +CONFIG_BROWNOUT_DET_LVL_SEL_2= +CONFIG_BROWNOUT_DET_LVL_SEL_3= +CONFIG_BROWNOUT_DET_LVL_SEL_4= +CONFIG_BROWNOUT_DET_LVL_SEL_5= +CONFIG_BROWNOUT_DET_LVL_SEL_6= +CONFIG_BROWNOUT_DET_LVL_SEL_7= +CONFIG_BROWNOUT_DET_LVL=0 +CONFIG_REDUCE_PHY_TX_POWER=y +CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y +CONFIG_ESP32_TIME_SYSCALL_USE_RTC= +CONFIG_ESP32_TIME_SYSCALL_USE_FRC1= +CONFIG_ESP32_TIME_SYSCALL_USE_NONE= +CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC=y +CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL= +CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_OSC= +CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_8MD256= +CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024 +CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=2000 +CONFIG_ESP32_XTAL_FREQ_40=y +CONFIG_ESP32_XTAL_FREQ_26= +CONFIG_ESP32_XTAL_FREQ_AUTO= +CONFIG_ESP32_XTAL_FREQ=40 +CONFIG_DISABLE_BASIC_ROM_CONSOLE= +CONFIG_NO_BLOBS= +CONFIG_ESP_TIMER_PROFILING= +CONFIG_COMPATIBLE_PRE_V2_1_BOOTLOADERS= +CONFIG_ESP_ERR_TO_NAME_LOOKUP=y +CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL=5 + +# +# Wi-Fi +# +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 +CONFIG_ESP32_WIFI_STATIC_TX_BUFFER=y +CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=0 +CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM=16 +CONFIG_ESP32_WIFI_CSI_ENABLED= +CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y +CONFIG_ESP32_WIFI_TX_BA_WIN=6 +CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y +CONFIG_ESP32_WIFI_RX_BA_WIN=6 +CONFIG_ESP32_WIFI_NVS_ENABLED=y +CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y +CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1= +CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 +CONFIG_ESP32_WIFI_IRAM_OPT=y +CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 + +# +# PHY +# +CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y +CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION= +CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 +CONFIG_ESP32_PHY_MAX_TX_POWER=20 + +# +# Power Management +# +CONFIG_PM_ENABLE= + +# +# ADC-Calibration +# +CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y +CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y +CONFIG_ADC_CAL_LUT_ENABLE=y + +# +# Event Loop Library +# +CONFIG_EVENT_LOOP_PROFILING= + +# +# ESP HTTP client +# +CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y + +# +# HTTP Server +# +CONFIG_HTTPD_MAX_REQ_HDR_LEN=512 +CONFIG_HTTPD_MAX_URI_LEN=512 +CONFIG_HTTPD_PURGE_BUF_LEN=32 +CONFIG_HTTPD_LOG_PURGE_DATA= + +# +# Ethernet +# +CONFIG_DMA_RX_BUF_NUM=10 +CONFIG_DMA_TX_BUF_NUM=10 +CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE=y +CONFIG_EMAC_CHECK_LINK_PERIOD_MS=2000 +CONFIG_EMAC_TASK_PRIORITY=20 +CONFIG_EMAC_TASK_STACK_SIZE=3072 + +# +# FAT Filesystem support +# +CONFIG_FATFS_CODEPAGE_DYNAMIC= +CONFIG_FATFS_CODEPAGE_437=y +CONFIG_FATFS_CODEPAGE_720= +CONFIG_FATFS_CODEPAGE_737= +CONFIG_FATFS_CODEPAGE_771= +CONFIG_FATFS_CODEPAGE_775= +CONFIG_FATFS_CODEPAGE_850= +CONFIG_FATFS_CODEPAGE_852= +CONFIG_FATFS_CODEPAGE_855= +CONFIG_FATFS_CODEPAGE_857= +CONFIG_FATFS_CODEPAGE_860= +CONFIG_FATFS_CODEPAGE_861= +CONFIG_FATFS_CODEPAGE_862= +CONFIG_FATFS_CODEPAGE_863= +CONFIG_FATFS_CODEPAGE_864= +CONFIG_FATFS_CODEPAGE_865= +CONFIG_FATFS_CODEPAGE_866= +CONFIG_FATFS_CODEPAGE_869= +CONFIG_FATFS_CODEPAGE_932= +CONFIG_FATFS_CODEPAGE_936= +CONFIG_FATFS_CODEPAGE_949= +CONFIG_FATFS_CODEPAGE_950= +CONFIG_FATFS_CODEPAGE=437 +CONFIG_FATFS_LFN_NONE=y +CONFIG_FATFS_LFN_HEAP= +CONFIG_FATFS_LFN_STACK= +CONFIG_FATFS_FS_LOCK=0 +CONFIG_FATFS_TIMEOUT_MS=10000 +CONFIG_FATFS_PER_FILE_CACHE=y + +# +# Modbus configuration +# +CONFIG_MB_QUEUE_LENGTH=20 +CONFIG_MB_SERIAL_TASK_STACK_SIZE=2048 +CONFIG_MB_SERIAL_BUF_SIZE=256 +CONFIG_MB_SERIAL_TASK_PRIO=10 +CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT= +CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT=20 +CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 +CONFIG_MB_CONTROLLER_STACK_SIZE=4096 +CONFIG_MB_EVENT_QUEUE_TIMEOUT=20 +CONFIG_MB_TIMER_PORT_ENABLED=y +CONFIG_MB_TIMER_GROUP=0 +CONFIG_MB_TIMER_INDEX=0 + +# +# FreeRTOS +# +CONFIG_FREERTOS_UNICORE= +CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF +CONFIG_FREERTOS_CORETIMER_0=y +CONFIG_FREERTOS_CORETIMER_1= +CONFIG_FREERTOS_HZ=1000 +CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y +CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE= +CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL= +CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y +CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK= +CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y +CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 +CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y +CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE= +CONFIG_FREERTOS_ASSERT_DISABLE= +CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536 +CONFIG_FREERTOS_ISR_STACKSIZE=1536 +CONFIG_FREERTOS_LEGACY_HOOKS= +CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 +CONFIG_SUPPORT_STATIC_ALLOCATION=y +CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK= +CONFIG_TIMER_TASK_PRIORITY=1 +CONFIG_TIMER_TASK_STACK_DEPTH=2048 +CONFIG_TIMER_QUEUE_LENGTH=10 +CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0 +CONFIG_FREERTOS_USE_TRACE_FACILITY= +CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS= +CONFIG_FREERTOS_DEBUG_INTERNALS= + +# +# Heap memory debugging +# +CONFIG_HEAP_POISONING_DISABLED= +CONFIG_HEAP_POISONING_LIGHT=y +CONFIG_HEAP_POISONING_COMPREHENSIVE= +CONFIG_HEAP_TRACING=y +CONFIG_HEAP_TRACING_STACK_DEPTH=2 +CONFIG_HEAP_TASK_TRACKING=y + +# +# libsodium +# +CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y + +# +# Log output +# +CONFIG_LOG_DEFAULT_LEVEL_NONE= +CONFIG_LOG_DEFAULT_LEVEL_ERROR= +CONFIG_LOG_DEFAULT_LEVEL_WARN= +CONFIG_LOG_DEFAULT_LEVEL_INFO=y +CONFIG_LOG_DEFAULT_LEVEL_DEBUG= +CONFIG_LOG_DEFAULT_LEVEL_VERBOSE= +CONFIG_LOG_DEFAULT_LEVEL=3 +CONFIG_LOG_COLORS=y + +# +# LWIP +# +CONFIG_L2_TO_L3_COPY= +CONFIG_LWIP_IRAM_OPTIMIZATION= +CONFIG_LWIP_MAX_SOCKETS=10 +CONFIG_USE_ONLY_LWIP_SELECT= +CONFIG_LWIP_SO_REUSE=y +CONFIG_LWIP_SO_REUSE_RXTOALL=y +CONFIG_LWIP_SO_RCVBUF= +CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1 +CONFIG_LWIP_IP_FRAG= +CONFIG_LWIP_IP_REASSEMBLY= +CONFIG_LWIP_STATS= +CONFIG_LWIP_ETHARP_TRUST_IP_MAC= +CONFIG_ESP_GRATUITOUS_ARP=y +CONFIG_GARP_TMR_INTERVAL=60 +CONFIG_TCPIP_RECVMBOX_SIZE=32 +CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y +CONFIG_LWIP_DHCP_RESTORE_LAST_IP= + +# +# DHCP server +# +CONFIG_LWIP_DHCPS_LEASE_UNIT=60 +CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 +CONFIG_LWIP_AUTOIP= +CONFIG_LWIP_NETIF_LOOPBACK=y +CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 + +# +# TCP +# +CONFIG_LWIP_MAX_ACTIVE_TCP=16 +CONFIG_LWIP_MAX_LISTENING_TCP=16 +CONFIG_TCP_MAXRTX=12 +CONFIG_TCP_SYNMAXRTX=6 +CONFIG_TCP_MSS=1436 +CONFIG_TCP_MSL=60000 +CONFIG_TCP_SND_BUF_DEFAULT=5744 +CONFIG_TCP_WND_DEFAULT=5744 +CONFIG_TCP_RECVMBOX_SIZE=6 +CONFIG_TCP_QUEUE_OOSEQ=y +CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES= +CONFIG_TCP_OVERSIZE_MSS=y +CONFIG_TCP_OVERSIZE_QUARTER_MSS= +CONFIG_TCP_OVERSIZE_DISABLE= + +# +# UDP +# +CONFIG_LWIP_MAX_UDP_PCBS=16 +CONFIG_UDP_RECVMBOX_SIZE=6 +CONFIG_TCPIP_TASK_STACK_SIZE=3072 +CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y +CONFIG_TCPIP_TASK_AFFINITY_CPU0= +CONFIG_TCPIP_TASK_AFFINITY_CPU1= +CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF +CONFIG_PPP_SUPPORT= + +# +# ICMP +# +CONFIG_LWIP_MULTICAST_PING= +CONFIG_LWIP_BROADCAST_PING= + +# +# LWIP RAW API +# +CONFIG_LWIP_MAX_RAW_PCBS=16 + +# +# mbedTLS +# +CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y +CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC= +CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC= +CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC= +CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=16384 +CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN= +CONFIG_MBEDTLS_DEBUG= +CONFIG_MBEDTLS_HARDWARE_AES=y +CONFIG_MBEDTLS_HARDWARE_MPI= +CONFIG_MBEDTLS_HARDWARE_SHA= +CONFIG_MBEDTLS_HAVE_TIME=y +CONFIG_MBEDTLS_HAVE_TIME_DATE= +CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y +CONFIG_MBEDTLS_TLS_SERVER_ONLY= +CONFIG_MBEDTLS_TLS_CLIENT_ONLY= +CONFIG_MBEDTLS_TLS_DISABLED= +CONFIG_MBEDTLS_TLS_SERVER=y +CONFIG_MBEDTLS_TLS_CLIENT=y +CONFIG_MBEDTLS_TLS_ENABLED=y + +# +# TLS Key Exchange Methods +# +CONFIG_MBEDTLS_PSK_MODES=y +CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y +CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK=y +CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_PSK=y +CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y +CONFIG_MBEDTLS_SSL_RENEGOTIATION=y +CONFIG_MBEDTLS_SSL_PROTO_SSL3= +CONFIG_MBEDTLS_SSL_PROTO_TLS1=y +CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y +CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y +CONFIG_MBEDTLS_SSL_PROTO_DTLS=y +CONFIG_MBEDTLS_SSL_ALPN=y +CONFIG_MBEDTLS_SSL_SESSION_TICKETS=y + +# +# Symmetric Ciphers +# +CONFIG_MBEDTLS_AES_C=y +CONFIG_MBEDTLS_CAMELLIA_C= +CONFIG_MBEDTLS_DES_C= +CONFIG_MBEDTLS_RC4_DISABLED=y +CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT= +CONFIG_MBEDTLS_RC4_ENABLED= +CONFIG_MBEDTLS_BLOWFISH_C= +CONFIG_MBEDTLS_XTEA_C= +CONFIG_MBEDTLS_CCM_C=y +CONFIG_MBEDTLS_GCM_C=y +CONFIG_MBEDTLS_RIPEMD160_C= + +# +# Certificates +# +CONFIG_MBEDTLS_PEM_PARSE_C=y +CONFIG_MBEDTLS_PEM_WRITE_C=y +CONFIG_MBEDTLS_X509_CRL_PARSE_C=y +CONFIG_MBEDTLS_X509_CSR_PARSE_C=y +CONFIG_MBEDTLS_ECP_C=y +CONFIG_MBEDTLS_ECDH_C=y +CONFIG_MBEDTLS_ECDSA_C=y +CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y +CONFIG_MBEDTLS_ECP_NIST_OPTIM=y + +# +# mDNS +# +CONFIG_MDNS_MAX_SERVICES=10 + +# +# ESP-MQTT Configurations +# +CONFIG_MQTT_PROTOCOL_311=y +CONFIG_MQTT_TRANSPORT_SSL=y +CONFIG_MQTT_TRANSPORT_WEBSOCKET=y +CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y +CONFIG_MQTT_USE_CUSTOM_CONFIG= +CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED= +CONFIG_MQTT_CUSTOM_OUTBOX= + +# +# NVS +# + +# +# OpenSSL +# +CONFIG_OPENSSL_DEBUG= +CONFIG_OPENSSL_ASSERT_DO_NOTHING=y +CONFIG_OPENSSL_ASSERT_EXIT= + +# +# PThreads +# +CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_PTHREAD_STACK_MIN=768 + +# +# SPI Flash driver +# +CONFIG_SPI_FLASH_VERIFY_WRITE= +CONFIG_SPI_FLASH_ENABLE_COUNTERS= +CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y +CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y +CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS= +CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED= +CONFIG_SPI_FLASH_YIELD_DURING_ERASE= + +# +# SPIFFS Configuration +# +CONFIG_SPIFFS_MAX_PARTITIONS=3 + +# +# SPIFFS Cache Configuration +# +CONFIG_SPIFFS_CACHE=y +CONFIG_SPIFFS_CACHE_WR=y +CONFIG_SPIFFS_CACHE_STATS= +CONFIG_SPIFFS_PAGE_CHECK=y +CONFIG_SPIFFS_GC_MAX_RUNS=10 +CONFIG_SPIFFS_GC_STATS= +CONFIG_SPIFFS_PAGE_SIZE=256 +CONFIG_SPIFFS_OBJ_NAME_LEN=32 +CONFIG_SPIFFS_USE_MAGIC=y +CONFIG_SPIFFS_USE_MAGIC_LENGTH=y +CONFIG_SPIFFS_META_LENGTH=4 +CONFIG_SPIFFS_USE_MTIME=y + +# +# Debug Configuration +# +CONFIG_SPIFFS_DBG= +CONFIG_SPIFFS_API_DBG= +CONFIG_SPIFFS_GC_DBG= +CONFIG_SPIFFS_CACHE_DBG= +CONFIG_SPIFFS_CHECK_DBG= +CONFIG_SPIFFS_TEST_VISUALISATION= + +# +# TCP/IP Adapter +# +CONFIG_IP_LOST_TIMER_INTERVAL=120 +CONFIG_TCPIP_LWIP=y + +# +# Virtual file system +# +CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y +CONFIG_SUPPORT_TERMIOS=y + +# +# Wear Levelling +# +CONFIG_WL_SECTOR_SIZE_512= +CONFIG_WL_SECTOR_SIZE_4096=y +CONFIG_WL_SECTOR_SIZE=4096