From cbb0247f26b50cfd125f6870ff9b7e68230b5c47 Mon Sep 17 00:00:00 2001 From: Francois Berder <18538310+francois-berder@users.noreply.github.com> Date: Fri, 10 Jan 2020 18:04:40 +0000 Subject: [PATCH] cpu: mips_pic32_common: Implement pm_reboot Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com> --- cpu/mips_pic32_common/periph/pm.c | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 cpu/mips_pic32_common/periph/pm.c diff --git a/cpu/mips_pic32_common/periph/pm.c b/cpu/mips_pic32_common/periph/pm.c new file mode 100644 index 0000000000..8ce6af3ca5 --- /dev/null +++ b/cpu/mips_pic32_common/periph/pm.c @@ -0,0 +1,38 @@ +/* + * Copyright 2020 Francois Berder + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup cpu_mips_pic32_common + * @ingroup drivers_periph_pm + * @{ + * + * @file + * @brief common periph/pm functions + * + * @author Francois Berder + * + * @} + */ + +#include "periph/pm.h" + +void pm_reboot(void) +{ + /* Unlock OSCCON */ + SYSKEY = 0x00000000; + SYSKEY = 0xAA996655; + SYSKEY = 0x556699AA; + + /* Set SWRST bit to arm reset */ + RSWRSTSET = 1; + + /* Read RSWRST register to trigger reset */ + RSWRST; + + while(1); +}