board.c 1.1 KB

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