fix pre-commit, remove svd file since they are heavy and should be in mcu/sdk instead

add cmake support for f403a_407 and f423
This commit is contained in:
hathach
2025-07-28 22:28:22 +07:00
parent f4843c0307
commit 3682b6c663
77 changed files with 496 additions and 249968 deletions

View File

@@ -109,7 +109,7 @@
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 0
#define INCLUDE_xTaskGetCurrentTaskHandle 0
#define INCLUDE_xTaskGetCurrentTaskHandle 1
#define INCLUDE_uxTaskGetStackHighWaterMark 0
#define INCLUDE_xTaskGetIdleTaskHandle 0
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0

View File

@@ -121,7 +121,7 @@ void system_clock_config(void)
#endif
#ifdef AT32F402xx
/* reduce power comsumption */
/* reduce power consumption */
reduce_power_consumption();
#endif
}

View File

@@ -41,4 +41,3 @@ void system_clock_config(void);
#endif
#endif

View File

@@ -137,4 +137,3 @@ void DebugMon_Handler(void)
/**
* @}
*/

View File

@@ -53,4 +53,3 @@ void SysTick_Handler(void);
#endif
#endif

View File

@@ -104,7 +104,7 @@ SECTIONS
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
@@ -119,7 +119,7 @@ SECTIONS
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
/* This is used by the startup in order to initialize the .bss section */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)

File diff suppressed because it is too large Load Diff

View File

@@ -55,7 +55,7 @@
#define PRINT_UART_TX_PIN_SOURCE GPIO_PINS_SOURCE9
#define PRINT_UART_TX_PIN_MUX_NUM GPIO_MUX_7
//USB
//USB
#ifdef BOARD_TUD_RHPORT
#if BOARD_TUD_RHPORT == 0
#define USB_ID USB_OTG1_ID

View File

