1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup lpc24xx |
---|
5 | * |
---|
6 | * @brief Startup code. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2008-2012 embedded brains GmbH. All rights reserved. |
---|
11 | * |
---|
12 | * embedded brains GmbH |
---|
13 | * Obere Lagerstr. 30 |
---|
14 | * 82178 Puchheim |
---|
15 | * Germany |
---|
16 | * <rtems@embedded-brains.de> |
---|
17 | * |
---|
18 | * The license and distribution terms for this file may be |
---|
19 | * found in the file LICENSE in this distribution or at |
---|
20 | * http://www.rtems.com/license/LICENSE. |
---|
21 | */ |
---|
22 | |
---|
23 | #include <bsp.h> |
---|
24 | #include <bsp/bootcard.h> |
---|
25 | #include <bsp/dma.h> |
---|
26 | #include <bsp/io.h> |
---|
27 | #include <bsp/irq-generic.h> |
---|
28 | #include <bsp/irq.h> |
---|
29 | #include <bsp/linker-symbols.h> |
---|
30 | #include <bsp/lpc24xx.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 | static void initialize_console(void) |
---|
65 | { |
---|
66 | #ifdef LPC24XX_CONFIG_CONSOLE |
---|
67 | static const lpc24xx_pin_range pins [] = { |
---|
68 | LPC24XX_PIN_UART_0_TXD, |
---|
69 | LPC24XX_PIN_UART_0_RXD, |
---|
70 | LPC24XX_PIN_TERMINAL |
---|
71 | }; |
---|
72 | |
---|
73 | lpc24xx_module_enable(LPC24XX_MODULE_UART_0, LPC24XX_MODULE_PCLK_DEFAULT); |
---|
74 | lpc24xx_pin_config(&pins [0], LPC24XX_PIN_SET_FUNCTION); |
---|
75 | BSP_CONSOLE_UART_INIT(LPC24XX_PCLK / 16 / LPC24XX_UART_BAUD); |
---|
76 | #endif |
---|
77 | } |
---|
78 | |
---|
79 | void bsp_start(void) |
---|
80 | { |
---|
81 | /* Initialize Timer 1 */ |
---|
82 | lpc24xx_module_enable(LPC24XX_MODULE_TIMER_1, LPC24XX_MODULE_PCLK_DEFAULT); |
---|
83 | |
---|
84 | /* Initialize standard timer */ |
---|
85 | lpc24xx_timer_initialize(); |
---|
86 | |
---|
87 | initialize_console(); |
---|
88 | |
---|
89 | /* Interrupts */ |
---|
90 | bsp_interrupt_initialize(); |
---|
91 | |
---|
92 | /* DMA */ |
---|
93 | lpc24xx_dma_initialize(); |
---|
94 | } |
---|