<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > GPIO輸出---LED流水燈(EasyARM2131)

          GPIO輸出---LED流水燈(EasyARM2131)

          作者: 時(shí)間:2016-11-10 來(lái)源:網(wǎng)絡(luò) 收藏
          /****************************************Copyright (c)*******************

          **--------------File Info------------------------------------------------
          ** File name:main.c
          ** Last modified Date: 2011/04-09
          ** Last Version:1.0
          ** Descriptions:The main() function example template
          **
          **-----------------------------------------------------------------------
          ** Created by:lxliu
          ** Created date:2011-04-09
          ** Version:1.0
          ** Descriptions:The original version
          *************************************************************************/
          #include "config.h"

          本文引用地址:http://www.ex-cimer.com/article/201611/317406.htm

          /*LED8~LED1 這8個(gè)LED分別由P1.25~P1.18控制*/

          const uint32 LEDS8 = (0xFF<<18);

          /*************************************************************************
          ** 函數(shù)名稱:DelayNS()
          ** 函數(shù)功能:長(zhǎng)軟件延時(shí)
          ** 入口參數(shù):dly延時(shí)控制值,值越大,延時(shí)越長(zhǎng)
          ** 出口參數(shù):無(wú)
          *************************************************************************/

          void DelayNS(uint32 dly)
          {
          uint32 i;
          for(;dly>0;dly--)
          for(i=0;i<50000;i++);
          }

          /*************************************************************************
          ** 函數(shù)名稱:main()
          ** 函數(shù)功能:流水燈顯示程序
          ** 調(diào)試說(shuō)明:需將跳線JP12連接至LED8~LED1
          *************************************************************************/

          /*流水燈花樣,低電平點(diǎn)亮,調(diào)用時(shí)使用了取反操作*/
          const uint32 LED_TBL[] =
          {
          0x00,0xFF, //全部熄滅后再次點(diǎn)亮
          0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80, //依次逐個(gè)點(diǎn)亮
          0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF, //依次逐個(gè)疊加
          0xFF,0x7f,0x3F,0x1F,0x0F,0x07,0x03,0x01, //依次逐個(gè)遞減
          0x81,0x42,0x24,0x18,0x18,0x24,0x42,0x81, //兩個(gè)靠攏后分開(kāi)
          0x81,0xC3,0xE7,0xFF,0xFF,0xE7,0xC3,0x81 //從兩邊疊加后遞減
          };

          int main (void)
          {
          uint8 i;

          PINSEL2 = PINSEL2 & (~0x08); //P1[25:16]為GPIO功能,PINSEL2的第三位設(shè)置為0
          IO0DIR = LEDS8; //設(shè)置P1.25~P1.18為輸出
          while(1)
          {
          for (i=0;i<42;i++)
          {
          IO1SET = ~((LED_TBL[i])<<18);
          DelayNS(50);
          IO1CLR = ~((LED_TBL[i])<<18);
          DelayNS(50);
          }
          }
          return 0;
          }
          /*****************************************************************************
          ** End Of File
          *****************************************************************************/



          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();