@@ -36,11 +36,11 @@ void usb_gpio_config(void);
//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
//--------------------------------------------------------------------+
void OTGFS1_IRQHandler(void)
void OTGFS1_IRQHandler(void)
{
tusb_int_handler(0, true);
}
void OTGHS_IRQHandler(void)
void OTGHS_IRQHandler(void)
{
tusb_int_handler(1, true);
}
@@ -53,7 +53,7 @@ void OTGHS_WKUP_IRQHandler(void)
tusb_int_handler(1, true);
}
void board_init(void)
void board_init(void)
{
/* config nvic priority group */
nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
@@ -94,7 +94,7 @@ void board_init(void)
//--------------------------------------------------------------------+
// Board porting API
//--------------------------------------------------------------------+
void led_and_botton_init(void)
void led_and_botton_init(void)
{
/* LED */
gpio_init_type gpio_led_init_struct;
@@ -217,7 +217,7 @@ int board_uart_write(void const *buf, int len)
#if CFG_TUSB_OS == OPT_OS_NONE
int txsize = len;
u16 timeout = 0xffff;
while (txsize--)
while (txsize--)
{
while(usart_flag_get(PRINT_UART, USART_TDBE_FLAG) == RESET)
{
@@ -238,17 +238,17 @@ int board_uart_write(void const *buf, int len)
#endif
}
void board_led_write(bool state)
void board_led_write(bool state)
{
gpio_bits_write(LED_PORT, LED_PIN, state ^ (!LED_STATE_ON));
}
uint32_t board_button_read(void)
uint32_t board_button_read(void)
{
return gpio_input_data_bit_read(BUTTON_PORT, BUTTON_PIN);
}
size_t board_get_unique_id(uint8_t id[], size_t max_len)
size_t board_get_unique_id(uint8_t id[], size_t max_len)
{
(void) max_len;
volatile uint32_t * at32_uuid = ((volatile uint32_t*)0x1FFFF7E8);
@@ -264,11 +264,11 @@ size_t board_get_unique_id(uint8_t id[], size_t max_len)
#if CFG_TUSB_OS == OPT_OS_NONE
volatile uint32_t system_ticks = 0;
void SysTick_Handler(void)
void SysTick_Handler(void)
{
system_ticks++;
}
uint32_t board_millis(void)
uint32_t board_millis(void)
{
return system_ticks;
}
@@ -280,7 +280,7 @@ size_t board_get_unique_id(uint8_t id[], size_t max_len)
}
#endif
void HardFault_Handler(void)
void HardFault_Handler(void)
{
__asm("BKPT #0\n");
}
@@ -294,4 +294,3 @@ void assert_failed(const char *file, uint32_t line)
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

View File

@@ -1,6 +1,5 @@
# Submodules
AT32F402_405_SDK = hw/mcu/artery/at32f402_405
DEPS_SUBMODULES += $(AT32F402_405_SDK)
# AT32 SDK path
AT32F402_405_SDK_SRC = $(AT32F402_405_SDK)/libraries

View File

@@ -78,7 +78,7 @@ LoopFillZerobss:
cmp r2, r3
bcc FillZerobss
/* Call the clock system intitialization function.*/
/* Call the clock system initialization function.*/
bl SystemInit
/* Call static constructors */
bl __libc_init_array
@@ -104,7 +104,7 @@ Infinite_Loop:
* The minimal vector table for a Cortex M3. Note that the proper constructs
* must be placed on this to ensure that it ends up at physical address
* 0x0000.0000.
*
*
*******************************************************************************/
.section .isr_vector,"a",%progbits
.type g_pfnVectors, %object
@@ -128,7 +128,7 @@ g_pfnVectors:
.word 0
.word PendSV_Handler
.word SysTick_Handler
/* External Interrupts */
.word WWDT_IRQHandler /* Window Watchdog Timer */
.word PVM_IRQHandler /* PVM through EXINT Line detect */
@@ -237,20 +237,20 @@ g_pfnVectors:
/*******************************************************************************
*
* Provide weak aliases for each Exception handler to the Default_Handler.
* As they are weak aliases, any function with the same name will override
* Provide weak aliases for each Exception handler to the Default_Handler.
* As they are weak aliases, any function with the same name will override
* this definition.
*
*
*******************************************************************************/
.weak NMI_Handler
.thumb_set NMI_Handler,Default_Handler
.weak HardFault_Handler
.thumb_set HardFault_Handler,Default_Handler
.weak MemManage_Handler
.thumb_set MemManage_Handler,Default_Handler
.weak BusFault_Handler
.thumb_set BusFault_Handler,Default_Handler
@@ -267,10 +267,10 @@ g_pfnVectors:
.thumb_set PendSV_Handler,Default_Handler
.weak SysTick_Handler
.thumb_set SysTick_Handler,Default_Handler
.thumb_set SysTick_Handler,Default_Handler
.weak WWDT_IRQHandler
.thumb_set WWDT_IRQHandler,Default_Handler
.thumb_set WWDT_IRQHandler,Default_Handler
.weak PVM_IRQHandler
.thumb_set PVM_IRQHandler,Default_Handler
@@ -294,7 +294,7 @@ g_pfnVectors:
.thumb_set EXINT1_IRQHandler,Default_Handler
.weak EXINT2_IRQHandler
.thumb_set EXINT2_IRQHandler,Default_Handler
.thumb_set EXINT2_IRQHandler,Default_Handler
.weak EXINT3_IRQHandler
.thumb_set EXINT3_IRQHandler,Default_Handler
@@ -312,7 +312,7 @@ g_pfnVectors:
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
.weak DMA1_Channel4_IRQHandler
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
.weak DMA1_Channel5_IRQHandler
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
@@ -479,7 +479,7 @@ g_pfnVectors:
.weak QSPI1_IRQHandler
.thumb_set QSPI1_IRQHandler,Default_Handler
.weak DMAMUX_IRQHandler
.weak DMAMUX_IRQHandler
.thumb_set DMAMUX_IRQHandler ,Default_Handler
.weak ACC_IRQHandler

View File

@@ -109,7 +109,7 @@
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 0
#define INCLUDE_xTaskGetCurrentTaskHandle 0
#define INCLUDE_xTaskGetCurrentTaskHandle 1
#define INCLUDE_uxTaskGetStackHighWaterMark 0
#define INCLUDE_xTaskGetIdleTaskHandle 0
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0

View File

@@ -84,4 +84,4 @@ void system_clock_config(void)
/* update system_core_clock global variable */
system_core_clock_update();
}
}

View File

@@ -41,4 +41,3 @@ void system_clock_config(void);
#endif
#endif /* __AT32F403A_407_CLOCK_H */

View File

@@ -32,7 +32,7 @@ extern "C" {
/**
* @brief in the following line adjust the value of high speed exernal crystal (hext)
* @brief in the following line adjust the value of high speed external crystal (hext)
* used in your application
*
* tip: to avoid modifying this file each time you need to use different hext, you
@@ -40,11 +40,11 @@ extern "C" {
*
*/
#if !defined HEXT_VALUE
#define HEXT_VALUE ((uint32_t)8000000) /*!< value of the high speed exernal crystal in hz */
#define HEXT_VALUE ((uint32_t)8000000) /*!< value of the high speed external crystal in hz */
#endif
/**
* @brief in the following line adjust the high speed exernal crystal (hext) startup
* @brief in the following line adjust the high speed external crystal (hext) startup
* timeout value
*/
#define HEXT_STARTUP_TIMEOUT ((uint16_t)0x3000) /*!< time out for hext start up */

View File

@@ -53,4 +53,3 @@ void SysTick_Handler(void);
#endif
#endif

View File

@@ -104,7 +104,7 @@ SECTIONS
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
@@ -119,7 +119,7 @@ SECTIONS
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
/* This is used by the startup in order to initialize the .bss section */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
set(MCU_VARIANT AT32F403ACGU7)
set(JLINK_DEVICE ${MCU_VARIANT})
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/AT32F403AxG_FLASH.ld)
set(LD_FILE_IAR ${AT_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/AT32F403AxG.icf)
function(update_board TARGET)
target_compile_definitions(${TARGET} PUBLIC ${MCU_VARIANT})
endfunction()

View File

@@ -1,3 +1,4 @@
JLINK_DEVICE = at32f403acgu7
LD_FILE = $(BOARD_PATH)/AT32F403AxG_FLASH.ld
CFLAGS += \

View File

@@ -25,8 +25,8 @@
*/
#include "at32f403a_407_clock.h"
#include "bsp/board_api.h"
#include "board.h"
#include "bsp/board_api.h"
void usb_clock48m_select(usb_clk48_s clk_s);
void uart_print_init(uint32_t baudrate);
@@ -50,8 +50,7 @@ void USBFSWakeUp_IRQHandler(void) {
tud_int_handler(0);
}
void board_init(void)
{
void board_init(void) {
system_clock_config();
/* config nvic priority group */
@@ -62,7 +61,7 @@ void board_init(void)
/* configure systick */
systick_clock_source_config(SYSTICK_CLOCK_SOURCE_AHBCLK_NODIV);
/* enable usb clock */
crm_periph_clock_enable(CRM_USB_PERIPH_CLOCK, TRUE);
@@ -82,7 +81,7 @@ void board_init(void)
gpio_default_para_init(&gpio_led_init_struct);
/* configure the led gpio */
gpio_led_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
gpio_led_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
gpio_led_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
gpio_led_init_struct.gpio_mode = GPIO_MODE_OUTPUT;
gpio_led_init_struct.gpio_pins = LED_PIN;
gpio_led_init_struct.gpio_pull = GPIO_PULL_NONE;
@@ -114,10 +113,8 @@ void board_init(void)
* @param clk_s:USB_CLK_HICK, USB_CLK_HEXT
* @retval none
*/
void usb_clock48m_select(usb_clk48_s clk_s)
{
if(clk_s == USB_CLK_HICK)
{
void usb_clock48m_select(usb_clk48_s clk_s) {
if (clk_s == USB_CLK_HICK) {
crm_usb_clock_source_select(CRM_USB_CLOCK_SOURCE_HICK);
/* enable the acc calibration ready interrupt */
@@ -130,11 +127,8 @@ void usb_clock48m_select(usb_clk48_s clk_s)
/* open acc calibration */
acc_calibration_mode_enable(ACC_CAL_HICKTRIM, TRUE);
}
else
{
switch(system_core_clock)
{
} else {
switch (system_core_clock) {
/* 48MHz */
case 48000000:
crm_usb_clock_div_set(CRM_USB_DIV_1);
@@ -172,13 +166,11 @@ void usb_clock48m_select(usb_clk48_s clk_s)
default:
break;
}
}
}
void uart_print_init(uint32_t baudrate)
{
void uart_print_init(uint32_t baudrate) {
gpio_init_type gpio_init_struct;
/* enable the uart and gpio clock */
crm_periph_clock_enable(PRINT_UART_CRM_CLK, TRUE);
@@ -186,7 +178,7 @@ void uart_print_init(uint32_t baudrate)
gpio_default_para_init(&gpio_init_struct);
/* configure the uart tx pin */
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
gpio_init_struct.gpio_pins = PRINT_UART_TX_PIN;
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
@@ -207,8 +199,8 @@ uint32_t board_button_read(void) {
size_t board_get_unique_id(uint8_t id[], size_t max_len) {
(void) max_len;
volatile uint32_t * at32_uuid = ((volatile uint32_t*)0x1FFFF7E8);
uint32_t* id32 = (uint32_t*) (uintptr_t) id;
volatile uint32_t *at32_uuid = ((volatile uint32_t *) 0x1FFFF7E8);
uint32_t *id32 = (uint32_t *) (uintptr_t) id;
uint8_t const len = 12;
id32[0] = at32_uuid[0];
@@ -224,61 +216,57 @@ int board_uart_read(uint8_t *buf, int len) {
return 0;
}
int board_uart_write(void const *buf, int len)
{
#if CFG_TUSB_OS == OPT_OS_NONE
int txsize = len;
u16 timeout = 0xffff;
while (txsize--)
{
while(usart_flag_get(PRINT_UART, USART_TDBE_FLAG) == RESET)
{
timeout--;
if(timeout == 0)
{
return 0;
}
int board_uart_write(void const *buf, int len) {
#if CFG_TUSB_OS == OPT_OS_NONE
int txsize = len;
u16 timeout = 0xffff;
while (txsize--) {
while (usart_flag_get(PRINT_UART, USART_TDBE_FLAG) == RESET) {
timeout--;
if (timeout == 0) {
return 0;
}
PRINT_UART->dt = (*((uint8_t const *)buf) & 0x01FF);
buf++;
}
return len;
#else
(void) buf;
(void) len;
return 0;
#endif
PRINT_UART->dt = (*((uint8_t const *) buf) & 0x01FF);
buf++;
}
return len;
#else
(void) buf;
(void) len;
return 0;
#endif
}
#if CFG_TUSB_OS == OPT_OS_NONE
volatile uint32_t system_ticks = 0;
void SysTick_Handler(void)
{
system_ticks++;
}
volatile uint32_t system_ticks = 0;
void SysTick_Handler(void) {
system_ticks++;
}
uint32_t board_millis(void)
{
return system_ticks;
}
void SVC_Handler(void)
{
}
uint32_t board_millis(void) {
return system_ticks;
}
void PendSV_Handler(void)
{
}
void SVC_Handler(void) {
}
void PendSV_Handler(void) {
}
#endif
void HardFault_Handler(void) {
__asm("BKPT #0\n");
}
#ifdef USE_FULL_ASSERT
void assert_failed(const char *file, uint32_t line)
{
// Required by __libc_init_array in startup code if we are compiling using
// -nostdlib/-nostartfiles.
void _init(void) {
}
#ifdef USE_FULL_ASSERT
void assert_failed(const char *file, uint32_t line) {
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

View File

@@ -0,0 +1,102 @@
include_guard()
set(AT_FAMILY at32f403a_407)
set(AT_SDK_LIB ${TOP}/hw/mcu/artery/${AT_FAMILY}/libraries)
# include board specific
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
# toolchain set up
set(CMAKE_SYSTEM_CPU cortex-m4 CACHE INTERNAL "System Processor")
set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
set(FAMILY_MCUS AT32F403A_407 CACHE INTERNAL "")
#------------------------------------
# BOARD_TARGET
#------------------------------------
# only need to be built ONCE for all examples
function(add_board_target BOARD_TARGET)
if (TARGET ${BOARD_TARGET})
return()
endif ()
# Startup & Linker script
set(STARTUP_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/startup_${AT_FAMILY}.s)
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
set(STARTUP_FILE_IAR ${AT_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT_FAMILY}.s)
set(LD_FILE_Clang ${LD_FILE_GNU})
add_library(${BOARD_TARGET} STATIC
${AT_SDK_LIB}/cmsis/cm4/device_support/system_${AT_FAMILY}.c
${AT_SDK_LIB}/drivers/src/${AT_FAMILY}_gpio.c
${AT_SDK_LIB}/drivers/src/${AT_FAMILY}_misc.c
${AT_SDK_LIB}/drivers/src/${AT_FAMILY}_usart.c
${AT_SDK_LIB}/drivers/src/${AT_FAMILY}_acc.c
${AT_SDK_LIB}/drivers/src/${AT_FAMILY}_crm.c
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${AT_SDK_LIB}/cmsis/cm4/core_support
${AT_SDK_LIB}/cmsis/cm4/device_support
${AT_SDK_LIB}/drivers/inc
)
update_board(${BOARD_TARGET})
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${LD_FILE_GNU}"
-nostartfiles
--specs=nosys.specs --specs=nano.specs
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${LD_FILE_Clang}"
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--config=${LD_FILE_IAR}"
)
endif ()
endfunction()
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
# Board target
add_board_target(board_${BOARD})
#---------- Port Specific ----------
# These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
# BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT_FAMILY}_clock.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT_FAMILY}_int.c
)
target_include_directories(${TARGET} PUBLIC
# family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
# Add TinyUSB target and port source
family_add_tinyusb(${TARGET} OPT_MCU_AT32F403A_407)
target_sources(${TARGET} PUBLIC
${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
)
target_link_libraries(${TARGET} PUBLIC board_${BOARD})
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${TARGET})
endfunction()

View File

@@ -1,6 +1,5 @@
# Submodules
AT32F403A_407_SDK = hw/mcu/artery/at32f403a_407
DEPS_SUBMODULES += $(AT32F403A_407_SDK)
# AT32 SDK path
AT32F403A_407_SDK_SRC = $(AT32F403A_407_SDK)/libraries
@@ -16,7 +15,7 @@ CFLAGS += \
-DCFG_TUSB_MCU=OPT_MCU_AT32F403A_407
LDFLAGS_GCC += \
-flto --specs=nosys.specs
-flto --specs=nosys.specs -nostdlib -nostartfiles
SRC_C += \
src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \

View File

@@ -78,7 +78,7 @@ LoopFillZerobss:
cmp r2, r3
bcc FillZerobss
/* Call the clock system intitialization function.*/
/* Call the clock system initialization function.*/
bl SystemInit
/* Call static constructors */
bl __libc_init_array

View File

@@ -109,7 +109,7 @@
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 0
#define INCLUDE_xTaskGetCurrentTaskHandle 0
#define INCLUDE_xTaskGetCurrentTaskHandle 1
#define INCLUDE_uxTaskGetStackHighWaterMark 0
#define INCLUDE_xTaskGetIdleTaskHandle 0
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0

View File

@@ -41,4 +41,3 @@ void system_clock_config(void);
#endif
#endif /* __AT32F413_CLOCK_H */

View File

@@ -137,5 +137,3 @@ void DebugMon_Handler(void)
/**
* @}
*/

View File

@@ -53,4 +53,3 @@ void SysTick_Handler(void);
#endif
#endif

View File

@@ -105,7 +105,7 @@ SECTIONS
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
@@ -118,7 +118,7 @@ SECTIONS
_spim_init_base = LOADADDR(.spim);
_spim_init_length = SIZEOF(.spim);
.spim :
{
. = ALIGN(4);
@@ -133,7 +133,7 @@ SECTIONS
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
/* This is used by the startup in order to initialize the .bss section */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)

File diff suppressed because it is too large Load Diff

View File

@@ -52,7 +52,7 @@
static inline void board_vbus_sense_init(void)
{
}
#ifdef __cplusplus

View File

@@ -50,7 +50,7 @@ void USBFSWakeUp_IRQHandler(void) {
tud_int_handler(0);
}
void board_init(void)
void board_init(void)
{
system_clock_config();
@@ -62,7 +62,7 @@ void board_init(void)
/* configure systick */
systick_clock_source_config(SYSTICK_CLOCK_SOURCE_AHBCLK_NODIV);
/* enable usb clock */
crm_periph_clock_enable(CRM_USB_PERIPH_CLOCK, TRUE);
@@ -228,7 +228,7 @@ int board_uart_write(void const *buf, int len)
#if CFG_TUSB_OS == OPT_OS_NONE
int txsize = len;
u16 timeout = 0xffff;
while (txsize--)
while (txsize--)
{
while(usart_flag_get(PRINT_UART, USART_TDBE_FLAG) == RESET)
{
@@ -252,16 +252,16 @@ int board_uart_write(void const *buf, int len)
#if CFG_TUSB_OS == OPT_OS_NONE
volatile uint32_t system_ticks = 0;
void SysTick_Handler(void)
void SysTick_Handler(void)
{
system_ticks++;
}
uint32_t board_millis(void)
uint32_t board_millis(void)
{
return system_ticks;
}
void SVC_Handler(void)
{
}

View File

@@ -1,6 +1,5 @@
# Submodules
AT32F413_SDK = hw/mcu/artery/at32f413
DEPS_SUBMODULES += $(AT32F413_SDK)
# AT32 SDK path
AT32F413_SDK_SRC = $(AT32F413_SDK)/libraries

View File

@@ -78,7 +78,7 @@ LoopFillZerobss:
cmp r2, r3
bcc FillZerobss
/* Call the clock system intitialization function.*/
/* Call the clock system initialization function.*/
bl SystemInit
/* Call static constructors */
bl __libc_init_array

View File

@@ -109,7 +109,7 @@
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 0
#define INCLUDE_xTaskGetCurrentTaskHandle 0
#define INCLUDE_xTaskGetCurrentTaskHandle 1
#define INCLUDE_uxTaskGetStackHighWaterMark 0
#define INCLUDE_xTaskGetIdleTaskHandle 0
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0

View File

@@ -5,11 +5,11 @@
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -46,8 +46,8 @@
void system_clock_config(void)
{
/* config flash psr register */
flash_psr_set(FLASH_WAIT_CYCLE_4);
flash_psr_set(FLASH_WAIT_CYCLE_4);
/* reset crm */
crm_reset();

View File

@@ -5,11 +5,11 @@
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -41,4 +41,3 @@ void system_clock_config(void);
#endif
#endif /* __AT32F415_CLOCK_H */

View File

@@ -5,11 +5,11 @@
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -141,5 +141,3 @@ extern "C" {
#endif
#endif /* __AT32F415_CONF_H */

View File

@@ -5,11 +5,11 @@
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -28,11 +28,11 @@
/** @addtogroup AT32F415_periph_examples
* @{
*/
/** @addtogroup 415_CRC_calculation
* @{
*/
/**
* @brief this function handles nmi exception.
* @param none
@@ -52,9 +52,9 @@ void MemManage_Handler(void)
/* go to infinite loop when memory manage exception occurs */
while(1)
{
{
}
}
/**
@@ -112,8 +112,8 @@ void DebugMon_Handler(void)
/**
* @}
*/
*/
/**
* @}
*/
*/

View File

@@ -5,11 +5,11 @@
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -53,4 +53,3 @@ void SysTick_Handler(void);
#endif
#endif

View File

@@ -104,7 +104,7 @@ SECTIONS
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
@@ -119,7 +119,7 @@ SECTIONS
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
/* This is used by the startup in order to initialize the .bss section */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)

File diff suppressed because it is too large Load Diff

View File

@@ -35,16 +35,16 @@ void led_and_button_init(void);
//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
//--------------------------------------------------------------------+
void OTGFS1_IRQHandler(void)
void OTGFS1_IRQHandler(void)
{
tusb_int_handler(0, true);
}
void OTGFS1_WKUP_IRQHandler(void)
void OTGFS1_WKUP_IRQHandler(void)
{
tusb_int_handler(0, true);
}
void board_init(void)
void board_init(void)
{
/* config nvic priority group */
nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
@@ -85,7 +85,7 @@ void board_init(void)
/* config led and key */
led_and_button_init();
/* config usart printf */
uart_print_init(115200);
printf("usart printf config success!\r\n");
@@ -128,13 +128,13 @@ void usb_clock48m_select(usb_clk48_s clk_s)
case 144000000:
crm_usb_clock_div_set(CRM_USB_DIV_3);
break;
default:
break;
}
}
void led_and_button_init(void)
void led_and_button_init(void)
{
/* LED */
gpio_init_type gpio_led_init_struct;
@@ -190,7 +190,7 @@ void uart_print_init(uint32_t baudrate)
}
// Get characters from UART. Return number of read bytes
int board_uart_read(uint8_t *buf, int len)
int board_uart_read(uint8_t *buf, int len)
{
(void) buf;
(void) len;
@@ -203,7 +203,7 @@ int board_uart_write(void const *buf, int len)
#if CFG_TUSB_OS == OPT_OS_NONE
int txsize = len;
u16 timeout = 0xffff;
while (txsize--)
while (txsize--)
{
while(usart_flag_get(PRINT_UART, USART_TDBE_FLAG) == RESET)
{
@@ -224,17 +224,17 @@ int board_uart_write(void const *buf, int len)
#endif
}
void board_led_write(bool state)
void board_led_write(bool state)
{
gpio_bits_write(LED_PORT, LED_PIN, state ^ (!LED_STATE_ON));
}
uint32_t board_button_read(void)
uint32_t board_button_read(void)
{
return gpio_input_data_bit_read(BUTTON_PORT, BUTTON_PIN);
}
size_t board_get_unique_id(uint8_t id[], size_t max_len)
size_t board_get_unique_id(uint8_t id[], size_t max_len)
{
(void) max_len;
volatile uint32_t * at32_uuid = ((volatile uint32_t*)0x1FFFF7E8);
@@ -252,12 +252,12 @@ size_t board_get_unique_id(uint8_t id[], size_t max_len)
#if CFG_TUSB_OS == OPT_OS_NONE
volatile uint32_t system_ticks = 0;
void SysTick_Handler(void)
void SysTick_Handler(void)
{
system_ticks++;
}
uint32_t board_millis(void)
uint32_t board_millis(void)
{
return system_ticks;
}
@@ -271,7 +271,7 @@ size_t board_get_unique_id(uint8_t id[], size_t max_len)
}
#endif
void HardFault_Handler(void)
void HardFault_Handler(void)
{
__asm("BKPT #0\n");
}

View File

@@ -1,6 +1,5 @@
# Submodules
AT32F415_SDK = hw/mcu/artery/at32f415
DEPS_SUBMODULES += $(AT32F415_SDK)
# AT32 SDK path
AT32F415_SDK_SRC = $(AT32F415_SDK)/libraries

View File

@@ -78,7 +78,7 @@ LoopFillZerobss:
cmp r2, r3
bcc FillZerobss
/* Call the clock system intitialization function.*/
/* Call the clock system initialization function.*/
bl SystemInit
/* Call static constructors */
bl __libc_init_array

View File

@@ -109,7 +109,7 @@
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 0
#define INCLUDE_xTaskGetCurrentTaskHandle 0
#define INCLUDE_xTaskGetCurrentTaskHandle 1
#define INCLUDE_uxTaskGetStackHighWaterMark 0
#define INCLUDE_xTaskGetIdleTaskHandle 0
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0

View File

@@ -125,4 +125,3 @@ void system_clock_config(void)
/**
* @}
*/

View File

@@ -41,4 +41,3 @@ void system_clock_config(void);
#endif
#endif

View File

@@ -137,4 +137,3 @@ void DebugMon_Handler(void)
/**
* @}
*/

View File

@@ -53,4 +53,3 @@ void SysTick_Handler(void);
#endif
#endif

View File

@@ -104,7 +104,7 @@ SECTIONS
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
@@ -119,7 +119,7 @@ SECTIONS
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
/* This is used by the startup in order to initialize the .bss section */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
set(MCU_VARIANT AT32F423VCT7)
set(JLINK_DEVICE ${MCU_VARIANT})
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/AT32F423xC_FLASH.ld)
set(LD_FILE_IAR ${AT_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/AT32F423xC.icf)
function(update_board TARGET)
target_compile_definitions(${TARGET} PUBLIC ${MCU_VARIANT})
endfunction()

View File

@@ -1,3 +1,4 @@
JLINK_DEVICE = AT32F423VCT7
LD_FILE = $(BOARD_PATH)/AT32F423xC_FLASH.ld
CFLAGS += \

View File

@@ -25,8 +25,8 @@
*/
#include "at32f423_clock.h"
#include "bsp/board_api.h"
#include "board.h"
#include "bsp/board_api.h"
void usb_clock48m_select(usb_clk48_s clk_s);
void led_and_button_init(void);
@@ -34,17 +34,14 @@ void uart_print_init(uint32_t baudrate);
//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
//--------------------------------------------------------------------+
void OTGFS1_IRQHandler(void)
{
void OTGFS1_IRQHandler(void) {
tusb_int_handler(0, true);
}
void OTGFS1_WKUP_IRQHandler(void)
{
void OTGFS1_WKUP_IRQHandler(void) {
tusb_int_handler(0, true);
}
void board_init(void)
{
void board_init(void) {
/* config nvic priority group */
nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
@@ -63,24 +60,24 @@ void board_init(void)
/* configure systick */
systick_clock_source_config(SYSTICK_CLOCK_SOURCE_AHBCLK_NODIV);
SysTick_Config(SystemCoreClock / 1000);
#if CFG_TUSB_OS == OPT_OS_FREERTOS
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
NVIC_SetPriority(OTG_IRQ, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
#endif
#if CFG_TUSB_OS == OPT_OS_FREERTOS
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
NVIC_SetPriority(OTG_IRQ, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
#endif
/* otgfs use vbus pin */
#ifndef USB_VBUS_IGNORE
gpio_init_type gpio_init_struct;
crm_periph_clock_enable(OTG_PIN_GPIO_CLOCK, TRUE);
gpio_default_para_init(&gpio_init_struct);
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
gpio_init_struct.gpio_pins = OTG_PIN_VBUS;
gpio_init_struct.gpio_pull = GPIO_PULL_DOWN;
gpio_pin_mux_config(OTG_PIN_GPIO, OTG_PIN_VBUS_SOURCE, OTG_PIN_MUX);
gpio_init(OTG_PIN_GPIO, &gpio_init_struct);
#endif
/* otgfs use vbus pin */
#ifndef USB_VBUS_IGNORE
gpio_init_type gpio_init_struct;
crm_periph_clock_enable(OTG_PIN_GPIO_CLOCK, TRUE);
gpio_default_para_init(&gpio_init_struct);
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
gpio_init_struct.gpio_pins = OTG_PIN_VBUS;
gpio_init_struct.gpio_pull = GPIO_PULL_DOWN;
gpio_pin_mux_config(OTG_PIN_GPIO, OTG_PIN_VBUS_SOURCE, OTG_PIN_MUX);
gpio_init(OTG_PIN_GPIO, &gpio_init_struct);
#endif
/* config led and key */
led_and_button_init();
@@ -98,10 +95,8 @@ void board_init(void)
* @param clk_s:USB_CLK_HICK, USB_CLK_HEXT
* @retval none
*/
void usb_clock48m_select(usb_clk48_s clk_s)
{
if(clk_s == USB_CLK_HICK)
{
void usb_clock48m_select(usb_clk48_s clk_s) {
if (clk_s == USB_CLK_HICK) {
crm_usb_clock_source_select(CRM_USB_CLOCK_SOURCE_HICK);
/* enable the acc calibration ready interrupt */
@@ -114,11 +109,8 @@ void usb_clock48m_select(usb_clk48_s clk_s)
/* open acc calibration */
acc_calibration_mode_enable(ACC_CAL_HICKTRIM, TRUE);
}
else
{
switch(system_core_clock)
{
} else {
switch (system_core_clock) {
/* 48MHz */
case 48000000:
crm_usb_clock_div_set(CRM_USB_DIV_2);
@@ -138,7 +130,7 @@ void usb_clock48m_select(usb_clk48_s clk_s)
case 120000000:
crm_usb_clock_div_set(CRM_USB_DIV_5);
break;
/* 144MHz */
case 144000000:
crm_usb_clock_div_set(CRM_USB_DIV_6);
@@ -149,8 +141,7 @@ void usb_clock48m_select(usb_clk48_s clk_s)
}
}
}
void uart_print_init(uint32_t baudrate)
{
void uart_print_init(uint32_t baudrate) {
gpio_init_type gpio_init_struct;
/* enable the uart and gpio clock */
crm_periph_clock_enable(PRINT_UART_CRM_CLK, TRUE);
@@ -158,7 +149,7 @@ void uart_print_init(uint32_t baudrate)
gpio_default_para_init(&gpio_init_struct);
/* configure the uart tx pin */
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
gpio_init_struct.gpio_pins = PRINT_UART_TX_PIN;
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
@@ -170,8 +161,7 @@ void uart_print_init(uint32_t baudrate)
usart_enable(PRINT_UART, TRUE);
}
void led_and_button_init(void)
{
void led_and_button_init(void) {
/* LED */
gpio_init_type gpio_led_init_struct;
/* enable the led clock */
@@ -180,7 +170,7 @@ void led_and_button_init(void)
gpio_default_para_init(&gpio_led_init_struct);
/* configure the led gpio */
gpio_led_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
gpio_led_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
gpio_led_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
gpio_led_init_struct.gpio_mode = GPIO_MODE_OUTPUT;
gpio_led_init_struct.gpio_pins = LED_PIN;
gpio_led_init_struct.gpio_pull = GPIO_PULL_NONE;
@@ -200,21 +190,18 @@ void led_and_button_init(void)
gpio_init(BUTTON_PORT, &gpio_button_init_struct);
}
void board_led_write(bool state)
{
void board_led_write(bool state) {
gpio_bits_write(LED_PORT, LED_PIN, state ^ (!LED_STATE_ON));
}
uint32_t board_button_read(void)
{
uint32_t board_button_read(void) {
return gpio_input_data_bit_read(BUTTON_PORT, BUTTON_PIN);
}
size_t board_get_unique_id(uint8_t id[], size_t max_len)
{
size_t board_get_unique_id(uint8_t id[], size_t max_len) {
(void) max_len;
volatile uint32_t * at32_uuid = ((volatile uint32_t*)0x1FFFF7E8);
uint32_t* id32 = (uint32_t*) (uintptr_t) id;
volatile uint32_t *at32_uuid = ((volatile uint32_t *) 0x1FFFF7E8);
uint32_t *id32 = (uint32_t *) (uintptr_t) id;
uint8_t const len = 12;
id32[0] = at32_uuid[0];
@@ -224,68 +211,62 @@ size_t board_get_unique_id(uint8_t id[], size_t max_len)
return len;
}
int board_uart_read(uint8_t *buf, int len)
{
int board_uart_read(uint8_t *buf, int len) {
(void) buf;
(void) len;
return 0;
}
int board_uart_write(void const *buf, int len)
{
#if CFG_TUSB_OS == OPT_OS_NONE
int txsize = len;
u16 timeout = 0xffff;
while (txsize--)
{
while(usart_flag_get(PRINT_UART, USART_TDBE_FLAG) == RESET)
{
timeout--;
if(timeout == 0)
{
return 0;
}
int board_uart_write(void const *buf, int len) {
#if CFG_TUSB_OS == OPT_OS_NONE
int txsize = len;
u16 timeout = 0xffff;
while (txsize--) {
while (usart_flag_get(PRINT_UART, USART_TDBE_FLAG) == RESET) {
timeout--;
if (timeout == 0) {
return 0;
}
PRINT_UART->dt = (*((uint8_t const *)buf) & 0x01FF);
buf++;
}
return len;
#else
(void) buf;
(void) len;
return 0;
#endif
PRINT_UART->dt = (*((uint8_t const *) buf) & 0x01FF);
buf++;
}
return len;
#else
(void) buf;
(void) len;
return 0;
#endif
}
#if CFG_TUSB_OS == OPT_OS_NONE
volatile uint32_t system_ticks = 0;
void SysTick_Handler(void)
{
system_ticks++;
}
volatile uint32_t system_ticks = 0;
void SysTick_Handler(void) {
system_ticks++;
}
uint32_t board_millis(void)
{
return system_ticks;
}
uint32_t board_millis(void) {
return system_ticks;
}
void SVC_Handler(void)
{
}
void SVC_Handler(void) {
}
void PendSV_Handler(void)
{
}
void PendSV_Handler(void) {
}
#endif
void HardFault_Handler(void)
{
void HardFault_Handler(void) {
__asm("BKPT #0\n");
}
#ifdef USE_FULL_ASSERT
void assert_failed(const char *file, uint32_t line)
{
// Required by __libc_init_array in startup code if we are compiling using
// -nostdlib/-nostartfiles.
// void _init(void) {
// }
#ifdef USE_FULL_ASSERT
void assert_failed(const char *file, uint32_t line) {
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

View File

@@ -0,0 +1,104 @@
include_guard()
set(AT_FAMILY at32f423)
set(AT_SDK_LIB ${TOP}/hw/mcu/artery/${AT_FAMILY}/libraries)
# include board specific
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
# toolchain set up
set(CMAKE_SYSTEM_CPU cortex-m4 CACHE INTERNAL "System Processor")
set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
set(FAMILY_MCUS AT32F423 CACHE INTERNAL "")
#------------------------------------
# BOARD_TARGET
#------------------------------------
# only need to be built ONCE for all examples
function(add_board_target BOARD_TARGET)
if (TARGET ${BOARD_TARGET})
return()
endif ()
# Startup & Linker script
set(STARTUP_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/startup_${AT_FAMILY}.s)
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
set(STARTUP_FILE_IAR ${AT_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT_FAMILY}.s)
set(LD_FILE_Clang ${LD_FILE_GNU})
add_library(${BOARD_TARGET} STATIC
${AT_SDK_LIB}/cmsis/cm4/device_support/system_${AT_FAMILY}.c
${AT_SDK_LIB}/drivers/src/${AT_FAMILY}_gpio.c
${AT_SDK_LIB}/drivers/src/${AT_FAMILY}_misc.c
${AT_SDK_LIB}/drivers/src/${AT_FAMILY}_usart.c
${AT_SDK_LIB}/drivers/src/${AT_FAMILY}_acc.c
${AT_SDK_LIB}/drivers/src/${AT_FAMILY}_crm.c
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${AT_SDK_LIB}/cmsis/cm4/core_support
${AT_SDK_LIB}/cmsis/cm4/device_support
${AT_SDK_LIB}/drivers/inc
)
update_board(${BOARD_TARGET})
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${LD_FILE_GNU}"
-nostartfiles
--specs=nosys.specs --specs=nano.specs
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${LD_FILE_Clang}"
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--config=${LD_FILE_IAR}"
)
endif ()
endfunction()
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
# Board target
add_board_target(board_${BOARD})
#---------- Port Specific ----------
# These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
# BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT_FAMILY}_clock.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT_FAMILY}_int.c
)
target_include_directories(${TARGET} PUBLIC
# family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
# Add TinyUSB target and port source
family_add_tinyusb(${TARGET} OPT_MCU_AT32F423)
target_sources(${TARGET} PUBLIC
${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
)
target_link_libraries(${TARGET} PUBLIC board_${BOARD})
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${TARGET})
endfunction()

View File

@@ -1,6 +1,6 @@
# Submodules
JLINK_DEVICE = AT32F423VCT7
AT32F423_SDK = hw/mcu/artery/at32f423
DEPS_SUBMODULES += $(AT32F423_SDK)
# AT32 SDK path
AT32F423_SDK_SRC = $(AT32F423_SDK)/libraries
@@ -16,7 +16,7 @@ CFLAGS += \
-DCFG_TUSB_MCU=OPT_MCU_AT32F423 \
LDFLAGS_GCC += \
-flto --specs=nosys.specs
-flto --specs=nosys.specs -nostdlib -nostartfiles
SRC_C += \
src/portable/synopsys/dwc2/dcd_dwc2.c \

View File

@@ -78,7 +78,7 @@ LoopFillZerobss:
cmp r2, r3
bcc FillZerobss
/* Call the clock system intitialization function.*/
/* Call the clock system initialization function.*/
bl SystemInit
/* Call static constructors */
bl __libc_init_array

View File

@@ -109,7 +109,7 @@
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 0
#define INCLUDE_xTaskGetCurrentTaskHandle 0
#define INCLUDE_xTaskGetCurrentTaskHandle 1
#define INCLUDE_uxTaskGetStackHighWaterMark 0
#define INCLUDE_xTaskGetIdleTaskHandle 0
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0

View File

@@ -41,4 +41,3 @@ void system_clock_config(void);
#endif
#endif

View File

@@ -137,4 +137,3 @@ void DebugMon_Handler(void)
/**
* @}
*/

View File

@@ -53,4 +53,3 @@ void SysTick_Handler(void);
#endif
#endif

View File

@@ -103,7 +103,7 @@ SECTIONS
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
@@ -118,7 +118,7 @@ SECTIONS
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
/* This is used by the startup in order to initialize the .bss section */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)

File diff suppressed because it is too large Load Diff

View File

@@ -35,16 +35,16 @@ void led_and_button_init(void);
//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
//--------------------------------------------------------------------+
void OTGFS1_IRQHandler(void)
void OTGFS1_IRQHandler(void)
{
tusb_int_handler(0, true);
}
void OTGFS1_WKUP_IRQHandler(void)
void OTGFS1_WKUP_IRQHandler(void)
{
tusb_int_handler(0, true);
}
void board_init(void)
void board_init(void)
{
/* config nvic priority group */
nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
@@ -85,7 +85,7 @@ void board_init(void)
/* config led and key */
led_and_button_init();
/* config usart printf */
uart_print_init(115200);
printf("usart printf config success!\r\n");
@@ -120,7 +120,7 @@ void usb_clock48m_select(usb_clk48_s clk_s)
{
/* usb divider reset */
crm_usb_div_reset();
switch(system_core_clock)
{
/* 48MHz */
@@ -144,7 +144,7 @@ void usb_clock48m_select(usb_clk48_s clk_s)
}
}
void led_and_button_init(void)
void led_and_button_init(void)
{
/* LED */
gpio_init_type gpio_led_init_struct;
@@ -201,7 +201,7 @@ void uart_print_init(uint32_t baudrate)
}
// Get characters from UART. Return number of read bytes
int board_uart_read(uint8_t *buf, int len)
int board_uart_read(uint8_t *buf, int len)
{
(void) buf;
(void) len;
@@ -214,7 +214,7 @@ int board_uart_write(void const *buf, int len)
#if CFG_TUSB_OS == OPT_OS_NONE
int txsize = len;
u16 timeout = 0xffff;
while (txsize--)
while (txsize--)
{
while(usart_flag_get(PRINT_UART, USART_TDBE_FLAG) == RESET)
{
@@ -235,17 +235,17 @@ int board_uart_write(void const *buf, int len)
#endif
}
void board_led_write(bool state)
void board_led_write(bool state)
{
gpio_bits_write(LED_PORT, LED_PIN, state ^ (!LED_STATE_ON));
}
uint32_t board_button_read(void)
uint32_t board_button_read(void)
{
return gpio_input_data_bit_read(BUTTON_PORT, BUTTON_PIN);
}
size_t board_get_unique_id(uint8_t id[], size_t max_len)
size_t board_get_unique_id(uint8_t id[], size_t max_len)
{
(void) max_len;
volatile uint32_t * at32_uuid = ((volatile uint32_t*)0x1FFFF7E8);
@@ -263,12 +263,12 @@ size_t board_get_unique_id(uint8_t id[], size_t max_len)
#if CFG_TUSB_OS == OPT_OS_NONE
volatile uint32_t system_ticks = 0;
void SysTick_Handler(void)
void SysTick_Handler(void)
{
system_ticks++;
}
uint32_t board_millis(void)
uint32_t board_millis(void)
{
return system_ticks;
}
@@ -282,7 +282,7 @@ size_t board_get_unique_id(uint8_t id[], size_t max_len)
}
#endif
void HardFault_Handler(void)
void HardFault_Handler(void)
{
__asm("BKPT #0\n");
}

View File

@@ -1,6 +1,5 @@
# Submodules
AT32F425_SDK = hw/mcu/artery/at32f425
DEPS_SUBMODULES += $(AT32F425_SDK)
# AT32 SDK path
AT32F425_SDK_SRC = $(AT32F425_SDK)/libraries

View File

@@ -78,7 +78,7 @@ LoopFillZerobss:
cmp r2, r3
bcc FillZerobss
/* Call the clock system intitialization function.*/
/* Call the clock system initialization function.*/
bl SystemInit
/* Call static constructors */
bl __libc_init_array

View File

@@ -109,7 +109,7 @@
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 0
#define INCLUDE_xTaskGetCurrentTaskHandle 0
#define INCLUDE_xTaskGetCurrentTaskHandle 1
#define INCLUDE_uxTaskGetStackHighWaterMark 0
#define INCLUDE_xTaskGetIdleTaskHandle 0
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0

View File

@@ -41,4 +41,3 @@ void system_clock_config(void);
#endif
#endif

View File

@@ -117,4 +117,3 @@ void DebugMon_Handler(void)
/**
* @}
*/

View File

@@ -53,4 +53,3 @@ void SysTick_Handler(void);
#endif
#endif

View File

@@ -104,7 +104,7 @@ SECTIONS
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
@@ -119,7 +119,7 @@ SECTIONS
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
/* This is used by the startup in order to initialize the .bss section */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)

File diff suppressed because it is too large Load Diff

View File

@@ -36,11 +36,11 @@ int inHandlerMode(void);
//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
//--------------------------------------------------------------------+
void OTGFS1_IRQHandler(void)
void OTGFS1_IRQHandler(void)
{
tusb_int_handler(0, true);
}
void OTGFS2_IRQHandler(void)
void OTGFS2_IRQHandler(void)
{
tusb_int_handler(1, true);
}
@@ -53,7 +53,7 @@ void OTGFS2_WKUP_IRQHandler(void)
tusb_int_handler(1, true);
}
void board_init(void)
void board_init(void)
{
/* config nvic priority group */
nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
@@ -185,7 +185,7 @@ void usb_clock48m_select(usb_clk48_s clk_s)
}
}
void led_and_botton_init(void)
void led_and_botton_init(void)
{
/* LED */
gpio_init_type gpio_led_init_struct;
@@ -245,7 +245,7 @@ void uart_print_init(uint32_t baudrate)
}
// Get characters from UART. Return number of read bytes
int board_uart_read(uint8_t *buf, int len)
int board_uart_read(uint8_t *buf, int len)
{
(void) buf;
(void) len;
@@ -257,7 +257,7 @@ int board_uart_write(void const *buf, int len)
#if CFG_TUSB_OS == OPT_OS_NONE
int txsize = len;
u16 timeout = 0xffff;
while (txsize--)
while (txsize--)
{
while(usart_flag_get(PRINT_UART, USART_TDBE_FLAG) == RESET)
{
@@ -280,7 +280,7 @@ int board_uart_write(void const *buf, int len)
int inHandlerMode(void)
{
return __get_IPSR();
return __get_IPSR();
}
void usb_gpio_config(void)
@@ -312,17 +312,17 @@ void usb_gpio_config(void)
#endif
}
void board_led_write(bool state)
void board_led_write(bool state)
{
gpio_bits_write(LED_PORT, LED_PIN, state ^ (!LED_STATE_ON));
}
uint32_t board_button_read(void)
uint32_t board_button_read(void)
{
return gpio_input_data_bit_read(BUTTON_PORT, BUTTON_PIN);
}
size_t board_get_unique_id(uint8_t id[], size_t max_len)
size_t board_get_unique_id(uint8_t id[], size_t max_len)
{
(void) max_len;
volatile uint32_t * at32_uuid = ((volatile uint32_t*)0x1FFFF7E8);
@@ -338,11 +338,11 @@ size_t board_get_unique_id(uint8_t id[], size_t max_len)
#if CFG_TUSB_OS == OPT_OS_NONE
volatile uint32_t system_ticks = 0;
void SysTick_Handler(void)
void SysTick_Handler(void)
{
system_ticks++;
}
uint32_t board_millis(void)
uint32_t board_millis(void)
{
return system_ticks;
}
@@ -354,7 +354,7 @@ size_t board_get_unique_id(uint8_t id[], size_t max_len)
}
#endif
void HardFault_Handler(void)
void HardFault_Handler(void)
{
__asm("BKPT #0\n");
}

View File

@@ -1,6 +1,5 @@
# Submodules
AT32F435_437_SDK = hw/mcu/artery/at32f435_437
DEPS_SUBMODULES += $(AT32F435_437_SDK)
# AT32 SDK path
AT32F435_437_SDK_SRC = $(AT32F435_437_SDK)/libraries

View File

@@ -78,7 +78,7 @@ LoopFillZerobss:
cmp r2, r3
bcc FillZerobss
/* Call the clock system intitialization function.*/
/* Call the clock system initialization function.*/
bl SystemInit
/* Call static constructors */
bl __libc_init_array