OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 16809|回复: 23

nRF51822 AK II BLE 蓝牙4.0 开发板(实验1跑马灯)第一集

[复制链接]

75

主题

458

帖子

4

精华

金牌会员

Rank: 6Rank: 6

积分
1633
金钱
1633
注册时间
2012-8-28
在线时间
71 小时
发表于 2013-11-8 10:41:12 | 显示全部楼层 |阅读模式
<a href="http://item.taobao.com/item.htm?spm=a230r.1.14.15.A0efUu&amp;id=19066213304" target="_blank">http://item.taobao.com/item.htm?spm=a230r.1.14.15.A0efUu&amp;id=19066213304</a><br />
<br />
刚拿到开发板有2件事要做,了解下外围硬件结构和软件里需要的文件<br />
1 (usb-jtag有3个led灯共阳设计,低电平亮。p0.21red,p0.22green,p0.23blue)带jtag仿真器的那款<br />
&nbsp; &nbsp; AK板上【key0p0.16,key1p0.17(按下按钮低电平)】5个共阴led灯,高电平亮,led0p0.18,led1p0.19,led2p0.20,led3p0.21,led4p0.22<br />
&nbsp; &nbsp;<br />
<br />
2软件部分:这个51822和51单片机一样,需要启动文件,和声明寄存器地址名字的文件(寄存器对应的地址,就像0x80是P0口)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;arm_startup_nrf51.s(启动文件)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;nrf51.h(对应地址声明寄存器名字文件)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;有了这2个文件就可以建工程了。启动文件需要稍微修改下:<br />
103行; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IMPORT &nbsp;SystemInit
<div>
        104行 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IMPORT &nbsp;__main
</div>
<div>
        105; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LDR &nbsp; &nbsp; R0, =NRF_POWER_RAMON_ADDRESS
</div>
<div>
        106; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LDR &nbsp; &nbsp; R2, [R0]
</div>
<div>
        107; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MOVS &nbsp; &nbsp;R1, #NRF_POWER_RAMON_RAMxON_ONMODE_Msk
</div>
<div>
        108; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ORRS &nbsp; &nbsp;R2, R2, R1
</div>
<div>
        109; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;STR &nbsp; &nbsp; R2, [R0]
</div>
<div>
        110; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LDR &nbsp; &nbsp; R0, =SystemInit
</div>
<div>
        111; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BLX &nbsp; &nbsp; R0<br />
上面用 ; 注释掉了几行(原因是SystemInit是检查编译器32位情况还有bool。这里我们不需要这个,工程越简单越好。)<br />
<br />
该单片机跟stm32一样有2个晶振源(真奇怪我程序不启动晶振也照样用,难道真和51单片机一样,本实验只讲跑马灯)<br />
<br />
在io口控制的寄存器我们来看下,在nrf51.h文件中<br />
        <div style="margin:0px;padding:0px;color:#ff8000;font-family:Tahoma;font-size:14px;background-color:#232323;">
                /**
        </div>
        <div style="margin:0px;padding:0px;color:#ff8000;font-family:Tahoma;font-size:14px;background-color:#232323;">
                &nbsp; * @简短的通用输入和输出。 (GPIO)
        </div>
        <div style="margin:0px;padding:0px;color:#ff8000;font-family:Tahoma;font-size:14px;background-color:#232323;">
                &nbsp; */
        </div>
        <div style="margin:0px;padding:0px;color:#ff8000;font-family:Tahoma;font-size:14px;background-color:#232323;">
                <br />
        </div>
        <div style="margin:0px;padding:0px;color:#ff8000;font-family:Tahoma;font-size:14px;background-color:#232323;">
                typedef struct { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*!&lt; GPIO结构 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/
        </div>
        <div style="margin:0px;padding:0px;color:#ff8000;font-family:Tahoma;font-size:14px;background-color:#232323;">
                &nbsp; __I &nbsp;uint32_t &nbsp;RESERVED0[321]; &nbsp; &nbsp; //保留
        </div>
        <div style="margin:0px;padding:0px;color:#ff8000;font-family:Tahoma;font-size:14px;background-color:#232323;">
                &nbsp; __IO uint32_t &nbsp;OUT; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/*!&lt; 写GPIO端口。&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/
        </div>
        <div style="margin:0px;padding:0px;color:#ff8000;font-family:Tahoma;font-size:14px;background-color:#232323;">
                &nbsp; __IO uint32_t &nbsp;OUTSET; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/*!&lt; 设置中的单个位GPIO端口。 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */
        </div>
        <div style="margin:0px;padding:0px;color:#ff8000;font-family:Tahoma;font-size:14px;background-color:#232323;">
                &nbsp; __IO uint32_t &nbsp;OUTCLR; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*!&lt; 清除个别位GPIO端口。&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */
        </div>
        <div style="margin:0px;padding:0px;color:#ff8000;font-family:Tahoma;font-size:14px;background-color:#232323;">
                &nbsp; __I &nbsp;uint32_t &nbsp;IN; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/*!&lt; 阅读GPIO端口。 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */
        </div>
        <div style="margin:0px;padding:0px;color:#ff8000;font-family:Tahoma;font-size:14px;background-color:#232323;">
                &nbsp; __IO uint32_t &nbsp;DIR; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/*!&lt;GPIO引脚的方向。 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */
        </div>
        <div style="margin:0px;padding:0px;color:#ff8000;font-family:Tahoma;font-size:14px;background-color:#232323;">
                &nbsp; __IO uint32_t &nbsp;DIRSET; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/*!&lt;DIR组寄存器。&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */
        </div>
        <div style="margin:0px;padding:0px;color:#ff8000;font-family:Tahoma;font-size:14px;background-color:#232323;">
                &nbsp; __IO uint32_t &nbsp;DIRCLR; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/*!&lt; DIR明确寄存器。&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */
        </div>
        <div style="margin:0px;padding:0px;color:#ff8000;font-family:Tahoma;font-size:14px;background-color:#232323;">
                &nbsp; __I &nbsp;uint32_t &nbsp;RESERVED1[120];
        </div>
        <div style="margin:0px;padding:0px;color:#ff8000;font-family:Tahoma;font-size:14px;background-color:#232323;">
                &nbsp; __IO uint32_t &nbspIN_CNF[32]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/*!&lt; 配置GPIO引脚。 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */
        </div>
        <div style="margin:0px;padding:0px;color:#ff8000;font-family:Tahoma;font-size:14px;background-color:#232323;">
                } NRF_GPIO_Type; &nbsp; &nbsp; //起始地址0x50000000UL
        </div>
