From 6ed5e5289532e88768107ca3dfd343cd12c91bf6 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Wed, 13 Mar 2013 22:33:40 +0100 Subject: ucoolib/arch: add arch_reset --- ucoolib/arch/arch.hh | 4 ++++ ucoolib/arch/arch.host.cc | 7 +++++++ ucoolib/arch/arch.stm32.cc | 7 +++++++ 3 files changed, 18 insertions(+) (limited to 'ucoolib') diff --git a/ucoolib/arch/arch.hh b/ucoolib/arch/arch.hh index 92aa115..ecf123f 100644 --- a/ucoolib/arch/arch.hh +++ b/ucoolib/arch/arch.hh @@ -30,6 +30,10 @@ namespace ucoo { void arch_init (int argc, const char **argv); +/// Reset. +void +arch_reset (); + #ifdef TARGET_host /// Retrieve program arguments. diff --git a/ucoolib/arch/arch.host.cc b/ucoolib/arch/arch.host.cc index ed8c503..06bb2bd 100644 --- a/ucoolib/arch/arch.host.cc +++ b/ucoolib/arch/arch.host.cc @@ -41,6 +41,13 @@ arch_init (int argc, const char **argv) arch_stored_argv = argv; } +void +arch_reset () +{ + // Not supported. + halt (); +} + void arch_get_args (int &argc, const char **&argv) { diff --git a/ucoolib/arch/arch.stm32.cc b/ucoolib/arch/arch.stm32.cc index 23c772a..869b1d9 100644 --- a/ucoolib/arch/arch.stm32.cc +++ b/ucoolib/arch/arch.stm32.cc @@ -25,6 +25,7 @@ #include "ucoolib/common.hh" #include +#include namespace ucoo { @@ -34,6 +35,12 @@ arch_init (int argc, const char **argv) rcc_clock_setup_hse_3v3 (&hse_8mhz_3v3[CLOCK_3V3_120MHZ]); } +void +arch_reset () +{ + SCB_AIRCR = SCB_AIRCR_VECTKEY | SCB_AIRCR_SYSRESETREQ; +} + void halt () { -- cgit v1.2.3