发光二极管接口(左端)应为低电平
以LED1为例
LED1的接口为GPB5
void led_init(void)
{
//配置GPB5功能为输出
GPBCON &= ~(0x3 << 10);
GPBCON |= (0x1 << 10);
//使GPB5输出高电平(关灯)
GPBDAT |= (1 << 5);
}
void led_on(void)
{
GPBDAT &= ~(1 << 5);
}
void led_off(void)
{
GPBDAT |= (1 << 5);
}
int main(void)
{
// unsigned int * gpbcon = (unsigned int *)0x56000010;
led_init();
while(1)
{
led_on();
led_off();
}
}