<br />
<span style="color:#ff8000;font-family:Tahoma;font-size:14px;line-height:22px;background-color:#232323;">#define NRF_GPIO_BASE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x50000000UL</span>&nbsp;<br />
<br class="Apple-interchange-newline" />
<span style="color:#ff8000;font-family:Tahoma;font-size:14px;line-height:22px;background-color:#232323;">#define NRF_GPIO &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;((NRF_GPIO_Type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *) NRF_GPIO_BASE)</span>&nbsp;<br />
以上翻译的nrf51.h在QQ750273008日志-&gt;蓝牙-&gt;<strong><span><span class="blog_tit_detail">nrf51822模块</span></span></strong>&nbsp;<br />
<br />
这里我们讲几点关键的:<br />
1第一次用引脚必须对该引脚配置比如p0.16这个按钮<br />
        <div>
                NRF_GPIO-&gtIN_CNF[16]=(0 &lt;&lt; 0)//key0
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 2)//1la
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (4 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt;16);
        </div>
<br />
可以看到bit0,bit1,bit(2,3),bit(8,9,10),bit(16,17)<br />
我来讲下
PIN_CNF[n]&nbsp;这个n代表硬件的引脚0~31用法NRF_GPIO-&gtIN_CNF[16]就是设置p0.16脚<br />
<br />
PIN_CNF&nbsp;是32位寄存器<span style="color:#000000;background-color:#e53333;">bit31~bit0</span>这里只用部分几个位(妈比的总算看到个用寄存器比较奢侈的单片机了)<br />
<br />
<span style="color:#ffe500;background-color:#000000;">bit0</span>&nbsp; &nbsp; &nbsp; 写0为输入,写1为输出(和DIR的寄存器关联也可以设置)<br />
<br />
<span style="color:#ffe500;background-color:#000000;">bit1</span><span style="color:#003399;">&nbsp; &nbsp; &nbsp; </span>设置PIN[]的INPUT缓冲(写1断开缓冲,写0连上)<br />
<br />
<span style="color:#ffe500;background-color:#000000;">bit(3,2)</span>&nbsp; &nbsp; 设置上下拉13k内置电阻,00无拉,01下拉电阻,10保留,11上拉电阻。<br />
<br />
<span style="color:#ffe500;background-color:#000000;">bit(10,9,8)</span>&nbsp; &nbsp;设置驱动强度000是最弱,我输出用011 &nbsp; 我输入用100<br />
<br />
<span style="color:#ffe500;background-color:#000000;">bit(17,16)</span>&nbsp; &nbsp; 这是中断用的触发沿(10是上升沿触发,11下降沿触发)<br />
<br />
<br />
这里就配置好了1个引脚了。32个脚全用要写个函数配置下这32个脚。<br />
<br />
<br />
2配置好了引脚就可以使用这个引脚了。<br />
NRF_GPIO-&gt;OUT=0x0000 0000; //如果这32个脚都配置输出,就代表p0.31到p0.0都是低电平<br />
NRF_GPIO-&gt;OUT=0x0000 000f; //表示p0.7到p0.0是高电平,其他都是低电平。<br />
<br />
<br />
NRF_GPIO-&gt;OUTSET=
0x0000 000f;&nbsp;//表示只把
p0.7到p0.0电平拉高,其他脚电平不变(写1有效,写0无效) &nbsp;
</div>
<div>
        NRF_GPIO-&gt;OUTCLR=&nbsp;0x0000 000f;&nbsp;//表示只把&nbsp;p0.7到p0.0电平拉低,其他脚电平不变&nbsp;(写1有效,写0无效) &nbsp;&nbsp;
