⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 code_uint.c

📁 SDU的字库
💻 C
字号:
   

// 收码程序
// 若P1.3闪烁则说明程序工作正常
// 单026发码时,将楼层的低位码(code_data[4])显示在P2口上。

//  uchar floor_m;
//  uchar floor_l;
  static bit arrow_type;
sbit S_487_IN   = P3^2;
//sbit S_487_OUT  = P2^6;
sbit S_487_CTRL = P2^7;
//sbit flash_led  = P1^3;

uchar bdata data_487;
sbit data_487_bit_0 = data_487^0;

uchar code_data1[4];
#define code_ctrl1    code_data1[0]
#define code_message1 code_data1[1]
#define code_floor_h1 code_data1[2]
#define code_floor_l1 code_data1[3]
 
union
{
  uchar c_d[2];
  uint  u_d;
} t_data;


delay100us(uchar x)
{
  uchar i,j;
  //uchar y;
  for(i=0;i<x;i++)
  {
   for(j=0;j<46;j++)
   {
    _nop_();
   }
  }
}


bit watch_pre_code()
{
  delay100us(1);
  if(S_487_IN == 0)
  {
   delay100us(1);
   if(S_487_IN == 0)
   return(1);
   else return(0);
  }
  else return(0);
}

uchar read_bite_code()
{
   uchar i;
   uchar error_a = 0;
   uchar error_b = 0;
   for(i=0;i<8;i++)
   {
//----------------------------------------
    data_487 <<= 1;             
    TR1 = 0;                     
	TH1 = 0;
	TL1 = 0;
    t_data.u_d = 0;              
//----------------------------------------
    while(S_487_IN && error_a++ < 255);           
    TR1 = 1;                   
    while(~S_487_IN && error_b++ < 255);          
//----------------------------------------
    TR1 = 0;                   
    t_data.c_d[0] = TH1;
    t_data.c_d[1] = TL1;
    if(t_data.u_d < 150) data_487_bit_0 = 0; // data<70,判为零
    else data_487_bit_0 = 1;        
   }
    return( data_487 );
}


void read_code()
{
   uchar i;
   for(i=0;i<4;i++)
   code_data1[i] = read_bite_code();
}

 
void floor_dis_doing1()
{
   floor_m = code_floor_h1;
   floor_l = code_floor_l1;

   dis_floor();
}

void code_ctrl_doing1()
{ 
 if( (~code_data1[0] & 0x80) == 0x80 ) sbwhz_cn();//{ ztfw_cn();}
 else
 {
  switch( ~code_data1[0] & 0x07 )
  {
    case  0 :  {  stop(); } break;
	case  1 :  {  up_arrow_stop();   } break; //静态,写一次即可
 	case  2 :  {  down_arrow_stop(); } break;
	case  5 :  {  up_arrow_stop();  arrow_type = 0;} break; //arrow_type=0,it is up arrow                  //动态,需不停刷新故将其

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -