yuto kawamura
/
George_Slave_BOTHMOVE
right and left move at the same time
KondoServoLibrary/SerialHalfDuplex_HM/SerialHalfDuplex.cpp@0:411ab20ce87d, 2019-04-26 (annotated)
- Committer:
- eri
- Date:
- Fri Apr 26 11:34:44 2019 +0000
- Revision:
- 0:411ab20ce87d
a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
eri | 0:411ab20ce87d | 1 | /* mbed Microcontroller Library - SerialHalfDuplex |
eri | 0:411ab20ce87d | 2 | * Copyright (c) 2010-2011 ARM Limited. All rights reserved. |
eri | 0:411ab20ce87d | 3 | * written and changed by Hiroki Mineshita at 2016-04-12 |
eri | 0:411ab20ce87d | 4 | * by https://github.com/mbedmicro/mbed/tree/master/libraries/tests/libs/SerialHalfDuplex |
eri | 0:411ab20ce87d | 5 | */ |
eri | 0:411ab20ce87d | 6 | #include "SerialHalfDuplex.h" |
eri | 0:411ab20ce87d | 7 | |
eri | 0:411ab20ce87d | 8 | #if DEVICE_SERIAL |
eri | 0:411ab20ce87d | 9 | |
eri | 0:411ab20ce87d | 10 | namespace mbed { |
eri | 0:411ab20ce87d | 11 | |
eri | 0:411ab20ce87d | 12 | SerialHalfDuplex::SerialHalfDuplex(PinName tx, PinName rx,const char *name) |
eri | 0:411ab20ce87d | 13 | : Serial(tx,rx,name) { |
eri | 0:411ab20ce87d | 14 | } |
eri | 0:411ab20ce87d | 15 | |
eri | 0:411ab20ce87d | 16 | int SerialHalfDuplex::_putc(int c) { |
eri | 0:411ab20ce87d | 17 | int retc; |
eri | 0:411ab20ce87d | 18 | Serial::_putc(c); |
eri | 0:411ab20ce87d | 19 | if(Serial::readable())retc = Serial::getc(); // reading also clears any interrupt |
eri | 0:411ab20ce87d | 20 | else retc=-1000; |
eri | 0:411ab20ce87d | 21 | return retc; |
eri | 0:411ab20ce87d | 22 | } |
eri | 0:411ab20ce87d | 23 | |
eri | 0:411ab20ce87d | 24 | int SerialHalfDuplex::_getc(void) { |
eri | 0:411ab20ce87d | 25 | if(Serial::readable()) return Serial::_getc(); |
eri | 0:411ab20ce87d | 26 | else return -1000; |
eri | 0:411ab20ce87d | 27 | } |
eri | 0:411ab20ce87d | 28 | |
eri | 0:411ab20ce87d | 29 | } // End namespace |
eri | 0:411ab20ce87d | 30 | |
eri | 0:411ab20ce87d | 31 | #endif |