Kei Ohta
/
USB_Serial
for TSUBAME
main.cpp@0:522b4f6b8f49, 2014-07-03 (annotated)
- Committer:
- ohtake_i
- Date:
- Thu Jul 03 01:50:47 2014 +0000
- Revision:
- 0:522b4f6b8f49
for TSUBAME
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ohtake_i | 0:522b4f6b8f49 | 1 | #include "mbed.h"; |
ohtake_i | 0:522b4f6b8f49 | 2 | |
ohtake_i | 0:522b4f6b8f49 | 3 | Serial pc(USBTX, USBRX); // tx, rx |
ohtake_i | 0:522b4f6b8f49 | 4 | DigitalOut debug1(LED1); |
ohtake_i | 0:522b4f6b8f49 | 5 | |
ohtake_i | 0:522b4f6b8f49 | 6 | // display character from pc using interrupt |
ohtake_i | 0:522b4f6b8f49 | 7 | void rxCallBack(void) { |
ohtake_i | 0:522b4f6b8f49 | 8 | debug1 = !debug1; |
ohtake_i | 0:522b4f6b8f49 | 9 | pc.putc(pc.getc()); |
ohtake_i | 0:522b4f6b8f49 | 10 | } |
ohtake_i | 0:522b4f6b8f49 | 11 | |
ohtake_i | 0:522b4f6b8f49 | 12 | int main() { |
ohtake_i | 0:522b4f6b8f49 | 13 | |
ohtake_i | 0:522b4f6b8f49 | 14 | // define interrupt |
ohtake_i | 0:522b4f6b8f49 | 15 | pc.attach(rxCallBack, Serial::RxIrq); |
ohtake_i | 0:522b4f6b8f49 | 16 | |
ohtake_i | 0:522b4f6b8f49 | 17 | char TSUBAME[] = {'T','S','U','B','A','M','E',' '}; // 8 |
ohtake_i | 0:522b4f6b8f49 | 18 | char data[] = {'8','8',' ','2','0',' ','C','2',' ','9','A',' ','0','1',' ','0','1',' ','2','E',' ','2','E',' ','1','8',' ','4','3',' ','8','7',' ','F','8',' ','0','9',' ','0','9',' ','0','0',' ','0','1',' '}; // 32 |
ohtake_i | 0:522b4f6b8f49 | 19 | char MESSAGE[] = {'H','I',' ','H','I',' ','D','E',' ','J','Q','1','Y','T','C',' '}; // 15 |
ohtake_i | 0:522b4f6b8f49 | 20 | |
ohtake_i | 0:522b4f6b8f49 | 21 | while(1) |
ohtake_i | 0:522b4f6b8f49 | 22 | { |
ohtake_i | 0:522b4f6b8f49 | 23 | int i; |
ohtake_i | 0:522b4f6b8f49 | 24 | for(i=0; i<8; i++) |
ohtake_i | 0:522b4f6b8f49 | 25 | { |
ohtake_i | 0:522b4f6b8f49 | 26 | pc.putc(TSUBAME[i]); |
ohtake_i | 0:522b4f6b8f49 | 27 | pc.printf("\r\n"); |
ohtake_i | 0:522b4f6b8f49 | 28 | wait(0.1); |
ohtake_i | 0:522b4f6b8f49 | 29 | } |
ohtake_i | 0:522b4f6b8f49 | 30 | for(i=0; i<48; i++) |
ohtake_i | 0:522b4f6b8f49 | 31 | { |
ohtake_i | 0:522b4f6b8f49 | 32 | pc.putc(data[i]); |
ohtake_i | 0:522b4f6b8f49 | 33 | pc.printf("\r\n"); |
ohtake_i | 0:522b4f6b8f49 | 34 | wait(0.1); |
ohtake_i | 0:522b4f6b8f49 | 35 | } |
ohtake_i | 0:522b4f6b8f49 | 36 | for(i=0; i<16; i++) |
ohtake_i | 0:522b4f6b8f49 | 37 | { |
ohtake_i | 0:522b4f6b8f49 | 38 | pc.putc(MESSAGE[i]); |
ohtake_i | 0:522b4f6b8f49 | 39 | pc.printf("\r\n"); |
ohtake_i | 0:522b4f6b8f49 | 40 | wait(0.1); |
ohtake_i | 0:522b4f6b8f49 | 41 | } |
ohtake_i | 0:522b4f6b8f49 | 42 | } |
ohtake_i | 0:522b4f6b8f49 | 43 | } |
ohtake_i | 0:522b4f6b8f49 | 44 |