Anders Hörnfeldt / Mbed 2 deprecated coniolib

Dependencies:   mbed

Dependents:   KNN_coba5

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers hw_mbed.c Source File

hw_mbed.c

00001 #include "mbed.h"
00002 #include "conio.h"
00003 
00004 Serial pc(USBTX, USBRX);
00005 
00006 int get_esc_sec () {
00007     int ch;
00008     if (pc.scanf("\x1b\x5b%c",ch) == 0)
00009         return 0;
00010     else
00011         return ch;
00012 }
00013 
00014 int _kbhit (void) {
00015     return pc.readable();
00016 }
00017 
00018 
00019 void _putch (char ch) {
00020     pc.putc(ch);
00021 }
00022 
00023 int _getch (void) {
00024     int ret;
00025 
00026     while (!_kbhit()); //wait and read new char
00027     ret = pc.getc();
00028     if (ret==0) {
00029         while (!_kbhit()); //wait and read new char
00030         ret = pc.getc();
00031         ret = ret | 0x100;
00032     }
00033 
00034     return ret;
00035 }
00036 
00037 
00038 void MCU_Init(void) {
00039     pc.baud(19200);
00040 }