</div>
<div>
        num=NRF_GPIO-&gt;IN;&nbsp;//表示读出32脚电平的值给变量num&nbsp;<br />
<br />
NRF_GPIO-&gt;DIR=0x0000 000f;&nbsp;//表示把&nbsp;p0.7到p0.0设置输出状态,其他脚设置为输入 &nbsp;
</div>
<div>
        <br />
NRF_GPIO-&gt;DIRSET=
0x0000 000f;&nbsp;//表示只把&nbsp;p0.7到p0.0设置输出状态,其他脚不变(写1有效,写0无效)&nbsp;&nbsp;<br />
NRF_GPIO-&gt;DIRCLR=&nbsp;0x0000 000f;&nbsp;//表示只把&nbsp;p0.7到p0.0设置输入状态,其他脚不变(写1有效,写0无效)&nbsp;<br />
<br />
<br />
<br />
以下是我写的例程<br />
<br />
<br />
        <div>
                <br />
        </div>
        <div>
                void ioinit()
        </div>
        <div>
                {int i;
        </div>
        <div>
                /* &nbsp;//usb-jtag
        </div>
        <div>
                <span class="Apple-tab-span"> </span>NRF_GPIO-&gtIN_CNF[21]=(1 &lt;&lt; 0)//usb-jtag-red
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (1 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 2)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt;16);
        </div>
        <div>
                <span class="Apple-tab-span"> </span>NRF_GPIO-&gtIN_CNF[22]=(1 &lt;&lt; 0)//usb-jtag-green
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (1 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 2)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt;16);
        </div>
        <div>
                <span class="Apple-tab-span"> </span>NRF_GPIO-&gtIN_CNF[23]=(1 &lt;&lt; 0)//usb-jtag-blue
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (1 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 2)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt;16);
        </div>
        <div>
                */
        </div>
        <div>
                <span class="Apple-tab-span"> </span> &nbsp;//boards-AK
        </div>
        <div>
                <span class="Apple-tab-span"> </span>i=NRF_GPIO-&gt;IN;//look
        </div>
        <div>
                <span class="Apple-tab-span"> </span>NRF_GPIO-&gtIN_CNF[16]=(0 &lt;&lt; 0)//key0
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 2)//1la
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (4 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt;16);
        </div>
        <div>
                <span class="Apple-tab-span"> </span>NRF_GPIO-&gtIN_CNF[17]=(0 &lt;&lt; 0)//key1
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 2)//1la
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (4 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt;16);
        </div>
        <div>
                <span class="Apple-tab-span"> </span>i=NRF_GPIO-&gt;IN;//look:0x00030000<span class="Apple-tab-span"> </span>&nbsp;
        </div>
        <div>
                &nbsp; NRF_GPIO-&gtIN_CNF[18]=(1 &lt;&lt; 0)//led0
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (1 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt; 2)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt;16);
        </div>
        <div>
                <span class="Apple-tab-span"> </span>i=NRF_GPIO-&gt;IN;//look<span class="Apple-tab-span"> </span>&nbsp;
        </div>
        <div>
                <span class="Apple-tab-span"> </span>NRF_GPIO-&gtIN_CNF[19]=(1 &lt;&lt; 0)//led1
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (1 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt; 2)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt;16);
        </div>
        <div>
                <span class="Apple-tab-span"> </span>i=NRF_GPIO-&gt;IN;//look<span class="Apple-tab-span"> </span>&nbsp;
        </div>
        <div>
                <span class="Apple-tab-span"> </span>NRF_GPIO-&gt;PIN_CNF[20]=(1 &lt;&lt; 0)//led2
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (1 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt; 2)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt;16);
        </div>
        <div>
                <span class="Apple-tab-span"> </span>i=NRF_GPIO-&gt;IN;//look<span class="Apple-tab-span"> </span>&nbsp;
        </div>
        <div>
                <span class="Apple-tab-span"> </span>NRF_GPIO-&gt;PIN_CNF[21]=(1 &lt;&lt; 0)//led3
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (1 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt; 2)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt;16);
        </div>
        <div>
                <span class="Apple-tab-span"> </span>i=NRF_GPIO-&gt;IN;//look<span class="Apple-tab-span"> </span>&nbsp;
        </div>
        <div>
                <span class="Apple-tab-span"> </span>NRF_GPIO-&gt;PIN_CNF[22]=(1 &lt;&lt; 0)//led4
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (1 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt; 2)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt;16);
        </div>
        <div>
                <span class="Apple-tab-span"> </span>i=NRF_GPIO-&gt;IN;//look<span class="Apple-tab-span"> </span>&nbsp;
        </div>
        <div>
                <span class="Apple-tab-span"> </span>NRF_GPIO-&gt;PIN_CNF[0]=(1 &lt;&lt; 0)//p0.00
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (1 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt; 2)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt;16);
        </div>
        <div>
                <span class="Apple-tab-span"> </span>i=NRF_GPIO-&gt;IN;//look<span class="Apple-tab-span"> </span>&nbsp;
        </div>
        <div>
                <span class="Apple-tab-span"> </span>NRF_GPIO-&gt;PIN_CNF[1]=(1 &lt;&lt; 0)//p0.01
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (1 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt; 2)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt;16);
        </div>
        <div>
                <span class="Apple-tab-span"> </span>i=NRF_GPIO-&gt;IN;//look<span class="Apple-tab-span"> </span>&nbsp;
        </div>
        <div>
                <span class="Apple-tab-span"> </span>NRF_GPIO-&gt;PIN_CNF[2]=(1 &lt;&lt; 0)//p0.02
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt; 2)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt;16);
        </div>
        <div>
                <span class="Apple-tab-span"> </span>i=NRF_GPIO-&gt;IN;//look<span class="Apple-tab-span"> </span>&nbsp;
        </div>
        <div>
                <span class="Apple-tab-span"> </span>NRF_GPIO-&gt;PIN_CNF[3]=(1 &lt;&lt; 0)//p0.03
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (1 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt; 2)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt;16);
        </div>
        <div>
                <span class="Apple-tab-span"> </span>i=NRF_GPIO-&gt;IN;//look<span class="Apple-tab-span"> </span>&nbsp;
        </div>
        <div>
                <span class="Apple-tab-span"> </span>NRF_GPIO-&gt;PIN_CNF[4]=(1 &lt;&lt; 0)//p0.04
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (1 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt; 2)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt;16);
        </div>
        <div>
                <span class="Apple-tab-span"> </span>i=NRF_GPIO-&gt;IN;//look<span class="Apple-tab-span"> </span>&nbsp;
        </div>
        <div>
                <span class="Apple-tab-span"> </span>NRF_GPIO-&gt;PIN_CNF[5]=(1 &lt;&lt; 0)//p0.05
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (1 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt; 2)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt;16);
        </div>
        <div>
                <span class="Apple-tab-span"> </span>i=NRF_GPIO-&gt;IN;//look<span class="Apple-tab-span"> </span>&nbsp;
        </div>
        <div>
                <span class="Apple-tab-span"> </span>NRF_GPIO-&gt;PIN_CNF[6]=(1 &lt;&lt; 0)//p0.06
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (1 &lt;&lt; 1)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt; 2)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (3 &lt;&lt; 8)
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| (0 &lt;&lt;16);
        </div>
        <div>
                <span class="Apple-tab-span"> </span>i=NRF_GPIO-&gt;IN;//look<span class="Apple-tab-span"> </span>&nbsp;
        </div>
        <div>
                NRF_GPIO-&gt;OUT=0;
        </div>
        <div>
                i=NRF_GPIO-&gt;IN;//look
        </div>
        <div>
                NRF_GPIO-&gt;OUT=0xffffffff;
        </div>
        <div>
                i=NRF_GPIO-&gt;IN;//look:0x007f007b(.. 0111 1111 .. 0111 1n11 )bit2???
        </div>
        <div>
                NRF_GPIO-&gt;OUT=0;
        </div>
        <div>
                NRF_GPIO-&gt;OUT=0xffffffff;//led01234
        </div>
        <div>
                NRF_GPIO-&gt;OUTSET=3&lt;&lt;16;//key0,key1
        </div>
        <div>
                i=NRF_GPIO-&gt;IN;//look
        </div>
        <div>
                }
        </div>
        <div>
                <br />
        </div>
        <div>
                //delay
        </div>
        <div>
                void nrf_delay_ms(uint32_t volatile number_of_ms)
        </div>
        <div>
                {
        </div>
        <div>
                &nbsp; &nbsp; int i;
        </div>
        <div>
                <span class="Apple-tab-span"> </span> &nbsp; while(number_of_ms != 0)
        </div>
        <div>
                &nbsp; &nbsp; {
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; number_of_ms--;
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; while(i&lt;1000)
        </div>
        <div>
                <span class="Apple-tab-span"> </span>{
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ++i;
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; }
        </div>
        <div>
                &nbsp; &nbsp; &nbsp; &nbsp; i=0;
        </div>
        <div>
                &nbsp; &nbsp; }
        </div>
        <div>
                }
        </div>
        <div>
                我硬件仿真了以下,结过和我想的差不多,除了P0.02这个脚,复位状态居然会拉低电平,和其他脚不一样,虽然也能当普通io脚用,我查了下这个脚可能复用了AD。<br />
