1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup lpc24xx |
---|
5 | * |
---|
6 | * @brief Startup code. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2008, 2009 |
---|
11 | * embedded brains GmbH |
---|
12 | * Obere Lagerstr. 30 |
---|
13 | * D-82178 Puchheim |
---|
14 | * Germany |
---|
15 | * <rtems@embedded-brains.de> |
---|
16 | * |
---|
17 | * The license and distribution terms for this file may be |
---|
18 | * found in the file LICENSE in this distribution or at |
---|
19 | * http://www.rtems.com/license/LICENSE. |
---|
20 | */ |
---|
21 | |
---|
22 | #include <bsp.h> |
---|
23 | #include <bsp/bootcard.h> |
---|
24 | #include <bsp/dma.h> |
---|
25 | #include <bsp/io.h> |
---|
26 | #include <bsp/irq-generic.h> |
---|
27 | #include <bsp/irq.h> |
---|
28 | #include <bsp/linker-symbols.h> |
---|
29 | #include <bsp/lpc24xx.h> |
---|
30 | #include <bsp/stackalloc.h> |
---|
31 | #include <bsp/system-clocks.h> |
---|
32 | #include <bsp/uart-output-char.h> |
---|
33 | |
---|
34 | #ifdef LPC24XX_HEAP_EXTEND |
---|
35 | LINKER_SYMBOL(lpc24xx_region_heap_0_begin); |
---|
36 | LINKER_SYMBOL(lpc24xx_region_heap_0_size); |
---|
37 | LINKER_SYMBOL(lpc24xx_region_heap_0_end); |
---|
38 | |
---|
39 | LINKER_SYMBOL(lpc24xx_region_heap_1_begin); |
---|
40 | LINKER_SYMBOL(lpc24xx_region_heap_1_size); |
---|
41 | LINKER_SYMBOL(lpc24xx_region_heap_1_end); |
---|
42 | |
---|
43 | extern Heap_Control *RTEMS_Malloc_Heap; |
---|
44 | #endif |
---|
45 | |
---|
46 | void bsp_pretasking_hook(void) |
---|
47 | { |
---|
48 | #ifdef LPC24XX_HEAP_EXTEND |
---|
49 | _Heap_Extend( |
---|
50 | RTEMS_Malloc_Heap, |
---|
51 | lpc24xx_region_heap_0_begin, |
---|
52 | (uintptr_t) lpc24xx_region_heap_0_size, |
---|
53 | NULL |
---|
54 | ); |
---|
55 | _Heap_Extend( |
---|
56 | RTEMS_Malloc_Heap, |
---|
57 | lpc24xx_region_heap_1_begin, |
---|
58 | (uintptr_t) lpc24xx_region_heap_1_size, |
---|
59 | NULL |
---|
60 | ); |
---|
61 | #endif |
---|
62 | } |
---|
63 | |
---|
64 | void bsp_start(void) |
---|
65 | { |
---|
66 | /* Initialize Timer 1 */ |
---|
67 | lpc24xx_module_enable(LPC24XX_MODULE_TIMER_1, LPC24XX_MODULE_CCLK); |
---|
68 | |
---|
69 | /* Initialize standard timer */ |
---|
70 | lpc24xx_timer_initialize(); |
---|
71 | |
---|
72 | /* Initialize console */ |
---|
73 | #ifdef LPC24XX_CONFIG_CONSOLE |
---|
74 | lpc24xx_module_enable(LPC24XX_MODULE_UART_0, LPC24XX_MODULE_CCLK); |
---|
75 | lpc24xx_io_config(LPC24XX_MODULE_UART_0, LPC24XX_CONFIG_CONSOLE); |
---|
76 | BSP_CONSOLE_UART_INIT(lpc24xx_cclk() / 16 / LPC24XX_UART_BAUD); |
---|
77 | #endif |
---|
78 | |
---|
79 | /* Interrupts */ |
---|
80 | if (bsp_interrupt_initialize() != RTEMS_SUCCESSFUL) { |
---|
81 | _CPU_Fatal_halt(0xe); |
---|
82 | } |
---|
83 | |
---|
84 | /* DMA */ |
---|
85 | lpc24xx_dma_initialize(); |
---|
86 | |
---|
87 | /* Task stacks */ |
---|
88 | #ifdef LPC24XX_SPECIAL_TASK_STACKS_SUPPORT |
---|
89 | bsp_stack_initialize( |
---|
90 | bsp_section_stack_begin, |
---|
91 | (uintptr_t) bsp_section_stack_size |
---|
92 | ); |
---|
93 | #endif |
---|
94 | |
---|
95 | /* UART configurations */ |
---|
96 | #ifdef LPC24XX_CONFIG_UART_1 |
---|
97 | lpc24xx_module_enable(LPC24XX_MODULE_UART_1, LPC24XX_MODULE_CCLK); |
---|
98 | lpc24xx_io_config(LPC24XX_MODULE_UART_1, LPC24XX_CONFIG_UART_1); |
---|
99 | #endif |
---|
100 | #ifdef LPC24XX_CONFIG_UART_2 |
---|
101 | lpc24xx_module_enable(LPC24XX_MODULE_UART_2, LPC24XX_MODULE_CCLK); |
---|
102 | lpc24xx_io_config(LPC24XX_MODULE_UART_2, LPC24XX_CONFIG_UART_2); |
---|
103 | #endif |
---|
104 | #ifdef LPC24XX_CONFIG_UART_3 |
---|
105 | lpc24xx_module_enable(LPC24XX_MODULE_UART_3, LPC24XX_MODULE_CCLK); |
---|
106 | lpc24xx_io_config(LPC24XX_MODULE_UART_3, LPC24XX_CONFIG_UART_3); |
---|
107 | #endif |
---|
108 | } |
---|