//start.s
.global _start
_start:
ldr sp, =0xD0030000 @初始化堆栈
b main
//main.c
#define GPH0CON (*(volatile unsigned int *)0xE0200C00)
#define GPH0DAT (*(volatile unsigned int *)0xE0200C04)
void led_init(void)
{
/* 配置GPH0_0,GPH0_1,GPH0_2,GPH0_3为输出引脚 */
GPH0CON = 0x1111;
}
void delay(void)
{
volatile int i = 0x100000;
while (i--);
}
void led(int i)
{
GPH0DAT=0x01<<i;
}
void main(void)
{
int i = 0;
led_init();
while (1)
{
i=i%4;
led(i);
delay();
i++;
}
}
//makefile
my_test.bin:clean test.bin
./mktiny210spl.exe test.bin my_test.bin
test.bin:start.s main.c
arm-linux-gcc -nostdlib -c -o start.o start.s
arm-linux-gcc -nostdlib -c -o main.o main.c
arm-linux-ld -Ttext 0xD0020010 start.o main.o -o test_elf
arm-linux-objcopy -O binary -S test_elf test.bin
clean:
rm -rf test_elf *.bin *.o