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.
main.cpp@3:2788b2e18904, 2020-05-18 (annotated)
- Committer:
- namcheol
- Date:
- Mon May 18 12:23:24 2020 +0000
- Revision:
- 3:2788b2e18904
- Parent:
- 2:20e20cfae75e
lab06-button-isr
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| dshin | 0:f31836d48420 | 1 | #include "mbed.h" |
| namcheol | 3:2788b2e18904 | 2 | #include "C12832.h" |
| namcheol | 3:2788b2e18904 | 3 | |
| namcheol | 3:2788b2e18904 | 4 | C12832 lcd(D11, D13, D12, D7, D10); //lcd = (MOSI, SCK, RESET, A0, nCS) |
| namcheol | 3:2788b2e18904 | 5 | PwmOut Red(D5); |
| namcheol | 3:2788b2e18904 | 6 | PwmOut Green(D9); |
| namcheol | 3:2788b2e18904 | 7 | InterruptIn sw2(SW2); |
| namcheol | 3:2788b2e18904 | 8 | InterruptIn sw3(SW3); |
| namcheol | 3:2788b2e18904 | 9 | |
| namcheol | 3:2788b2e18904 | 10 | int count_sw2 = 0; |
| namcheol | 3:2788b2e18904 | 11 | int count_sw3 = 0; |
| dshin | 0:f31836d48420 | 12 | |
| namcheol | 3:2788b2e18904 | 13 | void ISR_sw2(){ |
| namcheol | 3:2788b2e18904 | 14 | Red = 0; |
| namcheol | 3:2788b2e18904 | 15 | Green = 1; |
| namcheol | 3:2788b2e18904 | 16 | count_sw2++; |
| namcheol | 3:2788b2e18904 | 17 | } |
| namcheol | 3:2788b2e18904 | 18 | |
| namcheol | 3:2788b2e18904 | 19 | void ISR_sw3(){ |
| namcheol | 3:2788b2e18904 | 20 | Red = 1; |
| namcheol | 3:2788b2e18904 | 21 | Green = 0; |
| namcheol | 3:2788b2e18904 | 22 | count_sw3++; |
| namcheol | 3:2788b2e18904 | 23 | } |
| dshin | 0:f31836d48420 | 24 | |
| dshin | 0:f31836d48420 | 25 | int main() |
| dshin | 0:f31836d48420 | 26 | { |
| namcheol | 3:2788b2e18904 | 27 | int loop = 0; |
| namcheol | 3:2788b2e18904 | 28 | Red = Green = 1; |
| namcheol | 3:2788b2e18904 | 29 | |
| namcheol | 3:2788b2e18904 | 30 | sw2.rise(&ISR_sw2); |
| namcheol | 3:2788b2e18904 | 31 | sw3.fall(&ISR_sw3); |
| namcheol | 3:2788b2e18904 | 32 | |
| namcheol | 3:2788b2e18904 | 33 | lcd.cls(); |
| namcheol | 3:2788b2e18904 | 34 | while(true){ |
| namcheol | 3:2788b2e18904 | 35 | lcd.locate(0,6); |
| namcheol | 3:2788b2e18904 | 36 | lcd.printf("Button ISRs!"); |
| namcheol | 3:2788b2e18904 | 37 | lcd.locate(0,16); |
| namcheol | 3:2788b2e18904 | 38 | lcd.printf("Loop =%i, SW2=%i, SW3=%i", loop, count_sw2, count_sw3); |
| namcheol | 3:2788b2e18904 | 39 | ++loop; |
| namcheol | 3:2788b2e18904 | 40 | thread_sleep_for(100); |
| dshin | 0:f31836d48420 | 41 | } |
| dshin | 0:f31836d48420 | 42 | } |