diff --git a/testhal/STM32/STM32F37x/SPI/.cproject b/testhal/STM32/STM32F37x/SPI/.cproject
deleted file mode 100644
index 853f1a50e..000000000
--- a/testhal/STM32/STM32F37x/SPI/.cproject
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/testhal/STM32/STM32F37x/SPI/.project b/testhal/STM32/STM32F37x/SPI/.project
deleted file mode 100644
index b3ceb5b95..000000000
--- a/testhal/STM32/STM32F37x/SPI/.project
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
- STM32F37x-SPI
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- board
- 2
- CHIBIOS/os/hal/boards/ST_STM32373C_EVAL
-
-
- os
- 2
- CHIBIOS/os
-
-
-
diff --git a/testhal/STM32/STM32F37x/SPI/main.c b/testhal/STM32/STM32F37x/SPI/main.c
deleted file mode 100644
index fb9ff76ed..000000000
--- a/testhal/STM32/STM32F37x/SPI/main.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include "ch.h"
-#include "hal.h"
-
-/*
- * Maximum speed SPI configuration (18MHz, CPHA=0, CPOL=0, MSb first).
- */
-static const SPIConfig hs_spicfg = {
- .circular = false,
- .slave = false,
- .data_cb = NULL,
- .error_cb = NULL,
- .ssport = GPIOB,
- .sspad = 10U,
- .cr1 = 0U,
- .cr2 = SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0
-};
-
-/*
- * Low speed SPI configuration (140.625kHz, CPHA=0, CPOL=0, MSb first).
- */
-static const SPIConfig ls_spicfg = {
- .circular = false,
- .slave = false,
- .data_cb = NULL,
- .error_cb = NULL,
- .ssport = GPIOB,
- .sspad = 10U,
- .cr1 = SPI_CR1_BR_2 | SPI_CR1_BR_1,
- .cr2 = SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0
-};
-
-/*
- * SPI TX and RX buffers.
- */
-static uint8_t txbuf[512];
-static uint8_t rxbuf[512];
-
-/*
- * SPI bus contender 1.
- */
-static THD_WORKING_AREA(spi_thread_1_wa, 256);
-static THD_FUNCTION(spi_thread_1, p) {
-
- (void)p;
-
- chRegSetThreadName("SPI thread 1");
- while (true) {
- spiAcquireBus(&SPID2); /* Acquire ownership of the bus. */
- palClearPad(GPIOC, GPIOC_LED2); /* LED ON. */
- spiStart(&SPID2, &hs_spicfg); /* Setup transfer parameters. */
- spiSelect(&SPID2); /* Slave Select assertion. */
- spiExchange(&SPID2, 512,
- txbuf, rxbuf); /* Atomic transfer operations. */
- spiUnselect(&SPID2); /* Slave Select de-assertion. */
- spiReleaseBus(&SPID2); /* Ownership release. */
- }
-}
-
-/*
- * SPI bus contender 2.
- */
-static THD_WORKING_AREA(spi_thread_2_wa, 256);
-static THD_FUNCTION(spi_thread_2, p) {
-
- (void)p;
-
- chRegSetThreadName("SPI thread 2");
- while (true) {
- spiAcquireBus(&SPID2); /* Acquire ownership of the bus. */
- palSetPad(GPIOC, GPIOC_LED2); /* LED OFF. */
- spiStart(&SPID2, &ls_spicfg); /* Setup transfer parameters. */
- spiSelect(&SPID2); /* Slave Select assertion. */
- spiExchange(&SPID2, 512,
- txbuf, rxbuf); /* Atomic transfer operations. */
- spiUnselect(&SPID2); /* Slave Select de-assertion. */
- spiReleaseBus(&SPID2); /* Ownership release. */
- }
-}
-
-/*
- * This is a periodic thread that does absolutely nothing except flashing
- * a LED.
- */
-static THD_WORKING_AREA(blinker_wa, 128);
-static THD_FUNCTION(blinker, arg) {
-
- (void)arg;
-
- chRegSetThreadName("blinker");
- while (true) {
- palSetPad(GPIOC, GPIOC_LED1);
- chThdSleepMilliseconds(500);
- palClearPad(GPIOC, GPIOC_LED1);
- chThdSleepMilliseconds(500);
- }
-}
-
-/*
- * Application entry point.
- */
-int main(void) {
- unsigned i;
-
- /*
- * System initializations.
- * - HAL initialization, this also initializes the configured device drivers
- * and performs the board-specific initializations.
- * - Kernel initialization, the main() function becomes a thread and the
- * RTOS is active.
- */
- halInit();
- chSysInit();
-
- /*
- * SPI2 I/O pins setup.
- */
- palSetPadMode(GPIOB, 14, PAL_MODE_ALTERNATE(5) |
- PAL_STM32_OSPEED_HIGHEST); /* New MISO. */
- palSetPadMode(GPIOB, 15, PAL_MODE_ALTERNATE(5) |
- PAL_STM32_OSPEED_HIGHEST); /* New MOSI. */
-
- /*
- * Prepare transmit pattern.
- */
- for (i = 0; i < sizeof(txbuf); i++)
- txbuf[i] = (uint8_t)i;
-
- /*
- * Starting the transmitter and receiver threads.
- */
- chThdCreateStatic(spi_thread_1_wa, sizeof(spi_thread_1_wa),
- NORMALPRIO + 1, spi_thread_1, NULL);
- chThdCreateStatic(spi_thread_2_wa, sizeof(spi_thread_2_wa),
- NORMALPRIO + 1, spi_thread_2, NULL);
-
- /*
- * Starting the blinker thread.
- */
- chThdCreateStatic(blinker_wa, sizeof(blinker_wa),
- NORMALPRIO-1, blinker, NULL);
-
- /*
- * Normal main() thread activity, in this demo it does nothing.
- */
- while (true) {
- chThdSleepMilliseconds(500);
- }
- return 0;
-}
diff --git a/testhal/STM32/STM32F37x/SPI/readme.txt b/testhal/STM32/STM32F37x/SPI/readme.txt
deleted file mode 100644
index 12c8d0050..000000000
--- a/testhal/STM32/STM32F37x/SPI/readme.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-*****************************************************************************
-** ChibiOS/HAL - SPI driver demo for STM32F37x. **
-*****************************************************************************
-
-** TARGET **
-
-The demo runs on an STMicroelectronics STM32373C-EVAL board.
-
-** The Demo **
-
-The application demonstrates the use of the STM32F37x SPI driver.
-
-** Board Setup **
-
-- Connect PB14 and PB15 together for SPI loop-back.
-
-** Build Procedure **
-
-The demo has been tested using the free Codesourcery GCC-based toolchain
-and YAGARTO.
-Just modify the TRGT line in the makefile in order to use different GCC ports.
-
-** Notes **
-
-Some files used by the demo are not part of ChibiOS/RT but are copyright of
-ST Microelectronics and are licensed under a different license.
-Also note that not all the files present in the ST library are distributed
-with ChibiOS/RT, you can find the whole library on the ST web site:
-
- http://www.st.com
diff --git a/testhal/STM32/multi/SPI/.cproject b/testhal/STM32/multi/SPI/.cproject
index 2282448d3..8a4d8531b 100644
--- a/testhal/STM32/multi/SPI/.cproject
+++ b/testhal/STM32/multi/SPI/.cproject
@@ -341,12 +341,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testhal/STM32/multi/SPI/cfg/stm32f091_nucleo64/portab.c b/testhal/STM32/multi/SPI/cfg/stm32f091_nucleo64/portab.c
index cb6495f0b..283393068 100644
--- a/testhal/STM32/multi/SPI/cfg/stm32f091_nucleo64/portab.c
+++ b/testhal/STM32/multi/SPI/cfg/stm32f091_nucleo64/portab.c
@@ -101,14 +101,14 @@ void portab_setup(void) {
* SPI2 I/O pins setup.
*/
palSetPadMode(GPIOB, 13, PAL_MODE_ALTERNATE(0) |
- PAL_STM32_OSPEED_HIGHEST); /* New SCK. */
+ PAL_STM32_OSPEED_HIGHEST); /* SPI2 SCK. */
palSetPadMode(GPIOB, 14, PAL_MODE_ALTERNATE(0) |
- PAL_STM32_OSPEED_HIGHEST); /* New MISO. */
+ PAL_STM32_OSPEED_HIGHEST); /* SPI2 MISO. */
palSetPadMode(GPIOB, 15, PAL_MODE_ALTERNATE(0) |
- PAL_STM32_OSPEED_HIGHEST); /* New MOSI. */
+ PAL_STM32_OSPEED_HIGHEST); /* SPI2 MOSI. */
palSetPad(GPIOB, 12);
palSetPadMode(GPIOB, 12, PAL_MODE_OUTPUT_PUSHPULL |
- PAL_STM32_OSPEED_HIGHEST); /* New CS. */
+ PAL_STM32_OSPEED_HIGHEST); /* SPI2 CS. */
}
/** @} */
diff --git a/testhal/STM32/STM32F37x/SPI/chconf.h b/testhal/STM32/multi/SPI/cfg/stm32f373vc_eval/chconf.h
similarity index 100%
rename from testhal/STM32/STM32F37x/SPI/chconf.h
rename to testhal/STM32/multi/SPI/cfg/stm32f373vc_eval/chconf.h
diff --git a/testhal/STM32/STM32F37x/SPI/halconf.h b/testhal/STM32/multi/SPI/cfg/stm32f373vc_eval/halconf.h
similarity index 100%
rename from testhal/STM32/STM32F37x/SPI/halconf.h
rename to testhal/STM32/multi/SPI/cfg/stm32f373vc_eval/halconf.h
diff --git a/testhal/STM32/STM32F37x/SPI/mcuconf.h b/testhal/STM32/multi/SPI/cfg/stm32f373vc_eval/mcuconf.h
similarity index 100%
rename from testhal/STM32/STM32F37x/SPI/mcuconf.h
rename to testhal/STM32/multi/SPI/cfg/stm32f373vc_eval/mcuconf.h
diff --git a/testhal/STM32/multi/SPI/cfg/stm32f373vc_eval/portab.c b/testhal/STM32/multi/SPI/cfg/stm32f373vc_eval/portab.c
new file mode 100644
index 000000000..a3b1bd8a9
--- /dev/null
+++ b/testhal/STM32/multi/SPI/cfg/stm32f373vc_eval/portab.c
@@ -0,0 +1,113 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file portab.c
+ * @brief Application portability module code.
+ *
+ * @addtogroup application_portability
+ * @{
+ */
+
+#include "hal.h"
+#include "portab.h"
+
+/*===========================================================================*/
+/* Module local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+void spi_circular_cb(SPIDriver *spip);
+void spi_error_cb(SPIDriver *spip);
+
+/*
+ * Circular SPI configuration (18MHz, CPHA=0, CPOL=0, MSb first).
+ */
+const SPIConfig c_spicfg = {
+ .circular = true,
+ .slave = false,
+ .data_cb = spi_circular_cb,
+ .error_cb = spi_error_cb,
+ .ssport = GPIOB,
+ .sspad = 10U,
+ .cr1 = SPI_CR1_BR_0,
+ .cr2 = SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0
+};
+
+/*
+ * Maximum speed SPI configuration (18MHz, CPHA=0, CPOL=0, MSb first).
+ */
+const SPIConfig hs_spicfg = {
+ .circular = false,
+ .slave = false,
+ .data_cb = NULL,
+ .error_cb = spi_error_cb,
+ .ssport = GPIOB,
+ .sspad = 10U,
+ .cr1 = SPI_CR1_BR_0,
+ .cr2 = SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0
+};
+
+/*
+ * Low speed SPI configuration (562.5kHz, CPHA=0, CPOL=0, MSb first).
+ */
+const SPIConfig ls_spicfg = {
+ .circular = false,
+ .slave = false,
+ .data_cb = NULL,
+ .error_cb = spi_error_cb,
+ .ssport = GPIOB,
+ .sspad = 10U,
+ .cr1 = SPI_CR1_BR_2 | SPI_CR1_BR_1,
+ .cr2 = SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0
+};
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
+void portab_setup(void) {
+
+ /*
+ * SPI2 I/O pins setup.
+ */
+ palSetPadMode(GPIOB, 13, PAL_MODE_ALTERNATE(5) |
+ PAL_STM32_OSPEED_HIGHEST); /* SPI2 SCK. */
+ palSetPadMode(GPIOB, 14, PAL_MODE_ALTERNATE(5) |
+ PAL_STM32_OSPEED_HIGHEST); /* SPI2 MISO. */
+ palSetPadMode(GPIOB, 15, PAL_MODE_ALTERNATE(5) |
+ PAL_STM32_OSPEED_HIGHEST); /* SPI2 MOSI. */
+ palSetPadMode(GPIOB, 10, PAL_MODE_OUTPUT_PUSHPULL |
+ PAL_STM32_OSPEED_HIGHEST); /* SPI2 CS. */
+ palSetPad(GPIOB, 10);
+}
+
+/** @} */
diff --git a/testhal/STM32/multi/SPI/cfg/stm32f373vc_eval/portab.h b/testhal/STM32/multi/SPI/cfg/stm32f373vc_eval/portab.h
new file mode 100644
index 000000000..356eaea04
--- /dev/null
+++ b/testhal/STM32/multi/SPI/cfg/stm32f373vc_eval/portab.h
@@ -0,0 +1,80 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file portab.h
+ * @brief Application portability macros and structures.
+ *
+ * @addtogroup application_portability
+ * @{
+ */
+
+#ifndef PORTAB_H
+#define PORTAB_H
+
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+#define PORTAB_LINE_LED1 LINE_LED1
+#define PORTAB_LINE_LED2 LINE_LED2
+#define PORTAB_LED_OFF PAL_LOW
+#define PORTAB_LED_ON PAL_HIGH
+
+#define PORTAB_LINE_BUTTON LINE_WKUP_BUTTON
+#define PORTAB_BUTTON_PRESSED PAL_HIGH
+
+#define PORTAB_SPI1 SPID1
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+extern const SPIConfig c_spicfg;
+extern const SPIConfig hs_spicfg;
+extern const SPIConfig ls_spicfg;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void portab_setup(void);
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
+
+#endif /* PORTAB_H */
+
+/** @} */
diff --git a/testhal/STM32/STM32F37x/SPI/Makefile b/testhal/STM32/multi/SPI/make/stm32f373vc_eval.make
similarity index 62%
rename from testhal/STM32/STM32F37x/SPI/Makefile
rename to testhal/STM32/multi/SPI/make/stm32f373vc_eval.make
index 48c5a3804..b155ab0bd 100644
--- a/testhal/STM32/STM32F37x/SPI/Makefile
+++ b/testhal/STM32/multi/SPI/make/stm32f373vc_eval.make
@@ -1,214 +1,190 @@
-##############################################################################
-# Build global options
-# NOTE: Can be overridden externally.
-#
-
-# Compiler options here.
-ifeq ($(USE_OPT),)
- USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
-endif
-
-# C specific options here (added to USE_OPT).
-ifeq ($(USE_COPT),)
- USE_COPT =
-endif
-
-# C++ specific options here (added to USE_OPT).
-ifeq ($(USE_CPPOPT),)
- USE_CPPOPT = -fno-rtti
-endif
-
-# Enable this if you want the linker to remove unused code and data
-ifeq ($(USE_LINK_GC),)
- USE_LINK_GC = yes
-endif
-
-# Linker extra options here.
-ifeq ($(USE_LDOPT),)
- USE_LDOPT =
-endif
-
-# Enable this if you want link time optimizations (LTO)
-ifeq ($(USE_LTO),)
- USE_LTO = yes
-endif
-
-# If enabled, this option allows to compile the application in THUMB mode.
-ifeq ($(USE_THUMB),)
- USE_THUMB = yes
-endif
-
-# Enable this if you want to see the full log while compiling.
-ifeq ($(USE_VERBOSE_COMPILE),)
- USE_VERBOSE_COMPILE = no
-endif
-
-# If enabled, this option makes the build process faster by not compiling
-# modules not used in the current configuration.
-ifeq ($(USE_SMART_BUILD),)
- USE_SMART_BUILD = yes
-endif
-
-#
-# Build global options
-##############################################################################
-
-##############################################################################
-# Architecture or project specific options
-#
-
-# Stack size to be allocated to the Cortex-M process stack. This stack is
-# the stack used by the main() thread.
-ifeq ($(USE_PROCESS_STACKSIZE),)
- USE_PROCESS_STACKSIZE = 0x400
-endif
-
-# Stack size to the allocated to the Cortex-M main/exceptions stack. This
-# stack is used for processing interrupts and exceptions.
-ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
- USE_EXCEPTIONS_STACKSIZE = 0x400
-endif
-
-# Enables the use of FPU (no, softfp, hard).
-ifeq ($(USE_FPU),)
- USE_FPU = no
-endif
-
-#
-# Architecture or project specific options
-##############################################################################
-
-##############################################################################
-# Project, sources and paths
-#
-
-# Define project name here
-PROJECT = ch
-
-# Imported source files and paths
-CHIBIOS = ../../../..
-
-# Licensing files.
-include $(CHIBIOS)/os/license/license.mk
-# Startup files.
-include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f3xx.mk
-# HAL-OSAL files (optional).
-include $(CHIBIOS)/os/hal/hal.mk
-include $(CHIBIOS)/os/hal/ports/STM32/STM32F37x/platform.mk
-include $(CHIBIOS)/os/hal/boards/ST_STM32373C_EVAL/board.mk
-include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk
-# RTOS files (optional).
-include $(CHIBIOS)/os/rt/rt.mk
-include $(CHIBIOS)/os/common/ports/ARMv7-M/compilers/GCC/mk/port.mk
-# Other files (optional).
-#include $(CHIBIOS)/os/test/test.mk
-#include $(CHIBIOS)/test/rt/rt_test.mk
-#include $(CHIBIOS)/test/oslib/oslib_test.mk
-
-# Define linker script file here
-LDSCRIPT= $(STARTUPLD)/STM32F373xC.ld
-
-# C sources that can be compiled in ARM or THUMB mode depending on the global
-# setting.
-CSRC = $(ALLCSRC) \
- $(TESTSRC) \
- main.c
-
-# C++ sources that can be compiled in ARM or THUMB mode depending on the global
-# setting.
-CPPSRC = $(ALLCPPSRC)
-
-# C sources to be compiled in ARM mode regardless of the global setting.
-# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
-# option that results in lower performance and larger code size.
-ACSRC =
-
-# C++ sources to be compiled in ARM mode regardless of the global setting.
-# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
-# option that results in lower performance and larger code size.
-ACPPSRC =
-
-# C sources to be compiled in THUMB mode regardless of the global setting.
-# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
-# option that results in lower performance and larger code size.
-TCSRC =
-
-# C sources to be compiled in THUMB mode regardless of the global setting.
-# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
-# option that results in lower performance and larger code size.
-TCPPSRC =
-
-# List ASM source files here
-ASMSRC = $(ALLASMSRC)
-ASMXSRC = $(ALLXASMSRC)
-
-INCDIR = $(ALLINC) $(TESTINC)
-
-#
-# Project, sources and paths
-##############################################################################
-
-##############################################################################
-# Compiler settings
-#
-
-MCU = cortex-m4
-
-#TRGT = arm-elf-
-TRGT = arm-none-eabi-
-CC = $(TRGT)gcc
-CPPC = $(TRGT)g++
-# Enable loading with g++ only if you need C++ runtime support.
-# NOTE: You can use C++ even without C++ support if you are careful. C++
-# runtime support makes code size explode.
-LD = $(TRGT)gcc
-#LD = $(TRGT)g++
-CP = $(TRGT)objcopy
-AS = $(TRGT)gcc -x assembler-with-cpp
-AR = $(TRGT)ar
-OD = $(TRGT)objdump
-SZ = $(TRGT)size
-HEX = $(CP) -O ihex
-BIN = $(CP) -O binary
-
-# ARM-specific options here
-AOPT =
-
-# THUMB-specific options here
-TOPT = -mthumb -DTHUMB
-
-# Define C warning options here
-CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes
-
-# Define C++ warning options here
-CPPWARN = -Wall -Wextra -Wundef
-
-#
-# Compiler settings
-##############################################################################
-
-##############################################################################
-# Start of user section
-#
-
-# List all user C define here, like -D_DEBUG=1
-UDEFS =
-
-# Define ASM defines here
-UADEFS =
-
-# List all user directories here
-UINCDIR =
-
-# List the user directory to look for the libraries here
-ULIBDIR =
-
-# List all user libraries here
-ULIBS =
-
-#
-# End of user defines
-##############################################################################
-
-RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk
-include $(RULESPATH)/rules.mk
+##############################################################################
+# Build global options
+# NOTE: Can be overridden externally.
+#
+
+# Compiler options here.
+ifeq ($(USE_OPT),)
+ USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
+endif
+
+# C specific options here (added to USE_OPT).
+ifeq ($(USE_COPT),)
+ USE_COPT =
+endif
+
+# C++ specific options here (added to USE_OPT).
+ifeq ($(USE_CPPOPT),)
+ USE_CPPOPT = -fno-rtti
+endif
+
+# Enable this if you want the linker to remove unused code and data.
+ifeq ($(USE_LINK_GC),)
+ USE_LINK_GC = yes
+endif
+
+# Linker extra options here.
+ifeq ($(USE_LDOPT),)
+ USE_LDOPT =
+endif
+
+# Enable this if you want link time optimizations (LTO).
+ifeq ($(USE_LTO),)
+ USE_LTO = yes
+endif
+
+# Enable this if you want to see the full log while compiling.
+ifeq ($(USE_VERBOSE_COMPILE),)
+ USE_VERBOSE_COMPILE = no
+endif
+
+# If enabled, this option makes the build process faster by not compiling
+# modules not used in the current configuration.
+ifeq ($(USE_SMART_BUILD),)
+ USE_SMART_BUILD = yes
+endif
+
+#
+# Build global options
+##############################################################################
+
+##############################################################################
+# Architecture or project specific options
+#
+
+# Stack size to be allocated to the Cortex-M process stack. This stack is
+# the stack used by the main() thread.
+ifeq ($(USE_PROCESS_STACKSIZE),)
+ USE_PROCESS_STACKSIZE = 0x400
+endif
+
+# Stack size to the allocated to the Cortex-M main/exceptions stack. This
+# stack is used for processing interrupts and exceptions.
+ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
+ USE_EXCEPTIONS_STACKSIZE = 0x400
+endif
+
+# Enables the use of FPU (no, softfp, hard).
+ifeq ($(USE_FPU),)
+ USE_FPU = no
+endif
+
+# FPU-related options.
+ifeq ($(USE_FPU_OPT),)
+ USE_FPU_OPT = -mfloat-abi=$(USE_FPU) -mfpu=fpv4-sp-d16
+endif
+
+#
+# Architecture or project specific options
+##############################################################################
+
+##############################################################################
+# Project, target, sources and paths
+#
+
+# Define project name here
+PROJECT = ch
+
+# Target settings.
+MCU = cortex-m4
+
+# Imported source files and paths.
+CHIBIOS := ../../../..
+CONFDIR := ./cfg/stm32f373vc_eval
+BUILDDIR := ./build/stm32f373vc_eval
+DEPDIR := ./.dep/stm32f373vc_eval
+
+# Licensing files.
+include $(CHIBIOS)/os/license/license.mk
+# Startup files.
+include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f3xx.mk
+# HAL-OSAL files (optional).
+include $(CHIBIOS)/os/hal/hal.mk
+include $(CHIBIOS)/os/hal/ports/STM32/STM32F37x/platform.mk
+include $(CHIBIOS)/os/hal/boards/ST_STM32373C_EVAL/board.mk
+include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk
+# RTOS files (optional).
+include $(CHIBIOS)/os/rt/rt.mk
+include $(CHIBIOS)/os/common/ports/ARMv7-M/compilers/GCC/mk/port.mk
+# Auto-build files in ./source recursively.
+include $(CHIBIOS)/tools/mk/autobuild.mk
+# Other files (optional).
+#include $(CHIBIOS)/os/test/test.mk
+#include $(CHIBIOS)/test/rt/rt_test.mk
+#include $(CHIBIOS)/test/oslib/oslib_test.mk
+
+# Define linker script file here.
+LDSCRIPT= $(STARTUPLD)/STM32F373xC.ld
+
+# C sources that can be compiled in ARM or THUMB mode depending on the global
+# setting.
+CSRC = $(ALLCSRC) \
+ $(TESTSRC) \
+ $(CONFDIR)/portab.c \
+ main.c
+
+# C++ sources that can be compiled in ARM or THUMB mode depending on the global
+# setting.
+CPPSRC = $(ALLCPPSRC)
+
+# List ASM source files here.
+ASMSRC = $(ALLASMSRC)
+
+# List ASM with preprocessor source files here.
+ASMXSRC = $(ALLXASMSRC)
+
+# Inclusion directories.
+INCDIR = $(CONFDIR) $(ALLINC) $(TESTINC)
+
+# Define C warning options here.
+CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes
+
+# Define C++ warning options here.
+CPPWARN = -Wall -Wextra -Wundef
+
+#
+# Project, target, sources and paths
+##############################################################################
+
+##############################################################################
+# Start of user section
+#
+
+# List all user C define here, like -D_DEBUG=1
+UDEFS =
+
+# Define ASM defines here
+UADEFS =
+
+# List all user directories here
+UINCDIR =
+
+# List the user directory to look for the libraries here
+ULIBDIR =
+
+# List all user libraries here
+ULIBS =
+
+#
+# End of user section
+##############################################################################
+
+##############################################################################
+# Common rules
+#
+
+RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk
+include $(RULESPATH)/arm-none-eabi.mk
+include $(RULESPATH)/rules.mk
+
+#
+# Common rules
+##############################################################################
+
+##############################################################################
+# Custom rules
+#
+
+#
+# Custom rules
+##############################################################################