首页|嵌入式系统|显示技术|模拟IC/电源|元件与制造|其他IC/制程|消费类电子|无线/通信|汽车电子|工业控制|医疗电子|测试测量
首页 > 分享下载 > 嵌入式系统 > HIDUSB手柄(玩游戏比键盘爽)

HIDUSB手柄(玩游戏比键盘爽)

资料介绍

HIDUSB手柄(玩游戏比键盘爽)

=======================================FC.c=========================================
#include"FC.h"

#includeutil/delay.h>
#includeavr/io.h>

inlineU8FC_Read(void)
{
U8i,buf=0;
PORTD|=FC_LATCH;//latch=H;
_delay_us(1);
for(i=0;i8;i++)
{
buf=1;
PORTD|=FC_CLOCK;//clock=H;
PORTD=~FC_LATCH;//latch=L;
_delay_us(1);
if(PINDFC_DATA)
{
buf++;
}

PORTD=~FC_CLOCK;//clock=L;
_delay_us(1);
}
if(buf==0x7F)
PORTC|=(14);
if(buf==0xBF)
PORTC=~(14);
returnbuf;
}

voidFC_Init(void)
{
DDRD|=0x60;//PD6,PD5inoutput
DDRD=~FC_DATA;//ThisisFCofPORTs

DDRC|=(14);//ThisisLEDofPORTs
}





============================FC.h=================================================
#ifndefFC_H
#defineFC_H

#ifndefU8
typedefunsignedcharU8;
#endif

#ifndefU16
typedefunsignedintU16;
#endif

#ifndefU32
typedefunsignedlongU32;
#endif

#defineFC_CLOCK(15)
#defineFC_LATCH(16)
#defineFC_DATA(17)

U8FC_Read(void);
voidFC_Init(void);

#endif


===========================END===================================================

标签:嵌入式单片机MCU
HIDUSB手柄(玩游戏比键盘爽)
本地下载

评论