解决界面显示异常的问题,解决触屏失效的问题

This commit is contained in:
2025-06-30 21:36:12 +08:00
parent 82092d05ab
commit 645f5aab72
4 changed files with 53 additions and 64 deletions

View File

@@ -23,6 +23,7 @@
***/ ***/
#include "touch_iic.h" #include "touch_iic.h"
#include "rthw.h"
/***************************************************************************************** /*****************************************************************************************
@@ -74,11 +75,7 @@ void Touch_IIC_GPIO_Config (void)
void Touch_IIC_Delay(u32 a) void Touch_IIC_Delay(u32 a)
{ {
int i; rt_hw_us_delay(a);
while (a --)
{
for (i = 0; i < 10; i++);
}
} }
/***************************************************************************************** /*****************************************************************************************

View File

@@ -104,21 +104,21 @@
#include "ff.h" #include "ff.h"
#include "ftfile.h" #include "ftfile.h"
#define FT_FILE FILE // #define FT_FILE FILE
#define ft_fclose fclose // #define ft_fclose fclose
#define ft_fopen fopen // #define ft_fopen fopen
#define ft_fread fread // #define ft_fread fread
#define ft_fseek fseek // #define ft_fseek fseek
#define ft_ftell ftell // #define ft_ftell ftell
#define ft_sprintf sprintf // #define ft_sprintf sprintf
//#define FT_FILE ft_file_struct #define FT_FILE ft_file_struct
//#define ft_fclose ft_if_fclose #define ft_fclose ft_if_fclose
//#define ft_fopen ft_if_fopen #define ft_fopen ft_if_fopen
//#define ft_fread ft_if_fread #define ft_fread ft_if_fread
//#define ft_fseek ft_if_fseek #define ft_fseek ft_if_fseek
//#define ft_ftell ft_if_ftell #define ft_ftell ft_if_ftell
//#define ft_sprintf sprintf #define ft_sprintf sprintf

View File

@@ -401,8 +401,9 @@ int WIN_GetWordData(u8 size,u8 type,unsigned char *buff, int word, int buff_size
if (word>0x80) if (word>0x80)
{ {
gbk[0]=(word>>8)&0xff; gbk[0]=(word>>16)&0xff;
gbk[1]=word&0xff; gbk[1]=(word>>8)&0xff;
gbk[2]=word&0xff;
} }
else else
{ {

View File

@@ -26,69 +26,64 @@ void SystemClock_Config(void);
#define _SYSTICK_CALIB (*(rt_uint32_t *)(_SCB_BASE + 0xC)) #define _SYSTICK_CALIB (*(rt_uint32_t *)(_SCB_BASE + 0xC))
#define _SYSTICK_PRI (*(rt_uint8_t *)(0xE000ED23UL)) #define _SYSTICK_PRI (*(rt_uint8_t *)(0xE000ED23UL))
// Updates the variable SystemCoreClock and must be called // Updates the variable SystemCoreClock and must be called
// whenever the core clock is changed during program execution. // whenever the core clock is changed during program execution.
extern void SystemCoreClockUpdate(void); extern void SystemCoreClockUpdate(void);
// Holds the system core clock, which is the system clock // Holds the system core clock, which is the system clock
// frequency supplied to the SysTick timer and the processor // frequency supplied to the SysTick timer and the processor
// core clock. // core clock.
extern uint32_t SystemCoreClock; extern uint32_t SystemCoreClock;
static uint32_t _SysTick_Config(rt_uint32_t ticks) static uint32_t _SysTick_Config(rt_uint32_t ticks)
{ {
if ((ticks - 1) > 0xFFFFFF) if ((ticks - 1) > 0xFFFFFF)
{ {
return 1; return 1;
} }
_SYSTICK_LOAD = ticks - 1; _SYSTICK_LOAD = ticks - 1;
_SYSTICK_PRI = 0xFF; _SYSTICK_PRI = 0xFF;
_SYSTICK_VAL = 0; _SYSTICK_VAL = 0;
_SYSTICK_CTRL = 0x07; _SYSTICK_CTRL = 0x07;
return 0; return 0;
} }
// us<75><73><EFBFBD><EFBFBD>ʱ
void rt_hw_us_delay(rt_uint32_t us) void rt_hw_us_delay(rt_uint32_t us)
{ {
u32 ticks; u32 ticks;
u32 told,tnow,tcnt=0; u32 told,tnow,tcnt=0;
u32 reload=SysTick->LOAD; //LOAD<41><44>ֵ u32 reload=SysTick->LOAD;
ticks=us; //<2F><>Ҫ<EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD> ticks=us;
rt_enter_critical(); //<2F><>ֹOS<4F><53><EFBFBD>ȣ<EFBFBD><C8A3><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD>us<75><73>ʱ rt_enter_critical();
told=SysTick->VAL; //<2F>ս<EFBFBD><D5BD><EFBFBD>ʱ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ֵ told=SysTick->VAL;
while(1) while(1)
{ {
tnow=SysTick->VAL; tnow=SysTick->VAL;
if(tnow!=told) if(tnow!=told)
{ {
if(tnow<told)tcnt+=told-tnow; //<2F><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>һ<EFBFBD><D2BB>SYSTICK<43><4B>һ<EFBFBD><D2BB><EFBFBD>ݼ<EFBFBD><DDBC>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><CDBF><EFBFBD><EFBFBD><EFBFBD>. if(tnow<told)tcnt+=told-tnow;
else tcnt+=reload-tnow+told; else tcnt+=reload-tnow+told;
told=tnow; told=tnow;
if(tcnt>=ticks)break; //ʱ<><EFBFBD><E4B3AC>/<2F><><EFBFBD><EFBFBD>Ҫ<EFBFBD>ӳٵ<D3B3>ʱ<EFBFBD><CAB1>,<2C><><EFBFBD>˳<EFBFBD>. if(tcnt>=ticks)break;
} }
}; };
rt_exit_critical(); //<2F>ָ<EFBFBD>OS<4F><53><EFBFBD><EFBFBD> rt_exit_critical();
} }
#endif #endif
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP) #if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
#define RT_HEAP_SIZE 5*1024//1536
//static uint32_t rt_heap[RT_HEAP_SIZE]; // heap default size: 6K(1536 * 4)
RT_WEAK void *rt_heap_begin_get(void) RT_WEAK void *rt_heap_begin_get(void)
{ {
// return rt_heap; return (void *)0x10000000;
return (void *)0x10000000;
} }
RT_WEAK void *rt_heap_end_get(void) RT_WEAK void *rt_heap_end_get(void)
{ {
// return rt_heap + RT_HEAP_SIZE; return (void *)(0x10000000+64*1024/4);
return (void *)(0x10000000+64*1024/4);
} }
#endif #endif
@@ -96,13 +91,9 @@ RT_WEAK void *rt_heap_end_get(void)
void mpu_init(void) void mpu_init(void)
{ {
//ѡ<><D1A1>0<EFBFBD><30>region
MPU->RNR=0; MPU->RNR=0;
//ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD>ַ
MPU->RBAR=0x00000000; MPU->RBAR=0x00000000;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>
MPU->RASR=((0x3)<<MPU_RASR_AP_Pos)|((31)<<MPU_RASR_SIZE_Pos)|(0x5<<16)|1; MPU->RASR=((0x3)<<MPU_RASR_AP_Pos)|((31)<<MPU_RASR_SIZE_Pos)|(0x5<<16)|1;
//<2F><><EFBFBD><EFBFBD>MPU
MPU->CTRL=1; MPU->CTRL=1;
} }
@@ -112,20 +103,20 @@ const libc_device_file *g_usart;
* This function will initial your board. * This function will initial your board.
*/ */
void rt_hw_board_init() void rt_hw_board_init()
{ {
// NVIC_SetVectorTable(NVIC_VectTab_FLASH,(u32)128*1024); // NVIC_SetVectorTable(NVIC_VectTab_FLASH,(u32)128*1024);
NVIC_SetVectorTable(NVIC_VectTab_FLASH,(u32)0); NVIC_SetVectorTable(NVIC_VectTab_FLASH,(u32)0);
_SysTick_Config (SystemCoreClock/1000); _SysTick_Config (SystemCoreClock/1000);
NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1);
LED_Init(); // LED初始<E5889D>? LED_Init();
Usart_Config(); // 串口初始<E5889D>? Usart_Config();
SDRAM_Init(); // sdram要先于emwin之前初始<E5889D>? SDRAM_Init();
sFLASH_Init(); sFLASH_Init();
mymem_init(); mymem_init();
rt_system_heap_init(rt_heap_begin_get(),rt_heap_end_get()); rt_system_heap_init(rt_heap_begin_get(),rt_heap_end_get());
// irq_vector_init(); // irq_vector_init();
mpu_init(); mpu_init();
Touch_Init(); // 触摸屏初始化 Touch_Init();
USART3_Init(); USART3_Init();
RANDOM_Init(); RANDOM_Init();
// USBD_InitAsVcp (); // USBD_InitAsVcp ();