📄 input_8c-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Procyon ARMlib-LPC2100: input.c Source File</title><link href="dox.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.6 --><div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="globals.html">Globals</a></div><h1>input.c</h1><a href="input_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*! \file input.c \brief User-Input Functions. */</span>00002 <span class="comment">//*****************************************************************************</span>00003 <span class="comment">//</span>00004 <span class="comment">// File Name : 'input.c'</span>00005 <span class="comment">// Title : User-Input Functions</span>00006 <span class="comment">// Author : Pascal Stang - Copyright (C) 2003</span>00007 <span class="comment">// Created : 2003.09.11</span>00008 <span class="comment">// Revised : 2003.09.11</span>00009 <span class="comment">// Version : 0.1</span>00010 <span class="comment">// Target MCU : any</span>00011 <span class="comment">// Editor Tabs : 4</span>00012 <span class="comment">//</span>00013 <span class="comment">// This code is distributed under the GNU Public License</span>00014 <span class="comment">// which can be found at http://www.gnu.org/licenses/gpl.txt</span>00015 <span class="comment">//</span>00016 <span class="comment">//*****************************************************************************</span>00017 00018 <span class="comment">//----- Include Files ---------------------------------------------------------</span>00019 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span> <span class="comment">// include our global settings</span>00020 <span class="preprocessor">#include "<a class="code" href="uart_8h.html">uart.h</a>"</span>00021 <span class="preprocessor">#include "<a class="code" href="rprintf_8h.html">rprintf.h</a>"</span> <span class="comment">// include printf function library</span>00022 00023 <span class="preprocessor">#include "<a class="code" href="input_8h.html">input.h</a>"</span>00024 00025 <span class="comment">// globals</span>00026 00027 <span class="comment">// functions</span>00028 u08 inputString(u08 termChar, u08 termLen, u08* data)00029 {00030 <span class="keywordtype">int</span> s=-1;00031 u08 length=0;00032 00033 <span class="keywordflow">while</span>(length < termLen)00034 {00035 <span class="comment">// get input</span>00036 s = -1;00037 <span class="keywordflow">while</span>(s == -1)00038 {00039 s = uart1GetByte();00040 }00041 00042 <span class="comment">// handle special characters</span>00043 <span class="keywordflow">if</span>(s == 0x08) <span class="comment">// backspace</span>00044 {00045 <span class="keywordflow">if</span>(length > 0)00046 {00047 <span class="comment">// echo backspace-space-backspace</span>00048 <a class="code" href="rprintf_8h.html#a7">rprintfChar</a>(0x08);00049 <a class="code" href="rprintf_8h.html#a7">rprintfChar</a>(<span class="charliteral">' '</span>);00050 <a class="code" href="rprintf_8h.html#a7">rprintfChar</a>(0x08);00051 length--;00052 }00053 }00054 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(s == termChar) <span class="comment">// termination character</span>00055 {00056 <span class="comment">// save null-termination</span>00057 data[length] = 0;00058 <span class="keywordflow">break</span>;00059 }00060 <span class="keywordflow">else</span>00061 {00062 <span class="comment">// echo character</span>00063 <a class="code" href="rprintf_8h.html#a7">rprintfChar</a>(s);00064 <span class="comment">// save character</span>00065 data[length++] = s;00066 }00067 }00068 <span class="keywordflow">return</span> length;00069 }00070 00071 u08 asciiHexToByte(u08* string)00072 {00073 <span class="comment">// convert 2-byte hex string to byte</span>00074 <span class="keywordflow">return</span> (asciiHexToNibble(string[0])<<4) + asciiHexToNibble(string[1]);00075 }00076 00077 u08 asciiHexToNibble(u08 character)00078 {00079 <span class="comment">// convert 1-byte hex ascii character to nibble</span>00080 <span class="keywordflow">if</span>((character >= 0x30) && (character <= 0x39))00081 <span class="keywordflow">return</span> character-0x30;00082 <span class="keywordflow">else</span> <span class="keywordflow">if</span>((character >= <span class="charliteral">'A'</span>) && (character <= <span class="charliteral">'F'</span>))00083 <span class="keywordflow">return</span> character-<span class="charliteral">'A'</span>+10;00084 <span class="keywordflow">else</span> <span class="keywordflow">if</span>((character >= <span class="charliteral">'a'</span>) && (character <= <span class="charliteral">'f'</span>))00085 <span class="keywordflow">return</span> character-<span class="charliteral">'a'</span>+10;00086 <span class="keywordflow">else</span> <span class="keywordflow">return</span> 0;00087 }</pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Jul 13 03:38:11 2004 for Procyon ARMlib-LPC2100 by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 > </a>1.3.6 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -