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:
@@ -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
|
||||
|
@@ -121,7 +121,7 @@ void system_clock_config(void)
|
||||
#endif
|
||||
|
||||
#ifdef AT32F402xx
|
||||
/* reduce power comsumption */
|
||||
/* reduce power consumption */
|
||||
reduce_power_consumption();
|
||||
#endif
|
||||
}
|
||||
|
@@ -41,4 +41,3 @@ void system_clock_config(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -137,4 +137,3 @@ void DebugMon_Handler(void)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
@@ -53,4 +53,3 @@ void SysTick_Handler(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -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
@@ -294,4 +294,3 @@ void assert_failed(const char *file, uint32_t line)
|
||||
/* USER CODE END 6 */
|
||||
}
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -41,4 +41,3 @@ void system_clock_config(void);
|
||||
#endif
|
||||
|
||||
#endif /* __AT32F403A_407_CLOCK_H */
|
||||
|
||||
|
@@ -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 */
|
||||
|
@@ -53,4 +53,3 @@ void SysTick_Handler(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -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
@@ -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()
|
@@ -1,3 +1,4 @@
|
||||
JLINK_DEVICE = at32f403acgu7
|
||||
LD_FILE = $(BOARD_PATH)/AT32F403AxG_FLASH.ld
|
||||
|
||||
CFLAGS += \
|
||||
|
@@ -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 */
|
||||
@@ -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);
|
||||
@@ -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 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)
|
||||
{
|
||||
while (txsize--) {
|
||||
while (usart_flag_get(PRINT_UART, USART_TDBE_FLAG) == RESET) {
|
||||
timeout--;
|
||||
if(timeout == 0)
|
||||
{
|
||||
if (timeout == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
PRINT_UART->dt = (*((uint8_t const *)buf) & 0x01FF);
|
||||
PRINT_UART->dt = (*((uint8_t const *) buf) & 0x01FF);
|
||||
buf++;
|
||||
}
|
||||
return len;
|
||||
#else
|
||||
#else
|
||||
(void) buf;
|
||||
(void) len;
|
||||
return 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
volatile uint32_t system_ticks = 0;
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
volatile uint32_t system_ticks = 0;
|
||||
void SysTick_Handler(void) {
|
||||
system_ticks++;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t board_millis(void)
|
||||
{
|
||||
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) {
|
||||
__asm("BKPT #0\n");
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
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) */
|
||||
|
102
hw/bsp/at32f403a_407/family.cmake
Normal file
102
hw/bsp/at32f403a_407/family.cmake
Normal 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()
|
@@ -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 \
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -41,4 +41,3 @@ void system_clock_config(void);
|
||||
#endif
|
||||
|
||||
#endif /* __AT32F413_CLOCK_H */
|
||||
|
||||
|
@@ -137,5 +137,3 @@ void DebugMon_Handler(void)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -53,4 +53,3 @@ void SysTick_Handler(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -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
@@ -1,6 +1,5 @@
|
||||
# Submodules
|
||||
AT32F413_SDK = hw/mcu/artery/at32f413
|
||||
DEPS_SUBMODULES += $(AT32F413_SDK)
|
||||
|
||||
# AT32 SDK path
|
||||
AT32F413_SDK_SRC = $(AT32F413_SDK)/libraries
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -41,4 +41,3 @@ void system_clock_config(void);
|
||||
#endif
|
||||
|
||||
#endif /* __AT32F415_CLOCK_H */
|
||||
|
||||
|
@@ -141,5 +141,3 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#endif /* __AT32F415_CONF_H */
|
||||
|
||||
|
||||
|
@@ -53,4 +53,3 @@ void SysTick_Handler(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -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
@@ -1,6 +1,5 @@
|
||||
# Submodules
|
||||
AT32F415_SDK = hw/mcu/artery/at32f415
|
||||
DEPS_SUBMODULES += $(AT32F415_SDK)
|
||||
|
||||
# AT32 SDK path
|
||||
AT32F415_SDK_SRC = $(AT32F415_SDK)/libraries
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -125,4 +125,3 @@ void system_clock_config(void)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
@@ -41,4 +41,3 @@ void system_clock_config(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -137,4 +137,3 @@ void DebugMon_Handler(void)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
@@ -53,4 +53,3 @@ void SysTick_Handler(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -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
9
hw/bsp/at32f423/boards/AT_START_F423/board.cmake
Normal file
9
hw/bsp/at32f423/boards/AT_START_F423/board.cmake
Normal 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()
|
@@ -1,3 +1,4 @@
|
||||
JLINK_DEVICE = AT32F423VCT7
|
||||
LD_FILE = $(BOARD_PATH)/AT32F423xC_FLASH.ld
|
||||
|
||||
CFLAGS += \
|
||||
|
@@ -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,13 +60,13 @@ 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 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
|
||||
#endif
|
||||
|
||||
/* otgfs use vbus pin */
|
||||
#ifndef USB_VBUS_IGNORE
|
||||
/* 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);
|
||||
@@ -80,7 +77,7 @@ void board_init(void)
|
||||
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
|
||||
#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);
|
||||
@@ -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);
|
||||
@@ -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 */
|
||||
@@ -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 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)
|
||||
{
|
||||
while (txsize--) {
|
||||
while (usart_flag_get(PRINT_UART, USART_TDBE_FLAG) == RESET) {
|
||||
timeout--;
|
||||
if(timeout == 0)
|
||||
{
|
||||
if (timeout == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
PRINT_UART->dt = (*((uint8_t const *)buf) & 0x01FF);
|
||||
PRINT_UART->dt = (*((uint8_t const *) buf) & 0x01FF);
|
||||
buf++;
|
||||
}
|
||||
return len;
|
||||
#else
|
||||
#else
|
||||
(void) buf;
|
||||
(void) len;
|
||||
return 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
volatile uint32_t system_ticks = 0;
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
volatile uint32_t system_ticks = 0;
|
||||
void SysTick_Handler(void) {
|
||||
system_ticks++;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t board_millis(void)
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
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) */
|
||||
|
104
hw/bsp/at32f423/family.cmake
Normal file
104
hw/bsp/at32f423/family.cmake
Normal 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()
|
@@ -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 \
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -41,4 +41,3 @@ void system_clock_config(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -137,4 +137,3 @@ void DebugMon_Handler(void)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
@@ -53,4 +53,3 @@ void SysTick_Handler(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -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
@@ -1,6 +1,5 @@
|
||||
# Submodules
|
||||
AT32F425_SDK = hw/mcu/artery/at32f425
|
||||
DEPS_SUBMODULES += $(AT32F425_SDK)
|
||||
|
||||
# AT32 SDK path
|
||||
AT32F425_SDK_SRC = $(AT32F425_SDK)/libraries
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -41,4 +41,3 @@ void system_clock_config(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -117,4 +117,3 @@ void DebugMon_Handler(void)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
@@ -53,4 +53,3 @@ void SysTick_Handler(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -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
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user