📄 89lv51.lst
字号:
C51 COMPILER V7.06 89LV51 05/08/2007 23:29:40 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE 89LV51
OBJECT MODULE PLACED IN 89LV51.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE 89LV51.C BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include <reg51.h>
2 #include <intrins.h>
3 #include "api.h"
4 /***************************************************/
5 BYTE RFFlag,UartFlag;
6 /**************************************************/
7 BYTE bdata sta;
8 sbit RX_DR =sta^6;
9 sbit TX_DS =sta^5;
10 sbit MAX_RT =sta^4;
11 /**************************************************
12 Function: InitUart();
13
14 Description:
15 set uart working mode
16 /**************************************************/
17 void InitUart(void)
18 {
19 1 TMOD = 0x20; //timer1 working mode 2
20 1 TL1 = 0xfd; //f7=9600 for 16mhz Fosc,and ...
21 1 TH1 = 0xfd; //...fd=19200 for 11.0592mhz Fosc
22 1
23 1 //SCON = 0xd8; //uart mode 3,ren==1, 1101_1000,9位数据
24 1 SCON = 0x58; //uart mode 1,ren==1, 0101_1000,8位数据
25 1 PCON = 0x80; //smod=0
26 1 TR1 = 1; //start timer1
27 1 //
28 1 ET1 = 0;//禁止定时器1中断
29 1 ES = 1; //允许串行中断
30 1 }
31 /**************************************************/
32
33 /**************************************************
34 Function: init_int0();
35
36 Description:
37 enable int0 interrupt;
38 /**************************************************/
39 void Init_int0(void)
40 {
41 1 EA=1;
42 1 EX0=1; // Enable int0 interrupt.
43 1 }
44
45 /**************************************************/
46 void delay_ms(BYTE x)
47 {
48 1 BYTE i,j;
49 1 for(i=0;i<x;i++)
50 1 {
51 2 j=108;
52 2 while(j--);
53 2 }
54 1 }
55 /**************************************************/
C51 COMPILER V7.06 89LV51 05/08/2007 23:29:40 PAGE 2
56
57
58 /**************************************************
59 Function: RF_RX_Mode();
60
61 Description:
62 This function initializes one nRF24L01 device to
63 RX Mode, set RX address, writes RX payload width,
64 select RF channel, datarate & LNA HCURR.
65 After init, CE is toggled high, which means that
66 this device is now ready to receive a datapacket.
67 /**************************************************/
68 void RF_RX_Mode(void)
69 {
70 1 TRX_CE = TRX_Disable;
71 1
72 1 /*SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADR_WIDTH); // Use the same address on the RX de
-vice as the TX device
73 1
74 1 SPI_Write(WRITE_REG + EN_AA, 0x01); // Enable Auto.Ack:Pipe0
75 1 SPI_Write(WRITE_REG + EN_RXADDR, 0x01); // Enable Pipe0
76 1 SPI_Write(WRITE_REG + RF_CH, 40); // Select RF channel 40
77 1 SPI_Write(WRITE_REG + RX_PW_P0, TX_PLOAD_WIDTH); // Select same RX payload width as TX Payload width
78 1 SPI_Write(WRITE_REG + RF_SETUP, 0x07); // TX_PWR:0dBm, Datarate:2Mbps, LNA:HCURR*/
79 1
80 1 SPI_Write(WRITE_REG + CONFIG, 0x0f); // Set PWR_UP bit, enable CRC(2 bytes) & Prim:RX. RX_DR enable
-d..
81 1
82 1 TRX_CE = TRX_Enable; // Set CE pin high to enable RX device
83 1
84 1 // This device is now ready to receive one packet of 16 bytes payload from a TX device sending to addre
-ss
85 1 // '3443101001', with auto acknowledgment, retransmit count of 10, RF channel 40 and datarate = 2Mbps.
86 1
87 1 }
88 /**************************************************/
89
90 /**************************************************
91 Function: RF_TX_Mode();
92
93 Description:
94 This function initializes one nRF24L01 device to
95 TX mode, set TX address, set RX address for auto.ack,
96 fill TX payload, select RF channel, datarate & TX pwr.
97 PWR_UP is set, CRC(2 bytes) is enabled, & PRIM:TX.
98
99 ToDo: One high pulse(>10us) on CE will now send this
100 packet and expext an acknowledgment from the RX device.
101 /**************************************************/
102 void RF_TX_Mode(void)
103 {
104 1 TRX_CE = TRX_Disable;
105 1
106 1 SPI_Write_Buf(WR_TX_PLOAD, tx_buf, TX_PLOAD_WIDTH); // Writes data to TX payload
107 1 SPI_Write(WRITE_REG + SETUP_RETR, 0x1a); // 500us + 86us, 10 retrans...
108 1
109 1 /*SPI_Write_Buf(WRITE_REG + TX_ADDR, TX_ADDRESS, TX_ADR_WIDTH); // Writes TX_Address to nRF24L01
110 1 SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADR_WIDTH); // RX_Addr0 same as TX_Adr for Auto.Ac
-k
111 1 SPI_Write_Buf(WR_TX_PLOAD, tx_buf, TX_PLOAD_WIDTH); // Writes data to TX payload
112 1
113 1 SPI_Write(WRITE_REG + EN_AA, 0x01); // Enable Auto.Ack:Pipe0
C51 COMPILER V7.06 89LV51 05/08/2007 23:29:40 PAGE 3
114 1 SPI_Write(WRITE_REG + EN_RXADDR, 0x01); // Enable Pipe0
115 1 SPI_Write(WRITE_REG + SETUP_RETR, 0x1a); // 500us + 86us, 10 retrans...
116 1 SPI_Write(WRITE_REG + RF_CH, 40); // Select RF channel 40
117 1 SPI_Write(WRITE_REG + RF_SETUP, 0x07); // TX_PWR:0dBm, Datarate:2Mbps, LNA:HCURR*/
118 1
119 1 SPI_Write(WRITE_REG + CONFIG, 0x0e); // Set PWR_UP bit, enable CRC(2 bytes) & Prim:TX. MAX_RT & TX_
-DS enabled..
120 1 TRX_CE = TRX_Enable;
121 1 }
122 /**************************************************/
123
124 /**************************************************
125 Function: check_ACK();
126
127 Description:
128 check if have "Data sent TX FIFO interrupt",if TX_DS=1,
129 all led light and after delay 100ms all led close
130 /**************************************************
131 void check_ACK()
132 {
133 BYTE test;
134 test=SPI_Read(READ_REG+STATUS); // read register STATUS's
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -