Line No. | Rev | Author | Line |
---|---|---|---|
1 | 6 | kaklik | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
||
3 | <title>Procyon AVRlib: spyglass.c Source File</title> |
||
4 | <link href="dox.css" rel="stylesheet" type="text/css"> |
||
5 | </head><body> |
||
6 | <!-- Generated by Doxygen 1.4.2 --> |
||
7 | <div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div> |
||
8 | <h1>spyglass.c</h1><a href="spyglass_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file spyglass.c \brief Spyglass Control Panel UI Board Driver. */</span> |
||
9 | 00002 <span class="comment">//*****************************************************************************</span> |
||
10 | 00003 <span class="comment">//</span> |
||
11 | 00004 <span class="comment">// File Name : 'spyglass.c'</span> |
||
12 | 00005 <span class="comment">// Title : Spyglass Control Panel UI Board Driver</span> |
||
13 | 00006 <span class="comment">// Author : Pascal Stang - Copyright (C) 2005</span> |
||
14 | 00007 <span class="comment">// Created : 7/20/2005</span> |
||
15 | 00008 <span class="comment">// Revised : 7/23/2005</span> |
||
16 | 00009 <span class="comment">// Version : 0.9</span> |
||
17 | 00010 <span class="comment">// Target MCU : Atmel AVR series</span> |
||
18 | 00011 <span class="comment">// Editor Tabs : 4</span> |
||
19 | 00012 <span class="comment">//</span> |
||
20 | 00013 <span class="comment">// This code is distributed under the GNU Public License</span> |
||
21 | 00014 <span class="comment">// which can be found at http://www.gnu.org/licenses/gpl.txt</span> |
||
22 | 00015 <span class="comment">//</span> |
||
23 | 00016 <span class="comment">//*****************************************************************************</span> |
||
24 | 00017 |
||
25 | 00018 |
||
26 | 00019 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span> |
||
27 | 00020 <span class="preprocessor">#include "<a class="code" href="rprintf_8h.html">rprintf.h</a>"</span> |
||
28 | 00021 <span class="preprocessor">#include "<a class="code" href="timer_8h.html">timer.h</a>"</span> |
||
29 | 00022 <span class="preprocessor">#include "<a class="code" href="i2c_8h.html">i2c.h</a>"</span> |
||
30 | 00023 <span class="preprocessor">#include "<a class="code" href="spyglass_8h.html">spyglass.h</a>"</span> |
||
31 | 00024 |
||
32 | 00025 <span class="preprocessor">#include "<a class="code" href="lcd_8h.html">lcd.h</a>"</span> |
||
33 | 00026 |
||
34 | 00027 u08 PcfCtrlData; |
||
35 | 00028 |
||
36 | <a name="l00029"></a><a class="code" href="group__spyglass.html#ga11">00029</a> u08 <a class="code" href="group__spyglass.html#ga11">pcf8574Write</a>(u08 nodeAddr, u08 data) |
||
37 | 00030 { |
||
38 | 00031 <span class="comment">// write data</span> |
||
39 | 00032 <span class="keywordflow">return</span> <a class="code" href="i2c_8c.html#a24">i2cMasterSendNI</a>(PCF8574_I2C_BASE_ADDR+(nodeAddr<<1), 1, &data); |
||
40 | 00033 } |
||
41 | 00034 |
||
42 | <a name="l00035"></a><a class="code" href="group__spyglass.html#ga12">00035</a> u08 <a class="code" href="group__spyglass.html#ga12">pcf8574Read</a>(u08 nodeAddr) |
||
43 | 00036 { |
||
44 | 00037 u08 data; |
||
45 | 00038 <a class="code" href="i2c_8c.html#a25">i2cMasterReceiveNI</a>(PCF8574_I2C_BASE_ADDR+(nodeAddr<<1), 1, &data); |
||
46 | 00039 <span class="keywordflow">return</span> data; |
||
47 | 00040 } |
||
48 | 00041 |
||
49 | <a name="l00042"></a><a class="code" href="group__spyglass.html#ga0">00042</a> <span class="keywordtype">void</span> <a class="code" href="group__spyglass.html#ga0">spyglassInit</a>(<span class="keywordtype">void</span>) |
||
50 | 00043 { |
||
51 | 00044 <a class="code" href="i2c_8c.html#a10">i2cInit</a>(); |
||
52 | 00045 <a class="code" href="i2c_8c.html#a11">i2cSetBitrate</a>(100); |
||
53 | 00046 PcfCtrlData = (SPYGLASS_LED0 | SPYGLASS_LED1 | SPYGLASS_BEEPER); |
||
54 | 00047 <a class="code" href="group__spyglass.html#ga2">spyglassSetLeds</a>(0); |
||
55 | 00048 <a class="code" href="group__spyglass.html#ga3">spyglassSetBeeper</a>(0); |
||
56 | 00049 } |
||
57 | 00050 |
||
58 | <a name="l00051"></a><a class="code" href="group__spyglass.html#ga1">00051</a> u08 <a class="code" href="group__spyglass.html#ga1">spyglassGetPushbuttons</a>(<span class="keywordtype">void</span>) |
||
59 | 00052 { |
||
60 | 00053 <span class="keywordflow">return</span> ~<a class="code" href="group__spyglass.html#ga12">pcf8574Read</a>(PCF_NODE_BUTTONS); |
||
61 | 00054 } |
||
62 | 00055 |
||
63 | <a name="l00056"></a><a class="code" href="group__spyglass.html#ga2">00056</a> <span class="keywordtype">void</span> <a class="code" href="group__spyglass.html#ga2">spyglassSetLeds</a>(u08 leds) |
||
64 | 00057 { |
||
65 | 00058 PcfCtrlData = (PcfCtrlData|0x03) & ~(leds&0x03); |
||
66 | 00059 <a class="code" href="group__spyglass.html#ga11">pcf8574Write</a>(PCF_NODE_CONTROL, PcfCtrlData); |
||
67 | 00060 } |
||
68 | 00061 |
||
69 | <a name="l00062"></a><a class="code" href="group__spyglass.html#ga3">00062</a> <span class="keywordtype">void</span> <a class="code" href="group__spyglass.html#ga3">spyglassSetBeeper</a>(u08 state) |
||
70 | 00063 { |
||
71 | 00064 <span class="keywordflow">if</span>(state) |
||
72 | 00065 PcfCtrlData &=~SPYGLASS_BEEPER; <span class="comment">// beeper on</span> |
||
73 | 00066 <span class="keywordflow">else</span> |
||
74 | 00067 PcfCtrlData |= SPYGLASS_BEEPER; <span class="comment">// beeper off</span> |
||
75 | 00068 <a class="code" href="group__spyglass.html#ga11">pcf8574Write</a>(PCF_NODE_CONTROL, PcfCtrlData); |
||
76 | 00069 } |
||
77 | 00070 |
||
78 | <a name="l00071"></a><a class="code" href="group__spyglass.html#ga4">00071</a> u08 <a class="code" href="group__spyglass.html#ga4">spyglassSetLcdContrast</a>(u08 contrast) |
||
79 | 00072 { |
||
80 | 00073 u08 data[2]; |
||
81 | 00074 data[0] = 0; |
||
82 | 00075 data[1] = contrast; |
||
83 | 00076 <span class="keywordflow">return</span> <a class="code" href="i2c_8c.html#a24">i2cMasterSendNI</a>(MAX517_I2C_BASE_ADDR, 2, data); |
||
84 | 00077 } |
||
85 | 00078 |
||
86 | <a name="l00079"></a><a class="code" href="group__spyglass.html#ga9">00079</a> <span class="keywordtype">void</span> <a class="code" href="group__spyglass.html#ga9">spyglassLcdWrite</a>(u08 rs, u08 data) |
||
87 | 00080 { |
||
88 | 00081 <span class="comment">// prepare LCD control lines</span> |
||
89 | 00082 PcfCtrlData &= ~(SPYGLASS_LCD_RW | SPYGLASS_LCD_RS | SPYGLASS_LCD_E); |
||
90 | 00083 <span class="keywordflow">if</span>(rs) |
||
91 | 00084 PcfCtrlData |= SPYGLASS_LCD_RS; |
||
92 | 00085 <span class="comment">// set LCD control lines</span> |
||
93 | 00086 <a class="code" href="group__spyglass.html#ga11">pcf8574Write</a>(PCF_NODE_CONTROL, PcfCtrlData); |
||
94 | 00087 <span class="comment">// set data lines</span> |
||
95 | 00088 <a class="code" href="group__spyglass.html#ga11">pcf8574Write</a>(PCF_NODE_LCD_DATA, data); |
||
96 | 00089 <span class="comment">// clock E line</span> |
||
97 | 00090 <a class="code" href="group__spyglass.html#ga11">pcf8574Write</a>(PCF_NODE_CONTROL, PcfCtrlData|SPYGLASS_LCD_E); |
||
98 | 00091 <a class="code" href="group__spyglass.html#ga11">pcf8574Write</a>(PCF_NODE_CONTROL, PcfCtrlData); |
||
99 | 00092 } |
||
100 | 00093 |
||
101 | <a name="l00094"></a><a class="code" href="group__spyglass.html#ga10">00094</a> <span class="keywordtype">void</span> <a class="code" href="group__spyglass.html#ga10">spyglassLcdWriteChar</a>(u08 c) |
||
102 | 00095 { |
||
103 | 00096 <a class="code" href="group__spyglass.html#ga9">spyglassLcdWrite</a>(1,c); |
||
104 | 00097 } |
||
105 | 00098 |
||
106 | <a name="l00099"></a><a class="code" href="group__spyglass.html#ga5">00099</a> <span class="keywordtype">void</span> <a class="code" href="group__spyglass.html#ga5">spyglassLcdInit</a>(<span class="keywordtype">void</span>) |
||
107 | 00100 { |
||
108 | 00101 <span class="comment">// LCD function set</span> |
||
109 | 00102 <a class="code" href="group__spyglass.html#ga9">spyglassLcdWrite</a>(0,LCD_FUNCTION_DEFAULT); |
||
110 | 00103 <span class="comment">// clear LCD</span> |
||
111 | 00104 <a class="code" href="group__spyglass.html#ga9">spyglassLcdWrite</a>(0,1<<LCD_CLR); |
||
112 | 00105 delay(60000); <span class="comment">// wait 60ms</span> |
||
113 | 00106 <span class="comment">// set entry mode</span> |
||
114 | 00107 <a class="code" href="group__spyglass.html#ga9">spyglassLcdWrite</a>(0,1<<LCD_ENTRY_MODE | 1<<LCD_ENTRY_INC); |
||
115 | 00108 <span class="comment">// set display to on</span> |
||
116 | 00109 <a class="code" href="group__spyglass.html#ga9">spyglassLcdWrite</a>(0,1<<LCD_ON_CTRL | 1<<LCD_ON_DISPLAY ); |
||
117 | 00110 <span class="comment">// move cursor to home</span> |
||
118 | 00111 <a class="code" href="group__spyglass.html#ga9">spyglassLcdWrite</a>(0,1<<LCD_HOME); |
||
119 | 00112 <span class="comment">// set data address to 0</span> |
||
120 | 00113 <a class="code" href="group__spyglass.html#ga9">spyglassLcdWrite</a>(0,1<<LCD_DDRAM | 0x00); |
||
121 | 00114 |
||
122 | 00115 <span class="comment">// set contrast</span> |
||
123 | 00116 <a class="code" href="group__spyglass.html#ga4">spyglassSetLcdContrast</a>(20); |
||
124 | 00117 } |
||
125 | 00118 |
||
126 | <a name="l00119"></a><a class="code" href="group__spyglass.html#ga6">00119</a> <span class="keywordtype">void</span> <a class="code" href="group__spyglass.html#ga6">spyglassLcdHome</a>(<span class="keywordtype">void</span>) |
||
127 | 00120 { |
||
128 | 00121 <span class="comment">// move cursor to home</span> |
||
129 | 00122 <a class="code" href="group__spyglass.html#ga9">spyglassLcdWrite</a>(0,1<<LCD_HOME); |
||
130 | 00123 } |
||
131 | 00124 |
||
132 | <a name="l00125"></a><a class="code" href="group__spyglass.html#ga7">00125</a> <span class="keywordtype">void</span> <a class="code" href="group__spyglass.html#ga7">spyglassLcdClear</a>(<span class="keywordtype">void</span>) |
||
133 | 00126 { |
||
134 | 00127 <span class="comment">// clear LCD</span> |
||
135 | 00128 <a class="code" href="group__spyglass.html#ga9">spyglassLcdWrite</a>(0,1<<LCD_CLR); |
||
136 | 00129 } |
||
137 | 00130 |
||
138 | <a name="l00131"></a><a class="code" href="group__spyglass.html#ga8">00131</a> <span class="keywordtype">void</span> <a class="code" href="group__spyglass.html#ga8">spyglassLcdGotoXY</a>(u08 x, u08 y) |
||
139 | 00132 { |
||
140 | 00133 <span class="keyword">register</span> u08 DDRAMAddr; |
||
141 | 00134 |
||
142 | 00135 <span class="comment">// remap lines into proper order</span> |
||
143 | 00136 <span class="keywordflow">switch</span>(y) |
||
144 | 00137 { |
||
145 | 00138 <span class="keywordflow">case</span> 0: DDRAMAddr = LCD_LINE0_DDRAMADDR+x; <span class="keywordflow">break</span>; |
||
146 | 00139 <span class="keywordflow">case</span> 1: DDRAMAddr = LCD_LINE1_DDRAMADDR+x; <span class="keywordflow">break</span>; |
||
147 | 00140 <span class="keywordflow">case</span> 2: DDRAMAddr = LCD_LINE2_DDRAMADDR+x; <span class="keywordflow">break</span>; |
||
148 | 00141 <span class="keywordflow">case</span> 3: DDRAMAddr = LCD_LINE3_DDRAMADDR+x; <span class="keywordflow">break</span>; |
||
149 | 00142 <span class="keywordflow">default</span>: DDRAMAddr = LCD_LINE0_DDRAMADDR+x; |
||
150 | 00143 } |
||
151 | 00144 |
||
152 | 00145 <span class="comment">// set data address</span> |
||
153 | 00146 <a class="code" href="group__spyglass.html#ga9">spyglassLcdWrite</a>(0,1<<LCD_DDRAM | DDRAMAddr); |
||
154 | 00147 } |
||
155 | </pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:07 2006 for Procyon AVRlib by |
||
156 | <a href="http://www.doxygen.org/index.html"> |
||
157 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address> |
||
158 | </body> |
||
159 | </html> |
Powered by WebSVN v2.8.3