查看: 2183|回复: 0

NuMaker-PFM-M453的ARM mbed OS 编程示例

[复制链接]
  • TA的每日心情
    开心
    2018-7-3 13:52
  • 签到天数: 2 天

    连续签到: 1 天

    [LV.1]初来乍到

    发表于 2018-6-13 08:45:56 | 显示全部楼层 |阅读模式
    分享到:
        NuMaker-PFM-M453的ARM mbed OS 编程示例

       下载固件更新完成就可以编写程序了。我们可以点击U盘里的MBED.html文件,也可以先去mbed网站上登录自己的mbed用户,进行项目开发。这里我们选用第一种方式,这样快一点,因为一般mbed用户可能会用不同的板子,和项目,会要求选择一下。

    下面来说明下操作过程。然后编写一个程序验证一下。

    1.当我们点击MBED.html文件,出现下图,这时我们点击complier按钮。

                  



    2.选择一个官方提供的程序工程,编辑一下,它编辑后会自动下载。

                     
                   





    3.下载过程.......

                         


    4.观察现象,符合程序的描述。

    5.源程序

    #include "mbed.h"



    #if defined(TARGET_NUMAKER_PFM_NUC472)

    DigitalOut  rgbled_B(LED_BLUE);  // low-active

    DigitalOut  rgbled_R(LED_RED);  // low-active

    DigitalOut  rgbled_G(LED_GREEN);  // low-active

    DigitalOut  greenled(PG_0);  // low-active

    DigitalOut  buzzer(PD_11);  // low-active

    DigitalIn  button_SW1(SW1);  // press button =0

    DigitalIn  button_SW2(SW2);  // press button =0

    #elif defined(TARGET_NUMAKER_PFM_M453)*/

    DigitalOut  rgbled_B(LED_BLUE);  // low-active

    DigitalOut  rgbled_R(LED_RED);  // low-active

    DigitalOut  rgbled_G(LED_GREEN);  // low-active

    DigitalOut  greenled(PB_12);  // low-active

    DigitalOut  buzzer(PE_2);  // low-active

    DigitalIn  button_SW1(SW2);  // press button =0

    DigitalIn  button_SW2(SW3);  // press button =0

    #elif defined(TARGET_NUMAKER_PFM_M487)

    DigitalOut  rgbled_B(LED_YELLOW);  // in M487, rgbled_B is yellow, not blue, low-active

    DigitalOut  rgbled_R(LED_RED);  // low-active

    DigitalOut  rgbled_G(LED_GREEN);  // low-active

    DigitalOut  greenled(D2);  // in M487, change the pin to match real hardware, low-active

    DigitalOut  buzzer(D3);  // in M487, change the pin to match real hardware, low-active

    DigitalIn  button_SW1(SW2);  // in M487, button_SW1 is SW2, press button =0

    DigitalIn  button_SW2(SW3);  // in M487, button_SW2 is SW3, press button =0

    #elif defined(TARGET_NUMAKER_PFM_NANO130)

    DigitalOut  rgbled_B(LED_YELLOW);  // in NANO130, rgbled_B is yellow, not blue, low-active

    DigitalOut  rgbled_R(LED_RED);  // low-active

    DigitalOut  rgbled_G(LED_GREEN);  // low-active

    DigitalOut  greenled(D2);  // in NANO130, change the pin to match real hardware, low-active

    DigitalOut  buzzer(D3);  // in NANO130, change the pin to match real hardware, low-active

    DigitalIn  button_SW1(SW1);  // press button =0

    DigitalIn  button_SW2(SW2);  // press button =0

    #endif



    // main() runs in its own thread in the OS

    // (note the calls to Thread::wait below for d elays)

    int main() {

      

      rgbled_B=1; rgbled_R=1; rgbled_G=1;

      greenled=1;

      buzzer=1;

      

      while (true) {

      // press SW1 will turn on greeled and RGBLED=blue

      if (button_SW1==0) {

      greenled=0;

      //rgbled_B=0;

      

      rgbled_G=0;

      //rgbled_R=0;

      

       }  

      else  {

      greenled=1;

      //rgbled_B=1;

      

      rgbled_G=1;

       //rgbled_R=1;

      }

      // press SW2 will turn on buzzer  

      if (button_SW2==0) buzzer=0;

      else  buzzer=1;

      }

    }

    回复

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /2 下一条

    手机版|小黑屋|与非网

    GMT+8, 2024-4-27 01:37 , Processed in 0.130510 second(s), 17 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.