📄 程序.htm
字号:
<td width=180 style='width:135.0pt;padding:0cm 0cm 0cm 30.0pt;height:21.0pt'>
<p class=MsoNormal style='line-height:150%;word-break:break-all'><b><span
lang=EN-US style='font-size:9.0pt;line-height:150%'><a
href="http://www.elechome.com/Article/ShowElite.asp"><span lang=EN-US
style='color:white'><span lang=EN-US>最</span></span><span lang=EN-US
style='color:white'><span lang=EN-US> </span></span><span lang=EN-US
style='color:white'><span lang=EN-US>新</span></span><span lang=EN-US
style='color:white'><span lang=EN-US> </span></span><span lang=EN-US
style='color:white'><span lang=EN-US>推</span></span><span lang=EN-US
style='color:white'><span lang=EN-US> </span></span><span lang=EN-US
style='color:white'><span lang=EN-US>荐</span></span></a><o:p></o:p></span></b></p>
</td>
</tr>
<tr style='mso-yfti-irow:7'>
<td style='padding:0cm 6.0pt 0cm 3.75pt'>
<p class=MsoNormal style='line-height:150%;word-break:break-all'><span
lang=EN-US style='font-size:9.0pt;line-height:150%'><script language="JavaScript" src="/Article/JS/Article_Elite2.js">
</script><o:p> </o:p></span></p>
</td>
</tr>
<tr style='mso-yfti-irow:8;height:7.5pt'>
<td style='padding:0cm 0cm 0cm 0cm;height:7.5pt'>
<p class=MsoNormal style='line-height:150%;word-break:break-all'><span
lang=EN-US style='font-size:8.0pt;mso-bidi-font-size:9.0pt;line-height:
150%'><o:p> </o:p></span></p>
</td>
</tr>
<tr style='mso-yfti-irow:9;height:21.0pt'>
<td width=180 style='width:135.0pt;padding:0cm 0cm 0cm 30.0pt;height:21.0pt'>
<p class=MsoNormal style='line-height:150%;word-break:break-all'><b><span
style='font-size:9.0pt;line-height:150%'>相 关 文 章<span lang=EN-US><o:p></o:p></span></span></b></p>
</td>
</tr>
<tr style='mso-yfti-irow:10'>
<td style='padding:0cm 6.0pt 0cm 3.75pt'>
<p class=MsoNormal style='line-height:150%;word-break:break-all'><span
lang=EN-US style='font-size:9.0pt;line-height:150%'><a
href="http://www.elechome.com/Article/ShowArticle.asp?ArticleID=24"
target="_self"
title="文章标题:Keil C动态内存管理机制分析及改进 作 者:重庆电力高等专科学校 丁明亮 熊真春 更新时间:2007-04-26 17:14:04">Keil C<span
lang=EN-US><span lang=EN-US>动态内存管理机制</span></span></a><o:p></o:p></span></p>
</td>
</tr>
<tr style='mso-yfti-irow:11;mso-yfti-lastrow:yes;height:7.5pt'>
<td style='padding:0cm 0cm 0cm 0cm;height:7.5pt'>
<p class=MsoNormal style='line-height:150%;word-break:break-all'><span
lang=EN-US style='font-size:8.0pt;mso-bidi-font-size:9.0pt;line-height:
150%'><o:p> </o:p></span></p>
</td>
</tr>
</table>
<p class=MsoNormal style='line-height:150%;word-break:break-all'><span
lang=EN-US style='font-size:9.0pt;line-height:150%'><o:p></o:p></span></p>
</td>
<!--网页中部左栏代码结束-->
<td width=10 style='width:7.2pt;padding:0cm 0cm 0cm 0cm'>
<p class=MsoNormal style='line-height:150%;word-break:break-all'><span
lang=EN-US style='font-size:9.0pt;line-height:150%'><o:p> </o:p></span></p>
</td>
<td width=575 valign=top style='width:431.25pt;padding:0cm 0cm 0cm 0cm'><!--网页中部右栏文章内容代码开始-->
<div align=center>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width="100%"
style='width:100.0%;mso-cellspacing:0cm;mso-padding-alt:0cm 0cm 0cm 0cm;
width:fixed'>
<tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes'>
<td width="3%" style='width:3.0%;padding:0cm 0cm 0cm 0cm'>
<p class=MsoNormal style='line-height:150%;word-break:break-all'><span
lang=EN-US style='font-size:9.0pt;line-height:150%'><img border=0 width=11
height=14 id="_x0000_i1034" src="http://www.elechome.com/Images/arrow.gif"
align=absmiddle><o:p></o:p></span></p>
</td>
<td width="66%" style='width:66.0%;padding:0cm 0cm 0cm 0cm'>
<p class=MsoNormal style='line-height:150%;word-break:break-all'><strong><span
lang=EN-US style='font-size:9.0pt;line-height:150%;font-family:宋体;
mso-bidi-font-family:宋体'>nRF24E1</span></strong><strong><span
style='font-size:9.0pt;line-height:150%;font-family:宋体;mso-bidi-font-family:
宋体'>原版源程序</span></strong><span lang=EN-US style='font-size:9.0pt;
line-height:150%'><o:p></o:p></span></p>
</td>
<td style='padding:0cm 0cm 0cm 0cm'>
<p class=MsoNormal align=right style='text-align:right;line-height:150%;
word-break:break-all'><span lang=EN-US style='font-size:9.0pt;line-height:
150%'> </span><span style='font-size:9.0pt;line-height:
150%;color:red'>热</span><span lang=EN-US style='font-size:9.0pt;line-height:
150%'> <o:p></o:p></span></p>
</td>
</tr>
</table>
</div>
<p class=MsoNormal style='line-height:150%;word-break:break-all'><span
lang=EN-US style='font-size:9.0pt;line-height:150%;display:none;mso-hide:
all'><o:p> </o:p></span></p>
<div align=center>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width="100%"
style='width:100.0%;mso-cellspacing:0cm;mso-padding-alt:0cm 3.75pt 0cm 3.75pt;
width:fixed'>
<tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;height:22.5pt'>
<td colspan=2 style='padding:0cm 3.75pt 0cm 3.75pt;height:22.5pt;
width:fixed'>
<p class=MsoNormal align=center style='text-align:center;line-height:150%;
word-break:break-all'><span lang=EN-US style='font-size:9.0pt;line-height:
150%'>nRF24E1</span><span style='font-size:9.0pt;line-height:150%'>原版源程序<span
lang=EN-US><o:p></o:p></span></span></p>
</td>
</tr>
<tr style='mso-yfti-irow:1'>
<td colspan=2 style='padding:0cm 3.75pt 0cm 3.75pt;width:fixed'>
<p class=MsoNormal align=center style='text-align:center;line-height:150%;
word-break:break-all'><b><span lang=EN-US style='font-size:9.0pt;
line-height:150%'><o:p> </o:p></span></b></p>
</td>
</tr>
<tr style='mso-yfti-irow:2'>
<td colspan=2 style='background:whitesmoke;padding:0cm 3.75pt 0cm 3.75pt'>
<p class=MsoNormal align=center style='text-align:center;line-height:150%;
word-break:break-all'><span style='font-size:9.0pt;line-height:150%'>作者:黄盈鑫
文章来源:本站原创 点击数:<span lang=EN-US>979 </span>更新时间:<span lang=EN-US>2006-03-16
11:12:16 <a
href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(vivi=window.open('http://vivi.sina.com.cn/collect/icollect.php?pid=2008&title='+escape(d.title)+'&url='+escape(d.location.href)+'&desc='+escape(t),'vivi','scrollbars=no,width=480,height=480,left=75,top=20,status=no,resizable=yes'));vivi.focus();"
title="收藏的网页将被永久地保存到新浪ViVi收藏夹http://vivi.sina.com.cn"><img border=0
width=74 height=19 id="_x0000_i1035"
src="http://www.elechome.com/images/vivi_coop1.gif" align=absmiddle></a><o:p></o:p></span></span></p>
</td>
</tr>
<tr style='mso-yfti-irow:3;height:225.0pt'>
<td colspan=2 valign=top style='padding:0cm 3.75pt 0cm 3.75pt;height:225.0pt;
width:fixed' id=fontzoom><!--插入广告JS代码-->
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
align=left style='mso-cellspacing:0cm;mso-table-lspace:2.25pt;mso-table-rspace:
2.25pt;mso-table-anchor-vertical:paragraph;mso-table-anchor-horizontal:
column;mso-table-left:left;mso-padding-alt:7.5pt 7.5pt 7.5pt 7.5pt'>
<tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes'>
<td style='padding:7.5pt 7.5pt 7.5pt 7.5pt'>
<p class=MsoNormal style='line-height:150%'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'><o:p> </o:p></span></p>
</td>
</tr>
</table>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'>/*<o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span style='font-size:
9.0pt;line-height:150%'>如果需要详细设计资料请发邮件联系,<span lang=EN-US>senxin79@163.com<o:p></o:p></span></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'>*/<o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'>/* wireless.c
================================================================================================<br>
* <br>
* This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTYT; without even the<br>
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.<br>
*<br>
* Author(s): Ole Saether<br>
*<br>
* NOTES:<br>
*<br>
* A frame is the time between each transmission of a packet.<br>
* A frame is divided into NSLOTS time-slots. The duration of a
time-slot is 1/fs, where fs is the ADC<br>
* sampling frequency.<br>
*<br>
* The NOSYNC variable is used by the slave to keep track of how many
frames have gone since it received a<br>
* valid packet. It is incremented once each frame in the TIMER2 irq
handler and cleared each time a packet is<br>
* received. If the variable reaches the constant NSYNC (see below)
the slave enters continuous receive mode.<br>
*<br>
* The pin P0.2 is used to select slave (P0.2 = 1) or master (P0.2 =
0).<br>
*<br>
* $Date: 8.10.03 12:02 $<br>
* $Revision: 1 $<br>
*<br>
*=============================================================================================================<br>
*/<br>
#include <Nordic\reg24e1.h><o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'>#define ADDR_INDEX
8
// Index to address bytes in RFConfig.buf <br>
#define ADDR_COUNT
4
// Number of address bytes<o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'>#define
FSZ
32
// Buffer size<br>
#define FMASK FSZ-1<o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'>struct RFConfig<br>
{<br>
unsigned char n;<br>
unsigned char buf[15];<br>
};<o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'>typedef struct RFConfig RFConfig;<o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'>#define
NSLOTS
24
// Number of samples in one packet<br>
#define NSYNC
10
// #frames wo/packets before the slave enters receive mode<br>
#define RXSLOT
14
// Wait from slot 14 to..<br>
#define WTSLOT
21
// ..slot 21 for reception of a packet<br>
#define SYNCSLOT
20
// When the slave receives a valid packet set the slot counter to this
number<o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'><br>
volatile unsigned char idata RxBuf[FSZ];<br>
volatile unsigned char idata TxBuf[FSZ];<br>
volatile unsigned char TxWrp, TxRdp, TxNum;<br>
volatile unsigned char RxWrp, RxRdp, RxNum;<br>
volatile unsigned char rec, slotn, nosync, slave, prevsample;<o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'>const RFConfig RxTxConf =<br>
{<br>
15,<br>
0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,<br>
0xaa, 0xbb, 0x12, 0x34, 0x83, 0x6f, 0x04<br>
};<o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'>void InitBuffers(void)<br>
{<br>
RxWrp = RxRdp = RxRdp = RxNum = 0;<br>
TxWrp = TxRdp = TxRdp = TxNum = 0;<br>
}<o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'>void Delay100us(volatile unsigned
char n)<br>
{<br>
unsigned char i;<br>
while(n--)<br>
for(i=0;i<35;i++)<br>
;<br>
}<o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'>unsigned char
SpiReadWrite(unsigned char b)<br>
{<br>
EXIF &=
~0x20;
// Clear SPI interrupt<br>
SPI_DATA =
b;
// Move byte to send to SPI data register<br>
while((EXIF & 0x20) ==
0x00) //
Wait until SPI hs finished transmitting<br>
;<br>
return SPI_DATA;<br>
}<o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'>void Init(void)<br>
{<br>
unsigned char i;<o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'> P0_DIR =
0x04;
// P0.2 is input, the rest output<br>
P0 =
0x02;
// P0.1 = 1 for the master/slave selection<o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'> slotn = nosync
= 0;<br>
InitBuffers();<o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'> if ((P0 &
0x04) == 0x04)<br>
slave = 1;<br>
else<br>
slave = 0;<o:p></o:p></span></p>
<p style='line-height:150%;word-break:break-all'><span lang=EN-US
style='font-size:9.0pt;line-height:150%'> // TIMER2:<br>
TR2 =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -