Files
moyuhai f0bbac3bb3 V1.0
2026-06-11 17:26:06 +08:00

217 lines
7.6 KiB
Plaintext

C51 COMPILER V9.60.0.0 RF_SEND 05/05/2026 17:41:51 PAGE 1
C51 COMPILER V9.60.0.0, COMPILATION OF MODULE RF_SEND
OBJECT MODULE PLACED IN .\hex\rf_send.obj
COMPILER INVOKED BY: C:\keil5\C51\BIN\C51.EXE rf_send.c OMF2 OPTIMIZE(9,SIZE) BROWSE DEBUG PRINT(.\lst\rf_send.lst) TABS
-(2) OBJECT(.\hex\rf_send.obj)
line level source
1 #ifndef _rf_send_C_
2 #define _rf_send_C_
3 /*********************************************************************************************************
-************/
4 #include "ca51f5_config.h"
5 #include "includes\ca51f5sfr.h"
6 #include "includes\ca51f5xsfr.h"
7 #include "includes\gpiodef_f5.h"
8
9 #include "Library\Includes\delay.h"
10
11 #include "rf_send.h"
12
13 sbit Pin_rf = P3^2;
14 unsigned char D0,D1;
15 unsigned int idata ID;
16 unsigned char RF_Time; //用于控制RF发送间隔时间
17
18
19 unsigned char Send433_Status = 0; //发送过程的状态
20 unsigned int Send433_Time = 0; //记录433发送数据的高低电平时间
21
22 unsigned char Yaokong_Data[3]={0};
23
24 unsigned char Send433_Byte_Cont=0;//记录发送一组433数据的字节数
25 unsigned char Send433_Bit_Cont = 0; //记录发送位
26 unsigned char Temp=0;
27 unsigned char Chose_Data_En=0;//使能选择一组433数据的第N个字节
28
29 void Send433_Byte(void) //100us执行一次
30 {
31 1 // switch (Send433_Status)
32 1 // {
33 1 // case 0: //同步头高
34 1 // Pin_rf = 1;
35 1 // if (++Send433_Time >= 4)//高电平400us
36 1 // {
37 1 // Send433_Time = 0;
38 1 // Send433_Status = 1; //进入同步头低
39 1 // }
40 1 // break;
41 1 // case 1://同步头低电平
42 1 // Pin_rf = 0;
43 1 // if (++Send433_Time >= 120)//电平12300us
44 1 // {
45 1 // Send433_Time = 0;
46 1 // Send433_Status = 2; //进入发送24位
47 1 // }
48 1 // break;
49 1 // case 2:
50 1
51 1 // if(!Chose_Data_En)//还没开始发送 或者上次已经发送完一个字节才使能选择
52 1 // {
53 1 // Chose_Data_En=1;
C51 COMPILER V9.60.0.0 RF_SEND 05/05/2026 17:41:51 PAGE 2
54 1 // Temp=Yaokong_Data[Send433_Byte_Cont];
55 1 // //Send433_Byte_Cont++;
56 1 // }
57 1
58 1 // Send433_Time++;
59 1 // if (Temp & 0x80) //1
60 1 // {
61 1 // if (Send433_Time <= 12)
62 1 // {
63 1 // Pin_rf = 1;
64 1 // }
65 1 // else if (Send433_Time >= 13)
66 1 // {
67 1 // Pin_rf = 0;
68 1 // if (Send433_Time == 16)
69 1 // {
70 1 // Send433_Time = 0;
71 1 // Temp <<= 1;
72 1 // Send433_Bit_Cont++;
73 1 // }
74 1 // }
75 1 // }
76 1 // else//0
77 1 // {
78 1 // if (Send433_Time <= 4)
79 1 // {
80 1 // Pin_rf = 1;
81 1 // }
82 1 // else if (Send433_Time >= 5)
83 1 // {
84 1 // Pin_rf = 0;
85 1 // if (Send433_Time == 16)
86 1 // {
87 1 // Send433_Time = 0;
88 1 // Temp <<= 1;
89 1 // Send433_Bit_Cont++;
90 1 // }
91 1 // }
92 1 // }
93 1 // if (Send433_Bit_Cont == 8)//发送完一字节
94 1 // {
95 1 // Send433_Bit_Cont = 0;
96 1
97 1 // Chose_Data_En=0;//使能选择下一个字节
98 1 // if(++Send433_Byte_Cont==3)
99 1 // {
100 1 // Send433_Byte_Cont=0;
101 1 //
102 1 // if(flagStart == 1)
103 1 // {
104 1 // Send433_Status = 3; //结束脉冲
105 1 // }
106 1 // else
107 1 // {
108 1 // Send433_Status = 0; //一帧数据发送完毕
109 1 // }
110 1 //
111 1 // }
112 1 // }
113 1 // break;
114 1 //
115 1 // case 3:
C51 COMPILER V9.60.0.0 RF_SEND 05/05/2026 17:41:51 PAGE 3
116 1 // if (++Send433_Time <= 4)
117 1 // {
118 1 // Pin_rf = 1;
119 1 // }
120 1 // else
121 1 // {
122 1 // Pin_rf = 0;
123 1 // Send433_Time = 0;
124 1 // // flagStart = 0;
125 1 // Send433_Status = 0;
126 1 // TR0 = 0; //定时器0禁止
127 1 //
128 1 // }
129 1 // break;
130 1 // default:
131 1 // break;
132 1 // }
133 1 }
134
135 void RF_send(unsigned char cnt);
136 void send_8bit(unsigned char n);
137
138 /*****************************************/
139
140 void RF_send(unsigned char cnt)
141 {
142 1 unsigned char i;
143 1
144 1 for(i=cnt;i>0;i--) //单个包发送次数
145 1 {
146 2 Pin_rf=1;
147 2 Delay_50us(5); //同步码高电平
148 2 Pin_rf=0;
149 2 Delay_50us(185); //同步码低电平
150 2 Pin_rf=1;
151 2
152 2 send_8bit(D0);
153 2 send_8bit(D1);
154 2 send_8bit(valueSend);
155 2 }
156 1 }
157
158 void send_8bit(unsigned char n)
159 {
160 1 unsigned char i;
161 1 for(i=8;i>0;i--)
162 1 {
163 2 Pin_rf=1;
164 2 if(n&0x80)
165 2 {//发1码
166 3 Delay_50us(18);
167 3 Pin_rf=0;
168 3 Delay_50us(4);
169 3 }
170 2 else
171 2 {//发0码
172 3 Delay_50us(5);
173 3 Pin_rf=0;
174 3 Delay_50us(17);
175 3 }
176 2 n<<=1;
177 2 }
C51 COMPILER V9.60.0.0 RF_SEND 05/05/2026 17:41:51 PAGE 4
178 1 }
179
180
181 #endif
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 117 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 13 3
IDATA SIZE = 2 ----
BIT SIZE = ---- ----
EDATA SIZE = ---- ----
HDATA SIZE = ---- ----
XDATA CONST SIZE = ---- ----
FAR CONST SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)