From 1c6a8267f9514ee5d02948719acab7bae4407311 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 18 Sep 2019 11:26:27 -0400 Subject: [PATCH] armcm_reset: Add a new helper file defining command_reset() Add a generic ARM Cortex-M implementation of the "reset" command. Signed-off-by: Kevin O'Connor --- src/atsamd/Makefile | 4 ++-- src/atsamd/main.c | 7 ------- src/generic/armcm_reset.c | 15 +++++++++++++++ src/lpc176x/Makefile | 2 +- src/lpc176x/main.c | 7 ------- src/stm32/Makefile | 5 +++-- src/stm32/main.c | 7 ------- 7 files changed, 21 insertions(+), 26 deletions(-) create mode 100644 src/generic/armcm_reset.c diff --git a/src/atsamd/Makefile b/src/atsamd/Makefile index 4c943cbc..d856376f 100644 --- a/src/atsamd/Makefile +++ b/src/atsamd/Makefile @@ -19,8 +19,8 @@ CFLAGS_klipper.elf += -T $(OUT)src/generic/armcm_link.ld $(OUT)klipper.elf: $(OUT)src/generic/armcm_link.ld # Add source files -src-y += atsamd/main.c atsamd/gpio.c -src-y += generic/armcm_boot.c generic/armcm_irq.c generic/crc16_ccitt.c +src-y += atsamd/main.c atsamd/gpio.c generic/crc16_ccitt.c +src-y += generic/armcm_boot.c generic/armcm_irq.c generic/armcm_reset.c src-$(CONFIG_USBSERIAL) += atsamd/usbserial.c generic/usb_cdc.c src-$(CONFIG_SERIAL) += atsamd/serial.c generic/serial_irq.c src-$(CONFIG_HAVE_GPIO_ADC) += atsamd/adc.c diff --git a/src/atsamd/main.c b/src/atsamd/main.c index 41b437cd..bc0a1c4c 100644 --- a/src/atsamd/main.c +++ b/src/atsamd/main.c @@ -10,13 +10,6 @@ DECL_CONSTANT_STR("MCU", CONFIG_MCU); -void -command_reset(uint32_t *args) -{ - NVIC_SystemReset(); -} -DECL_COMMAND_FLAGS(command_reset, HF_IN_SHUTDOWN, "reset"); - // Main entry point int main(void) diff --git a/src/generic/armcm_reset.c b/src/generic/armcm_reset.c new file mode 100644 index 00000000..19c2096d --- /dev/null +++ b/src/generic/armcm_reset.c @@ -0,0 +1,15 @@ +// Generic reset command handler for ARM Cortex-M boards +// +// Copyright (C) 2019 Kevin O'Connor +// +// This file may be distributed under the terms of the GNU GPLv3 license. + +#include "board/internal.h" // NVIC_SystemReset +#include "command.h" // DECL_COMMAND_FLAGS + +void +command_reset(uint32_t *args) +{ + NVIC_SystemReset(); +} +DECL_COMMAND_FLAGS(command_reset, HF_IN_SHUTDOWN, "reset"); diff --git a/src/lpc176x/Makefile b/src/lpc176x/Makefile index ef5b0460..275d3972 100644 --- a/src/lpc176x/Makefile +++ b/src/lpc176x/Makefile @@ -14,7 +14,7 @@ $(OUT)klipper.elf: $(OUT)src/generic/armcm_link.ld # Add source files src-y += lpc176x/main.c lpc176x/gpio.c src-y += generic/armcm_boot.c generic/armcm_irq.c generic/armcm_timer.c -src-y += generic/crc16_ccitt.c +src-y += generic/armcm_reset.c generic/crc16_ccitt.c src-y += ../lib/lpc176x/device/system_LPC17xx.c src-$(CONFIG_HAVE_GPIO_ADC) += lpc176x/adc.c src-$(CONFIG_HAVE_GPIO_I2C) += lpc176x/i2c.c diff --git a/src/lpc176x/main.c b/src/lpc176x/main.c index 62c5c207..7fddde5a 100644 --- a/src/lpc176x/main.c +++ b/src/lpc176x/main.c @@ -60,13 +60,6 @@ enable_pclock(uint32_t pclk) } } -void -command_reset(uint32_t *args) -{ - NVIC_SystemReset(); -} -DECL_COMMAND_FLAGS(command_reset, HF_IN_SHUTDOWN, "reset"); - // Main entry point int main(void) diff --git a/src/stm32/Makefile b/src/stm32/Makefile index 710c9f83..4e8e2f4a 100644 --- a/src/stm32/Makefile +++ b/src/stm32/Makefile @@ -20,8 +20,9 @@ CFLAGS_klipper.elf += -T $(OUT)src/generic/armcm_link.ld $(OUT)klipper.elf: $(OUT)src/generic/armcm_link.ld # Add source files -src-y += stm32/main.c stm32/watchdog.c stm32/gpio.c generic/armcm_boot.c -src-y += generic/crc16_ccitt.c generic/armcm_irq.c generic/armcm_timer.c +src-y += stm32/main.c stm32/watchdog.c stm32/gpio.c generic/crc16_ccitt.c +src-y += generic/armcm_boot.c generic/armcm_irq.c generic/armcm_timer.c +src-y += generic/armcm_reset.c src-$(CONFIG_MACH_STM32F1) += ../lib/stm32f1/system_stm32f1xx.c src-$(CONFIG_MACH_STM32F1) += stm32/stm32f1.c src-$(CONFIG_MACH_STM32F4) += ../lib/stm32f4/system_stm32f4xx.c diff --git a/src/stm32/main.c b/src/stm32/main.c index 6d9290fd..56da9718 100644 --- a/src/stm32/main.c +++ b/src/stm32/main.c @@ -11,13 +11,6 @@ DECL_CONSTANT_STR("MCU", CONFIG_MCU); -void -command_reset(uint32_t *args) -{ - NVIC_SystemReset(); -} -DECL_COMMAND_FLAGS(command_reset, HF_IN_SHUTDOWN, "reset"); - // Main entry point int main(void)