-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlpc.h
executable file
·67 lines (50 loc) · 1.67 KB
/
lpc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "lpc21xx.h"
// ----------------- The memory Map ------------------------------------------
// Entire VM memory, in kilobytes
#define MEMSIZE (14*1024/CELL)
// All sizes are specified in bytes, must be divisable by CELL!
// Stack sizes
#define RETURN_STACK (1024/CELL)
#define PAR_STACK (1024/CELL)
// User variable area
#define USER_S (400/CELL)
// Terminal input buffer
#define TIB_S (80/CELL)
// Variable memory storage
#define VM_S (400/CELL)
// Pad text buffer
#define PAD_S (80/CELL)
// Prototypes
void putCharacter(int ch);
// ------------------- Platform specific IO Interface ------------------------
#define LINEFEED '\r'
void initIO(void)
{
// configure IO pins
PINSEL0 = 0x005505;
//config the uart 0
UART0_LCR = 0x83; // 8 bits, no Parity, 1 Stop bit
UART0_DLL = 5; // 56700 Baud @ 18432kHz xtal Clock
UART0_DLM = 0;
UART0_LCR = 0x03; // DLAB = 0
UART0_FCR = 0x01; // Must set bit0 for UART to work at alll(apparently)
//UART0_IER = 0x01; //enable rx data availbe interrupt
//VICVectAddr5 = (unsigned long)uart_rx0; // set interrupt vector in 0
//VICVectCntl5 = 0x20 | 6; // use it for use it for uart0 rx Interrupt
//VICIntEnable = (1<<6); //set bit 6 to enable uart0 interrupt!
}
int kbhit() // Returns non-zero if KB hit, 0 if not.
{
return (UART0_LSR & 0x01);
}
int getCharacter()
{
int ch;
ch = UART0_RBR;
return (ch);
}
void putCharacter(int ch)
{
while (((UART0_LSR & 0x20) == 0)) ; // wait till empty
UART0_THR = ch; // send character
}