V1.0
This commit is contained in:
@@ -28,161 +28,154 @@ unsigned char Chose_Data_En=0;//ʹ
|
||||
|
||||
void Send433_Byte(void) //100us执行一次
|
||||
{
|
||||
switch (Send433_Status)
|
||||
{
|
||||
case 0: //同步头高
|
||||
Pin_rf = 1;
|
||||
if (++Send433_Time >= 4)//高电平400us
|
||||
{
|
||||
Send433_Time = 0;
|
||||
Send433_Status = 1; //进入同步头低
|
||||
}
|
||||
break;
|
||||
case 1://同步头低电平
|
||||
Pin_rf = 0;
|
||||
if (++Send433_Time >= 120)//电平12300us
|
||||
{
|
||||
Send433_Time = 0;
|
||||
Send433_Status = 2; //进入发送24位
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// switch (Send433_Status)
|
||||
// {
|
||||
// case 0: //同步头高
|
||||
// Pin_rf = 1;
|
||||
// if (++Send433_Time >= 4)//高电平400us
|
||||
// {
|
||||
// Send433_Time = 0;
|
||||
// Send433_Status = 1; //进入同步头低
|
||||
// }
|
||||
// break;
|
||||
// case 1://同步头低电平
|
||||
// Pin_rf = 0;
|
||||
// if (++Send433_Time >= 120)//电平12300us
|
||||
// {
|
||||
// Send433_Time = 0;
|
||||
// Send433_Status = 2; //进入发送24位
|
||||
// }
|
||||
// break;
|
||||
// case 2:
|
||||
|
||||
if(!Chose_Data_En)//还没开始发送 或者上次已经发送完一个字节才使能选择
|
||||
{
|
||||
Chose_Data_En=1;
|
||||
Temp=Yaokong_Data[Send433_Byte_Cont];
|
||||
//Send433_Byte_Cont++;
|
||||
}
|
||||
// if(!Chose_Data_En)//还没开始发送 或者上次已经发送完一个字节才使能选择
|
||||
// {
|
||||
// Chose_Data_En=1;
|
||||
// Temp=Yaokong_Data[Send433_Byte_Cont];
|
||||
// //Send433_Byte_Cont++;
|
||||
// }
|
||||
|
||||
Send433_Time++;
|
||||
if (Temp & 0x80) //1
|
||||
{
|
||||
if (Send433_Time <= 12)
|
||||
{
|
||||
Pin_rf = 1;
|
||||
}
|
||||
else if (Send433_Time >= 13)
|
||||
{
|
||||
Pin_rf = 0;
|
||||
if (Send433_Time == 16)
|
||||
{
|
||||
Send433_Time = 0;
|
||||
Temp <<= 1;
|
||||
Send433_Bit_Cont++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else//0
|
||||
{
|
||||
if (Send433_Time <= 4)
|
||||
{
|
||||
Pin_rf = 1;
|
||||
}
|
||||
else if (Send433_Time >= 5)
|
||||
{
|
||||
Pin_rf = 0;
|
||||
if (Send433_Time == 16)
|
||||
{
|
||||
Send433_Time = 0;
|
||||
Temp <<= 1;
|
||||
Send433_Bit_Cont++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Send433_Bit_Cont == 8)//发送完一字节
|
||||
{
|
||||
Send433_Bit_Cont = 0;
|
||||
// Send433_Time++;
|
||||
// if (Temp & 0x80) //1
|
||||
// {
|
||||
// if (Send433_Time <= 12)
|
||||
// {
|
||||
// Pin_rf = 1;
|
||||
// }
|
||||
// else if (Send433_Time >= 13)
|
||||
// {
|
||||
// Pin_rf = 0;
|
||||
// if (Send433_Time == 16)
|
||||
// {
|
||||
// Send433_Time = 0;
|
||||
// Temp <<= 1;
|
||||
// Send433_Bit_Cont++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else//0
|
||||
// {
|
||||
// if (Send433_Time <= 4)
|
||||
// {
|
||||
// Pin_rf = 1;
|
||||
// }
|
||||
// else if (Send433_Time >= 5)
|
||||
// {
|
||||
// Pin_rf = 0;
|
||||
// if (Send433_Time == 16)
|
||||
// {
|
||||
// Send433_Time = 0;
|
||||
// Temp <<= 1;
|
||||
// Send433_Bit_Cont++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (Send433_Bit_Cont == 8)//发送完一字节
|
||||
// {
|
||||
// Send433_Bit_Cont = 0;
|
||||
|
||||
Chose_Data_En=0;//使能选择下一个字节
|
||||
if(++Send433_Byte_Cont==3)
|
||||
{
|
||||
Send433_Byte_Cont=0;
|
||||
|
||||
if(flagStart == 1)
|
||||
{
|
||||
Send433_Status = 3; //结束脉冲
|
||||
}
|
||||
else
|
||||
{
|
||||
Send433_Status = 0; //一帧数据发送完毕
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (++Send433_Time <= 4)
|
||||
{
|
||||
Pin_rf = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Pin_rf = 0;
|
||||
Send433_Time = 0;
|
||||
// flagStart = 0;
|
||||
Send433_Status = 0;
|
||||
TR0 = 0; //定时器0禁止
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// Chose_Data_En=0;//使能选择下一个字节
|
||||
// if(++Send433_Byte_Cont==3)
|
||||
// {
|
||||
// Send433_Byte_Cont=0;
|
||||
//
|
||||
// if(flagStart == 1)
|
||||
// {
|
||||
// Send433_Status = 3; //结束脉冲
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Send433_Status = 0; //一帧数据发送完毕
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
//
|
||||
// case 3:
|
||||
// if (++Send433_Time <= 4)
|
||||
// {
|
||||
// Pin_rf = 1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Pin_rf = 0;
|
||||
// Send433_Time = 0;
|
||||
// // flagStart = 0;
|
||||
// Send433_Status = 0;
|
||||
// TR0 = 0; //定时器0禁止
|
||||
//
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
|
||||
void RF_send(unsigned char cnt);
|
||||
void send_8bit(unsigned char n);
|
||||
|
||||
/*****************************************/
|
||||
|
||||
void RF_send(unsigned char cnt)
|
||||
{
|
||||
unsigned char i;
|
||||
|
||||
for(i=cnt;i>0;i--) //单个包发送次数
|
||||
{
|
||||
Pin_rf=1;
|
||||
Delay_50us(5); //同步码高电平
|
||||
Pin_rf=0;
|
||||
Delay_50us(185); //同步码低电平
|
||||
Pin_rf=1;
|
||||
|
||||
send_8bit(D0);
|
||||
send_8bit(D1);
|
||||
send_8bit(valueSend);
|
||||
}
|
||||
}
|
||||
|
||||
void send_8bit(unsigned char n)
|
||||
{
|
||||
unsigned char i;
|
||||
for(i=8;i>0;i--)
|
||||
{
|
||||
Pin_rf=1;
|
||||
if(n&0x80)
|
||||
{//发1码
|
||||
Delay_50us(18);
|
||||
Pin_rf=0;
|
||||
Delay_50us(4);
|
||||
}
|
||||
else
|
||||
{//发0码
|
||||
Delay_50us(5);
|
||||
Pin_rf=0;
|
||||
Delay_50us(17);
|
||||
}
|
||||
n<<=1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//void RF_send(unsigned char cnt);
|
||||
//void send_8bit(unsigned char n);
|
||||
|
||||
///*****************************************/
|
||||
|
||||
//void RF_send(unsigned char cnt)
|
||||
//{
|
||||
// unsigned char i;
|
||||
|
||||
// for(i=cnt;i>0;i--) //单个包发送次数
|
||||
// {
|
||||
// Pin_rf=1;
|
||||
// Delay_50us(8); //同步码高电平
|
||||
// Pin_rf=0;
|
||||
// Delay_ms(12); //同步码低电平
|
||||
// Pin_rf=1;
|
||||
|
||||
// send_8bit(D0);
|
||||
// send_8bit(D1);
|
||||
// send_8bit(valueSend);
|
||||
//
|
||||
//// if(WheelSliderPosition == -1&&KeysFlagSN == 0)
|
||||
//// {
|
||||
//// Pin_rf=1;
|
||||
//// Delay_50us(7);
|
||||
//// Pin_rf=0;
|
||||
//// }
|
||||
// }
|
||||
//}
|
||||
////---------------------------------------------
|
||||
//void send_8bit(unsigned char n)
|
||||
//{
|
||||
// unsigned char i;
|
||||
// for(i=8;i>0;i--)
|
||||
// {
|
||||
// Pin_rf=1;
|
||||
// if(n&0x80)
|
||||
// {
|
||||
// Delay_50us(24);
|
||||
// Pin_rf=0;
|
||||
// Delay_50us(7);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Delay_50us(7);
|
||||
// Pin_rf=0;
|
||||
// Delay_50us(24);
|
||||
// }
|
||||
// n<<=1;
|
||||
// }
|
||||
//}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user