51822有1个AD,可以在p0.6~p0.0这7个脚之间轮询取值。51822坑爹的资料,到现在也没翻译的参考手册。
        </div>
<br />
大家去看个文件nrf51_bitfields.h这个文件详细介绍了各个寄存器的设置值及偏移位。(哪个寄存器哪个bit位设置什么值,代表什么意思。)<br />
你可以把这些库文件加到你的工程里看看(虽然用只需要两个文件)。我觉得想真正了解设备工作状态流程的还是寄存器开发,用库开发你仿真时都跳到这文件,跳到那文件,跳的眼花。如果你英语好的话,可能你会习惯。我英语从小学就没及格过,一直用谷歌翻译,好累啊,希望后来学的朋友没我这么辛苦。51822用寄存器操作的我好像到现在还没看到这样的人。要是有就留个QQ哈。一起学习<br />
下面几集会陆续播出,我自学的慢,大家别见怪,我很懒的。。。。。
</div>

bleclass.rar

665.63 KB, 下载次数: 1689

QQ750273008有好的资料记得发给我哦。。。
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

75

主题

458

帖子

4

精华

金牌会员

Rank: 6Rank: 6

积分
1633
金钱
1633
注册时间
2012-8-28
在线时间
71 小时
 楼主| 发表于 2013-11-8 10:45:40 | 显示全部楼层
