Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: low power event dispatcher #156

Merged
merged 3 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions hal_st/instantiations/StmEventInfrastructure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,15 @@ namespace main_
{
eventDispatcher.Run();
}

LowPowerStmEventInfrastructure::LowPowerStmEventInfrastructure(infra::Duration tickDuration)
: eventDispatcher(lowPowerStrategy)
, gpio(hal::pinoutTableDefaultStm, hal::analogTableDefaultStm)
, systemTick(tickDuration)
{}

void LowPowerStmEventInfrastructure::Run()
{
eventDispatcher.Run();
}
}
17 changes: 16 additions & 1 deletion hal_st/instantiations/StmEventInfrastructure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#define HAL_ST_STM_EVENT_INFRASTRUCTURE_HPP

#include "hal_st/stm32fxxx/GpioStm.hpp"
#include "hal_st/stm32fxxx/LowPowerStrategyStm.hpp"
#include "hal_st/stm32fxxx/SystemTickTimerService.hpp"
#include "infra/event/EventDispatcherWithWeakPtr.hpp"

namespace main_
{
struct StmEventInfrastructure
{
StmEventInfrastructure(infra::Duration tickDuration = std::chrono::milliseconds(1));
explicit StmEventInfrastructure(infra::Duration tickDuration = std::chrono::milliseconds(1));

void Run();

Expand All @@ -19,6 +20,20 @@ namespace main_

hal::SystemTickTimerService systemTick;
};

struct LowPowerStmEventInfrastructure
{
explicit LowPowerStmEventInfrastructure(infra::Duration tickDuration = std::chrono::milliseconds(1));

void Run();

hal::InterruptTable::WithStorage<128> interruptTable;
hal::LowPowerStrategyStm lowPowerStrategy;
infra::LowPowerEventDispatcher::WithSize<50> eventDispatcher;
hal::GpioStm gpio;

hal::SystemTickTimerService systemTick;
};
}

#endif
2 changes: 2 additions & 0 deletions hal_st/stm32fxxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ target_sources(hal_st.stm32fxxx PRIVATE
QuadSpiStm.hpp
$<$<NOT:$<STREQUAL:${TARGET_MCU_FAMILY},stm32g0xx>>:QuadSpiStmDma.cpp>
$<$<NOT:$<STREQUAL:${TARGET_MCU_FAMILY},stm32g0xx>>:QuadSpiStmDma.hpp>
LowPowerStrategyStm.cpp
LowPowerStrategyStm.hpp
RandomDataGeneratorStm.cpp
RandomDataGeneratorStm.hpp
ResetStm.cpp
Expand Down
17 changes: 17 additions & 0 deletions hal_st/stm32fxxx/LowPowerStrategyStm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "hal_st/stm32fxxx/LowPowerStrategyStm.hpp"
#include DEVICE_HEADER

namespace hal
{
void LowPowerStrategyStm::RequestExecution()
{
__DSB();
__SEV();
}

void LowPowerStrategyStm::Idle(const infra::EventDispatcherWorker& eventDispatcher)
{
__DSB();
__WFE();
}
}
19 changes: 19 additions & 0 deletions hal_st/stm32fxxx/LowPowerStrategyStm.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef HAL_LOW_POWER_STRATEGY_STM_HPP
#define HAL_LOW_POWER_STRATEGY_STM_HPP

#include "infra/event/LowPowerEventDispatcher.hpp"

namespace hal
{
class LowPowerStrategyStm
: public infra::LowPowerStrategy
{
public:
LowPowerStrategyStm() = default;

void RequestExecution() override;
void Idle(const infra::EventDispatcherWorker& eventDispatcher) override;
};
}

#endif