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.
Revision 3:2788b2e18904, committed 2020-05-18
- Comitter:
- namcheol
- Date:
- Mon May 18 12:23:24 2020 +0000
- Parent:
- 2:20e20cfae75e
- Commit message:
- lab06-button-isr
Changed in this revision
| C12832.lib | 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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/C12832.lib Mon May 18 12:23:24 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/chris/code/C12832/#7de323fa46fe
--- a/main.cpp Mon Apr 27 08:02:20 2020 +0000
+++ b/main.cpp Mon May 18 12:23:24 2020 +0000
@@ -1,14 +1,42 @@
#include "mbed.h"
+#include "C12832.h"
+
+C12832 lcd(D11, D13, D12, D7, D10); //lcd = (MOSI, SCK, RESET, A0, nCS)
+PwmOut Red(D5);
+PwmOut Green(D9);
+InterruptIn sw2(SW2);
+InterruptIn sw3(SW3);
+
+int count_sw2 = 0;
+int count_sw3 = 0;
-Serial uart_tx(D1, D0); //D1 = tx, D0 = rx
-DigitalIn sw(D2, PullDown);
+void ISR_sw2(){
+ Red = 0;
+ Green = 1;
+ count_sw2++;
+ }
+
+void ISR_sw3(){
+ Red = 1;
+ Green = 0;
+ count_sw3++;
+ }
int main()
{
- while(true) {
- if(sw == 1) {
- uart_tx.putc('1');
- thread_sleep_for(200);
- }
+ int loop = 0;
+ Red = Green = 1;
+
+ sw2.rise(&ISR_sw2);
+ sw3.fall(&ISR_sw3);
+
+ lcd.cls();
+ while(true){
+ lcd.locate(0,6);
+ lcd.printf("Button ISRs!");
+ lcd.locate(0,16);
+ lcd.printf("Loop =%i, SW2=%i, SW3=%i", loop, count_sw2, count_sw3);
+ ++loop;
+ thread_sleep_for(100);
}
}
\ No newline at end of file