2020-01-03 16:52:07 +08:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <rthw.h>
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include "cy_device_headers.h"
|
|
|
|
#include "board.h"
|
|
|
|
#include "uart.h"
|
|
|
|
#include "cy_systick.h"
|
|
|
|
#include "cycfg.h"
|
|
|
|
|
|
|
|
#define configTOTAL_HEAP_SIZE (24*1024)
|
|
|
|
/* Allocate the memory for the heap. */
|
2022-12-12 02:12:03 +08:00
|
|
|
rt_align(RT_ALIGN_SIZE)
|
2020-01-03 16:52:07 +08:00
|
|
|
static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
|
|
|
|
/**
|
|
|
|
* This is the timer interrupt service routine.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void SysTick_Handler_CB(void)
|
|
|
|
{
|
|
|
|
/* enter interrupt */
|
|
|
|
rt_interrupt_enter();
|
|
|
|
|
|
|
|
rt_tick_increase();
|
|
|
|
|
|
|
|
/* leave interrupt */
|
|
|
|
rt_interrupt_leave();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void rt_hw_board_init()
|
|
|
|
{
|
|
|
|
/* init systick */
|
2022-01-08 23:29:41 +08:00
|
|
|
init_cycfg_all();
|
2020-01-03 16:52:07 +08:00
|
|
|
|
2022-01-08 23:29:41 +08:00
|
|
|
SystemCoreClockUpdate();
|
2020-01-03 16:52:07 +08:00
|
|
|
|
|
|
|
Cy_SysTick_Init(CY_SYSTICK_CLOCK_SOURCE_CLK_CPU, SystemCoreClock/RT_TICK_PER_SECOND);
|
|
|
|
Cy_SysTick_SetCallback(0, SysTick_Handler_CB);
|
|
|
|
Cy_SysTick_EnableInterrupt();
|
2022-01-08 23:29:41 +08:00
|
|
|
|
2020-01-03 16:52:07 +08:00
|
|
|
rt_system_heap_init((void*)ucHeap, (void*)(ucHeap+configTOTAL_HEAP_SIZE));
|
|
|
|
/* initialize UART device */
|
|
|
|
rt_hw_uart_init();
|
|
|
|
|
2022-01-08 23:29:41 +08:00
|
|
|
#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
|
2020-01-03 16:52:07 +08:00
|
|
|
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*@}*/
|