#include <iom8v.h>#include <macros.h>/**//*-----------------** PC0 ------ DATA ** PC3 ------ CLOCK ** PD0~7 --- LED1~8 **-----------------*/#define PC0 0#define PC1 1#define PC2 2#define PC3 3#define PC4 4#define PC5 5#define PC6 6#define PC7 7#define CLOCK_HIGH (PORTC |= BIT(PC3)) //设置时钟为高电平#define CLOCK_LOW (PORTC &= ~BIT(PC3)) //设置时钟为低电平#define CUR_CLOCK (PINC & BIT(PC3) ? BIT(0) : 0x00) //获取当前时钟状态#define CUR_DATA (PINC & BIT(PC0) ? BIT(0) : 0x00) //获取当前数据状态#define LED_DATA PORTD //定义LED灯接口UINT8 Get_A_Bit() //获取当前键盘正在发送的一位...{ while(CUR_CLOCK == 0x00) //跳过低电平 ...{;} while(CUR_CLOCK != 0x00) //跳过高电平,等待下降沿 ...{;} return CUR_DATA; //返回当前数据值}void main()...{ UINT8 chData = 0; //存值 UINT8 chCount = 0; //循环控制 Device_Init(); CLOCK_LOW; //抑制键盘输出 while(1) ...{ CLOCK_HIGH; //开始允许键盘输出 Get_A_Bit(); //获取开始位 chData = 0x00; //初始化数据 for(chCount = 0; chCount < 8; chCount++) //连续获取八位数据并保存 ...{ chData |= Get_A_Bit() << chCount; //数据从低位开始传输 } LED_DATA = ~chData; //置反以便LED灯显示 for(chCount = 0; chCount < 2; chCount++) //丢弃最后两位 ...{ Get_A_Bit(); } CLOCK_LOW; //键盘停止输出 }}