本帖最后由 750273008 于 2017-11-16 14:52 编辑

1.MDK5软件安装、软件破解                                                                                      //搭建平台
2.CPU型号(pack installer、help、welcome、www网址下载PDF文件)           //建立支持的cpu
3.project、New uVision Project、文件位置、程序名、保存、选择CPU型号   //开始准备编程
4.Manage Run、Cmsis:core(打钩)、Device:start up,rcc,gpio(打钩)                //提取操作的库函数
5.RESOLVE(按键)                                                                                                       //进行默认化
6.options for target、target:8Mhz,Use micro LIB                                            //平台环境设置
7.OUTPUT:输出文件位置,创建HEX文件                                                               //平台环境设置
8.C/C++定义(STM32F40XX,USE_STDPERIPH_DRIVER)、Debug            //平台环境设置     语法和仿真器设置
9.新建main.c文件保存,添加到Target里                                                                // 主程序文本建立
10. 在main.c文件中写:

#include "stm32f4xx_conf.h"

int main(void)
{

  GPIO_InitTypeDef  GPIO_InitStructure;
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_Init(GPIOD, &GPIO_InitStructure);

  while(1){
                GPIO_SetBits(GPIOD,GPIO_Pin_12|GPIO_Pin_13);
//                Delay(0x7FFFFF);
                GPIO_ResetBits(GPIOD,GPIO_Pin_12|GPIO_Pin_13);
//                Delay(0x7FFFFF);
       
        }
}



keil 5跟以前的版本使用上有些区别,大家参考下吧。
QQ750273008有好的资料记得发给我哦。。。
回复 支持 反对

使用道具 举报

0

主题

1

帖子

0

精华

新手入门

积分
21
金钱
21
注册时间
2013-11-8
在线时间
0 小时
发表于 2013-11-8 18:44:10 | 显示全部楼层
楼主你好,我也是今天才刚碰这块板子,专门来搞蓝牙4.0的,有空交流一下
回复 支持 反对

使用道具 举报

1

主题

12

帖子

0

精华

