board.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * File : board.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2009 RT-Thread Develop 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. * 2006-03-24 Bernard first implementation
  13. * 2006-05-05 Bernard add DATA_COUNT definition
  14. * 2006-10-05 Alsor.Z for s3c2410x porting
  15. * 2007-11-20 Yi.Qiu add lcd,touch,console
  16. */
  17. #include <rtthread.h>
  18. #include <rthw.h>
  19. #include "board.h"
  20. #include "led.h"
  21. /**
  22. * @addtogroup mini2440
  23. */
  24. /*@{*/
  25. #if defined(__CC_ARM)
  26. extern int Image$$ER_ZI$$ZI$$Base;
  27. extern int Image$$ER_ZI$$ZI$$Length;
  28. extern int Image$$ER_ZI$$ZI$$Limit;
  29. #elif (defined (__GNUC__))
  30. rt_uint8_t _irq_stack_start[1024];
  31. rt_uint8_t _fiq_stack_start[1024];
  32. rt_uint8_t _undefined_stack_start[512];
  33. rt_uint8_t _abort_stack_start[512];
  34. rt_uint8_t _svc_stack_start[4096] RT_SECTION(".nobss");
  35. #endif
  36. #if defined(__CC_ARM)
  37. extern int Image$$RW_IRAM1$$ZI$$Limit;
  38. #define HEAP_BEGIN ((void*)&Image$$RW_IRAM1$$ZI$$Limit)
  39. #elif defined(__GNUC__)
  40. extern int __bss_end;
  41. #define HEAP_BEGIN (((void*)&__bss_end) + 0x1000)
  42. #endif
  43. #define HEAP_END (void*)(0x33F00000)
  44. extern rt_uint32_t PCLK, FCLK, HCLK, UCLK;
  45. extern void rt_hw_clock_init(void);
  46. extern void rt_hw_mmu_init(void);
  47. extern void rt_hw_get_clock(void);
  48. extern void rt_hw_set_dividor(rt_uint8_t hdivn, rt_uint8_t pdivn);
  49. extern void rt_hw_set_clock(rt_uint8_t sdiv, rt_uint8_t pdiv, rt_uint8_t mdiv);
  50. /**
  51. * This function will handle rtos timer
  52. */
  53. static void rt_timer_handler(int vector, void *param)
  54. {
  55. rt_tick_increase();
  56. }
  57. /**
  58. * This function will init timer4 for system ticks
  59. */
  60. static void rt_hw_timer_init(void)
  61. {
  62. /* timer4, pre = 15+1 */
  63. TCFG0 &= 0xffff00ff;
  64. TCFG0 |= 15 << 8;
  65. /* all are interrupt mode,set Timer 4 MUX 1/4 */
  66. TCFG1 &= 0xfff0ffff;
  67. TCFG1 |= 0x00010000;
  68. TCNTB4 = (rt_int32_t)(PCLK / (4 *16* RT_TICK_PER_SECOND)) - 1;
  69. /* manual update */
  70. TCON = TCON & (~(0x0f<<20)) | (0x02<<20);
  71. /* install interrupt handler */
  72. rt_hw_interrupt_install(INTTIMER4, rt_timer_handler, RT_NULL, "tick");
  73. rt_hw_interrupt_umask(INTTIMER4);
  74. /* start timer4, reload */
  75. TCON = TCON & (~(0x0f<<20)) | (0x05<<20);
  76. }
  77. /**
  78. * This function will init s3ceb2410 board
  79. */
  80. void rt_hw_board_init(void)
  81. {
  82. rt_hw_cpu_icache_enable();
  83. rt_hw_cpu_dcache_enable();
  84. /* init hardware interrupt */
  85. rt_hw_interrupt_init();
  86. /* initialize the system clock */
  87. rt_hw_clock_init();
  88. /* Get the clock */
  89. rt_hw_get_clock();
  90. /* initialize led port */
  91. rt_hw_led_init();
  92. /* initialize mmu */
  93. rt_hw_mmu_init();
  94. /* initialize timer4 */
  95. rt_hw_timer_init();
  96. /* initialize system heap */
  97. rt_system_heap_init(HEAP_BEGIN, HEAP_END);
  98. rt_components_board_init();
  99. #ifdef RT_USING_CONSOLE
  100. rt_console_set_device("uart0");
  101. #endif
  102. }
  103. /*@}*/