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