diff --git a/.settings/.rtmenus b/.settings/.rtmenus index c611ad9..876b936 100644 Binary files a/.settings/.rtmenus and b/.settings/.rtmenus differ diff --git a/applications/PLC_link.c b/applications/PLC_link.c index 03544dc..22732b6 100644 --- a/applications/PLC_link.c +++ b/applications/PLC_link.c @@ -29,6 +29,8 @@ static const mb_backend_param_t mb_bkd_prm = { }; extern unsigned char sys_time[6]; +uint8_t r_buffer[16],w_buffer[16]; +uint16_t r_regsD[128],w_regsD[128]; static void mb_plc_read_regs(mb_inst_t *hinst) { @@ -39,7 +41,7 @@ static void mb_plc_read_regs(mb_inst_t *hinst) } //输入m0000->rtu2000 - uint8_t r_buffer[(DI_TABLE_SIZE + 7) / 8]; + //uint8_t r_buffer[(DI_TABLE_SIZE + 7) / 8]; //读取 Modbus bits int mrx = mb_read_bits(hinst, 2000, DI_TABLE_SIZE, r_buffer); if (mrx > 0) @@ -53,7 +55,7 @@ static void mb_plc_read_regs(mb_inst_t *hinst) } // 输出 m0256 -> RTU 2256 - uint8_t w_buffer[(DO_TABLE_SIZE + 7) / 8]; // 关键:初始化为0 + //uint8_t w_buffer[(DO_TABLE_SIZE + 7) / 8]; // 关键:初始化为0 // 打包 do_table 到 bit_buffer for (int i = 0; i < DO_TABLE_SIZE; i++) { const int byte_idx = i / 8; @@ -73,7 +75,7 @@ static void mb_plc_read_regs(mb_inst_t *hinst) } //输入寄存器d0->6000 - u16 r_regsD[AI_TABLE_SIZE]; + //u16 r_regsD[AI_TABLE_SIZE]; // 读 Modbus int mrd = mb_read_regs(hinst, 6000, AI_TABLE_SIZE, r_regsD); if (mrd > 0) @@ -87,7 +89,7 @@ static void mb_plc_read_regs(mb_inst_t *hinst) } //输出寄存器d100->6100 - u16 w_regsD [AO_TABLE_SIZE]; + //u16 w_regsD [AO_TABLE_SIZE]; for (int i = 0; i < AO_TABLE_SIZE; i++) { w_regsD [i] = ao_table[i].current_Value; diff --git a/applications/lvgl/lv_port_mem.c b/applications/lvgl/lv_port_mem.c new file mode 100644 index 0000000..feefefc --- /dev/null +++ b/applications/lvgl/lv_port_mem.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2026-01-24 Administrator the first version + */ +#include +#include "lvgl.h" +#include + +extern struct rt_memheap sdram_heap; // + +void *lv_custom_mem_alloc(size_t size) +{ + return rt_memheap_alloc(&sdram_heap, size); +} + +void lv_custom_mem_free(void *ptr) +{ + if (ptr) rt_memheap_free(ptr); +} + +void *lv_custom_mem_realloc(void *ptr, size_t new_size) +{ + return rt_memheap_realloc(&sdram_heap, ptr, new_size); +} diff --git a/applications/lvgl/lv_port_mem.h b/applications/lvgl/lv_port_mem.h new file mode 100644 index 0000000..1d19b6f --- /dev/null +++ b/applications/lvgl/lv_port_mem.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2026-01-24 Administrator the first version + */ +#ifndef APPLICATIONS_LVGL_LV_PORT_MEM_H_ +#define APPLICATIONS_LVGL_LV_PORT_MEM_H_ + +void *lv_custom_mem_alloc(size_t size); +void lv_custom_mem_free(void *ptr); +void *lv_custom_mem_realloc(void *ptr, size_t new_size); + +#endif /* APPLICATIONS_LVGL_LV_PORT_MEM_H_ */ diff --git a/applications/sql/DB_SQLite.c b/applications/sql/DB_SQLite.c index 9423d8b..896c164 100644 --- a/applications/sql/DB_SQLite.c +++ b/applications/sql/DB_SQLite.c @@ -190,8 +190,6 @@ void db_sqlite_init_full(void) if (g_db) { sqlite3_close(g_db); - //限制缓存大小 (100KB) - sqlite3_exec(g_db, "PRAGMA cache_size = 50;", 0, 0, 0); g_db = RT_NULL; } return; // @@ -286,7 +284,6 @@ static void db_sqlite(void *parameter) { if (first_wait_done) { first_wait_done = RT_FALSE; - sqlite3_exec(g_db, "PRAGMA shrink_memory;", 0, 0, 0); sqlite3_close(g_db); g_db=RT_NULL; op_link=0; diff --git a/applications/wdt.c b/applications/wdt.c index 7ef05f3..45c3963 100644 --- a/applications/wdt.c +++ b/applications/wdt.c @@ -35,6 +35,9 @@ static void idle_hook(void) static int wdt_sample() { + + rt_thread_mdelay(5000); + rt_err_t ret = RT_EOK; rt_uint32_t timeout = 1; /* 溢出时间,单位:秒 */ char device_name[RT_NAME_MAX]; diff --git a/packages/LVGL-v8.3.10/env_support/cmsis-pack/lv_conf_cmsis.h b/packages/LVGL-v8.3.10/env_support/cmsis-pack/lv_conf_cmsis.h index 3c20533..d08e4b1 100644 --- a/packages/LVGL-v8.3.10/env_support/cmsis-pack/lv_conf_cmsis.h +++ b/packages/LVGL-v8.3.10/env_support/cmsis-pack/lv_conf_cmsis.h @@ -39,7 +39,7 @@ *=========================*/ /*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/ -#define LV_MEM_CUSTOM 0 +#define LV_MEM_CUSTOM 1 #if LV_MEM_CUSTOM == 0 /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/ #define LV_MEM_SIZE (64U * 1024U) /*[bytes]*/ @@ -54,9 +54,9 @@ #else /*LV_MEM_CUSTOM*/ #define LV_MEM_CUSTOM_INCLUDE /*Header for the dynamic memory function*/ - #define LV_MEM_CUSTOM_ALLOC malloc - #define LV_MEM_CUSTOM_FREE free - #define LV_MEM_CUSTOM_REALLOC realloc + #define LV_MEM_CUSTOM_ALLOC rt_memheap_alloc(&sdram_heap) + #define LV_MEM_CUSTOM_FREE rt_memheap_free() + #define LV_MEM_CUSTOM_REALLOC rt_memheap_realloc(&sdram_heap) #endif /*LV_MEM_CUSTOM*/ /*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms. diff --git a/packages/LVGL-v8.3.10/env_support/rt-thread/lv_rt_thread_conf.h b/packages/LVGL-v8.3.10/env_support/rt-thread/lv_rt_thread_conf.h index c1458be..a7191fb 100644 --- a/packages/LVGL-v8.3.10/env_support/rt-thread/lv_rt_thread_conf.h +++ b/packages/LVGL-v8.3.10/env_support/rt-thread/lv_rt_thread_conf.h @@ -23,9 +23,15 @@ #ifdef RT_USING_HEAP # define LV_MEM_CUSTOM 1 # define LV_MEM_CUSTOM_INCLUDE LV_RTTHREAD_INCLUDE -# define LV_MEM_CUSTOM_ALLOC rt_malloc -# define LV_MEM_CUSTOM_FREE rt_free -# define LV_MEM_CUSTOM_REALLOC rt_realloc +//# define LV_MEM_CUSTOM_ALLOC rt_malloc +//# define LV_MEM_CUSTOM_FREE rt_free +//# define LV_MEM_CUSTOM_REALLOC rt_realloc + +extern struct rt_memheap sdram_heap; +#define LV_MEM_CUSTOM_ALLOC(x) rt_memheap_alloc(&sdram_heap,(rt_size_t)x) +#define LV_MEM_CUSTOM_FREE rt_memheap_free +#define LV_MEM_CUSTOM_REALLOC(x,y) rt_memheap_realloc(&sdram_heap,(x),(rt_size_t)(y)) + #endif /*==================== diff --git a/packages/LVGL-v8.3.10/lv_conf_template.h b/packages/LVGL-v8.3.10/lv_conf_template.h index 6653513..3e5ebaf 100644 --- a/packages/LVGL-v8.3.10/lv_conf_template.h +++ b/packages/LVGL-v8.3.10/lv_conf_template.h @@ -61,9 +61,9 @@ #else /*LV_MEM_CUSTOM*/ #define LV_MEM_CUSTOM_INCLUDE /*Header for the dynamic memory function*/ - #define LV_MEM_CUSTOM_ALLOC malloc - #define LV_MEM_CUSTOM_FREE free - #define LV_MEM_CUSTOM_REALLOC realloc + #define LV_MEM_CUSTOM_ALLOC rt_memheap_alloc(&sdram_heap) + #define LV_MEM_CUSTOM_FREE rt_memheap_free() + #define LV_MEM_CUSTOM_REALLOC rt_memheap_realloc(&sdram_heap) #endif /*LV_MEM_CUSTOM*/ /*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms. diff --git a/packages/cJSON-v1.7.17/cJSON.c b/packages/cJSON-v1.7.17/cJSON.c index fca9ddb..656cbc9 100644 --- a/packages/cJSON-v1.7.17/cJSON.c +++ b/packages/cJSON-v1.7.17/cJSON.c @@ -176,9 +176,29 @@ static void * CJSON_CDECL internal_realloc(void *pointer, size_t size) return realloc(pointer, size); } #elif defined(__RTTHREAD__) -#define internal_malloc rt_malloc -#define internal_free rt_free -#define internal_realloc rt_realloc +//#define internal_malloc rt_malloc +//#define internal_free rt_free +//#define internal_realloc rt_realloc + +extern struct rt_memheap sdram_heap; + +void *cjson_malloc(size_t size) +{ + return rt_memheap_alloc(&sdram_heap, size); +} +void cjson_free(void *ptr) +{ + if (ptr) + rt_memheap_free(ptr); +} +void* cjson_realloc(void *ptr, size_t new_size) { + return rt_memheap_realloc(&sdram_heap, ptr, new_size); +} + +#define internal_malloc cjson_malloc +#define internal_free cjson_free +#define internal_realloc cjson_realloc + #else #define internal_malloc malloc #define internal_free free diff --git a/packages/sqlite/sqlite3.c b/packages/sqlite/sqlite3.c index bd6d5b8..9e97d2c 100644 --- a/packages/sqlite/sqlite3.c +++ b/packages/sqlite/sqlite3.c @@ -20727,13 +20727,13 @@ static malloc_zone_t* _sqliteZone_; ** Use standard C library malloc and free on non-Apple systems. ** Also used by rt-thread systems if SQLITE_WITHOUT_ZONEMALLOC is defined. */ -extern struct rt_memheap sram_DTCMRAM; -#define SQLITE_MALLOC(x) rt_memheap_alloc(&sram_DTCMRAM,(rt_size_t)x) +/*extern struct rt_memheap sdram_heap; +#define SQLITE_MALLOC(x) rt_memheap_alloc(&sdram_heap,(rt_size_t)x) #define SQLITE_FREE(x) rt_memheap_free(x) -#define SQLITE_REALLOC(x,y) rt_memheap_realloc(&sram_DTCMRAM,(x),(rt_size_t)(y)) -//#define SQLITE_MALLOC(x) rt_malloc((rt_size_t)x) -//#define SQLITE_FREE(x) rt_free(x) -//#define SQLITE_REALLOC(x,y) rt_realloc((x),(rt_size_t)(y)) +#define SQLITE_REALLOC(x,y) rt_memheap_realloc(&sdram_heap,(x),(rt_size_t)(y))*/ +#define SQLITE_MALLOC(x) rt_malloc((rt_size_t)x) +#define SQLITE_FREE(x) rt_free(x) +#define SQLITE_REALLOC(x,y) rt_realloc((x),(rt_size_t)(y)) #if (!defined(SQLITE_WITHOUT_MSIZE)) \ && (defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE))