2022-04-14 10:54:53 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c)
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Email Notes
|
|
|
|
* 2019-07-16 Kevin.Liu kevin.liu.mchp@gmail.com First Release
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <atmel_start.h>
|
|
|
|
#include "peripheral_clk_config.h"
|
|
|
|
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include "board.h"
|
|
|
|
|
|
|
|
#ifdef RT_USING_SERIAL
|
|
|
|
extern int rt_hw_uart_init(void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static struct io_descriptor* g_stdio;
|
|
|
|
|
|
|
|
void rt_hw_console_output(const char *str)
|
|
|
|
{
|
|
|
|
io_write(g_stdio, (uint8_t *)str, strlen(str));
|
2022-04-19 14:32:02 +08:00
|
|
|
while (TARGET_IO.stat != 0);
|
2022-04-14 10:54:53 +08:00
|
|
|
}
|
|
|
|
RTM_EXPORT(rt_hw_console_output);
|
|
|
|
|
|
|
|
static inline void hw_board_init_usart(void)
|
|
|
|
{
|
2022-04-19 14:32:02 +08:00
|
|
|
usart_async_get_io_descriptor(&TARGET_IO, &g_stdio);
|
|
|
|
usart_async_enable(&TARGET_IO);
|
2022-04-14 10:54:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the timer interrupt service routine.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void SysTick_Handler(void)
|
|
|
|
{
|
|
|
|
/* enter interrupt */
|
|
|
|
rt_interrupt_enter();
|
|
|
|
|
|
|
|
rt_tick_increase();
|
|
|
|
|
|
|
|
/* leave interrupt */
|
|
|
|
rt_interrupt_leave();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function will initial SAMC21 board.
|
|
|
|
*/
|
|
|
|
void rt_hw_board_init(void)
|
|
|
|
{
|
|
|
|
/* Initializes MCU, drivers and middleware */
|
|
|
|
atmel_start_init();
|
|
|
|
|
|
|
|
/* enable USART stdout module */
|
|
|
|
hw_board_init_usart();
|
|
|
|
|
|
|
|
/* UART driver initialization is open by default */
|
|
|
|
#ifdef RT_USING_SERIAL
|
|
|
|
rt_hw_uart_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* init systick */
|
|
|
|
SysTick_Config(CONF_CPU_FREQUENCY / RT_TICK_PER_SECOND);
|
|
|
|
|
|
|
|
/* set pend exception priority */
|
|
|
|
NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
|
|
|
|
|
|
|
|
#ifdef RT_USING_HEAP
|
2022-08-15 22:38:16 +08:00
|
|
|
#if defined(__ARMCC_VERSION)
|
2022-04-14 10:54:53 +08:00
|
|
|
rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)HEAP_END);
|
|
|
|
#elif __ICCARM__
|
|
|
|
rt_system_heap_init((void*)HEAP_BEGIN, (void*)HEAP_END);
|
|
|
|
#else
|
|
|
|
/* init memory system */
|
|
|
|
rt_system_heap_init((void*)&__bss_end, (void*)HEAP_END);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Set the shell console output device */
|
|
|
|
#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
|
|
|
|
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_COMPONENTS_INIT
|
|
|
|
rt_components_board_init();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*@}*/
|