51_LanQiaoBei/题目/真题/14 第十四届省赛_左岚/第十四届省赛/driver/Led.c

19 lines
370 B
C
Raw Permalink Normal View History

2025-04-13 01:02:19 +08:00
#include "Led.h"
void Led_Disp(unsigned char addr, bit enable)
{
static unsigned char temp = 0x00;
static unsigned char temp_old = 0xff;
if (enable)
temp |= 0x01 << addr;
else
temp &= ~(0x01 << addr);
if (temp != temp_old)
{
P0 = ~temp;
P2 = P2 & 0x1f | 0x80;
P2 &= 0x1f;
temp_old = temp;
}
}