1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup lpc176x |
---|
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.org/license/LICENSE. |
---|
21 | */ |
---|
22 | |
---|
23 | #include <bsp.h> |
---|
24 | #include <bsp/io.h> |
---|
25 | #include <bsp/irq.h> |
---|
26 | #include <bsp/dma.h> |
---|
27 | #include <bsp/bootcard.h> |
---|
28 | #include <bsp/timer.h> |
---|
29 | #include <bsp/irq-generic.h> |
---|
30 | #include <bsp/system-clocks.h> |
---|
31 | #include <bsp/linker-symbols.h> |
---|
32 | #include <bsp/common-types.h> |
---|
33 | #include <bsp/uart-output-char.h> |
---|
34 | |
---|
35 | #ifdef LPC176X_HEAP_EXTEND |
---|
36 | LINKER_SYMBOL( lpc176x_region_heap_0_begin ); |
---|
37 | LINKER_SYMBOL( lpc176x_region_heap_0_size ); |
---|
38 | LINKER_SYMBOL( lpc176x_region_heap_0_end ); |
---|
39 | LINKER_SYMBOL( lpc176x_region_heap_1_begin ); |
---|
40 | LINKER_SYMBOL( lpc176x_region_heap_1_size ); |
---|
41 | LINKER_SYMBOL( lpc176x_region_heap_1_end ); |
---|
42 | extern Heap_Control *RTEMS_Malloc_Heap; |
---|
43 | #endif |
---|
44 | |
---|
45 | static void heap_extend( void ) |
---|
46 | { |
---|
47 | #ifdef LPC176X_HEAP_EXTEND |
---|
48 | _Heap_Extend( RTEMS_Malloc_Heap, |
---|
49 | lpc176x_region_heap_0_begin, |
---|
50 | (uintptr_t) lpc176x_region_heap_0_size, |
---|
51 | NULL ); |
---|
52 | _Heap_Extend( RTEMS_Malloc_Heap, |
---|
53 | lpc176x_region_heap_1_begin, |
---|
54 | (uintptr_t) lpc176x_region_heap_1_size, |
---|
55 | NULL ); |
---|
56 | #endif |
---|
57 | } |
---|
58 | |
---|
59 | /** |
---|
60 | * @brief Console initialization |
---|
61 | */ |
---|
62 | static void initialize_console( void ) |
---|
63 | { |
---|
64 | #ifdef LPC176X_CONFIG_CONSOLE |
---|
65 | |
---|
66 | lpc176x_module_enable( LPC176X_MODULE_UART_0, LPC176X_MODULE_PCLK_DEFAULT ); |
---|
67 | |
---|
68 | lpc176x_pin_select( LPC176X_PIN_UART_0_TXD, LPC176X_PIN_FUNCTION_01 ); |
---|
69 | lpc176x_pin_select( LPC176X_PIN_UART_0_RXD, LPC176X_PIN_FUNCTION_01 ); |
---|
70 | |
---|
71 | BSP_CONSOLE_UART_INIT( LPC176X_PCLK / 16 / LPC176X_UART_BAUD ); |
---|
72 | #endif |
---|
73 | } |
---|
74 | |
---|
75 | void bsp_start( void ) |
---|
76 | { |
---|
77 | /* Initialize console */ |
---|
78 | initialize_console(); |
---|
79 | |
---|
80 | /*Initialize timer*/ |
---|
81 | lpc176x_timer_init( LPC176X_TIMER_1 ); |
---|
82 | lpc176x_timer_start( LPC176X_TIMER_1 ); |
---|
83 | |
---|
84 | /* Interrupts */ |
---|
85 | bsp_interrupt_initialize(); |
---|
86 | |
---|
87 | /* DMA */ |
---|
88 | lpc176x_dma_initialize(); |
---|
89 | |
---|
90 | heap_extend(); |
---|
91 | } |
---|