📄 up_dw505key.c
字号:
#include <pic.h>
__CONFIG( WDTEN & XT );
#define portbit(adr, bit) ((unsigned)(&adr)*8+(bit))
//static unsigned char status @0x03;
//static unsigned char indf @0x00;
static bit c @(unsigned)&STATUS*8+0;
static bit z @(unsigned)&STATUS*8+2;
//static bit PD @(unsigned)&STATUS*8+3;
//static bit rp0 @(unsigned)&STATUS*8+5;
//static bit rp1 @(unsigned)&STATUS*8+6;
//static bit irp @(unsigned)&STATUS*8+7;
////////////////
static bit Ctvout @portbit(PORTB,0);
static bit outstart @portbit(PORTB,1);
static bit outmain @portbit(PORTB,2);
static bit tripup @portbit(PORTB,3);
static bit tripdw @portbit(PORTB,4);
static bit checkcu @portbit(PORTB,5);
////////////////
static bit outup @portbit(PORTC,0);
static bit outdw @portbit(PORTC,1);
static bit wireless @portbit(PORTC,2);
static bit keyup @portbit(PORTC,3);
static bit kpause @portbit(PORTC,4);
static bit keydw @portbit(PORTC,5);
static unsigned char flag @0x1f;
static bit keyfg @(unsigned)&flag*8+0;
static bit wlfg @(unsigned)&flag*8+1;
static bit wllast @(unsigned)&flag*8+2;
static bit wlnew @(unsigned)&flag*8+3;
static bit delayfg @(unsigned)&flag*8+4;
static bit pausefg @(unsigned)&flag*8+5;
static bit fullfg @(unsigned)&flag*8+6;
static bit syncfg @(unsigned)&flag*8+7;
static unsigned char wdata3 @0x1e;
static unsigned char wdata2 @0x1d;
static unsigned char wdata1 @0x1c;
static unsigned char pausec1 @0x1b;
static unsigned char pausec2 @0x1a;
static unsigned char pausec3 @0x19;
static unsigned char wltimer @0x18;
static unsigned char task @0x17;
static unsigned char allfun @0x16;
static bit keyupfg @(unsigned)&allfun*8+0;
static bit keydwfg @(unsigned)&allfun*8+1;
static bit wlupfg @(unsigned)&allfun*8+2;
static bit wldwfg @(unsigned)&allfun*8+3;
static bit moterbackfg @(unsigned)&allfun*8+4;
static bit backfg @(unsigned)&allfun*8+5;
static bit closefg @(unsigned)&allfun*8+6;
static unsigned char delayc1 @0x15;
static unsigned char delayc2 @0x14;
static unsigned char tripcount @0x13;
static unsigned char fullcount @0x12;
static unsigned char wlpart @0x11;
static unsigned char wlcount @0x10;
static unsigned char keycount @0x0f;
static unsigned char outcount @0x0e;
static unsigned char closecount @0x0d;
////////define const data
#define Tmr0init 0x2a
#define wlupdata 0xc0
#define wldwdtat 0x03
#define wladdl 0x53
#define wladdh 0x04 //55 54 57 51 50 53 5d 5c 5f
#define cufulldata 0xfa
#define trisbdata 0xf8
#define triscdata 0xfc //ec
#define syncdatal 0x1e //30
#define syncdatah 0x82 //130;
#define wl4a 0x05
void main(void)
{
OSCCAL=0;
CLRWDT();
TRISB=trisbdata;
TRISC=triscdata;
PORTB=trisbdata;
PORTC=triscdata;
TMR0=0;
allfun=0;
pausec1=0;
pausec2=0;
pausec3=0;
keycount=0;
tripcount=0;
outcount=0;
OPTION=0x00;
flag&=0x03;
// syncfg=1;
while(1){
while(TMR0<Tmr0init){
if(syncfg){//sync ok
if(wlfg){//ch last
if(wireless){
if(wllast){
wllast=0;
if((wltimer>35)&&(wltimer<110))wdata3=0;
wltimer=0;
if(wdata3>150)syncfg=0;
}}
else{
if(!wllast){
wllast=1;wltimer=0;}}}
else{//rec data
if(!wireless){
if(wllast){
wllast=0;
#asm
movlw wl4a
subwf _wltimer,f
rlf _wdata3,f
rlf _wdata2,f
rlf _wdata1,f
clrf _wltimer
#endasm
/*
wdata3<<=1;
if(wltimer>3)wdata3|=0x01;
wltimer=0;
wlcount++;.
if(wlcount==8){wdata2=wdata3;}
if(wlcount==16){wdata1=wdata3;}*/
if(--wlcount==0){
if(((wdata1==wladdl)&&(wdata2==wladdh))||((wdata1==0x55)&&(wdata2==0x55))){
wlpart=wdata3;wlnew=1;}
else {syncfg=0;wlfg=0;}
}}
}
else{
if(!wllast){
wllast=1;
wltimer=0;}}}}
else{//rec sync
if(wireless){
if(wllast){
wllast=0;
if((wltimer>35)&&(wltimer<110)){
syncfg=1;
wlfg=0;
wlcount=24;
wdata3=0;
wdata2=0;
wdata1=0;}
wltimer=0;}}
else{
if(!wllast){
wllast=1;
wltimer=0;}
}}}
TMR0=TMR0-Tmr0init;
if(++wltimer==0){
syncfg=0;
wlfg=0;}
task++;
if(wlnew){
wlnew=0;
wdata3=0;
if(!wlfg){
if(wlpart==0xc0){
wlfg=1;
keyfg=0;
pausefg=0;
allfun&=0xf4;
wlupfg=!wlupfg;
closefg=1;
closecount=0;
delayfg=0;
delayc2=0;
delayc1=0;
}
if(wlpart==0x03){
wlfg=1;
keyfg=0;
pausefg=0;
allfun&=0xf8;
wldwfg=!wldwfg;
closefg=1;
closecount=0;
delayfg=0;
delayc1=0;
delayc2=0;
}
wlpart=0;}
else wdata3++;}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -