クイズ大会で使う早押しボタンのスパゲッティプログラムです。
Dependencies: mbed
main.cpp@0:cb13f0c964c0, 2018-08-16 (annotated)
- Committer:
- 771_8bit
- Date:
- Thu Aug 16 11:45:58 2018 +0000
- Revision:
- 0:cb13f0c964c0
- Child:
- 1:201290089367
?????????????????????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
771_8bit | 0:cb13f0c964c0 | 1 | #include "mbed.h" |
771_8bit | 0:cb13f0c964c0 | 2 | #include "Serial.h" |
771_8bit | 0:cb13f0c964c0 | 3 | |
771_8bit | 0:cb13f0c964c0 | 4 | Serial usbSerial(USBTX, USBRX); |
771_8bit | 0:cb13f0c964c0 | 5 | InterruptIn mybutton(USER_BUTTON,PullUp); |
771_8bit | 0:cb13f0c964c0 | 6 | |
771_8bit | 0:cb13f0c964c0 | 7 | |
771_8bit | 0:cb13f0c964c0 | 8 | void ISR_Serial_Rx() |
771_8bit | 0:cb13f0c964c0 | 9 | { |
771_8bit | 0:cb13f0c964c0 | 10 | // シリアルの受信処理 |
771_8bit | 0:cb13f0c964c0 | 11 | char data = usbSerial.getc(); |
771_8bit | 0:cb13f0c964c0 | 12 | } |
771_8bit | 0:cb13f0c964c0 | 13 | |
771_8bit | 0:cb13f0c964c0 | 14 | void ISR_Serial_Tx() |
771_8bit | 0:cb13f0c964c0 | 15 | { |
771_8bit | 0:cb13f0c964c0 | 16 | // シリアルのs送信処理 |
771_8bit | 0:cb13f0c964c0 | 17 | usbSerial.attach(NULL, Serial::TxIrq); |
771_8bit | 0:cb13f0c964c0 | 18 | } |
771_8bit | 0:cb13f0c964c0 | 19 | |
771_8bit | 0:cb13f0c964c0 | 20 | void isr() { |
771_8bit | 0:cb13f0c964c0 | 21 | usbSerial.puts("a"); |
771_8bit | 0:cb13f0c964c0 | 22 | } |
771_8bit | 0:cb13f0c964c0 | 23 | |
771_8bit | 0:cb13f0c964c0 | 24 | int main() |
771_8bit | 0:cb13f0c964c0 | 25 | { |
771_8bit | 0:cb13f0c964c0 | 26 | mybutton.fall(&isr); |
771_8bit | 0:cb13f0c964c0 | 27 | while (1) {} |
771_8bit | 0:cb13f0c964c0 | 28 | } |