summaryrefslogtreecommitdiffstats
path: root/Graphic_Equalizer_v1.0/doc/html/smartmedia_8hcc-source.html
blob: f2918340a58119cd32e0341dae9ed0c8fbf98d81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!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>Graphic Equalizer 2: C:/Project  Marcel &amp; Oliver/Graphic_Equalizer/src/smartmedia.hcc Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.9.1 -->
<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="dirs.html">Directories</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>
<div class="nav">
<a class="el" href="dir_000000.html">C:</a>&nbsp;/&nbsp;<a class="el" href="dir_000001.html">Project  Marcel &amp; Oliver</a>&nbsp;/&nbsp;<a class="el" href="dir_000002.html">Graphic_Equalizer</a>&nbsp;/&nbsp;<a class="el" href="dir_000004.html">src</a></div>
<h1>smartmedia.hcc</h1><a href="smartmedia_8hcc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 
00019 <span class="comment">/******** System Includes *************/</span>
00020 <span class="preprocessor">#include &lt;stdlib.hch&gt;</span>
00021 
00022 <span class="preprocessor">#include "pal_master.hch"</span>
00023 
00024 <span class="comment">/******** Application Includes ********/</span>
00025 <span class="preprocessor">#include "<a class="code" href="configuration_8hch.html">configuration.hch</a>"</span>
00026 <span class="preprocessor">#include "<a class="code" href="display__shared_8hch.html">display_shared.hch</a>"</span>
00027 <span class="preprocessor">#include "<a class="code" href="smartmedia__shared_8hch.html">smartmedia_shared.hch</a>"</span>
00028 <span class="preprocessor">#include "<a class="code" href="smartmedia_8hch.html">smartmedia.hch</a>"</span>
00029 
00030 <span class="preprocessor">#if HAVE_DEBUG</span>
00031 <span class="preprocessor"></span><span class="preprocessor">        #include "debug.hch"</span>
00032 <span class="preprocessor">#endif</span>
00033 <span class="preprocessor"></span>
00034 <span class="preprocessor">#include "<a class="code" href="audio_8hch.html">audio.hch</a>"</span>
00035 <span class="preprocessor">#include "<a class="code" href="mouse__shared_8hch.html">mouse_shared.hch</a>"</span>
00036 <span class="preprocessor">#include "<a class="code" href="eventhandler__shared_8hch.html">eventhandler_shared.hch</a>"</span>
00037 <span class="preprocessor">#include "<a class="code" href="display_8hch.html">display.hch</a>"</span> <span class="comment">/* FIXME: temporary include, needs to be moved to 'init' */</span>
00038 
<a name="l00046"></a><a class="code" href="smartmedia_8hcc.html#a0">00046</a> <span class="keywordtype">unsigned</span> 1 <a class="code" href="smartmedia_8hch.html#a9">smartmedia_init</a>(<span class="keywordtype">void</span>) {
00047         <span class="keywordtype">unsigned</span> 1 retval;
00048         <span class="comment">/*</span>
00049 <span class="comment">         * Firstly we enable both the CPLD and the SmartMedia.</span>
00050 <span class="comment">         */</span>
00051         RC200CPLDEnable();
00052         RC200SmartMediaInit(&amp;retval);
00053 
00054         <span class="keywordflow">if</span> (retval) {
00055                 RC200SmartMediaReset(&amp;retval);
00056                 RC200SmartMediaInit(&amp;retval);
00057         }
00058         
00059         <span class="keywordflow">return</span> retval;  
00060 } <span class="comment">/* --- smartmedia_init() --- */</span>
00061 
00062 
00063 
<a name="l00072"></a><a class="code" href="smartmedia_8hcc.html#a1">00072</a> <span class="keywordtype">void</span> <a class="code" href="smartmedia_8hcc.html#a1">smartmedia_loaddata</a>(<a class="code" href="structskindata__t.html">skindata_t</a> *skindata) {
00073         <span class="comment">/*</span>
00074 <span class="comment">         * Setup RAM Handle, and determin maximum Data and Address widths</span>
00075 <span class="comment">         */</span>
00076         macro expr RAM_BANK0 = PalPL2RAMCT(0);
00077         macro expr DW = PalPL2RAMGetMaxDataWidthCT();
00078         macro expr AW = PalPL2RAMGetMaxAddressWidthCT();
00079 
00080         <span class="keywordtype">unsigned</span> DW data;
00081         <span class="keywordtype">unsigned</span> 27 smartmedia_address, smartmedia_address_mask;
00082         <span class="keywordtype">unsigned</span> AW address;
00083         <span class="keywordtype">unsigned</span> 8 mask, r, g, b;
00084         <span class="keywordtype">unsigned</span> 3 stage;
00085         <span class="keywordtype">unsigned</span> 1 result;
00086 
00087         <span class="keyword">extern</span> ram <span class="keywordtype">unsigned</span> 8 <a class="code" href="events_8hcc.html#a0">presets_default_values</a>[768];
00088 
00089 <span class="preprocessor">#if HAVE_DEBUG</span>
00090 <span class="preprocessor"></span>        <span class="comment">/*</span>
00091 <span class="comment">         * Print some nice stats about data loading.</span>
00092 <span class="comment">         */</span>
00093         print_eol();
00094         print_hex_value(0);
00095 <span class="preprocessor">#endif</span>
00096 <span class="preprocessor"></span>        <span class="comment">/*</span>
00097 <span class="comment">         * Before we enter our loop to fill our memory with valid data, we have</span>
00098 <span class="comment">         * to set the startup positions for the SmartMedia.</span>
00099 <span class="comment">         */</span>
00100         smartmedia_address = SMARTMEDIA_ADDRESS_SKIN_START;
00101         smartmedia_address_mask = SMARTMEDIA_ADDRESS_SKINMASK_START;
00102         stage = STAGE_LOAD_SKIN;
00103         <span class="comment">/*</span>
00104 <span class="comment">         * We start with the address of the skin, and do the loop until we have</span>
00105 <span class="comment">         * done the end of the help.</span>
00106 <span class="comment">         */</span>
00107         <span class="keywordflow">for</span> (address = ADDRESS_SKIN_START; address != (<a class="code" href="smartmedia__shared_8hch.html#a31">ADDRESS_PRESET_RESET_END</a> +1); address++) {
00108                 <span class="comment">/*</span>
00109 <span class="comment">                 * Once we are done with the loading of our skin, we need to</span>
00110 <span class="comment">                 * change the smartmedia start addresses.</span>
00111 <span class="comment">                 */</span>
00112                 <span class="keywordflow">switch</span> (address) {
00113                         <span class="keywordflow">case</span> <a class="code" href="smartmedia__shared_8hch.html#a24">ADDRESS_HELP_START</a>:
00114                                 smartmedia_address = SMARTMEDIA_ADDRESS_HELP_START;
00115                                 smartmedia_address_mask = SMARTMEDIA_ADDRESS_HELPMASK_START;
00116                                 stage = STAGE_LOAD_HELP;
00117                                 <span class="keywordflow">break</span>;
00118                         <span class="keywordflow">case</span> <a class="code" href="smartmedia__shared_8hch.html#a26">ADDRESS_GRAPHMASK_START</a>:
00119                                 smartmedia_address_mask = SMARTMEDIA_ADDRESS_GRAPHMASK_START;
00120                                 stage = STAGE_LOAD_GRAPH;
00121                                 <span class="keywordflow">break</span>;
00122                         <span class="keywordflow">case</span> <a class="code" href="smartmedia__shared_8hch.html#a28">ADDRESS_PRESET_DEMO_START</a>:
00123                                 smartmedia_address_mask = SMARTMEDIA_ADDRESS_PRESET_DEMO_START;
00124                                 stage = STAGE_LOAD_PRESET;
00125                                 <span class="keywordflow">break</span>;
00126                         <span class="keywordflow">case</span> <a class="code" href="smartmedia__shared_8hch.html#a30">ADDRESS_PRESET_RESET_START</a>:
00127                                 smartmedia_address_mask = SMARTMEDIA_ADDRESS_PRESET_RESET_START;
00128                                 stage = STAGE_LOAD_PRESET;
00129                                 <span class="keywordflow">break</span>;
00130                         <span class="keywordflow">default</span>:
00131                                 <span class="keywordflow">break</span>;
00132                 }
00133 
00134                 <span class="comment">/*</span>
00135 <span class="comment">                 * Before reading our data from the smartmedia we set our</span>
00136 <span class="comment">                 * address pointer to the address from our loop.</span>
00137 <span class="comment">                 */</span>
00138 <span class="preprocessor">#if HAVE_SMARTMEDIA</span>
00139 <span class="preprocessor"></span>                PalPL2RAMSetWriteAddress(RAM_BANK0, address);
00140 <span class="preprocessor">#else</span>
00141 <span class="preprocessor"></span>                PalPL2RAMSetWriteAddress(RAM_BANK0, 0);
00142 <span class="preprocessor">#endif</span>
00143 <span class="preprocessor"></span>
00144                 <span class="comment">/*</span>
00145 <span class="comment">                 * SmartMedia data is read one byte per call. Because we want</span>
00146 <span class="comment">                 * to store the mask + the rgb values in one variable for later</span>
00147 <span class="comment">                 * useage we need to read those 4 bytes from the smartmedia</span>
00148 <span class="comment">                 * before storing it as one.</span>
00149 <span class="comment">                 */</span>
00150 <span class="preprocessor">#if HAVE_SMARTMEDIA</span>
00151 <span class="preprocessor"></span>                <span class="comment">/*</span>
00152 <span class="comment">                 * FIXME: Due to a bug in the DK2 smartmedia libraries we need</span>
00153 <span class="comment">                 * stop reading after each byte with OperationEnd call. This is</span>
00154 <span class="comment">                 * VERY slow and must be changed.</span>
00155 <span class="comment">                 */</span>
00156                 <span class="keywordflow">if</span> ((<a class="code" href="smartmedia_8hch.html#a3">STAGE_LOAD_SKIN</a> == stage) || (<a class="code" href="smartmedia_8hch.html#a4">STAGE_LOAD_HELP</a> == stage)) {
00157                         RC200SmartMediaSetAddress(<a class="code" href="smartmedia_8hch.html#a1">READ</a>, smartmedia_address);
00158                         RC200SmartMediaRead(&amp;r, TRUE);
00159                         RC200SmartMediaOperationEnd(&amp;result);
00160                         RC200SmartMediaSetAddress(<a class="code" href="smartmedia_8hch.html#a1">READ</a>, (smartmedia_address +1));
00161                         RC200SmartMediaRead(&amp;g, TRUE);
00162                         RC200SmartMediaOperationEnd(&amp;result);
00163                         RC200SmartMediaSetAddress(<a class="code" href="smartmedia_8hch.html#a1">READ</a>, (smartmedia_address +2));
00164                         RC200SmartMediaRead(&amp;b, TRUE);
00165                         RC200SmartMediaOperationEnd(&amp;result);
00166                 }
00167                 RC200SmartMediaSetAddress(<a class="code" href="smartmedia_8hch.html#a1">READ</a>, smartmedia_address_mask);
00168                 RC200SmartMediaRead(&amp;mask, TRUE);
00169                 RC200SmartMediaOperationEnd(&amp;result);
00170 
00171                 <span class="keywordflow">switch</span> (stage) {
00172                         <span class="keywordflow">case</span> <a class="code" href="smartmedia_8hch.html#a3">STAGE_LOAD_SKIN</a>:
00173                                 data = 0 @ mask @ r @ g @ b;
00174                                 <span class="keywordflow">break</span>;
00175                         <span class="keywordflow">case</span> <a class="code" href="smartmedia_8hch.html#a4">STAGE_LOAD_HELP</a>:
00176                                 data = 0 @ mask @ r @ g @ b;
00177                                 <span class="keywordflow">break</span>;
00178                         <span class="keywordflow">case</span> <a class="code" href="smartmedia_8hch.html#a5">STAGE_LOAD_GRAPH</a>:
00179                                 data = (<span class="keywordtype">unsigned</span> DW)(0 @ mask) &lt;&lt; 24;
00180                                 <span class="keywordflow">break</span>;
00181                         <span class="keywordflow">case</span> <a class="code" href="smartmedia_8hch.html#a6">STAGE_LOAD_PRESET</a>:
00182                                 <a class="code" href="events_8hcc.html#a0">presets_default_values</a>[(address -ADDRESS_PRESET_DEMO_START) &lt;- 10] = mask;
00183                 }
00184                 
00185 <span class="preprocessor">#else</span>
00186 <span class="preprocessor"></span>                data = 0x0000ff00;
00187 <span class="preprocessor">#endif</span>
00188 <span class="preprocessor"></span>                <span class="comment">/*</span>
00189 <span class="comment">                 * Now that we have gathered all pixel data, store it in ram.</span>
00190 <span class="comment">                 */</span>
00191                 PalPL2RAMWrite(RAM_BANK0, data);
00192 
00193 <span class="preprocessor">#if HAVE_DEBUG</span>
00194 <span class="preprocessor"></span>                <span class="comment">/*</span>
00195 <span class="comment">                 * Print some nice stats about data loading.</span>
00196 <span class="comment">                 */</span>
00197                 <span class="keywordflow">if</span> (!(address &lt;- 10)) {
00198                         print_cr();
00199                         print_hex_value(0 @ (address \\ 11));
00200                         print_string(<span class="stringliteral">" / 000001C2 | data: "</span>);
00201                         print_hex_value(data &lt;- 32);
00202                 }
00203 <span class="preprocessor">#endif</span>
00204 <span class="preprocessor"></span>
00205                 <span class="comment">/*</span>
00206 <span class="comment">                 * Finally increase al our indexes approperiatly.</span>
00207 <span class="comment">                 */</span>
00208                 smartmedia_address += 3;
00209                 smartmedia_address_mask++;
00210         }
00211 
00212         <span class="comment">/*</span>
00213 <span class="comment">         * This block needs to probably move up into the fore loop where we</span>
00214 <span class="comment">         * calculate these settings later.</span>
00215 <span class="comment">         */</span>
00216         skindata-&gt;area_spectrum_top = 200;
00217         skindata-&gt;area_spectrum_bottom = 335;
00218         skindata-&gt;area_spectrum_left = 77;
00219         skindata-&gt;area_spectrum_right = 575;
00220         skindata-&gt;area_waveform_top = 46;
00221         skindata-&gt;area_waveform_bottom = 118;
00222         skindata-&gt;area_waveform_left = 76;
00223         skindata-&gt;area_waveform_right = 413;
00224         skindata-&gt;area_volume_top = 112;
00225         skindata-&gt;area_volume_bottom = 66;
00226         skindata-&gt;area_volume_left = 439;
00227         skindata-&gt;area_volume_right = 455;
00228         skindata-&gt;color_area_volume = PIXEL_VOLUME;
00229         skindata-&gt;color_area_waveform = PIXEL_WAVEFORM;
00230 <span class="comment">//      skindata-&gt;color_area_spectrum_top = PIXEL_SPECTRUM;</span>
00231 <span class="comment">//      skindata-&gt;color_area_spectrum_bottom = PIXEL_SPECTRUM;</span>
00232         skindata-&gt;color_equalizer = PIXEL_EQUALIZER;
00233 } <span class="comment">/* --- smartmedia_loaddata() --- */</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Dec 9 14:37:07 2004 for Graphic Equalizer 2 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address>
</body>
</html>