1 2 #include <stdint.h> 3 #include <rthw.h> 4 #include <rtthread.h> 5 #include "cy_device_headers.h" 6 #include "board.h" 7 #include "uart.h" 8 #include "cy_systick.h" 9 #include "cycfg.h" 10 11 #define configTOTAL_HEAP_SIZE (24*1024) 12 /* Allocate the memory for the heap. */ rt_align(RT_ALIGN_SIZE)13rt_align(RT_ALIGN_SIZE) 14 static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; 15 /** 16 * This is the timer interrupt service routine. 17 * 18 */ 19 void SysTick_Handler_CB(void) 20 { 21 /* enter interrupt */ 22 rt_interrupt_enter(); 23 24 rt_tick_increase(); 25 26 /* leave interrupt */ 27 rt_interrupt_leave(); 28 } 29 30 rt_hw_board_init()31void rt_hw_board_init() 32 { 33 /* init systick */ 34 init_cycfg_all(); 35 36 SystemCoreClockUpdate(); 37 38 Cy_SysTick_Init(CY_SYSTICK_CLOCK_SOURCE_CLK_CPU, SystemCoreClock/RT_TICK_PER_SECOND); 39 Cy_SysTick_SetCallback(0, SysTick_Handler_CB); 40 Cy_SysTick_EnableInterrupt(); 41 42 rt_system_heap_init((void*)ucHeap, (void*)(ucHeap+configTOTAL_HEAP_SIZE)); 43 /* initialize UART device */ 44 rt_hw_uart_init(); 45 46 #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) 47 rt_console_set_device(RT_CONSOLE_DEVICE_NAME); 48 #endif 49 } 50 51 /*@}*/ 52