1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @ingroup RTEMSBSPsARMLPC176X |
---|
7 | * |
---|
8 | * @brief Startup code. |
---|
9 | */ |
---|
10 | |
---|
11 | /* |
---|
12 | * Copyright (C) 2008, 2012 embedded brains GmbH & Co. KG |
---|
13 | * |
---|
14 | * Redistribution and use in source and binary forms, with or without |
---|
15 | * modification, are permitted provided that the following conditions |
---|
16 | * are met: |
---|
17 | * 1. Redistributions of source code must retain the above copyright |
---|
18 | * notice, this list of conditions and the following disclaimer. |
---|
19 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
20 | * notice, this list of conditions and the following disclaimer in the |
---|
21 | * documentation and/or other materials provided with the distribution. |
---|
22 | * |
---|
23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
33 | * POSSIBILITY OF SUCH DAMAGE. |
---|
34 | */ |
---|
35 | |
---|
36 | #include <bsp.h> |
---|
37 | #include <bsp/io.h> |
---|
38 | #include <bsp/irq.h> |
---|
39 | #include <bsp/dma.h> |
---|
40 | #include <bsp/bootcard.h> |
---|
41 | #include <bsp/timer.h> |
---|
42 | #include <bsp/irq-generic.h> |
---|
43 | #include <bsp/system-clocks.h> |
---|
44 | #include <bsp/linker-symbols.h> |
---|
45 | #include <bsp/common-types.h> |
---|
46 | #include <bsp/uart-output-char.h> |
---|
47 | |
---|
48 | #ifdef LPC176X_HEAP_EXTEND |
---|
49 | LINKER_SYMBOL( lpc176x_region_heap_0_begin ); |
---|
50 | LINKER_SYMBOL( lpc176x_region_heap_0_size ); |
---|
51 | LINKER_SYMBOL( lpc176x_region_heap_0_end ); |
---|
52 | LINKER_SYMBOL( lpc176x_region_heap_1_begin ); |
---|
53 | LINKER_SYMBOL( lpc176x_region_heap_1_size ); |
---|
54 | LINKER_SYMBOL( lpc176x_region_heap_1_end ); |
---|
55 | extern Heap_Control *RTEMS_Malloc_Heap; |
---|
56 | #endif |
---|
57 | |
---|
58 | static void heap_extend( void ) |
---|
59 | { |
---|
60 | #ifdef LPC176X_HEAP_EXTEND |
---|
61 | _Heap_Extend( RTEMS_Malloc_Heap, |
---|
62 | lpc176x_region_heap_0_begin, |
---|
63 | (uintptr_t) lpc176x_region_heap_0_size, |
---|
64 | NULL ); |
---|
65 | _Heap_Extend( RTEMS_Malloc_Heap, |
---|
66 | lpc176x_region_heap_1_begin, |
---|
67 | (uintptr_t) lpc176x_region_heap_1_size, |
---|
68 | NULL ); |
---|
69 | #endif |
---|
70 | } |
---|
71 | |
---|
72 | /** |
---|
73 | * @brief Console initialization |
---|
74 | */ |
---|
75 | static void initialize_console( void ) |
---|
76 | { |
---|
77 | #ifdef LPC176X_CONFIG_CONSOLE |
---|
78 | |
---|
79 | lpc176x_module_enable( LPC176X_MODULE_UART_0, LPC176X_MODULE_PCLK_DEFAULT ); |
---|
80 | |
---|
81 | lpc176x_pin_select( LPC176X_PIN_UART_0_TXD, LPC176X_PIN_FUNCTION_01 ); |
---|
82 | lpc176x_pin_select( LPC176X_PIN_UART_0_RXD, LPC176X_PIN_FUNCTION_01 ); |
---|
83 | |
---|
84 | BSP_CONSOLE_UART_INIT( LPC176X_PCLK / 16 / LPC176X_UART_BAUD ); |
---|
85 | #endif |
---|
86 | } |
---|
87 | |
---|
88 | void bsp_start( void ) |
---|
89 | { |
---|
90 | /* Initialize console */ |
---|
91 | initialize_console(); |
---|
92 | |
---|
93 | /*Initialize timer*/ |
---|
94 | lpc176x_timer_init( LPC176X_TIMER_1 ); |
---|
95 | lpc176x_timer_start( LPC176X_TIMER_1 ); |
---|
96 | |
---|
97 | /* Interrupts */ |
---|
98 | bsp_interrupt_initialize(); |
---|
99 | |
---|
100 | /* DMA */ |
---|
101 | lpc176x_dma_initialize(); |
---|
102 | |
---|
103 | heap_extend(); |
---|
104 | } |
---|