新手上路

积分
36
金钱
36
注册时间
2013-10-28
在线时间
0 小时
发表于 2013-11-8 20:28:24 | 显示全部楼层
顶起!
<br>有问题多交流。
回复 支持 反对

使用道具 举报

558

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
164897
金钱
164897
注册时间
2010-12-1
在线时间
2100 小时
发表于 2013-11-8 23:06:16 | 显示全部楼层
cool。
回复 支持 反对

使用道具 举报

0

主题

9

帖子

0

精华

新手上路

积分
31
金钱
31
注册时间
2013-4-19
在线时间
0 小时
发表于 2013-11-9 21:51:03 | 显示全部楼层
板子不错啊,哈哈
回复 支持 反对

使用道具 举报

1

主题

12

帖子

0

精华

新手上路

积分
36
金钱
36
注册时间
2013-10-28
在线时间
0 小时
发表于 2013-11-26 18:15:09 | 显示全部楼层
建立工程那个帖子在哪啊?
回复 支持 反对

使用道具 举报

20

主题

64

帖子

0

精华

初级会员

Rank: 2

积分
175
金钱
175
注册时间
2012-10-23
在线时间
9 小时
发表于 2014-7-29 23:00:19 | 显示全部楼层
楼主好,我写的按键怎么没反应,能不能帮忙看下,主要程序如下:<br />
<div   style="background-color:#E8E8E8;">
[mw_shl_code=c,true]#define        KEY                16

void KEY_Init(void)
{
        NRF_GPIO-&gt;DIR &amp;= ~(1 &lt;&lt; KEY);                //Direction of GPIO pins:0-&gt;input;1-&gt;output
        NRF_GPIO-&gtIN_CNF[KEY] = (0 &lt;&lt; 0) | (0 &lt;&lt; 1) | (3 &lt;&lt; 2) | (7 &lt;&lt; 8) | (3 &lt;&lt; 16);
}

int main(void)
{
        KEY_Init();
        LED_Init();
        while (1)
        {
                if (NRF_GPIO-&gt;IN &amp; (~(1 &lt;&lt; KEY)))
                {
                        NRF_GPIO-&gt;OUT = 0xffffffff;
                }
                else
                {
                        NRF_GPIO-&gt;OUT = 0x00000000;
                }
        }
}
[/mw_shl_code]
</div>
<br />
回复 支持 反对

使用道具 举报

20

主题

64

帖子

0

精华

初级会员

Rank: 2

积分
175
金钱
175
注册时间
2012-10-23
在线时间
9 小时
发表于 2014-7-29 23:05:01 | 显示全部楼层
<img src="/static/image/smiley/kindeditor/26.gif" border="0" alt="" />&nbsp; 我好像2b了,已经搞定,判断换成这样就可以了,不糗。<br />
<div   style="background-color:#E8E8E8;">
[mw_shl_code=c,true]if ((NRF_GPIO-&gt;IN &amp; (1 &lt;&lt; KEY)) == (1 &lt;&lt; KEY))[/mw_shl_code]
</div>
<br />
回复 支持 反对

使用道具 举报

0

主题

14

帖子

0

精华

初级会员

Rank: 2

积分
106
金钱
106
注册时间
2014-1-14
在线时间
20 小时
发表于 2014-9-3 17:10:17 | 显示全部楼层
谢谢原子,很好的学习参考,能多写几个模块就好了,关键是BLE部分
回复 支持 反对

使用道具 举报

0

主题

1

帖子

0

精华

新手入门

积分
21
金钱
21
注册时间
2014-12-9
在线时间
0 小时
发表于 2014-12-9 10:58:36 | 显示全部楼层
大赞!00000000000
回复 支持 反对

使用道具 举报

2

主题

10

帖子

0

精华

新手上路

积分
48
金钱
48
注册时间
2014-8-11
在线时间
3 小时
发表于 2014-12-9 23:14:31 | 显示全部楼层
回复【2楼】750273008:
<br>---------------------------------
<br>请问楼主,我是飞思卡尔智能车赛参赛者,今年电磁组要用到无线通信实现两部车的信息通信,就传输速度、传输距离和可靠性24L01和蓝牙哪个更好,或者楼主能否推荐一款无线模块?
回复 支持 反对

使用道具 举报

4

主题

25

帖子

0

精华

初级会员

Rank: 2

积分
61
金钱
61
注册时间
2015-1-19
在线时间
0 小时
发表于 2015-5-29 22:36:34 | 显示全部楼层
蓝牙有办法加密吗?小白来问。。
回复 支持 反对

使用道具 举报

14

主题

490

帖子

1

