Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Task615Solution-mbedos54 by
Revision 3:0a9b0acc594d, committed 2017-10-31
- Comitter:
- noutram
- Date:
- Tue Oct 31 15:01:10 2017 +0000
- Parent:
- 2:91200df5ccd6
- Commit message:
- stage-3;
Changed in this revision
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 91200df5ccd6 -r 0a9b0acc594d main.cpp --- a/main.cpp Thu Mar 30 14:24:24 2017 +0000 +++ b/main.cpp Tue Oct 31 15:01:10 2017 +0000 @@ -8,19 +8,17 @@ void countUP(); void countDOWN(); -//Digital outputs DigitalOut onBoardLED(LED1); -DigitalOut redLED(D7); -DigitalOut yellowLED(D6); -DigitalOut greenLED(D5); +DigitalOut redLED(PE_15); +DigitalOut yellowLED(PB_10); +DigitalOut greenLED(PB_11); -//Digital inputs DigitalIn onBoardSwitch(USER_BUTTON); -DigitalIn SW1(D4); -DigitalIn SW2(D3); +DigitalIn SW1(PE_12); +DigitalIn SW2(PE_14); //MUTEX Lock -Mutex *countLock; +Mutex countLock; //Thread ID for the Main function (CMSIS API) osThreadId tidMain; @@ -33,9 +31,9 @@ { redLED = 1; - for (unsigned int n=0; n<10000; n++) { + for (unsigned int n=0; n<1000000; n++) { //Take lock - countLock->lock(); + countLock.lock(); //Critical section(s) count++; @@ -50,7 +48,7 @@ count++; //Release lock - countLock->unlock(); + countLock.unlock(); } redLED = 0; @@ -61,9 +59,9 @@ { yellowLED = 1; - for (unsigned int n=0; n<10000; n++) { + for (unsigned int n=0; n<1000000; n++) { //Take lock - countLock->lock(); + countLock.lock(); //Critical section(s) count--; @@ -78,7 +76,7 @@ count--; //Release lock - countLock->unlock(); + countLock.unlock(); } osSignalSet(tidMain, YELLOW_DONE); //Signal main thread we are done @@ -98,9 +96,6 @@ //Main thread ID tidMain = Thread::gettid(); - //Create lock - countLock = new Mutex(); - //Press the switch to run concurrently if (onBoardSwitch == 1) { printf("Running sequntially\n"); @@ -121,8 +116,5 @@ greenLED = 0; } - //Tidy - delete countLock; - while(true); }
diff -r 91200df5ccd6 -r 0a9b0acc594d mbed-os.lib --- a/mbed-os.lib Thu Mar 30 14:24:24 2017 +0000 +++ b/mbed-os.lib Tue Oct 31 15:01:10 2017 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#50b3418e45484ebf442b88cd935a2d5355402d7d +https://github.com/ARMmbed/mbed-os/#e62a1b9236b44e70ae3b0902dc538481c04d455b