|
11 | 11 | * Date Author Notes |
12 | 12 | * 2010-06-25 Bernard first version |
13 | 13 | * 2011-08-08 lgnq modified for Loongson LS1B |
| 14 | + * 2019-12-04 Jiaxun Yang Adapt new MIPS generic code |
14 | 15 | */ |
15 | 16 |
|
16 | 17 | #include <rtthread.h> |
|
20 | 21 | #include "uart.h" |
21 | 22 | #include "ls1b.h" |
22 | 23 |
|
| 24 | +#ifdef RT_USING_RTGUI |
| 25 | +#include <rtgui/rtgui.h> |
| 26 | +rt_device_t dc; |
| 27 | +extern void rt_hw_dc_init(void); |
| 28 | +#endif |
| 29 | + |
| 30 | +extern unsigned char __bss_end; |
| 31 | + |
23 | 32 | /** |
24 | 33 | * @addtogroup Loongson LS1B |
25 | 34 | */ |
26 | 35 |
|
27 | 36 | /*@{*/ |
28 | 37 |
|
29 | | -/** |
30 | | - * This is the timer interrupt service routine. |
31 | | - */ |
32 | | -void rt_hw_timer_handler(void) |
33 | | -{ |
34 | | - unsigned int count; |
35 | | - |
36 | | - count = read_c0_compare(); |
37 | | - write_c0_compare(count); |
38 | | - write_c0_count(0); |
39 | | - |
40 | | - /* increase a OS tick */ |
41 | | - rt_tick_increase(); |
42 | | -} |
43 | | - |
44 | | -/** |
45 | | - * This function will initial OS timer |
46 | | - */ |
47 | | -void rt_hw_timer_init(void) |
48 | | -{ |
49 | | - write_c0_compare(CPU_HZ/2/RT_TICK_PER_SECOND); |
50 | | - write_c0_count(0); |
51 | | -} |
52 | | - |
53 | 38 | /** |
54 | 39 | * This function will initial sam7s64 board. |
55 | 40 | */ |
56 | 41 | void rt_hw_board_init(void) |
57 | 42 | { |
58 | | -#ifdef RT_USING_UART |
59 | | - /* init hardware UART device */ |
60 | | - rt_hw_uart_init(); |
| 43 | + /* init hardware interrupt */ |
| 44 | + rt_hw_exception_init(); |
| 45 | + |
| 46 | + /* init hardware interrupt */ |
| 47 | + rt_hw_interrupt_init(); |
| 48 | + |
| 49 | +#ifdef RT_USING_HEAP |
| 50 | + rt_system_heap_init((void*)&__bss_end, (void*)RT_HW_HEAP_END); |
| 51 | +#endif |
| 52 | + |
| 53 | +#ifdef RT_USING_SERIAL |
| 54 | + /* init hardware UART device */ |
| 55 | + rt_hw_uart_init(); |
61 | 56 | #endif |
62 | 57 |
|
63 | 58 | #ifdef RT_USING_CONSOLE |
64 | | - /* set console device */ |
65 | | - rt_console_set_device("uart0"); |
| 59 | + /* set console device */ |
| 60 | + rt_console_set_device(RT_CONSOLE_DEVICE_NAME); |
66 | 61 | #endif |
| 62 | + /* init operating system timer */ |
| 63 | + rt_hw_timer_init(); |
67 | 64 |
|
68 | | - /* init operating system timer */ |
69 | | - rt_hw_timer_init(); |
| 65 | +#ifdef RT_USING_FPU |
| 66 | + /* init hardware fpu */ |
| 67 | + rt_hw_fpu_init(); |
| 68 | +#endif |
70 | 69 |
|
71 | | - rt_kprintf("current sr: 0x%08x\n", read_c0_status()); |
72 | | -} |
| 70 | +#ifdef RT_USING_RTGUI |
| 71 | + rt_device_t dc; |
73 | 72 |
|
74 | | -#define __raw_out_put(unr) \ |
75 | | - while (*ptr) \ |
76 | | - { \ |
77 | | - if (*ptr == '\n') \ |
78 | | - { \ |
79 | | - /* FIFO status, contain valid data */ \ |
80 | | - while (!(UART_LSR(UART##unr##_BASE) & (UARTLSR_TE | UARTLSR_TFE))); \ |
81 | | - /* write data */ \ |
82 | | - UART_DAT(UART##unr##_BASE) = '\r'; \ |
83 | | - } \ |
84 | | - /* FIFO status, contain valid data */ \ |
85 | | - while (!(UART_LSR(UART##unr##_BASE) & (UARTLSR_TE | UARTLSR_TFE))); \ |
86 | | - /* write data */ \ |
87 | | - UART_DAT(UART##unr##_BASE) = *ptr; \ |
88 | | - ptr ++; \ |
89 | | - } |
| 73 | + /* init Display Controller */ |
| 74 | + rt_hw_dc_init(); |
90 | 75 |
|
91 | | -/* UART line status register value */ |
92 | | -#define UARTLSR_ERROR (1 << 7) |
93 | | -#define UARTLSR_TE (1 << 6) |
94 | | -#define UARTLSR_TFE (1 << 5) |
95 | | -#define UARTLSR_BI (1 << 4) |
96 | | -#define UARTLSR_FE (1 << 3) |
97 | | -#define UARTLSR_PE (1 << 2) |
98 | | -#define UARTLSR_OE (1 << 1) |
99 | | -#define UARTLSR_DR (1 << 0) |
100 | | -void rt_hw_console_output(const char *ptr) |
101 | | -{ |
102 | | -#if defined(RT_USING_UART0) |
103 | | - __raw_out_put(0); |
104 | | -#elif defined(RT_USING_UART1) |
105 | | - __raw_out_put(1); |
106 | | -#elif defined(RT_USING_UART3) |
107 | | - __raw_out_put(3); |
| 76 | + /* find Display Controller device */ |
| 77 | + dc = rt_device_find("dc"); |
| 78 | + |
| 79 | + /* set Display Controller device as rtgui graphic driver */ |
| 80 | + rtgui_graphic_set_device(dc); |
108 | 81 | #endif |
109 | | -} |
110 | 82 |
|
| 83 | +#ifdef RT_USING_COMPONENTS_INIT |
| 84 | + rt_components_board_init(); |
| 85 | +#endif |
| 86 | + |
| 87 | +} |
111 | 88 | /*@}*/ |
0 commit comments