startup.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2006-08-31 Bernard first implementation
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include "board.h"
  13. #include "intrinsics.h"
  14. /**
  15. * @addtogroup rx62n
  16. */
  17. /*@{*/
  18. extern int rt_application_init(void);
  19. #pragma section="HEAP"
  20. /*******************************************************************************
  21. * Function Name : assert_failed
  22. * Description : Reports the name of the source file and the source line number
  23. * where the assert error has occurred.
  24. * Input : - file: pointer to the source file name
  25. * - line: assert error line source number
  26. * Output : None
  27. * Return : None
  28. *******************************************************************************/
  29. void assert_failed(unsigned char * file, unsigned long line)
  30. {
  31. rt_kprintf("\n\r Wrong parameter value detected on\r\n");
  32. rt_kprintf(" file %s\r\n", file);
  33. rt_kprintf(" line %d\r\n", line);
  34. while (1) ;
  35. }
  36. /**
  37. * This function will startup RT-Thread RTOS.
  38. */
  39. void rtthread_startup(void)
  40. {
  41. /* init board */
  42. rt_hw_board_init();
  43. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  44. /* show version */
  45. rt_show_version();
  46. #endif
  47. #ifdef RT_USING_HEAP
  48. rt_system_heap_init(__segment_end("HEAP"), (void*)RX62N_SRAM_END);
  49. #endif /* RT_USING_HEAP */
  50. /* init scheduler system */
  51. rt_system_scheduler_init();
  52. /* initialize timer */
  53. rt_system_timer_init();
  54. /* init timer thread */
  55. rt_system_timer_thread_init();
  56. /* init application */
  57. rt_application_init();
  58. /* init idle thread */
  59. rt_thread_idle_init();
  60. /* start scheduler */
  61. rt_system_scheduler_start();
  62. /* never reach here */
  63. return ;
  64. }
  65. int main(void)
  66. {
  67. rt_hw_system_freq_init();
  68. __enable_interrupt();
  69. /* disable interrupt first */
  70. rt_hw_interrupt_disable();
  71. /* startup RT-Thread RTOS */
  72. rtthread_startup();
  73. return 0;
  74. }
  75. /*@}*/