Initial commit
This commit is contained in:
commit
8cbd53da5f
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "SDK"]
|
||||||
|
path = SDK
|
||||||
|
url = https://git.minori.work/Embedded_SDK/Artery_AT32F43x.git
|
|
@ -0,0 +1,141 @@
|
||||||
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
|
||||||
|
project(at32f437_start_template)
|
||||||
|
|
||||||
|
enable_language(CXX)
|
||||||
|
enable_language(ASM)
|
||||||
|
|
||||||
|
# Different linker scripts
|
||||||
|
set(TARGET_LDSCRIPT_FLASH "${CMAKE_SOURCE_DIR}/SDK/libraries/cmsis/cm4/device_support/startup/gcc/linker/AT32F437xM_FLASH.ld")
|
||||||
|
set(TARGET_LDSCRIPT_RAM "${CMAKE_SOURCE_DIR}/SDK/libraries/cmsis/cm4/device_support/startup/gcc/linker/AT32F437xM_FLASH.ld")
|
||||||
|
|
||||||
|
set(TARGET_SOURCES
|
||||||
|
"SDK/libraries/cmsis/cm4/device_support/startup/gcc/startup_at32f435_437.s"
|
||||||
|
"SDK/libraries/cmsis/cm4/device_support/system_at32f435_437.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_acc.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_adc.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_can.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_crc.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_crm.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_dac.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_debug.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_dma.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_dvp.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_edma.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_emac.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_ertc.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_exint.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_flash.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_gpio.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_i2c.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_misc.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_pwc.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_qspi.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_scfg.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_sdio.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_spi.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_tmr.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_usart.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_usb.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_wdt.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_wwdt.c"
|
||||||
|
"SDK/libraries/drivers/src/at32f435_437_xmc.c"
|
||||||
|
"board/at32f435_437_board.c"
|
||||||
|
"board/at32f435_437_clock.c"
|
||||||
|
"src/main.c"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(TARGET_C_DEFINES
|
||||||
|
"AT_START_F437_V1"
|
||||||
|
"AT32F437ZMT7"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(TARGET_C_INCLUDES
|
||||||
|
"SDK/libraries/cmsis/cm4/core_support"
|
||||||
|
"SDK/libraries/cmsis/cm4/device_support"
|
||||||
|
"SDK/libraries/drivers/inc"
|
||||||
|
"board"
|
||||||
|
"include"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Shared libraries linked with application
|
||||||
|
set(TARGET_LIBS
|
||||||
|
"c"
|
||||||
|
"m"
|
||||||
|
"nosys"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Shared library and linker script search paths
|
||||||
|
set(TARGET_LIB_DIRECTORIES
|
||||||
|
)
|
||||||
|
|
||||||
|
# Conditional flags
|
||||||
|
# DEBUG
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -O0 -g")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -O0 -g")
|
||||||
|
set(CMAKE_ASM_FLAGS_DEBUG "-DDEBUG -O0 -g")
|
||||||
|
|
||||||
|
# RELEASE
|
||||||
|
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2 -flto")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O2 -flto")
|
||||||
|
set(CMAKE_ASM_FLAGS_RELEASE "-DNDEBUG -O2 -flto")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-flto")
|
||||||
|
|
||||||
|
# Final compiler flags
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fno-common -fno-builtin -ffreestanding -fdata-sections -ffunction-sections")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-common -fno-builtin -ffreestanding -fdata-sections -ffunction-sections")
|
||||||
|
set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -x assembler-with-cpp")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
|
||||||
|
|
||||||
|
# Shared sources, includes and definitions
|
||||||
|
add_compile_definitions(${TARGET_C_DEFINES})
|
||||||
|
include_directories(${TARGET_C_INCLUDES})
|
||||||
|
link_directories(${TARGET_LIB_DIRECTORIES})
|
||||||
|
link_libraries(${TARGET_LIBS})
|
||||||
|
|
||||||
|
# Main targets are added here
|
||||||
|
|
||||||
|
# Create ELF
|
||||||
|
add_executable("${CMAKE_PROJECT_NAME}_FLASH.elf" ${TARGET_SOURCES})
|
||||||
|
target_compile_definitions("${CMAKE_PROJECT_NAME}_FLASH.elf"
|
||||||
|
PRIVATE ${TARGET_C_DEFINES_XIP}
|
||||||
|
)
|
||||||
|
target_link_options("${CMAKE_PROJECT_NAME}_FLASH.elf"
|
||||||
|
PRIVATE "-T${TARGET_LDSCRIPT_FLASH}"
|
||||||
|
PRIVATE "-Wl,--Map=${CMAKE_PROJECT_NAME}_FLASH.map"
|
||||||
|
)
|
||||||
|
set_property(TARGET "${CMAKE_PROJECT_NAME}_FLASH.elf" APPEND
|
||||||
|
PROPERTY ADDITIONAL_CLEAN_FILES "${CMAKE_PROJECT_NAME}_FLASH.map"
|
||||||
|
)
|
||||||
|
add_custom_command(OUTPUT "${CMAKE_PROJECT_NAME}_FLASH.hex"
|
||||||
|
COMMAND ${CMAKE_OBJCOPY} "-O" "ihex" "${CMAKE_PROJECT_NAME}_FLASH.elf" "${CMAKE_PROJECT_NAME}_FLASH.hex"
|
||||||
|
DEPENDS "${CMAKE_PROJECT_NAME}_FLASH.elf"
|
||||||
|
)
|
||||||
|
add_custom_target("${CMAKE_PROJECT_NAME}_FLASH_HEX" DEPENDS "${CMAKE_PROJECT_NAME}_FLASH.hex")
|
||||||
|
if(DEFINED TARGET_TOOLCHAIN_SIZE)
|
||||||
|
add_custom_command(TARGET "${CMAKE_PROJECT_NAME}_FLASH.elf" POST_BUILD
|
||||||
|
COMMAND ${TARGET_TOOLCHAIN_SIZE} "${CMAKE_PROJECT_NAME}_FLASH.elf"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
# Create ELF
|
||||||
|
add_executable("${CMAKE_PROJECT_NAME}_RAM.elf" ${TARGET_SOURCES})
|
||||||
|
target_link_options("${CMAKE_PROJECT_NAME}_RAM.elf"
|
||||||
|
PRIVATE "-T${TARGET_LDSCRIPT_RAM}"
|
||||||
|
PRIVATE "-Wl,--Map=${CMAKE_PROJECT_NAME}_RAM.map"
|
||||||
|
)
|
||||||
|
set_property(TARGET "${CMAKE_PROJECT_NAME}_RAM.elf" APPEND
|
||||||
|
PROPERTY ADDITIONAL_CLEAN_FILES "${CMAKE_PROJECT_NAME}_RAM.map"
|
||||||
|
)
|
||||||
|
add_custom_command(OUTPUT "${CMAKE_PROJECT_NAME}_RAM.hex"
|
||||||
|
COMMAND ${CMAKE_OBJCOPY} "-O" "ihex" "${CMAKE_PROJECT_NAME}_RAM.elf" "${CMAKE_PROJECT_NAME}_RAM.hex"
|
||||||
|
DEPENDS "${CMAKE_PROJECT_NAME}_RAM.elf"
|
||||||
|
)
|
||||||
|
add_custom_target("${CMAKE_PROJECT_NAME}_RAM_HEX" DEPENDS "${CMAKE_PROJECT_NAME}_RAM.hex")
|
||||||
|
if(DEFINED TARGET_TOOLCHAIN_SIZE)
|
||||||
|
add_custom_command(TARGET "${CMAKE_PROJECT_NAME}_RAM.elf" POST_BUILD
|
||||||
|
COMMAND ${TARGET_TOOLCHAIN_SIZE} "${CMAKE_PROJECT_NAME}_RAM.elf"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Poor old Windows...
|
||||||
|
if(WIN32)
|
||||||
|
set(CMAKE_SYSTEM_NAME "Generic")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
|
||||||
|
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
|
||||||
|
|
||||||
|
# Optionally set size binary name, for elf section size reporting.
|
||||||
|
set(TARGET_TOOLCHAIN_SIZE arm-none-eabi-size)
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS_INIT "-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16")
|
||||||
|
set(CMAKE_CXX_FLAGS_INIT "-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS_INIT "-specs=nano.specs -specs=nosys.specs -Wl,--print-memory-usage -Wl,--no-warn-rwx-segments")
|
||||||
|
|
||||||
|
# Make CMake happy about those compilers
|
||||||
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
|
@ -0,0 +1,389 @@
|
||||||
|
/**
|
||||||
|
**************************************************************************
|
||||||
|
* @file at32f435_437_board.c
|
||||||
|
* @brief set of firmware functions to manage leds and push-button.
|
||||||
|
* initialize delay function.
|
||||||
|
**************************************************************************
|
||||||
|
* 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
|
||||||
|
* software is governed by this copyright notice and the following disclaimer.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||||
|
* GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
|
||||||
|
* TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
|
||||||
|
* STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "at32f435_437_board.h"
|
||||||
|
|
||||||
|
/** @addtogroup AT32F435_437_board
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup BOARD
|
||||||
|
* @brief onboard periph driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* delay macros */
|
||||||
|
#define STEP_DELAY_MS 50
|
||||||
|
|
||||||
|
/* at-start led resouce array */
|
||||||
|
gpio_type *led_gpio_port[LED_NUM] = {LED2_GPIO, LED3_GPIO, LED4_GPIO};
|
||||||
|
uint16_t led_gpio_pin[LED_NUM] = {LED2_PIN, LED3_PIN, LED4_PIN};
|
||||||
|
crm_periph_clock_type led_gpio_crm_clk[LED_NUM] = {LED2_GPIO_CRM_CLK, LED3_GPIO_CRM_CLK, LED4_GPIO_CRM_CLK};
|
||||||
|
|
||||||
|
/* delay variable */
|
||||||
|
static __IO uint32_t fac_us;
|
||||||
|
static __IO uint32_t fac_ms;
|
||||||
|
|
||||||
|
/* support printf function, usemicrolib is unnecessary */
|
||||||
|
#if (__ARMCC_VERSION > 6000000)
|
||||||
|
__asm (".global __use_no_semihosting\n\t");
|
||||||
|
void _sys_exit(int x)
|
||||||
|
{
|
||||||
|
x = x;
|
||||||
|
}
|
||||||
|
/* __use_no_semihosting was requested, but _ttywrch was */
|
||||||
|
void _ttywrch(int ch)
|
||||||
|
{
|
||||||
|
ch = ch;
|
||||||
|
}
|
||||||
|
FILE __stdout;
|
||||||
|
#else
|
||||||
|
#ifdef __CC_ARM
|
||||||
|
#pragma import(__use_no_semihosting)
|
||||||
|
struct __FILE
|
||||||
|
{
|
||||||
|
int handle;
|
||||||
|
};
|
||||||
|
FILE __stdout;
|
||||||
|
void _sys_exit(int x)
|
||||||
|
{
|
||||||
|
x = x;
|
||||||
|
}
|
||||||
|
/* __use_no_semihosting was requested, but _ttywrch was */
|
||||||
|
void _ttywrch(int ch)
|
||||||
|
{
|
||||||
|
ch = ch;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (__GNUC__) && !defined (__clang__)
|
||||||
|
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
|
||||||
|
#else
|
||||||
|
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief retargets the c library printf function to the usart.
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
PUTCHAR_PROTOTYPE
|
||||||
|
{
|
||||||
|
while(usart_flag_get(PRINT_UART, USART_TDBE_FLAG) == RESET);
|
||||||
|
usart_data_transmit(PRINT_UART, ch);
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined (__GNUC__) && !defined (__clang__)
|
||||||
|
int _write(int fd, char *pbuffer, int size)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < size; i ++)
|
||||||
|
{
|
||||||
|
__io_putchar(*pbuffer++);
|
||||||
|
}
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief initialize uart
|
||||||
|
* @param baudrate: uart baudrate
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void uart_print_init(uint32_t baudrate)
|
||||||
|
{
|
||||||
|
gpio_init_type gpio_init_struct;
|
||||||
|
|
||||||
|
#if defined (__GNUC__) && !defined (__clang__)
|
||||||
|
setvbuf(stdout, NULL, _IONBF, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* enable the uart and gpio clock */
|
||||||
|
crm_periph_clock_enable(PRINT_UART_CRM_CLK, TRUE);
|
||||||
|
crm_periph_clock_enable(PRINT_UART_TX_GPIO_CRM_CLK, TRUE);
|
||||||
|
|
||||||
|
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_mode = GPIO_MODE_MUX;
|
||||||
|
gpio_init_struct.gpio_pins = PRINT_UART_TX_PIN;
|
||||||
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
||||||
|
gpio_init(PRINT_UART_TX_GPIO, &gpio_init_struct);
|
||||||
|
|
||||||
|
gpio_pin_mux_config(PRINT_UART_TX_GPIO, PRINT_UART_TX_PIN_SOURCE, PRINT_UART_TX_PIN_MUX_NUM);
|
||||||
|
|
||||||
|
/* configure uart param */
|
||||||
|
usart_init(PRINT_UART, baudrate, USART_DATA_8BITS, USART_STOP_1_BIT);
|
||||||
|
usart_transmitter_enable(PRINT_UART, TRUE);
|
||||||
|
usart_enable(PRINT_UART, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief board initialize interface init led and button
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void at32_board_init()
|
||||||
|
{
|
||||||
|
/* initialize delay function */
|
||||||
|
delay_init();
|
||||||
|
|
||||||
|
/* configure led in at_start_board */
|
||||||
|
at32_led_init(LED2);
|
||||||
|
at32_led_init(LED3);
|
||||||
|
at32_led_init(LED4);
|
||||||
|
at32_led_off(LED2);
|
||||||
|
at32_led_off(LED3);
|
||||||
|
at32_led_off(LED4);
|
||||||
|
|
||||||
|
/* configure button in at_start board */
|
||||||
|
at32_button_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief configure button gpio
|
||||||
|
* @param button: specifies the button to be configured.
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void at32_button_init(void)
|
||||||
|
{
|
||||||
|
gpio_init_type gpio_init_struct;
|
||||||
|
|
||||||
|
/* enable the button clock */
|
||||||
|
crm_periph_clock_enable(USER_BUTTON_CRM_CLK, TRUE);
|
||||||
|
|
||||||
|
/* set default parameter */
|
||||||
|
gpio_default_para_init(&gpio_init_struct);
|
||||||
|
|
||||||
|
/* configure button pin as input with pull-up/pull-down */
|
||||||
|
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_INPUT;
|
||||||
|
gpio_init_struct.gpio_pins = USER_BUTTON_PIN;
|
||||||
|
gpio_init_struct.gpio_pull = GPIO_PULL_DOWN;
|
||||||
|
gpio_init(USER_BUTTON_PORT, &gpio_init_struct);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief returns the selected button state
|
||||||
|
* @param none
|
||||||
|
* @retval the button gpio pin value
|
||||||
|
*/
|
||||||
|
uint8_t at32_button_state(void)
|
||||||
|
{
|
||||||
|
return gpio_input_data_bit_read(USER_BUTTON_PORT, USER_BUTTON_PIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief returns which button have press down
|
||||||
|
* @param none
|
||||||
|
* @retval the button have press down
|
||||||
|
*/
|
||||||
|
button_type at32_button_press()
|
||||||
|
{
|
||||||
|
static uint8_t pressed = 1;
|
||||||
|
/* get button state in at_start board */
|
||||||
|
if((pressed == 1) && (at32_button_state() != RESET))
|
||||||
|
{
|
||||||
|
/* debounce */
|
||||||
|
pressed = 0;
|
||||||
|
delay_ms(10);
|
||||||
|
if(at32_button_state() != RESET)
|
||||||
|
return USER_BUTTON;
|
||||||
|
}
|
||||||
|
else if(at32_button_state() == RESET)
|
||||||
|
{
|
||||||
|
pressed = 1;
|
||||||
|
}
|
||||||
|
return NO_BUTTON;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief configure led gpio
|
||||||
|
* @param led: specifies the led to be configured.
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void at32_led_init(led_type led)
|
||||||
|
{
|
||||||
|
gpio_init_type gpio_init_struct;
|
||||||
|
|
||||||
|
/* enable the led clock */
|
||||||
|
crm_periph_clock_enable(led_gpio_crm_clk[led], TRUE);
|
||||||
|
|
||||||
|
/* set default parameter */
|
||||||
|
gpio_default_para_init(&gpio_init_struct);
|
||||||
|
|
||||||
|
/* configure the led gpio */
|
||||||
|
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_OUTPUT;
|
||||||
|
gpio_init_struct.gpio_pins = led_gpio_pin[led];
|
||||||
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
||||||
|
gpio_init(led_gpio_port[led], &gpio_init_struct);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief turns selected led on.
|
||||||
|
* @param led: specifies the led to be set on.
|
||||||
|
* this parameter can be one of following parameters:
|
||||||
|
* @arg LED2
|
||||||
|
* @arg LED3
|
||||||
|
* @arg LED4
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void at32_led_on(led_type led)
|
||||||
|
{
|
||||||
|
if(led > (LED_NUM - 1))
|
||||||
|
return;
|
||||||
|
if(led_gpio_pin[led])
|
||||||
|
led_gpio_port[led]->clr = led_gpio_pin[led];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief turns selected led off.
|
||||||
|
* @param led: specifies the led to be set off.
|
||||||
|
* this parameter can be one of following parameters:
|
||||||
|
* @arg LED2
|
||||||
|
* @arg LED3
|
||||||
|
* @arg LED4
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void at32_led_off(led_type led)
|
||||||
|
{
|
||||||
|
if(led > (LED_NUM - 1))
|
||||||
|
return;
|
||||||
|
if(led_gpio_pin[led])
|
||||||
|
led_gpio_port[led]->scr = led_gpio_pin[led];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief turns selected led toggle.
|
||||||
|
* @param led: specifies the led to be set off.
|
||||||
|
* this parameter can be one of following parameters:
|
||||||
|
* @arg LED2
|
||||||
|
* @arg LED3
|
||||||
|
* @arg LED4
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void at32_led_toggle(led_type led)
|
||||||
|
{
|
||||||
|
if(led > (LED_NUM - 1))
|
||||||
|
return;
|
||||||
|
if(led_gpio_pin[led])
|
||||||
|
led_gpio_port[led]->odt ^= led_gpio_pin[led];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief initialize delay function
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void delay_init()
|
||||||
|
{
|
||||||
|
/* configure systick */
|
||||||
|
systick_clock_source_config(SYSTICK_CLOCK_SOURCE_AHBCLK_NODIV);
|
||||||
|
fac_us = system_core_clock / (1000000U);
|
||||||
|
fac_ms = fac_us * (1000U);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief inserts a delay time.
|
||||||
|
* @param nus: specifies the delay time length, in microsecond.
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void delay_us(uint32_t nus)
|
||||||
|
{
|
||||||
|
uint32_t temp = 0;
|
||||||
|
SysTick->LOAD = (uint32_t)(nus * fac_us);
|
||||||
|
SysTick->VAL = 0x00;
|
||||||
|
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk ;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
temp = SysTick->CTRL;
|
||||||
|
}while((temp & 0x01) && !(temp & (1 << 16)));
|
||||||
|
|
||||||
|
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||||
|
SysTick->VAL = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief inserts a delay time.
|
||||||
|
* @param nms: specifies the delay time length, in milliseconds.
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void delay_ms(uint16_t nms)
|
||||||
|
{
|
||||||
|
uint32_t temp = 0;
|
||||||
|
while(nms)
|
||||||
|
{
|
||||||
|
if(nms > STEP_DELAY_MS)
|
||||||
|
{
|
||||||
|
SysTick->LOAD = (uint32_t)(STEP_DELAY_MS * fac_ms);
|
||||||
|
nms -= STEP_DELAY_MS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SysTick->LOAD = (uint32_t)(nms * fac_ms);
|
||||||
|
nms = 0;
|
||||||
|
}
|
||||||
|
SysTick->VAL = 0x00;
|
||||||
|
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
temp = SysTick->CTRL;
|
||||||
|
}while((temp & 0x01) && !(temp & (1 << 16)));
|
||||||
|
|
||||||
|
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||||
|
SysTick->VAL = 0x00;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief inserts a delay time.
|
||||||
|
* @param sec: specifies the delay time, in seconds.
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void delay_sec(uint16_t sec)
|
||||||
|
{
|
||||||
|
uint16_t index;
|
||||||
|
for(index = 0; index < sec; index++)
|
||||||
|
{
|
||||||
|
delay_ms(500);
|
||||||
|
delay_ms(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
|
@ -0,0 +1,152 @@
|
||||||
|
/**
|
||||||
|
**************************************************************************
|
||||||
|
* @file at32f435_437_board.c
|
||||||
|
* @brief header file for at-start board. set of firmware functions to
|
||||||
|
* manage leds and push-button. initialize delay function.
|
||||||
|
**************************************************************************
|
||||||
|
* 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
|
||||||
|
* software is governed by this copyright notice and the following disclaimer.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||||
|
* GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
|
||||||
|
* TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
|
||||||
|
* STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __AT32F435_437_BOARD_H
|
||||||
|
#define __AT32F435_437_BOARD_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "stdio.h"
|
||||||
|
#include "at32f435_437.h"
|
||||||
|
|
||||||
|
/** @addtogroup AT32F435_437_board
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup BOARD
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup BOARD_pins_definition
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this header include define support list:
|
||||||
|
* 1. at-start-f435 v1.x board
|
||||||
|
* 2. at-start-f437 v1.x board
|
||||||
|
* if define AT_START_F435_V1, the header file support at-start-f437 v1.x board
|
||||||
|
* if define AT_START_F437_V1, the header file support at-start-f437 v1.x board
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined (AT_START_F435_V1) && !defined (AT_START_F437_V1)
|
||||||
|
#error "please select first the board at-start device used in your application (in at32f435_437_board.h file)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/******************** define led ********************/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
LED2 = 0,
|
||||||
|
LED3 = 1,
|
||||||
|
LED4 = 2
|
||||||
|
}led_type;
|
||||||
|
|
||||||
|
#define LED_NUM 3
|
||||||
|
|
||||||
|
#if defined (AT_START_F435_V1) || defined (AT_START_F437_V1)
|
||||||
|
#define LED2_PIN GPIO_PINS_13
|
||||||
|
#define LED2_GPIO GPIOD
|
||||||
|
#define LED2_GPIO_CRM_CLK CRM_GPIOD_PERIPH_CLOCK
|
||||||
|
|
||||||
|
#define LED3_PIN GPIO_PINS_14
|
||||||
|
#define LED3_GPIO GPIOD
|
||||||
|
#define LED3_GPIO_CRM_CLK CRM_GPIOD_PERIPH_CLOCK
|
||||||
|
|
||||||
|
#define LED4_PIN GPIO_PINS_15
|
||||||
|
#define LED4_GPIO GPIOD
|
||||||
|
#define LED4_GPIO_CRM_CLK CRM_GPIOD_PERIPH_CLOCK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************** define print uart ******************/
|
||||||
|
#define PRINT_UART USART1
|
||||||
|
#define PRINT_UART_CRM_CLK CRM_USART1_PERIPH_CLOCK
|
||||||
|
#define PRINT_UART_TX_PIN GPIO_PINS_9
|
||||||
|
#define PRINT_UART_TX_GPIO GPIOA
|
||||||
|
#define PRINT_UART_TX_GPIO_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
|
||||||
|
#define PRINT_UART_TX_PIN_SOURCE GPIO_PINS_SOURCE9
|
||||||
|
#define PRINT_UART_TX_PIN_MUX_NUM GPIO_MUX_7
|
||||||
|
|
||||||
|
/******************* define button *******************/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
USER_BUTTON = 0,
|
||||||
|
NO_BUTTON = 1
|
||||||
|
} button_type;
|
||||||
|
|
||||||
|
#define USER_BUTTON_PIN GPIO_PINS_0
|
||||||
|
#define USER_BUTTON_PORT GPIOA
|
||||||
|
#define USER_BUTTON_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup BOARD_exported_functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/******************** functions ********************/
|
||||||
|
void at32_board_init(void);
|
||||||
|
|
||||||
|
/* led operation function */
|
||||||
|
void at32_led_init(led_type led);
|
||||||
|
void at32_led_on(led_type led);
|
||||||
|
void at32_led_off(led_type led);
|
||||||
|
void at32_led_toggle(led_type led);
|
||||||
|
|
||||||
|
/* button operation function */
|
||||||
|
void at32_button_init(void);
|
||||||
|
button_type at32_button_press(void);
|
||||||
|
uint8_t at32_button_state(void);
|
||||||
|
|
||||||
|
/* delay function */
|
||||||
|
void delay_init(void);
|
||||||
|
void delay_us(uint32_t nus);
|
||||||
|
void delay_ms(uint16_t nms);
|
||||||
|
void delay_sec(uint16_t sec);
|
||||||
|
|
||||||
|
/* printf uart init function */
|
||||||
|
void uart_print_init(uint32_t baudrate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,136 @@
|
||||||
|
/**
|
||||||
|
**************************************************************************
|
||||||
|
* @file at32f435_437_clock.c
|
||||||
|
* @brief system clock config program
|
||||||
|
**************************************************************************
|
||||||
|
* 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
|
||||||
|
* software is governed by this copyright notice and the following disclaimer.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||||
|
* GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
|
||||||
|
* TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
|
||||||
|
* STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* includes ------------------------------------------------------------------*/
|
||||||
|
#include "at32f435_437_clock.h"
|
||||||
|
|
||||||
|
/** @addtogroup AT32F437_periph_template
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup 437_System_clock_configuration System_clock_configuration
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief system clock config program
|
||||||
|
* @note the system clock is configured as follow:
|
||||||
|
* - system clock = (hext * pll_ns)/(pll_ms * pll_fr)
|
||||||
|
* - system clock source = pll (hext)
|
||||||
|
* - hext = 8000000
|
||||||
|
* - sclk = 288000000
|
||||||
|
* - ahbdiv = 1
|
||||||
|
* - ahbclk = 288000000
|
||||||
|
* - apb2div = 2
|
||||||
|
* - apb2clk = 144000000
|
||||||
|
* - apb1div = 2
|
||||||
|
* - apb1clk = 144000000
|
||||||
|
* - pll_ns = 144
|
||||||
|
* - pll_ms = 1
|
||||||
|
* - pll_fr = 4
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void system_clock_config(void)
|
||||||
|
{
|
||||||
|
/* reset crm */
|
||||||
|
crm_reset();
|
||||||
|
|
||||||
|
/* enable pwc periph clock */
|
||||||
|
crm_periph_clock_enable(CRM_PWC_PERIPH_CLOCK, TRUE);
|
||||||
|
|
||||||
|
/* config ldo voltage */
|
||||||
|
pwc_ldo_output_voltage_set(PWC_LDO_OUTPUT_1V3);
|
||||||
|
|
||||||
|
/* set the flash clock divider */
|
||||||
|
flash_clock_divider_set(FLASH_CLOCK_DIV_3);
|
||||||
|
|
||||||
|
crm_clock_source_enable(CRM_CLOCK_SOURCE_HEXT, TRUE);
|
||||||
|
|
||||||
|
/* wait till hext is ready */
|
||||||
|
while(crm_hext_stable_wait() == ERROR)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* config pll clock resource
|
||||||
|
common frequency config list: pll source selected hick or hext(8mhz)
|
||||||
|
_________________________________________________________________________________________________
|
||||||
|
| | | | | | | | | | |
|
||||||
|
|pll(mhz)| 288 | 252 | 216 | 192 | 180 | 144 | 108 | 72 | 36 |
|
||||||
|
|________|_________|_________|_________|_________|_________|_________|_________|_________________|
|
||||||
|
| | | | | | | | | | |
|
||||||
|
|pll_ns | 144 | 126 | 108 | 96 | 90 | 72 | 108 | 72 | 72 |
|
||||||
|
| | | | | | | | | | |
|
||||||
|
|pll_ms | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
|
||||||
|
| | | | | | | | | | |
|
||||||
|
|pll_fr | FR_4 | FR_4 | FR_4 | FR_4 | FR_4 | FR_4 | FR_8 | FR_8 | FR_16|
|
||||||
|
|________|_________|_________|_________|_________|_________|_________|_________|________|________|
|
||||||
|
|
||||||
|
if pll clock source selects hext with other frequency values, or configure pll to other
|
||||||
|
frequency values, please use the at32 new clock configuration tool for configuration. */
|
||||||
|
crm_pll_config(CRM_PLL_SOURCE_HEXT, 144, 1, CRM_PLL_FR_4);
|
||||||
|
|
||||||
|
/* enable pll */
|
||||||
|
crm_clock_source_enable(CRM_CLOCK_SOURCE_PLL, TRUE);
|
||||||
|
|
||||||
|
/* wait till pll is ready */
|
||||||
|
while(crm_flag_get(CRM_PLL_STABLE_FLAG) != SET)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* config ahbclk */
|
||||||
|
crm_ahb_div_set(CRM_AHB_DIV_1);
|
||||||
|
|
||||||
|
/* config apb2clk, the maximum frequency of APB1/APB2 clock is 144 MHz */
|
||||||
|
crm_apb2_div_set(CRM_APB2_DIV_2);
|
||||||
|
|
||||||
|
/* config apb1clk, the maximum frequency of APB1/APB2 clock is 144 MHz */
|
||||||
|
crm_apb1_div_set(CRM_APB1_DIV_2);
|
||||||
|
|
||||||
|
/* enable auto step mode */
|
||||||
|
crm_auto_step_mode_enable(TRUE);
|
||||||
|
|
||||||
|
/* select pll as system clock source */
|
||||||
|
crm_sysclk_switch(CRM_SCLK_PLL);
|
||||||
|
|
||||||
|
/* wait till pll is used as system clock source */
|
||||||
|
while(crm_sysclk_switch_status_get() != CRM_SCLK_PLL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* disable auto step mode */
|
||||||
|
crm_auto_step_mode_enable(FALSE);
|
||||||
|
|
||||||
|
/* update system_core_clock global variable */
|
||||||
|
system_core_clock_update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/**
|
||||||
|
**************************************************************************
|
||||||
|
* @file at32f435_437_clock.h
|
||||||
|
* @brief header file of clock program
|
||||||
|
**************************************************************************
|
||||||
|
* 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
|
||||||
|
* software is governed by this copyright notice and the following disclaimer.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||||
|
* GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
|
||||||
|
* TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
|
||||||
|
* STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __AT32F435_437_CLOCK_H
|
||||||
|
#define __AT32F435_437_CLOCK_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* includes ------------------------------------------------------------------*/
|
||||||
|
#include "at32f435_437.h"
|
||||||
|
|
||||||
|
/* exported functions ------------------------------------------------------- */
|
||||||
|
void system_clock_config(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,190 @@
|
||||||
|
/**
|
||||||
|
**************************************************************************
|
||||||
|
* @file at32f435_437_conf.h
|
||||||
|
* @brief at32f435_437 config header file
|
||||||
|
**************************************************************************
|
||||||
|
* 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
|
||||||
|
* software is governed by this copyright notice and the following disclaimer.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||||
|
* GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
|
||||||
|
* TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
|
||||||
|
* STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __AT32F435_437_CONF_H
|
||||||
|
#define __AT32F435_437_CONF_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/** @addtogroup AT32F437_periph_template
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup 437_Library_configuration Library_configuration
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief in the following line adjust the value of high speed exernal crystal (hext)
|
||||||
|
* used in your application
|
||||||
|
*
|
||||||
|
* tip: to avoid modifying this file each time you need to use different hext, you
|
||||||
|
* can define the hext value in your toolchain compiler preprocessor.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#if !defined HEXT_VALUE
|
||||||
|
#define HEXT_VALUE ((uint32_t)8000000) /*!< value of the high speed exernal crystal in hz */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief in the following line adjust the high speed exernal crystal (hext) startup
|
||||||
|
* timeout value
|
||||||
|
*/
|
||||||
|
#define HEXT_STARTUP_TIMEOUT ((uint16_t)0x3000) /*!< time out for hext start up */
|
||||||
|
#define HICK_VALUE ((uint32_t)8000000) /*!< value of the high speed internal clock in hz */
|
||||||
|
#define LEXT_VALUE ((uint32_t)32768) /*!< value of the low speed exernal clock in hz */
|
||||||
|
|
||||||
|
/* module define -------------------------------------------------------------*/
|
||||||
|
#define CRM_MODULE_ENABLED
|
||||||
|
#define TMR_MODULE_ENABLED
|
||||||
|
#define ERTC_MODULE_ENABLED
|
||||||
|
#define GPIO_MODULE_ENABLED
|
||||||
|
#define I2C_MODULE_ENABLED
|
||||||
|
#define USART_MODULE_ENABLED
|
||||||
|
#define PWC_MODULE_ENABLED
|
||||||
|
#define CAN_MODULE_ENABLED
|
||||||
|
#define ADC_MODULE_ENABLED
|
||||||
|
#define DAC_MODULE_ENABLED
|
||||||
|
#define SPI_MODULE_ENABLED
|
||||||
|
#define EDMA_MODULE_ENABLED
|
||||||
|
#define DMA_MODULE_ENABLED
|
||||||
|
#define DEBUG_MODULE_ENABLED
|
||||||
|
#define FLASH_MODULE_ENABLED
|
||||||
|
#define CRC_MODULE_ENABLED
|
||||||
|
#define WWDT_MODULE_ENABLED
|
||||||
|
#define WDT_MODULE_ENABLED
|
||||||
|
#define EXINT_MODULE_ENABLED
|
||||||
|
#define SDIO_MODULE_ENABLED
|
||||||
|
#define XMC_MODULE_ENABLED
|
||||||
|
#define USB_MODULE_ENABLED
|
||||||
|
#define ACC_MODULE_ENABLED
|
||||||
|
#define MISC_MODULE_ENABLED
|
||||||
|
#define QSPI_MODULE_ENABLED
|
||||||
|
#define DVP_MODULE_ENABLED
|
||||||
|
#define SCFG_MODULE_ENABLED
|
||||||
|
#define EMAC_MODULE_ENABLED
|
||||||
|
|
||||||
|
/* includes ------------------------------------------------------------------*/
|
||||||
|
#ifdef CRM_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_crm.h"
|
||||||
|
#endif
|
||||||
|
#ifdef TMR_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_tmr.h"
|
||||||
|
#endif
|
||||||
|
#ifdef ERTC_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_ertc.h"
|
||||||
|
#endif
|
||||||
|
#ifdef GPIO_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_gpio.h"
|
||||||
|
#endif
|
||||||
|
#ifdef I2C_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_i2c.h"
|
||||||
|
#endif
|
||||||
|
#ifdef USART_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_usart.h"
|
||||||
|
#endif
|
||||||
|
#ifdef PWC_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_pwc.h"
|
||||||
|
#endif
|
||||||
|
#ifdef CAN_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_can.h"
|
||||||
|
#endif
|
||||||
|
#ifdef ADC_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_adc.h"
|
||||||
|
#endif
|
||||||
|
#ifdef DAC_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_dac.h"
|
||||||
|
#endif
|
||||||
|
#ifdef SPI_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_spi.h"
|
||||||
|
#endif
|
||||||
|
#ifdef DMA_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_dma.h"
|
||||||
|
#endif
|
||||||
|
#ifdef DEBUG_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_debug.h"
|
||||||
|
#endif
|
||||||
|
#ifdef FLASH_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_flash.h"
|
||||||
|
#endif
|
||||||
|
#ifdef CRC_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_crc.h"
|
||||||
|
#endif
|
||||||
|
#ifdef WWDT_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_wwdt.h"
|
||||||
|
#endif
|
||||||
|
#ifdef WDT_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_wdt.h"
|
||||||
|
#endif
|
||||||
|
#ifdef EXINT_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_exint.h"
|
||||||
|
#endif
|
||||||
|
#ifdef SDIO_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_sdio.h"
|
||||||
|
#endif
|
||||||
|
#ifdef XMC_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_xmc.h"
|
||||||
|
#endif
|
||||||
|
#ifdef ACC_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_acc.h"
|
||||||
|
#endif
|
||||||
|
#ifdef MISC_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_misc.h"
|
||||||
|
#endif
|
||||||
|
#ifdef EDMA_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_edma.h"
|
||||||
|
#endif
|
||||||
|
#ifdef QSPI_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_qspi.h"
|
||||||
|
#endif
|
||||||
|
#ifdef SCFG_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_scfg.h"
|
||||||
|
#endif
|
||||||
|
#ifdef EMAC_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_emac.h"
|
||||||
|
#endif
|
||||||
|
#ifdef DVP_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_dvp.h"
|
||||||
|
#endif
|
||||||
|
#ifdef USB_MODULE_ENABLED
|
||||||
|
#include "at32f435_437_usb.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,139 @@
|
||||||
|
/**
|
||||||
|
**************************************************************************
|
||||||
|
* @file at32f435_437_int.c
|
||||||
|
* @brief main interrupt service routines.
|
||||||
|
**************************************************************************
|
||||||
|
* 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
|
||||||
|
* software is governed by this copyright notice and the following disclaimer.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||||
|
* GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
|
||||||
|
* TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
|
||||||
|
* STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* includes ------------------------------------------------------------------*/
|
||||||
|
#include "at32f435_437_int.h"
|
||||||
|
|
||||||
|
/** @addtogroup AT32F437_periph_template
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup 437_LED_toggle
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this function handles nmi exception.
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void NMI_Handler(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this function handles hard fault exception.
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void HardFault_Handler(void)
|
||||||
|
{
|
||||||
|
/* go to infinite loop when hard fault exception occurs */
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this function handles memory manage exception.
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void MemManage_Handler(void)
|
||||||
|
{
|
||||||
|
/* go to infinite loop when memory manage exception occurs */
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this function handles bus fault exception.
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void BusFault_Handler(void)
|
||||||
|
{
|
||||||
|
/* go to infinite loop when bus fault exception occurs */
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this function handles usage fault exception.
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void UsageFault_Handler(void)
|
||||||
|
{
|
||||||
|
/* go to infinite loop when usage fault exception occurs */
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this function handles svcall exception.
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void SVC_Handler(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this function handles debug monitor exception.
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void DebugMon_Handler(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this function handles pendsv_handler exception.
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void PendSV_Handler(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this function handles systick handler.
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void SysTick_Handler(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
|
@ -0,0 +1,56 @@
|
||||||
|
/**
|
||||||
|
**************************************************************************
|
||||||
|
* @file at32f435_437_int.h
|
||||||
|
* @brief header file of main interrupt service routines.
|
||||||
|
**************************************************************************
|
||||||
|
* 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
|
||||||
|
* software is governed by this copyright notice and the following disclaimer.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||||
|
* GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
|
||||||
|
* TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
|
||||||
|
* STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __AT32F435_437_INT_H
|
||||||
|
#define __AT32F435_437_INT_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* includes ------------------------------------------------------------------*/
|
||||||
|
#include "at32f435_437.h"
|
||||||
|
|
||||||
|
/* exported types ------------------------------------------------------------*/
|
||||||
|
/* exported constants --------------------------------------------------------*/
|
||||||
|
/* exported macro ------------------------------------------------------------*/
|
||||||
|
/* exported functions ------------------------------------------------------- */
|
||||||
|
|
||||||
|
void NMI_Handler(void);
|
||||||
|
void HardFault_Handler(void);
|
||||||
|
void MemManage_Handler(void);
|
||||||
|
void BusFault_Handler(void);
|
||||||
|
void UsageFault_Handler(void);
|
||||||
|
void SVC_Handler(void);
|
||||||
|
void DebugMon_Handler(void);
|
||||||
|
void PendSV_Handler(void);
|
||||||
|
void SysTick_Handler(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "at32f435_437_board.h"
|
||||||
|
#include "at32f435_437_clock.h"
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
system_clock_config();
|
||||||
|
at32_board_init();
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
/* -- */
|
||||||
|
__WFI();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue