|
点击此处下载 ourdev_539977.rar(文件大小:17.27M) (原文件名:MVI_0790.rar)
(原文件名:atmega8_hid_usb.jpg)
(原文件名:IMG_0793.jpg)
=======================================FC.c=========================================
#include "FC.h"
#include <util/delay.h>
#include <avr/io.h>
inline U8 FC_Read(void)
{
U8 i,buf=0;
PORTD|=FC_LATCH;//latch=H;
_delay_us(1);
for(i=0;i<8;i++)
{
buf<<=1;
PORTD|=FC_CLOCK;//clock=H;
PORTD&=~FC_LATCH;//latch=L;
_delay_us(1);
if(PIND & FC_DATA)
{
buf++;
}
PORTD&=~FC_CLOCK;//clock=L;
_delay_us(1);
}
if(buf==0x7F)
PORTC |= (1<<4);
if(buf==0xBF)
PORTC&=~(1<<4);
return buf;
}
void FC_Init(void)
{
DDRD|=0x60;//PD6,PD5 in output
DDRD&=~FC_DATA; //This is FC of PORTs
DDRC|=(1<<4); //This is LED of PORTs
}
============================FC.h=================================================
#ifndef FC_H
#define FC_H
#ifndef U8
typedef unsigned char U8;
#endif
#ifndef U16
typedef unsigned int U16;
#endif
#ifndef U32
typedef unsigned long U32;
#endif
#define FC_CLOCK (1<<5)
#define FC_LATCH (1<<6)
#define FC_DATA (1<<7)
U8 FC_Read(void);
void FC_Init(void);
#endif
===========================END=================================================== |
阿莫论坛20周年了!感谢大家的支持与爱护!!
月入3000的是反美的。收入3万是亲美的。收入30万是移民美国的。收入300万是取得绿卡后回国,教唆那些3000来反美的!
|