Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ jobs:
run: docker run -d --name flex_container -v "$(pwd)":/external -p 1234:1234/tcp -p 1235:1235/tcp ghcr.io/philips-software/amp-postmaster-flex:v0.2.0 ${{ vars.ENV_POSTMASTER_IP }} /external/integration_test.tester.bin
- run: docker logs flex_container
- run: while [[ "$(docker inspect flex_container | python -c 'import json,sys;print(json.load(sys.stdin)[0]["State"]["Health"]["Status"])')" != "healthy" ]] ; do docker inspect flex_container | python -c 'import json,sys;print(json.load(sys.stdin)[0]["State"]["Health"]["Status"])'; sleep 1; done
timeout-minutes: 2
timeout-minutes: 5
- run: docker inspect flex_container
- run: tar -zxvf hal_st-*-Linux.tar.gz
- run: mkdir install
Expand Down
3 changes: 3 additions & 0 deletions examples/helloworld/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "hal/interfaces/Gpio.hpp"
#include "hal_st/cortex/FaultTracer.hpp"
#include "hal_st/instantiations/NucleoUi.hpp"
#include "hal_st/instantiations/ResetReason.hpp"
#include "hal_st/instantiations/StmEventInfrastructure.hpp"
#include "hal_st/stm32fxxx/DmaStm.hpp"
#include "hal_st/stm32fxxx/UartStmDma.hpp"
Expand Down Expand Up @@ -82,6 +83,8 @@ int main()

services::SetGlobalTracerInstance(tracerWithDateTime);

services::GlobalTracer().Trace() << "Reset reason: " << hal::GetResetReason();

static infra::TimerRepeating timerRepeating{ std::chrono::seconds{ 1 }, []
{
services::GlobalTracer().Trace() << "Hello World !";
Expand Down
2 changes: 2 additions & 0 deletions hal_st/instantiations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ target_link_libraries(hal_st.instantiations PUBLIC
hal_st.synchronous_stm32fxxx
infra.event
infra.timer
infra.util
services.tracer
)

Expand All @@ -25,4 +26,5 @@ target_sources(hal_st.instantiations PRIVATE
StmTracerInfrastructure.hpp
TracingResetStm.cpp
TracingResetStm.hpp
ResetReason.hpp
)
38 changes: 38 additions & 0 deletions hal_st/instantiations/ResetReason.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef HAL_ST_INSTANTIATIONS_RESETREASON_HPP
#define HAL_ST_INSTANTIATIONS_RESETREASON_HPP

#include "infra/util/BoundedString.hpp"
#include DEVICE_HEADER

namespace hal
{
// Note: This function clears the reset flags after reading them
infra::BoundedConstString GetResetReason()
{
const char* resetReason;

if (__HAL_RCC_GET_FLAG(RCC_FLAG_LPWRRST))
resetReason = "LowPower";
#if defined(RCC_FLAG_PORRST)
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST))
resetReason = "PowerOn";
#endif
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_WWDGRST))
resetReason = "Window WatchDog";
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST))
resetReason = "Independent WatchDog";
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST))
resetReason = "Software";
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST))
resetReason = "Reset Pin";
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_BORRST))
resetReason = "BrownOut(BOR)";
else
resetReason = "Unknown";

__HAL_RCC_CLEAR_RESET_FLAGS();
return resetReason;
}
}

#endif // HAL_ST_INSTANTIATIONS_RESETREASON_HPP
Loading