Modify the file main.cpp for M487

Committer:
shliu1
Date:
Fri Sep 29 05:42:52 2017 +0000
Revision:
0:fc7f6fbecb11
main.cpp adds the setting of TARGET_NUMAKER_PFM_M487 for M487

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shliu1 0:fc7f6fbecb11 1 // For NuMaker-PFM-NUC472 GPIO pins connected to rgbled, green led, buzzer
shliu1 0:fc7f6fbecb11 2 #include "mbed.h"
shliu1 0:fc7f6fbecb11 3 #if defined(TARGET_NUMAKER_PFM_NUC472)
shliu1 0:fc7f6fbecb11 4 DigitalOut rgbled_B(PD_8); // low-active
shliu1 0:fc7f6fbecb11 5 DigitalOut rgbled_R(PD_9); // low-active
shliu1 0:fc7f6fbecb11 6 DigitalOut rgbled_G(PA_4); // low-active
shliu1 0:fc7f6fbecb11 7 DigitalOut greenled(PG_0); // low-active
shliu1 0:fc7f6fbecb11 8 DigitalOut buzzer(PD_11); // low-active
shliu1 0:fc7f6fbecb11 9 DigitalIn button_SW1(PC_12); // press button =0
shliu1 0:fc7f6fbecb11 10 DigitalIn button_SW2(PC_13); // press button =0
shliu1 0:fc7f6fbecb11 11 #elif defined(TARGET_NUMAKER_PFM_M453)
shliu1 0:fc7f6fbecb11 12 DigitalOut rgbled_B(PD_7); // low-active
shliu1 0:fc7f6fbecb11 13 DigitalOut rgbled_R(PD_2); // low-active
shliu1 0:fc7f6fbecb11 14 DigitalOut rgbled_G(PD_3); // low-active
shliu1 0:fc7f6fbecb11 15 DigitalOut greenled(PB_12); // low-active
shliu1 0:fc7f6fbecb11 16 DigitalOut buzzer(PE_2); // low-active
shliu1 0:fc7f6fbecb11 17 DigitalIn button_SW1(PA_15); // press button =0
shliu1 0:fc7f6fbecb11 18 DigitalIn button_SW2(PA_14); // press button =0
shliu1 0:fc7f6fbecb11 19 #elif defined(TARGET_NUMAKER_PFM_M487)
shliu1 0:fc7f6fbecb11 20 DigitalOut rgbled_B(PH_1); // in M487 rgbled_B is yellow, not blue. low-active
shliu1 0:fc7f6fbecb11 21 DigitalOut rgbled_R(PH_0); // low-active
shliu1 0:fc7f6fbecb11 22 DigitalOut rgbled_G(PH_2); // low-active
shliu1 0:fc7f6fbecb11 23 DigitalOut greenled(PH_2); // in M487 use the pin to connect the led, low-active
shliu1 0:fc7f6fbecb11 24 DigitalOut buzzer(PF_11); // in M487 use the pin to connect the buzzer, low-active
shliu1 0:fc7f6fbecb11 25 DigitalIn button_SW1(PC_10); // in M487 button_SW1 is SW2, press button =0
shliu1 0:fc7f6fbecb11 26 DigitalIn button_SW2(PC_9); // in M487 button_SW2 is SW3, press button =0
shliu1 0:fc7f6fbecb11 27 #endif
shliu1 0:fc7f6fbecb11 28
shliu1 0:fc7f6fbecb11 29 // main() runs in its own thread in the OS
shliu1 0:fc7f6fbecb11 30 // (note the calls to Thread::wait below for d elays)
shliu1 0:fc7f6fbecb11 31 int main() {
shliu1 0:fc7f6fbecb11 32
shliu1 0:fc7f6fbecb11 33 rgbled_B=1; rgbled_R=1; rgbled_G=1;
shliu1 0:fc7f6fbecb11 34 greenled=1;
shliu1 0:fc7f6fbecb11 35 buzzer=1;
shliu1 0:fc7f6fbecb11 36
shliu1 0:fc7f6fbecb11 37 while (true) {
shliu1 0:fc7f6fbecb11 38 // press SW1 will turn on greeled and RGBLED=blue
shliu1 0:fc7f6fbecb11 39 if (button_SW1==0) {
shliu1 0:fc7f6fbecb11 40 greenled=0;
shliu1 0:fc7f6fbecb11 41 rgbled_B=0;
shliu1 0:fc7f6fbecb11 42 }
shliu1 0:fc7f6fbecb11 43 else {
shliu1 0:fc7f6fbecb11 44 greenled=1;
shliu1 0:fc7f6fbecb11 45 rgbled_B=1;
shliu1 0:fc7f6fbecb11 46 }
shliu1 0:fc7f6fbecb11 47 // press SW2 will turn on buzzer
shliu1 0:fc7f6fbecb11 48 if (button_SW2==0) buzzer=0;
shliu1 0:fc7f6fbecb11 49 else buzzer=1;
shliu1 0:fc7f6fbecb11 50 }
shliu1 0:fc7f6fbecb11 51 }
shliu1 0:fc7f6fbecb11 52