diff --git a/module-bsp/board/rt1051/common/clock_config.cpp b/module-bsp/board/rt1051/common/clock_config.cpp index 8649f27d0..8ad96f219 100644 --- a/module-bsp/board/rt1051/common/clock_config.cpp +++ b/module-bsp/board/rt1051/common/clock_config.cpp @@ -773,7 +773,7 @@ void clkPLL1setup(uint8_t enabled) { } } -__attribute__((section( ".intfoo" ))) + void clkPLL2setup(uint8_t enabled) { const clock_sys_pll_config_t sysPllConfig_BOARD_BootClockRUN = { @@ -940,7 +940,7 @@ void clkPLL7setup(uint8_t enabled) { } } -__attribute__((section( ".intfoo" ))) + uint32_t GetPerphSourceClock(PerphClock_t clock) { switch (clock) { @@ -962,7 +962,7 @@ uint32_t GetPerphSourceClock(PerphClock_t clock) { } } -__attribute__((section( ".intfoo" ))) + void PrintSystemClocks() { @@ -1259,7 +1259,7 @@ void LPM_EnterLowPowerRun(){ } -__attribute__((section( ".sdram" ))) uint8_t sdramtable[1024]; +/* #include "fsl_semc.h" #include "pin_mux.h" @@ -1269,41 +1269,66 @@ status_t BOARD_InitSEMC(void) semc_sdram_config_t sdramconfig; uint32_t clockFrq = CLOCK_GetFreq(kCLOCK_SemcClk); - /* Initializes the MAC configure structure to zero. */ + */ +/* Initializes the MAC configure structure to zero. *//* + memset(&config, 0, sizeof(semc_config_t)); memset(&sdramconfig, 0, sizeof(semc_sdram_config_t)); - /* Initialize SEMC. */ + */ +/* Initialize SEMC. *//* + SEMC_GetDefaultConfig(&config); - config.dqsMode = kSEMC_Loopbackdqspad; /* For more accurate timing. */ + config.dqsMode = kSEMC_Loopbackdqspad; */ +/* For more accurate timing. *//* + SEMC_Init(SEMC, &config); - /* Configure SDRAM. */ + */ +/* Configure SDRAM. *//* + sdramconfig.csxPinMux = kSEMC_MUXCSX0; sdramconfig.address = 0x80000000; - sdramconfig.memsize_kbytes = 16 * 1024; /* 16MB = 32*1024*1KBytes*/ + sdramconfig.memsize_kbytes = 16 * 1024; */ +/* 16MB = 32*1024*1KBytes*//* + sdramconfig.portSize = kSEMC_PortSize16Bit; sdramconfig.burstLen = kSEMC_Sdram_BurstLen8; sdramconfig.columnAddrBitNum = kSEMC_SdramColunm_9bit; sdramconfig.casLatency = kSEMC_LatencyThree; - sdramconfig.tPrecharge2Act_Ns = 18; /* Trp 18ns */ - sdramconfig.tAct2ReadWrite_Ns = 18; /* Trcd 18ns */ - sdramconfig.tRefreshRecovery_Ns = 67; /* Use the maximum of the (Trfc , Txsr). */ - sdramconfig.tWriteRecovery_Ns = 12; /* 12ns */ + sdramconfig.tPrecharge2Act_Ns = 18; */ +/* Trp 18ns *//* + + sdramconfig.tAct2ReadWrite_Ns = 18; */ +/* Trcd 18ns *//* + + sdramconfig.tRefreshRecovery_Ns = 67; */ +/* Use the maximum of the (Trfc , Txsr). *//* + + sdramconfig.tWriteRecovery_Ns = 12; */ +/* 12ns *//* + sdramconfig.tCkeOff_Ns = - 42; /* The minimum cycle of SDRAM CLK off state. CKE is off in self refresh at a minimum period tRAS.*/ - sdramconfig.tAct2Prechage_Ns = 42; /* Tras 42ns */ + 42; */ +/* The minimum cycle of SDRAM CLK off state. CKE is off in self refresh at a minimum period tRAS.*//* + + sdramconfig.tAct2Prechage_Ns = 42; */ +/* Tras 42ns *//* + sdramconfig.tSelfRefRecovery_Ns = 67; sdramconfig.tRefresh2Refresh_Ns = 60; sdramconfig.tAct2Act_Ns = 60; sdramconfig.tPrescalePeriod_Ns = 160 * (1000000000 / clockFrq); - sdramconfig.refreshPeriod_nsPerRow = 64 * 1000000 / 8192; /* 64ms/8192 */ + sdramconfig.refreshPeriod_nsPerRow = 64 * 1000000 / 8192; */ +/* 64ms/8192 *//* + sdramconfig.refreshUrgThreshold = sdramconfig.refreshPeriod_nsPerRow; sdramconfig.refreshBurstLen = 1; return SEMC_ConfigureSDRAM(SEMC, kSEMC_SDRAM_CS0, &sdramconfig, clockFrq); } +*/ + -__attribute__((section( ".intfoo" ))) void LPM_EnterFullSpeed(void) { /* CCM Mode */ @@ -1438,8 +1463,6 @@ void LPM_EnterLowPowerIdle(void) DisableRegularLDO(); BandgapOff(); - PrintSystemClocks(); - CLOCK_SetMux(kCLOCK_SemcMux,0); clkPLL2setup(CLK_DISABLE); PrintSystemClocks(); diff --git a/module-bsp/board/rt1051/common/fsl_drivers/fsl_clock.c b/module-bsp/board/rt1051/common/fsl_drivers/fsl_clock.c index bce321a7a..d581be7d5 100644 --- a/module-bsp/board/rt1051/common/fsl_drivers/fsl_clock.c +++ b/module-bsp/board/rt1051/common/fsl_drivers/fsl_clock.c @@ -350,7 +350,7 @@ void CLOCK_DeinitArmPll(void) CCM_ANALOG->PLL_ARM = CCM_ANALOG_PLL_ARM_POWERDOWN_MASK; } -__attribute__((section( ".intfoo" ))) + void CLOCK_InitSysPll(const clock_sys_pll_config_t *config) { /* Bypass PLL first */ @@ -369,7 +369,7 @@ void CLOCK_InitSysPll(const clock_sys_pll_config_t *config) CCM_ANALOG->PLL_SYS &= ~CCM_ANALOG_PLL_SYS_BYPASS_MASK; } -__attribute__((section( ".intfoo" ))) + void CLOCK_DeinitSysPll(void) { CCM_ANALOG->PLL_SYS = CCM_ANALOG_PLL_SYS_POWERDOWN_MASK; diff --git a/module-bsp/board/rt1051/common/fsl_drivers/fsl_clock.h b/module-bsp/board/rt1051/common/fsl_drivers/fsl_clock.h index 22a13fbaa..6dbfe75d6 100644 --- a/module-bsp/board/rt1051/common/fsl_drivers/fsl_clock.h +++ b/module-bsp/board/rt1051/common/fsl_drivers/fsl_clock.h @@ -966,7 +966,7 @@ static inline void CLOCK_SetDiv(clock_div_t divider, uint32_t value) * * @param divider Which div node to get, see \ref clock_div_t. */ -__attribute__((section( ".intfoo" ))) + static inline uint32_t CLOCK_GetDiv(clock_div_t divider) { return ((CCM_TUPLE_REG(CCM, divider) & CCM_TUPLE_MASK(divider)) >> CCM_TUPLE_SHIFT(divider)); diff --git a/module-sys/PowerManager/PowerManager.cpp b/module-sys/PowerManager/PowerManager.cpp index 12e0e681a..9cb98cefd 100644 --- a/module-sys/PowerManager/PowerManager.cpp +++ b/module-sys/PowerManager/PowerManager.cpp @@ -16,28 +16,27 @@ namespace sys{ const char *powerManagerServiceName = "PwrMgrService"; - __attribute__((section( ".intfoo" ))) + PowerManager::PowerManager() : Service(powerManagerServiceName){ - lowPower = bsp::LowPowerMode::Create().value_or(nullptr); + lowPowerControl = bsp::LowPowerMode::Create().value_or(nullptr); + + busChannels = {BusChannels::PowerManagerRequests}; } - __attribute__((section( ".intfoo" ))) + PowerManager::~PowerManager() { } - __attribute__((section( ".intfoo" ))) + void PowerManager::TickHandler(uint32_t id) { } - __attribute__((section( ".intfoo" ))) Message_t PowerManager::DataReceivedHandler(sys::DataMessage *msg, sys::ResponseMessage *resp) { } - __attribute__((section( ".intfoo" ))) ReturnCodes PowerManager::InitHandler() { - lowPower->Switch(bsp::LowPowerMode::Mode::FullSpeed); + lowPowerControl->Switch(bsp::LowPowerMode::Mode::FullSpeed); } - __attribute__((section( ".intfoo" ))) ReturnCodes PowerManager::DeinitHandler() { } diff --git a/module-sys/PowerManager/PowerManager.hpp b/module-sys/PowerManager/PowerManager.hpp index 7f49ce559..8e3068b28 100644 --- a/module-sys/PowerManager/PowerManager.hpp +++ b/module-sys/PowerManager/PowerManager.hpp @@ -12,6 +12,7 @@ #ifndef PUREPHONE_POWERMANAGER_HPP #define PUREPHONE_POWERMANAGER_HPP +#include #include "Service/Mailbox.hpp" #include "Service/Bus.hpp" #include "Service/Service.hpp" @@ -27,6 +28,9 @@ namespace sys { PowerManager(); ~PowerManager(); + void RegisterInterruptHandler(std::function handler); + + private: @@ -40,7 +44,9 @@ namespace sys { ReturnCodes SwitchPowerModeHandler(const ServicePowerMode mode) override final{return ReturnCodes::Success;} - std::unique_ptr lowPower; + std::unique_ptr lowPowerControl; + + bsp::LowPowerMode::Mode currentPowerMode = bsp::LowPowerMode::Mode ::FullSpeed; }; diff --git a/module-sys/Service/Common.hpp b/module-sys/Service/Common.hpp index 3ee813737..5c766f0d1 100644 --- a/module-sys/Service/Common.hpp +++ b/module-sys/Service/Common.hpp @@ -15,7 +15,8 @@ namespace sys enum class BusChannels { System, - SystemManagerRequests + SystemManagerRequests, + PowerManagerRequests #ifndef MODULE_CORE_CUSTOM_BUS #else diff --git a/module-sys/SystemManager/SystemManager.cpp b/module-sys/SystemManager/SystemManager.cpp index 5411382a9..f90294210 100644 --- a/module-sys/SystemManager/SystemManager.cpp +++ b/module-sys/SystemManager/SystemManager.cpp @@ -41,7 +41,7 @@ namespace sys { if (userInit) { userInit(); } - + while (enableRunLoop) { auto msg = mailbox.pop(); @@ -175,7 +175,6 @@ namespace sys { ReturnCodes SystemManager::InitHandler() { - CreateService(std::make_shared(), this); isReady = true; return ReturnCodes::Success; } diff --git a/source/main.cpp b/source/main.cpp index 25a18bbc5..3141030ac 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -123,9 +123,6 @@ int main() { bsp::BoardInit(); - LPM_EnterLowPowerIdle(); - LPM_EnterFullSpeed(); - #if 1 auto sysmgr = std::make_shared(5000); @@ -135,8 +132,9 @@ int main() { bool ret = false; - //ret = sys::SystemManager::CreateService(std::make_shared("EventManager"), sysmgr.get()); - //ret |= sys::SystemManager::CreateService(std::make_shared(), sysmgr.get()); + ret |= sys::SystemManager::CreateService(std::make_shared(), sysmgr.get()); + ret |= sys::SystemManager::CreateService(std::make_shared("EventManager"), sysmgr.get()); + ret |= sys::SystemManager::CreateService(std::make_shared(), sysmgr.get()); ret |= sys::SystemManager::CreateService(std::make_shared("Blinky"), sysmgr.get());