1 |
786 |
skrzyp |
#ifndef CYGONCE_HAL_PLATFORM_SETUP_H
|
2 |
|
|
#define CYGONCE_HAL_PLATFORM_SETUP_H
|
3 |
|
|
|
4 |
|
|
/*=============================================================================
|
5 |
|
|
//
|
6 |
|
|
// hal_platform_setup.h
|
7 |
|
|
//
|
8 |
|
|
// Platform specific support for HAL (assembly code)
|
9 |
|
|
//
|
10 |
|
|
//=============================================================================
|
11 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
12 |
|
|
// -------------------------------------------
|
13 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
14 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
15 |
|
|
//
|
16 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
17 |
|
|
// the terms of the GNU General Public License as published by the Free
|
18 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
19 |
|
|
// version.
|
20 |
|
|
//
|
21 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
22 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
23 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
24 |
|
|
// for more details.
|
25 |
|
|
//
|
26 |
|
|
// You should have received a copy of the GNU General Public License
|
27 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
28 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
29 |
|
|
//
|
30 |
|
|
// As a special exception, if other files instantiate templates or use
|
31 |
|
|
// macros or inline functions from this file, or you compile this file
|
32 |
|
|
// and link it with other works to produce a work based on this file,
|
33 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
34 |
|
|
// the GNU General Public License. However the source code for this file
|
35 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
36 |
|
|
// General Public License v2.
|
37 |
|
|
//
|
38 |
|
|
// This exception does not invalidate any other reasons why a work based
|
39 |
|
|
// on this file might be covered by the GNU General Public License.
|
40 |
|
|
// -------------------------------------------
|
41 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
42 |
|
|
//=============================================================================
|
43 |
|
|
//#####DESCRIPTIONBEGIN####
|
44 |
|
|
//
|
45 |
|
|
// Author(s): jani
|
46 |
|
|
// Contributors:
|
47 |
|
|
// Date: 2004-09-12
|
48 |
|
|
// Purpose: LPC2XXX/P2106 platform specific support routines
|
49 |
|
|
// Description:
|
50 |
|
|
// Usage: #include <cyg/hal/hal_platform_setup.h>
|
51 |
|
|
//
|
52 |
|
|
//####DESCRIPTIONEND####
|
53 |
|
|
//
|
54 |
|
|
//===========================================================================*/
|
55 |
|
|
|
56 |
|
|
#include <pkgconf/system.h>
|
57 |
|
|
#include <cyg/hal/var_io.h>
|
58 |
|
|
|
59 |
|
|
//===========================================================================*/
|
60 |
|
|
|
61 |
|
|
.macro _led_init
|
62 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_IO_BASE
|
63 |
|
|
ldr r1,=(1<<7) // GPIO0 pins 7 is LED output
|
64 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IODIR]
|
65 |
|
|
.endm
|
66 |
|
|
|
67 |
|
|
.macro _led x
|
68 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_IO_BASE
|
69 |
|
|
ldr r1,=(1<<7)
|
70 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IOCLR]
|
71 |
|
|
ldr r1,=((\x & 1)<<7)
|
72 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IOSET]
|
73 |
|
|
.endm
|
74 |
|
|
|
75 |
|
|
.macro _pll_init
|
76 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_SCB_BASE
|
77 |
|
|
|
78 |
|
|
mov r2,#0xAA
|
79 |
|
|
mov r3,#0x55
|
80 |
|
|
|
81 |
|
|
mov r1,#1 // enable PLL
|
82 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLCON]
|
83 |
|
|
|
84 |
|
|
mov r1,#(0x20 | (CYGNUM_HAL_ARM_LPC2XXX_PLL_MUL - 1))
|
85 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLCFG]
|
86 |
|
|
|
87 |
|
|
str r2,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED] // update PLL registers
|
88 |
|
|
str r3,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]
|
89 |
|
|
|
90 |
|
|
1:
|
91 |
|
|
ldr r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLSTAT] // wait for it to lock
|
92 |
|
|
ands r1,r1,#(1<<10)
|
93 |
|
|
beq 1b
|
94 |
|
|
|
95 |
|
|
mov r1,#3 // connect PLL
|
96 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLCON]
|
97 |
|
|
|
98 |
|
|
str r2,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED] // update PLL registers
|
99 |
|
|
str r3,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]
|
100 |
|
|
|
101 |
|
|
.endm
|
102 |
|
|
|
103 |
|
|
.macro _mem_init
|
104 |
|
|
mov r0,#0 // copy first 64 bytes of flash to RAM
|
105 |
|
|
mov r1,#0x40000000
|
106 |
|
|
mov r2,#0x40
|
107 |
|
|
1:
|
108 |
|
|
ldr r3,[r0,#4]!
|
109 |
|
|
str r3,[r1,#4]!
|
110 |
|
|
cmps r0,r2
|
111 |
|
|
bne 1b
|
112 |
|
|
|
113 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_SCB_BASE
|
114 |
|
|
mov r1,#2
|
115 |
|
|
// interrupt vector table is mapped to flash (1) or RAM(2)
|
116 |
|
|
str r1, [r0,#CYGARC_HAL_LPC2XXX_REG_MEMMAP]
|
117 |
|
|
mov r1,#4
|
118 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_MAMTIM] // flash timings
|
119 |
|
|
mov r1,#2
|
120 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_MAMCR] // enable full MAM
|
121 |
|
|
.endm
|
122 |
|
|
|
123 |
|
|
.macro _gpio_init
|
124 |
|
|
// enable RX and TX on UART0 and the button
|
125 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_PIN_BASE
|
126 |
|
|
ldr r1,=0x80000005
|
127 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PINSEL0]
|
128 |
|
|
.endm
|
129 |
|
|
|
130 |
|
|
#define CYGHWR_LED_MACRO _led \x
|
131 |
|
|
|
132 |
|
|
//===========================================================================*/
|
133 |
|
|
|
134 |
|
|
#if defined(CYG_HAL_STARTUP_ROM)
|
135 |
|
|
|
136 |
|
|
.macro _setup
|
137 |
|
|
|
138 |
|
|
_pll_init
|
139 |
|
|
|
140 |
|
|
_mem_init
|
141 |
|
|
|
142 |
|
|
_gpio_init
|
143 |
|
|
|
144 |
|
|
_led_init
|
145 |
|
|
|
146 |
|
|
.endm
|
147 |
|
|
|
148 |
|
|
#define CYGSEM_HAL_ROM_RESET_USES_JUMP
|
149 |
|
|
|
150 |
|
|
#else
|
151 |
|
|
|
152 |
|
|
.macro _setup
|
153 |
|
|
.endm
|
154 |
|
|
|
155 |
|
|
#endif
|
156 |
|
|
|
157 |
|
|
#define PLATFORM_SETUP1 _setup
|
158 |
|
|
|
159 |
|
|
//-----------------------------------------------------------------------------
|
160 |
|
|
// end of hal_platform_setup.h
|
161 |
|
|
#endif // CYGONCE_HAL_PLATFORM_SETUP_H
|