/* c.c */ #define GPJ2CON *((volatile unsigned int *)0xE0200280) #define GPJ2DAT *((volatile unsigned int *)0xE0200284) #define LED_ON 0 #define LED_OFF 1 #define GPD0CON *((volatile unsigned int *)0xE02000A0) #define GPD0DAT *((volatile unsigned int *)0xE02000A4) #define BEEP_ON 1 #define BEEP_OFF 0 typedef unsigned char u8_t; void delay(int n) { unsigned int i, j; for(i=0; i<n; i++) for(j=0; j< 1000000; j++) j = j + 0; } void led_init(void) { GPJ2CON &= 0XFFFF0000; // 好习惯 GPJ2CON |= 0x00001111; // 4个等处在 output 模式 } void led(u8_t t1, u8_t t2, u8_t t3, u8_t t4) { u8_t stat = 0; stat += t1; stat <<= 1; stat += t2; stat <<= 1; stat += t3; stat <<= 1; stat +=t4; GPJ2DAT = stat; } void beep_init(void) { GPD0CON &= 0xffff0000; GPD0CON |= 0X00001111; } void beep(u8_t stat) { GPD0DAT = stat; } void key1_init(void) { ; } int ky1_is_down(void) { return 0; } int c_entry(void) { led_init(); while(1){ led(LED_ON, LED_OFF, LED_OFF, LED_OFF); delay(100); led(LED_OFF, LED_ON, LED_OFF, LED_OFF); delay(100); led(LED_OFF, LED_OFF, LED_ON, LED_OFF); delay(100); led(LED_OFF, LED_OFF, LED_OFF, LED_ON); beep(BEEP_ON); delay(100) beep(BEEP_OFF); } return 0; }
; 汇编 a.s 调用 c.c
; ARM linker Equivalent Commandline 链接参数 -info totals -ro-base 0x21000000 -first a.o
area start,code,readonly code32 entry import c_entry aaaaa ldr r13,=0x38000000 b c_entry end