diff --git a/demos/AT32/.keep b/demos/AT32/.keep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/testhal/AT32/AT32F415/USB_CDC/.cproject b/demos/AT32/RT-AT-START-F415/.cproject similarity index 62% rename from testhal/AT32/AT32F415/USB_CDC/.cproject rename to demos/AT32/RT-AT-START-F415/.cproject index 7e9524dabe8..74701160a0a 100644 --- a/testhal/AT32/AT32F415/USB_CDC/.cproject +++ b/demos/AT32/RT-AT-START-F415/.cproject @@ -1,8 +1,8 @@ - - + + @@ -14,20 +14,20 @@ - - - - - - - - + + + + + + + + - - + + - - + + @@ -37,18 +37,18 @@ - + - + - + diff --git a/demos/AT32/RT-AT-START-F415/.project b/demos/AT32/RT-AT-START-F415/.project new file mode 100644 index 00000000000..6229eed12ea --- /dev/null +++ b/demos/AT32/RT-AT-START-F415/.project @@ -0,0 +1,78 @@ + + + RT-AT-START-F415 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + mingw32-make + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + false + + + + + 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 + + diff --git a/testhal/AT32/AT32F415/USB_CDC/Makefile b/demos/AT32/RT-AT-START-F415/Makefile similarity index 69% rename from testhal/AT32/AT32F415/USB_CDC/Makefile rename to demos/AT32/RT-AT-START-F415/Makefile index cd0e85a6dda..9ca5d645d78 100644 --- a/testhal/AT32/AT32F415/USB_CDC/Makefile +++ b/demos/AT32/RT-AT-START-F415/Makefile @@ -33,11 +33,6 @@ 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 @@ -74,6 +69,11 @@ 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 ############################################################################## @@ -85,9 +85,12 @@ endif # Define project name here PROJECT = ch +# Target settings. +MCU = cortex-m4 + # Imported source files and paths. -CHIBIOS := ../../../../../ChibiOS -CHIBIOS_CONTRIB := ../../../../ +CHIBIOS := ../../../../ChibiOS +CHIBIOS_CONTRIB := ../../.. CONFDIR := ./cfg BUILDDIR := ./build DEPDIR := ./.dep @@ -104,6 +107,8 @@ 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 @@ -111,80 +116,28 @@ include $(CHIBIOS)/test/oslib/oslib_test.mk include $(CHIBIOS)/os/hal/lib/streams/streams.mk include $(CHIBIOS)/os/various/shell/shell.mk -# Define linker script file here +# Define linker script file here. LDSCRIPT= $(STARTUPLD_CONTRIB)/AT32F415xC.ld # C sources that can be compiled in ARM or THUMB mode depending on the global # setting. CSRC = $(ALLCSRC) \ $(TESTSRC) \ - usbcfg.c main.c + 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) + # List ASM with preprocessor source files here. ASMXSRC = $(ALLXASMSRC) # Inclusion directories. INCDIR = $(CONFDIR) $(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 @@ -192,7 +145,7 @@ CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes CPPWARN = -Wall -Wextra -Wundef # -# Compiler settings +# Project, target, sources and paths ############################################################################## ############################################################################## @@ -215,7 +168,7 @@ ULIBDIR = ULIBS = # -# End of user defines +# End of user section ############################################################################## ############################################################################## @@ -223,6 +176,7 @@ ULIBS = # RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk +include $(RULESPATH)/arm-none-eabi.mk include $(RULESPATH)/rules.mk # diff --git a/testhal/AT32/AT32F415/PWM-ICU/cfg/chconf.h b/demos/AT32/RT-AT-START-F415/cfg/chconf.h similarity index 96% rename from testhal/AT32/AT32F415/PWM-ICU/cfg/chconf.h rename to demos/AT32/RT-AT-START-F415/cfg/chconf.h index 6ae2a5be1bd..42828da814b 100644 --- a/testhal/AT32/AT32F415/PWM-ICU/cfg/chconf.h +++ b/demos/AT32/RT-AT-START-F415/cfg/chconf.h @@ -141,6 +141,19 @@ #define CH_CFG_NO_IDLE_THREAD FALSE #endif +/** + * @brief Kernel hardening level. + * @details This option is the level of functional-safety checks enabled + * in the kerkel. The meaning is: + * - 0: No checks, maximum performance. + * - 1: Reasonable checks. + * - 2: All checks. + * . + */ +#if !defined(CH_CFG_HARDENING_LEVEL) +#define CH_CFG_HARDENING_LEVEL 0 +#endif + /** @} */ /*===========================================================================*/ @@ -362,6 +375,16 @@ #define CH_CFG_USE_MAILBOXES TRUE #endif +/** + * @brief Memory checks APIs. + * @details If enabled then the memory checks APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_MEMCHECKS) +#define CH_CFG_USE_MEMCHECKS TRUE +#endif + /** * @brief Core Memory Manager APIs. * @details If enabled then the core memory manager APIs are included @@ -565,7 +588,7 @@ * @note The default is @p FALSE. */ #if !defined(CH_DBG_SYSTEM_STATE_CHECK) -#define CH_DBG_SYSTEM_STATE_CHECK TRUE +#define CH_DBG_SYSTEM_STATE_CHECK FALSE #endif /** @@ -576,7 +599,7 @@ * @note The default is @p FALSE. */ #if !defined(CH_DBG_ENABLE_CHECKS) -#define CH_DBG_ENABLE_CHECKS TRUE +#define CH_DBG_ENABLE_CHECKS FALSE #endif /** @@ -588,7 +611,7 @@ * @note The default is @p FALSE. */ #if !defined(CH_DBG_ENABLE_ASSERTS) -#define CH_DBG_ENABLE_ASSERTS TRUE +#define CH_DBG_ENABLE_ASSERTS FALSE #endif /** @@ -598,7 +621,7 @@ * @note The default is @p CH_DBG_TRACE_MASK_DISABLED. */ #if !defined(CH_DBG_TRACE_MASK) -#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_ALL +#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED #endif /** @@ -621,7 +644,7 @@ * @p panic_msg variable set to @p NULL. */ #if !defined(CH_DBG_ENABLE_STACK_CHECK) -#define CH_DBG_ENABLE_STACK_CHECK TRUE +#define CH_DBG_ENABLE_STACK_CHECK FALSE #endif /** @@ -633,7 +656,7 @@ * @note The default is @p FALSE. */ #if !defined(CH_DBG_FILL_THREADS) -#define CH_DBG_FILL_THREADS TRUE +#define CH_DBG_FILL_THREADS FALSE #endif /** diff --git a/testhal/AT32/AT32F415/PWM-ICU/cfg/halconf.h b/demos/AT32/RT-AT-START-F415/cfg/halconf.h similarity index 99% rename from testhal/AT32/AT32F415/PWM-ICU/cfg/halconf.h rename to demos/AT32/RT-AT-START-F415/cfg/halconf.h index 099dca49dad..379afbbea6e 100644 --- a/testhal/AT32/AT32F415/PWM-ICU/cfg/halconf.h +++ b/demos/AT32/RT-AT-START-F415/cfg/halconf.h @@ -102,7 +102,7 @@ * @brief Enables the ICU subsystem. */ #if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) -#define HAL_USE_ICU TRUE +#define HAL_USE_ICU FALSE #endif /** @@ -123,7 +123,7 @@ * @brief Enables the PWM subsystem. */ #if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) -#define HAL_USE_PWM TRUE +#define HAL_USE_PWM FALSE #endif /** @@ -144,7 +144,7 @@ * @brief Enables the SERIAL subsystem. */ #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL FALSE +#define HAL_USE_SERIAL TRUE #endif /** diff --git a/testhal/AT32/AT32F415/PWM-ICU/cfg/mcuconf.h b/demos/AT32/RT-AT-START-F415/cfg/mcuconf.h similarity index 96% rename from testhal/AT32/AT32F415/PWM-ICU/cfg/mcuconf.h rename to demos/AT32/RT-AT-START-F415/cfg/mcuconf.h index a8222ec6349..8b6899806d6 100644 --- a/testhal/AT32/AT32F415/PWM-ICU/cfg/mcuconf.h +++ b/demos/AT32/RT-AT-START-F415/cfg/mcuconf.h @@ -1,5 +1,5 @@ /* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006..2020 Giovanni Di Sirio ChibiOS - Copyright (C) 2023..2024 HorrorTroll ChibiOS - Copyright (C) 2023..2024 Zhaqian @@ -19,8 +19,6 @@ #ifndef MCUCONF_H #define MCUCONF_H -#define AT32F415_MCUCONF - /* * AT32F415 drivers configuration. * The following settings override the default settings present in @@ -35,6 +33,8 @@ * 0...3 Lowest...Highest. */ +#define AT32F415_MCUCONF + /* * HAL driver system settings. */ @@ -58,6 +58,7 @@ #define AT32_USB_CLOCK_REQUIRED TRUE #define AT32_USBDIV AT32_USBDIV_DIV3 #define AT32_CLKOUT_SEL AT32_CLKOUT_SEL_NOCLOCK +#define AT32_CLKOUTDIV AT32_CLKOUTDIV_DIV1 #define AT32_ERTCSEL AT32_ERTCSEL_HEXTDIV #define AT32_PVM_ENABLE FALSE #define AT32_PVMSEL AT32_PVMSEL_LEV1 @@ -143,7 +144,7 @@ #define AT32_ICU_USE_TMR1 FALSE #define AT32_ICU_USE_TMR2 FALSE #define AT32_ICU_USE_TMR3 FALSE -#define AT32_ICU_USE_TMR4 TRUE +#define AT32_ICU_USE_TMR4 FALSE #define AT32_ICU_USE_TMR5 FALSE #define AT32_ICU_USE_TMR9 FALSE #define AT32_ICU_USE_TMR10 FALSE @@ -152,7 +153,7 @@ /* * PWM driver system settings. */ -#define AT32_PWM_USE_TMR1 TRUE +#define AT32_PWM_USE_TMR1 FALSE #define AT32_PWM_USE_TMR2 FALSE #define AT32_PWM_USE_TMR3 FALSE #define AT32_PWM_USE_TMR4 FALSE @@ -172,7 +173,7 @@ /* * SERIAL driver system settings. */ -#define AT32_SERIAL_USE_USART1 FALSE +#define AT32_SERIAL_USE_USART1 TRUE #define AT32_SERIAL_USE_USART2 FALSE #define AT32_SERIAL_USE_USART3 FALSE #define AT32_SERIAL_USE_UART4 FALSE @@ -212,7 +213,6 @@ #define AT32_USB_USE_OTG1 FALSE #define AT32_USB_OTG1_IRQ_PRIORITY 14 #define AT32_USB_OTG1_RX_FIFO_SIZE 512 -#define AT32_USB_HOST_WAKEUP_DURATION 2 /* * WDG driver system settings. diff --git a/demos/AT32/RT-AT-START-F415/main.c b/demos/AT32/RT-AT-START-F415/main.c new file mode 100644 index 00000000000..fc991eb7a88 --- /dev/null +++ b/demos/AT32/RT-AT-START-F415/main.c @@ -0,0 +1,85 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + ChibiOS - Copyright (C) 2023..2024 HorrorTroll + ChibiOS - Copyright (C) 2023..2024 Zhaqian + + 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" +#include "rt_test_root.h" +#include "oslib_test_root.h" + +/* + * This is a periodic thread that does absolutely nothing except flashing + * a LED. + */ +static THD_WORKING_AREA(waThread1, 128); +static THD_FUNCTION(Thread1, arg) { + + (void)arg; + chRegSetThreadName("blinker"); + while (true) { + palSetLine(LINE_LED_RED); + chThdSleepMilliseconds(250); + palSetLine(LINE_LED_YELLOW); + chThdSleepMilliseconds(250); + palSetLine(LINE_LED_GREEN); + chThdSleepMilliseconds(250); + palClearLine(LINE_LED_RED); + chThdSleepMilliseconds(250); + palClearLine(LINE_LED_YELLOW); + chThdSleepMilliseconds(250); + palClearLine(LINE_LED_GREEN); + chThdSleepMilliseconds(250); + } +} + +/* + * Application entry point. + */ +int main(void) { + + /* + * 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(); + + /* + * Activates the serial driver 1 using the driver default configuration. + */ + sdStart(&SD1, NULL); + + /* + * Creates the example thread. + */ + chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); + + /* + * Normal main() thread activity, in this demo it does nothing except + * sleeping in a loop and check the button state. + */ + while (true) { + if (palReadLine(LINE_BUTTON)) { + test_execute((BaseSequentialStream *)&SD1, &rt_test_suite); + test_execute((BaseSequentialStream *)&SD1, &oslib_test_suite); + } + chThdSleepMilliseconds(500); + } +} diff --git a/os/hal/boards/AT_START_F415/board.h b/os/hal/boards/AT_START_F415/board.h index 61b0c75a3f1..7eecf54707d 100644 --- a/os/hal/boards/AT_START_F415/board.h +++ b/os/hal/boards/AT_START_F415/board.h @@ -112,6 +112,47 @@ #define GPIOF_PIN6 6U #define GPIOF_PIN7 7U +/* + * IO lines assignments. + */ +#define LINE_BUTTON PAL_LINE(GPIOA, 0U) +#define LINE_ARD_A1 PAL_LINE(GPIOA, 1U) +#define LINE_ARD_D1 PAL_LINE(GPIOA, 2U) +#define LINE_ARD_D0 PAL_LINE(GPIOA, 3U) +#define LINE_ARD_A2 PAL_LINE(GPIOA, 4U) +#define LINE_ARD_D13 PAL_LINE(GPIOA, 5U) +#define LINE_ARD_D12 PAL_LINE(GPIOA, 6U) +#define LINE_ARD_D11 PAL_LINE(GPIOA, 7U) +#define LINE_ARD_D7 PAL_LINE(GPIOA, 8U) +#define LINE_ARD_D8 PAL_LINE(GPIOA, 9U) +#define LINE_ARD_D2 PAL_LINE(GPIOA, 10U) +#define LINE_SWDIO PAL_LINE(GPIOA, 13U) +#define LINE_SWCLK PAL_LINE(GPIOA, 14U) +#define LINE_ARD_D10 PAL_LINE(GPIOA, 15U) +#define LINE_ARD_A3 PAL_LINE(GPIOB, 0U) +#define LINE_SWO PAL_LINE(GPIOB, 3U) +#define LINE_ARD_D5 PAL_LINE(GPIOB, 4U) +#define LINE_ARD_D4 PAL_LINE(GPIOB, 5U) +#define LINE_ARD_SCL PAL_LINE(GPIOB, 8U) +#define LINE_ARD_SDA PAL_LINE(GPIOB, 9U) +#define LINE_ARD_D6 PAL_LINE(GPIOB, 10U) +#define LINE_ARD_PB11 PAL_LINE(GPIOB, 11U) +#define LINE_ARD_NSS PAL_LINE(GPIOB, 12U) +#define LINE_ARD_SCK PAL_LINE(GPIOB, 13U) +#define LINE_ARD_MISO PAL_LINE(GPIOB, 14U) +#define LINE_ARD_MOSI PAL_LINE(GPIOB, 15U) +#define LINE_ARD_A5 PAL_LINE(GPIOC, 0U) +#define LINE_ARD_A4 PAL_LINE(GPIOC, 1U) +#define LINE_LED_RED PAL_LINE(GPIOC, 2U) +#define LINE_LED_YELLOW PAL_LINE(GPIOC, 3U) +#define LINE_LED_GREEN PAL_LINE(GPIOC, 5U) +#define LINE_ARD_D9 PAL_LINE(GPIOC, 7U) +#define LINE_BUTTON_ALT PAL_LINE(GPIOC, 13U) +#define LINE_LEXT_IN PAL_LINE(GPIOC, 14U) +#define LINE_LEXT_OUT PAL_LINE(GPIOC, 15U) +#define LINE_HEXT_IN PAL_LINE(GPIOD, 0U) +#define LINE_HEXT_OUT PAL_LINE(GPIOD, 1U) + /*===========================================================================*/ /* Driver pre-compile time settings. */ /*===========================================================================*/ @@ -155,13 +196,12 @@ /* * Port A setup. * Everything input with pull-up except: - * PA0 - Normal input (GPIOA_BUTTON) - * PA2 - Alternate output (GPIOA_ARD_D1) - * PA3 - Normal input (GPIOA_ARD_D0) - * PA14 - Pull-down input (GPIOA_SWCLK) + * PA0 - Normal input (GPIOA_BUTTON). + * PA9 - Alternate output (GPIOA_ARD_D8). + * PA10 - Normal input (GPIOA_ARD_D2). */ -#define VAL_GPIOACFGLR 0x88884B84 /* PA7...PA0 */ -#define VAL_GPIOACFGHR 0x88888888 /* PA15...PA8 */ +#define VAL_GPIOACFGLR 0x88888884 /* PA7...PA0 */ +#define VAL_GPIOACFGHR 0x888884B8 /* PA15...PA8 */ #define VAL_GPIOAODT 0xFFFFFFFF /* @@ -174,10 +214,10 @@ /* * Port C setup. * Everything input with pull-up except: - * PC2 - Push Pull output (GPIOC_LED_RED) - * PC3 - Push Pull output (GPIOC_LED_YELLOW) - * PC5 - Push Pull output (GPIOC_LED_GREEN) - * PC13 - Normal input (GPIOC_BUTTON) + * PC2 - Push Pull output (GPIOC_LED_RED). + * PC3 - Push Pull output (GPIOC_LED_YELLOW). + * PC5 - Push Pull output (GPIOC_LED_GREEN). + * PC13 - Normal input (GPIOC_BUTTON). */ #define VAL_GPIOCCFGLR 0x88383388 /* PC7...PC0 */ #define VAL_GPIOCCFGHR 0x88488888 /* PC15...PC8 */ diff --git a/testhal/AT32/AT32F415/PWM-ICU/.project b/testhal/AT32/AT32F415/PWM-ICU/.project deleted file mode 100644 index a94f918b024..00000000000 --- a/testhal/AT32/AT32F415/PWM-ICU/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - AT32F415-PWM-ICU - - - - - - 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 - - - - os - 2 - CHIBIOS/os - - - diff --git a/testhal/AT32/AT32F415/PWM-ICU/main.c b/testhal/AT32/AT32F415/PWM-ICU/main.c deleted file mode 100644 index 4f22f79cec5..00000000000 --- a/testhal/AT32/AT32F415/PWM-ICU/main.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio - ChibiOS - Copyright (C) 2023..2024 HorrorTroll - ChibiOS - Copyright (C) 2023..2024 Zhaqian - - 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" - -static void pwmpcb(PWMDriver *pwmp) { - - (void)pwmp; - palSetPad(IOPORT3, GPIOC_LED_GREEN); -} - -static void pwmc1cb(PWMDriver *pwmp) { - - (void)pwmp; - palClearPad(IOPORT3, GPIOC_LED_GREEN); -} - -static PWMConfig pwmcfg = { - 10000, /* 10kHz PWM clock frequency. */ - 10000, /* Initial PWM period 1S. */ - pwmpcb, - { - {PWM_OUTPUT_ACTIVE_HIGH, pwmc1cb}, - {PWM_OUTPUT_DISABLED, NULL}, - {PWM_OUTPUT_DISABLED, NULL}, - {PWM_OUTPUT_DISABLED, NULL} - }, - 0, - 0, - 0 -}; - -icucnt_t last_width, last_period; - -static void icuwidthcb(ICUDriver *icup) { - - last_width = icuGetWidthX(icup); -} - -static void icuperiodcb(ICUDriver *icup) { - - last_period = icuGetPeriodX(icup); -} - -static ICUConfig icucfg = { - ICU_INPUT_ACTIVE_HIGH, - 10000, /* 10kHz ICU clock frequency. */ - icuwidthcb, - icuperiodcb, - NULL, - ICU_CHANNEL_1, - 0U, - 0xFFFFFFFFU -}; - -/* - * Application entry point. - */ -int main(void) { - - /* - * 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(); - - /* - * LED initially off. - */ - palSetPad(IOPORT3, GPIOC_LED_GREEN); - - /* - * Initializes the PWM driver 1 and ICU driver 4. - */ - pwmStart(&PWMD1, &pwmcfg); - pwmEnablePeriodicNotification(&PWMD1); - palSetPadMode(IOPORT1, 8, PAL_MODE_AT32_ALTERNATE_PUSHPULL); - icuStart(&ICUD4, &icucfg); - icuStartCapture(&ICUD4); - icuEnableNotifications(&ICUD4); - chThdSleepMilliseconds(2000); - - /* - * Starts the PWM channel 0 using 75% duty cycle. - */ - pwmEnableChannel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 7500)); - pwmEnableChannelNotification(&PWMD1, 0); - chThdSleepMilliseconds(5000); - - /* - * Changes the PWM channel 0 to 50% duty cycle. - */ - pwmEnableChannel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000)); - chThdSleepMilliseconds(5000); - - /* - * Changes the PWM channel 0 to 25% duty cycle. - */ - pwmEnableChannel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 2500)); - chThdSleepMilliseconds(5000); - - /* - * Changes PWM period to half second the duty cycle becomes 50% - * implicitly. - */ - pwmChangePeriod(&PWMD1, 5000); - chThdSleepMilliseconds(5000); - - /* - * Disables channel 0 and stops the drivers. - */ - pwmDisableChannel(&PWMD1, 0); - pwmStop(&PWMD1); - icuStopCapture(&ICUD4); - icuStop(&ICUD4); - palSetPad(IOPORT3, GPIOC_LED_GREEN); - - /* - * Normal main() thread activity, in this demo it does nothing. - */ - while (true) { - chThdSleepMilliseconds(500); - } - return 0; -} diff --git a/testhal/AT32/AT32F415/PWM-ICU/readme.txt b/testhal/AT32/AT32F415/PWM-ICU/readme.txt deleted file mode 100644 index 831073bf7df..00000000000 --- a/testhal/AT32/AT32F415/PWM-ICU/readme.txt +++ /dev/null @@ -1,28 +0,0 @@ -***************************************************************************** -** ChibiOS/HAL - PWM/ICU driver demo for AT32. ** -***************************************************************************** - -** TARGET ** - -The demo runs on an AT-START-F415 board. - -** The Demo ** - -The application demonstrates the use of the AT32 PWM and ICU drivers. Pins -PA8 and PB6 must be connected in order to trigger the ICU input with the -PWM output. The ICU unit will measure the generated PWM. - -** 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 -Artery Technology and are licensed under a different license. -Also note that not all the files present in the AT library are distributed -with ChibiOS/RT, you can find the whole library on the AT web site: - - https://www.arterychip.com/en diff --git a/testhal/AT32/AT32F415/USB_CDC/.project b/testhal/AT32/AT32F415/USB_CDC/.project deleted file mode 100644 index d38abd8218e..00000000000 --- a/testhal/AT32/AT32F415/USB_CDC/.project +++ /dev/null @@ -1,49 +0,0 @@ - - - AT32F415-USB_CDC - - - - - - 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_CONTRIB/os/hal/boards/AT_START_F415 - - - os - 2 - CHIBIOS/os - - - test - 2 - CHIBIOS/test - - - - - CHIBIOS_CONTRIB - file:/E:/Duc/Secrets/QMK_custom_mcu/at32_test_qmk/lib/chibios-contrib - - - diff --git a/testhal/AT32/AT32F415/USB_CDC/readme.txt b/testhal/AT32/AT32F415/USB_CDC/readme.txt deleted file mode 100644 index a016a1945e2..00000000000 --- a/testhal/AT32/AT32F415/USB_CDC/readme.txt +++ /dev/null @@ -1,26 +0,0 @@ -***************************************************************************** -** ChibiOS/HAL - USB-CDC driver demo for AT32. ** -***************************************************************************** - -** TARGET ** - -The demo runs on an AT-START-F415 board. - -** The Demo ** - -The application demonstrates the use of the AT32 USB (OTG) driver. - -** 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 -Artery Technology and are licensed under a different license. -Also note that not all the files present in the AT library are distributed -with ChibiOS/RT, you can find the whole library on the AT web site: - - https://www.arterychip.com/en diff --git a/testhal/AT32/AT32F415/PWM-ICU/.cproject b/testhal/AT32/multi/USB_CDC/.cproject similarity index 56% rename from testhal/AT32/AT32F415/PWM-ICU/.cproject rename to testhal/AT32/multi/USB_CDC/.cproject index 6caf490fe75..74701160a0a 100644 --- a/testhal/AT32/AT32F415/PWM-ICU/.cproject +++ b/testhal/AT32/multi/USB_CDC/.cproject @@ -1,8 +1,8 @@ - - + + @@ -14,20 +14,20 @@ - - - - - - - - + + + + + + + + - - + + - - + + @@ -37,13 +37,20 @@ - + - + + + + + + + + \ No newline at end of file diff --git a/testhal/AT32/multi/USB_CDC/.project b/testhal/AT32/multi/USB_CDC/.project new file mode 100644 index 00000000000..619fe276fe1 --- /dev/null +++ b/testhal/AT32/multi/USB_CDC/.project @@ -0,0 +1,78 @@ + + + AT32-USB_CDC + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + mingw32-make + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + false + + + + + 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 + + diff --git a/testhal/AT32/multi/USB_CDC/Makefile b/testhal/AT32/multi/USB_CDC/Makefile new file mode 100644 index 00000000000..c8606df05ea --- /dev/null +++ b/testhal/AT32/multi/USB_CDC/Makefile @@ -0,0 +1,18 @@ +############################################################################## +# Multi-project makefile rules +# + +all: + @echo + @echo === Building for AT-START-F415 ===================================== + +@make --no-print-directory -f ./make/at-start-f415.make all + @echo ==================================================================== + @echo + +clean: + @echo + +@make --no-print-directory -f ./make/at-start-f415.make clean + @echo + +# +############################################################################## diff --git a/testhal/AT32/AT32F415/USB_CDC/cfg/chconf.h b/testhal/AT32/multi/USB_CDC/cfg/at-start-f415/chconf.h similarity index 96% rename from testhal/AT32/AT32F415/USB_CDC/cfg/chconf.h rename to testhal/AT32/multi/USB_CDC/cfg/at-start-f415/chconf.h index 6ae2a5be1bd..42828da814b 100644 --- a/testhal/AT32/AT32F415/USB_CDC/cfg/chconf.h +++ b/testhal/AT32/multi/USB_CDC/cfg/at-start-f415/chconf.h @@ -141,6 +141,19 @@ #define CH_CFG_NO_IDLE_THREAD FALSE #endif +/** + * @brief Kernel hardening level. + * @details This option is the level of functional-safety checks enabled + * in the kerkel. The meaning is: + * - 0: No checks, maximum performance. + * - 1: Reasonable checks. + * - 2: All checks. + * . + */ +#if !defined(CH_CFG_HARDENING_LEVEL) +#define CH_CFG_HARDENING_LEVEL 0 +#endif + /** @} */ /*===========================================================================*/ @@ -362,6 +375,16 @@ #define CH_CFG_USE_MAILBOXES TRUE #endif +/** + * @brief Memory checks APIs. + * @details If enabled then the memory checks APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_MEMCHECKS) +#define CH_CFG_USE_MEMCHECKS TRUE +#endif + /** * @brief Core Memory Manager APIs. * @details If enabled then the core memory manager APIs are included @@ -565,7 +588,7 @@ * @note The default is @p FALSE. */ #if !defined(CH_DBG_SYSTEM_STATE_CHECK) -#define CH_DBG_SYSTEM_STATE_CHECK TRUE +#define CH_DBG_SYSTEM_STATE_CHECK FALSE #endif /** @@ -576,7 +599,7 @@ * @note The default is @p FALSE. */ #if !defined(CH_DBG_ENABLE_CHECKS) -#define CH_DBG_ENABLE_CHECKS TRUE +#define CH_DBG_ENABLE_CHECKS FALSE #endif /** @@ -588,7 +611,7 @@ * @note The default is @p FALSE. */ #if !defined(CH_DBG_ENABLE_ASSERTS) -#define CH_DBG_ENABLE_ASSERTS TRUE +#define CH_DBG_ENABLE_ASSERTS FALSE #endif /** @@ -598,7 +621,7 @@ * @note The default is @p CH_DBG_TRACE_MASK_DISABLED. */ #if !defined(CH_DBG_TRACE_MASK) -#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_ALL +#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED #endif /** @@ -621,7 +644,7 @@ * @p panic_msg variable set to @p NULL. */ #if !defined(CH_DBG_ENABLE_STACK_CHECK) -#define CH_DBG_ENABLE_STACK_CHECK TRUE +#define CH_DBG_ENABLE_STACK_CHECK FALSE #endif /** @@ -633,7 +656,7 @@ * @note The default is @p FALSE. */ #if !defined(CH_DBG_FILL_THREADS) -#define CH_DBG_FILL_THREADS TRUE +#define CH_DBG_FILL_THREADS FALSE #endif /** diff --git a/testhal/AT32/AT32F415/USB_CDC/cfg/halconf.h b/testhal/AT32/multi/USB_CDC/cfg/at-start-f415/halconf.h similarity index 100% rename from testhal/AT32/AT32F415/USB_CDC/cfg/halconf.h rename to testhal/AT32/multi/USB_CDC/cfg/at-start-f415/halconf.h diff --git a/testhal/AT32/AT32F415/USB_CDC/cfg/mcuconf.h b/testhal/AT32/multi/USB_CDC/cfg/at-start-f415/mcuconf.h similarity index 98% rename from testhal/AT32/AT32F415/USB_CDC/cfg/mcuconf.h rename to testhal/AT32/multi/USB_CDC/cfg/at-start-f415/mcuconf.h index cdc11f27bfe..3b0e65f93f9 100644 --- a/testhal/AT32/AT32F415/USB_CDC/cfg/mcuconf.h +++ b/testhal/AT32/multi/USB_CDC/cfg/at-start-f415/mcuconf.h @@ -1,5 +1,5 @@ /* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006..2020 Giovanni Di Sirio ChibiOS - Copyright (C) 2023..2024 HorrorTroll ChibiOS - Copyright (C) 2023..2024 Zhaqian @@ -19,8 +19,6 @@ #ifndef MCUCONF_H #define MCUCONF_H -#define AT32F415_MCUCONF - /* * AT32F415 drivers configuration. * The following settings override the default settings present in @@ -35,6 +33,8 @@ * 0...3 Lowest...Highest. */ +#define AT32F415_MCUCONF + /* * HAL driver system settings. */ @@ -58,6 +58,7 @@ #define AT32_USB_CLOCK_REQUIRED TRUE #define AT32_USBDIV AT32_USBDIV_DIV3 #define AT32_CLKOUT_SEL AT32_CLKOUT_SEL_NOCLOCK +#define AT32_CLKOUTDIV AT32_CLKOUTDIV_DIV1 #define AT32_ERTCSEL AT32_ERTCSEL_HEXTDIV #define AT32_PVM_ENABLE FALSE #define AT32_PVMSEL AT32_PVMSEL_LEV1 @@ -212,7 +213,6 @@ #define AT32_USB_USE_OTG1 TRUE #define AT32_USB_OTG1_IRQ_PRIORITY 14 #define AT32_USB_OTG1_RX_FIFO_SIZE 512 -#define AT32_USB_HOST_WAKEUP_DURATION 2 /* * WDG driver system settings. diff --git a/testhal/AT32/multi/USB_CDC/cfg/at-start-f415/portab.c b/testhal/AT32/multi/USB_CDC/cfg/at-start-f415/portab.c new file mode 100644 index 00000000000..25e871321a0 --- /dev/null +++ b/testhal/AT32/multi/USB_CDC/cfg/at-start-f415/portab.c @@ -0,0 +1,59 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + ChibiOS - Copyright (C) 2023..2024 HorrorTroll + ChibiOS - Copyright (C) 2023..2024 Zhaqian + + 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. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module local types. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module exported functions. */ +/*===========================================================================*/ + +void portab_setup(void) { + +} + +/** @} */ diff --git a/testhal/AT32/multi/USB_CDC/cfg/at-start-f415/portab.h b/testhal/AT32/multi/USB_CDC/cfg/at-start-f415/portab.h new file mode 100644 index 00000000000..586eb17f65f --- /dev/null +++ b/testhal/AT32/multi/USB_CDC/cfg/at-start-f415/portab.h @@ -0,0 +1,78 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + ChibiOS - Copyright (C) 2023..2024 HorrorTroll + ChibiOS - Copyright (C) 2023..2024 Zhaqian + + 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_USB1 USBD1 + +#define PORTAB_SDU1 SDU1 + +#define PORTAB_BLINK_LED1 LINE_LED_RED + +#define PORTAB_BLINK_LED2 LINE_LED_YELLOW + +#define PORTAB_BLINK_LED3 LINE_LED_GREEN + +/*===========================================================================*/ +/* Module pre-compile time settings. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module data structures and types. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module macros. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + void portab_setup(void); +#ifdef __cplusplus +} +#endif + +/*===========================================================================*/ +/* Module inline functions. */ +/*===========================================================================*/ + +#endif /* PORTAB_H */ + +/** @} */ diff --git a/testhal/AT32/AT32F415/USB_CDC/main.c b/testhal/AT32/multi/USB_CDC/main.c similarity index 82% rename from testhal/AT32/AT32F415/USB_CDC/main.c rename to testhal/AT32/multi/USB_CDC/main.c index 6bf5791d5a3..a18e70123e4 100644 --- a/testhal/AT32/AT32F415/USB_CDC/main.c +++ b/testhal/AT32/multi/USB_CDC/main.c @@ -16,12 +16,12 @@ limitations under the License. */ +#include #include #include #include "ch.h" #include "hal.h" - #include "shell.h" #include "chprintf.h" @@ -62,12 +62,12 @@ static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) { while (chnGetTimeout((BaseChannel *)chp, TIME_IMMEDIATE) == Q_TIMEOUT) { #if 1 /* Writing in channel mode.*/ - chnWrite(&SDU1, buf, sizeof buf - 1); + chnWrite(&PORTAB_SDU1, buf, sizeof buf - 1); #else /* Writing in buffer mode.*/ - (void) obqGetEmptyBufferTimeout(&SDU1.obqueue, TIME_INFINITE); - memcpy(SDU1.obqueue.ptr, buf, SERIAL_USB_BUFFERS_SIZE); - obqPostFullBuffer(&SDU1.obqueue, SERIAL_USB_BUFFERS_SIZE); + (void) obqGetEmptyBufferTimeout(&PORTAB_SDU1.obqueue, TIME_INFINITE); + memcpy(PORTAB_SDU1.obqueue.ptr, buf, SERIAL_USB_BUFFERS_SIZE); + obqPostFullBuffer(&PORTAB_SDU1.obqueue, SERIAL_USB_BUFFERS_SIZE); #endif } chprintf(chp, "\r\n\nstopped\r\n"); @@ -79,7 +79,7 @@ static const ShellCommand commands[] = { }; static const ShellConfig shell_cfg1 = { - (BaseSequentialStream *)&SDU1, + (BaseSequentialStream *)&PORTAB_SDU1, commands }; @@ -88,7 +88,7 @@ static const ShellConfig shell_cfg1 = { /*===========================================================================*/ /* - * Green LED blinker thread, times are in milliseconds. + * LED blinker thread, times are in milliseconds. */ static THD_WORKING_AREA(waThread1, 128); static THD_FUNCTION(Thread1, arg) { @@ -96,10 +96,20 @@ static THD_FUNCTION(Thread1, arg) { (void)arg; chRegSetThreadName("blinker"); while (true) { - systime_t time = serusbcfg.usbp->state == USB_ACTIVE ? 250 : 500; - palClearPad(IOPORT3, GPIOC_LED_GREEN); + systime_t time; + + time = serusbcfg.usbp->state == USB_ACTIVE ? 250 : 500; + palSetLine(PORTAB_BLINK_LED1); + chThdSleepMilliseconds(time); + palSetLine(PORTAB_BLINK_LED2); + chThdSleepMilliseconds(time); + palSetLine(PORTAB_BLINK_LED3); + chThdSleepMilliseconds(time); + palClearLine(PORTAB_BLINK_LED1); chThdSleepMilliseconds(time); - palSetPad(IOPORT3, GPIOC_LED_GREEN); + palClearLine(PORTAB_BLINK_LED2); + chThdSleepMilliseconds(time); + palClearLine(PORTAB_BLINK_LED3); chThdSleepMilliseconds(time); } } @@ -119,11 +129,16 @@ int main(void) { halInit(); chSysInit(); + /* + * Board-dependent initialization. + */ + portab_setup(); + /* * Initializes a serial-over-USB CDC driver. */ - sduObjectInit(&SDU1); - sduStart(&SDU1, &serusbcfg); + sduObjectInit(&PORTAB_SDU1); + sduStart(&PORTAB_SDU1, &serusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. @@ -131,7 +146,7 @@ int main(void) { * after a reset. */ usbDisconnectBus(serusbcfg.usbp); - chThdSleepMilliseconds(1000); + chThdSleepMilliseconds(1500); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); @@ -149,7 +164,7 @@ int main(void) { * Normal main() thread activity, spawning shells. */ while (true) { - if (SDU1.config->usbp->state == USB_ACTIVE) { + if (PORTAB_SDU1.config->usbp->state == USB_ACTIVE) { thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE, "shell", NORMALPRIO + 1, shellThread, (void *)&shell_cfg1); diff --git a/testhal/AT32/AT32F415/PWM-ICU/Makefile b/testhal/AT32/multi/USB_CDC/make/at-start-f415.make similarity index 67% rename from testhal/AT32/AT32F415/PWM-ICU/Makefile rename to testhal/AT32/multi/USB_CDC/make/at-start-f415.make index a00e20a67fc..60300dbfcda 100644 --- a/testhal/AT32/AT32F415/PWM-ICU/Makefile +++ b/testhal/AT32/multi/USB_CDC/make/at-start-f415.make @@ -33,11 +33,6 @@ 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 @@ -74,6 +69,11 @@ 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 ############################################################################## @@ -85,12 +85,15 @@ endif # Define project name here PROJECT = ch +# Target settings. +MCU = cortex-m4 + # Imported source files and paths. CHIBIOS := ../../../../../ChibiOS -CHIBIOS_CONTRIB := ../../../../ -CONFDIR := ./cfg -BUILDDIR := ./build -DEPDIR := ./.dep +CHIBIOS_CONTRIB := ../../../.. +CONFDIR := ./cfg/at-start-f415 +BUILDDIR := ./build/at-start-f415 +DEPDIR := ./.dep/at-start-f415 # Licensing files. include $(CHIBIOS)/os/license/license.mk @@ -104,85 +107,38 @@ 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 +include $(CHIBIOS)/os/test/test.mk +include $(CHIBIOS)/test/rt/rt_test.mk +include $(CHIBIOS)/test/oslib/oslib_test.mk +include $(CHIBIOS)/os/hal/lib/streams/streams.mk +include $(CHIBIOS)/os/various/shell/shell.mk -# Define linker script file here +# Define linker script file here. LDSCRIPT= $(STARTUPLD_CONTRIB)/AT32F415xC.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) -# 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) + # List ASM with preprocessor source files here. ASMXSRC = $(ALLXASMSRC) # Inclusion directories. INCDIR = $(CONFDIR) $(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 @@ -190,7 +146,7 @@ CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes CPPWARN = -Wall -Wextra -Wundef # -# Compiler settings +# Project, target, sources and paths ############################################################################## ############################################################################## @@ -213,7 +169,7 @@ ULIBDIR = ULIBS = # -# End of user defines +# End of user section ############################################################################## ############################################################################## @@ -221,6 +177,7 @@ ULIBS = # RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk +include $(RULESPATH)/arm-none-eabi.mk include $(RULESPATH)/rules.mk # diff --git a/testhal/AT32/AT32F415/USB_CDC/usbcfg.c b/testhal/AT32/multi/USB_CDC/source/usbcfg.c similarity index 93% rename from testhal/AT32/AT32F415/USB_CDC/usbcfg.c rename to testhal/AT32/multi/USB_CDC/source/usbcfg.c index b1afb386b44..4ec94841aa1 100644 --- a/testhal/AT32/AT32F415/USB_CDC/usbcfg.c +++ b/testhal/AT32/multi/USB_CDC/source/usbcfg.c @@ -17,16 +17,17 @@ */ #include "hal.h" +#include "portab.h" /* Virtual serial port over USB.*/ -SerialUSBDriver SDU1; +SerialUSBDriver PORTAB_SDU1; /* * Endpoints to be used for USBD1. */ -#define USBD1_DATA_REQUEST_EP 1 -#define USBD1_DATA_AVAILABLE_EP 1 -#define USBD1_INTERRUPT_REQUEST_EP 2 +#define USB1_DATA_REQUEST_EP 1 +#define USB1_DATA_AVAILABLE_EP 1 +#define USB1_INTERRUPT_REQUEST_EP 2 /* * USB Device Descriptor. @@ -104,7 +105,7 @@ static const uint8_t vcom_configuration_descriptor_data[67] = { USB_DESC_BYTE (0x01), /* bSlaveInterface0 (Data Class Interface). */ /* Endpoint 2 Descriptor.*/ - USB_DESC_ENDPOINT (USBD1_INTERRUPT_REQUEST_EP|0x80, + USB_DESC_ENDPOINT (USB1_INTERRUPT_REQUEST_EP|0x80, 0x03, /* bmAttributes (Interrupt). */ 0x0008, /* wMaxPacketSize. */ 0xFF), /* bInterval. */ @@ -120,12 +121,12 @@ static const uint8_t vcom_configuration_descriptor_data[67] = { 4.7). */ 0x00), /* iInterface. */ /* Endpoint 3 Descriptor.*/ - USB_DESC_ENDPOINT (USBD1_DATA_AVAILABLE_EP, /* bEndpointAddress.*/ + USB_DESC_ENDPOINT (USB1_DATA_AVAILABLE_EP, /* bEndpointAddress.*/ 0x02, /* bmAttributes (Bulk). */ 0x0040, /* wMaxPacketSize. */ 0x00), /* bInterval. */ /* Endpoint 1 Descriptor.*/ - USB_DESC_ENDPOINT (USBD1_DATA_REQUEST_EP|0x80, /* bEndpointAddress.*/ + USB_DESC_ENDPOINT (USB1_DATA_REQUEST_EP|0x80, /* bEndpointAddress.*/ 0x02, /* bmAttributes (Bulk). */ 0x0040, /* wMaxPacketSize. */ 0x00) /* bInterval. */ @@ -266,7 +267,7 @@ static const USBEndpointConfig ep2config = { * Handles the USB driver global events. */ static void usb_event(USBDriver *usbp, usbevent_t event) { - extern SerialUSBDriver SDU1; + extern SerialUSBDriver PORTAB_SDU1; switch (event) { case USB_EVENT_ADDRESS: @@ -277,11 +278,11 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { /* Enables the endpoints specified into the configuration. Note, this callback is invoked from an ISR so I-Class functions must be used.*/ - usbInitEndpointI(usbp, USBD1_DATA_REQUEST_EP, &ep1config); - usbInitEndpointI(usbp, USBD1_INTERRUPT_REQUEST_EP, &ep2config); + usbInitEndpointI(usbp, USB1_DATA_REQUEST_EP, &ep1config); + usbInitEndpointI(usbp, USB1_INTERRUPT_REQUEST_EP, &ep2config); /* Resetting the state of the CDC subsystem.*/ - sduConfigureHookI(&SDU1); + sduConfigureHookI(&PORTAB_SDU1); chSysUnlockFromISR(); return; @@ -293,7 +294,7 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { chSysLockFromISR(); /* Disconnection event on suspend.*/ - sduSuspendHookI(&SDU1); + sduSuspendHookI(&PORTAB_SDU1); chSysUnlockFromISR(); return; @@ -301,7 +302,7 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { chSysLockFromISR(); /* Connection event on wakeup.*/ - sduWakeupHookI(&SDU1); + sduWakeupHookI(&PORTAB_SDU1); chSysUnlockFromISR(); return; @@ -319,7 +320,7 @@ static void sof_handler(USBDriver *usbp) { (void)usbp; osalSysLockFromISR(); - sduSOFHookI(&SDU1); + sduSOFHookI(&PORTAB_SDU1); osalSysUnlockFromISR(); } @@ -337,8 +338,8 @@ const USBConfig usbcfg = { * Serial over USB driver configuration. */ const SerialUSBConfig serusbcfg = { - &USBD1, - USBD1_DATA_REQUEST_EP, - USBD1_DATA_AVAILABLE_EP, - USBD1_INTERRUPT_REQUEST_EP + &PORTAB_USB1, + USB1_DATA_REQUEST_EP, + USB1_DATA_AVAILABLE_EP, + USB1_INTERRUPT_REQUEST_EP }; diff --git a/testhal/AT32/AT32F415/USB_CDC/usbcfg.h b/testhal/AT32/multi/USB_CDC/source/usbcfg.h similarity index 95% rename from testhal/AT32/AT32F415/USB_CDC/usbcfg.h rename to testhal/AT32/multi/USB_CDC/source/usbcfg.h index 036a822f31b..40a9a2d3ef3 100644 --- a/testhal/AT32/AT32F415/USB_CDC/usbcfg.h +++ b/testhal/AT32/multi/USB_CDC/source/usbcfg.h @@ -21,7 +21,7 @@ extern const USBConfig usbcfg; extern SerialUSBConfig serusbcfg; -extern SerialUSBDriver SDU1; +extern SerialUSBDriver PORTAB_SDU1; #endif /* USBCFG_H */