From 3a3a3530324204432d68a41f195593f4af54a1c4 Mon Sep 17 00:00:00 2001 From: Repeerc Date: Thu, 18 Aug 2022 02:17:57 +0800 Subject: [PATCH] fix "Interrupt requested" & Add Basic Power Consumption Adjustment --- OSLoader/HAL/Hardware/stmp_clkctrl.c | 8 ++++---- OSLoader/HAL/mtd_up.c | 6 +++++- OSLoader/start.c | 4 ++-- System/kcasporing_gl.c | 7 +++++++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/OSLoader/HAL/Hardware/stmp_clkctrl.c b/OSLoader/HAL/Hardware/stmp_clkctrl.c index ada6dc46..87dad0fa 100644 --- a/OSLoader/HAL/Hardware/stmp_clkctrl.c +++ b/OSLoader/HAL/Hardware/stmp_clkctrl.c @@ -28,8 +28,8 @@ void setHCLKDivider(uint32_t div) void setCPUDivider(uint32_t div) { - uint32_t val = BF_RD(CLKCTRL_CPU, DIV_CPU); - INFO("CPU old Div:%lu\n", val); + //uint32_t val = BF_RD(CLKCTRL_CPU, DIV_CPU); + //INFO("CPU old Div:%lu\n", val); if (!div) { return; } @@ -38,7 +38,7 @@ void setCPUDivider(uint32_t div) //while (BF_RD(CLKCTRL_CPU, BUSY_REF_CPU)); BF_CLRV(CLKCTRL_CPU, DIV_CPU, BF_RD(CLKCTRL_CPU, DIV_CPU) ^ div); - INFO("CPU new Div:%d\n", BF_RD(CLKCTRL_CPU, DIV_CPU)); + //INFO("CPU new Div:%d\n", BF_RD(CLKCTRL_CPU, DIV_CPU)); } void setCPUFracDivider(uint32_t div) { @@ -87,7 +87,7 @@ void portCLKCtrlInit(void) { setCPU_HFreqDomain(true); setHCLKDivider(2); - setCPUFracDivider(24); + setCPUFracDivider(27); enableUSBClock(true); } diff --git a/OSLoader/HAL/mtd_up.c b/OSLoader/HAL/mtd_up.c index b0558722..67674844 100644 --- a/OSLoader/HAL/mtd_up.c +++ b/OSLoader/HAL/mtd_up.c @@ -1,6 +1,8 @@ #include "SystemConfig.h" #include "FreeRTOS.h" +#include "board_up.h" + #include "mtd_up.h" #include "nand.h" #include "../debug.h" @@ -65,6 +67,8 @@ void MTD_Task() if(xQueueReceive(MTD_Operates_Queue, &curOpa, portMAX_DELAY) == pdTRUE) { + setCPUDivider(12); + retry_cnt = 5; retry: @@ -242,7 +246,7 @@ void MTD_Task() } //xEventGroupSetBits(MTDLockEventGroup , (1 << curOpa.BLock)); - + setCPUDivider(2); } } diff --git a/OSLoader/start.c b/OSLoader/start.c index 9aeb4942..b49c6ee0 100644 --- a/OSLoader/start.c +++ b/OSLoader/start.c @@ -650,8 +650,8 @@ static bool transScr = false; void vMainThread(void *pvParameters) { // vTaskDelay(pdMS_TO_TICKS(100)); - setHCLKDivider(2); - setCPUDivider(1); + setCPUDivider(2); + setHCLKDivider(1); // portLRADCEnable(1, 7); // MTD_EraseAllBLock(); diff --git a/System/kcasporing_gl.c b/System/kcasporing_gl.c index 3bda7fc4..f5b5b92f 100644 --- a/System/kcasporing_gl.c +++ b/System/kcasporing_gl.c @@ -357,6 +357,9 @@ int vGL_Initialize() { return 0; } +extern volatile bool interrupted ; +extern volatile bool ctrl_c ; + bool vGL_chkEsc() { uint32_t keys, key, kpress; @@ -365,6 +368,8 @@ bool vGL_chkEsc() kpress = keys >> 16; if((key == KEY_ON) && kpress) { + ctrl_c = true; + interrupted = true; return true; } return false; @@ -382,6 +387,8 @@ bool vGL_getkey(int *keyid) key = keys & 0xFFFF; kpress = keys >> 16; + + }while((last_key == key) && (last_press == kpress));