This commit is contained in:
2025-07-07 10:41:49 +08:00
commit 1bae677e06
88 changed files with 36686 additions and 0 deletions
+188
View File
@@ -0,0 +1,188 @@
#ifndef _rf_send_C_
#define _rf_send_C_
/*********************************************************************************************************************/
#include "ca51f5_config.h"
#include "includes\ca51f5sfr.h"
#include "includes\ca51f5xsfr.h"
#include "includes\gpiodef_f5.h"
#include "Library\Includes\delay.h"
#include "rf_send.h"
sbit Pin_rf = P3^2;
unsigned char D0,D1;
unsigned int idata ID;
unsigned char RF_Time; //用于控制RF发送间隔时间
unsigned char Send433_Status = 0; //发送过程的状态
unsigned int Send433_Time = 0; //记录433发送数据的高低电平时间
unsigned char Yaokong_Data[3]={0};
unsigned char Send433_Byte_Cont=0;//记录发送一组433数据的字节数
unsigned char Send433_Bit_Cont = 0; //记录发送位
unsigned char Temp=0;
unsigned char Chose_Data_En=0;//使能选择一组433数据的第N个字节
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:
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;
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(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