board.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * File : board.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2009-09-22 Bernard add board.h to this bsp
  13. * 2018-09-02 xuzhuoyi modify for TMS320F28379D version
  14. */
  15. #include <rtthread.h>
  16. #include "board.h"
  17. #include "F28x_Project.h"
  18. extern interrupt void RTOSINT_Handler();
  19. /**
  20. * This is the timer interrupt service routine.
  21. *
  22. */
  23. interrupt void cpu_timer2_isr (void)
  24. {
  25. CpuTimer2Regs.TCR.all = 0x8000;
  26. /* enter interrupt */
  27. rt_interrupt_enter();
  28. rt_tick_increase();
  29. /* leave interrupt */
  30. rt_interrupt_leave();
  31. }
  32. /**
  33. * This function will initial STM32 board.
  34. */
  35. void rt_hw_board_init()
  36. {
  37. /* Configure the system clock @ 84 Mhz */
  38. InitSysCtrl();
  39. DINT;
  40. InitPieCtrl();
  41. IER = 0x0000;
  42. IFR = 0x0000;
  43. InitPieVectTable();
  44. EALLOW; // This is needed to write to EALLOW protected registers
  45. PieVectTable.TIMER2_INT = &cpu_timer2_isr;
  46. PieVectTable.RTOS_INT = &RTOSINT_Handler;
  47. EDIS;
  48. InitCpuTimers();
  49. ConfigCpuTimer(&CpuTimer2, 200, 1000000 / RT_TICK_PER_SECOND);
  50. CpuTimer2Regs.TCR.all = 0x4000;
  51. IER |= M_INT14;
  52. #ifdef RT_USING_HEAP
  53. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  54. #endif
  55. #ifdef RT_USING_COMPONENTS_INIT
  56. rt_components_board_init();
  57. #endif
  58. #ifdef RT_USING_CONSOLE
  59. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  60. #endif
  61. }