⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd__driver_8c-source.html

📁 SMS傳送Sourcode,compiler with C,AT command
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!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>AVR323 Interfacing GSM modems: ATAVRBFLY_FILES/LCD_driver.c Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.7 --><div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div><h1>ATAVRBFLY_FILES/LCD_driver.c</h1><a href="LCD__driver_8c.html">Go to the documentation of this file.</a><pre class="fragment"><div>00001 <span class="comment">// This file has been prepared for Doxygen automatic documentation generation.</span>00023 <span class="comment"></span><span class="comment">// Include files.</span>00024 <span class="preprocessor">#include"iom169.h"</span>00025 <span class="preprocessor">#include"<a class="code" href="LCD__driver_8h.html">LCD_driver.h</a>"</span>00026 <span class="preprocessor">#include"<a class="code" href="types_8h.html">types.h</a>"</span>00027 00028 00029 <span class="comment">// Variable from "button.c" to prevent button-bouncing</span><a name="l00030"></a><a class="code" href="LCD__driver_8c.html#a0">00030</a> <span class="keyword">extern</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="button_8c.html#a0">gButtonTimeout</a>;00031 <a name="l00032"></a><a class="code" href="LCD__driver_8c.html#a1">00032</a> <span class="keyword">extern</span> <a class="code" href="types_8h.html#a0">BOOL</a> <a class="code" href="LCD__driver_8c.html#a1">gAutoPressJoystick</a>;00033 00034 <span class="comment">// Used to indicate when the LCD interrupt handler should update the LCD</span><a name="l00035"></a><a class="code" href="LCD__driver_8c.html#a2">00035</a> <span class="keywordtype">char</span> <a class="code" href="LCD__driver_8c.html#a2">gLCD_Update_Required</a> = <a class="code" href="LCD__functions_8c.html#a0">FALSE</a>;00036 00037 <span class="comment">// LCD display buffer (for double buffering).</span><a name="l00038"></a><a class="code" href="LCD__driver_8c.html#a3">00038</a> <span class="keywordtype">char</span> <a class="code" href="LCD__driver_8c.html#a3">LCD_Data</a>[<a class="code" href="LCD__driver_8h.html#a3">LCD_REGISTER_COUNT</a>];00039 00040 <span class="comment">// Buffer that contains the text to be displayed</span>00041 <span class="comment">// Note: Bit 7 indicates that this character is flashing</span><a name="l00042"></a><a class="code" href="LCD__driver_8c.html#a4">00042</a> <span class="keywordtype">char</span> <a class="code" href="LCD__driver_8c.html#a4">gTextBuffer</a>[<a class="code" href="LCD__driver_8h.html#a4">TEXTBUFFER_SIZE</a>];00043 00044 <span class="comment">// Only six letters can be shown on the LCD.</span>00045 <span class="comment">// With the gScroll and gScrollMode variables,</span>00046 <span class="comment">// one can select which part of the buffer to show</span><a name="l00047"></a><a class="code" href="LCD__driver_8c.html#a5">00047</a> <span class="keywordtype">signed</span> <span class="keywordtype">char</span> <a class="code" href="LCD__driver_8c.html#a5">gScroll</a>;<a name="l00048"></a><a class="code" href="LCD__driver_8c.html#a6">00048</a> <span class="keywordtype">char</span> <a class="code" href="LCD__driver_8c.html#a6">gScrollMode</a>;00049 <a name="l00051"></a><a class="code" href="LCD__driver_8c.html#a7">00051</a> <span class="keywordtype">char</span> <a class="code" href="LCD__driver_8c.html#a7">gLCD_Start_Scroll_Timer</a> = 0;00052 00053 <span class="comment">// The gFlashTimer is used to determine the on/off</span>00054 <span class="comment">// timing of flashing characters</span><a name="l00055"></a><a class="code" href="LCD__driver_8c.html#a8">00055</a> <span class="keywordtype">char</span> <a class="code" href="LCD__driver_8c.html#a8">gFlashTimer</a> = 0;00056 00057 <span class="comment">// Turns on/off the colons on the LCD</span><a name="l00058"></a><a class="code" href="LCD__driver_8c.html#a9">00058</a> <span class="keywordtype">char</span> <a class="code" href="LCD__driver_8c.html#a9">gColon</a> = 0;00059 00060 00061 <span class="comment">// Look-up table used when converting ASCII to</span>00062 <span class="comment">// LCD display data (segment control)</span><a name="l00063"></a><a class="code" href="LCD__driver_8c.html#a10">00063</a> __flash <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="LCD__driver_8c.html#a10">LCD_character_table</a>[] =00064 {00065     0x0A51,     <span class="comment">// '*' (?)</span>00066     0x2A80,     <span class="comment">// '+'</span>00067     0x0000,     <span class="comment">// ',' (Not defined)</span>00068     0x0A00,     <span class="comment">// '-'</span>00069     0x0A51,     <span class="comment">// '.' Degree sign</span>00070     0x0000,     <span class="comment">// '/' (Not defined)</span>00071     0x5559,     <span class="comment">// '0'</span>00072     0x0118,     <span class="comment">// '1'</span>00073     0x1e11,     <span class="comment">// '2</span>00074     0x1b11,     <span class="comment">// '3</span>00075     0x0b50,     <span class="comment">// '4</span>00076     0x1b41,     <span class="comment">// '5</span>00077     0x1f41,     <span class="comment">// '6</span>00078     0x0111,     <span class="comment">// '7</span>00079     0x1f51,     <span class="comment">// '8</span>00080     0x1b51,     <span class="comment">// '9'</span>00081     0x0000,     <span class="comment">// ':' (Not defined)</span>00082     0x0000,     <span class="comment">// ';' (Not defined)</span>00083     0x0000,     <span class="comment">// '&lt;' (Not defined)</span>00084     0x0000,     <span class="comment">// '=' (Not defined)</span>00085     0x0000,     <span class="comment">// '&gt;' (Not defined)</span>00086     0x0000,     <span class="comment">// '?' (Not defined)</span>00087     0x0000,     <span class="comment">// '@' (Not defined)</span>00088     0x0f51,     <span class="comment">// 'A' (+ 'a')</span>00089     0x3991,     <span class="comment">// 'B' (+ 'b')</span>00090     0x1441,     <span class="comment">// 'C' (+ 'c')</span>00091     0x3191,     <span class="comment">// 'D' (+ 'd')</span>00092     0x1e41,     <span class="comment">// 'E' (+ 'e')</span>00093     0x0e41,     <span class="comment">// 'F' (+ 'f')</span>00094     0x1d41,     <span class="comment">// 'G' (+ 'g')</span>00095     0x0f50,     <span class="comment">// 'H' (+ 'h')</span>00096     0x2080,     <span class="comment">// 'I' (+ 'i')</span>00097     0x1510,     <span class="comment">// 'J' (+ 'j')</span>00098     0x8648,     <span class="comment">// 'K' (+ 'k')</span>00099     0x1440,     <span class="comment">// 'L' (+ 'l')</span>00100     0x0578,     <span class="comment">// 'M' (+ 'm')</span>00101     0x8570,     <span class="comment">// 'N' (+ 'n')</span>00102     0x1551,     <span class="comment">// 'O' (+ 'o')</span>00103     0x0e51,     <span class="comment">// 'P' (+ 'p')</span>00104     0x9551,     <span class="comment">// 'Q' (+ 'q')</span>00105     0x8e51,     <span class="comment">// 'R' (+ 'r')</span>00106     0x9021,     <span class="comment">// 'S' (+ 's')</span>00107     0x2081,     <span class="comment">// 'T' (+ 't')</span>00108     0x1550,     <span class="comment">// 'U' (+ 'u')</span>00109     0x4448,     <span class="comment">// 'V' (+ 'v')</span>00110     0xc550,     <span class="comment">// 'W' (+ 'w')</span>00111     0xc028,     <span class="comment">// 'X' (+ 'x')</span>00112     0x2028,     <span class="comment">// 'Y' (+ 'y')</span>00113     0x5009,     <span class="comment">// 'Z' (+ 'z')</span>00114     0x0000,     <span class="comment">// '[' (Not defined)</span>00115     0x0000,     <span class="comment">// '\' (Not defined)</span>00116     0x0000,     <span class="comment">// ']' (Not defined)</span>00117     0x0000,     <span class="comment">// '^' (Not defined)</span>00118     0x0000      <span class="comment">// '_'</span>00119 };00120 00121 00122 <span class="comment">/*****************************************************************************</span>00123 <span class="comment">*</span>00124 <span class="comment">*   Function name : LCD_Init</span>00125 <span class="comment">*</span>00126 <span class="comment">*   Returns :       None</span>00127 <span class="comment">*</span>00128 <span class="comment">*   Parameters :    None</span>00129 <span class="comment">*</span>00130 <span class="comment">*   Purpose :       Initialize LCD_displayData buffer.</span>00131 <span class="comment">*                   Set up the LCD (timing, contrast, etc.)</span>00132 <span class="comment">*</span>00133 <span class="comment">*****************************************************************************/</span><a name="l00134"></a><a class="code" href="LCD__driver_8h.html#a18">00134</a> <span class="keywordtype">void</span> <a class="code" href="LCD__driver_8c.html#a11">LCD_Init</a> (<span class="keywordtype">void</span>)00135 {00136     <a class="code" href="LCD__driver_8h.html#a20">LCD_AllSegments</a>(<a class="code" href="LCD__functions_8c.html#a0">FALSE</a>);                     <span class="comment">// Clear segment buffer.</span>00137 00138     <a class="code" href="LCD__driver_8h.html#a10">LCD_CONTRAST_LEVEL</a>(<a class="code" href="LCD__driver_8h.html#a0">LCD_INITIAL_CONTRAST</a>);    <span class="comment">//Set the LCD contrast level</span>00139 00140     <span class="comment">// Select asynchronous clock source, enable all COM pins and enable all</span>00141     <span class="comment">// segment pins.</span>00142     LCDCRB = (1&lt;&lt;LCDCS) | (3&lt;&lt;LCDMUX0) | (7&lt;&lt;LCDPM0);00143 00144     <span class="comment">// Set LCD prescaler to give a framerate of 32,0 Hz</span>00145     LCDFRR = (0&lt;&lt;LCDPS0) | (7&lt;&lt;LCDCD0);00146 00147     LCDCRA = (1&lt;&lt;LCDEN) | (1&lt;&lt;LCDAB);           <span class="comment">// Enable LCD and set low power waveform</span>00148 00149     <span class="comment">//Enable LCD start of frame interrupt</span>00150     LCDCRA |= (1&lt;&lt;LCDIE);00151 00152     <a class="code" href="LCD__driver_8c.html#a2">gLCD_Update_Required</a> = <a class="code" href="LCD__functions_8c.html#a0">FALSE</a>;00153 00154 00155 }00156 00157 00158 <span class="comment">/*****************************************************************************</span>00159 <span class="comment">*</span>00160 <span class="comment">*   Function name : LCD_WriteDigit(char c, char digit)</span>00161 <span class="comment">*</span>00162 <span class="comment">*   Returns :       None</span>00163 <span class="comment">*</span>00164 <span class="comment">*   Parameters :    Inputs</span>00165 <span class="comment">*                   c: The symbol to be displayed in a LCD digit</span>00166 <span class="comment">*                   digit: In which digit (0-5) the symbol should be displayed</span>00167 <span class="comment">*                   Note: Digit 0 is the first used digit on the LCD,</span>00168 <span class="comment">*                   i.e LCD digit 2</span>00169 <span class="comment">*</span>00170 <span class="comment">*   Purpose :       Stores LCD control data in the LCD_displayData buffer.</span>00171 <span class="comment">*                   (The LCD_displayData is latched in the LCD_SOF interrupt.)</span>00172 <span class="comment">*</span>00173 <span class="comment">*****************************************************************************/</span><a name="l00174"></a><a class="code" href="LCD__driver_8h.html#a19">00174</a> <span class="keywordtype">void</span> <a class="code" href="LCD__driver_8h.html#a19">LCD_WriteDigit</a>(<span class="keywordtype">char</span> c, <span class="keywordtype">char</span> digit)00175 {00176 00177     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> seg = 0x0000;                  <span class="comment">// Holds the segment pattern</span>00178     <span class="keywordtype">char</span> <a class="code" href="AVRGSM__zip_8c.html#a1">mask</a>, nibble;00179     <span class="keywordtype">char</span> *ptr;00180     <span class="keywordtype">char</span> i;00181 00182 00183     <span class="keywordflow">if</span> (digit &gt; 5)                              <span class="comment">// Skip if digit is illegal</span>00184         <span class="keywordflow">return</span>;00185 00186     <span class="comment">//Lookup character table for segmet data</span>00187     <span class="keywordflow">if</span> ((c &gt;= <span class="charliteral">'*'</span>) &amp;&amp; (c &lt;= <span class="charliteral">'z'</span>))00188     {00189         <span class="comment">// c is a letter</span>00190         <span class="keywordflow">if</span> (c &gt;= <span class="charliteral">'a'</span>)                           <span class="comment">// Convert to upper case</span>00191             c &amp;= ~0x20;                         <span class="comment">// if necessarry</span>00192 00193         c -= <span class="charliteral">'*'</span>;00194 00195         seg = <a class="code" href="LCD__driver_8c.html#a10">LCD_character_table</a>[c];00196     }00197 00198     <span class="comment">// Adjust mask according to LCD segment mapping</span>00199     <span class="keywordflow">if</span> (digit &amp; 0x01)00200         <a class="code" href="AVRGSM__zip_8c.html#a1">mask</a> = 0x0F;                <span class="comment">// Digit 1, 3, 5</span>00201     <span class="keywordflow">else</span>00202         <a class="code" href="AVRGSM__zip_8c.html#a1">mask</a> = 0xF0;                <span class="comment">// Digit 0, 2, 4</span>00203 00204     ptr = <a class="code" href="LCD__driver_8c.html#a3">LCD_Data</a> + (digit &gt;&gt; 1);  <span class="comment">// digit = {0,0,1,1,2,2}</span>00205 00206     <span class="keywordflow">for</span> (i = 0; i &lt; 4; i++)00207     {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -