三个LED引脚为GPF4/5/6,点电平亮,高电平灭;
led.c:
void delay(volatile int d)
{
while(d--);
}
int main()
{
unsigned int *pGPFCON = (unsigned int *)0x56000050;
unsigned int *pGPFDAT = (unsigned int *)0x56000054;
int val=7; /* val:0b000,0b111 */
/* 设置GPFCON让GPF4/5/6配置为输出引脚 */
*pGPFCON &= ~((3<<8)|(3<<10)|(3<<12)) ; //清零
*pGPFCON |= ((1<<8)|(1<<10)|(1<<12));
/*循环点亮*/
while(1)
{
switch(val)
{
case 7:
break;
case 6:
break;
case 5:
break;
case 3:
break;
default:
break;
}
*pGPFDAT &= ~(7<<4);
*pGPFDAT |= (val<<4);
delay(100000);
if(val == 5)
{
val = 3;
}
else if(val == 3)
{
val =7;
}
else
val--;
}
return 0;
}
start.S
.text
.global _start
_start:
/* 关闭看门狗 */
ldr r0, =0x53000000
ldr r1, =0
str r1, [r0]