精华

金牌会员

Rank: 6Rank: 6

积分
1229
金钱
1229
注册时间
2012-8-4
在线时间
248 小时
发表于 2015-5-30 00:00:07 | 显示全部楼层
回复【13楼】cxran2wms:
<br>---------------------------------
<br>蓝牙通信&nbsp;&nbsp;本来就加密的&nbsp;&nbsp;你还要加密一次吗?
nrf51822蓝牙4.0手环开发板: 淘宝小店
回复 支持 反对

使用道具 举报

4

主题

25

帖子

0

精华

初级会员

Rank: 2

积分
61
金钱
61
注册时间
2015-1-19
在线时间
0 小时
发表于 2015-6-1 15:57:36 | 显示全部楼层
回复【14楼】muniao:
<br>---------------------------------
<br>嗯。我想不让别人看到我的数据。可以吗?
回复 支持 反对

使用道具 举报

0

主题

25

帖子

0

精华

初级会员

Rank: 2

积分
50
金钱
50
注册时间
2015-6-25
在线时间
0 小时
发表于 2015-6-25 17:17:57 | 显示全部楼层
代理NORDIC蓝牙4.0芯片NRF51822
<br>联系人:刘工
<br>QQ:1330504646
<br>手机:13714153746
<br>NRF51822是一款为超低功耗无线应用(ULP&nbsp;wirelesss&nbsp;applications)打造的多协议单芯片解决方案。
<br>它整合了Nordic一流的无线传送器,同时支持Bluetooth(R)&nbsp;low&nbsp;energy&nbsp;和专用的2.4GHz协议栈。
<br>基本情况是:
<br>2.4GHZ多协议无线射频
<br>32位ARM&nbsp;Cortex&nbsp;M0&nbsp;处理器
<br>128位AES硬件加密处理器
<br>256kB&nbsp;flash&nbsp;/&nbsp;16kB&nbsp;RAM
<br>可编程外设接口PPI
<br>全功能数字接口:&nbsp;SPI&nbsp;/&nbsp;I2C&nbsp;/&nbsp;UART
<br>10位ADC
<br>可编程的输出功率:&nbsp;+4dBm&nbsp;to&nbsp;-20dBm
<br>应用开发和协议堆栈完全独立
<br>与NRF24L系列完全兼容
<br>与NRF51xxx系列管脚兼容
<br>全局独立电源管理
<br>工作电压范围(1.8&nbsp;V&nbsp;~&nbsp;3.6&nbsp;V)
回复 支持 反对

使用道具 举报

3

主题

130

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
373
金钱
373
注册时间
2015-3-7
在线时间
43 小时
发表于 2016-3-8 15:33:13 | 显示全部楼层
LZ我想问下,NRF51822的8种驱动模式怎么理解?
为人莫作千年计,三十河东四十西,莫欺少年穷。
回复 支持 反对

使用道具 举报

0

主题

1

帖子

0

精华

新手入门

积分
10
金钱
10
注册时间
2016-5-23
在线时间
1 小时
发表于 2016-5-23 22:01:43 | 显示全部楼层
请问这款芯片的IO能够在不改变配置的情况下既能输出又能输入吗?
回复 支持 反对

使用道具 举报

5

主题

23

帖子

0

精华

初级会员

Rank: 2

积分
101
金钱
101
注册时间
2016-5-16
在线时间
13 小时
发表于 2017-11-14 12:17:02 | 显示全部楼层
NRF_GPIO->IN_CNF[16]=(0 << 0)//key0
                                   | (0 << 1)
                                   | (3 << 2)//1la
                                   | (4 << 8)
                                   | (3 <<16);

请问以上语句是什么意思?
回复 支持 反对

使用道具 举报

5

主题

23

帖子

0

精华

初级会员

Rank: 2

积分
101
金钱
101
注册时间
2016-5-16
在线时间
13 小时
发表于 2017-11-14 14:54:20 | 显示全部楼层
哦!明白了。
原来是PIN_CNF[16]寄存器各位的值。为什么不能直接写在这样:
  PIN_CNF[16]=0X0003040C;
回复 支持 反对

使用道具 举报

75

主题

458

帖子

4

精华

金牌会员

Rank: 6Rank: 6

积分
1633
金钱
1633
注册时间
2012-8-28
在线时间
71 小时
 楼主| 发表于 2017-11-16 13:32:31 | 显示全部楼层
xiachime 发表于 2017-11-14 14:54
哦!明白了。
原来是PIN_CNF[16]寄存器各位的值。为什么不能直接写在这样:
  PIN_CNF[16]=0X0003040C;

