add ci build for all at32, use linker and startup from mcu cmsis instead of local files
This commit is contained in:
@@ -25,8 +25,8 @@
|
||||
*/
|
||||
|
||||
#include "at32f435_437_clock.h"
|
||||
#include "bsp/board_api.h"
|
||||
#include "board.h"
|
||||
#include "bsp/board_api.h"
|
||||
|
||||
void usb_gpio_config(void);
|
||||
void uart_print_init(uint32_t baudrate);
|
||||
@@ -36,25 +36,20 @@ 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);
|
||||
}
|
||||
void OTGFS1_WKUP_IRQHandler(void)
|
||||
{
|
||||
void OTGFS1_WKUP_IRQHandler(void) {
|
||||
tusb_int_handler(0, true);
|
||||
}
|
||||
void OTGFS2_WKUP_IRQHandler(void)
|
||||
{
|
||||
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);
|
||||
|
||||
@@ -97,10 +92,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 */
|
||||
@@ -110,20 +103,17 @@ void usb_clock48m_select(usb_clk48_s clk_s)
|
||||
acc_write_c1(7980);
|
||||
acc_write_c2(8000);
|
||||
acc_write_c3(8020);
|
||||
#ifdef BOARD_TUD_RHPORT
|
||||
#if BOARD_TUD_RHPORT == 0
|
||||
acc_sof_select(ACC_SOF_OTG1);
|
||||
#else
|
||||
acc_sof_select(ACC_SOF_OTG2);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef BOARD_TUD_RHPORT
|
||||
#if BOARD_TUD_RHPORT == 0
|
||||
acc_sof_select(ACC_SOF_OTG1);
|
||||
#else
|
||||
acc_sof_select(ACC_SOF_OTG2);
|
||||
#endif
|
||||
#endif
|
||||
/* 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);
|
||||
@@ -185,8 +175,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;
|
||||
/* enable the led clock */
|
||||
@@ -195,7 +184,7 @@ void led_and_botton_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;
|
||||
@@ -223,8 +212,7 @@ void led_and_botton_init(void)
|
||||
* @param baudrate: uart baudrate
|
||||
* @retval none
|
||||
*/
|
||||
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);
|
||||
@@ -232,7 +220,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;
|
||||
@@ -245,51 +233,44 @@ 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;
|
||||
return 0;
|
||||
}
|
||||
// Send characters to UART. Return number of sent bytes
|
||||
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
|
||||
}
|
||||
|
||||
int inHandlerMode(void)
|
||||
{
|
||||
return __get_IPSR();
|
||||
int inHandlerMode(void) {
|
||||
return __get_IPSR();
|
||||
}
|
||||
|
||||
void usb_gpio_config(void)
|
||||
{
|
||||
void usb_gpio_config(void) {
|
||||
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_out_type = GPIO_OUTPUT_PUSH_PULL;
|
||||
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
||||
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
||||
/* dp and dm */
|
||||
@@ -297,36 +278,33 @@ void usb_gpio_config(void)
|
||||
gpio_init(OTG_PIN_GPIO, &gpio_init_struct);
|
||||
gpio_pin_mux_config(OTG_PIN_GPIO, OTG_PIN_DP_SOURCE, OTG_PIN_MUX);
|
||||
gpio_pin_mux_config(OTG_PIN_GPIO, OTG_PIN_DM_SOURCE, OTG_PIN_MUX);
|
||||
#ifdef USB_SOF_OUTPUT_ENABLE
|
||||
crm_periph_clock_enable(OTG_PIN_SOF_GPIO_CLOCK, TRUE);
|
||||
gpio_init_struct.gpio_pins = OTG_PIN_SOF;
|
||||
gpio_init(OTG_PIN_SOF_GPIO, &gpio_init_struct);
|
||||
gpio_pin_mux_config(OTG_PIN_SOF_GPIO, OTG_PIN_SOF_SOURCE, OTG_PIN_MUX);
|
||||
#endif
|
||||
/* otgfs use vbus pin */
|
||||
#ifndef USB_VBUS_IGNORE
|
||||
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
|
||||
#ifdef USB_SOF_OUTPUT_ENABLE
|
||||
crm_periph_clock_enable(OTG_PIN_SOF_GPIO_CLOCK, TRUE);
|
||||
gpio_init_struct.gpio_pins = OTG_PIN_SOF;
|
||||
gpio_init(OTG_PIN_SOF_GPIO, &gpio_init_struct);
|
||||
gpio_pin_mux_config(OTG_PIN_SOF_GPIO, OTG_PIN_SOF_SOURCE, OTG_PIN_MUX);
|
||||
#endif
|
||||
/* otgfs use vbus pin */
|
||||
#ifndef USB_VBUS_IGNORE
|
||||
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
|
||||
}
|
||||
|
||||
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];
|
||||
@@ -337,21 +315,17 @@ 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)
|
||||
{
|
||||
system_ticks++;
|
||||
}
|
||||
uint32_t board_millis(void)
|
||||
{
|
||||
return system_ticks;
|
||||
}
|
||||
void SVC_Handler(void)
|
||||
{
|
||||
}
|
||||
void PendSV_Handler(void)
|
||||
{
|
||||
}
|
||||
volatile uint32_t system_ticks = 0;
|
||||
void SysTick_Handler(void) {
|
||||
system_ticks++;
|
||||
}
|
||||
uint32_t board_millis(void) {
|
||||
return system_ticks;
|
||||
}
|
||||
void SVC_Handler(void) {
|
||||
}
|
||||
void PendSV_Handler(void) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void HardFault_Handler(void) {
|
||||
@@ -363,9 +337,8 @@ void HardFault_Handler(void) {
|
||||
void _init(void) {
|
||||
}
|
||||
|
||||
#ifdef USE_FULL_ASSERT
|
||||
void assert_failed(const char *file, uint32_t line)
|
||||
{
|
||||
#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) */
|
||||
|
Reference in New Issue
Block a user