Modify the file main.cpp for M487

Files at this revision

API Documentation at this revision

Comitter:
shliu1
Date:
Fri Sep 29 05:42:52 2017 +0000
Commit message:
main.cpp adds the setting of TARGET_NUMAKER_PFM_M487 for M487

Changed in this revision

.gitignore Show annotated file Show diff for this revision Revisions of this file
README.md Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r fc7f6fbecb11 .gitignore
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Fri Sep 29 05:42:52 2017 +0000
@@ -0,0 +1,4 @@
+.build
+.mbed
+projectfiles
+*.py*
diff -r 000000000000 -r fc7f6fbecb11 README.md
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Fri Sep 29 05:42:52 2017 +0000
@@ -0,0 +1,16 @@
+# Getting started with LED and buzzer on mbed OS
+
+
+### Import NuMaker-mbed-GPIO-button-buzzer-rgbled from on-line IDE
+1. Please choose Nuvoton NuMaker-PFM-XXX as your target platform.
+2. Please press the left-up icon "New", then choose "NuMaker GPIO button with LED and buzzer" from the template list.
+3. Your NuMaker-mbed-GPIO-button-buzzer-rgbled program is existed.
+
+#### Now compile
+Please press compile icon.
+
+#### Burn Code & Execute
+1. Connect the board NuMaker-PFM-XXX with your PC by USB cable, then there will be one "mbed" disk.
+2. Copy the built binary file into "mbed" disk on you PC.
+3. Press device's reset button to execute, press the SW1 button to turn on blue LED and green LED, 
+   press the SW2 button to turn on buzzer. 
diff -r 000000000000 -r fc7f6fbecb11 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Sep 29 05:42:52 2017 +0000
@@ -0,0 +1,52 @@
+// For NuMaker-PFM-NUC472 GPIO pins connected to rgbled, green led, buzzer
+#include "mbed.h"
+#if defined(TARGET_NUMAKER_PFM_NUC472)
+DigitalOut    rgbled_B(PD_8); // low-active
+DigitalOut    rgbled_R(PD_9); // low-active
+DigitalOut    rgbled_G(PA_4); // low-active
+DigitalOut    greenled(PG_0); // low-active
+DigitalOut    buzzer(PD_11);  // low-active
+DigitalIn     button_SW1(PC_12); // press button =0
+DigitalIn     button_SW2(PC_13); // press button =0
+#elif defined(TARGET_NUMAKER_PFM_M453)
+DigitalOut    rgbled_B(PD_7); // low-active
+DigitalOut    rgbled_R(PD_2); // low-active
+DigitalOut    rgbled_G(PD_3); // low-active
+DigitalOut    greenled(PB_12); // low-active
+DigitalOut    buzzer(PE_2);  // low-active
+DigitalIn     button_SW1(PA_15); // press button =0
+DigitalIn     button_SW2(PA_14); // press button =0
+#elif defined(TARGET_NUMAKER_PFM_M487)
+DigitalOut    rgbled_B(PH_1); // in M487 rgbled_B is yellow, not blue. low-active
+DigitalOut    rgbled_R(PH_0); // low-active
+DigitalOut    rgbled_G(PH_2); // low-active
+DigitalOut    greenled(PH_2); // in M487 use the pin to connect the led, low-active
+DigitalOut    buzzer(PF_11);  // in M487 use the pin to connect the buzzer, low-active
+DigitalIn     button_SW1(PC_10); // in M487 button_SW1 is SW2, press button =0
+DigitalIn     button_SW2(PC_9); // in M487 button_SW2 is SW3, 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;
+                           }                             
+        else               {
+                             greenled=1;
+                             rgbled_B=1;
+                           }
+        // press SW2 will turn on buzzer                                  
+        if (button_SW2==0) buzzer=0;
+        else               buzzer=1;
+    }
+}
+
diff -r 000000000000 -r fc7f6fbecb11 mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Fri Sep 29 05:42:52 2017 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#ca661f9d28526ca8f874b05432493a489c9671ea