4 * Copyright (C) 2013-11-07 K.Ohta <whatisthis.sowhat ai gmail.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2,
9 * or (at your option) any later version.
10 * This library / program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this library; see the file COPYING. If not, write to the
17 * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
20 * As a special exception, if you link this(includeed from sdcc) library
21 * with other files, some of which are compiled with SDCC,
22 * to produce an executable, this library does not by itself cause
23 * the resulting executable to be covered by the GNU General Public License.
24 * This exception does not however invalidate any other reasons why
25 * the executable file might be covered by the GNU General Public License.
30 #include <pic18fregs.h> /* ONLY FOR PIC18x */
42 #include "uart_termio.h"
43 #include "shell_strutl.h"
46 unsigned char uart_term_putstr(unsigned char *s)
49 if((uart_getstat() & UART_WAKEUP) == 0) return 0; // Error
52 uart_pushchar(s[p], 200); // Timeout = 10ms
54 if(p >= 255) return 0; // Overlen
59 void uart_term_getstr(unsigned char *s, unsigned int timeout, unsigned char echo)
62 unsigned char c = 0x00;
73 if(chk_powerbutton() != 0) {
79 if(echo != 0) uart_pushchar(c, 200); // Echoback
89 if((c == '\t') || (c == '\n') || (c == '\r')) break; // TAB OR CR
93 } else if(timeout != 0) { // ZAP n * 100mSec.
94 if(chk_powerbutton() != 0) shutdown(0xff);
95 idle_time_ms(100 - 48); // Poll 0.1Sec
98 s[0] = TERM_CHAR_TIMEOUT;
103 idle_time_ms(100 - 48); // Wait 100ms if none (and no Timeout).
104 if(chk_powerbutton() != 0) shutdown(0xff);