* first compilable version

git-svn-id: trunk@12614 -
This commit is contained in:
florian 2009-01-26 14:28:46 +00:00
parent e86a03553e
commit 5f9b82d38b

View File

@ -31,7 +31,7 @@ unit lpc21x4;
// VECTDATA_FIQ { __TODO } // VECTDATA_FIQ { __TODO }
type type
BITS32 = bitpacked array[0..31] of 0..1; TBitvector32 = bitpacked array[0..31] of 0..1;
{############################################################################## {##############################################################################
@ -350,36 +350,39 @@ unit lpc21x4;
MAM_MAMMAP : DWord absolute $E01FC040; MAM_MAMMAP : DWord absolute $E01FC040;
var var
Undefined_Handler Undefined_Handler,
SWI_Handler, SWI_Handler,
Prefetch_Handler, Prefetch_Handler,
Abort_Handler, Abort_Handler,
FIQ_Handler : pointer; FIQ_Handler : pointer;
procedure InitPLL(m : 1..32;p : 1..8); type
procedure PLLFeed; tm = 1..32;
function GetProcessorClock : DWord; tp = 1..8;
procedure InitPLL(m : tm;p : tp);
procedure PLLFeed;
function GetProcessorClock(CrystalFrequency : DWord) : DWord;
implementation implementation
procedure PLLFeed; procedure PLLFeed;
begin begin
SCB_PLLFEED:=$aa SCB_PLLFEED:=$aa;
SCB_PLLFEED:=$55 SCB_PLLFEED:=$55;
end; end;
function GetProcessorClock(CrystalFrequency : DWord) : DWord; function GetProcessorClock(CrystalFrequency : DWord) : DWord;
begin begin
if (TBitvector32(SCB_PLLSTAT)[8] and 1)<>0 then if (TBitvector32(SCB_PLLSTAT)[8] and 1)<>0 then
Result:=((SCB_PLLSTAT and $f)+1)*CrystalFrequency; GetProcessorClock:=((SCB_PLLSTAT and $f)+1)*CrystalFrequency
else else
Result:=CrystalFrequency; GetProcessorClock:=CrystalFrequency;
end; end;
procedure InitPLL(m : 1..32;p : 1..8); procedure InitPLL(m : tm;p : tp);
begin begin
case p of case p of
1: p:=0; 1: p:=0;
@ -410,35 +413,51 @@ unit lpc21x4;
PLLFeed; PLLFeed;
end; end;
procedure PASCALMAIN; external name 'PASCALMAIN';
begin begin
asm asm
// code derived from phillips appnote 10254 // code derived from phillips appnote 10254
.init .init
Entry: ldr pc, .Lstart
ldr pc, _start ldr pc, .LUndefined_Addr
ldr pc, Undefined_Addr ldr pc, .LSWI_Addr
ldr pc, SWI_Addr ldr pc, .LPrefetch_Addr
ldr pc, Prefetch_Addr ldr pc, .LAbort_Addr
ldr pc, Abort_Addr
// signature // signature
nop nop
ldr pc, [PC, #-0xFF0] // load irq vector from vic ldr pc, [PC, #-0xFF0] // load irq vector from vic
ldr pc, FIQ_Addr ldr pc, .LFIQ_Addr
Undefined_Addr: .LUndefined_Addr:
ldr ldr r0,.L1
ldr pc,[r0]
.LSWI_Addr:
ldr r0,.L2
ldr pc,[r0]
.LPrefetch_Addr:
ldr r0,.L3
ldr pc,[r0]
.LAbort_Addr:
ldr r0,.L4
ldr pc,[r0]
.LFIQ_Addr:
ldr r0,.L5
ldr pc,[r0]
.L1: .L1:
.word Un .word Undefined_Handler
SWI_Handler: .L2:
B SWI_Handler .word SWI_Handler
Prefetch_Handler: .L3:
B Prefetch_Handler .word Prefetch_Handler
Abort_Handler: .L4:
B Abort_Handler .word Abort_Handler
FIQ_Handler: .L5:
B FIQ_Handler .word FIQ_Handler
_start:
{ .Lstart:
(*
Set SP for Supervisor mode. Depending upon Set SP for Supervisor mode. Depending upon
the stack the application needs this value the stack the application needs this value
needs to be set. needs to be set.
@ -446,10 +465,10 @@ _start:
but if this point is entered by any but if this point is entered by any
other means than reset, the stack pointer other means than reset, the stack pointer
needs to be set explicity needs to be set explicity
} *)
// LDR SP,=0x40001000 // LDR SP,=0x40001000
{ (*
Setting up SP for IRQ and FIQ mode. Setting up SP for IRQ and FIQ mode.
Change mode before setting each one Change mode before setting each one
move back again to Supervisor mode move back again to Supervisor mode
@ -458,12 +477,12 @@ _start:
counter The stack pointers must be counter The stack pointers must be
initialized for interrupts to be initialized for interrupts to be
used later. used later.
} *)
{ (*
setup for fiq and irq interrupt stacks to run setup for fiq and irq interrupt stacks to run
below current stack by 1000. below current stack by 1000.
} *)
mov r0, sp // copy current stack pointer mov r0, sp // copy current stack pointer
sub r0, r0, #1000 // make irq stack pointer sub r0, r0, #1000 // make irq stack pointer
sub r1, r0, #1000 // make fiq stack pointer sub r1, r0, #1000 // make fiq stack pointer
@ -474,5 +493,7 @@ _start:
msr cpsr_c, #0x13 // supervisor mode F,I enabled msr cpsr_c, #0x13 // supervisor mode F,I enabled
bl PASCALMAIN bl PASCALMAIN
.text
end; end;
end. end.