分类: LINUX
2010-07-21 17:46:26
cpu: s3c2410;
板子: SMDK2410;
.text
.global _start
_start:
ldr r0,=0x56000010
mov r1,#0x0
str r1,[r0]
ldr sp,=1024*4
bl main
halt_loop:
b halt_loop
int main()
{
unsigned char c;
uart0_init();
c = 'a';
while(1)
{
c = getc_dancy();
if (isDigit(c) || isLetter(c))
putc_dancy(c++);
return 0;
}
void uart0_init(void)
{
GPHCON |= 0xa0;
GPHUP = 0x0c;
ULCON0 = 0x03;
UCON0 = 0x05;
UFCON0 = 0x00;
UMCON0 = 0x00;
UBRDIV0 = UART_BRD;
}
void putc_dancy(unsigned char c)
{
while (!(UTRSTAT0 & TXD0READY));
UTXH0 = c;
}
unsigned char getc_dancy(void)
{
while (!(UTRSTAT0 & RXD0READY));
return URXH0;
}
int isDigit(unsigned char c)
{
if (c >= '0' && c <= '9')
return 1;
else
return 0;
}
int isLetter(unsigned char c)
{
if (c >= 'a' && c <= 'z')
return 1;
else if (c >= 'A' && c <= 'Z')
return 1;
else
return 0;
}
uart.bin: head.S main.c
arm-linux-gcc -g -c -o head.o head.S
arm-linux-gcc -g -c -o main.o main.c
# arm-linux-ld -Ttext 0x30008000 -g head.o main.o -o uart
arm-linux-ld -Tuart.lds -o uart head.o main.o
arm-linux-objcopy -O binary -S uart uart.bin
# arm-linux-objdump -D -m arm uart > uart.dis
clean:
rm -f uart.bin uart_elf *.o uart
SECTIONS {
. = 0x30008000;
.text : { *(.text) }
.rodata ALIGN(4) : {*(.rodata)}
.data ALIGN(4) : { *(.data) }
.bss ALIGN(4) : { *(.bss) *(COMMON) }
}