#define GPBCON (*(volatile unsigned *)0x56000010) #define GPBDAT (*(volatile unsigned *)0x56000014) #define GPBUP (*(volatile unsigned *)0x56000018) #define MPLL100MHz 0x0007f022 #define CLKDIV2 0x02 #define rMPLLCON (*(volatile unsigned *)0x4c000004) #define rCLKDIVN (*(volatile unsigned *)0x4c000014) int main() { int i = 0; int count = 0; int LEDS[4] = {0x1c0, 0x1a0, 0x160, 0xe0}; rMPLLCON = MPLL100MHz; rCLKDIVN = CLKDIV2; GPBCON = 0x00155555; GPBUP = GPBUP & 0xFF00; while(1) { for(count = 0; count != 4; ++ count) { GPBDAT=LEDS[count]; for(i = 0; i<0x30000;i++ ); } } }
命令行下的编译流程我就不写了,直接把makefile贴在这里吧led.bin:led.c arm-linux-gcc -g -c -o led.o led.c arm-linux-ld -Ttext 0x30000000 -g led.o -o led.elf -e main arm-linux-objcopy -O binary -S led.elf led.bin .Python:clean clean: rm *.o led.elf led.bin
这里我想提醒一下,纯C的makefile与汇编的makefile是有点区别的,由于C的主函数是main,但是arm执行环境并不知道是main,因此需要显式的指定arm入口函数-e main,其他的就没什么可说的了,多文件编译可以使用推导,我相信到这里大家都能自己编写多文件的makefile了,我就不多说了,