📄 227pm_prx.lst
字号:
C51 COMPILER V6.12 227PM_PRX 02/27/2009 16:06:01 PAGE 1
C51 COMPILER V6.12, COMPILATION OF MODULE 227PM_PRX
OBJECT MODULE PLACED IN .\227pm_prx.OBJ
COMPILER INVOKED BY: C:\软件备份\学习工具软件\KeilC51v612\programm\C51\BIN\C51.EXE .\227pm_prx.c DEBUG OBJECTEXTEND
stmt level source
1 #include "API.h"
2 #include<reg52.h>
3
4 #define uchar unsigned char
5 //******************initializtion*******************//
6
7 //paramenters part******//
8
9 #define addr_wid 0x05//both,length of adress.
10 #define pld_wid 0x01//both,1~32,only ack canbe use 0 length
11 uchar ptx_addr[addr_wid]={0x7c,0x7c,0x7c,0x7c,0x7c};//PTX ,the free address ,the destination of the packet
12 uchar pipe0_addr[addr_wid]={0x7c,0x7c,0x7c,0x7c,0x7c};//PRX ,free address which pipe0 canbe allow.
13 uchar static_rcv_buf[5]=0;//PTX,data buf to be transmitted.
14 uchar new_data=0;
15 uchar led[16]={0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70,0x7f,0x7b,0x77,0x1f,0x0d,0x3d,0x4f,0x47};
16
17
18 sbit CE=P3^0;
19 sbit CSN= P1^4;
20 sbit SCK= P1^7;
21 sbit MOSI= P1^5;
22 sbit MISO= P1^6;
23 sbit IRQ = P3^2;
24 sbit send_over=P0^0;
25 sbit recieve_over=P0^1;
26 sbit begin_tran=P0^2;
27 sbit init_over=P0^3;
28 //functions part********//
29
30
31 //****************************************************//
32 //function name: delay_11us();
33 //parameter: dull.
34 //function: to delay 11us,for transmiting.
35
36 void delay_11us(void)
37 {uchar counter=0;
38 1 for(;counter<5;counter++);
39 1 }
40
41 //****************************************************//
42 //function name: delay_50us();
43 //parameter: dull.
44 //function: to delay 50us.
45
46 void delay_50us(void)
47 {
48 1 uchar counter=0;
49 1 for(;counter<15;counter++);
50 1 }
51
52 //****************************************************//
53 //function name: delay_200us();
54 //parameter: dull.
55 //function: to delay 50us.
C51 COMPILER V6.12 227PM_PRX 02/27/2009 16:06:01 PAGE 2
56
57 void delay_200us(void)
58 {
59 1 uchar counter=0;
60 1 for(;counter<60;counter++);
61 1 }
62
63 //****************************************************//
64 //function name: delay_1.5ms();
65 //parameter: dull.
66 //function: to delay 1.5ms.
67
68 void delay_1p5ms(void)
69 {
70 1 uchar counter;
71 1
72 1 for(counter=0;counter<0x2e;counter++)
73 1 delay_50us();
74 1
75 1 }
76
77 //****************************************************//
78 //function name: delay_0.5s();
79 //parameter: dull.
80 //function: to delay 1s.
81
82 void delay_0p5s(void)
83 {
84 1 uchar counter1;
85 1 uchar counter2;
86 1 for(counter1=0;counter1<0x20;counter1++)//80*250*50=1*10^6 us
87 1 {
88 2 for(counter2=0;counter2<0xfa;counter2++)
89 2 delay_50us();
90 2 }
91 1 }
92
93 //****************************************************//
94 //function name: delay_1s();
95 //parameter: dull.
96 //function: to delay 1s.
97
98 void delay_1s(void)
99 {
100 1 uchar counter1;
101 1 uchar counter2;
102 1 for(counter1=0;counter1<0x50;counter1++)//80*250*50=1*10^6 us
103 1 {
104 2 for(counter2=0;counter2<0xfa;counter2++)
105 2 delay_50us();
106 2 }
107 1 }
108
109 //****************************************************//
110 //function name: mcu_init().
111 //parameter: dull.
112 //function: to set initial condition of MCU.
113
114 void mcu_init(void) //IO,SPI_init,CE线电平0,各灯齐闪,设定SPI工作模式,CSN线电平,CLK频率
115 {
116 1 P0=0x0f; // led close
117 1 CE=0; // chip enable
C51 COMPILER V6.12 227PM_PRX 02/27/2009 16:06:01 PAGE 3
118 1 CSN=1; // Spi disable
119 1 SCK=0; // Spi clock line init high
120 1 MOSI=1;
121 1 MISO=1; //NUST TO WRITE 1,THEN YOU CAN USE IT AS INPUT PIN.
122 1 delay_0p5s();
123 1 P0=0x00; // led close
124 1
125 1 }
126
127 //****************************************************//
128 //function name: SPI_DEAL(data)
129 //parameter: data
130 //function: operation on SPI department.then return the walue in MISO reg.
131
132 uchar SPI_DEAL(uchar byte)
133 {
134 1 uchar bit_ctr;
135 1 for(bit_ctr=0;bit_ctr<8;bit_ctr++) // output 8-bit
136 1 {
137 2 MOSI = (byte & 0x80); // output 'byte', MSB to MOSI
138 2 byte = (byte << 1); // shift next bit into MSB..
139 2 SCK = 1; // Set SCK high..
140 2 byte |=MISO; // capture current MISO bit
141 2 SCK = 0; // ..then set SCK low again
142 2 }
143 1 return (byte);
144 1 }
145 //****************************************************//
146 //function name: TRAN_COMMOND(commond)
147 //parameter: commond,the SPI commonds such as,NOP,FLUSH_TX,FLUSH_RX,REUSE_TX_PL.
148 //function: to read status reg,as the last commonds,return the value in the status reg
149
150 uchar TRAN_COMMOND(uchar commond)
151 {
152 1 uchar temp=0;
153 1 CSN=0; //命令操作使能
154 1 temp=SPI_DEAL(commond);//发送操作命令,同时返回stature寄存器的值
155 1 CSN=1; //命令操作结束
156 1 return temp; //返回值
157 1 }
158
159 //****************************************************//
160 //function name: READ_REG(commond)
161 //parameter: reg,the register whoes value is to be read.
162 //function:read single byte value of reg
163
164 uchar READ_REG(uchar commond) //读寄存器的值
165 {
166 1 uchar temp=0;
167 1 CSN=0; //命令操作使能
168 1 SPI_DEAL(commond);//发送命令,同时返回stature寄存器的值
169 1 temp=SPI_DEAL(0);//读取相应寄存器的值
170 1 CSN=1; //命令操作结束
171 1 return temp;//返回值
172 1 }
173
174 //****************************************************//
175 //function name: READ_BUF(commond,buf,wid)
176 //parameter: commond,a special commond to read many bytes from a register.
177 // buf, where is the read out bytes to be storeged.
178 // wid,the length of bytes
179 //function: read multi values from a register.
C51 COMPILER V6.12 227PM_PRX 02/27/2009 16:06:01 PAGE 4
180
181 void READ_BUF(uchar commond,uchar *buf,uchar wid)//读rx_payload或者pipe里的地址,多字节,wid 可通过读相应寄
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -