by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
HostIO.cpp@0:507436d37d5e, 2012-10-15 (annotated)
- Committer:
- robt
- Date:
- Mon Oct 15 21:23:48 2012 +0000
- Revision:
- 0:507436d37d5e
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
robt | 0:507436d37d5e | 1 | /* Program Example 6.8: HostIO.cpp code for modular 7-seg keyboard controller |
robt | 0:507436d37d5e | 2 | */ |
robt | 0:507436d37d5e | 3 | #include "HostIO.h" |
robt | 0:507436d37d5e | 4 | |
robt | 0:507436d37d5e | 5 | Serial pc(USBTX, USBRX); // communication to host PC |
robt | 0:507436d37d5e | 6 | |
robt | 0:507436d37d5e | 7 | void HostInit(void) { |
robt | 0:507436d37d5e | 8 | pc.printf("\n\rType two digit numbers to be \n\r"); |
robt | 0:507436d37d5e | 9 | } |
robt | 0:507436d37d5e | 10 | |
robt | 0:507436d37d5e | 11 | char GetKeyInput(void) { |
robt | 0:507436d37d5e | 12 | char c = pc.getc(); // get keyboard ascii data |
robt | 0:507436d37d5e | 13 | pc.printf("%c",c); // print ascii value to host PC terminal |
robt | 0:507436d37d5e | 14 | return (c&0x0F); // return value as non-ascii |
robt | 0:507436d37d5e | 15 | } |