application.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * File : app.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, 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. * 2010-06-25 Bernard first version
  13. */
  14. /**
  15. * @addtogroup Loongson SoC3210
  16. */
  17. /*@{*/
  18. #include <rtthread.h>
  19. #include <soc3210.h>
  20. struct rt_thread thread;
  21. ALIGN(4)
  22. rt_uint8_t thread_stack[1024];
  23. #include <finsh.h>
  24. void thread_entry(void* parameter)
  25. {
  26. int i = 0;
  27. while (1)
  28. {
  29. rt_kprintf("i = %d, cause: 0x%08x, config: 0x%08x\n", i++, read_c0_cause(), read_c0_config());
  30. rt_kprintf("HSB_MISC_CFG 0x%08x\n", HSB_MISC_REG);
  31. rt_thread_delay(100);
  32. }
  33. }
  34. void thread_test()
  35. {
  36. rt_err_t result = rt_thread_init(&thread,
  37. "tid",
  38. thread_entry, RT_NULL,
  39. &thread_stack, sizeof(thread_stack),
  40. 200,
  41. 5);
  42. if (result == RT_EOK)
  43. rt_thread_startup(&thread);
  44. else
  45. rt_kprintf("init thread failed\n");
  46. }
  47. FINSH_FUNCTION_EXPORT(thread_test, test thread!!);
  48. #ifdef RT_USING_RTGUI
  49. #include <rtgui/rtgui.h>
  50. #include <rtgui/event.h>
  51. #include <rtgui/rtgui_server.h>
  52. #endif
  53. int rt_application_init()
  54. {
  55. #ifdef RT_USING_RTGUI
  56. rtgui_rect_t rect;
  57. rtgui_system_server_init();
  58. /* register dock panel */
  59. rect.x1 = 0;
  60. rect.y1 = 0;
  61. rect.x2 = 400;
  62. rect.y2 = 480;
  63. rtgui_panel_register("panel", &rect);
  64. /* register main panel */
  65. rect.x1 = 400;
  66. rect.y1 = 0;
  67. rect.x2 = 800;
  68. rect.y2 = 480;
  69. rtgui_panel_register("main", &rect);
  70. rtgui_panel_set_default_focused("main");
  71. rt_hw_lcd_init();
  72. #endif
  73. return 0;
  74. }
  75. /*@}*/