board.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. * File : board.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, 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://openlab.rt-thread.com/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2006-09-23 Bernard first version
  13. * 2006-09-24 Bernard add rt_hw_finsh_init implementation
  14. */
  15. #include <rtthread.h>
  16. #include <rthw.h>
  17. #include <s3c44b0.h>
  18. #include "board.h"
  19. /* #define BOARD_DEBUG */
  20. extern void rt_serial_putc(const char ch);
  21. #define DATA_COUNT 0xfff
  22. /**
  23. * @addtogroup wh44b0
  24. */
  25. /*@{*/
  26. void rt_timer_handler(int vector)
  27. {
  28. #ifdef BOARD_DEBUG
  29. rt_kprintf("timer handler, increase a tick\n");
  30. #endif
  31. rt_tick_increase();
  32. }
  33. void rt_hw_port_init(void)
  34. {
  35. /* PORT A GROUP */
  36. /* BIT 9 8 7 6 5 4 3 2 1 0 */
  37. /* A24 A23 A22 A21 A20 A19 A18 A17 A16 A0 */
  38. /* 1 1 1 1 1 1 1 1 1 1 */
  39. PCONA = 0x1ff;
  40. PDATA = 0x2db;
  41. /* PORT B GROUP */
  42. /* BIT 10 9 8 7 6 5 4 3 2 1 0 */
  43. /* /CS5 /CS4 /CS3 /CS2 /CS1 nWBE3 nWBE2 /SRAS /SCAS SCLS SCKE */
  44. /* NC NC RTL8019 USBD12 NV_Flash NC NC Sdram Sdram Sdram Sdram*/
  45. /* 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1 */
  46. PDATB = 0x4f;
  47. PCONB = 0x7cf;
  48. /* PORT C GROUP */
  49. /* BUSWIDTH=16 */
  50. /* PC15 14 13 12 11 10 9 8 */
  51. /* o o RXD1 TXD1 o o o o */
  52. /* NC NC Uart1 Uart1 NC NC NC NC */
  53. /* 01 01 11 11 01 01 01 00 */
  54. /* PC7 6 5 4 3 2 1 0 */
  55. /* o o o o o o o o */
  56. /* NC NC NC NC NFALE NFCLE NFCE NFRB*/
  57. /* 01 01 01 01 01 01 01 00 */
  58. PDATC = 0x3001; /* All IO is low */
  59. PCONC = 0x5f555555;
  60. PUPC = 0x3000; /* PULL UP RESISTOR should be enabled to I/O */
  61. /* PORT D GROUP */
  62. /* PORT D GROUP(I/O OR LCD) */
  63. /* BIT7 6 5 4 3 2 1 0 */
  64. /* VF VM VLINE VCLK VD3 VD2 VD1 VD0 */
  65. /* 01 01 01 01 01 01 01 01 */
  66. PDATD= 0x0;
  67. PCOND= 0xaaaa;
  68. PUPD = 0x00; /* These pins must be set only after CPU's internal LCD controller is enable */
  69. /* PORT E GROUP */
  70. /* Bit 8 7 6 5 4 3 2 1 0 */
  71. /* ENDLAN LED3 LED2 LED1 LED0 BEEP RXD0 TXD0 CLKOUT */
  72. /* 00 01 01 01 01 01 10 10 11 */
  73. PCONE = 0x556b; /*0->input, 1 2->TXD0 RXD0, 3 4->input, 5->led, 6->buzzer, 7->led, 8->CODECLK */
  74. PDATE = 0x57;
  75. PUPE = 0x006; /* disable all pull-up */
  76. /* PORT F GROUP */
  77. /* Bit8 7 6 5 4 3 2 1 0 */
  78. /* IISCLK IISDI IISDO IISLRCK Input Input Input IICSDA IICSCL */
  79. /* 100 010 010 001 00 01 01 10 10 */
  80. PDATF = 0x2f;
  81. PCONF = 0x24900a;
  82. PUPF = 0x1d3;
  83. /* PORT G GROUP */
  84. /* BIT7 6 5 4 3 2 1 0 */
  85. /* INT7 INT6 INT5 INT4 INT3 INT2 INT1 INT0 */
  86. /* S3 S4 S5 S6 NIC EXT IDE USB */
  87. /* 11 11 11 11 11 11 11 11 */
  88. PDATG = 0xfc;
  89. PCONG = 0x000f; /* eint1 is eth interrupt in WH44B0 */
  90. PUPG = 0x00; /* should be enabled */
  91. SPUCR=0x7; /* D15-D0 pull-up disable */
  92. /* all external interrupts are triggered by low level */
  93. EXTINT=0x0;
  94. }
  95. /**
  96. * This function will init lumit4510 board
  97. */
  98. void rt_hw_board_init()
  99. {
  100. /* init port setting */
  101. rt_hw_port_init();
  102. /* set timer0 register */
  103. /* stop timer */
  104. TCON &= ~(0x00000001);
  105. /* dead zone = 0, pre = 150 */
  106. TCFG0 = 0x00000095;
  107. /* all are interrupt mode */
  108. TCFG1 = 0x00000003;
  109. TCNTB0 = DATA_COUNT;
  110. TCMPB0 = 0;
  111. /* manual update */
  112. TCON |= 0x00000002;
  113. /* auto reload on,output inverter off */
  114. TCON &= ~(0x0000000f);
  115. TCON |= (0x00000008);
  116. /* install timer handler */
  117. rt_hw_interrupt_install(INT_TIMER0, rt_timer_handler, RT_NULL);
  118. rt_hw_interrupt_umask(INT_TIMER0);
  119. /* start timer */
  120. TCON |=(0x00000001);
  121. }
  122. void rt_hw_led_set(rt_uint32_t led)
  123. {
  124. if((led & 0x01)==0x01) /* D1 */
  125. PDATC = PDATC | (1<<1) ;
  126. else
  127. PDATC = PDATC & (~(1<<1)) ;
  128. if((led & 0x02)==0x02) /* D2 */
  129. PDATC = PDATC | (1<<2) ;
  130. else
  131. PDATC = PDATC & (~(1<<2)) ;
  132. if((led & 0x04)==0x04) /* D3 */
  133. PDATC = PDATC | (1<<3) ;
  134. else
  135. PDATC = PDATC & (~(1<<3)) ;
  136. }
  137. /* led loop */
  138. void rt_hw_led_flash(void)
  139. {
  140. register int i;
  141. rt_hw_led_set(0x01);
  142. for ( i = 0; i < 2000000; i++);
  143. rt_hw_led_set(0x02);
  144. for ( i = 0; i < 2000000; i++);
  145. rt_hw_led_set(0x04);
  146. for ( i = 0; i < 2000000; i++);
  147. }
  148. #ifdef RT_USING_FINSH
  149. extern void finsh_notify(void);
  150. void rt_serial_isr(int vector)
  151. {
  152. finsh_notify();
  153. }
  154. void rt_hw_finsh_init()
  155. {
  156. /* install UART isr */
  157. rt_hw_interrupt_install(INT_URXD0, rt_serial_isr, RT_NULL);
  158. rt_hw_interrupt_umask(INT_URXD0);
  159. }
  160. #endif
  161. void rt_hw_console_output(const char* string)
  162. {
  163. while (*string)
  164. {
  165. rt_serial_putc(*string++);
  166. }
  167. }
  168. /*@}*/