1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup RTEMSBSPsARMLPC176X |
---|
5 | * |
---|
6 | * @brief Startup code. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2008-2012 embedded brains GmbH. All rights reserved. |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #include <bsp.h> |
---|
18 | #include <bsp/io.h> |
---|
19 | #include <bsp/irq.h> |
---|
20 | #include <bsp/dma.h> |
---|
21 | #include <bsp/bootcard.h> |
---|
22 | #include <bsp/timer.h> |
---|
23 | #include <bsp/irq-generic.h> |
---|
24 | #include <bsp/system-clocks.h> |
---|
25 | #include <bsp/linker-symbols.h> |
---|
26 | #include <bsp/common-types.h> |
---|
27 | #include <bsp/uart-output-char.h> |
---|
28 | |
---|
29 | #ifdef LPC176X_HEAP_EXTEND |
---|
30 | LINKER_SYMBOL( lpc176x_region_heap_0_begin ); |
---|
31 | LINKER_SYMBOL( lpc176x_region_heap_0_size ); |
---|
32 | LINKER_SYMBOL( lpc176x_region_heap_0_end ); |
---|
33 | LINKER_SYMBOL( lpc176x_region_heap_1_begin ); |
---|
34 | LINKER_SYMBOL( lpc176x_region_heap_1_size ); |
---|
35 | LINKER_SYMBOL( lpc176x_region_heap_1_end ); |
---|
36 | extern Heap_Control *RTEMS_Malloc_Heap; |
---|
37 | #endif |
---|
38 | |
---|
39 | static void heap_extend( void ) |
---|
40 | { |
---|
41 | #ifdef LPC176X_HEAP_EXTEND |
---|
42 | _Heap_Extend( RTEMS_Malloc_Heap, |
---|
43 | lpc176x_region_heap_0_begin, |
---|
44 | (uintptr_t) lpc176x_region_heap_0_size, |
---|
45 | NULL ); |
---|
46 | _Heap_Extend( RTEMS_Malloc_Heap, |
---|
47 | lpc176x_region_heap_1_begin, |
---|
48 | (uintptr_t) lpc176x_region_heap_1_size, |
---|
49 | NULL ); |
---|
50 | #endif |
---|
51 | } |
---|
52 | |
---|
53 | /** |
---|
54 | * @brief Console initialization |
---|
55 | */ |
---|
56 | static void initialize_console( void ) |
---|
57 | { |
---|
58 | #ifdef LPC176X_CONFIG_CONSOLE |
---|
59 | |
---|
60 | lpc176x_module_enable( LPC176X_MODULE_UART_0, LPC176X_MODULE_PCLK_DEFAULT ); |
---|
61 | |
---|
62 | lpc176x_pin_select( LPC176X_PIN_UART_0_TXD, LPC176X_PIN_FUNCTION_01 ); |
---|
63 | lpc176x_pin_select( LPC176X_PIN_UART_0_RXD, LPC176X_PIN_FUNCTION_01 ); |
---|
64 | |
---|
65 | BSP_CONSOLE_UART_INIT( LPC176X_PCLK / 16 / LPC176X_UART_BAUD ); |
---|
66 | #endif |
---|
67 | } |
---|
68 | |
---|
69 | void bsp_start( void ) |
---|
70 | { |
---|
71 | /* Initialize console */ |
---|
72 | initialize_console(); |
---|
73 | |
---|
74 | /*Initialize timer*/ |
---|
75 | lpc176x_timer_init( LPC176X_TIMER_1 ); |
---|
76 | lpc176x_timer_start( LPC176X_TIMER_1 ); |
---|
77 | |
---|
78 | /* Interrupts */ |
---|
79 | bsp_interrupt_initialize(); |
---|
80 | |
---|
81 | /* DMA */ |
---|
82 | lpc176x_dma_initialize(); |
---|
83 | |
---|
84 | heap_extend(); |
---|
85 | } |
---|