移位你们都看的吃力,直接赋值岂不是更看不懂。
QQ750273008有好的资料记得发给我哦。。。
回复 支持 反对

使用道具 举报

75

主题

458

帖子

4

精华

金牌会员

Rank: 6Rank: 6

积分
1633
金钱
1633
注册时间
2012-8-28
在线时间
71 小时
 楼主| 发表于 2017-11-16 13:36:33 | 显示全部楼层
本帖最后由 750273008 于 2017-11-16 15:06 编辑
xiachime 发表于 2017-11-14 12:17
NRF_GPIO->IN_CNF[16]=(0

/**
  * @简述通用的输入和输出。 (GPIO)
  */


typedef struct {                                         /*!< GPIO结构                                                  */
  __I  uint32_t  RESERVED0[321];     //保留位
  __IO uint32_t  OUT;                                /*!< 引脚输出值。                                            */
  __IO uint32_t  OUTSET;                          /*!< 置位某个引脚。                                         */
  __IO uint32_t  OUTCLR;                         /*!< 复位某个引脚。                                         */
  __I  uint32_t  IN;                                    /*!< 获取GPIO引脚点平。                                  */
  __IO uint32_t  DIR;                                /*!<GPIO引脚的方向。       写1为输出 0为输入  */
  __IO uint32_t  DIRSET;                          /*!<DIR方向置位存器。        置1为输出              */
  __IO uint32_t  DIRCLR;                          /*!<DIR方向复位寄存器。    置1为输入              */
  __I  uint32_t  RESERVED1[120];
  __IO uint32_t  PIN_CNF[32];                  /*!< 配置GPIO引脚。                                           */
} NRF_GPIO_Type;     //起始地址0x50000000UL

#define NRF_GPIO_BASE                   0x50000000UL    //基地址

#define NRF_GPIO                        ((NRF_GPIO_Type  *) NRF_GPIO_BASE)//开辟空间
//在0x50000000UL 的地址上建立 NRF_GPIO_Type的结构体  定义为  NRF_GPIO
以上翻译的nrf51.h在QQ750273008日志->蓝牙->nrf51822模块

这里我们讲几点关键的:
1第一次用引脚必须对该引脚配置 :比如p0.16这个按钮
NRF_GPIO->PIN_CNF[16]=    (0 << 0)             //引脚方向 0为输入, 1为输出
                                   | (0 << 1)  //写1断开缓冲,写0连上
                                   | (3 << 2)  //13k内置电阻,00无拉,01下拉电阻,10保留,11上拉电阻。
                                   | (4 << 8)  //设置驱动强度000是最弱,我输出用011   我输入用100
                                   | (3 <<16); //10是上升沿触发,11下降沿触发

QQ750273008有好的资料记得发给我哦。。。
回复 支持 反对

使用道具 举报

5

主题

23

帖子

0

精华

初级会员

Rank: 2

积分
101
金钱
101
注册时间
2016-5-16
在线时间
13 小时
发表于 2017-11-17 09:25:58 | 显示全部楼层
谢谢!
回复 支持 反对

使用道具 举报

75

主题

458

帖子

4

精华

金牌会员

Rank: 6Rank: 6

积分
1633
金钱
1633
注册时间
2012-8-28
在线时间
71 小时
 楼主| 发表于 2018-2-7 09:19:14 | 显示全部楼层
2配置好了引脚就可以使用这个引脚了。
NRF_GPIO->OUT=0x0000 0000; //如果这32个脚都配置输出,就代表p0.31到p0.0都是低电平
NRF_GPIO->OUT=0x0000 00FF; //表示p0.7到p0.0是高电平,其他都是低电平。


NRF_GPIO->OUTSET= 0x0000 00FF; //表示只把 p0.7到p0.0电平拉高,其他脚电平不变(写1有效,写0无效)  
NRF_GPIO->OUTCLR= 0x0000 00FF; //表示只把 p0.7到p0.0电平拉低,其他脚电平不变 (写1有效,写0无效)   
num=NRF_GPIO->IN; //表示读出32脚电平的值给变量num

NRF_GPIO->DIR=0x0000 00FF; //表示把 p0.7到p0.0设置输出状态,其他脚设置为输入  

NRF_GPIO->DIRSET= 0x0000 00FF; //表示只把 p0.7到p0.0设置输出状态,其他脚不变(写1有效,写0无效)  
NRF_GPIO->DIRCLR= 0x0000 00FF; //表示只把 p0.7到p0.0设置输入状态,其他脚不变(写1有效,写0无效)
QQ750273008有好的资料记得发给我哦。。。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2024-6-10 16:17

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表