@@ -0,0 +1,4 | |||||
|
1 | [Paths] | |||
|
2 | Prefix=.. | |||
|
3 | Examples=../../Examples/Qt-5.4 | |||
|
4 | Documentation=../../Docs/Qt-5.4 |
This diff has been collapsed as it changes many lines, (1227 lines changed) Show them Hide them | |||||
@@ -0,0 +1,1227 | |||||
|
1 | #!/usr/bin/env perl | |||
|
2 | ############################################################################# | |||
|
3 | ## | |||
|
4 | ## Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | |||
|
5 | ## Contact: http://www.qt-project.org/legal | |||
|
6 | ## | |||
|
7 | ## This file is part of the build configuration tools of the Qt Toolkit. | |||
|
8 | ## | |||
|
9 | ## $QT_BEGIN_LICENSE:LGPL$ | |||
|
10 | ## Commercial License Usage | |||
|
11 | ## Licensees holding valid commercial Qt licenses may use this file in | |||
|
12 | ## accordance with the commercial license agreement provided with the | |||
|
13 | ## Software or, alternatively, in accordance with the terms contained in | |||
|
14 | ## a written agreement between you and Digia. For licensing terms and | |||
|
15 | ## conditions see http://qt.digia.com/licensing. For further information | |||
|
16 | ## use the contact form at http://qt.digia.com/contact-us. | |||
|
17 | ## | |||
|
18 | ## GNU Lesser General Public License Usage | |||
|
19 | ## Alternatively, this file may be used under the terms of the GNU Lesser | |||
|
20 | ## General Public License version 2.1 as published by the Free Software | |||
|
21 | ## Foundation and appearing in the file LICENSE.LGPL included in the | |||
|
22 | ## packaging of this file. Please review the following information to | |||
|
23 | ## ensure the GNU Lesser General Public License version 2.1 requirements | |||
|
24 | ## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | |||
|
25 | ## | |||
|
26 | ## In addition, as a special exception, Digia gives you certain additional | |||
|
27 | ## rights. These rights are described in the Digia Qt LGPL Exception | |||
|
28 | ## version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | |||
|
29 | ## | |||
|
30 | ## GNU General Public License Usage | |||
|
31 | ## Alternatively, this file may be used under the terms of the GNU | |||
|
32 | ## General Public License version 3.0 as published by the Free Software | |||
|
33 | ## Foundation and appearing in the file LICENSE.GPL included in the | |||
|
34 | ## packaging of this file. Please review the following information to | |||
|
35 | ## ensure the GNU General Public License version 3.0 requirements will be | |||
|
36 | ## met: http://www.gnu.org/copyleft/gpl.html. | |||
|
37 | ## | |||
|
38 | ## | |||
|
39 | ## $QT_END_LICENSE$ | |||
|
40 | ## | |||
|
41 | ############################################################################# | |||
|
42 | ||||
|
43 | # | |||
|
44 | # Synchronizes Qt header files - internal development tool. | |||
|
45 | # | |||
|
46 | ||||
|
47 | # use packages ------------------------------------------------------- | |||
|
48 | use File::Basename; | |||
|
49 | use File::Path; | |||
|
50 | use File::Spec; | |||
|
51 | use Cwd; | |||
|
52 | use Cwd 'abs_path'; | |||
|
53 | use Config; | |||
|
54 | use strict; | |||
|
55 | use warnings; | |||
|
56 | use English qw(-no_match_vars ); | |||
|
57 | ||||
|
58 | my $normalizePath_fixDrive = ($^O eq "msys" ? 1 : 0); | |||
|
59 | ||||
|
60 | ###################################################################### | |||
|
61 | # Syntax: normalizePath(\$path) | |||
|
62 | # Params: Reference to a path that's going to be normalized. | |||
|
63 | # | |||
|
64 | # Purpose: Converts the path into a form that can be used as include | |||
|
65 | # path from C++ sources and qmake's .pro files. | |||
|
66 | # Only relevant on Windows. | |||
|
67 | # Returns: -none- | |||
|
68 | ###################################################################### | |||
|
69 | sub normalizePath { | |||
|
70 | my $s = shift; | |||
|
71 | $$s =~ s=\\=/=g; | |||
|
72 | if ($normalizePath_fixDrive && ($$s =~ m,^/([a-zA-Z])/(.*), || $$s =~ m,^([a-zA-Z]):/(.*),)) { | |||
|
73 | $$s = lc($1) . ":/$2"; | |||
|
74 | } | |||
|
75 | } | |||
|
76 | ||||
|
77 | # set output basedir to be where ever syncqt is run from | |||
|
78 | our $out_basedir = getcwd(); | |||
|
79 | normalizePath(\$out_basedir); | |||
|
80 | our $basedir; | |||
|
81 | our $quoted_basedir; | |||
|
82 | ||||
|
83 | # Make sure we use Windows line endings for chomp and friends on Windows. | |||
|
84 | $INPUT_RECORD_SEPARATOR = "\r\n" if ($^O eq "msys"); | |||
|
85 | ||||
|
86 | # will be defined based on the modules sync.profile | |||
|
87 | our (%modules, %moduleheaders, @allmoduleheadersprivate, %classnames, %deprecatedheaders); | |||
|
88 | our @qpa_headers = (); | |||
|
89 | ||||
|
90 | # will be derived from sync.profile | |||
|
91 | our %reverse_classnames = (); | |||
|
92 | ||||
|
93 | # global variables (modified by options) | |||
|
94 | my $isunix = 0; | |||
|
95 | my $module = 0; | |||
|
96 | my $showonly = 0; | |||
|
97 | my $verbose_level = 1; | |||
|
98 | my $remove_stale = 1; | |||
|
99 | my $force_win = 0; | |||
|
100 | my $force_relative = 0; | |||
|
101 | my $check_includes = 0; | |||
|
102 | my $copy_headers = 0; | |||
|
103 | my $create_private_headers = 1; | |||
|
104 | my $minimal = 0; | |||
|
105 | my $module_version = 0; | |||
|
106 | my @modules_to_sync ; | |||
|
107 | $force_relative = 1 if ( -d "/System/Library/Frameworks" ); | |||
|
108 | ||||
|
109 | ||||
|
110 | # functions ---------------------------------------------------------- | |||
|
111 | ||||
|
112 | ###################################################################### | |||
|
113 | # Syntax: showUsage() | |||
|
114 | # Params: -none- | |||
|
115 | # | |||
|
116 | # Purpose: Show the usage of the script. | |||
|
117 | # Returns: -none- | |||
|
118 | ###################################################################### | |||
|
119 | sub showUsage | |||
|
120 | { | |||
|
121 | print "$0 usage:\n"; | |||
|
122 | print " <module directory> Specifies which module to sync header files for (required for shadow builds!)\n\n"; | |||
|
123 | ||||
|
124 | print " -copy Copy headers instead of include-fwd(default: " . ($copy_headers ? "yes" : "no") . ")\n"; | |||
|
125 | print " -remove-stale Removes stale headers (default: " . ($remove_stale ? "yes" : "no") . ")\n"; | |||
|
126 | print " -relative Force relative symlinks (default: " . ($force_relative ? "yes" : "no") . ")\n"; | |||
|
127 | print " -windows Force platform to Windows (default: " . ($force_win ? "yes" : "no") . ")\n"; | |||
|
128 | print " -showonly Show action but not perform (default: " . ($showonly ? "yes" : "no") . ")\n"; | |||
|
129 | print " -minimal Do not create CamelCase headers (default: " . ($minimal ? "yes" : "no") . ")\n"; | |||
|
130 | print " -outdir <PATH> Specify output directory for sync (default: $out_basedir)\n"; | |||
|
131 | print " -version <VERSION> Specify the module's version (default: detect from qglobal.h)\n"; | |||
|
132 | print " -quiet Only report problems, not activity (same as -verbose 0)\n"; | |||
|
133 | print " -v, -verbose <level> Sets the verbosity level (max. 4) (default: $verbose_level)\n"; | |||
|
134 | print " The short form increases the level by +1\n"; | |||
|
135 | print " -separate-module <NAME>:<PROFILEDIR>:<HEADERDIR>\n"; | |||
|
136 | print " Create headers for <NAME> with original headers in\n"; | |||
|
137 | print " <HEADERDIR> relative to <PROFILEDIR> \n"; | |||
|
138 | print " -private Force copy private headers (default: " . ($create_private_headers ? "yes" : "no") . ")\n"; | |||
|
139 | print " -help This help\n"; | |||
|
140 | exit 0; | |||
|
141 | } | |||
|
142 | ||||
|
143 | ###################################################################### | |||
|
144 | # Syntax: checkUnix() | |||
|
145 | # Params: -none- | |||
|
146 | # | |||
|
147 | # Purpose: Check if script runs on a Unix system or not. Cygwin | |||
|
148 | # systems are _not_ detected as Unix systems. | |||
|
149 | # Returns: 1 if a unix system, else 0. | |||
|
150 | ###################################################################### | |||
|
151 | sub checkUnix { | |||
|
152 | my ($r) = 0; | |||
|
153 | if ( $force_win != 0) { | |||
|
154 | return 0; | |||
|
155 | } elsif ( -f "/bin/uname" ) { | |||
|
156 | $r = 1; | |||
|
157 | (-f "\\bin\\uname") && ($r = 0); | |||
|
158 | } elsif ( -f "/usr/bin/uname" ) { | |||
|
159 | $r = 1; | |||
|
160 | (-f "\\usr\\bin\\uname") && ($r = 0); | |||
|
161 | } | |||
|
162 | if($r) { | |||
|
163 | $_ = $Config{'osname'}; | |||
|
164 | $r = 0 if( /(ms)|(cyg)win/i ); | |||
|
165 | } | |||
|
166 | return $r; | |||
|
167 | } | |||
|
168 | ||||
|
169 | sub checkRelative { | |||
|
170 | my ($dir) = @_; | |||
|
171 | return 0 if($dir =~ /^\//); | |||
|
172 | return 0 if(!checkUnix() && $dir =~ /[a-zA-Z]:[\/\\]/); | |||
|
173 | return 1; | |||
|
174 | } | |||
|
175 | ||||
|
176 | ###################################################################### | |||
|
177 | # Syntax: shouldMasterInclude(iheader) | |||
|
178 | # Params: iheader, string, filename to verify inclusion | |||
|
179 | # | |||
|
180 | # Purpose: Determines if header should be in the master include file. | |||
|
181 | # Returns: 0 if file contains "#pragma qt_no_master_include" or not | |||
|
182 | # able to open, else 1. | |||
|
183 | ###################################################################### | |||
|
184 | sub shouldMasterInclude { | |||
|
185 | my ($iheader) = @_; | |||
|
186 | return 0 if (basename($iheader) =~ /_/); | |||
|
187 | return 0 if (basename($iheader) =~ /qconfig/); | |||
|
188 | if (open(F, "<$iheader")) { | |||
|
189 | while (<F>) { | |||
|
190 | chomp; | |||
|
191 | return 0 if (/^\#pragma qt_no_master_include$/); | |||
|
192 | } | |||
|
193 | close(F); | |||
|
194 | } else { | |||
|
195 | return 0; | |||
|
196 | } | |||
|
197 | return 1; | |||
|
198 | } | |||
|
199 | ||||
|
200 | ###################################################################### | |||
|
201 | # Syntax: classNames(iheader) | |||
|
202 | # Params: iheader, string, filename to parse for classname "symlinks" | |||
|
203 | # | |||
|
204 | # Purpose: Scans through iheader to find all classnames that should be | |||
|
205 | # synced into library's include structure. | |||
|
206 | # Returns: List of all class names in a file. | |||
|
207 | ###################################################################### | |||
|
208 | sub classNames { | |||
|
209 | my @ret; | |||
|
210 | my ($iheader) = @_; | |||
|
211 | ||||
|
212 | my $ihdrbase = basename($iheader); | |||
|
213 | my $classname = $classnames{$ihdrbase}; | |||
|
214 | push @ret, split(/,/, $classname) if ($classname); | |||
|
215 | ||||
|
216 | my $parsable = ""; | |||
|
217 | if(open(F, "<$iheader")) { | |||
|
218 | while(<F>) { | |||
|
219 | my $line = $_; | |||
|
220 | chomp $line; | |||
|
221 | chop $line if ($line =~ /\r$/); | |||
|
222 | if($line =~ /^\#/) { | |||
|
223 | return @ret if($line =~ m/^#pragma qt_sync_stop_processing/); | |||
|
224 | push(@ret, $1) if($line =~ m/^#pragma qt_class\(([^)]*)\)[\r\n]*$/); | |||
|
225 | $line = 0; | |||
|
226 | } | |||
|
227 | if($line) { | |||
|
228 | $line =~ s,//.*$,,; #remove c++ comments | |||
|
229 | $line .= ";" if($line =~ m/^Q_[A-Z_]*\(.*\)[\r\n]*$/); #qt macro | |||
|
230 | $line .= ";" if($line =~ m/^QT_(BEGIN|END)_HEADER[\r\n]*$/); #qt macro | |||
|
231 | $line .= ";" if($line =~ m/^QT_(BEGIN|END)_NAMESPACE(_[A-Z]+)*[\r\n]*$/); #qt macro | |||
|
232 | $line .= ";" if($line =~ m/^QT_MODULE\(.*\)[\r\n]*$/); # QT_MODULE macro | |||
|
233 | $parsable .= " " . $line; | |||
|
234 | } | |||
|
235 | } | |||
|
236 | close(F); | |||
|
237 | } | |||
|
238 | ||||
|
239 | my $last_definition = 0; | |||
|
240 | my @namespaces; | |||
|
241 | for(my $i = 0; $i < length($parsable); $i++) { | |||
|
242 | my $definition = 0; | |||
|
243 | my $character = substr($parsable, $i, 1); | |||
|
244 | if($character eq "/" && substr($parsable, $i+1, 1) eq "*") { #I parse like this for greedy reasons | |||
|
245 | for($i+=2; $i < length($parsable); $i++) { | |||
|
246 | my $end = substr($parsable, $i, 2); | |||
|
247 | if($end eq "*/") { | |||
|
248 | $last_definition = $i+2; | |||
|
249 | $i++; | |||
|
250 | last; | |||
|
251 | } | |||
|
252 | } | |||
|
253 | } elsif($character eq "{") { | |||
|
254 | my $brace_depth = 1; | |||
|
255 | my $block_start = $i + 1; | |||
|
256 | BLOCK: for($i+=1; $i < length($parsable); $i++) { | |||
|
257 | my $ignore = substr($parsable, $i, 1); | |||
|
258 | if($ignore eq "{") { | |||
|
259 | $brace_depth++; | |||
|
260 | } elsif($ignore eq "}") { | |||
|
261 | $brace_depth--; | |||
|
262 | unless($brace_depth) { | |||
|
263 | for(my $i2 = $i+1; $i2 < length($parsable); $i2++) { | |||
|
264 | my $end = substr($parsable, $i2, 1); | |||
|
265 | if($end eq ";" || $end ne " ") { | |||
|
266 | $definition = substr($parsable, $last_definition, $block_start - $last_definition) . "}"; | |||
|
267 | $i = $i2 if($end eq ";"); | |||
|
268 | $last_definition = $i + 1; | |||
|
269 | last BLOCK; | |||
|
270 | } | |||
|
271 | } | |||
|
272 | } | |||
|
273 | } | |||
|
274 | } | |||
|
275 | } elsif($character eq ";") { | |||
|
276 | $definition = substr($parsable, $last_definition, $i - $last_definition + 1); | |||
|
277 | $last_definition = $i + 1; | |||
|
278 | } elsif($character eq "}") { | |||
|
279 | # a naked } must be a namespace ending | |||
|
280 | # if it's not a namespace, it's eaten by the loop above | |||
|
281 | pop @namespaces; | |||
|
282 | $last_definition = $i + 1; | |||
|
283 | } | |||
|
284 | ||||
|
285 | if (substr($parsable, $last_definition, $i - $last_definition + 1) =~ m/ namespace ([^ ]*) / | |||
|
286 | && substr($parsable, $i+1, 1) eq "{") { | |||
|
287 | push @namespaces, $1; | |||
|
288 | ||||
|
289 | # Eat the opening { so that the condensing loop above doesn't see it | |||
|
290 | $i++; | |||
|
291 | $last_definition = $i + 1; | |||
|
292 | } | |||
|
293 | ||||
|
294 | if($definition) { | |||
|
295 | $definition =~ s=[\n\r]==g; | |||
|
296 | my @symbols; | |||
|
297 | my $post_kw = qr/Q_DECL_FINAL|final|sealed/; # add here macros and keywords that go after the class-name of a class definition | |||
|
298 | if($definition =~ m/^ *typedef *.*\(\*([^\)]*)\)\(.*\);$/) { | |||
|
299 | push @symbols, $1; | |||
|
300 | } elsif($definition =~ m/^ *typedef +(.*) +([^ ]*);$/) { | |||
|
301 | push @symbols, $2; | |||
|
302 | } elsif($definition =~ m/^ *(template *<.*> *)?(class|struct) +([^ <>]* +)?((?!$post_kw)[^<\s]+) ?(<[^>]*> ?)?\s*(?:$post_kw)?\s*((,|:)\s*(public|protected|private) *.*)? *\{\}$/o) { | |||
|
303 | push @symbols, $4; | |||
|
304 | } elsif($definition =~ m/^ *Q_DECLARE_.*ITERATOR\((.*)\);$/) { | |||
|
305 | push @symbols, "Q" . $1 . "Iterator"; | |||
|
306 | push @symbols, "QMutable" . $1 . "Iterator"; | |||
|
307 | } | |||
|
308 | ||||
|
309 | our $publicclassregexp; | |||
|
310 | foreach my $symbol (@symbols) { | |||
|
311 | $symbol = (join("::", @namespaces) . "::" . $symbol) if (scalar @namespaces); | |||
|
312 | ||||
|
313 | my $revhdr = $reverse_classnames{$symbol}; | |||
|
314 | next if (defined($revhdr) and $revhdr ne $ihdrbase); | |||
|
315 | if ($symbol =~ /^Q[^:]*$/) { # no-namespace, starting with Q | |||
|
316 | push @ret, $symbol; | |||
|
317 | } elsif (defined($publicclassregexp)) { | |||
|
318 | push @ret, $symbol if ($symbol =~ $publicclassregexp); | |||
|
319 | } | |||
|
320 | } | |||
|
321 | } | |||
|
322 | } | |||
|
323 | return @ret; | |||
|
324 | } | |||
|
325 | ||||
|
326 | sub make_path { | |||
|
327 | my ($dir, $lib, $be_verbose) = @_; | |||
|
328 | unless(-e $dir) { | |||
|
329 | mkpath $dir; | |||
|
330 | $dir = "<outbase>" . substr($dir, length($out_basedir)) if ($be_verbose < 3); | |||
|
331 | print "$lib: mkpath $dir\n" if ($be_verbose > 1); | |||
|
332 | } | |||
|
333 | } | |||
|
334 | ||||
|
335 | ###################################################################### | |||
|
336 | # Syntax: syncHeader(header, iheader, copy, timestamp) | |||
|
337 | # Params: header, string, filename to create "symlink" for | |||
|
338 | # iheader, string, destination name of symlink | |||
|
339 | # copy, forces header to be a copy of iheader | |||
|
340 | # timestamp, the requested modification time if copying | |||
|
341 | # | |||
|
342 | # Purpose: Syncronizes header to iheader | |||
|
343 | # Returns: 1 if successful, else 0. | |||
|
344 | ###################################################################### | |||
|
345 | sub syncHeader { | |||
|
346 | my ($lib, $header, $iheader, $copy, $ts) = @_; | |||
|
347 | normalizePath(\$iheader); | |||
|
348 | normalizePath(\$header); | |||
|
349 | return copyFile($lib, $iheader, $header) if($copy); | |||
|
350 | ||||
|
351 | unless(-e $header) { | |||
|
352 | my $header_dir = dirname($header); | |||
|
353 | make_path($header_dir, $lib, $verbose_level); | |||
|
354 | ||||
|
355 | #write it | |||
|
356 | my $iheader_out = fixPaths($iheader, $header_dir); | |||
|
357 | open(HEADER, ">$header") || die "Could not open $header for writing: $!\n"; | |||
|
358 | print HEADER "#include \"$iheader_out\"\n"; | |||
|
359 | close HEADER; | |||
|
360 | if(defined($ts)) { | |||
|
361 | utime(time, $ts, $header) or die "$iheader, $header"; | |||
|
362 | } | |||
|
363 | return 1; | |||
|
364 | } | |||
|
365 | return 0; | |||
|
366 | } | |||
|
367 | ||||
|
368 | ###################################################################### | |||
|
369 | # Syntax: fixPaths(file, dir) | |||
|
370 | # Params: file, string, filepath to be made relative to dir | |||
|
371 | # dir, string, dirpath for point of origin | |||
|
372 | # | |||
|
373 | # Purpose: file is made relative (if possible) of dir. | |||
|
374 | # Returns: String with the above applied conversion. | |||
|
375 | ###################################################################### | |||
|
376 | ||||
|
377 | sub cleanupPath { | |||
|
378 | my ($file) = @_; | |||
|
379 | normalizePath(\$file); | |||
|
380 | while ($file =~ s,/[^/]+/\.\./,/,) {} | |||
|
381 | return $file; | |||
|
382 | } | |||
|
383 | ||||
|
384 | sub fixPaths { | |||
|
385 | my ($file, $dir) = @_; | |||
|
386 | ||||
|
387 | my $out = File::Spec->abs2rel(cleanupPath($file), cleanupPath($dir)); | |||
|
388 | $out =~ s,\\,/,g; | |||
|
389 | return $out; | |||
|
390 | } | |||
|
391 | ||||
|
392 | ###################################################################### | |||
|
393 | # Syntax: fileContents(filename) | |||
|
394 | # Params: filename, string, filename of file to return contents | |||
|
395 | # | |||
|
396 | # Purpose: Get the contents of a file. | |||
|
397 | # Returns: String with contents of the file, or empty string if file | |||
|
398 | # doens't exist. | |||
|
399 | # Warning: Dies if it does exist but script cannot get read access. | |||
|
400 | ###################################################################### | |||
|
401 | sub fileContents { | |||
|
402 | my ($filename) = @_; | |||
|
403 | my $filecontents = ""; | |||
|
404 | if (-e $filename) { | |||
|
405 | open(I, "< $filename") || die "Could not open $filename for reading, read block?"; | |||
|
406 | local $/; | |||
|
407 | binmode I; | |||
|
408 | $filecontents = <I>; | |||
|
409 | close I; | |||
|
410 | } | |||
|
411 | return $filecontents; | |||
|
412 | } | |||
|
413 | ||||
|
414 | ###################################################################### | |||
|
415 | # Syntax: writeFile(filename, contents) | |||
|
416 | # Params: filename, string, filename of file to write | |||
|
417 | # contents, string, new contents for the file | |||
|
418 | # | |||
|
419 | # Purpose: Write file with given contents. If new contents match old | |||
|
420 | # ones, do no change the file's timestamp. | |||
|
421 | # Returns: 1 if the file's contents changed. | |||
|
422 | ###################################################################### | |||
|
423 | sub writeFile { | |||
|
424 | my ($filename, $contents, $lib, $what) = @_; | |||
|
425 | my $oldcontents = fileContents($filename); | |||
|
426 | $oldcontents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms | |||
|
427 | if ($oldcontents ne $contents) { | |||
|
428 | open(O, "> " . $filename) || die "Could not open $filename for writing: $!\n"; | |||
|
429 | print O $contents; | |||
|
430 | close O; | |||
|
431 | if ($lib && $verbose_level) { | |||
|
432 | my $action = ($oldcontents eq "") ? "created" : "updated"; | |||
|
433 | print "$lib: $action $what\n"; | |||
|
434 | } | |||
|
435 | return 1; | |||
|
436 | } | |||
|
437 | return 0; | |||
|
438 | } | |||
|
439 | ||||
|
440 | ###################################################################### | |||
|
441 | # Syntax: fileCompare(file1, file2) | |||
|
442 | # Params: file1, string, filename of first file | |||
|
443 | # file2, string, filename of second file | |||
|
444 | # | |||
|
445 | # Purpose: Determines if files are equal, and which one is newer. | |||
|
446 | # Returns: 0 if files are equal no matter the timestamp, -1 if file1 | |||
|
447 | # is newer, 1 if file2 is newer. | |||
|
448 | ###################################################################### | |||
|
449 | sub fileCompare { | |||
|
450 | my ($file1, $file2) = @_; | |||
|
451 | my $file1contents = fileContents($file1); | |||
|
452 | my $file2contents = fileContents($file2); | |||
|
453 | if (! -e $file1) { return 1; } | |||
|
454 | if (! -e $file2) { return -1; } | |||
|
455 | return $file1contents ne $file2contents ? (stat($file2))[9] <=> (stat($file1))[9] : 0; | |||
|
456 | } | |||
|
457 | ||||
|
458 | ###################################################################### | |||
|
459 | # Syntax: copyFile(file, ifile) | |||
|
460 | # Params: file, string, filename to create duplicate for | |||
|
461 | # ifile, string, destination name of duplicate | |||
|
462 | # | |||
|
463 | # Purpose: Keeps files in sync so changes in the newer file will be | |||
|
464 | # written to the other. | |||
|
465 | # Returns: 1 if files were synced, else 0. | |||
|
466 | # Warning: Dies if script cannot get write access. | |||
|
467 | ###################################################################### | |||
|
468 | sub copyFile | |||
|
469 | { | |||
|
470 | my ($lib, $file,$ifile, $copy,$knowdiff,$filecontents,$ifilecontents) = @_; | |||
|
471 | # Bi-directional synchronization | |||
|
472 | open( I, "< " . $file ) || die "Could not open $file for reading"; | |||
|
473 | local $/; | |||
|
474 | binmode I; | |||
|
475 | $filecontents = <I>; | |||
|
476 | close I; | |||
|
477 | if ( open(I, "< " . $ifile) ) { | |||
|
478 | local $/; | |||
|
479 | binmode I; | |||
|
480 | $ifilecontents = <I>; | |||
|
481 | close I; | |||
|
482 | $copy = fileCompare($file, $ifile); | |||
|
483 | $knowdiff = 0, | |||
|
484 | } else { | |||
|
485 | $copy = -1; | |||
|
486 | $knowdiff = 1; | |||
|
487 | } | |||
|
488 | ||||
|
489 | if ( $knowdiff || ($filecontents ne $ifilecontents) ) { | |||
|
490 | if ( $copy > 0 ) { | |||
|
491 | my $file_dir = dirname($file); | |||
|
492 | make_path($file_dir, $lib, $verbose_level); | |||
|
493 | open(O, "> " . $file) || die "Could not open $file for writing (no write permission?)"; | |||
|
494 | local $/; | |||
|
495 | binmode O; | |||
|
496 | print O $ifilecontents; | |||
|
497 | close O; | |||
|
498 | utime time, (stat($ifile))[9], $file; | |||
|
499 | return 1; | |||
|
500 | } elsif ( $copy < 0 ) { | |||
|
501 | my $ifile_dir = dirname($ifile); | |||
|
502 | make_path($ifile_dir, $lib, $verbose_level); | |||
|
503 | open(O, "> " . $ifile) || die "Could not open $ifile for writing (no write permission?)"; | |||
|
504 | local $/; | |||
|
505 | binmode O; | |||
|
506 | print O $filecontents; | |||
|
507 | close O; | |||
|
508 | utime time, (stat($file))[9], $ifile; | |||
|
509 | return 1; | |||
|
510 | } | |||
|
511 | } | |||
|
512 | return 0; | |||
|
513 | } | |||
|
514 | ||||
|
515 | ###################################################################### | |||
|
516 | # Syntax: findFiles(dir, match, descend) | |||
|
517 | # Params: dir, string, directory to search for name | |||
|
518 | # match, string, regular expression to match in dir | |||
|
519 | # descend, integer, 0 = non-recursive search | |||
|
520 | # 1 = recurse search into subdirectories | |||
|
521 | # | |||
|
522 | # Purpose: Finds files matching a regular expression. | |||
|
523 | # Returns: List of matching files. | |||
|
524 | # | |||
|
525 | # Examples: | |||
|
526 | # findFiles("/usr","\.cpp$",1) - finds .cpp files in /usr and below | |||
|
527 | # findFiles("/tmp","^#",0) - finds #* files in /tmp | |||
|
528 | ###################################################################### | |||
|
529 | sub findFiles { | |||
|
530 | my ($dir,$match,$descend) = @_; | |||
|
531 | my ($file,$p,@files); | |||
|
532 | local(*D); | |||
|
533 | normalizePath(\$dir); | |||
|
534 | ($dir eq "") && ($dir = "."); | |||
|
535 | if ( opendir(D,$dir) ) { | |||
|
536 | if ( $dir eq "." ) { | |||
|
537 | $dir = ""; | |||
|
538 | } else { | |||
|
539 | ($dir =~ /\/$/) || ($dir .= "/"); | |||
|
540 | } | |||
|
541 | foreach $file ( sort readdir(D) ) { | |||
|
542 | next if ( $file =~ /^\.\.?$/ ); | |||
|
543 | $p = $file; | |||
|
544 | ($file =~ /$match/) && (push @files, $p); | |||
|
545 | if ( $descend && -d $p && ! -l $p ) { | |||
|
546 | push @files, &findFiles($p,$match,$descend); | |||
|
547 | } | |||
|
548 | } | |||
|
549 | closedir(D); | |||
|
550 | } | |||
|
551 | return @files; | |||
|
552 | } | |||
|
553 | ||||
|
554 | sub listSubdirs { | |||
|
555 | my @subdirs = @_; | |||
|
556 | foreach my $subdir (@subdirs) { | |||
|
557 | opendir DIR, $subdir or die "Huh, directory ".$subdir." cannot be opened."; | |||
|
558 | foreach my $t (sort readdir(DIR)) { | |||
|
559 | push @subdirs, "$subdir/$t" if(-d "$subdir/$t" && !($t eq ".") && | |||
|
560 | !($t eq "..") && !($t eq ".obj") && | |||
|
561 | !($t eq ".moc") && !($t eq ".rcc") && | |||
|
562 | !($t eq ".uic") && !($t eq "build") && | |||
|
563 | !($t eq "doc")); | |||
|
564 | } | |||
|
565 | closedir DIR; | |||
|
566 | } | |||
|
567 | return @subdirs; | |||
|
568 | } | |||
|
569 | ||||
|
570 | ###################################################################### | |||
|
571 | # Syntax: loadSyncProfile() | |||
|
572 | # | |||
|
573 | # Purpose: Locates the sync.profile. | |||
|
574 | # Returns: Hashmap of module name -> directory. | |||
|
575 | ###################################################################### | |||
|
576 | sub loadSyncProfile { | |||
|
577 | my ($srcbase, $outbase) = @_; | |||
|
578 | if ($verbose_level) { | |||
|
579 | print("<srcbase> = $$srcbase \n"); | |||
|
580 | print("<outbase> = $$outbase \n"); | |||
|
581 | } | |||
|
582 | ||||
|
583 | my $syncprofile = "$$srcbase/sync.profile"; | |||
|
584 | my $result; | |||
|
585 | unless ($result = do "$syncprofile") { | |||
|
586 | die "syncqt couldn't parse $syncprofile: $@" if $@; | |||
|
587 | die "syncqt couldn't execute $syncprofile: $!" unless defined $result; | |||
|
588 | } | |||
|
589 | ||||
|
590 | for my $fn (keys %classnames) { | |||
|
591 | for my $cn (split(/,/, $classnames{$fn})) { | |||
|
592 | $reverse_classnames{$cn} = $fn; | |||
|
593 | } | |||
|
594 | } | |||
|
595 | ||||
|
596 | return $result; | |||
|
597 | } | |||
|
598 | ||||
|
599 | sub basePrettify { | |||
|
600 | my ($arg) = @_; | |||
|
601 | $$arg =~ s,^\Q$basedir\E,<srcbase>,; | |||
|
602 | $$arg =~ s,^\Q$out_basedir\E,<outbase>,; | |||
|
603 | } | |||
|
604 | ||||
|
605 | sub cleanPath { | |||
|
606 | my ($arg) = @_; | |||
|
607 | while ($arg =~ s,[^/]+/\.\.(/|$),,) {} | |||
|
608 | return $arg; | |||
|
609 | } | |||
|
610 | ||||
|
611 | sub locateSyncProfile | |||
|
612 | { | |||
|
613 | my ($directory) = @_; | |||
|
614 | $directory = abs_path($directory); | |||
|
615 | while (1) { | |||
|
616 | my $file = $directory."/sync.profile"; | |||
|
617 | return $file if (-e $file); | |||
|
618 | my $odir = $directory; | |||
|
619 | $directory = dirname($directory); | |||
|
620 | return undef if ($directory eq $odir); | |||
|
621 | } | |||
|
622 | } | |||
|
623 | ||||
|
624 | sub isQpaHeader | |||
|
625 | { | |||
|
626 | my ($header) = @_; | |||
|
627 | foreach my $qpa_header (@qpa_headers) { | |||
|
628 | return 1 if ($header =~ $qpa_header); | |||
|
629 | } | |||
|
630 | return 0; | |||
|
631 | } | |||
|
632 | ||||
|
633 | # check if this is an in-source build, and if so use that as the basedir too | |||
|
634 | $basedir = locateSyncProfile($out_basedir); | |||
|
635 | if ($basedir) { | |||
|
636 | $basedir = dirname($basedir) ; | |||
|
637 | normalizePath(\$basedir); | |||
|
638 | $quoted_basedir = "\Q$basedir"; | |||
|
639 | } | |||
|
640 | ||||
|
641 | # -------------------------------------------------------------------- | |||
|
642 | # "main" function | |||
|
643 | # -------------------------------------------------------------------- | |||
|
644 | ||||
|
645 | while ( @ARGV ) { | |||
|
646 | my $var = 0; | |||
|
647 | my $val = 0; | |||
|
648 | ||||
|
649 | #parse | |||
|
650 | my $arg = shift @ARGV; | |||
|
651 | if ($arg eq "-h" || $arg eq "-help" || $arg eq "-?" || $arg eq "?") { | |||
|
652 | $var = "show_help"; | |||
|
653 | $val = "yes"; | |||
|
654 | } elsif($arg eq "-copy") { | |||
|
655 | $var = "copy"; | |||
|
656 | $val = "yes"; | |||
|
657 | } elsif($arg eq "-o" || $arg eq "-outdir") { | |||
|
658 | $var = "output"; | |||
|
659 | $val = shift @ARGV; | |||
|
660 | } elsif($arg eq "-showonly" || $arg eq "-remove-stale" || $arg eq "-windows" || | |||
|
661 | $arg eq "-relative" || $arg eq "-check-includes") { | |||
|
662 | $var = substr($arg, 1); | |||
|
663 | $val = "yes"; | |||
|
664 | } elsif($arg =~ /^-no-(.*)$/) { | |||
|
665 | $var = $1; | |||
|
666 | $val = "no"; | |||
|
667 | #these are for commandline compat | |||
|
668 | } elsif($arg eq "-inc") { | |||
|
669 | $var = "output"; | |||
|
670 | $val = shift @ARGV; | |||
|
671 | } elsif($arg eq "-module") { | |||
|
672 | $var = "module"; | |||
|
673 | $val = shift @ARGV; | |||
|
674 | } elsif($arg eq "-separate-module") { | |||
|
675 | $var = "separate-module"; | |||
|
676 | $val = shift @ARGV; | |||
|
677 | } elsif($arg eq "-show") { | |||
|
678 | $var = "showonly"; | |||
|
679 | $val = "yes"; | |||
|
680 | } elsif($arg eq "-quiet") { | |||
|
681 | $var = "verbose"; | |||
|
682 | $val = "0"; | |||
|
683 | } elsif($arg eq "-v") { | |||
|
684 | $var = "verbose"; | |||
|
685 | $val = "yes"; | |||
|
686 | } elsif($arg eq "-verbose") { | |||
|
687 | $var = "verbose"; | |||
|
688 | $val = shift @ARGV; | |||
|
689 | } elsif($arg eq "-minimal") { | |||
|
690 | $var = "minimal"; | |||
|
691 | $val = "yes"; | |||
|
692 | } elsif($arg eq "-private") { | |||
|
693 | $var = "create_private_headers"; | |||
|
694 | $val = "yes"; | |||
|
695 | } elsif($arg eq "-version") { | |||
|
696 | $var = "version"; | |||
|
697 | $val = shift @ARGV; | |||
|
698 | } elsif($arg =~/^-/) { | |||
|
699 | print "Unknown option: $arg\n\n" if(!$var); | |||
|
700 | showUsage(); | |||
|
701 | } else { | |||
|
702 | $basedir = locateSyncProfile($arg); | |||
|
703 | die "Could not find a sync.profile for '$arg'\n" if (!$basedir); | |||
|
704 | $basedir = dirname($basedir); | |||
|
705 | normalizePath(\$basedir); | |||
|
706 | $quoted_basedir = "\Q$basedir"; | |||
|
707 | $var = "ignore"; | |||
|
708 | } | |||
|
709 | ||||
|
710 | #do something | |||
|
711 | if(!$var || $var eq "show_help") { | |||
|
712 | print "Unknown option: $arg\n\n" if(!$var); | |||
|
713 | showUsage(); | |||
|
714 | } elsif ($var eq "copy") { | |||
|
715 | if($val eq "yes") { | |||
|
716 | $copy_headers++; | |||
|
717 | } elsif($showonly) { | |||
|
718 | $copy_headers--; | |||
|
719 | } | |||
|
720 | } elsif ($var eq "showonly") { | |||
|
721 | if($val eq "yes") { | |||
|
722 | $showonly++; | |||
|
723 | } elsif($showonly) { | |||
|
724 | $showonly--; | |||
|
725 | } | |||
|
726 | } elsif ($var eq "verbose") { | |||
|
727 | if($val eq "yes") { | |||
|
728 | $verbose_level++; | |||
|
729 | } elsif($val eq "no" && $verbose_level) { | |||
|
730 | $verbose_level--; | |||
|
731 | } else { | |||
|
732 | $verbose_level = int($val); | |||
|
733 | } | |||
|
734 | } elsif ($var eq "check-includes") { | |||
|
735 | if($val eq "yes") { | |||
|
736 | $check_includes++; | |||
|
737 | } elsif($check_includes) { | |||
|
738 | $check_includes--; | |||
|
739 | } | |||
|
740 | } elsif ($var eq "remove-stale") { | |||
|
741 | if($val eq "yes") { | |||
|
742 | $remove_stale++; | |||
|
743 | } elsif($remove_stale) { | |||
|
744 | $remove_stale--; | |||
|
745 | } | |||
|
746 | } elsif ($var eq "windows") { | |||
|
747 | if($val eq "yes") { | |||
|
748 | $force_win++; | |||
|
749 | } elsif($force_win) { | |||
|
750 | $force_win--; | |||
|
751 | } | |||
|
752 | } elsif ($var eq "relative") { | |||
|
753 | if($val eq "yes") { | |||
|
754 | $force_relative++; | |||
|
755 | } elsif($force_relative) { | |||
|
756 | $force_relative--; | |||
|
757 | } | |||
|
758 | } elsif ($var eq "minimal") { | |||
|
759 | if($val eq "yes") { | |||
|
760 | $minimal++; | |||
|
761 | } elsif($minimal) { | |||
|
762 | $minimal--; | |||
|
763 | } | |||
|
764 | } elsif ($var eq "module") { | |||
|
765 | push @modules_to_sync, $val; | |||
|
766 | } elsif ($var eq "separate-module") { | |||
|
767 | my ($module, $prodir, $headerdir) = split(/:/, $val); | |||
|
768 | $modules{$module} = $prodir; | |||
|
769 | push @modules_to_sync, $module; | |||
|
770 | $moduleheaders{$module} = $headerdir; | |||
|
771 | } elsif ($var eq "version") { | |||
|
772 | if($val) { | |||
|
773 | $module_version = $val; | |||
|
774 | } else { | |||
|
775 | die "The -version option requires an argument"; | |||
|
776 | } | |||
|
777 | } elsif ($var eq "output") { | |||
|
778 | my $outdir = $val; | |||
|
779 | if(checkRelative($outdir)) { | |||
|
780 | $out_basedir = getcwd(); | |||
|
781 | chomp $out_basedir; | |||
|
782 | $out_basedir .= "/" . $outdir; | |||
|
783 | } else { | |||
|
784 | $out_basedir = $outdir; | |||
|
785 | } | |||
|
786 | normalizePath(\$out_basedir); | |||
|
787 | } | |||
|
788 | } | |||
|
789 | ||||
|
790 | # if we have no $basedir we cannot be sure which sources you want, so die | |||
|
791 | die "Could not find any sync.profile for your module!\nPass <module directory> to syncqt to sync your header files.\nsyncqt failed" if (!$basedir); | |||
|
792 | ||||
|
793 | our @ignore_headers = (); | |||
|
794 | our @ignore_for_master_contents = (); | |||
|
795 | our @ignore_for_include_check = (); | |||
|
796 | our @ignore_for_qt_begin_namespace_check = (); | |||
|
797 | our @ignore_for_qt_module_check = (); | |||
|
798 | our %inject_headers = (); | |||
|
799 | ||||
|
800 | # load the module's sync.profile here, before we can | |||
|
801 | loadSyncProfile(\$basedir, \$out_basedir); | |||
|
802 | ||||
|
803 | @modules_to_sync = keys(%modules) if($#modules_to_sync == -1); | |||
|
804 | ||||
|
805 | my %allmoduleheadersprivate = map { $_ => 1 } @allmoduleheadersprivate; | |||
|
806 | ||||
|
807 | $isunix = checkUnix; #cache checkUnix | |||
|
808 | ||||
|
809 | if (!$module_version) { | |||
|
810 | my $filco = fileContents($basedir."/src/corelib/global/qglobal.h"); | |||
|
811 | if ($filco !~ m,.*^#[ \t]*define[ \t]+QT_VERSION_STR[ \t]+"([^"]+)".*,sm) { | |||
|
812 | die "Cannot determine Qt/Module version. Use -version.\n"; | |||
|
813 | } | |||
|
814 | $module_version = $1; | |||
|
815 | } | |||
|
816 | foreach my $lib (@modules_to_sync) { | |||
|
817 | die "No such module: $lib" unless(defined $modules{$lib}); | |||
|
818 | ||||
|
819 | #iteration info | |||
|
820 | my $module = $modules{$lib}; | |||
|
821 | my $is_qt = !($module =~ s/^!//); | |||
|
822 | my @dirs = split(/;/, $module); | |||
|
823 | my $dir = $dirs[0]; | |||
|
824 | ||||
|
825 | my $pathtoheaders = ""; | |||
|
826 | $pathtoheaders = $moduleheaders{$lib} if ($moduleheaders{$lib}); | |||
|
827 | ||||
|
828 | my $allheadersprivate = 0; | |||
|
829 | $allheadersprivate = 1 if $allmoduleheadersprivate{$lib}; | |||
|
830 | ||||
|
831 | #information used after the syncing | |||
|
832 | my $pri_install_classes = ""; | |||
|
833 | my $pri_install_files = ""; | |||
|
834 | my $pri_install_pfiles = ""; | |||
|
835 | my $pri_install_qpafiles = ""; | |||
|
836 | my $pri_injections = ""; | |||
|
837 | ||||
|
838 | my $libcapitals = uc($lib); | |||
|
839 | my $master_contents = | |||
|
840 | "#ifndef QT_".$libcapitals."_MODULE_H\n" . | |||
|
841 | "#define QT_".$libcapitals."_MODULE_H\n" . | |||
|
842 | "#include <$lib/${lib}Depends>\n"; | |||
|
843 | ||||
|
844 | #remove the old files | |||
|
845 | if($remove_stale) { | |||
|
846 | my %injections = (); | |||
|
847 | for my $p (keys %inject_headers) { | |||
|
848 | next unless ($p =~ /^\Q$dir\E(\/|$)/); | |||
|
849 | my $sp = $p; | |||
|
850 | $sp =~ s,^\Q$basedir\E/,$out_basedir/,; | |||
|
851 | for my $n (@{$inject_headers{$p}}) { | |||
|
852 | $injections{$sp."/".$n} = 1; | |||
|
853 | } | |||
|
854 | } | |||
|
855 | my @subdirs = ("$out_basedir/include/$lib"); | |||
|
856 | foreach my $subdir (@subdirs) { | |||
|
857 | if (opendir DIR, $subdir) { | |||
|
858 | foreach my $t (sort { $b cmp $a } readdir(DIR)) { | |||
|
859 | my $file = "$subdir/$t"; | |||
|
860 | if(-d $file) { | |||
|
861 | push @subdirs, $file unless($t eq "." || $t eq ".."); | |||
|
862 | } else { | |||
|
863 | my @files = ($file); | |||
|
864 | #push @files, "$out_basedir/include/Qt/$t" if(-e "$out_basedir/include/Qt/$t"); | |||
|
865 | foreach my $file (@files) { | |||
|
866 | my $remove_file = 0; | |||
|
867 | if(open(F, "<$file")) { | |||
|
868 | while(my $line = <F>) { | |||
|
869 | chomp $line; | |||
|
870 | if($line =~ /^\#include \"([^\"]*)\"$/) { | |||
|
871 | my $include = $1; | |||
|
872 | $include = $subdir . "/" . $include unless(substr($include, 0, 1) eq "/"); | |||
|
873 | $remove_file = 1 unless(-e $include or defined $injections{cleanPath($include)}); | |||
|
874 | } else { | |||
|
875 | $remove_file = 0; | |||
|
876 | last; | |||
|
877 | } | |||
|
878 | } | |||
|
879 | close(F); | |||
|
880 | unlink $file if($remove_file); | |||
|
881 | } | |||
|
882 | } | |||
|
883 | } | |||
|
884 | } | |||
|
885 | closedir DIR; | |||
|
886 | } | |||
|
887 | ||||
|
888 | } | |||
|
889 | } | |||
|
890 | ||||
|
891 | #create the new ones | |||
|
892 | foreach my $current_dir (@dirs) { | |||
|
893 | my $thisprivate = 0; | |||
|
894 | ($current_dir =~ s/^\^//) and $thisprivate = 1; | |||
|
895 | my @headers_paths = split(/;/, $pathtoheaders); | |||
|
896 | if (@headers_paths) { | |||
|
897 | @headers_paths = map { "$current_dir/$_" } @headers_paths; | |||
|
898 | } else { | |||
|
899 | push @headers_paths, $current_dir; | |||
|
900 | } | |||
|
901 | ||||
|
902 | foreach my $headers_dir (@headers_paths) { | |||
|
903 | #calc subdirs | |||
|
904 | my @subdirs = listSubdirs($headers_dir); | |||
|
905 | ||||
|
906 | #calc files and "copy" them | |||
|
907 | foreach my $subdir (@subdirs) { | |||
|
908 | my @headers = findFiles($subdir, "^[-a-z0-9_]*\\.h\$" , 0); | |||
|
909 | if (defined $inject_headers{$subdir}) { | |||
|
910 | foreach my $if (@{$inject_headers{$subdir}}) { | |||
|
911 | @headers = grep(!/^\Q$if\E$/, @headers); #in case we configure'd previously | |||
|
912 | push @headers, "*".$if; | |||
|
913 | } | |||
|
914 | } | |||
|
915 | my $header_dirname = ""; | |||
|
916 | foreach my $header (@headers) { | |||
|
917 | my $shadow = ($header =~ s/^\*//); | |||
|
918 | $header = 0 if($header =~ /^ui_.*.h/); | |||
|
919 | foreach (@ignore_headers) { | |||
|
920 | $header = 0 if($header eq $_); | |||
|
921 | } | |||
|
922 | if($header) { | |||
|
923 | my $header_copies = 0; | |||
|
924 | #figure out if it is a public header | |||
|
925 | my $public_header = $header; | |||
|
926 | my $qpa_header = 0; | |||
|
927 | if(isQpaHeader($public_header)) { | |||
|
928 | $public_header = 0; | |||
|
929 | $qpa_header = 1; | |||
|
930 | } elsif($allheadersprivate || $thisprivate || $public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) { | |||
|
931 | $public_header = 0; | |||
|
932 | } else { | |||
|
933 | foreach (@ignore_for_master_contents) { | |||
|
934 | $public_header = 0 if($header eq $_); | |||
|
935 | } | |||
|
936 | } | |||
|
937 | ||||
|
938 | my $iheader = $subdir . "/" . $header; | |||
|
939 | $iheader =~ s/^\Q$basedir\E/$out_basedir/ if ($shadow); | |||
|
940 | my @classes = $public_header && (!$minimal && $is_qt) ? classNames($iheader) : (); | |||
|
941 | if($showonly) { | |||
|
942 | print "$header [$lib]\n"; | |||
|
943 | foreach(@classes) { | |||
|
944 | print "SYMBOL: $_\n"; | |||
|
945 | } | |||
|
946 | } else { | |||
|
947 | my $ts = $shadow ? 0 : (stat($iheader))[9]; | |||
|
948 | #find out all the places it goes.. | |||
|
949 | my $oheader; | |||
|
950 | if ($public_header) { | |||
|
951 | $oheader = "$out_basedir/include/$lib/$header"; | |||
|
952 | foreach my $full_class (@classes) { | |||
|
953 | my $header_base = basename($header); | |||
|
954 | # Strip namespaces: | |||
|
955 | my $class = $full_class; | |||
|
956 | $class =~ s/^.*:://; | |||
|
957 | # if ($class =~ m/::/) { | |||
|
958 | # class =~ s,::,/,g; | |||
|
959 | # } | |||
|
960 | ||||
|
961 | $header_copies++ if (!$shadow && syncHeader($lib, "$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0, $ts)); | |||
|
962 | } | |||
|
963 | } elsif ($create_private_headers && !$qpa_header) { | |||
|
964 | $oheader = "$out_basedir/include/$lib/$module_version/$lib/private/$header"; | |||
|
965 | } elsif ($create_private_headers) { | |||
|
966 | $oheader = "$out_basedir/include/$lib/$module_version/$lib/qpa/$header"; | |||
|
967 | } | |||
|
968 | $header_copies++ if (!$shadow && syncHeader($lib, $oheader, $iheader, $copy_headers, $ts)); | |||
|
969 | ||||
|
970 | my $pri_install_iheader = fixPaths($iheader, $dir); | |||
|
971 | my $injection = ""; | |||
|
972 | if($public_header) { | |||
|
973 | #put it into the master file | |||
|
974 | $master_contents .= "#include \"$public_header\"\n" if (!$shadow && shouldMasterInclude($iheader)); | |||
|
975 | ||||
|
976 | #deal with the install directives | |||
|
977 | foreach my $class (@classes) { | |||
|
978 | # Strip namespaces: | |||
|
979 | $class =~ s/^.*:://; | |||
|
980 | # if ($class =~ m/::/) { | |||
|
981 | # $class =~ s,::,/,g; | |||
|
982 | # } | |||
|
983 | my $class_header = fixPaths("$out_basedir/include/$lib/$class", $dir) . " "; | |||
|
984 | $pri_install_classes .= $class_header | |||
|
985 | unless($pri_install_classes =~ $class_header); | |||
|
986 | $injection .= ":$class"; | |||
|
987 | } | |||
|
988 | $pri_install_files.= "$pri_install_iheader ";; | |||
|
989 | } | |||
|
990 | elsif ($qpa_header) { | |||
|
991 | $pri_install_qpafiles.= "$pri_install_iheader ";; | |||
|
992 | } | |||
|
993 | else { | |||
|
994 | $pri_install_pfiles.= "$pri_install_iheader ";; | |||
|
995 | } | |||
|
996 | $pri_injections .= fixPaths($iheader, "$out_basedir/include/$lib") | |||
|
997 | .":".fixPaths($oheader, "$out_basedir/include/$lib") | |||
|
998 | .$injection." " if ($shadow); | |||
|
999 | } | |||
|
1000 | ||||
|
1001 | if ($verbose_level && $header_copies) { | |||
|
1002 | my $new_header_dirname = dirname($iheader); | |||
|
1003 | basePrettify(\$new_header_dirname) if ($new_header_dirname && $verbose_level < 2); | |||
|
1004 | my $header_base = basename($iheader); | |||
|
1005 | if ($verbose_level < 3) { | |||
|
1006 | my $line_prefix = ","; | |||
|
1007 | if ($new_header_dirname ne $header_dirname) { | |||
|
1008 | $line_prefix = "$lib: created fwd-include header(s) for $new_header_dirname/ {"; | |||
|
1009 | $line_prefix = " }\n".$line_prefix if ($header_dirname); | |||
|
1010 | $header_dirname = $new_header_dirname; | |||
|
1011 | } else { | |||
|
1012 | $line_prefix = ","; | |||
|
1013 | } | |||
|
1014 | print "$line_prefix $header_base ($header_copies)"; | |||
|
1015 | } else { # $verbose_level >= 3 | |||
|
1016 | basePrettify(\$iheader) if ($verbose_level == 3); | |||
|
1017 | print "$lib: created $header_copies fwd-include headers for $iheader\n"; | |||
|
1018 | } | |||
|
1019 | } | |||
|
1020 | } | |||
|
1021 | } | |||
|
1022 | print " }\n" if ($header_dirname && $verbose_level > 0 && $verbose_level < 3); | |||
|
1023 | } | |||
|
1024 | } | |||
|
1025 | } | |||
|
1026 | ||||
|
1027 | # close the master include: | |||
|
1028 | $master_contents .= | |||
|
1029 | "#include \"".lc($lib)."version.h\"\n" . | |||
|
1030 | "#endif\n"; | |||
|
1031 | ||||
|
1032 | unless ($showonly || $minimal || !$is_qt) { | |||
|
1033 | # create deprecated headers | |||
|
1034 | my $first = 1; | |||
|
1035 | while (my ($header, $include) = each %{$deprecatedheaders{$lib}}) { | |||
|
1036 | my $public_header = 0; | |||
|
1037 | $public_header = 1 unless ($allheadersprivate || ($header =~ /_p\.h$/)); | |||
|
1038 | next unless ($public_header || $create_private_headers); | |||
|
1039 | ||||
|
1040 | my $header_path = "$out_basedir/include/$lib/"; | |||
|
1041 | unless ($public_header) { | |||
|
1042 | $header_path .= "$module_version/$lib/private/"; | |||
|
1043 | } | |||
|
1044 | $header_path .= "$header"; | |||
|
1045 | ||||
|
1046 | unless (-e $header_path) { | |||
|
1047 | my $guard = "DEPRECATED_HEADER_" . $lib . "_" . $header; | |||
|
1048 | $guard =~ s/([^a-zA-Z0-9_])/_/g; | |||
|
1049 | ||||
|
1050 | my $header_dir = dirname($header_path); | |||
|
1051 | make_path($header_dir, $lib, $verbose_level); | |||
|
1052 | ||||
|
1053 | my $hdrcont = | |||
|
1054 | "#ifndef $guard\n" . | |||
|
1055 | "#define $guard\n"; | |||
|
1056 | my $warning = "Header <$lib/"; | |||
|
1057 | $warning .= "private/" unless ($public_header); | |||
|
1058 | $warning .= "$header> is deprecated. Please include <$include> instead."; | |||
|
1059 | $hdrcont .= | |||
|
1060 | "#if defined(__GNUC__)\n" . | |||
|
1061 | "# warning $warning\n" . | |||
|
1062 | "#elif defined(_MSC_VER)\n" . | |||
|
1063 | "# pragma message (\"$warning\")\n" . | |||
|
1064 | "#endif\n" . | |||
|
1065 | "#include <$include>\n"; | |||
|
1066 | if ($public_header) { | |||
|
1067 | $hdrcont .= | |||
|
1068 | "#if 0\n" . | |||
|
1069 | "#pragma qt_no_master_include\n" . | |||
|
1070 | "#endif\n"; | |||
|
1071 | } | |||
|
1072 | $hdrcont .= | |||
|
1073 | "#endif\n"; | |||
|
1074 | if (writeFile($header_path, $hdrcont)) { | |||
|
1075 | if ($verbose_level < 3) { | |||
|
1076 | my $line_prefix = ","; | |||
|
1077 | $line_prefix = "$lib: created deprecated header(s) {" if ($first); | |||
|
1078 | print "$line_prefix $header"; | |||
|
1079 | } else { | |||
|
1080 | print "$lib: created deprecated header $header => $include\n"; | |||
|
1081 | } | |||
|
1082 | $first = 0; | |||
|
1083 | } | |||
|
1084 | } | |||
|
1085 | ||||
|
1086 | my $addendum = fixPaths($header_path, $dir) . " "; | |||
|
1087 | if ($public_header) { | |||
|
1088 | $pri_install_files .= $addendum; | |||
|
1089 | } else { | |||
|
1090 | $pri_install_pfiles .= $addendum; | |||
|
1091 | } | |||
|
1092 | } | |||
|
1093 | if ($verbose_level < 3) { | |||
|
1094 | print " }\n" unless ($first); | |||
|
1095 | } | |||
|
1096 | ||||
|
1097 | # module version header | |||
|
1098 | my $vheader = "$out_basedir/include/$lib/".lc($lib)."version.h"; | |||
|
1099 | my $VHeader = "$out_basedir/include/$lib/${lib}Version"; | |||
|
1100 | syncHeader($lib, $VHeader, $vheader, 0); | |||
|
1101 | $pri_install_files .= fixPaths($vheader, $dir) . " "; | |||
|
1102 | $pri_install_classes .= fixPaths($VHeader, $dir) . " "; | |||
|
1103 | my @versions = split(/\./, $module_version); | |||
|
1104 | my $modulehexstring = sprintf("0x%02X%02X%02X", $versions[0], $versions[1], $versions[2]); | |||
|
1105 | my $vhdrcont = | |||
|
1106 | "/* This file was generated by syncqt. */\n". | |||
|
1107 | "#ifndef QT_".uc($lib)."_VERSION_H\n". | |||
|
1108 | "#define QT_".uc($lib)."_VERSION_H\n". | |||
|
1109 | "\n". | |||
|
1110 | "#define ".uc($lib)."_VERSION_STR \"".$module_version."\"\n". | |||
|
1111 | "\n". | |||
|
1112 | "#define ".uc($lib)."_VERSION ".$modulehexstring."\n". | |||
|
1113 | "\n". | |||
|
1114 | "#endif // QT_".uc($lib)."_VERSION_H\n"; | |||
|
1115 | writeFile($vheader, $vhdrcont, $lib, "version header"); | |||
|
1116 | ||||
|
1117 | my $master_include = "$out_basedir/include/$lib/$lib"; | |||
|
1118 | $pri_install_files .= fixPaths($master_include, $dir) . " "; | |||
|
1119 | writeFile($master_include, $master_contents, $lib, "master header"); | |||
|
1120 | } | |||
|
1121 | ||||
|
1122 | unless ($showonly || $minimal) { | |||
|
1123 | #handle the headers.pri for each module | |||
|
1124 | my $headers_pri_contents = ""; | |||
|
1125 | $headers_pri_contents .= "SYNCQT.HEADER_FILES = $pri_install_files\n"; | |||
|
1126 | $headers_pri_contents .= "SYNCQT.HEADER_CLASSES = $pri_install_classes\n"; | |||
|
1127 | $headers_pri_contents .= "SYNCQT.PRIVATE_HEADER_FILES = $pri_install_pfiles\n"; | |||
|
1128 | $headers_pri_contents .= "SYNCQT.QPA_HEADER_FILES = $pri_install_qpafiles\n"; | |||
|
1129 | $headers_pri_contents .= "SYNCQT.INJECTIONS = $pri_injections\n"; | |||
|
1130 | my $headers_pri_file = "$out_basedir/include/$lib/headers.pri"; | |||
|
1131 | writeFile($headers_pri_file, $headers_pri_contents, $lib, "headers.pri file"); | |||
|
1132 | } | |||
|
1133 | } | |||
|
1134 | ||||
|
1135 | if($check_includes) { | |||
|
1136 | foreach my $lib (@modules_to_sync) { | |||
|
1137 | next if ($modules{$lib} =~ /^!/); | |||
|
1138 | #calc subdirs | |||
|
1139 | my @subdirs = listSubdirs(map { s/^\^//; $_ } split(/;/, $modules{$lib})); | |||
|
1140 | ||||
|
1141 | foreach my $subdir (@subdirs) { | |||
|
1142 | my @headers = findFiles($subdir, "^[-a-z0-9_]*\\.h\$" , 0); | |||
|
1143 | foreach my $header (@headers) { | |||
|
1144 | my $header_skip_qt_begin_namespace_test = 0; | |||
|
1145 | $header = 0 if($header =~ /^ui_.*.h/); | |||
|
1146 | $header = 0 if ($header eq lc($lib)."version.h"); | |||
|
1147 | foreach (@ignore_headers) { | |||
|
1148 | $header = 0 if($header eq $_); | |||
|
1149 | } | |||
|
1150 | if($header) { | |||
|
1151 | my $public_header = $header; | |||
|
1152 | if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) { | |||
|
1153 | $public_header = 0; | |||
|
1154 | } elsif (isQpaHeader($public_header)) { | |||
|
1155 | $public_header = 0; | |||
|
1156 | } else { | |||
|
1157 | foreach (@ignore_for_master_contents) { | |||
|
1158 | $public_header = 0 if($header eq $_); | |||
|
1159 | } | |||
|
1160 | if($public_header) { | |||
|
1161 | foreach (@ignore_for_include_check) { | |||
|
1162 | $public_header = 0 if($header eq $_); | |||
|
1163 | } | |||
|
1164 | foreach(@ignore_for_qt_begin_namespace_check) { | |||
|
1165 | $header_skip_qt_begin_namespace_test = 1 if ($header eq $_); | |||
|
1166 | } | |||
|
1167 | } | |||
|
1168 | } | |||
|
1169 | ||||
|
1170 | my $iheader = $subdir . "/" . $header; | |||
|
1171 | if($public_header) { | |||
|
1172 | if(open(F, "<$iheader")) { | |||
|
1173 | my $qt_begin_namespace_found = 0; | |||
|
1174 | my $qt_end_namespace_found = 0; | |||
|
1175 | my $qt_namespace_suffix = ""; | |||
|
1176 | my $line; | |||
|
1177 | my $stop_processing = 0; | |||
|
1178 | while($line = <F>) { | |||
|
1179 | chomp $line; | |||
|
1180 | my $output_line = 1; | |||
|
1181 | if($line =~ /^ *\# *pragma (qt_no_included_check|qt_sync_stop_processing)/) { | |||
|
1182 | $stop_processing = 1; | |||
|
1183 | last; | |||
|
1184 | } elsif($line =~ /^ *\# *include/) { | |||
|
1185 | my $include = $line; | |||
|
1186 | if($line =~ /<.*>/) { | |||
|
1187 | $include =~ s,.*<(.*)>.*,$1,; | |||
|
1188 | } elsif($line =~ /".*"/) { | |||
|
1189 | $include =~ s,.*"(.*)".*,$1,; | |||
|
1190 | } else { | |||
|
1191 | $include = 0; | |||
|
1192 | } | |||
|
1193 | if($include) { | |||
|
1194 | for my $trylib (keys(%modules)) { | |||
|
1195 | if(-e "$out_basedir/include/$trylib/$include") { | |||
|
1196 | print "$lib: WARNING: $iheader includes $include when it should include $trylib/$include\n"; | |||
|
1197 | } | |||
|
1198 | } | |||
|
1199 | } | |||
|
1200 | } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_BEGIN_NAMESPACE(_[A-Z_]+)?\s*$/) { | |||
|
1201 | $qt_namespace_suffix = defined($1) ? $1 : ""; | |||
|
1202 | $qt_begin_namespace_found = 1; | |||
|
1203 | } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_END_NAMESPACE$qt_namespace_suffix\s*$/) { | |||
|
1204 | $qt_end_namespace_found = 1; | |||
|
1205 | } | |||
|
1206 | } | |||
|
1207 | ||||
|
1208 | if ($header_skip_qt_begin_namespace_test == 0 and $stop_processing == 0) { | |||
|
1209 | if ($qt_begin_namespace_found == 0) { | |||
|
1210 | print "$lib: WARNING: $iheader does not include QT_BEGIN_NAMESPACE\n"; | |||
|
1211 | } | |||
|
1212 | ||||
|
1213 | if ($qt_begin_namespace_found && $qt_end_namespace_found == 0) { | |||
|
1214 | print "$lib: WARNING: $iheader has QT_BEGIN_NAMESPACE$qt_namespace_suffix but no QT_END_NAMESPACE$qt_namespace_suffix\n"; | |||
|
1215 | } | |||
|
1216 | } | |||
|
1217 | ||||
|
1218 | close(F); | |||
|
1219 | } | |||
|
1220 | } | |||
|
1221 | } | |||
|
1222 | } | |||
|
1223 | } | |||
|
1224 | } | |||
|
1225 | } | |||
|
1226 | ||||
|
1227 | exit 0; |
@@ -0,0 +1,22 | |||||
|
1 | TEMPLATE = lib | |||
|
2 | ||||
|
3 | TARGET=bsp | |||
|
4 | ||||
|
5 | CONFIG += bsp | |||
|
6 | CONFIG += gui power | |||
|
7 | ||||
|
8 | BSP = SOSmartPSU | |||
|
9 | ||||
|
10 | UCMODEL=stm32f4 | |||
|
11 | ||||
|
12 | SOURCES += bsp.c | |||
|
13 | ||||
|
14 | HEADERS += bsp.h | |||
|
15 | ||||
|
16 | LIBS+= -lgpio -luart -li2c -lspi -lpwm | |||
|
17 | ||||
|
18 | ||||
|
19 | BSPFILE = bsp.pri | |||
|
20 | ||||
|
21 | ||||
|
22 |
This diff has been collapsed as it changes many lines, (516 lines changed) Show them Hide them | |||||
@@ -0,0 +1,516 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the libuc, microcontroler library | |||
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This 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. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | ------------------------------------------------------------------------------- | |||
|
19 | -- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |||
|
21 | -------------------------------------------------------------------------------*/ | |||
|
22 | #include "bsp.h" | |||
|
23 | #include <streamdevices.h> | |||
|
24 | #include <malloc.h> | |||
|
25 | #include <gpio.h> | |||
|
26 | #include <uart.h> | |||
|
27 | #include <stdio.h> | |||
|
28 | #include <stm32f4xx_gpio.h> | |||
|
29 | #include <stm32f4xx_fsmc.h> | |||
|
30 | #include <i2c.h> | |||
|
31 | #include <core.h> | |||
|
32 | #include <terminal.h> | |||
|
33 | #include <pwm.h> | |||
|
34 | #include <spi.h> | |||
|
35 | ||||
|
36 | uint32_t OSC0 =12000000; | |||
|
37 | uint32_t INTOSC =16000000; | |||
|
38 | uint32_t RTCOSC =32768; | |||
|
39 | uint32_t currentCpuFreq=0; | |||
|
40 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |||
|
41 | gpio_t TickLed = LED1; | |||
|
42 | ||||
|
43 | LCD_IF_t lcdIF0={ | |||
|
44 | .init = &bsp_FSMC_init, | |||
|
45 | .status = &bsp_lcd0_status, | |||
|
46 | .writereg = &bsp_lcd0_write_reg, | |||
|
47 | .readreg = &bsp_lcd0_read_reg, | |||
|
48 | .writeGRAM = &bsp_lcd0_writeGRAM, | |||
|
49 | .readGRAM = &bsp_lcd0_readGRAM | |||
|
50 | }; | |||
|
51 | ||||
|
52 | LCD_t lcd0={ | |||
|
53 | .interface = &lcdIF0, | |||
|
54 | .init = &D51E5TA7601init, | |||
|
55 | .paint = &D51E5TA7601paint, | |||
|
56 | .paintFB = D51E5TA7601paintFB, | |||
|
57 | .setFrame = &D51E5TA7601setFrame, | |||
|
58 | .paintText = &D51E5TA7601paintText, | |||
|
59 | .paintFilRect = &D51E5TA7601paintFilRect, | |||
|
60 | .getPix = &D51E5TA7601getPix, | |||
|
61 | .refreshenable = &D51E5TA7601refreshenable, | |||
|
62 | .width= 320, | |||
|
63 | .height = 480, | |||
|
64 | .isFrameBuffer = 0 | |||
|
65 | }; | |||
|
66 | ||||
|
67 | terminal_t terminal0; | |||
|
68 | ||||
|
69 | volatile int16_t* lcd0_CMD=(volatile int16_t*)0x60000000; | |||
|
70 | volatile int16_t* lcd0_DATA=(volatile int16_t*)0x61FFFFF0; | |||
|
71 | volatile int16_t* SRAM_DATA=(volatile int16_t*)0x64000000; | |||
|
72 | ||||
|
73 | // Frame buffers 300kB per buffer, RAM size=1M*16 -> 6.8 buffers max | |||
|
74 | volatile int16_t* FRAME_BUFFER0_data=(volatile int16_t*)0x64000000; | |||
|
75 | volatile int16_t* FRAME_BUFFER1_data=((volatile int16_t*)0x64000000)+(320*480); //300kB per buffer | |||
|
76 | LCD_t __attribute__ ((aligned (4))) FRAME_BUFFER0= | |||
|
77 | { | |||
|
78 | .interface.buffer=(int16_t*)0x64000000, | |||
|
79 | .init = &D51E5TA7601init_FrameBuff, | |||
|
80 | .paint = &D51E5TA7601paint_FrameBuff, | |||
|
81 | .setFrame = &D51E5TA7601setFrame_FrameBuff, | |||
|
82 | .paintText = &D51E5TA7601paintText_FrameBuff, | |||
|
83 | .paintFilRect = &D51E5TA7601paintFilRect_FrameBuff, | |||
|
84 | .getPix = &D51E5TA7601getPix_FrameBuff, | |||
|
85 | .refreshenable = &D51E5TA7601refreshenable_FrameBuff, | |||
|
86 | .width= 480, | |||
|
87 | .height = 320, | |||
|
88 | .isFrameBuffer = 1 | |||
|
89 | }; | |||
|
90 | ||||
|
91 | LCD_t __attribute__ ((aligned (4))) FRAME_BUFFER1= | |||
|
92 | { | |||
|
93 | .interface.buffer=(((int16_t*)0x64000000)+(320*480)), | |||
|
94 | .init = &D51E5TA7601init_FrameBuff, | |||
|
95 | .paint = &D51E5TA7601paint_FrameBuff, | |||
|
96 | .setFrame = &D51E5TA7601setFrame_FrameBuff, | |||
|
97 | .paintText = &D51E5TA7601paintText_FrameBuff, | |||
|
98 | .paintFilRect = &D51E5TA7601paintFilRect_FrameBuff, | |||
|
99 | .getPix = &D51E5TA7601getPix_FrameBuff, | |||
|
100 | .refreshenable = &D51E5TA7601refreshenable_FrameBuff, | |||
|
101 | .width= 480, | |||
|
102 | .height = 320, | |||
|
103 | .isFrameBuffer = 1 | |||
|
104 | }; | |||
|
105 | LCD_t* FRAME_BUFFER=&FRAME_BUFFER0; | |||
|
106 | ||||
|
107 | float VREF0 =(float)3.3; | |||
|
108 | ||||
|
109 | int bsp_init() | |||
|
110 | { | |||
|
111 | int i=0; | |||
|
112 | for(i=0;i<32;i++) | |||
|
113 | { | |||
|
114 | __opnfiles__[i] = NULL; | |||
|
115 | } | |||
|
116 | bsp_GPIO_init(); | |||
|
117 | // bsp_uart_init(); | |||
|
118 | bsp_iic_init(); | |||
|
119 | bsp_spi_init(); | |||
|
120 | bsp_TC_init(); | |||
|
121 | bsp_FSMC_init(); | |||
|
122 | bsp_GTerm_init(); | |||
|
123 | printf("\r=====================\n\r"); | |||
|
124 | printf( "=====================\n\r"); | |||
|
125 | printf(BSP); | |||
|
126 | printf(" initialised\n\r"); | |||
|
127 | printf( "=====================\n\r"); | |||
|
128 | return 1; | |||
|
129 | } | |||
|
130 | ||||
|
131 | void bsp_GPIO_init() | |||
|
132 | { | |||
|
133 | gpio_t gpio1 = gpioopen(LED1); | |||
|
134 | gpio_t gpio2 = gpioopen(LED2); | |||
|
135 | gpio_t gpio3 = gpioopen(LED3); | |||
|
136 | gpio_t gpio4 = gpioopen(PSU_DISABLE); | |||
|
137 | gpio_t gpio5 = gpioopen(PSU_ALERT_5V); | |||
|
138 | gpio_t gpio6 = gpioopen(PSU_ALERT_1_5V); | |||
|
139 | gpio_t gpio7 = gpioopen(PSU_ALERT_3_3V); | |||
|
140 | gpio_t gpio8 = gpioopen(BP1); | |||
|
141 | gpio_t gpio9 = gpioopen(BP2); | |||
|
142 | gpio_t gpio10 = gpioopen(BP3); | |||
|
143 | gpio_t gpio11 = gpioopen(BP4); | |||
|
144 | gpio_t gpio12 = gpioopen(TC_IRQ); | |||
|
145 | gpiosetspeed(&gpio1,gpiohighspeed); | |||
|
146 | gpiosetspeed(&gpio2,gpiohighspeed); | |||
|
147 | gpiosetspeed(&gpio3,gpiohighspeed); | |||
|
148 | gpiosetspeed(&gpio4,gpiohighspeed); | |||
|
149 | gpiosetspeed(&gpio5,gpiohighspeed); | |||
|
150 | gpiosetspeed(&gpio6,gpiohighspeed); | |||
|
151 | gpiosetspeed(&gpio7,gpiohighspeed); | |||
|
152 | gpiosetspeed(&gpio8,gpiohighspeed); | |||
|
153 | gpiosetspeed(&gpio9,gpiohighspeed); | |||
|
154 | gpiosetspeed(&gpio10,gpiohighspeed); | |||
|
155 | gpiosetspeed(&gpio11,gpiohighspeed); | |||
|
156 | gpiosetspeed(&gpio12,gpiohighspeed); | |||
|
157 | gpioclr(PSU_DISABLE); | |||
|
158 | gpiosetdir(&gpio1,gpiooutdir); | |||
|
159 | gpiosetdir(&gpio3,gpiooutdir); | |||
|
160 | gpiosetdir(&gpio2,gpiooutdir); | |||
|
161 | gpiosetdir(&gpio4,gpiooutdir); | |||
|
162 | gpiosetdir(&gpio5,gpioindir); | |||
|
163 | gpiosetdir(&gpio6,gpioindir); | |||
|
164 | gpiosetdir(&gpio7,gpioindir); | |||
|
165 | gpiosetdir(&gpio8,gpioindir); | |||
|
166 | gpiosetdir(&gpio9,gpioindir); | |||
|
167 | gpiosetdir(&gpio10,gpioindir); | |||
|
168 | gpiosetdir(&gpio11,gpioindir); | |||
|
169 | gpiosetdir(&gpio12,gpioindir); | |||
|
170 | gpiosetpulltype(&gpio4,gpiopushpulltype); | |||
|
171 | gpiosetpulltype(&gpio12,gpiopulluptype); | |||
|
172 | gpioclr(PSU_DISABLE); | |||
|
173 | pwmopen(PWM9_CH2,LCD_BACKLIGHT); | |||
|
174 | int error = pwmsetconfig(PWM9_CH2,100,80.0); | |||
|
175 | } | |||
|
176 | ||||
|
177 | void bsp_uart_init() | |||
|
178 | { | |||
|
179 | if(__opnfiles__[1]==NULL) | |||
|
180 | { | |||
|
181 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |||
|
182 | uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); | |||
|
183 | uartmkstreamdev(uart,fd1); | |||
|
184 | __opnfiles__[1] = fd1; | |||
|
185 | } | |||
|
186 | else | |||
|
187 | { | |||
|
188 | uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); | |||
|
189 | } | |||
|
190 | } | |||
|
191 | ||||
|
192 | ||||
|
193 | ||||
|
194 | int bsp_FSMC_init() | |||
|
195 | { | |||
|
196 | #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) | |||
|
197 | #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) | |||
|
198 | ||||
|
199 | gpio_t gpio1 = gpioopen(LCD_RESET); | |||
|
200 | gpiosetspeed(&gpio1,gpiohighspeed); | |||
|
201 | gpiosetdir(&gpio1,gpiooutdir); | |||
|
202 | gpioclr(LCD_RESET); | |||
|
203 | ||||
|
204 | gpio_t LCD_DBxList[]={ | |||
|
205 | LCD_CS, | |||
|
206 | LCD_RS, | |||
|
207 | LCD_WR, | |||
|
208 | LCD_RD, | |||
|
209 | LCD_D0, | |||
|
210 | LCD_D1, | |||
|
211 | LCD_D2, | |||
|
212 | LCD_D3, | |||
|
213 | LCD_D4, | |||
|
214 | LCD_D5, | |||
|
215 | LCD_D6, | |||
|
216 | LCD_D7, | |||
|
217 | LCD_D8, | |||
|
218 | LCD_D9, | |||
|
219 | LCD_D10, | |||
|
220 | LCD_D11, | |||
|
221 | LCD_D12, | |||
|
222 | LCD_D13, | |||
|
223 | LCD_D14, | |||
|
224 | LCD_D15}; | |||
|
225 | ||||
|
226 | for(int i=0;i<20;i++) | |||
|
227 | { | |||
|
228 | gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); | |||
|
229 | LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; | |||
|
230 | gpiosetconfig(&LCD_DBx); | |||
|
231 | GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); | |||
|
232 | } | |||
|
233 | ||||
|
234 | FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; | |||
|
235 | FSMC_NORSRAMTimingInitTypeDef p,readtim; | |||
|
236 | ||||
|
237 | /* Enable FSMC clock */ | |||
|
238 | RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); | |||
|
239 | ||||
|
240 | /*-- FSMC Configuration ------------------------------------------------------*/ | |||
|
241 | /*----------------------- SRAM Bank 3 ----------------------------------------*/ | |||
|
242 | /* FSMC_Bank1_NORSRAM3 configuration */ | |||
|
243 | p.FSMC_AddressSetupTime = 0xf; | |||
|
244 | p.FSMC_AddressHoldTime = 0xf; | |||
|
245 | //ili9328 -> data setup time > 10ns | |||
|
246 | p.FSMC_DataSetupTime = 0xf; | |||
|
247 | if(getCpuFreq()>100*1000*1000) | |||
|
248 | p.FSMC_DataSetupTime = 0xf;// 11; | |||
|
249 | p.FSMC_BusTurnAroundDuration = 0xf; | |||
|
250 | p.FSMC_CLKDivision = 0; | |||
|
251 | p.FSMC_DataLatency = 0xf; | |||
|
252 | //ili9328 -> data hold time > 15ns | |||
|
253 | if(getCpuFreq()>66*1000*1000) | |||
|
254 | p.FSMC_DataLatency = 0xf; | |||
|
255 | p.FSMC_AccessMode = FSMC_AccessMode_A; | |||
|
256 | ||||
|
257 | readtim.FSMC_AddressSetupTime = 0xf; | |||
|
258 | readtim.FSMC_AddressHoldTime = 0xf; | |||
|
259 | //p.FSMC_DataSetupTime = 9; | |||
|
260 | readtim.FSMC_DataSetupTime = 0xf ;// 11; | |||
|
261 | if(getCpuFreq()>100*1000*1000) | |||
|
262 | readtim.FSMC_DataSetupTime = 0xf;// 11; | |||
|
263 | readtim.FSMC_BusTurnAroundDuration = 0xf; | |||
|
264 | readtim.FSMC_CLKDivision = 2; | |||
|
265 | readtim.FSMC_DataLatency = 0xf; | |||
|
266 | if(getCpuFreq()>66*1000*1000) | |||
|
267 | readtim.FSMC_DataLatency = 0xf; | |||
|
268 | readtim.FSMC_AccessMode = FSMC_AccessMode_A; | |||
|
269 | ||||
|
270 | FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1; | |||
|
271 | FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; | |||
|
272 | FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; | |||
|
273 | FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; | |||
|
274 | FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; | |||
|
275 | FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; | |||
|
276 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; | |||
|
277 | FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; | |||
|
278 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; | |||
|
279 | FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; | |||
|
280 | FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; | |||
|
281 | FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; | |||
|
282 | FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; | |||
|
283 | FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readtim; | |||
|
284 | FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; | |||
|
285 | ||||
|
286 | FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); | |||
|
287 | ||||
|
288 | /* Enable FSMC NOR/SRAM Bank1 */ | |||
|
289 | FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); | |||
|
290 | gpio_t SRAM_DBxList[]={ | |||
|
291 | SRAM_A0, | |||
|
292 | SRAM_A1, | |||
|
293 | SRAM_A2, | |||
|
294 | SRAM_A3, | |||
|
295 | SRAM_A4, | |||
|
296 | SRAM_A5, | |||
|
297 | SRAM_A6, | |||
|
298 | SRAM_A7, | |||
|
299 | SRAM_A8, | |||
|
300 | SRAM_A9, | |||
|
301 | SRAM_A10, | |||
|
302 | SRAM_A11, | |||
|
303 | SRAM_A12, | |||
|
304 | SRAM_A13, | |||
|
305 | SRAM_A14, | |||
|
306 | SRAM_A15, | |||
|
307 | SRAM_A16, | |||
|
308 | SRAM_A17, | |||
|
309 | SRAM_A18, | |||
|
310 | SRAM_A19, | |||
|
311 | SRAM_NBL0, | |||
|
312 | SRAM_NBL1, | |||
|
313 | SRAM_NCE | |||
|
314 | }; | |||
|
315 | ||||
|
316 | for(int i=0;i<23;i++) | |||
|
317 | { | |||
|
318 | gpio_t SRAM_DBx = gpioopen(SRAM_DBxList[i]); | |||
|
319 | SRAM_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; | |||
|
320 | gpiosetconfig(&SRAM_DBx); | |||
|
321 | GPIO_PinAFConfig(GPIOGETPORT(SRAM_DBx), (uint8_t)(SRAM_DBx & 0xF), GPIO_AF_FSMC); | |||
|
322 | } | |||
|
323 | /*-- FSMC Configuration ------------------------------------------------------*/ | |||
|
324 | // p.FSMC_AddressSetupTime = 3; | |||
|
325 | p.FSMC_AddressSetupTime = 1; | |||
|
326 | p.FSMC_AddressHoldTime = 1; | |||
|
327 | // p.FSMC_DataSetupTime = 6; | |||
|
328 | p.FSMC_DataSetupTime = 1; | |||
|
329 | p.FSMC_BusTurnAroundDuration = 1; | |||
|
330 | p.FSMC_CLKDivision = 0; | |||
|
331 | p.FSMC_DataLatency = 1; | |||
|
332 | p.FSMC_AccessMode = FSMC_AccessMode_A; | |||
|
333 | ||||
|
334 | FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2; | |||
|
335 | FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; | |||
|
336 | FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_PSRAM; | |||
|
337 | FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; | |||
|
338 | FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; | |||
|
339 | FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; | |||
|
340 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; | |||
|
341 | FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; | |||
|
342 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; | |||
|
343 | FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; | |||
|
344 | FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; | |||
|
345 | FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; | |||
|
346 | FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; | |||
|
347 | FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; | |||
|
348 | FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; | |||
|
349 | ||||
|
350 | FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); | |||
|
351 | ||||
|
352 | /*!< Enable FSMC Bank1_SRAM2 Bank */ | |||
|
353 | FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM2, ENABLE); | |||
|
354 | gpioset(LCD_RESET); | |||
|
355 | delay_100us(500); | |||
|
356 | gpioclr(LCD_RESET); | |||
|
357 | delay_100us(500); | |||
|
358 | gpioset(LCD_RESET); | |||
|
359 | lcd0.init(&lcd0); | |||
|
360 | return 1; | |||
|
361 | } | |||
|
362 | ||||
|
363 | void bsp_spi_init() | |||
|
364 | { | |||
|
365 | ||||
|
366 | // ads7843init(&tc_dev,spi1,ADS7843_POWER_ADC_ON|ADS7843_MODE_12BITS,&TC_setnCS,&TC_busy); | |||
|
367 | spiopenandconfig(spi1,spimaster|spi8bits|spimsbfirst|spiclkfirstedge,10000000,TC_DIN,TC_DOUT,TC_CLK,-1); | |||
|
368 | } | |||
|
369 | ||||
|
370 | ||||
|
371 | void bsp_iic_init() | |||
|
372 | { | |||
|
373 | i2copenandconfig(i2c3,0,10000,PH8,PH7); | |||
|
374 | } | |||
|
375 | ||||
|
376 | void bsp_SD_init() | |||
|
377 | { | |||
|
378 | ||||
|
379 | } | |||
|
380 | ||||
|
381 | void vs10XXclearXCS(){} | |||
|
382 | void vs10XXsetXCS(){} | |||
|
383 | int vs10XXDREQ() | |||
|
384 | { | |||
|
385 | return 1; | |||
|
386 | } | |||
|
387 | ||||
|
388 | ||||
|
389 | void bsppowersdcard(char onoff) //always ON | |||
|
390 | { | |||
|
391 | ||||
|
392 | } | |||
|
393 | ||||
|
394 | char bspsdcardpresent() | |||
|
395 | { | |||
|
396 | return 0; | |||
|
397 | } | |||
|
398 | ||||
|
399 | char bspsdcardwriteprotected() | |||
|
400 | { | |||
|
401 | return 0; | |||
|
402 | } | |||
|
403 | ||||
|
404 | void bspsdcardselect(char YESNO) | |||
|
405 | { | |||
|
406 | ||||
|
407 | } | |||
|
408 | ||||
|
409 | ||||
|
410 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) | |||
|
411 | { | |||
|
412 | *lcd0_CMD=(uint16_t)reg; | |||
|
413 | *lcd0_DATA=(uint16_t)data; | |||
|
414 | } | |||
|
415 | ||||
|
416 | uint32_t bsp_lcd0_read_reg(uint32_t reg) | |||
|
417 | { | |||
|
418 | uint16_t value; | |||
|
419 | *lcd0_CMD=(uint16_t)reg; | |||
|
420 | value = *lcd0_DATA; | |||
|
421 | value = *lcd0_DATA; | |||
|
422 | return value; | |||
|
423 | } | |||
|
424 | ||||
|
425 | void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) | |||
|
426 | { | |||
|
427 | *lcd0_CMD=(uint16_t)D51E5TA7601_REGISTER_WRITEDATATOGRAM; | |||
|
428 | uint16_t* castedBuff=(uint16_t*)buffer; | |||
|
429 | for(int i=0;i<(int)count;i++) | |||
|
430 | { | |||
|
431 | *lcd0_DATA=castedBuff[i]; | |||
|
432 | } | |||
|
433 | } | |||
|
434 | ||||
|
435 | void bsp_lcd0_setGRAM() | |||
|
436 | { | |||
|
437 | *lcd0_CMD=(uint16_t)D51E5TA7601_REGISTER_WRITEDATATOGRAM; | |||
|
438 | } | |||
|
439 | ||||
|
440 | void bsp_lcd0_readGRAM(void* buffer,uint32_t count) | |||
|
441 | { | |||
|
442 | uint16_t* castedBuff=(uint16_t*)buffer; | |||
|
443 | *lcd0_CMD=(uint16_t)D51E5TA7601_REGISTER_WRITEDATATOGRAM; | |||
|
444 | castedBuff[0]=lcd0_DATA[0]; | |||
|
445 | for(int i=0;i<(int)count;i++) | |||
|
446 | { | |||
|
447 | castedBuff[i]=lcd0_DATA[0]; | |||
|
448 | } | |||
|
449 | } | |||
|
450 | ||||
|
451 | uint32_t bsp_lcd0_status() | |||
|
452 | { | |||
|
453 | uint16_t status = lcd0_CMD[0]; | |||
|
454 | return (uint32_t)status; | |||
|
455 | } | |||
|
456 | ||||
|
457 | void TC_setnCS(char val) | |||
|
458 | { | |||
|
459 | return gpiosetval(TC_BUSY,val); | |||
|
460 | } | |||
|
461 | ||||
|
462 | int TC_busy() | |||
|
463 | { | |||
|
464 | return gpiogetval(TC_BUSY); | |||
|
465 | } | |||
|
466 | ||||
|
467 | void bsp_TC_init() | |||
|
468 | { | |||
|
469 | #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) | |||
|
470 | #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) | |||
|
471 | ||||
|
472 | gpio_t gpio1 = gpioopen(TC_BUSY); | |||
|
473 | gpio1 |= gpiohighspeed | gpioindir | gpionopulltype; | |||
|
474 | gpiosetconfig(&gpio1); | |||
|
475 | ||||
|
476 | gpio1 = gpioopen(TC_IRQ); | |||
|
477 | gpio1 |= gpiohighspeed | gpioindir | gpiopulluptype; | |||
|
478 | gpiosetconfig(&gpio1); | |||
|
479 | ||||
|
480 | gpio1 = gpioopen(TC_CS); | |||
|
481 | gpio1 |= gpiohighspeed | gpiooutdir | gpionopulltype; | |||
|
482 | gpiosetconfig(&gpio1); | |||
|
483 | ||||
|
484 | gpio1 = gpioopen(TC_CLK); | |||
|
485 | gpio1 |= gpiohighspeed | gpioaf | gpionopulltype; | |||
|
486 | gpiosetconfig(&gpio1); | |||
|
487 | GPIO_PinAFConfig(GPIOGETPORT(TC_CLK), (uint8_t)(TC_CLK & 0xF), GPIO_AF_SPI1); | |||
|
488 | ||||
|
489 | gpio1 = gpioopen(TC_DIN); | |||
|
490 | gpio1 |= gpiohighspeed | gpioaf | gpionopulltype; | |||
|
491 | gpiosetconfig(&gpio1); | |||
|
492 | GPIO_PinAFConfig(GPIOGETPORT(gpio1), (uint8_t)(gpio1 & 0xF), GPIO_AF_SPI1); | |||
|
493 | ||||
|
494 | gpio1 = gpioopen(TC_DOUT); | |||
|
495 | gpio1 |= gpiohighspeed | gpioaf | gpionopulltype; | |||
|
496 | gpiosetconfig(&gpio1); | |||
|
497 | GPIO_PinAFConfig(GPIOGETPORT(gpio1), (uint8_t)(gpio1 & 0xF), GPIO_AF_SPI1); | |||
|
498 | } | |||
|
499 | ||||
|
500 | ||||
|
501 | void bsp_GTerm_init() | |||
|
502 | { | |||
|
503 | FRAME_BUFFER->init(FRAME_BUFFER); | |||
|
504 | if(__opnfiles__[1]==NULL) | |||
|
505 | { | |||
|
506 | //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); | |||
|
507 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |||
|
508 | terminal_init(&terminal0 ,FRAME_BUFFER,&ComicSansMS_8,fd1); | |||
|
509 | __opnfiles__[1] = fd1; | |||
|
510 | } | |||
|
511 | else | |||
|
512 | { | |||
|
513 | ||||
|
514 | } | |||
|
515 | } | |||
|
516 |
@@ -0,0 +1,202 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the libuc, microcontroler library | |||
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This 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. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | ------------------------------------------------------------------------------- | |||
|
19 | -- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |||
|
21 | -------------------------------------------------------------------------------*/ | |||
|
22 | #ifndef BSP_H | |||
|
23 | #define BSP_H | |||
|
24 | #include <stm32f4xx.h> | |||
|
25 | #include <stm32f4xx_gpio.h> | |||
|
26 | #include <stm32f4xx_rcc.h> | |||
|
27 | #include <gpio.h> | |||
|
28 | #include <ili9328.h> | |||
|
29 | #include <D51E5TA7601.h> | |||
|
30 | #include <genericLCD_Controler.h> | |||
|
31 | ||||
|
32 | #define __MAX_OPENED_FILES__ 4 | |||
|
33 | #define __FS_ROOT_SIZE__ 4 | |||
|
34 | /* | |||
|
35 | #ifndef PD8 | |||
|
36 | #define PD8 | |||
|
37 | #endif | |||
|
38 | #ifndef PD9 | |||
|
39 | #define PD9 | |||
|
40 | #endif | |||
|
41 | */ | |||
|
42 | ||||
|
43 | ||||
|
44 | #define LED1 PF6 | |||
|
45 | #define LED2 PF7 | |||
|
46 | #define LED3 PF8 | |||
|
47 | ||||
|
48 | #define PSU_DISABLE PH2 | |||
|
49 | #define DCIN_ALERT PH12 | |||
|
50 | #define PSU_ALERT_5V PH9 | |||
|
51 | #define PSU_ALERT_1_5V PH10 | |||
|
52 | #define PSU_ALERT_3_3V PH11 | |||
|
53 | ||||
|
54 | #define LCD_RESET PE2 | |||
|
55 | #define LCD_BACKLIGHT PE6 | |||
|
56 | #define BP1 PI1 | |||
|
57 | #define BP2 PI2 | |||
|
58 | #define BP3 PD2 | |||
|
59 | #define BP4 PD3 | |||
|
60 | ||||
|
61 | #define TC_IRQ PA3 | |||
|
62 | #define TC_CS PA4 | |||
|
63 | #define TC_CLK PA5 | |||
|
64 | #define TC_DOUT PA6 | |||
|
65 | #define TC_DIN PA7 | |||
|
66 | #define TC_BUSY PB0 | |||
|
67 | ||||
|
68 | ||||
|
69 | ||||
|
70 | //LCD Signals | |||
|
71 | #define LCD_CS PD7 //FSMC_NE1 | |||
|
72 | #define LCD_RS PE4 //FSMC_A20 | |||
|
73 | #define LCD_WR PD5 //FSMC_NWE | |||
|
74 | #define LCD_RD PD4 //FSMC_NOE | |||
|
75 | #define LCD_RST PE2 | |||
|
76 | ||||
|
77 | #define LCD_D0 PD14 | |||
|
78 | #define LCD_D1 PD15 | |||
|
79 | #define LCD_D2 PD0 | |||
|
80 | #define LCD_D3 PD1 | |||
|
81 | #define LCD_D4 PE7 | |||
|
82 | #define LCD_D5 PE8 | |||
|
83 | #define LCD_D6 PE9 | |||
|
84 | #define LCD_D7 PE10 | |||
|
85 | #define LCD_D8 PE11 | |||
|
86 | #define LCD_D9 PE12 | |||
|
87 | #define LCD_D10 PE13 | |||
|
88 | #define LCD_D11 PE14 | |||
|
89 | #define LCD_D12 PE15 | |||
|
90 | #define LCD_D13 PD8 | |||
|
91 | #define LCD_D14 PD9 | |||
|
92 | #define LCD_D15 PD10 | |||
|
93 | ||||
|
94 | //SSRAM Signals | |||
|
95 | #define SRAM_NBL0 PE0 //FSMC_NBL0 | |||
|
96 | #define SRAM_NBL1 PE1 //FSMC_NBL1 | |||
|
97 | #define SRAM_NOE PD4 //FSMC_NOE | |||
|
98 | #define SRAM_NWE PD5 //FSMC_NWE | |||
|
99 | #define SRAM_NCE PG9 //FSMC_NE2 | |||
|
100 | ||||
|
101 | #define SRAM_A0 PF0 //FSMC_A0 | |||
|
102 | #define SRAM_A1 PF1 //FSMC_A1 | |||
|
103 | #define SRAM_A2 PF2 //FSMC_A2 | |||
|
104 | #define SRAM_A3 PF3 //FSMC_A3 | |||
|
105 | #define SRAM_A4 PF4 //FSMC_A4 | |||
|
106 | #define SRAM_A5 PF5 //FSMC_A5 | |||
|
107 | #define SRAM_A6 PF12 //FSMC_A6 | |||
|
108 | #define SRAM_A7 PF13 //FSMC_A7 | |||
|
109 | #define SRAM_A8 PF14 //FSMC_A8 | |||
|
110 | #define SRAM_A9 PF15 //FSMC_A9 | |||
|
111 | #define SRAM_A10 PG0 //FSMC_A10 | |||
|
112 | #define SRAM_A11 PG1 //FSMC_A11 | |||
|
113 | #define SRAM_A12 PG2 //FSMC_A12 | |||
|
114 | #define SRAM_A13 PG3 //FSMC_A13 | |||
|
115 | #define SRAM_A14 PG4 //FSMC_A14 | |||
|
116 | #define SRAM_A15 PG5 //FSMC_A15 | |||
|
117 | #define SRAM_A16 PD11 //FSMC_A16 | |||
|
118 | #define SRAM_A17 PD12 //FSMC_A17 | |||
|
119 | #define SRAM_A18 PD13 //FSMC_A18 | |||
|
120 | #define SRAM_A19 PE3 //FSMC_A19 | |||
|
121 | ||||
|
122 | #define SRAM_D0 PD14 | |||
|
123 | #define SRAM_D1 PD15 | |||
|
124 | #define SRAM_D2 PD0 | |||
|
125 | #define SRAM_D3 PD1 | |||
|
126 | #define SRAM_D4 PE7 | |||
|
127 | #define SRAM_D5 PE8 | |||
|
128 | #define SRAM_D6 PE9 | |||
|
129 | #define SRAM_D7 PE10 | |||
|
130 | #define SRAM_D8 PE11 | |||
|
131 | #define SRAM_D9 PE12 | |||
|
132 | #define SRAM_D10 PE13 | |||
|
133 | #define SRAM_D11 PE14 | |||
|
134 | #define SRAM_D12 PE15 | |||
|
135 | #define SRAM_D13 PD8 | |||
|
136 | #define SRAM_D14 PD9 | |||
|
137 | #define SRAM_D15 PD10 | |||
|
138 | ||||
|
139 | ||||
|
140 | extern float VREF0; | |||
|
141 | ||||
|
142 | extern uint32_t currentCpuFreq; | |||
|
143 | extern LCD_t lcd0; | |||
|
144 | ||||
|
145 | extern LCD_t* FRAME_BUFFER; | |||
|
146 | extern LCD_t FRAME_BUFFER0; | |||
|
147 | extern LCD_t FRAME_BUFFER1; | |||
|
148 | ||||
|
149 | ||||
|
150 | extern int bsp_init(); | |||
|
151 | ||||
|
152 | extern void bsp_GPIO_init(); | |||
|
153 | extern void bsp_uart_init(); | |||
|
154 | extern void bsp_iic_init(); | |||
|
155 | extern void bsp_spi_init(); | |||
|
156 | extern void bsp_SD_init(); | |||
|
157 | extern void bsp_TC_init(); | |||
|
158 | extern void bsp_GTerm_init(); | |||
|
159 | extern int bsp_FSMC_init(); | |||
|
160 | ||||
|
161 | extern void TC_setnCS(char val); | |||
|
162 | extern int TC_busy(); | |||
|
163 | ||||
|
164 | /* VS1053 */ | |||
|
165 | extern void clearXCS(); | |||
|
166 | extern void setXCS(); | |||
|
167 | extern int vs10XXDREQ(); | |||
|
168 | ||||
|
169 | /* SD CARD */ | |||
|
170 | void bsppowersdcard(char onoff); | |||
|
171 | char bspsdcardpresent(); | |||
|
172 | void bspsdcardselect(char YESNO); | |||
|
173 | char bspsdcardwriteprotected(); | |||
|
174 | ||||
|
175 | ||||
|
176 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); | |||
|
177 | uint32_t bsp_lcd0_read_reg(uint32_t reg); | |||
|
178 | void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); | |||
|
179 | void bsp_lcd0_readGRAM(void *buffer, uint32_t count); | |||
|
180 | uint32_t bsp_lcd0_status(); | |||
|
181 | void bsp_lcd0_setGRAM(); | |||
|
182 | ||||
|
183 | #endif | |||
|
184 | ||||
|
185 | ||||
|
186 | ||||
|
187 | ||||
|
188 | ||||
|
189 | ||||
|
190 | ||||
|
191 | ||||
|
192 | ||||
|
193 | ||||
|
194 | ||||
|
195 | ||||
|
196 | ||||
|
197 | ||||
|
198 | ||||
|
199 | ||||
|
200 | ||||
|
201 | ||||
|
202 |
@@ -0,0 +1,53 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the libuc, microcontroler library | |||
|
3 | -- Copyright (C) 2015, Alexis Jeandet | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This 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. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | ------------------------------------------------------------------------------- | |||
|
19 | -- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@gmail.com | |||
|
21 | -------------------------------------------------------------------------------*/ | |||
|
22 | ||||
|
23 | #ifndef DMA_H | |||
|
24 | #define DMA_H | |||
|
25 | #include <streamdevices.h> | |||
|
26 | ||||
|
27 | #ifdef __cplusplus | |||
|
28 | extern "C" { | |||
|
29 | #endif | |||
|
30 | ||||
|
31 | typedef int dmaID_t; | |||
|
32 | ||||
|
33 | dmaID_t dmacopy(uint32_t source, uint32_t dest, int size, int count, char incSrc, char incDest); | |||
|
34 | dmaID_t dmamemset(uint32_t dest,int val, int size); | |||
|
35 | int dmaIsReady(dmaID_t dmaID); | |||
|
36 | int dmaLockStream(int stream,int dmaDev); | |||
|
37 | ||||
|
38 | #ifdef __cplusplus | |||
|
39 | } | |||
|
40 | #endif | |||
|
41 | #endif //DMA_H | |||
|
42 | ||||
|
43 | ||||
|
44 | ||||
|
45 | ||||
|
46 | ||||
|
47 | ||||
|
48 | ||||
|
49 | ||||
|
50 | ||||
|
51 | ||||
|
52 | ||||
|
53 |
@@ -0,0 +1,362 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the libuc, microcontroler library | |||
|
3 | -- Copyright (C) 2012, Alexis Jeandet | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This 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. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | ------------------------------------------------------------------------------- | |||
|
19 | -- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |||
|
21 | -------------------------------------------------------------------------------*/ | |||
|
22 | #include <dma.h> | |||
|
23 | #include <stm32f4xx_gpio.h> | |||
|
24 | #include <stm32f4xx_rcc.h> | |||
|
25 | #include <stm32f4xx_dma.h> | |||
|
26 | #include <misc.h> | |||
|
27 | ||||
|
28 | #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) | |||
|
29 | #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) | |||
|
30 | typedef enum dmaStreamState | |||
|
31 | { | |||
|
32 | avail=0, | |||
|
33 | inUse=1, | |||
|
34 | locked=2, | |||
|
35 | }dmaStreamState; | |||
|
36 | ||||
|
37 | char __DMA2_streams__[8]={avail,avail,avail,avail,avail,avail,avail,avail}; | |||
|
38 | DMA_Stream_TypeDef* __DMA2_streams_list__[8]={DMA2_Stream0,DMA2_Stream1,DMA2_Stream2,DMA2_Stream3,DMA2_Stream4,DMA2_Stream5,DMA2_Stream6,DMA2_Stream7}; | |||
|
39 | int __DMA2_streams_channels__[8]={DMA_Channel_1,DMA_Channel_3,DMA_Channel_2,DMA_Channel_0,DMA_Channel_3,DMA_Channel_5,DMA_Channel_3,DMA_Channel_3}; | |||
|
40 | uint32_t __DMA2_streams_remainig_data__[8]={0,0,0,0,0,0,0,0}; | |||
|
41 | int __DMA_Csts__[8]={0,0,0,0,0,0,0,0}; | |||
|
42 | char __dma_is_initialised =0; | |||
|
43 | typedef struct _dma_config_ | |||
|
44 | { | |||
|
45 | uint32_t source; | |||
|
46 | uint32_t dest; | |||
|
47 | int size; | |||
|
48 | int count; | |||
|
49 | char incSrc; | |||
|
50 | char incDest; | |||
|
51 | }_dma_config_; | |||
|
52 | ||||
|
53 | _dma_config_ __DMA2_streams_config__[8]; | |||
|
54 | ||||
|
55 | void __set_DMA_inc__(DMA_InitTypeDef* DMA_InitStructure,int* incsz,int*datacnt) | |||
|
56 | { | |||
|
57 | switch (*incsz) { | |||
|
58 | case 1: | |||
|
59 | DMA_InitStructure->DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; | |||
|
60 | DMA_InitStructure->DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; | |||
|
61 | break; | |||
|
62 | case 2: | |||
|
63 | DMA_InitStructure->DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; | |||
|
64 | DMA_InitStructure->DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; | |||
|
65 | break; | |||
|
66 | case 4: | |||
|
67 | DMA_InitStructure->DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; | |||
|
68 | DMA_InitStructure->DMA_MemoryDataSize = DMA_MemoryDataSize_Word; | |||
|
69 | break; | |||
|
70 | default: | |||
|
71 | DMA_InitStructure->DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; | |||
|
72 | DMA_InitStructure->DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; | |||
|
73 | (*datacnt)*=(*incsz); | |||
|
74 | *incsz=1; | |||
|
75 | break; | |||
|
76 | } | |||
|
77 | } | |||
|
78 | ||||
|
79 | void __DMA2_init() | |||
|
80 | { | |||
|
81 | int irq[8]={DMA2_Stream0_IRQn,DMA2_Stream1_IRQn,DMA2_Stream2_IRQn,DMA2_Stream3_IRQn,DMA2_Stream4_IRQn,DMA2_Stream5_IRQn,DMA2_Stream6_IRQn,DMA2_Stream7_IRQn}; | |||
|
82 | NVIC_InitTypeDef NVIC_InitStructure; | |||
|
83 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE); | |||
|
84 | ||||
|
85 | for(int i=0;i<8;i++) | |||
|
86 | { | |||
|
87 | if(__DMA2_streams__[i]!=locked) | |||
|
88 | { | |||
|
89 | DMA_DeInit(__DMA2_streams_list__[i]); | |||
|
90 | DMA_ITConfig(__DMA2_streams_list__[i], DMA_IT_TC, ENABLE); | |||
|
91 | NVIC_InitStructure.NVIC_IRQChannel = irq[i]; | |||
|
92 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; | |||
|
93 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; | |||
|
94 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; | |||
|
95 | NVIC_Init(&NVIC_InitStructure); | |||
|
96 | } | |||
|
97 | } | |||
|
98 | __dma_is_initialised = 1; | |||
|
99 | } | |||
|
100 | ||||
|
101 | void __dmacopy__(uint32_t source, uint32_t dest, int size, int count,char incSrc,char incDest,int streamIndex) | |||
|
102 | { | |||
|
103 | DMA_InitTypeDef DMA_InitStructure; | |||
|
104 | DMA_Stream_TypeDef* stream=__DMA2_streams_list__[streamIndex]; | |||
|
105 | while (DMA_GetCmdStatus(stream) != DISABLE); | |||
|
106 | __set_DMA_inc__(&DMA_InitStructure,&size,&count); | |||
|
107 | DMA_InitStructure.DMA_Channel = __DMA2_streams_channels__[streamIndex]; | |||
|
108 | DMA_InitStructure.DMA_PeripheralBaseAddr = source; | |||
|
109 | DMA_InitStructure.DMA_Memory0BaseAddr = dest; | |||
|
110 | DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToMemory; | |||
|
111 | if(count>65535) | |||
|
112 | { | |||
|
113 | DMA_InitStructure.DMA_BufferSize = 65535; | |||
|
114 | __DMA2_streams_config__[streamIndex].count = count-65535; | |||
|
115 | } | |||
|
116 | else | |||
|
117 | { | |||
|
118 | DMA_InitStructure.DMA_BufferSize = count; | |||
|
119 | __DMA2_streams_config__[streamIndex].count = 0; | |||
|
120 | } | |||
|
121 | __DMA2_streams_config__[streamIndex].incDest = incDest; | |||
|
122 | __DMA2_streams_config__[streamIndex].incSrc = incSrc; | |||
|
123 | __DMA2_streams_config__[streamIndex].size = size; | |||
|
124 | if(incSrc) | |||
|
125 | { | |||
|
126 | __DMA2_streams_config__[streamIndex].source = source+(DMA_InitStructure.DMA_BufferSize*size); | |||
|
127 | DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Enable; | |||
|
128 | } | |||
|
129 | else | |||
|
130 | { | |||
|
131 | __DMA2_streams_config__[streamIndex].source = source; | |||
|
132 | DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; | |||
|
133 | } | |||
|
134 | if(incDest) | |||
|
135 | { | |||
|
136 | __DMA2_streams_config__[streamIndex].dest = dest+(DMA_InitStructure.DMA_BufferSize*size); | |||
|
137 | DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; | |||
|
138 | } | |||
|
139 | else | |||
|
140 | { | |||
|
141 | __DMA2_streams_config__[streamIndex].dest = dest; | |||
|
142 | DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable; | |||
|
143 | } | |||
|
144 | DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; | |||
|
145 | DMA_InitStructure.DMA_Priority = DMA_Priority_High; | |||
|
146 | DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; | |||
|
147 | DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; | |||
|
148 | DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; | |||
|
149 | DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; | |||
|
150 | DMA_Init(stream, &DMA_InitStructure); | |||
|
151 | DMA_Cmd(stream, ENABLE); | |||
|
152 | } | |||
|
153 | ||||
|
154 | dmaID_t dmacopy(uint32_t source, uint32_t dest, int size, int count,char incSrc,char incDest) | |||
|
155 | { | |||
|
156 | int streamIndex; | |||
|
157 | if(!__dma_is_initialised) | |||
|
158 | { | |||
|
159 | __DMA2_init(); | |||
|
160 | } | |||
|
161 | for(int i=0;i<8;i++) | |||
|
162 | { | |||
|
163 | if(__DMA2_streams__[i]==avail) | |||
|
164 | { | |||
|
165 | streamIndex=i; | |||
|
166 | __DMA2_streams__[i]=inUse; | |||
|
167 | break; | |||
|
168 | } | |||
|
169 | } | |||
|
170 | __dmacopy__(source,dest,size,count,incSrc,incDest,streamIndex); | |||
|
171 | return streamIndex; | |||
|
172 | } | |||
|
173 | ||||
|
174 | void DMA2_continueCp(int streamIndex) | |||
|
175 | { | |||
|
176 | DMA_InitTypeDef DMA_InitStructure; | |||
|
177 | DMA_Stream_TypeDef* stream = __DMA2_streams_list__[streamIndex]; | |||
|
178 | if ((DMA_GetCmdStatus(stream) != DISABLE) && (__DMA2_streams__[streamIndex]==inUse)) | |||
|
179 | { | |||
|
180 | return; | |||
|
181 | } | |||
|
182 | if(__DMA2_streams_config__[streamIndex].count==0) | |||
|
183 | { | |||
|
184 | __DMA2_streams__[streamIndex]=avail; | |||
|
185 | return; | |||
|
186 | } | |||
|
187 | __set_DMA_inc__(&DMA_InitStructure,&(__DMA2_streams_config__[streamIndex].size),&(__DMA2_streams_config__[streamIndex].count)); | |||
|
188 | DMA_InitStructure.DMA_Channel = __DMA2_streams_channels__[streamIndex]; | |||
|
189 | DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToMemory; | |||
|
190 | DMA_InitStructure.DMA_PeripheralBaseAddr = __DMA2_streams_config__[streamIndex].source; | |||
|
191 | DMA_InitStructure.DMA_Memory0BaseAddr = __DMA2_streams_config__[streamIndex].dest; | |||
|
192 | if(__DMA2_streams_config__[streamIndex].count>65535) | |||
|
193 | { | |||
|
194 | DMA_InitStructure.DMA_BufferSize = 65535; | |||
|
195 | __DMA2_streams_config__[streamIndex].count = __DMA2_streams_config__[streamIndex].count-65535; | |||
|
196 | } | |||
|
197 | else | |||
|
198 | { | |||
|
199 | DMA_InitStructure.DMA_BufferSize = __DMA2_streams_config__[streamIndex].count; | |||
|
200 | __DMA2_streams_config__[streamIndex].count = 0; | |||
|
201 | } | |||
|
202 | if(__DMA2_streams_config__[streamIndex].incSrc) | |||
|
203 | { | |||
|
204 | __DMA2_streams_config__[streamIndex].source +=(DMA_InitStructure.DMA_BufferSize*__DMA2_streams_config__[streamIndex].size); | |||
|
205 | DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Enable; | |||
|
206 | } | |||
|
207 | else | |||
|
208 | { | |||
|
209 | __DMA2_streams_config__[streamIndex].source = __DMA2_streams_config__[streamIndex].source; | |||
|
210 | DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; | |||
|
211 | } | |||
|
212 | if(__DMA2_streams_config__[streamIndex].incDest) | |||
|
213 | { | |||
|
214 | __DMA2_streams_config__[streamIndex].dest +=(DMA_InitStructure.DMA_BufferSize*__DMA2_streams_config__[streamIndex].size); | |||
|
215 | DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; | |||
|
216 | } | |||
|
217 | else | |||
|
218 | { | |||
|
219 | __DMA2_streams_config__[streamIndex].dest = __DMA2_streams_config__[streamIndex].dest; | |||
|
220 | DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable; | |||
|
221 | } | |||
|
222 | DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; | |||
|
223 | DMA_InitStructure.DMA_Priority = DMA_Priority_High; | |||
|
224 | DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; | |||
|
225 | DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; | |||
|
226 | DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; | |||
|
227 | DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; | |||
|
228 | DMA_Init(stream, &DMA_InitStructure); | |||
|
229 | DMA_Cmd(stream, ENABLE); | |||
|
230 | } | |||
|
231 | ||||
|
232 | void DMA2_Stream0_IRQHandler(void) | |||
|
233 | { | |||
|
234 | if(DMA_GetITStatus(DMA2_Stream0, DMA_IT_TCIF0)) | |||
|
235 | { | |||
|
236 | /* Clear DMA Stream Transfer Complete interrupt pending bit */ | |||
|
237 | DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF0); | |||
|
238 | DMA2_continueCp(0); | |||
|
239 | } | |||
|
240 | } | |||
|
241 | ||||
|
242 | void DMA2_Stream1_IRQHandler(void) | |||
|
243 | { | |||
|
244 | if(DMA_GetITStatus(DMA2_Stream1, DMA_IT_TCIF1)) | |||
|
245 | { | |||
|
246 | /* Clear DMA Stream Transfer Complete interrupt pending bit */ | |||
|
247 | DMA_ClearITPendingBit(DMA2_Stream1, DMA_IT_TCIF1); | |||
|
248 | DMA2_continueCp(1); | |||
|
249 | } | |||
|
250 | ||||
|
251 | } | |||
|
252 | ||||
|
253 | void DMA2_Stream2_IRQHandler(void) | |||
|
254 | { | |||
|
255 | if(DMA_GetITStatus(DMA2_Stream2, DMA_IT_TCIF2)) | |||
|
256 | { | |||
|
257 | /* Clear DMA Stream Transfer Complete interrupt pending bit */ | |||
|
258 | DMA_ClearITPendingBit(DMA2_Stream2, DMA_IT_TCIF2); | |||
|
259 | DMA2_continueCp(2); | |||
|
260 | } | |||
|
261 | } | |||
|
262 | ||||
|
263 | void DMA2_Stream3_IRQHandler(void) | |||
|
264 | { | |||
|
265 | if(DMA_GetITStatus(DMA2_Stream3, DMA_IT_TCIF3)) | |||
|
266 | { | |||
|
267 | /* Clear DMA Stream Transfer Complete interrupt pending bit */ | |||
|
268 | DMA_ClearITPendingBit(DMA2_Stream3, DMA_IT_TCIF3); | |||
|
269 | DMA2_continueCp(3); | |||
|
270 | } | |||
|
271 | } | |||
|
272 | ||||
|
273 | void DMA2_Stream4_IRQHandler(void) | |||
|
274 | { | |||
|
275 | if(DMA_GetITStatus(DMA2_Stream4, DMA_IT_TCIF4)) | |||
|
276 | { | |||
|
277 | /* Clear DMA Stream Transfer Complete interrupt pending bit */ | |||
|
278 | DMA_ClearITPendingBit(DMA2_Stream4, DMA_IT_TCIF4); | |||
|
279 | DMA2_continueCp(4); | |||
|
280 | } | |||
|
281 | } | |||
|
282 | ||||
|
283 | void DMA2_Stream5_IRQHandler(void) | |||
|
284 | { | |||
|
285 | if(DMA_GetITStatus(DMA2_Stream5, DMA_IT_TCIF5)) | |||
|
286 | { | |||
|
287 | /* Clear DMA Stream Transfer Complete interrupt pending bit */ | |||
|
288 | DMA_ClearITPendingBit(DMA2_Stream5, DMA_IT_TCIF5); | |||
|
289 | DMA2_continueCp(5); | |||
|
290 | } | |||
|
291 | } | |||
|
292 | ||||
|
293 | void DMA2_Stream6_IRQHandler(void) | |||
|
294 | { | |||
|
295 | if(DMA_GetITStatus(DMA2_Stream6, DMA_IT_TCIF6)) | |||
|
296 | { | |||
|
297 | /* Clear DMA Stream Transfer Complete interrupt pending bit */ | |||
|
298 | DMA_ClearITPendingBit(DMA2_Stream6, DMA_IT_TCIF6); | |||
|
299 | DMA2_continueCp(6); | |||
|
300 | } | |||
|
301 | } | |||
|
302 | ||||
|
303 | void DMA2_Stream7_IRQHandler(void) | |||
|
304 | { | |||
|
305 | if(DMA_GetITStatus(DMA2_Stream7, DMA_IT_TCIF7)) | |||
|
306 | { | |||
|
307 | /* Clear DMA Stream Transfer Complete interrupt pending bit */ | |||
|
308 | DMA_ClearITPendingBit(DMA2_Stream7, DMA_IT_TCIF7); | |||
|
309 | DMA2_continueCp(7); | |||
|
310 | } | |||
|
311 | } | |||
|
312 | ||||
|
313 | ||||
|
314 | int dmaIsReady(dmaID_t dmaID) | |||
|
315 | { | |||
|
316 | if(!__dma_is_initialised) | |||
|
317 | { | |||
|
318 | __DMA2_init(); | |||
|
319 | } | |||
|
320 | return __DMA2_streams__[dmaID]==avail; | |||
|
321 | } | |||
|
322 | ||||
|
323 | ||||
|
324 | int dmaLockStream(int stream, int dmaDev) | |||
|
325 | { | |||
|
326 | if(!__dma_is_initialised) | |||
|
327 | { | |||
|
328 | __DMA2_init(); | |||
|
329 | } | |||
|
330 | if(dmaDev==2) | |||
|
331 | { | |||
|
332 | if(__DMA2_streams__[stream]==locked) | |||
|
333 | { | |||
|
334 | return 0; | |||
|
335 | } | |||
|
336 | while(__DMA2_streams__[stream]==inUse); | |||
|
337 | __DMA2_streams__[stream]=locked; | |||
|
338 | return 1; | |||
|
339 | } | |||
|
340 | } | |||
|
341 | ||||
|
342 | ||||
|
343 | dmaID_t dmamemset(uint32_t dest, int val, int size) | |||
|
344 | { | |||
|
345 | int streamIndex; | |||
|
346 | if(!__dma_is_initialised) | |||
|
347 | { | |||
|
348 | __DMA2_init(); | |||
|
349 | } | |||
|
350 | for(int i=0;i<8;i++) | |||
|
351 | { | |||
|
352 | if(__DMA2_streams__[i]==avail) | |||
|
353 | { | |||
|
354 | streamIndex=i; | |||
|
355 | __DMA2_streams__[i]=inUse; | |||
|
356 | break; | |||
|
357 | } | |||
|
358 | } | |||
|
359 | __DMA_Csts__[streamIndex]=val; | |||
|
360 | __dmacopy__((uint32_t)(__DMA_Csts__ + streamIndex),dest,1,size,0,1,streamIndex); | |||
|
361 | return streamIndex; | |||
|
362 | } |
@@ -0,0 +1,13 | |||||
|
1 | TEMPLATE = lib | |||
|
2 | CONFIG += libuc2lib | |||
|
3 | ||||
|
4 | SOURCES += dma.c | |||
|
5 | ||||
|
6 | UCMODEL=stm32f4 | |||
|
7 | ||||
|
8 | HEADERS += \ | |||
|
9 | ../../../include/PERIPHERALS/dma.h | |||
|
10 | ||||
|
11 | ||||
|
12 | ||||
|
13 |
@@ -1,9 +1,9 | |||||
1 | CPU=stm32f4xxxG |
|
1 | CPU=stm32f4xxxG | |
2 | DEFINES+=BSP=\\\"BEAGLESYNTH\\\" |
|
2 | DEFINES+=BSP=\\\"BEAGLESYNTH\\\" | |
3 | beagleCp.target = beagleCp |
|
3 | beagleCp.target = beagleCp | |
4 |
beagleCp.commands = cd |
|
4 | beagleCp.commands = cd $(DESTDIR) && scp $(QMAKE_TARGET).bin root@192.168.7.2://opt/stm32flashAje/hello.bin | |
5 | beagleCp131.target = beagleCp131 |
|
5 | beagleCp131.target = beagleCp131 | |
6 |
beagleCp131.commands = cd |
|
6 | beagleCp131.commands = cd $(DESTDIR) && scp $(QMAKE_TARGET).bin root@129.104.27.131://opt/stm32flashAje/hello.bin | |
7 | QMAKE_EXTRA_TARGETS += beagleCp beagleCp131 |
|
7 | QMAKE_EXTRA_TARGETS += beagleCp beagleCp131 | |
8 |
|
8 | |||
9 | UCMODEL=stm32f4 |
|
9 | UCMODEL=stm32f4 |
@@ -1,204 +1,204 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the libuc, microcontroler library |
|
2 | -- This file is a part of the libuc, microcontroler library | |
3 | -- Copyright (C) 2013, Alexis Jeandet |
|
3 | -- Copyright (C) 2013, Alexis Jeandet | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | ------------------------------------------------------------------------------- |
|
18 | ------------------------------------------------------------------------------- | |
19 | -- Author : Alexis Jeandet |
|
19 | -- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | -------------------------------------------------------------------------------*/ |
|
21 | -------------------------------------------------------------------------------*/ | |
22 | #include "bsp.h" |
|
22 | #include "bsp.h" | |
23 | #include <streamdevices.h> |
|
23 | #include <streamdevices.h> | |
24 | #include <malloc.h> |
|
24 | #include <malloc.h> | |
25 | #include <gpio.h> |
|
25 | #include <gpio.h> | |
26 | #include <uart.h> |
|
26 | #include <uart.h> | |
27 | #include <stdio.h> |
|
27 | #include <stdio.h> | |
28 | #include <stm32f4xx_gpio.h> |
|
28 | #include <stm32f4xx_gpio.h> | |
29 | #include <stm32f4xx_fsmc.h> |
|
29 | #include <stm32f4xx_fsmc.h> | |
30 | #include <i2c.h> |
|
30 | #include <i2c.h> | |
31 | #include <core.h> |
|
31 | #include <core.h> | |
32 | #include <terminal.h> |
|
32 | #include <terminal.h> | |
33 | #include "bsp_gpio.h" |
|
33 | #include "bsp_gpio.h" | |
34 | #include "bsp_i2c.h" |
|
34 | #include "bsp_i2c.h" | |
35 | #include "bsp_i2c.h" |
|
35 | #include "bsp_i2c.h" | |
36 |
|
36 | |||
37 | uint32_t OSC0 =8000000; |
|
37 | uint32_t OSC0 =8000000; | |
38 | uint32_t INTOSC =16000000; |
|
38 | uint32_t INTOSC =16000000; | |
39 | uint32_t RTCOSC =32768; |
|
39 | uint32_t RTCOSC =32768; | |
40 | uint32_t currentCpuFreq=0; |
|
40 | uint32_t currentCpuFreq=0; | |
41 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; |
|
41 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |
42 | gpio_t TickLed = LED1; |
|
42 | gpio_t TickLed = LED1; | |
43 |
|
43 | |||
44 |
|
44 | |||
45 | LCD_IF_t lcdIF0={ |
|
45 | LCD_IF_t lcdIF0={ | |
46 | .init = &bsp_FSMC_init, |
|
46 | .init = &bsp_FSMC_init, | |
47 | .writereg = &bsp_lcd0_write_reg, |
|
47 | .writereg = &bsp_lcd0_write_reg, | |
48 | .readreg = &bsp_lcd0_read_reg, |
|
48 | .readreg = &bsp_lcd0_read_reg, | |
49 | .writeGRAM = &bsp_lcd0_writeGRAM, |
|
49 | .writeGRAM = &bsp_lcd0_writeGRAM, | |
50 | .readGRAM = &bsp_lcd0_readGRAM |
|
50 | .readGRAM = &bsp_lcd0_readGRAM | |
51 | }; |
|
51 | }; | |
52 |
|
52 | |||
53 | LCD_t lcd0={ |
|
53 | LCD_t lcd0={ | |
54 | .interface = &lcdIF0, |
|
54 | .interface = &lcdIF0, | |
55 | .init = &ili9328init, |
|
55 | .init = &ili9328init, | |
56 | .paint = &ili9328paint, |
|
56 | .paint = &ili9328paint, | |
57 | .paintText = &ili9328paintText, |
|
57 | .paintText = &ili9328paintText, | |
58 | .paintFilRect = &ili9328paintFilRect, |
|
58 | .paintFilRect = &ili9328paintFilRect, | |
59 | .getPix = &ili9328getPix, |
|
59 | .getPix = &ili9328getPix, | |
60 | .refreshenable = &ili9328refreshenable, |
|
60 | .refreshenable = &ili9328refreshenable, | |
61 | .width= 240, |
|
61 | .width= 240, | |
62 | .height = 320 |
|
62 | .height = 320 | |
63 | }; |
|
63 | }; | |
64 |
|
64 | |||
65 | terminal_t terminal0; |
|
65 | terminal_t terminal0; | |
66 |
|
66 | |||
67 |
|
67 | |||
68 |
|
68 | |||
69 | float VREF0 =(float)3.3; |
|
69 | float VREF0 =(float)3.3; | |
70 | volatile vs10XXDev audioCodec0; |
|
70 | volatile vs10XXDev audioCodec0; | |
71 |
|
71 | |||
72 | ADS7843_t TC0; |
|
72 | ADS7843_t TC0; | |
73 |
|
73 | |||
74 | sdcardDev sdcard2; |
|
74 | sdcardDev sdcard2; | |
75 | blkdevice sdcard2blkdev; |
|
75 | blkdevice sdcard2blkdev; | |
76 | dikpartition sdcard2Part1; |
|
76 | dikpartition sdcard2Part1; | |
77 | FAT32fs sdcard2FAT32part1; |
|
77 | FAT32fs sdcard2FAT32part1; | |
78 | dikpartition sdcard2Part2; |
|
78 | dikpartition sdcard2Part2; | |
79 | FAT32fs sdcard2FAT32part2; |
|
79 | FAT32fs sdcard2FAT32part2; | |
80 | dikpartition sdcard2Part3; |
|
80 | dikpartition sdcard2Part3; | |
81 | FAT32fs sdcard2FAT32part3; |
|
81 | FAT32fs sdcard2FAT32part3; | |
82 | dikpartition sdcard2Part4; |
|
82 | dikpartition sdcard2Part4; | |
83 | FAT32fs sdcard2FAT32part4; |
|
83 | FAT32fs sdcard2FAT32part4; | |
84 |
|
84 | |||
85 | int bsp_init() |
|
85 | int bsp_init() | |
86 | { |
|
86 | { | |
87 | int i=0; |
|
87 | int i=0; | |
88 | for(i=0;i<__MAX_OPENED_FILES__;i++) |
|
88 | for(i=0;i<__MAX_OPENED_FILES__;i++) | |
89 | { |
|
89 | { | |
90 | __opnfiles__[i] = NULL; |
|
90 | __opnfiles__[i] = NULL; | |
91 | } |
|
91 | } | |
92 | bsp_GPIO_init(); |
|
92 | bsp_GPIO_init(); | |
93 | bsp_uart_init(); |
|
93 | bsp_uart_init(); | |
94 | bsp_iic_init(); |
|
94 | bsp_iic_init(); | |
95 | bsp_FSMC_init(); |
|
95 | bsp_FSMC_init(); | |
96 | bsp_GTerm_init(); |
|
96 | bsp_GTerm_init(); | |
97 | bsp_spi_init(); |
|
97 | bsp_spi_init(); | |
98 | bsp_SD_init(); |
|
98 | bsp_SD_init(); | |
99 | bsp_Audio_init(); |
|
99 | bsp_Audio_init(); | |
100 | bsp_TC_init(); |
|
100 | bsp_TC_init(); | |
101 | printf("\r=====================\n\r"); |
|
101 | printf("\r=====================\n\r"); | |
102 | printf( "=====================\n\r"); |
|
102 | printf( "=====================\n\r"); | |
103 | printf(BSP); |
|
103 | printf(BSP); | |
104 | printf(" initialised\n\r"); |
|
104 | printf(" initialised\n\r"); | |
105 | printf( "=====================\n\r"); |
|
105 | printf( "=====================\n\r"); | |
106 | #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ |
|
106 | #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ | |
107 | printf( "BIG ENDIAN MACHINE\n\r"); |
|
107 | printf( "BIG ENDIAN MACHINE\n\r"); | |
108 | #else |
|
108 | #else | |
109 | printf( "LITLE ENDIAN MACHINE\n\r"); |
|
109 | printf( "LITLE ENDIAN MACHINE\n\r"); | |
110 | #endif |
|
110 | #endif | |
111 | return 1; |
|
111 | return 1; | |
112 | } |
|
112 | } | |
113 |
|
113 | |||
114 | void bsp_GPIO_init() |
|
114 | void bsp_GPIO_init() | |
115 | { |
|
115 | { | |
116 | gpio_t GPIO_Out_init_List[]={LED1,LED2,LCD_RESET,LCD_BACKL,VS1053xCS,VS1053xDCS,\ |
|
116 | gpio_t GPIO_Out_init_List[]={LED1,LED2,LCD_RESET,LCD_BACKL,VS1053xCS,VS1053xDCS,\ | |
117 | VS1053xRESET,SDCARD2CS,LCD_RS,LCD_CS,TC_CS}; |
|
117 | VS1053xRESET,SDCARD2CS,LCD_RS,LCD_CS,TC_CS}; | |
118 |
|
118 | |||
119 | gpio_t GPIO_In_init_List[]={VS1053DREQ,SDCARD2CD,BP3,TC_BUSY}; |
|
119 | gpio_t GPIO_In_init_List[]={VS1053DREQ,SDCARD2CD,BP3,TC_BUSY}; | |
120 |
|
120 | |||
121 | bsp_gpio_set_outputs(GPIO_Out_init_List,11); |
|
121 | bsp_gpio_set_outputs(GPIO_Out_init_List,11); | |
122 | bsp_gpio_set_inputs(GPIO_In_init_List,4); |
|
122 | bsp_gpio_set_inputs(GPIO_In_init_List,4); | |
123 |
|
123 | |||
124 | gpioclr(VS1053xRESET); |
|
124 | gpioclr(VS1053xRESET); | |
125 | gpioset(VS1053xCS); |
|
125 | gpioset(VS1053xCS); | |
126 | gpioset(VS1053xDCS); |
|
126 | gpioset(VS1053xDCS); | |
127 | gpioset(SDCARD2CS); |
|
127 | gpioset(SDCARD2CS); | |
128 | gpioclr(LCD_RESET); |
|
128 | gpioclr(LCD_RESET); | |
129 | gpioclr(LCD_BACKL); |
|
129 | gpioclr(LCD_BACKL); | |
130 | } |
|
130 | } | |
131 |
|
131 | |||
132 | void bsp_uart_init() |
|
132 | void bsp_uart_init() | |
133 | { |
|
133 | { | |
134 |
|
134 | |||
135 | } |
|
135 | } | |
136 |
|
136 | |||
137 |
|
137 | |||
138 |
|
138 | |||
139 |
|
139 | |||
140 |
|
140 | |||
141 | int bsp_TC_init() |
|
141 | int bsp_TC_init() | |
142 | { |
|
142 | { | |
143 | ads7843init(&TC0,TC_SPI,tcsetncs,tcbusy); |
|
143 | ads7843init(&TC0,TC_SPI,ADS7843_POWER_ADC_ON|ADS7843_MODE_12BITS,tcsetncs,tcbusy); | |
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 |
|
146 | |||
147 |
|
147 | |||
148 |
|
148 | |||
149 | void bsp_iic_init() |
|
149 | void bsp_iic_init() | |
150 | { |
|
150 | { | |
151 | // i2copenandconfig(i2c2,0,10000,PF0,PF1); |
|
151 | // i2copenandconfig(i2c2,0,10000,PF0,PF1); | |
152 | } |
|
152 | } | |
153 |
|
153 | |||
154 |
|
154 | |||
155 |
|
155 | |||
156 |
|
156 | |||
157 | void tcsetncs(char val) |
|
157 | void tcsetncs(char val) | |
158 | { |
|
158 | { | |
159 | if(val) |
|
159 | if(val) | |
160 | gpioset(TC_CS); |
|
160 | gpioset(TC_CS); | |
161 | else |
|
161 | else | |
162 | gpioclr(TC_CS); |
|
162 | gpioclr(TC_CS); | |
163 | } |
|
163 | } | |
164 |
|
164 | |||
165 | int tcbusy() |
|
165 | int tcbusy() | |
166 | { |
|
166 | { | |
167 | return gpiogetval(TC_BUSY); |
|
167 | return gpiogetval(TC_BUSY); | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 |
|
170 | |||
171 |
|
171 | |||
172 |
|
172 | |||
173 |
|
173 | |||
174 | void bsp_GTerm_init() |
|
174 | void bsp_GTerm_init() | |
175 | { |
|
175 | { | |
176 | if(__opnfiles__[1]==NULL) |
|
176 | if(__opnfiles__[1]==NULL) | |
177 | { |
|
177 | { | |
178 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); |
|
178 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
179 | terminal_init(&terminal0 ,&lcd0,&ComicSansMS_8,fd1); |
|
179 | terminal_init(&terminal0 ,&lcd0,&ComicSansMS_8,fd1); | |
180 | terminal_settextColor(&terminal0,0); |
|
180 | terminal_settextColor(&terminal0,0); | |
181 | __opnfiles__[1] = fd1; |
|
181 | __opnfiles__[1] = fd1; | |
182 | } |
|
182 | } | |
183 | else |
|
183 | else | |
184 | { |
|
184 | { | |
185 |
|
185 | |||
186 | } |
|
186 | } | |
187 | } |
|
187 | } | |
188 |
|
188 | |||
189 |
|
189 | |||
190 |
|
190 | |||
191 |
|
191 | |||
192 |
|
192 | |||
193 |
|
193 | |||
194 |
|
194 | |||
195 |
|
195 | |||
196 |
|
196 | |||
197 |
|
197 | |||
198 |
|
198 | |||
199 |
|
199 | |||
200 |
|
200 | |||
201 |
|
201 | |||
202 |
|
202 | |||
203 |
|
203 | |||
204 |
|
204 |
@@ -1,21 +1,22 | |||||
1 | TEMPLATE = subdirs |
|
1 | TEMPLATE = subdirs | |
2 | CONFIG += ordered |
|
2 | CONFIG += ordered | |
3 | SUBDIRS += STM32F4Discovery \ |
|
3 | SUBDIRS += STM32F4Discovery \ | |
4 | M4Stick \ |
|
4 | M4Stick \ | |
5 | M4StickV2 \ |
|
5 | M4StickV2 \ | |
6 | SOLAR_LFR_PSU \ |
|
6 | SOLAR_LFR_PSU \ | |
7 | BEAGLESYNTH \ |
|
7 | BEAGLESYNTH \ | |
8 | STM32F4Eval \ |
|
8 | STM32F4Eval \ | |
9 | STM32F4Discovery-EXT \ |
|
9 | STM32F4Discovery-EXT \ | |
10 | STM32F4Discovery-ILI9328-8bits \ |
|
10 | STM32F4Discovery-ILI9328-8bits \ | |
11 | OPLAYER \ |
|
11 | OPLAYER \ | |
12 | STM32-E407 \ |
|
12 | STM32-E407 \ | |
13 | STM32F429Discovery \ |
|
13 | STM32F429Discovery \ | |
14 | STM32F4Discovery_35LCD |
|
14 | STM32F4Discovery_35LCD \ | |
|
15 | SOSmartPSU | |||
15 |
|
16 | |||
16 |
|
17 | |||
17 |
|
18 | |||
18 |
|
19 | |||
19 |
|
20 | |||
20 |
|
21 | |||
21 |
|
22 |
@@ -1,19 +1,20 | |||||
1 | TEMPLATE = app |
|
1 | TEMPLATE = app | |
2 |
|
2 | |||
3 | contains( UCMODEL , simulator ) { |
|
3 | contains( UCMODEL , simulator ) { | |
4 | BSP = SIMULATOR |
|
4 | BSP = SIMULATOR | |
5 | } |
|
5 | } | |
6 | contains( UCMODEL , stm32f4 ) { |
|
6 | contains( UCMODEL , stm32f4 ) { | |
7 | BSP = STM32F4Eval |
|
7 | #BSP = STM32F4Eval | |
|
8 | BSP = SOSmartPSU | |||
8 | } |
|
9 | } | |
9 |
|
10 | |||
10 | SOURCES += \ |
|
11 | SOURCES += \ | |
11 | main.c |
|
12 | main.c | |
12 |
|
13 | |||
13 |
|
14 | |||
14 |
|
15 | |||
15 |
|
16 | |||
16 |
|
17 | |||
17 |
|
18 | |||
18 |
|
19 | |||
19 |
|
20 |
@@ -1,110 +1,139 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the libuc, microcontroler library |
|
2 | -- This file is a part of the libuc, microcontroler library | |
3 | -- Copyright (C) 2012, Alexis Jeandet |
|
3 | -- Copyright (C) 2012, Alexis Jeandet | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | ------------------------------------------------------------------------------- |
|
18 | ------------------------------------------------------------------------------- | |
19 | -- Author : Alexis Jeandet |
|
19 | -- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@gmail.com |
|
20 | -- Mail : alexis.jeandet@gmail.com | |
21 | -------------------------------------------------------------------------------*/ |
|
21 | -------------------------------------------------------------------------------*/ | |
22 | #ifndef D51E5TA7601_H |
|
22 | #ifndef D51E5TA7601_H | |
23 | #define D51E5TA7601_H |
|
23 | #define D51E5TA7601_H | |
24 |
|
24 | |||
25 | /** |
|
25 | /** | |
26 | @todo Make an abstract layer for framebuffer devices and a painting api for it. |
|
26 | @todo Make an abstract layer for framebuffer devices and a painting api for it. | |
27 | */ |
|
27 | */ | |
28 |
|
28 | |||
29 |
|
29 | |||
30 | #include <genericLCD_Controler.h> |
|
30 | #include <genericLCD_Controler.h> | |
31 |
|
31 | |||
32 | /** |
|
32 | /** | |
33 | * @brief ili9328init |
|
33 | * @brief ili9328init | |
34 | * @param LCD |
|
34 | * @param LCD | |
35 | * @return |
|
35 | * @return | |
36 | */ |
|
36 | */ | |
37 |
|
37 | |||
38 | extern int D51E5TA7601init(struct LCD_t* LCD); |
|
38 | extern int D51E5TA7601init(struct LCD_t* LCD); | |
39 | extern void D51E5TA7601setFrame(LCD_t* LCD,uint16_t X,uint16_t Y,uint16_t W,uint16_t H); |
|
39 | extern void D51E5TA7601setFrame(LCD_t* LCD,uint16_t X,uint16_t Y,uint16_t W,uint16_t H); | |
40 | extern void D51E5TA7601setGRAMaddress(LCD_t* LCD,uint16_t Haddress,uint16_t Vaddress); |
|
40 | extern void D51E5TA7601setGRAMaddress(LCD_t* LCD,uint16_t Haddress,uint16_t Vaddress); | |
41 | extern void D51E5TA7601paint(LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height); |
|
41 | extern void D51E5TA7601paint(LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height); | |
|
42 | extern void D51E5TA7601paintFB(struct LCD_t* LCD,struct LCD_t* frameBuffer); | |||
42 | extern void D51E5TA7601paintText(LCD_t* LCD,char* buffer,uint16_t Xpos,uint16_t Ypos,sFONT *font,uint32_t color); |
|
43 | extern void D51E5TA7601paintText(LCD_t* LCD,char* buffer,uint16_t Xpos,uint16_t Ypos,sFONT *font,uint32_t color); | |
43 | extern void D51E5TA7601paintFilRect(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h,uint32_t contColor,uint16_t contSz,uint32_t fillColor); |
|
44 | extern void D51E5TA7601paintFilRect(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h,uint32_t contColor,uint16_t contSz,uint32_t fillColor); | |
44 | extern void D51E5TA7601paintFilCirc(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor); |
|
45 | extern void D51E5TA7601paintFilCirc(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor); | |
45 | extern void D51E5TA7601paintFilCircMidPoint(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor); |
|
46 | extern void D51E5TA7601paintFilCircMidPoint(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor); | |
46 | extern void D51E5TA7601getPix(struct LCD_t* LCD,uint16_t* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h); |
|
47 | extern void D51E5TA7601getPix(struct LCD_t* LCD,uint16_t* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h); | |
47 | extern void D51E5TA7601refreshenable(struct LCD_t* LCD,int enable); |
|
48 | extern void D51E5TA7601refreshenable(struct LCD_t* LCD,int enable); | |
48 | extern void D51E5TA7601paintChar(LCD_t* LCD,char buffer,uint16_t Xpos,uint16_t Ypos,sFONT* font,uint32_t color); |
|
49 | extern void D51E5TA7601paintChar(LCD_t* LCD,char buffer,uint16_t Xpos,uint16_t Ypos,sFONT* font,uint32_t color); | |
49 |
|
50 | |||
50 | #define ILI9328_REGISTER_DRIVERCODEREAD ((uint32_t) 0x0000 ) |
|
51 | ||
51 | #define ILI9328_REGISTER_DRIVEROUTPUTCONTROL1 ((uint32_t) 0x0001 ) |
|
52 | ||
52 | #define ILI9328_REGISTER_LCDDRIVINGCONTROL ((uint32_t) 0x0002 ) |
|
53 | extern int D51E5TA7601init_FrameBuff(struct LCD_t* LCD); | |
53 | #define ILI9328_REGISTER_ENTRYMODE ((uint32_t) 0x0003 ) |
|
54 | extern void D51E5TA7601setFrame_FrameBuff(LCD_t* LCD,uint16_t X,uint16_t Y,uint16_t W,uint16_t H); | |
54 | #define ILI9328_REGISTER_RESIZECONTROL ((uint32_t) 0x0004 ) |
|
55 | extern void D51E5TA7601paint_FrameBuff(LCD_t *frameBuff, void *buffer, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); | |
55 | #define ILI9328_REGISTER_DISPLAYCONTROL1 ((uint32_t) 0x0007 ) |
|
56 | extern void D51E5TA7601paintText_FrameBuff(LCD_t *frameBuff,char* buffer,uint16_t Xpos,uint16_t Ypos,sFONT *font,uint32_t color); | |
56 | #define ILI9328_REGISTER_DISPLAYCONTROL2 ((uint32_t) 0x0008 ) |
|
57 | extern void D51E5TA7601paintFilRect_FrameBuff(LCD_t *frameBuff,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h,uint32_t contColor,uint16_t contSz,uint32_t fillColor); | |
57 | #define ILI9328_REGISTER_DISPLAYCONTROL3 ((uint32_t) 0x0009 ) |
|
58 | extern void D51E5TA7601getPix_FrameBuff(LCD_t *frameBuff,uint16_t* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h); | |
58 | #define ILI9328_REGISTER_DISPLAYCONTROL4 ((uint32_t) 0x000A ) |
|
59 | extern void D51E5TA7601refreshenable_FrameBuff(struct LCD_t* LCD,int enable); | |
59 | #define ILI9328_REGISTER_RGBDISPLAYINTERFACECONTROL1 ((uint32_t) 0x000C ) |
|
60 | ||
60 | #define ILI9328_REGISTER_FRAMEMAKERPOSITION ((uint32_t) 0x000D ) |
|
61 | ||
61 | #define ILI9328_REGISTER_RGBDISPLAYINTERFACECONTROL2 ((uint32_t) 0x000F ) |
|
62 | ||
62 | #define ILI9328_REGISTER_POWERCONTROL1 ((uint32_t) 0x0010 ) |
|
63 | #define D51E5TA7601_DEV_ID ((uint32_t) 0x7601 ) | |
63 | #define ILI9328_REGISTER_POWERCONTROL2 ((uint32_t) 0x0011 ) |
|
64 | ||
64 |
#define |
|
65 | #define D51E5TA7601_REGISTER_DRIVERCODEREAD ((uint32_t) 0x0000 ) | |
65 |
#define |
|
66 | #define D51E5TA7601_REGISTER_STARTOSCILATION ((uint32_t) 0x0000 ) | |
66 |
#define |
|
67 | #define D51E5TA7601_REGISTER_DRIVEROUTPUTCONTROL1 ((uint32_t) 0x0001 ) | |
67 |
#define |
|
68 | #define D51E5TA7601_REGISTER_LCDDRIVINGCONTROL ((uint32_t) 0x0002 ) | |
68 |
#define |
|
69 | #define D51E5TA7601_REGISTER_ENTRYMODE ((uint32_t) 0x0003 ) | |
69 |
#define |
|
70 | #define D51E5TA7601_REGISTER_DISPLAYCONTROL1 ((uint32_t) 0x0004 ) | |
70 |
#define |
|
71 | #define D51E5TA7601_REGISTER_DISPLAYCONTROL2 ((uint32_t) 0x0005 ) | |
71 |
#define |
|
72 | #define D51E5TA7601_REGISTER_DISPLAYCONTROL3 ((uint32_t) 0x0006 ) | |
72 |
#define |
|
73 | #define D51E5TA7601_REGISTER_DISPLAYCONTROL4 ((uint32_t) 0x0007 ) | |
73 |
#define |
|
74 | #define D51E5TA7601_REGISTER_BLANKPERDIODCTRL ((uint32_t) 0x0008 ) | |
74 |
#define |
|
75 | #define D51E5TA7601_REGISTER_DISPLAYCONTROL5 ((uint32_t) 0x0009 ) | |
75 |
#define |
|
76 | #define D51E5TA7601_REGISTER_FRAMECYCLECONTROL ((uint32_t) 0x000A ) | |
76 |
#define |
|
77 | #define D51E5TA7601_REGISTER_EXTERNALDISPLAYCTRL ((uint32_t) 0x000B ) | |
77 |
#define |
|
78 | #define D51E5TA7601_REGISTER_LCDINTERFACECONTROL ((uint32_t) 0x000C ) | |
78 |
#define |
|
79 | #define D51E5TA7601_REGISTER_GATESCANPOSITIONCTRL ((uint32_t) 0x000D ) | |
79 |
#define |
|
80 | #define D51E5TA7601_REGISTER_FRAMESIGNALCONTROL ((uint32_t) 0x000E ) | |
80 |
#define |
|
81 | #define D51E5TA7601_REGISTER_DISPLAYCONTROL6 ((uint32_t) 0x000F ) | |
81 | #define ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION ((uint32_t) 0x0050 ) |
|
82 | #define D51E5TA7601_REGISTER_POWERCONTROL1 ((uint32_t) 0x0010 ) | |
82 | #define ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION ((uint32_t) 0x0051 ) |
|
83 | #define D51E5TA7601_REGISTER_POWERCONTROL2 ((uint32_t) 0x0011 ) | |
83 | #define ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION ((uint32_t) 0x0052 ) |
|
84 | #define D51E5TA7601_REGISTER_POWERCONTROL3 ((uint32_t) 0x0012 ) | |
84 |
#define |
|
85 | #define D51E5TA7601_REGISTER_POWERCONTROL4 ((uint32_t) 0x0013 ) | |
85 |
#define |
|
86 | #define D51E5TA7601_REGISTER_POWERCONTROL5 ((uint32_t) 0x0014 ) | |
86 |
#define |
|
87 | #define D51E5TA7601_REGISTER_POWERCONTROL6 ((uint32_t) 0x0015 ) | |
87 |
#define |
|
88 | #define D51E5TA7601_REGISTER_POWERCONTROL7 ((uint32_t) 0x0016 ) | |
88 |
#define |
|
89 | #define D51E5TA7601_REGISTER_VERTICALGRAMADDRESSSET ((uint32_t) 0x0020 ) | |
89 |
#define |
|
90 | #define D51E5TA7601_REGISTER_HORIZONTALGRAMADDRESSSET ((uint32_t) 0x0021 ) | |
90 |
#define |
|
91 | #define D51E5TA7601_REGISTER_WRITEDATATOGRAM ((uint32_t) 0x0022 ) | |
91 | #define ILI9328_REGISTER_PARTIALIMAGE2DISPLAYPOSITION ((uint32_t) 0x0083 ) |
|
92 | ||
92 |
#define |
|
93 | #define D51E5TA7601_REGISTER_GAMMACONTROL1 ((uint32_t) 0x0028 ) | |
93 |
#define |
|
94 | #define D51E5TA7601_REGISTER_GAMMACONTROL2 ((uint32_t) 0x0029 ) | |
94 |
#define |
|
95 | #define D51E5TA7601_REGISTER_GAMMACONTROL3 ((uint32_t) 0x002A) | |
95 |
#define |
|
96 | #define D51E5TA7601_REGISTER_GAMMACONTROL4 ((uint32_t) 0x002B ) | |
96 |
#define |
|
97 | #define D51E5TA7601_REGISTER_GAMMACONTROL5 ((uint32_t) 0x002C ) | |
97 |
#define |
|
98 | #define D51E5TA7601_REGISTER_GAMMACONTROL6 ((uint32_t) 0x002D ) | |
98 |
#define |
|
99 | #define D51E5TA7601_REGISTER_GAMMACONTROL7 ((uint32_t) 0x002E ) | |
99 |
#define |
|
100 | #define D51E5TA7601_REGISTER_GAMMACONTROL8 ((uint32_t) 0x002F ) | |
|
101 | #define D51E5TA7601_REGISTER_GAMMACONTROL9 ((uint32_t) 0x0030 ) | |||
|
102 | #define D51E5TA7601_REGISTER_GAMMACONTROL10 ((uint32_t) 0x0031 ) | |||
|
103 | #define D51E5TA7601_REGISTER_GAMMACONTROL11 ((uint32_t) 0x0032 ) | |||
|
104 | #define D51E5TA7601_REGISTER_GAMMACONTROL12 ((uint32_t) 0x0033 ) | |||
|
105 | #define D51E5TA7601_REGISTER_GAMMACONTROL13 ((uint32_t) 0x0034 ) | |||
|
106 | #define D51E5TA7601_REGISTER_GAMMACONTROL14 ((uint32_t) 0x0035 ) | |||
|
107 | #define D51E5TA7601_REGISTER_GAMMACONTROL15 ((uint32_t) 0x0036 ) | |||
|
108 | #define D51E5TA7601_REGISTER_GAMMACONTROL16 ((uint32_t) 0x0037 ) | |||
|
109 | #define D51E5TA7601_REGISTER_GAMMACONTROL17 ((uint32_t) 0x0038 ) | |||
|
110 | #define D51E5TA7601_REGISTER_GAMMACONTROL18 ((uint32_t) 0x0039 ) | |||
|
111 | #define D51E5TA7601_REGISTER_GAMMACONTROL19 ((uint32_t) 0x003A ) | |||
|
112 | #define D51E5TA7601_REGISTER_GAMMACONTROL20 ((uint32_t) 0x003B ) | |||
|
113 | #define D51E5TA7601_REGISTER_GAMMACONTROL21 ((uint32_t) 0x003C ) | |||
|
114 | #define D51E5TA7601_REGISTER_PARTIALSPLTSCREENS1 ((uint32_t) 0x0040 ) | |||
|
115 | #define D51E5TA7601_REGISTER_PARTIALSPLTSCREENE1 ((uint32_t) 0x0041 ) | |||
|
116 | #define D51E5TA7601_REGISTER_PARTIALSPLTSCREENS2 ((uint32_t) 0x0042 ) | |||
|
117 | #define D51E5TA7601_REGISTER_PARTIALSPLTSCREENE2 ((uint32_t) 0x0043 ) | |||
|
118 | #define D51E5TA7601_REGISTER_HORIZONTALADDRESSSTARTPOSITION ((uint32_t) 0x0045 ) | |||
|
119 | #define D51E5TA7601_REGISTER_HORIZONTALADDRESSENDPOSITION ((uint32_t) 0x0044 ) | |||
|
120 | #define D51E5TA7601_REGISTER_VERTICALADDRESSSTARTPOSITION ((uint32_t) 0x0047 ) | |||
|
121 | #define D51E5TA7601_REGISTER_VERTICALADDRESSENDPOSITION ((uint32_t) 0x0046 ) | |||
|
122 | #define D51E5TA7601_REGISTER_BACKLIGHTCONTROL1 ((uint32_t) 0x0048 ) | |||
|
123 | #define D51E5TA7601_REGISTER_BACKLIGHTCONTROL2 ((uint32_t) 0x0049 ) | |||
|
124 | #define D51E5TA7601_REGISTER_BACKLIGHTCONTROL3 ((uint32_t) 0x004A ) | |||
|
125 | #define D51E5TA7601_REGISTER_BACKLIGHTCONTROL4 ((uint32_t) 0x004B ) | |||
|
126 | #define D51E5TA7601_REGISTER_VCOMCONTROL1 ((uint32_t) 0x0050 ) | |||
|
127 | #define D51E5TA7601_REGISTER_VCOMCONTROL2 ((uint32_t) 0x0051 ) | |||
|
128 | #define D51E5TA7601_REGISTER_CABCCONTROL ((uint32_t) 0x0067 ) | |||
100 |
|
129 | |||
101 | #ifdef _PRVATE_D51E5TA7601_ |
|
130 | #ifdef _PRVATE_D51E5TA7601_ | |
102 | void ili9328cpFrame(LCD_t* LCD,void* buffer,int x,int y,int w, int h); |
|
131 | void ili9328cpFrame(LCD_t* LCD,void* buffer,int x,int y,int w, int h); | |
103 | #endif |
|
132 | #endif | |
104 |
|
133 | |||
105 | #endif |
|
134 | #endif | |
106 |
|
135 | |||
107 |
|
136 | |||
108 |
|
137 | |||
109 |
|
138 | |||
110 |
|
139 |
@@ -1,75 +1,86 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the libuc, microcontroler library |
|
2 | -- This file is a part of the libuc, microcontroler library | |
3 | -- Copyright (C) 2012, Alexis Jeandet |
|
3 | -- Copyright (C) 2012, Alexis Jeandet | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | ------------------------------------------------------------------------------- |
|
18 | ------------------------------------------------------------------------------- | |
19 | -- Author : Alexis Jeandet |
|
19 | -- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@gmail.com |
|
20 | -- Mail : alexis.jeandet@gmail.com | |
21 | -------------------------------------------------------------------------------*/ |
|
21 | -------------------------------------------------------------------------------*/ | |
22 | #ifndef GENERICLCD_CONTROLER_H |
|
22 | #ifndef GENERICLCD_CONTROLER_H | |
23 | #define GENERICLCD_CONTROLER_H |
|
23 | #define GENERICLCD_CONTROLER_H | |
24 |
|
24 | |||
25 | #include <uhandle.h> |
|
25 | #include <uhandle.h> | |
26 | #include <fonts.h> |
|
26 | #include <fonts.h> | |
27 |
|
27 | |||
28 |
|
28 | |||
29 | typedef struct LCD_IF_t |
|
29 | typedef struct LCD_IF_t | |
30 | { |
|
30 | { | |
31 | int (*init)(); |
|
31 | int (*init)(); | |
|
32 | uint32_t (*status)(); | |||
32 | void (*writereg)(uint32_t reg,uint32_t data); |
|
33 | void (*writereg)(uint32_t reg,uint32_t data); | |
33 | uint32_t (*readreg)(uint32_t reg); |
|
34 | uint32_t (*readreg)(uint32_t reg); | |
34 | void (*writeGRAM)(void* buffer,uint32_t count); |
|
35 | void (*writeGRAM)(void* buffer,uint32_t count); | |
35 | void (*readGRAM)(void* buffer,uint32_t count); |
|
36 | void (*readGRAM)(void* buffer,uint32_t count); | |
36 | }LCD_IF_t; |
|
37 | }LCD_IF_t; | |
37 |
|
38 | |||
38 | /** |
|
39 | /** | |
39 | * @brief Lcd buffer |
|
40 | * @brief Lcd buffer | |
40 | * |
|
41 | * | |
41 | * This structure contains a W width an H height buffer poiter to be copied to the screen at X;Y position. |
|
42 | * This structure contains a W width an H height buffer poiter to be copied to the screen at X;Y position. | |
42 | */ |
|
43 | */ | |
43 |
|
44 | |||
44 | typedef struct LCD_BUFFER_t |
|
45 | typedef struct LCD_BUFFER_t | |
45 | { |
|
46 | { | |
46 | void* buffer; /**< Buffer pointer write on pixels you want to print*/ |
|
47 | volatile void* buffer; /**< Buffer pointer write on pixels you want to print*/ | |
47 | uint32_t size; /**< The size of the buffer in bytes*/ |
|
48 | uint32_t size; /**< The size of the buffer in bytes*/ | |
48 | uint16_t X; /**< The X position of the buffer*/ |
|
49 | uint16_t X; /**< The X position of the buffer*/ | |
49 | uint16_t Y; /**< The Y position of the buffer*/ |
|
50 | uint16_t Y; /**< The Y position of the buffer*/ | |
50 | uint16_t W; /**< The width of the buffer*/ |
|
51 | uint16_t W; /**< The width of the buffer*/ | |
51 | uint16_t H; /**< The height of the buffer*/ |
|
52 | uint16_t H; /**< The height of the buffer*/ | |
52 | }LCD_BUFFER_t; |
|
53 | }LCD_BUFFER_t; | |
53 |
|
54 | |||
|
55 | typedef union interface_u | |||
|
56 | { | |||
|
57 | LCD_IF_t* lcd_interface; | |||
|
58 | volatile void* buffer; | |||
|
59 | }interface_u; | |||
|
60 | ||||
54 | typedef struct LCD_t |
|
61 | typedef struct LCD_t | |
55 | { |
|
62 | { | |
56 | LCD_IF_t* interface; |
|
63 | // LCD_IF_t* interface; | |
|
64 | interface_u interface; | |||
57 | int (*init)(struct LCD_t* LCD); |
|
65 | int (*init)(struct LCD_t* LCD); | |
58 | void (*paint)(struct LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height); |
|
66 | void (*paint)(struct LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height); | |
|
67 | void (*paintFB)(struct LCD_t* LCD,struct LCD_t* frameBuffer); | |||
|
68 | void (*setFrame)(struct LCD_t* LCD,uint16_t X,uint16_t Y,uint16_t W,uint16_t H); | |||
59 | void (*paintText)(struct LCD_t* LCD,char* buffer,uint16_t Xpos,uint16_t Ypos,sFONT *font,uint32_t color); |
|
69 | void (*paintText)(struct LCD_t* LCD,char* buffer,uint16_t Xpos,uint16_t Ypos,sFONT *font,uint32_t color); | |
60 | void (*paintFilRect)(struct LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h,uint32_t contColor,uint16_t contSz,uint32_t fillColor); |
|
70 | void (*paintFilRect)(struct LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h,uint32_t contColor,uint16_t contSz,uint32_t fillColor); | |
61 | void (*getPix)(struct LCD_t* LCD,uint16_t* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h); |
|
71 | void (*getPix)(struct LCD_t* LCD,uint16_t* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h); | |
62 | void (*refreshenable)(struct LCD_t* LCD,int enable); |
|
72 | void (*refreshenable)(struct LCD_t* LCD,int enable); | |
63 | LCD_BUFFER_t* (*getBuffer)(struct LCD_t* LCD); |
|
73 | // LCD_BUFFER_t* (*getBuffer)(struct LCD_t* LCD); | |
64 | void (*writeBuffer)(struct LCD_t* LCD,LCD_BUFFER_t* buffer); |
|
74 | void (*writeBuffer)(struct LCD_t* LCD,LCD_BUFFER_t* buffer); | |
65 | uint16_t width; |
|
75 | uint16_t width; | |
66 | uint16_t height; |
|
76 | uint16_t height; | |
|
77 | char isFrameBuffer; | |||
67 | }LCD_t; |
|
78 | }LCD_t; | |
68 |
|
79 | |||
69 |
|
80 | |||
70 | #endif /*GENERICLCD_CONTROLER_H*/ |
|
81 | #endif /*GENERICLCD_CONTROLER_H*/ | |
71 |
|
82 | |||
72 |
|
83 | |||
73 |
|
84 | |||
74 |
|
85 | |||
75 |
|
86 |
@@ -1,60 +1,102 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the libuc, microcontroler library |
|
2 | -- This file is a part of the libuc, microcontroler library | |
3 | -- Copyright (C) 2013, Alexis Jeandet |
|
3 | -- Copyright (C) 2013, Alexis Jeandet | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | ------------------------------------------------------------------------------- |
|
18 | ------------------------------------------------------------------------------- | |
19 | -- Author : Alexis Jeandet |
|
19 | -- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | -------------------------------------------------------------------------------*/ |
|
21 | -------------------------------------------------------------------------------*/ | |
22 | #ifndef STMPE811_H |
|
22 | #ifndef STMPE811_H | |
23 | #define STMPE811_H |
|
23 | #define STMPE811_H | |
24 | #include <stdio.h> |
|
24 | #include <stdio.h> | |
25 | #include <genericTC_Controler.h> |
|
25 | #include <genericTC_Controler.h> | |
26 | #include <spi.h> |
|
26 | #include <spi.h> | |
27 |
|
27 | |||
|
28 | #define ADS7843_CONFIG_MASK 0x0F | |||
|
29 | #define ADS7843_MODE_8BITS 0x08 | |||
|
30 | #define ADS7843_MODE_12BITS 0x00 | |||
|
31 | #define ADS7843_REFMODE_SINGLE 0x04 | |||
|
32 | #define ADS7843_REFMODE_DIFF 0x00 | |||
|
33 | #define ADS7843_POWER_ADC_ON 0x01 | |||
|
34 | #define ADS7843_POWER_ADC_OFF 0x00 | |||
|
35 | #define ADS7843_POWER_REF_ON 0x02 | |||
|
36 | #define ADS7843_POWER_REF_OFF 0x00 | |||
|
37 | #define ADS7843_START 0x80 | |||
|
38 | #define ADS7843_MEAS_X_POS 0x50 | |||
|
39 | #define ADS7843_MEAS_Y_POS 0x10 | |||
|
40 | #define ADS7843_MEAS_Z1_POS 0x30 | |||
|
41 | #define ADS7843_MEAS_Z2_POS 0x40 | |||
|
42 | ||||
|
43 | #define ADS7843_MEAS_X_POS_SINGLE (ADS7843_MEAS_X_POS |ADS7843_REFMODE_SINGLE) | |||
|
44 | #define ADS7843_MEAS_Y_POS_SINGLE (ADS7843_MEAS_Y_POS |ADS7843_REFMODE_SINGLE) | |||
|
45 | #define ADS7843_MEAS_Z1_POS_SINGLE (ADS7843_MEAS_Z1_POS|ADS7843_REFMODE_SINGLE) | |||
|
46 | #define ADS7843_MEAS_Z2_POS_SINGLE (ADS7843_MEAS_Z2_POS|ADS7843_REFMODE_SINGLE) | |||
|
47 | #define ADS7843_MEAS_TEMP0_SINGLE ( 0x00 |ADS7843_REFMODE_SINGLE) | |||
|
48 | #define ADS7843_MEAS_TEMP1_SINGLE ( 0x70 |ADS7843_REFMODE_SINGLE) | |||
|
49 | #define ADS7843_MEAS_AUX_SINGLE ( 0x60 |ADS7843_REFMODE_SINGLE) | |||
|
50 | #define ADS7843_MEAS_VBAT_SINGLE ( 0x20 |ADS7843_REFMODE_SINGLE) | |||
|
51 | #define ADS7843_MEAS_Z2_POS_SINGLE (ADS7843_MEAS_Z2_POS|ADS7843_REFMODE_SINGLE) | |||
|
52 | ||||
|
53 | #define ADS7843_MEAS_X_POS_DIFF (ADS7843_MEAS_X_POS |ADS7843_REFMODE_DIFF) | |||
|
54 | #define ADS7843_MEAS_Y_POS_DIFF (ADS7843_MEAS_Y_POS |ADS7843_REFMODE_DIFF) | |||
|
55 | #define ADS7843_MEAS_Z1_POS_DIFF (ADS7843_MEAS_Z1_POS|ADS7843_REFMODE_DIFF) | |||
|
56 | #define ADS7843_MEAS_Z2_POS_DIFF (ADS7843_MEAS_Z2_POS|ADS7843_REFMODE_DIFF) | |||
|
57 | ||||
28 | typedef struct ADS7843_t |
|
58 | typedef struct ADS7843_t | |
29 | { |
|
59 | { | |
30 | spi_t spidev; |
|
60 | spi_t spidev; | |
31 | void (*setnCS)(char); |
|
61 | void (*setnCS)(char); | |
32 | int (*busy)(); |
|
62 | int (*busy)(); | |
|
63 | char config; | |||
|
64 | uint16_t zeroX; | |||
|
65 | uint16_t zeroY; | |||
|
66 | uint16_t zeroRtouch; | |||
|
67 | uint16_t xMin; | |||
|
68 | uint16_t xMax; | |||
|
69 | uint16_t yMin; | |||
|
70 | uint16_t yMax; | |||
|
71 | char delta; | |||
33 | }ADS7843_t; |
|
72 | }ADS7843_t; | |
34 |
|
73 | |||
35 |
|
74 | |||
36 | extern int ads7843init(ADS7843_t *dev, spi_t spidev,void (*setnCS)(char),int (*busy)()); |
|
75 | extern int ads7843init(ADS7843_t *dev, spi_t spidev,char config,void (*setnCS)(char),int (*busy)()); | |
37 | extern int ads7843read(ADS7843_t *dev,int* x,int* y); |
|
76 | extern int ads7843read(ADS7843_t *dev,int* x,int* y); | |
|
77 | extern int ads7843readRtouch(ADS7843_t *dev); | |||
|
78 | extern int ads7843calibrate(ADS7843_t *dev,uint16_t zeroX,uint16_t zeroY,uint16_t zeroRtouch,uint16_t xMin,uint16_t xMax,uint16_t yMin,uint16_t yMax,char delta); | |||
|
79 | extern int ads7843isPenTouching(ADS7843_t *dev); | |||
38 |
|
80 | |||
39 |
|
81 | |||
40 |
|
82 | |||
41 | #endif |
|
83 | #endif | |
42 |
|
84 | |||
43 |
|
85 | |||
44 |
|
86 | |||
45 |
|
87 | |||
46 |
|
88 | |||
47 |
|
89 | |||
48 |
|
90 | |||
49 |
|
91 | |||
50 |
|
92 | |||
51 |
|
93 | |||
52 |
|
94 | |||
53 |
|
95 | |||
54 |
|
96 | |||
55 |
|
97 | |||
56 |
|
98 | |||
57 |
|
99 | |||
58 |
|
100 | |||
59 |
|
101 | |||
60 |
|
102 |
@@ -1,9 +1,9 | |||||
1 | CPU=stm32f4xxxG |
|
1 | CPU=stm32f4xxxG | |
2 | DEFINES+=BSP=\\\"BEAGLESYNTH\\\" |
|
2 | DEFINES+=BSP=\\\"BEAGLESYNTH\\\" | |
3 | beagleCp.target = beagleCp |
|
3 | beagleCp.target = beagleCp | |
4 |
beagleCp.commands = cd |
|
4 | beagleCp.commands = cd $(DESTDIR) && scp $(QMAKE_TARGET).bin root@192.168.7.2://opt/stm32flashAje/hello.bin | |
5 | beagleCp131.target = beagleCp131 |
|
5 | beagleCp131.target = beagleCp131 | |
6 |
beagleCp131.commands = cd |
|
6 | beagleCp131.commands = cd $(DESTDIR) && scp $(QMAKE_TARGET).bin root@129.104.27.131://opt/stm32flashAje/hello.bin | |
7 | QMAKE_EXTRA_TARGETS += beagleCp beagleCp131 |
|
7 | QMAKE_EXTRA_TARGETS += beagleCp beagleCp131 | |
8 |
|
8 | |||
9 | UCMODEL=stm32f4 |
|
9 | UCMODEL=stm32f4 |
@@ -1,2 +1,2 | |||||
1 | LIBS+= -lterminal -lfonts -lili9328 -lssd2119 -lADS7843 -lSTMPE811 |
|
1 | LIBS+= -lterminal -lfonts -lD51E5TA7601 -lili9328 -lssd2119 -lADS7843 -lSTMPE811 | |
2 |
|
2 |
@@ -1,358 +1,358 | |||||
1 | /* File: startup_ARMCM4.S |
|
1 | /* File: startup_ARMCM4.S | |
2 | * Purpose: startup file for Cortex-M4 devices. Should use with |
|
2 | * Purpose: startup file for Cortex-M4 devices. Should use with | |
3 | * GCC for ARM Embedded Processors |
|
3 | * GCC for ARM Embedded Processors | |
4 | * Version: V2.0 |
|
4 | * Version: V2.0 | |
5 | * Date: 16 August 2013 |
|
5 | * Date: 16 August 2013 | |
6 | * |
|
6 | * | |
7 | /* Copyright (c) 2011 - 2013 ARM LIMITED |
|
7 | /* Copyright (c) 2011 - 2013 ARM LIMITED | |
8 |
|
8 | |||
9 | All rights reserved. |
|
9 | All rights reserved. | |
10 | Redistribution and use in source and binary forms, with or without |
|
10 | Redistribution and use in source and binary forms, with or without | |
11 | modification, are permitted provided that the following conditions are met: |
|
11 | modification, are permitted provided that the following conditions are met: | |
12 | - Redistributions of source code must retain the above copyright |
|
12 | - Redistributions of source code must retain the above copyright | |
13 | notice, this list of conditions and the following disclaimer. |
|
13 | notice, this list of conditions and the following disclaimer. | |
14 | - Redistributions in binary form must reproduce the above copyright |
|
14 | - Redistributions in binary form must reproduce the above copyright | |
15 | notice, this list of conditions and the following disclaimer in the |
|
15 | notice, this list of conditions and the following disclaimer in the | |
16 | documentation and/or other materials provided with the distribution. |
|
16 | documentation and/or other materials provided with the distribution. | |
17 | - Neither the name of ARM nor the names of its contributors may be used |
|
17 | - Neither the name of ARM nor the names of its contributors may be used | |
18 | to endorse or promote products derived from this software without |
|
18 | to endorse or promote products derived from this software without | |
19 | specific prior written permission. |
|
19 | specific prior written permission. | |
20 | * |
|
20 | * | |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
|
24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE | |
25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
31 | POSSIBILITY OF SUCH DAMAGE. |
|
31 | POSSIBILITY OF SUCH DAMAGE. | |
32 | ---------------------------------------------------------------------------*/ |
|
32 | ---------------------------------------------------------------------------*/ | |
33 | /* |
|
33 | /* | |
34 | 2013 Modified for libuc2 use by Alexis Jeandet. |
|
34 | 2013 Modified for libuc2 use by Alexis Jeandet. | |
35 | */ |
|
35 | */ | |
36 | .syntax unified |
|
36 | .syntax unified | |
37 | .cpu cortex-m4 |
|
37 | .cpu cortex-m4 | |
38 | .fpu fpv4-sp-d16 |
|
38 | .fpu fpv4-sp-d16 | |
39 |
|
39 | |||
40 | .section .stack |
|
40 | .section .stack | |
41 |
.align |
|
41 | .align 3 | |
42 | #ifdef __STACK_SIZE |
|
42 | #ifdef __STACK_SIZE | |
43 | .equ Stack_Size, __STACK_SIZE |
|
43 | .equ Stack_Size, __STACK_SIZE | |
44 | #else |
|
44 | #else | |
45 | .equ Stack_Size, 0x7F00 |
|
45 | .equ Stack_Size, 0x7F00 | |
46 | #endif |
|
46 | #endif | |
47 | .globl __StackTop |
|
47 | .globl __StackTop | |
48 | .globl __StackLimit |
|
48 | .globl __StackLimit | |
49 | __StackLimit: |
|
49 | __StackLimit: | |
50 | .space Stack_Size |
|
50 | .space Stack_Size | |
51 | .size __StackLimit, . - __StackLimit |
|
51 | .size __StackLimit, . - __StackLimit | |
52 | __StackTop: |
|
52 | __StackTop: | |
53 | .size __StackTop, . - __StackTop |
|
53 | .size __StackTop, . - __StackTop | |
54 |
|
54 | |||
55 | .section .heap |
|
55 | .section .heap | |
56 | .align 3 |
|
56 | .align 3 | |
57 | #ifdef __HEAP_SIZE |
|
57 | #ifdef __HEAP_SIZE | |
58 | .equ Heap_Size, __HEAP_SIZE |
|
58 | .equ Heap_Size, __HEAP_SIZE | |
59 | #else |
|
59 | #else | |
60 | .equ Heap_Size, 0x7F00 |
|
60 | .equ Heap_Size, 0x7F00 | |
61 | #endif |
|
61 | #endif | |
62 | .globl __HeapBase |
|
62 | .globl __HeapBase | |
63 | .globl __HeapLimit |
|
63 | .globl __HeapLimit | |
64 | __HeapBase: |
|
64 | __HeapBase: | |
65 | .if Heap_Size |
|
65 | .if Heap_Size | |
66 | .space Heap_Size |
|
66 | .space Heap_Size | |
67 | .endif |
|
67 | .endif | |
68 | .size __HeapBase, . - __HeapBase |
|
68 | .size __HeapBase, . - __HeapBase | |
69 | __HeapLimit: |
|
69 | __HeapLimit: | |
70 | .size __HeapLimit, . - __HeapLimit |
|
70 | .size __HeapLimit, . - __HeapLimit | |
71 |
|
71 | |||
72 | .section .isr_vector |
|
72 | .section .isr_vector | |
73 | .align 2 |
|
73 | .align 2 | |
74 | .globl __isr_vector |
|
74 | .globl __isr_vector | |
75 | __isr_vector: |
|
75 | __isr_vector: | |
76 | .long __StackTop /* Top of Stack */ |
|
76 | .long __StackTop /* Top of Stack */ | |
77 | .long Reset_Handler /* Reset Handler */ |
|
77 | .long Reset_Handler /* Reset Handler */ | |
78 | .long NMI_Handler /* NMI Handler */ |
|
78 | .long NMI_Handler /* NMI Handler */ | |
79 | .long HardFault_Handler /* Hard Fault Handler */ |
|
79 | .long HardFault_Handler /* Hard Fault Handler */ | |
80 | .long MemManage_Handler /* MPU Fault Handler */ |
|
80 | .long MemManage_Handler /* MPU Fault Handler */ | |
81 | .long BusFault_Handler /* Bus Fault Handler */ |
|
81 | .long BusFault_Handler /* Bus Fault Handler */ | |
82 | .long UsageFault_Handler /* Usage Fault Handler */ |
|
82 | .long UsageFault_Handler /* Usage Fault Handler */ | |
83 | .long 0 /* Reserved */ |
|
83 | .long 0 /* Reserved */ | |
84 | .long 0 /* Reserved */ |
|
84 | .long 0 /* Reserved */ | |
85 | .long 0 /* Reserved */ |
|
85 | .long 0 /* Reserved */ | |
86 | .long 0 /* Reserved */ |
|
86 | .long 0 /* Reserved */ | |
87 | .long SVC_Handler /* SVCall Handler */ |
|
87 | .long SVC_Handler /* SVCall Handler */ | |
88 | .long DebugMon_Handler /* Debug Monitor Handler */ |
|
88 | .long DebugMon_Handler /* Debug Monitor Handler */ | |
89 | .long 0 /* Reserved */ |
|
89 | .long 0 /* Reserved */ | |
90 | .long PendSV_Handler /* PendSV Handler */ |
|
90 | .long PendSV_Handler /* PendSV Handler */ | |
91 | .long SysTick_Handler /* SysTick Handler */ |
|
91 | .long SysTick_Handler /* SysTick Handler */ | |
92 |
|
92 | |||
93 | /* External interrupts */ |
|
93 | /* External interrupts */ | |
94 | .word WWDG_IRQHandler /* Window WatchDog */ |
|
94 | .word WWDG_IRQHandler /* Window WatchDog */ | |
95 | .word PVD_IRQHandler /* PVD through EXTI Line detection */ |
|
95 | .word PVD_IRQHandler /* PVD through EXTI Line detection */ | |
96 | .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ |
|
96 | .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ | |
97 | .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ |
|
97 | .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ | |
98 | .word FLASH_IRQHandler /* FLASH */ |
|
98 | .word FLASH_IRQHandler /* FLASH */ | |
99 | .word RCC_IRQHandler /* RCC */ |
|
99 | .word RCC_IRQHandler /* RCC */ | |
100 | .word EXTI0_IRQHandler /* EXTI Line0 */ |
|
100 | .word EXTI0_IRQHandler /* EXTI Line0 */ | |
101 | .word EXTI1_IRQHandler /* EXTI Line1 */ |
|
101 | .word EXTI1_IRQHandler /* EXTI Line1 */ | |
102 | .word EXTI2_IRQHandler /* EXTI Line2 */ |
|
102 | .word EXTI2_IRQHandler /* EXTI Line2 */ | |
103 | .word EXTI3_IRQHandler /* EXTI Line3 */ |
|
103 | .word EXTI3_IRQHandler /* EXTI Line3 */ | |
104 | .word EXTI4_IRQHandler /* EXTI Line4 */ |
|
104 | .word EXTI4_IRQHandler /* EXTI Line4 */ | |
105 | .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ |
|
105 | .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ | |
106 | .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ |
|
106 | .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ | |
107 | .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ |
|
107 | .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ | |
108 | .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ |
|
108 | .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ | |
109 | .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ |
|
109 | .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ | |
110 | .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ |
|
110 | .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ | |
111 | .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ |
|
111 | .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ | |
112 | .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ |
|
112 | .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ | |
113 | .word CAN1_TX_IRQHandler /* CAN1 TX */ |
|
113 | .word CAN1_TX_IRQHandler /* CAN1 TX */ | |
114 | .word CAN1_RX0_IRQHandler /* CAN1 RX0 */ |
|
114 | .word CAN1_RX0_IRQHandler /* CAN1 RX0 */ | |
115 | .word CAN1_RX1_IRQHandler /* CAN1 RX1 */ |
|
115 | .word CAN1_RX1_IRQHandler /* CAN1 RX1 */ | |
116 | .word CAN1_SCE_IRQHandler /* CAN1 SCE */ |
|
116 | .word CAN1_SCE_IRQHandler /* CAN1 SCE */ | |
117 | .word EXTI9_5_IRQHandler /* External Line[9:5]s */ |
|
117 | .word EXTI9_5_IRQHandler /* External Line[9:5]s */ | |
118 | .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */ |
|
118 | .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */ | |
119 | .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */ |
|
119 | .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */ | |
120 | .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */ |
|
120 | .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */ | |
121 | .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ |
|
121 | .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ | |
122 | .word TIM2_IRQHandler /* TIM2 */ |
|
122 | .word TIM2_IRQHandler /* TIM2 */ | |
123 | .word TIM3_IRQHandler /* TIM3 */ |
|
123 | .word TIM3_IRQHandler /* TIM3 */ | |
124 | .word TIM4_IRQHandler /* TIM4 */ |
|
124 | .word TIM4_IRQHandler /* TIM4 */ | |
125 | .word I2C1_EV_IRQHandler /* I2C1 Event */ |
|
125 | .word I2C1_EV_IRQHandler /* I2C1 Event */ | |
126 | .word I2C1_ER_IRQHandler /* I2C1 Error */ |
|
126 | .word I2C1_ER_IRQHandler /* I2C1 Error */ | |
127 | .word I2C2_EV_IRQHandler /* I2C2 Event */ |
|
127 | .word I2C2_EV_IRQHandler /* I2C2 Event */ | |
128 | .word I2C2_ER_IRQHandler /* I2C2 Error */ |
|
128 | .word I2C2_ER_IRQHandler /* I2C2 Error */ | |
129 | .word SPI1_IRQHandler /* SPI1 */ |
|
129 | .word SPI1_IRQHandler /* SPI1 */ | |
130 | .word SPI2_IRQHandler /* SPI2 */ |
|
130 | .word SPI2_IRQHandler /* SPI2 */ | |
131 | .word USART1_IRQHandler /* USART1 */ |
|
131 | .word USART1_IRQHandler /* USART1 */ | |
132 | .word USART2_IRQHandler /* USART2 */ |
|
132 | .word USART2_IRQHandler /* USART2 */ | |
133 | .word USART3_IRQHandler /* USART3 */ |
|
133 | .word USART3_IRQHandler /* USART3 */ | |
134 | .word EXTI15_10_IRQHandler /* External Line[15:10]s */ |
|
134 | .word EXTI15_10_IRQHandler /* External Line[15:10]s */ | |
135 | .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ |
|
135 | .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ | |
136 | .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */ |
|
136 | .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */ | |
137 | .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ |
|
137 | .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ | |
138 | .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ |
|
138 | .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ | |
139 | .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ |
|
139 | .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ | |
140 | .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ |
|
140 | .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ | |
141 | .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ |
|
141 | .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ | |
142 | .word FSMC_IRQHandler /* FSMC */ |
|
142 | .word FSMC_IRQHandler /* FSMC */ | |
143 | .word SDIO_IRQHandler /* SDIO */ |
|
143 | .word SDIO_IRQHandler /* SDIO */ | |
144 | .word TIM5_IRQHandler /* TIM5 */ |
|
144 | .word TIM5_IRQHandler /* TIM5 */ | |
145 | .word SPI3_IRQHandler /* SPI3 */ |
|
145 | .word SPI3_IRQHandler /* SPI3 */ | |
146 | .word UART4_IRQHandler /* UART4 */ |
|
146 | .word UART4_IRQHandler /* UART4 */ | |
147 | .word UART5_IRQHandler /* UART5 */ |
|
147 | .word UART5_IRQHandler /* UART5 */ | |
148 | .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ |
|
148 | .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ | |
149 | .word TIM7_IRQHandler /* TIM7 */ |
|
149 | .word TIM7_IRQHandler /* TIM7 */ | |
150 | .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ |
|
150 | .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ | |
151 | .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ |
|
151 | .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ | |
152 | .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ |
|
152 | .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ | |
153 | .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ |
|
153 | .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ | |
154 | .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ |
|
154 | .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ | |
155 | .word ETH_IRQHandler /* Ethernet */ |
|
155 | .word ETH_IRQHandler /* Ethernet */ | |
156 | .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ |
|
156 | .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ | |
157 | .word CAN2_TX_IRQHandler /* CAN2 TX */ |
|
157 | .word CAN2_TX_IRQHandler /* CAN2 TX */ | |
158 | .word CAN2_RX0_IRQHandler /* CAN2 RX0 */ |
|
158 | .word CAN2_RX0_IRQHandler /* CAN2 RX0 */ | |
159 | .word CAN2_RX1_IRQHandler /* CAN2 RX1 */ |
|
159 | .word CAN2_RX1_IRQHandler /* CAN2 RX1 */ | |
160 | .word CAN2_SCE_IRQHandler /* CAN2 SCE */ |
|
160 | .word CAN2_SCE_IRQHandler /* CAN2 SCE */ | |
161 | .word OTG_FS_IRQHandler /* USB OTG FS */ |
|
161 | .word OTG_FS_IRQHandler /* USB OTG FS */ | |
162 | .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ |
|
162 | .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ | |
163 | .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ |
|
163 | .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ | |
164 | .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ |
|
164 | .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ | |
165 | .word USART6_IRQHandler /* USART6 */ |
|
165 | .word USART6_IRQHandler /* USART6 */ | |
166 | .word I2C3_EV_IRQHandler /* I2C3 event */ |
|
166 | .word I2C3_EV_IRQHandler /* I2C3 event */ | |
167 | .word I2C3_ER_IRQHandler /* I2C3 error */ |
|
167 | .word I2C3_ER_IRQHandler /* I2C3 error */ | |
168 | .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ |
|
168 | .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ | |
169 | .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ |
|
169 | .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ | |
170 | .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ |
|
170 | .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ | |
171 | .word OTG_HS_IRQHandler /* USB OTG HS */ |
|
171 | .word OTG_HS_IRQHandler /* USB OTG HS */ | |
172 | .word DCMI_IRQHandler /* DCMI */ |
|
172 | .word DCMI_IRQHandler /* DCMI */ | |
173 | .word CRYP_IRQHandler /* CRYP crypto */ |
|
173 | .word CRYP_IRQHandler /* CRYP crypto */ | |
174 | .word HASH_RNG_IRQHandler /* Hash and Rng */ |
|
174 | .word HASH_RNG_IRQHandler /* Hash and Rng */ | |
175 | .word FPU_IRQHandler /* FPU */ |
|
175 | .word FPU_IRQHandler /* FPU */ | |
176 |
|
176 | |||
177 |
|
177 | |||
178 | .size __isr_vector, . - __isr_vector |
|
178 | .size __isr_vector, . - __isr_vector | |
179 |
|
179 | |||
180 | .text |
|
180 | .text | |
181 | .thumb |
|
181 | .thumb | |
182 | .thumb_func |
|
182 | .thumb_func | |
183 | .align 2 |
|
183 | .align 2 | |
184 | .globl Reset_Handler |
|
184 | .globl Reset_Handler | |
185 | .type Reset_Handler, %function |
|
185 | .type Reset_Handler, %function | |
186 | Reset_Handler: |
|
186 | Reset_Handler: | |
187 | /* Firstly it copies data from read only memory to RAM. There are two schemes |
|
187 | /* Firstly it copies data from read only memory to RAM. There are two schemes | |
188 | * to copy. One can copy more than one sections. Another can only copy |
|
188 | * to copy. One can copy more than one sections. Another can only copy | |
189 | * one section. The former scheme needs more instructions and read-only |
|
189 | * one section. The former scheme needs more instructions and read-only | |
190 | * data to implement than the latter. |
|
190 | * data to implement than the latter. | |
191 | * Macro __STARTUP_COPY_MULTIPLE is used to choose between two schemes. */ |
|
191 | * Macro __STARTUP_COPY_MULTIPLE is used to choose between two schemes. */ | |
192 |
|
192 | |||
193 | /* Single section scheme. |
|
193 | /* Single section scheme. | |
194 | * |
|
194 | * | |
195 | * The ranges of copy from/to are specified by following symbols |
|
195 | * The ranges of copy from/to are specified by following symbols | |
196 | * __etext: LMA of start of the section to copy from. Usually end of text |
|
196 | * __etext: LMA of start of the section to copy from. Usually end of text | |
197 | * __data_start__: VMA of start of the section to copy to |
|
197 | * __data_start__: VMA of start of the section to copy to | |
198 | * __data_end__: VMA of end of the section to copy to |
|
198 | * __data_end__: VMA of end of the section to copy to | |
199 | * |
|
199 | * | |
200 | * All addresses must be aligned to 4 bytes boundary. |
|
200 | * All addresses must be aligned to 4 bytes boundary. | |
201 | */ |
|
201 | */ | |
202 | ldr r1, =__etext |
|
202 | ldr r1, =__etext | |
203 | ldr r2, =__data_start__ |
|
203 | ldr r2, =__data_start__ | |
204 | ldr r3, =__data_end__ |
|
204 | ldr r3, =__data_end__ | |
205 |
|
205 | |||
206 | .L_loop1: |
|
206 | .L_loop1: | |
207 | cmp r2, r3 |
|
207 | cmp r2, r3 | |
208 | ittt lt |
|
208 | ittt lt | |
209 | ldrlt r0, [r1], #4 |
|
209 | ldrlt r0, [r1], #4 | |
210 | strlt r0, [r2], #4 |
|
210 | strlt r0, [r2], #4 | |
211 | blt .L_loop1 |
|
211 | blt .L_loop1 | |
212 |
|
212 | |||
213 | /* This part of work usually is done in C library startup code. Otherwise, |
|
213 | /* This part of work usually is done in C library startup code. Otherwise, | |
214 | * define this macro to enable it in this startup. |
|
214 | * define this macro to enable it in this startup. | |
215 | * |
|
215 | * | |
216 | * There are two schemes too. One can clear multiple BSS sections. Another |
|
216 | * There are two schemes too. One can clear multiple BSS sections. Another | |
217 | * can only clear one section. The former is more size expensive than the |
|
217 | * can only clear one section. The former is more size expensive than the | |
218 | * latter. |
|
218 | * latter. | |
219 | * |
|
219 | * | |
220 | * Define macro __STARTUP_CLEAR_BSS_MULTIPLE to choose the former. |
|
220 | * Define macro __STARTUP_CLEAR_BSS_MULTIPLE to choose the former. | |
221 | * Otherwise efine macro __STARTUP_CLEAR_BSS to choose the later. |
|
221 | * Otherwise efine macro __STARTUP_CLEAR_BSS to choose the later. | |
222 | */ |
|
222 | */ | |
223 |
|
223 | |||
224 | /* Single BSS section scheme. |
|
224 | /* Single BSS section scheme. | |
225 | * |
|
225 | * | |
226 | * The BSS section is specified by following symbols |
|
226 | * The BSS section is specified by following symbols | |
227 | * __bss_start__: start of the BSS section. |
|
227 | * __bss_start__: start of the BSS section. | |
228 | * __bss_end__: end of the BSS section. |
|
228 | * __bss_end__: end of the BSS section. | |
229 | * |
|
229 | * | |
230 | * Both addresses must be aligned to 4 bytes boundary. |
|
230 | * Both addresses must be aligned to 4 bytes boundary. | |
231 | */ |
|
231 | */ | |
232 | ldr r1, =__bss_start__ |
|
232 | ldr r1, =__bss_start__ | |
233 | ldr r2, =__bss_end__ |
|
233 | ldr r2, =__bss_end__ | |
234 |
|
234 | |||
235 | movs r0, 0 |
|
235 | movs r0, 0 | |
236 | .L_loop3: |
|
236 | .L_loop3: | |
237 | cmp r1, r2 |
|
237 | cmp r1, r2 | |
238 | itt lt |
|
238 | itt lt | |
239 | strlt r0, [r1], #4 |
|
239 | strlt r0, [r1], #4 | |
240 | blt .L_loop3 |
|
240 | blt .L_loop3 | |
241 |
|
241 | |||
242 | bl main |
|
242 | bl main | |
243 |
|
243 | |||
244 |
|
244 | |||
245 | .pool |
|
245 | .pool | |
246 | .size Reset_Handler, . - Reset_Handler |
|
246 | .size Reset_Handler, . - Reset_Handler | |
247 |
|
247 | |||
248 | .align 1 |
|
248 | .align 1 | |
249 | .thumb_func |
|
249 | .thumb_func | |
250 | .weak Default_Handler |
|
250 | .weak Default_Handler | |
251 | .type Default_Handler, %function |
|
251 | .type Default_Handler, %function | |
252 | Default_Handler: |
|
252 | Default_Handler: | |
253 | b . |
|
253 | b . | |
254 | .size Default_Handler, . - Default_Handler |
|
254 | .size Default_Handler, . - Default_Handler | |
255 |
|
255 | |||
256 | /* Macro to define default handlers. Default handler |
|
256 | /* Macro to define default handlers. Default handler | |
257 | * will be weak symbol and just dead loops. They can be |
|
257 | * will be weak symbol and just dead loops. They can be | |
258 | * overwritten by other handlers */ |
|
258 | * overwritten by other handlers */ | |
259 | .macro def_irq_handler handler_name |
|
259 | .macro def_irq_handler handler_name | |
260 | .weak \handler_name |
|
260 | .weak \handler_name | |
261 | .set \handler_name, Default_Handler |
|
261 | .set \handler_name, Default_Handler | |
262 | .endm |
|
262 | .endm | |
263 |
|
263 | |||
264 | def_irq_handler NMI_Handler |
|
264 | def_irq_handler NMI_Handler | |
265 | def_irq_handler HardFault_Handler |
|
265 | def_irq_handler HardFault_Handler | |
266 | def_irq_handler MemManage_Handler |
|
266 | def_irq_handler MemManage_Handler | |
267 | def_irq_handler BusFault_Handler |
|
267 | def_irq_handler BusFault_Handler | |
268 | def_irq_handler UsageFault_Handler |
|
268 | def_irq_handler UsageFault_Handler | |
269 | def_irq_handler SVC_Handler |
|
269 | def_irq_handler SVC_Handler | |
270 | def_irq_handler DebugMon_Handler |
|
270 | def_irq_handler DebugMon_Handler | |
271 | def_irq_handler PendSV_Handler |
|
271 | def_irq_handler PendSV_Handler | |
272 | def_irq_handler SysTick_Handler |
|
272 | def_irq_handler SysTick_Handler | |
273 | def_irq_handler DEF_IRQHandler |
|
273 | def_irq_handler DEF_IRQHandler | |
274 |
|
274 | |||
275 | def_irq_handler WWDG_IRQHandler |
|
275 | def_irq_handler WWDG_IRQHandler | |
276 | def_irq_handler PVD_IRQHandler |
|
276 | def_irq_handler PVD_IRQHandler | |
277 | def_irq_handler TAMP_STAMP_IRQHandler |
|
277 | def_irq_handler TAMP_STAMP_IRQHandler | |
278 | def_irq_handler RTC_WKUP_IRQHandler |
|
278 | def_irq_handler RTC_WKUP_IRQHandler | |
279 | def_irq_handler FLASH_IRQHandler |
|
279 | def_irq_handler FLASH_IRQHandler | |
280 | def_irq_handler RCC_IRQHandler |
|
280 | def_irq_handler RCC_IRQHandler | |
281 | def_irq_handler EXTI0_IRQHandler |
|
281 | def_irq_handler EXTI0_IRQHandler | |
282 | def_irq_handler EXTI1_IRQHandler |
|
282 | def_irq_handler EXTI1_IRQHandler | |
283 | def_irq_handler EXTI2_IRQHandler |
|
283 | def_irq_handler EXTI2_IRQHandler | |
284 | def_irq_handler EXTI3_IRQHandler |
|
284 | def_irq_handler EXTI3_IRQHandler | |
285 | def_irq_handler EXTI4_IRQHandler |
|
285 | def_irq_handler EXTI4_IRQHandler | |
286 | def_irq_handler DMA1_Stream0_IRQHandler |
|
286 | def_irq_handler DMA1_Stream0_IRQHandler | |
287 | def_irq_handler DMA1_Stream1_IRQHandler |
|
287 | def_irq_handler DMA1_Stream1_IRQHandler | |
288 | def_irq_handler DMA1_Stream2_IRQHandler |
|
288 | def_irq_handler DMA1_Stream2_IRQHandler | |
289 | def_irq_handler DMA1_Stream3_IRQHandler |
|
289 | def_irq_handler DMA1_Stream3_IRQHandler | |
290 | def_irq_handler DMA1_Stream4_IRQHandler |
|
290 | def_irq_handler DMA1_Stream4_IRQHandler | |
291 | def_irq_handler DMA1_Stream5_IRQHandler |
|
291 | def_irq_handler DMA1_Stream5_IRQHandler | |
292 | def_irq_handler DMA1_Stream6_IRQHandler |
|
292 | def_irq_handler DMA1_Stream6_IRQHandler | |
293 | def_irq_handler ADC_IRQHandler |
|
293 | def_irq_handler ADC_IRQHandler | |
294 | def_irq_handler CAN1_TX_IRQHandler |
|
294 | def_irq_handler CAN1_TX_IRQHandler | |
295 | def_irq_handler CAN1_RX0_IRQHandler |
|
295 | def_irq_handler CAN1_RX0_IRQHandler | |
296 | def_irq_handler CAN1_RX1_IRQHandler |
|
296 | def_irq_handler CAN1_RX1_IRQHandler | |
297 | def_irq_handler CAN1_SCE_IRQHandler |
|
297 | def_irq_handler CAN1_SCE_IRQHandler | |
298 | def_irq_handler EXTI9_5_IRQHandler |
|
298 | def_irq_handler EXTI9_5_IRQHandler | |
299 | def_irq_handler TIM1_BRK_TIM9_IRQHandler |
|
299 | def_irq_handler TIM1_BRK_TIM9_IRQHandler | |
300 | def_irq_handler TIM1_UP_TIM10_IRQHandler |
|
300 | def_irq_handler TIM1_UP_TIM10_IRQHandler | |
301 | def_irq_handler TIM1_TRG_COM_TIM11_IRQHandler |
|
301 | def_irq_handler TIM1_TRG_COM_TIM11_IRQHandler | |
302 | def_irq_handler TIM1_CC_IRQHandler |
|
302 | def_irq_handler TIM1_CC_IRQHandler | |
303 | def_irq_handler TIM2_IRQHandler |
|
303 | def_irq_handler TIM2_IRQHandler | |
304 | def_irq_handler TIM3_IRQHandler |
|
304 | def_irq_handler TIM3_IRQHandler | |
305 | def_irq_handler TIM4_IRQHandler |
|
305 | def_irq_handler TIM4_IRQHandler | |
306 | def_irq_handler I2C1_EV_IRQHandler |
|
306 | def_irq_handler I2C1_EV_IRQHandler | |
307 | def_irq_handler I2C1_ER_IRQHandler |
|
307 | def_irq_handler I2C1_ER_IRQHandler | |
308 | def_irq_handler I2C2_EV_IRQHandler |
|
308 | def_irq_handler I2C2_EV_IRQHandler | |
309 | def_irq_handler I2C2_ER_IRQHandler |
|
309 | def_irq_handler I2C2_ER_IRQHandler | |
310 | def_irq_handler SPI1_IRQHandler |
|
310 | def_irq_handler SPI1_IRQHandler | |
311 | def_irq_handler SPI2_IRQHandler |
|
311 | def_irq_handler SPI2_IRQHandler | |
312 | def_irq_handler USART1_IRQHandler |
|
312 | def_irq_handler USART1_IRQHandler | |
313 | def_irq_handler USART2_IRQHandler |
|
313 | def_irq_handler USART2_IRQHandler | |
314 | def_irq_handler USART3_IRQHandler |
|
314 | def_irq_handler USART3_IRQHandler | |
315 | def_irq_handler EXTI15_10_IRQHandler |
|
315 | def_irq_handler EXTI15_10_IRQHandler | |
316 | def_irq_handler RTC_Alarm_IRQHandler |
|
316 | def_irq_handler RTC_Alarm_IRQHandler | |
317 | def_irq_handler OTG_FS_WKUP_IRQHandler |
|
317 | def_irq_handler OTG_FS_WKUP_IRQHandler | |
318 | def_irq_handler TIM8_BRK_TIM12_IRQHandler |
|
318 | def_irq_handler TIM8_BRK_TIM12_IRQHandler | |
319 | def_irq_handler TIM8_UP_TIM13_IRQHandler |
|
319 | def_irq_handler TIM8_UP_TIM13_IRQHandler | |
320 | def_irq_handler TIM8_TRG_COM_TIM14_IRQHandler |
|
320 | def_irq_handler TIM8_TRG_COM_TIM14_IRQHandler | |
321 | def_irq_handler TIM8_CC_IRQHandler |
|
321 | def_irq_handler TIM8_CC_IRQHandler | |
322 | def_irq_handler DMA1_Stream7_IRQHandler |
|
322 | def_irq_handler DMA1_Stream7_IRQHandler | |
323 | def_irq_handler FSMC_IRQHandler |
|
323 | def_irq_handler FSMC_IRQHandler | |
324 | def_irq_handler SDIO_IRQHandler |
|
324 | def_irq_handler SDIO_IRQHandler | |
325 | def_irq_handler TIM5_IRQHandler |
|
325 | def_irq_handler TIM5_IRQHandler | |
326 | def_irq_handler SPI3_IRQHandler |
|
326 | def_irq_handler SPI3_IRQHandler | |
327 | def_irq_handler UART4_IRQHandler |
|
327 | def_irq_handler UART4_IRQHandler | |
328 | def_irq_handler UART5_IRQHandler |
|
328 | def_irq_handler UART5_IRQHandler | |
329 | def_irq_handler TIM6_DAC_IRQHandler |
|
329 | def_irq_handler TIM6_DAC_IRQHandler | |
330 | def_irq_handler TIM7_IRQHandler |
|
330 | def_irq_handler TIM7_IRQHandler | |
331 | def_irq_handler DMA2_Stream0_IRQHandler |
|
331 | def_irq_handler DMA2_Stream0_IRQHandler | |
332 | def_irq_handler DMA2_Stream1_IRQHandler |
|
332 | def_irq_handler DMA2_Stream1_IRQHandler | |
333 | def_irq_handler DMA2_Stream2_IRQHandler |
|
333 | def_irq_handler DMA2_Stream2_IRQHandler | |
334 | def_irq_handler DMA2_Stream3_IRQHandler |
|
334 | def_irq_handler DMA2_Stream3_IRQHandler | |
335 | def_irq_handler DMA2_Stream4_IRQHandler |
|
335 | def_irq_handler DMA2_Stream4_IRQHandler | |
336 | def_irq_handler ETH_IRQHandler |
|
336 | def_irq_handler ETH_IRQHandler | |
337 | def_irq_handler ETH_WKUP_IRQHandler |
|
337 | def_irq_handler ETH_WKUP_IRQHandler | |
338 | def_irq_handler CAN2_TX_IRQHandler |
|
338 | def_irq_handler CAN2_TX_IRQHandler | |
339 | def_irq_handler CAN2_RX0_IRQHandler |
|
339 | def_irq_handler CAN2_RX0_IRQHandler | |
340 | def_irq_handler CAN2_RX1_IRQHandler |
|
340 | def_irq_handler CAN2_RX1_IRQHandler | |
341 | def_irq_handler CAN2_SCE_IRQHandler |
|
341 | def_irq_handler CAN2_SCE_IRQHandler | |
342 | def_irq_handler OTG_FS_IRQHandler |
|
342 | def_irq_handler OTG_FS_IRQHandler | |
343 | def_irq_handler DMA2_Stream5_IRQHandler |
|
343 | def_irq_handler DMA2_Stream5_IRQHandler | |
344 | def_irq_handler DMA2_Stream6_IRQHandler |
|
344 | def_irq_handler DMA2_Stream6_IRQHandler | |
345 | def_irq_handler DMA2_Stream7_IRQHandler |
|
345 | def_irq_handler DMA2_Stream7_IRQHandler | |
346 | def_irq_handler USART6_IRQHandler |
|
346 | def_irq_handler USART6_IRQHandler | |
347 | def_irq_handler I2C3_EV_IRQHandler |
|
347 | def_irq_handler I2C3_EV_IRQHandler | |
348 | def_irq_handler I2C3_ER_IRQHandler |
|
348 | def_irq_handler I2C3_ER_IRQHandler | |
349 | def_irq_handler OTG_HS_EP1_OUT_IRQHandler |
|
349 | def_irq_handler OTG_HS_EP1_OUT_IRQHandler | |
350 | def_irq_handler OTG_HS_EP1_IN_IRQHandler |
|
350 | def_irq_handler OTG_HS_EP1_IN_IRQHandler | |
351 | def_irq_handler OTG_HS_WKUP_IRQHandler |
|
351 | def_irq_handler OTG_HS_WKUP_IRQHandler | |
352 | def_irq_handler OTG_HS_IRQHandler |
|
352 | def_irq_handler OTG_HS_IRQHandler | |
353 | def_irq_handler DCMI_IRQHandler |
|
353 | def_irq_handler DCMI_IRQHandler | |
354 | def_irq_handler CRYP_IRQHandler |
|
354 | def_irq_handler CRYP_IRQHandler | |
355 | def_irq_handler HASH_RNG_IRQHandler |
|
355 | def_irq_handler HASH_RNG_IRQHandler | |
356 | def_irq_handler FPU_IRQHandler |
|
356 | def_irq_handler FPU_IRQHandler | |
357 |
|
357 | |||
358 | .end |
|
358 | .end |
@@ -1,96 +1,105 | |||||
1 | # |
|
1 | # | |
2 | # qmake configuration for stm32f4 |
|
2 | # qmake configuration for stm32f4 | |
3 | # |
|
3 | # | |
4 | # |
|
4 | # | |
5 |
|
5 | |||
6 |
|
6 | |||
7 | isEmpty(_stm32f4_conf){ |
|
7 | isEmpty(_stm32f4_conf){ | |
8 | _stm32f4_conf="oneshot" |
|
8 | _stm32f4_conf="oneshot" | |
9 |
|
9 | |||
10 | QMAKE_CFLAGS+= -g -mlittle-endian -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -std=c99 |
|
10 | QMAKE_CFLAGS+= -g -mlittle-endian -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -std=c99 | |
11 |
|
11 | |||
12 | include(../../common/arm-none-eabi.conf) |
|
12 | include(../../common/arm-none-eabi.conf) | |
13 |
|
13 | |||
14 | DEFINES += __OPTIMIZED_MATH |
|
14 | DEFINES += __OPTIMIZED_MATH | |
15 | DEFINES += \"assert_param(expr)=((void)0)\" |
|
15 | DEFINES += \"assert_param(expr)=((void)0)\" | |
16 | INCLUDEPATH += $$PWD |
|
16 | INCLUDEPATH += $$PWD | |
17 |
|
17 | |||
18 | DEFINES += __FPU_PRESENT=1 |
|
18 | DEFINES += __FPU_PRESENT=1 | |
19 | DEFINES += ARM_MATH_CM4 |
|
19 | DEFINES += ARM_MATH_CM4 | |
20 |
|
20 | |||
21 | DEFINES += BSP="\"\\\"$$BSP"\\\"\" |
|
21 | DEFINES += BSP="\"\\\"$$BSP"\\\"\" | |
22 |
|
22 | |||
23 |
|
23 | |||
24 | contains(CPU, stm32f42x){ |
|
24 | contains(CPU, stm32f42x){ | |
25 | LDSCRIPT=stm32f42.ld |
|
25 | LDSCRIPT=stm32f42.ld | |
26 | } |
|
26 | } | |
27 | contains(CPU, stm32f4xxxG){ |
|
27 | contains(CPU, stm32f4xxxG){ | |
28 | LDSCRIPT=stm32f4.ld |
|
28 | LDSCRIPT=stm32f4.ld | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 |
|
31 | |||
32 | contains( TEMPLATE, app ) { |
|
32 | contains( TEMPLATE, app ) { | |
33 |
|
33 | |||
34 | unix:QMAKE_POST_LINK += arm-none-eabi-objcopy -O ihex "$(TARGET)" $$DESTDIR/"$(QMAKE_TARGET).hex" $$escape_expand(\\n\\t) |
|
34 | unix:QMAKE_POST_LINK += arm-none-eabi-objcopy -O ihex "$(TARGET)" $$DESTDIR/"$(QMAKE_TARGET).hex" $$escape_expand(\\n\\t) | |
35 | unix:QMAKE_POST_LINK += arm-none-eabi-objcopy -O binary "$(TARGET)" $$DESTDIR/"$(QMAKE_TARGET).bin" $$escape_expand(\\n\\t) |
|
35 | unix:QMAKE_POST_LINK += arm-none-eabi-objcopy -O binary "$(TARGET)" $$DESTDIR/"$(QMAKE_TARGET).bin" $$escape_expand(\\n\\t) | |
36 | win32:QMAKE_POST_LINK += arm-none-eabi-objcopy -O ihex "$(DESTDIR_TARGET)" $$DESTDIR/"$(QMAKE_TARGET).hex" $$escape_expand(\\n\\t) |
|
36 | win32:QMAKE_POST_LINK += arm-none-eabi-objcopy -O ihex "$(DESTDIR_TARGET)" $$DESTDIR/"$(QMAKE_TARGET).hex" $$escape_expand(\\n\\t) | |
37 | win32:QMAKE_POST_LINK += arm-none-eabi-objcopy -O binary "$(DESTDIR_TARGET)" $$DESTDIR/"$(QMAKE_TARGET).bin" $$escape_expand(\\n\\t) |
|
37 | win32:QMAKE_POST_LINK += arm-none-eabi-objcopy -O binary "$(DESTDIR_TARGET)" $$DESTDIR/"$(QMAKE_TARGET).bin" $$escape_expand(\\n\\t) | |
38 |
|
38 | |||
39 | contains( CONFIG, dfu ){ |
|
39 | contains( CONFIG, dfu ){ | |
40 | unix:QMAKE_POST_LINK += python $$[QT_INSTALL_BINS]/dfu.py -b 0x08000000:$$DESTDIR/"$(QMAKE_TARGET).bin" $$DESTDIR/"$(QMAKE_TARGET).dfu" $$escape_expand(\\n\\t) |
|
40 | unix:QMAKE_POST_LINK += python $$[QT_INSTALL_BINS]/dfu.py -b 0x08000000:$$DESTDIR/"$(QMAKE_TARGET).bin" $$DESTDIR/"$(QMAKE_TARGET).dfu" $$escape_expand(\\n\\t) | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | LIBS += -L$$[QT_INSTALL_PREFIX]/bsp/lib/$$BSP -lbsp |
|
43 | LIBS += -L$$[QT_INSTALL_PREFIX]/bsp/lib/$$BSP -lbsp | |
44 | LIBS += -L$$[QT_INSTALL_LIBS]/$$UCMODEL |
|
44 | LIBS += -L$$[QT_INSTALL_LIBS]/$$UCMODEL | |
45 | LIBS += -lcpu |
|
45 | LIBS += -lcpu | |
46 | LIBS += -lcore -lm -lc |
|
46 | LIBS += -lcore -lm -lc | |
47 |
|
47 | |||
48 | QMAKE_LFLAGS += -g -mlittle-endian -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -std=c99 -T $$[QT_INSTALL_PREFIX]/mkspecs/features/stm32f4/$$LDSCRIPT |
|
48 | QMAKE_LFLAGS += -g -mlittle-endian -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -std=c99 -T $$[QT_INSTALL_PREFIX]/mkspecs/features/stm32f4/$$LDSCRIPT | |
49 |
|
49 | |||
50 |
|
50 | |||
51 |
|
51 | |||
52 | SOURCES +=$$[QT_INSTALL_PREFIX]/mkspecs/features/stm32f4/syscalls.c |
|
52 | SOURCES +=$$[QT_INSTALL_PREFIX]/mkspecs/features/stm32f4/syscalls.c | |
53 | SOURCES +=$$[QT_INSTALL_PREFIX]/mkspecs/features/stm32f4/fs.c |
|
53 | SOURCES +=$$[QT_INSTALL_PREFIX]/mkspecs/features/stm32f4/fs.c | |
54 | SOURCES +=$$[QT_INSTALL_PREFIX]/mkspecs/features/stm32f4/crt0.s |
|
54 | SOURCES +=$$[QT_INSTALL_PREFIX]/mkspecs/features/stm32f4/crt0.s | |
55 | SOURCES +=$$[QT_INSTALL_PREFIX]/mkspecs/features/stm32f4/cpuinit.c |
|
55 | SOURCES +=$$[QT_INSTALL_PREFIX]/mkspecs/features/stm32f4/cpuinit.c | |
56 |
|
56 | |||
57 |
|
57 | |||
58 | stflash.target = stflash |
|
58 | stflash.target = stflash | |
59 | stflash.commands = cd $$DESTDIR && st-flash write $(QMAKE_TARGET).bin 0x08000000 |
|
59 | stflash.commands = cd $$DESTDIR && st-flash write $(QMAKE_TARGET).bin 0x08000000 | |
60 | stflash.depends = $$DESTDIR/$(QMAKE_TARGET) |
|
60 | stflash.depends = $$DESTDIR/$(QMAKE_TARGET) | |
61 | qstlink2.target = qstlink2 |
|
61 | qstlink2.target = qstlink2 | |
62 | qstlink2.commands = cd $$DESTDIR && qstlink2 --cli --write --verify --reset ./$(QMAKE_TARGET).bin |
|
62 | qstlink2.commands = cd $$DESTDIR && qstlink2 --cli --write --verify --reset ./$(QMAKE_TARGET).bin | |
63 | qstlink2.depends = $$DESTDIR/$(QMAKE_TARGET) |
|
63 | qstlink2.depends = $$DESTDIR/$(QMAKE_TARGET) | |
64 | dfu_file.target = $$DESTDIR/$(QMAKE_TARGET).dfu |
|
64 | dfu_file.target = $$DESTDIR/$(QMAKE_TARGET).dfu | |
65 | dfu_file.commands = python $$[QT_INSTALL_BINS]/dfu.py -b 0x08000000:$$DESTDIR/$(QMAKE_TARGET).bin $$DESTDIR/$(QMAKE_TARGET).dfu |
|
65 | dfu_file.commands = python $$[QT_INSTALL_BINS]/dfu.py -b 0x08000000:$$DESTDIR/$(QMAKE_TARGET).bin $$DESTDIR/$(QMAKE_TARGET).dfu | |
66 | dfu_file.depends = $$DESTDIR/$(QMAKE_TARGET) |
|
66 | dfu_file.depends = $$DESTDIR/$(QMAKE_TARGET) | |
67 | dfu.target = dfu |
|
67 | dfu.target = dfu | |
68 | dfu.depends = $$DESTDIR/$(QMAKE_TARGET).dfu |
|
68 | dfu.depends = $$DESTDIR/$(QMAKE_TARGET).dfu | |
69 | dfu.commands = cd $$DESTDIR && dfu-util d 0483:df11 -c 1 -i 0 -a 0 -s 0x08000000 -D $(QMAKE_TARGET).bin 0x08000000 |
|
69 | dfu.commands = cd $$DESTDIR && dfu-util d 0483:df11 -c 1 -i 0 -a 0 -s 0x08000000 -D $(QMAKE_TARGET).bin 0x08000000 | |
70 | gdb-server.target = gdb-server |
|
70 | gdb-server.target = gdb-server | |
71 | gdb-server.commands = st-util -p 3333 & |
|
71 | gdb-server.commands = st-util -p 3333 & | |
72 | gdb-server.depends = stflash |
|
72 | gdb-server.depends = stflash | |
73 | nemiver.target = nemiver |
|
73 | nemiver.target = nemiver | |
74 | nemiver.commands = cd $$DESTDIR && nemiver --remote=localhost:3333 --gdb-binary=`which arm-none-eabi-gdb` $(QMAKE_TARGET) |
|
74 | nemiver.commands = cd $$DESTDIR && nemiver --remote=localhost:3333 --gdb-binary=`which arm-none-eabi-gdb` $(QMAKE_TARGET) | |
75 | nemiver.depends = gdb-server |
|
75 | nemiver.depends = gdb-server | |
76 | QMAKE_EXTRA_TARGETS += dfu_file stflash dfu nemiver gdb-server qstlink2 |
|
76 | openocd.target = openocd | |
|
77 | openocd.depends = $$DESTDIR/$(QMAKE_TARGET) | |||
|
78 | openocd.commands = openocd -f /usr/share/openocd/scripts/interface/ftdi/olimex-arm-usb-tiny-h.cfg -f /usr/share/openocd/scripts/target/stm32f4x.cfg | |||
|
79 | gdb-load.target = gdb-load | |||
|
80 | gdb-load.commands = cd $$DESTDIR && arm-none-eabi-gdb --eval-command \"set confirm off\" --eval-command \"target remote localhost:3333\" --eval-command \"monitor reset halt\" --eval-command \"load\" --eval-command \"quit\" $(QMAKE_TARGET) | |||
|
81 | gdb-load.depends = $$DESTDIR/$(QMAKE_TARGET) | |||
|
82 | nemiver_ocd.target = nemiver_ocd | |||
|
83 | nemiver_ocd.commands = cd $$DESTDIR && nemiver --remote=localhost:3333 --gdb-binary=`which arm-none-eabi-gdb` $(QMAKE_TARGET) | |||
|
84 | nemiver_ocd.depends = gdb-load | |||
|
85 | QMAKE_EXTRA_TARGETS += dfu_file stflash dfu nemiver gdb-server qstlink2 openocd nemiver_ocd gdb-load | |||
77 | } |
|
86 | } | |
78 |
|
87 | |||
79 |
|
88 | |||
80 |
|
89 | |||
81 | } |
|
90 | } | |
82 |
|
91 | |||
83 |
|
92 | |||
84 |
|
93 | |||
85 |
|
94 | |||
86 |
|
95 | |||
87 |
|
96 | |||
88 |
|
97 | |||
89 |
|
98 | |||
90 |
|
99 | |||
91 |
|
100 | |||
92 |
|
101 | |||
93 |
|
102 | |||
94 |
|
103 | |||
95 |
|
104 | |||
96 |
|
105 |
@@ -1,44 +1,357 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the libuc, microcontroler library |
|
2 | -- This file is a part of the libuc, microcontroler library | |
3 | -- Copyright (C) 2012, Alexis Jeandet |
|
3 | -- Copyright (C) 2012, Alexis Jeandet | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | ------------------------------------------------------------------------------- |
|
18 | ------------------------------------------------------------------------------- | |
19 | -- Author : Alexis Jeandet |
|
19 | -- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | -------------------------------------------------------------------------------*/ |
|
21 | -------------------------------------------------------------------------------*/ | |
22 | #define _PRVATE_D51E5TA7601_ |
|
22 | #define _PRVATE_D51E5TA7601_ | |
23 | #include <D51E5TA7601.h> |
|
23 | #include <D51E5TA7601.h> | |
24 | #include <stdio.h> |
|
24 | #include <stdio.h> | |
25 | #include <stddef.h> |
|
25 | #include <stddef.h> | |
26 | #include <core.h> |
|
26 | #include <core.h> | |
27 | #include <math.h> |
|
27 | #include <math.h> | |
28 | #include <malloc.h> |
|
28 | #include <malloc.h> | |
29 |
|
29 | |||
30 | #ifdef __OPTIMIZED_MATH |
|
30 | #ifdef __OPTIMIZED_MATH | |
31 | #include <optimised_math.h> |
|
31 | #include <optimised_math.h> | |
32 | #endif |
|
32 | #endif | |
|
33 | extern void bsp_lcd0_setGRAM(); | |||
|
34 | ||||
|
35 | int D51E5TA7601init(LCD_t *LCD) | |||
|
36 | { | |||
|
37 | if((LCD!=NULL) && (LCD->interface.lcd_interface!=NULL) && (LCD->interface.lcd_interface->writereg!=NULL)) | |||
|
38 | { | |||
|
39 | //first check which LCD controller is connected | |||
|
40 | if(0x7601==LCD->interface.lcd_interface->readreg(0)) | |||
|
41 | { | |||
|
42 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_DRIVEROUTPUTCONTROL1, 0x003C); | |||
|
43 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_LCDDRIVINGCONTROL, 0x0100); | |||
|
44 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_ENTRYMODE, 0x1030); | |||
|
45 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_BLANKPERDIODCTRL, 0x0808); | |||
|
46 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_FRAMECYCLECONTROL, 0x0500); | |||
|
47 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_EXTERNALDISPLAYCTRL, 0x0000); | |||
|
48 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_LCDINTERFACECONTROL, 0x0770); | |||
|
49 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GATESCANPOSITIONCTRL, 0x0000); | |||
|
50 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_FRAMESIGNALCONTROL, 0x0001); | |||
|
51 | ||||
|
52 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_POWERCONTROL2, 0x0406); | |||
|
53 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_POWERCONTROL3, 0x000E); | |||
|
54 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_POWERCONTROL4, 0x0222); | |||
|
55 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_POWERCONTROL5, 0x0015); | |||
|
56 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_POWERCONTROL6, 0x4277); | |||
|
57 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_POWERCONTROL7, 0x0000); | |||
|
58 | ||||
|
59 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL9, 0x6A50); | |||
|
60 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL10, 0x00C9); | |||
|
61 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL11, 0xC7BE); | |||
|
62 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL12, 0x0003); | |||
|
63 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL15, 0x3443); | |||
|
64 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL20, 0x0000); | |||
|
65 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL21, 0x0000); | |||
|
66 | ||||
|
67 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL5, 0x6A50); | |||
|
68 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL6, 0x00C9); | |||
|
69 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL7, 0xC7BE); | |||
|
70 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL8, 0x0003); | |||
|
71 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL14, 0x3443); | |||
|
72 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL18, 0x0000); | |||
|
73 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL19, 0x0000); | |||
|
74 | ||||
|
75 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL1, 0x6A50); | |||
|
76 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL2, 0x00C9); | |||
|
77 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL3, 0xC7BE); | |||
|
78 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL4, 0x0003); | |||
|
79 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL13, 0x3443); | |||
|
80 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL16, 0x0000); | |||
|
81 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_GAMMACONTROL17, 0x0000); | |||
|
82 | ||||
|
83 | delay_100us(500); | |||
|
84 | ||||
|
85 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_POWERCONTROL3, 0x200E); | |||
|
86 | ||||
|
87 | delay_100us(500); | |||
|
88 | ||||
|
89 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_POWERCONTROL3, 0x2003); | |||
|
90 | ||||
|
91 | delay_100us(500); | |||
|
92 | ||||
|
93 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_HORIZONTALADDRESSENDPOSITION, 0x013F); | |||
|
94 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_HORIZONTALADDRESSSTARTPOSITION, 0x0000); | |||
|
95 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_VERTICALADDRESSENDPOSITION, 0x01DF); | |||
|
96 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_VERTICALADDRESSSTARTPOSITION, 0x0000); | |||
|
97 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_HORIZONTALGRAMADDRESSSET, 0x0000); | |||
|
98 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_VERTICALGRAMADDRESSSET, 0x013F); | |||
|
99 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_DISPLAYCONTROL4, 0x0012); | |||
|
100 | ||||
|
101 | delay_100us(500); | |||
|
102 | ||||
|
103 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_DISPLAYCONTROL4, 0x0017); | |||
|
104 | delay_100us(500); | |||
|
105 | ||||
|
106 | bsp_lcd0_setGRAM(); | |||
|
107 | ||||
|
108 | delay_100us(5000); | |||
|
109 | bsp_lcd0_setGRAM(); | |||
|
110 | ||||
|
111 | } | |||
|
112 | ||||
|
113 | } | |||
|
114 | } | |||
33 |
|
115 | |||
34 |
|
116 | |||
|
117 | void D51E5TA7601setGRAMaddress(LCD_t* LCD,uint16_t Haddress,uint16_t Vaddress) | |||
|
118 | { | |||
|
119 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_HORIZONTALGRAMADDRESSSET,Vaddress); | |||
|
120 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_VERTICALGRAMADDRESSSET,Haddress); | |||
|
121 | } | |||
35 |
|
122 | |||
36 |
|
123 | |||
37 |
|
124 | |||
38 |
|
125 | |||
|
126 | void D51E5TA7601setFrame(LCD_t *LCD, uint16_t X, uint16_t Y, uint16_t W, uint16_t H) | |||
|
127 | { | |||
|
128 | // printf("X=%d Y=%d W=%d H=%d\n\r",X,Y,W,H); | |||
|
129 | if((X>(LCD->width-1)) || (Y>(LCD->height-1)) || ((X+W)>LCD->width) || ((Y+H)>LCD->height)) | |||
|
130 | { | |||
|
131 | printf("Error painting out of screen! %dx%d @%d;%d\n",W,H,X,Y); | |||
|
132 | return; | |||
|
133 | } | |||
|
134 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_HORIZONTALADDRESSENDPOSITION,(uint32_t)(X+W-1)); | |||
|
135 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_HORIZONTALADDRESSSTARTPOSITION,(uint32_t)X); | |||
|
136 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_VERTICALADDRESSENDPOSITION,(uint32_t)(Y+H-1)); | |||
|
137 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_VERTICALADDRESSSTARTPOSITION,(uint32_t)Y); | |||
|
138 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_VERTICALGRAMADDRESSSET,(uint32_t)(Y)); | |||
|
139 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_HORIZONTALGRAMADDRESSSET,(uint32_t)(X)); | |||
39 |
|
140 | |||
|
141 | } | |||
|
142 | ||||
|
143 | ||||
|
144 | void D51E5TA7601paint(LCD_t *LCD, void *buffer, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) | |||
|
145 | { | |||
|
146 | if((LCD!=NULL) && (LCD->interface.lcd_interface!=NULL) && (LCD->interface.lcd_interface->writeGRAM!=NULL) && (LCD->width>=(Xpos+Width)) && (LCD->height>=(Ypos+Height))) | |||
|
147 | { | |||
|
148 | D51E5TA7601setFrame(LCD,Xpos,Ypos,Width,Height); | |||
|
149 | LCD->interface.lcd_interface->writeGRAM(buffer,Width*Height); | |||
|
150 | } | |||
|
151 | } | |||
|
152 | ||||
|
153 | ||||
|
154 | void D51E5TA7601paintFilRect(LCD_t *LCD, uint16_t Xpos, uint16_t Ypos, uint16_t w, uint16_t h, uint32_t contColor, uint16_t contSz, uint32_t fillColor) | |||
|
155 | { | |||
|
156 | D51E5TA7601setFrame(LCD,Xpos,Ypos,w,h); | |||
|
157 | uint16_t tmp[32]; | |||
|
158 | for(int i=0;i<32;i++)tmp[i]=fillColor; | |||
|
159 | for(int i=0;i<(h*w);i+=32) | |||
|
160 | { | |||
|
161 | LCD->interface.lcd_interface->writeGRAM(tmp,32); | |||
|
162 | } | |||
|
163 | int rem=(w*h)%32; | |||
|
164 | if(rem)LCD->interface.lcd_interface->writeGRAM(tmp,rem); | |||
|
165 | if(contSz) | |||
|
166 | { | |||
|
167 | D51E5TA7601setFrame(LCD,Xpos,Ypos,w,contSz); | |||
|
168 | for(int i=0;i<32;i++)tmp[i]=contColor; | |||
|
169 | rem=(w*contSz)%32; | |||
|
170 | if(rem)LCD->interface.lcd_interface->writeGRAM(tmp,rem); | |||
|
171 | for(int i=rem;i<(w*contSz);i+=32) | |||
|
172 | { | |||
|
173 | LCD->interface.lcd_interface->writeGRAM(tmp,32); | |||
|
174 | } | |||
|
175 | ||||
|
176 | D51E5TA7601setFrame(LCD,Xpos,Ypos+h-contSz,w,contSz); | |||
|
177 | rem=(w*contSz)%32; | |||
|
178 | if(rem)LCD->interface.lcd_interface->writeGRAM(tmp,rem); | |||
|
179 | for(int i=rem;i<(w*contSz);i+=32) | |||
|
180 | { | |||
|
181 | LCD->interface.lcd_interface->writeGRAM(tmp,32); | |||
|
182 | } | |||
|
183 | ||||
|
184 | D51E5TA7601setFrame(LCD,Xpos,Ypos,contSz,h); | |||
|
185 | rem=(h*contSz)%32; | |||
|
186 | if(rem)LCD->interface.lcd_interface->writeGRAM(tmp,rem); | |||
|
187 | for(int i=rem;i<(h*contSz);i+=32) | |||
|
188 | { | |||
|
189 | LCD->interface.lcd_interface->writeGRAM(tmp,32); | |||
|
190 | } | |||
|
191 | ||||
|
192 | D51E5TA7601setFrame(LCD,Xpos+w-contSz,Ypos,contSz,h); | |||
|
193 | rem=(h*contSz)%32; | |||
|
194 | if(rem)LCD->interface.lcd_interface->writeGRAM(tmp,rem); | |||
|
195 | for(int i=rem;i<(h*contSz);i+=32) | |||
|
196 | { | |||
|
197 | LCD->interface.lcd_interface->writeGRAM(tmp,32); | |||
|
198 | } | |||
|
199 | } | |||
|
200 | } | |||
|
201 | ||||
|
202 | ||||
|
203 | void D51E5TA7601getPix(struct LCD_t* LCD,uint16_t* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h) | |||
|
204 | { | |||
|
205 | #define __set__Address__(_x_,_y_) LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_HORIZONTALGRAMADDRESSSET,(uint32_t)(_x_)); \ | |||
|
206 | LCD->interface.lcd_interface->writereg(D51E5TA7601_REGISTER_VERTICALGRAMADDRESSSET,(uint32_t)(_y_)) | |||
|
207 | int cx=Xpos,cy=Ypos; | |||
|
208 | D51E5TA7601setFrame(LCD,Xpos,Ypos,w,h); | |||
|
209 | int status; | |||
|
210 | do | |||
|
211 | { | |||
|
212 | status = LCD->interface.lcd_interface->status()>>8; | |||
|
213 | // }while (status>=Ypos && status<=(Ypos+h)); | |||
|
214 | }while (status!=0); | |||
|
215 | ||||
|
216 | LCD->interface.lcd_interface->readGRAM((void*)(buffer),w*h); | |||
|
217 | } | |||
|
218 | ||||
|
219 | ||||
|
220 | void D51E5TA7601paint_FrameBuff(LCD_t *frameBuff, void *buffer, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) | |||
|
221 | { | |||
|
222 | volatile uint16_t* OUTbuffer = (volatile uint16_t*)(frameBuff->interface.buffer); | |||
|
223 | volatile uint16_t* INbuffer = (volatile uint16_t*)buffer; | |||
|
224 | int index =0; | |||
|
225 | for(int Col=Xpos;Col<(Xpos+Width);Col++) | |||
|
226 | { | |||
|
227 | for(int Line=Ypos;Line<(Ypos+Height);Line++) | |||
|
228 | { | |||
|
229 | int i=Line+(Col*frameBuff->height); | |||
|
230 | OUTbuffer[i] = INbuffer[index++]; | |||
|
231 | } | |||
|
232 | } | |||
|
233 | } | |||
40 |
|
234 | |||
41 |
|
235 | |||
|
236 | void D51E5TA7601getPix_FrameBuff(LCD_t *frameBuff, uint16_t *buffer, uint16_t Xpos, uint16_t Ypos, uint16_t w, uint16_t h) | |||
|
237 | { | |||
|
238 | volatile uint16_t* OUTbuffer = (volatile uint16_t*)(frameBuff->interface.buffer); | |||
|
239 | volatile uint16_t* INbuffer = (volatile uint16_t*)buffer; | |||
|
240 | int index =0; | |||
|
241 | for(int Col=Xpos;Col<(Xpos+w);Col++) | |||
|
242 | { | |||
|
243 | for(int Line=Ypos;Line<(Ypos+h);Line++) | |||
|
244 | { | |||
|
245 | int i=Line+(Col*frameBuff->height); | |||
|
246 | INbuffer[index++] = OUTbuffer[i]; | |||
|
247 | } | |||
|
248 | } | |||
|
249 | } | |||
|
250 | ||||
|
251 | ||||
|
252 | int D51E5TA7601init_FrameBuff(LCD_t *LCD) | |||
|
253 | { | |||
|
254 | memset((void*)LCD->interface.buffer,-1,LCD->height*LCD->width*2); | |||
|
255 | return 0; | |||
|
256 | } | |||
|
257 | ||||
|
258 | ||||
|
259 | void D51E5TA7601setFrame_FrameBuff(LCD_t *LCD, uint16_t X, uint16_t Y, uint16_t W, uint16_t H) | |||
|
260 | { | |||
|
261 | return; | |||
|
262 | } | |||
|
263 | ||||
|
264 | ||||
|
265 | void D51E5TA7601refreshenable_FrameBuff(LCD_t *LCD, int enable) | |||
|
266 | { | |||
|
267 | ||||
|
268 | } | |||
|
269 | ||||
|
270 | ||||
|
271 | void D51E5TA7601paintText(LCD_t *LCD, char *buffer, uint16_t Xpos, uint16_t Ypos, sFONT *font, uint32_t color) | |||
|
272 | { | |||
|
273 | ||||
|
274 | } | |||
|
275 | ||||
|
276 | ||||
|
277 | void D51E5TA7601refreshenable(LCD_t *LCD, int enable) | |||
|
278 | { | |||
|
279 | ||||
|
280 | } | |||
42 |
|
281 | |||
43 |
|
282 | |||
|
283 | void D51E5TA7601paintText_FrameBuff(LCD_t *frameBuff, char *buffer, uint16_t Xpos, uint16_t Ypos, sFONT *font, uint32_t color) | |||
|
284 | { | |||
|
285 | int w=font->Width,h=font->Height,bpl=font->bytesPerLine,pix=0,tableoffset=0; | |||
|
286 | uint16_t tmp[w]; | |||
|
287 | uint16_t linenum=0,charnum=0; | |||
|
288 | uint8_t line=0; | |||
|
289 | while(*buffer!='\0') | |||
|
290 | { | |||
|
291 | if(*buffer<32)*buffer=32; | |||
|
292 | if(*buffer>127)*buffer=32; | |||
|
293 | // LCD->setFrame(LCD,Xpos+(charnum*w),Ypos-h,w,1); | |||
|
294 | // LCD->interface->readGRAM(tmp,w); | |||
|
295 | frameBuff->getPix(frameBuff,tmp,Xpos+(charnum*w),Ypos-h,w,1); | |||
|
296 | for(int i=0;i<(h*w);i++) | |||
|
297 | { | |||
|
298 | if( ((i%w)==0) ) //read current line to apply text pixmap | |||
|
299 | { | |||
|
300 | if(linenum++>0) | |||
|
301 | { | |||
|
302 | // LCD->setFrame(LCD,Xpos+(charnum*w),Ypos + linenum -h,w,1); | |||
|
303 | // LCD->interface->writeGRAM(tmp,w); | |||
|
304 | frameBuff->paint(frameBuff,tmp,Xpos+(charnum*w),Ypos + linenum -h,w,1); | |||
|
305 | //ili9328setFrame(LCD,Xpos+(charnum*w),Ypos + linenum + 1-h,w,1); | |||
|
306 | // LCD->interface->readGRAM(tmp,w); | |||
|
307 | frameBuff->getPix(frameBuff,tmp,Xpos+(charnum*w),Ypos + linenum + 1-h,w,1); | |||
|
308 | pix=0; | |||
|
309 | } | |||
|
310 | } | |||
|
311 | if((pix%8) == 0) | |||
|
312 | { | |||
|
313 | line=font->table[(((*buffer)-32)*h*bpl)+tableoffset++]; | |||
|
314 | } | |||
|
315 | //tmp[pix]=0; | |||
|
316 | if((line & (uint8_t)0x01)==(uint8_t)1)tmp[pix]=(uint16_t)color; | |||
|
317 | pix++; | |||
|
318 | line>>=1; | |||
|
319 | } | |||
|
320 | linenum=0; | |||
|
321 | tableoffset=0; | |||
|
322 | charnum++; | |||
|
323 | buffer++; | |||
|
324 | } | |||
|
325 | } | |||
44 |
|
326 | |||
|
327 | ||||
|
328 | void D51E5TA7601paintFilRect_FrameBuff(LCD_t *frameBuff, uint16_t Xpos, uint16_t Ypos, uint16_t w, uint16_t h, uint32_t contColor, uint16_t contSz, uint32_t fillColor) | |||
|
329 | { | |||
|
330 | volatile uint16_t* buffer= frameBuff->interface.buffer; | |||
|
331 | ||||
|
332 | #define drawR(_X_,_Y_,_W_,_H_,_color_) \ | |||
|
333 | for(int line=0;line<(_H_);line++)\ | |||
|
334 | {\ | |||
|
335 | for(int col=0;col<(_W_);col++)\ | |||
|
336 | {\ | |||
|
337 | buffer[(((_X_)+col)*frameBuff->height)+line+(_Y_)]=(_color_);\ | |||
|
338 | }\ | |||
|
339 | } | |||
|
340 | if(((2*contSz)<=w) && ((2*contSz)<=h)) | |||
|
341 | { | |||
|
342 | drawR(Xpos+contSz,Ypos+contSz,w-(2*contSz),h-(2*contSz),fillColor); | |||
|
343 | if(contSz) | |||
|
344 | { | |||
|
345 | drawR(Xpos,Ypos,w,contSz,contColor); | |||
|
346 | drawR(Xpos,Ypos,contSz,h,contColor); | |||
|
347 | drawR(Xpos,Ypos+h-contSz,w,contSz,contColor); | |||
|
348 | drawR(Xpos+w-contSz,Ypos,contSz,h,contColor); | |||
|
349 | } | |||
|
350 | } | |||
|
351 | } | |||
|
352 | ||||
|
353 | ||||
|
354 | void D51E5TA7601paintFB(LCD_t *LCD, LCD_t *frameBuffer) | |||
|
355 | { | |||
|
356 | LCD->paint(LCD,(void*)frameBuffer->interface.buffer,0,0,frameBuffer->height,frameBuffer->width); | |||
|
357 | } |
@@ -1,534 +1,535 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the libuc, microcontroler library |
|
2 | -- This file is a part of the libuc, microcontroler library | |
3 | -- Copyright (C) 2012, Alexis Jeandet |
|
3 | -- Copyright (C) 2012, Alexis Jeandet | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | ------------------------------------------------------------------------------- |
|
18 | ------------------------------------------------------------------------------- | |
19 | -- Author : Alexis Jeandet |
|
19 | -- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | -------------------------------------------------------------------------------*/ |
|
21 | -------------------------------------------------------------------------------*/ | |
22 | #define _PRVATE_ILI9328_ |
|
22 | #define _PRVATE_ILI9328_ | |
23 | #include <ili9328.h> |
|
23 | #include <ili9328.h> | |
24 | #include <stdio.h> |
|
24 | #include <stdio.h> | |
25 | #include <stddef.h> |
|
25 | #include <stddef.h> | |
26 | #include <core.h> |
|
26 | #include <core.h> | |
27 | #include <math.h> |
|
27 | #include <math.h> | |
28 | #include <malloc.h> |
|
28 | #include <malloc.h> | |
29 |
|
29 | |||
30 | #ifdef __OPTIMIZED_MATH |
|
30 | #ifdef __OPTIMIZED_MATH | |
31 | #include <optimised_math.h> |
|
31 | #include <optimised_math.h> | |
32 | #endif |
|
32 | #endif | |
33 |
|
33 | |||
34 |
|
34 | |||
35 | #define ilipaintLine(LCD,X,Y,W,buffer,buffsize) \ |
|
35 | #define ilipaintLine(LCD,X,Y,W,buffer,buffsize) \ | |
36 | for(int l=0;l<1;l++)\ |
|
36 | for(int l=0;l<1;l++)\ | |
37 | {\ |
|
37 | {\ | |
38 | ili9328setFrame(LCD,X,Y,W,1);\ |
|
38 | ili9328setFrame(LCD,X,Y,W,1);\ | |
39 | int rem=(W)%buffsize;\ |
|
39 | int rem=(W)%buffsize;\ | |
40 | if(rem)LCD->interface->writeGRAM(buffer,rem);\ |
|
40 | if(rem)LCD->interface.lcd_interface->writeGRAM(buffer,rem);\ | |
41 | for(int i=rem;i<(W);i+=buffsize)\ |
|
41 | for(int i=rem;i<(W);i+=buffsize)\ | |
42 | {\ |
|
42 | {\ | |
43 | LCD->interface->writeGRAM(buffer,buffsize);\ |
|
43 | LCD->interface.lcd_interface->writeGRAM(buffer,buffsize);\ | |
44 | }\ |
|
44 | }\ | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | #define ilipaintHLineWithCont(LCD,X,Y,W,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \ |
|
47 | #define ilipaintHLineWithCont(LCD,X,Y,W,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \ | |
48 | for(int l=0;l<1;l++)\ |
|
48 | for(int l=0;l<1;l++)\ | |
49 | {\ |
|
49 | {\ | |
50 | ili9328setFrame(LCD,X,Y,W,1);\ |
|
50 | ili9328setFrame(LCD,X,Y,W,1);\ | |
51 | int rem=(ContSz)%buffContsize;\ |
|
51 | int rem=(ContSz)%buffContsize;\ | |
52 | if(rem)LCD->interface->writeGRAM(bufferCont,rem);\ |
|
52 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferCont,rem);\ | |
53 | for(int i=rem;i<(ContSz);i+=buffContsize)\ |
|
53 | for(int i=rem;i<(ContSz);i+=buffContsize)\ | |
54 | {\ |
|
54 | {\ | |
55 | LCD->interface->writeGRAM(bufferCont,buffContsize);\ |
|
55 | LCD->interface.lcd_interface->writeGRAM(bufferCont,buffContsize);\ | |
56 | }\ |
|
56 | }\ | |
57 | if((2*ContSz)<W) \ |
|
57 | if((2*ContSz)<W) \ | |
58 | {\ |
|
58 | {\ | |
59 | rem=(W-(2*ContSz))%buffIntsize;\ |
|
59 | rem=(W-(2*ContSz))%buffIntsize;\ | |
60 | if(rem)LCD->interface->writeGRAM(bufferInt,rem);\ |
|
60 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferInt,rem);\ | |
61 | for(int i=rem;i<(W-(2*ContSz));i+=buffIntsize)\ |
|
61 | for(int i=rem;i<(W-(2*ContSz));i+=buffIntsize)\ | |
62 | {\ |
|
62 | {\ | |
63 | LCD->interface->writeGRAM(bufferInt,buffIntsize);\ |
|
63 | LCD->interface.lcd_interface->writeGRAM(bufferInt,buffIntsize);\ | |
64 | }\ |
|
64 | }\ | |
65 | }\ |
|
65 | }\ | |
66 | rem=(ContSz)%buffContsize;\ |
|
66 | rem=(ContSz)%buffContsize;\ | |
67 | if(rem)LCD->interface->writeGRAM(bufferCont,rem);\ |
|
67 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferCont,rem);\ | |
68 | for(int i=rem;i<(ContSz);i+=buffContsize)\ |
|
68 | for(int i=rem;i<(ContSz);i+=buffContsize)\ | |
69 | {\ |
|
69 | {\ | |
70 | LCD->interface->writeGRAM(bufferCont,buffContsize);\ |
|
70 | LCD->interface.lcd_interface->writeGRAM(bufferCont,buffContsize);\ | |
71 | }\ |
|
71 | }\ | |
72 | }\ |
|
72 | }\ | |
73 |
|
73 | |||
74 |
|
74 | |||
75 | #define ilipaintVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \ |
|
75 | #define ilipaintVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \ | |
76 | for(int l=0;l<1;l++)\ |
|
76 | for(int l=0;l<1;l++)\ | |
77 | {\ |
|
77 | {\ | |
78 | ili9328setFrame(LCD,X,Y,1,H);\ |
|
78 | ili9328setFrame(LCD,X,Y,1,H);\ | |
79 | int rem=(ContSz)%buffContsize;\ |
|
79 | int rem=(ContSz)%buffContsize;\ | |
80 | if(rem)LCD->interface->writeGRAM(bufferCont,rem);\ |
|
80 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferCont,rem);\ | |
81 | for(int i=rem;i<(ContSz);i+=buffContsize)\ |
|
81 | for(int i=rem;i<(ContSz);i+=buffContsize)\ | |
82 | {\ |
|
82 | {\ | |
83 | LCD->interface->writeGRAM(bufferCont,buffContsize);\ |
|
83 | LCD->interface.lcd_interface->writeGRAM(bufferCont,buffContsize);\ | |
84 | }\ |
|
84 | }\ | |
85 | if((2*ContSz)<H) \ |
|
85 | if((2*ContSz)<H) \ | |
86 | {\ |
|
86 | {\ | |
87 | rem=(H-(2*ContSz))%buffIntsize;\ |
|
87 | rem=(H-(2*ContSz))%buffIntsize;\ | |
88 | if(rem)LCD->interface->writeGRAM(bufferInt,rem);\ |
|
88 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferInt,rem);\ | |
89 | for(int i=rem;i<(H-(2*ContSz));i+=buffIntsize)\ |
|
89 | for(int i=rem;i<(H-(2*ContSz));i+=buffIntsize)\ | |
90 | {\ |
|
90 | {\ | |
91 | LCD->interface->writeGRAM(bufferInt,buffIntsize);\ |
|
91 | LCD->interface.lcd_interface->writeGRAM(bufferInt,buffIntsize);\ | |
92 | }\ |
|
92 | }\ | |
93 | }\ |
|
93 | }\ | |
94 | rem=(ContSz)%buffContsize;\ |
|
94 | rem=(ContSz)%buffContsize;\ | |
95 | if(rem)LCD->interface->writeGRAM(bufferCont,rem);\ |
|
95 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferCont,rem);\ | |
96 | for(int i=rem;i<(ContSz);i+=buffContsize)\ |
|
96 | for(int i=rem;i<(ContSz);i+=buffContsize)\ | |
97 | {\ |
|
97 | {\ | |
98 | LCD->interface->writeGRAM(bufferCont,buffContsize);\ |
|
98 | LCD->interface.lcd_interface->writeGRAM(bufferCont,buffContsize);\ | |
99 | }\ |
|
99 | }\ | |
100 | }\ |
|
100 | }\ | |
101 |
|
101 | |||
102 |
|
102 | |||
103 | #define ilipaintHalfTopVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \ |
|
103 | #define ilipaintHalfTopVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \ | |
104 | for(int l=0;l<1;l++)\ |
|
104 | for(int l=0;l<1;l++)\ | |
105 | {\ |
|
105 | {\ | |
106 | ili9328setFrame(LCD,X,Y,1,H);\ |
|
106 | ili9328setFrame(LCD,X,Y,1,H);\ | |
107 | int rem=(ContSz)%buffContsize;\ |
|
107 | int rem=(ContSz)%buffContsize;\ | |
108 | if(rem)LCD->interface->writeGRAM(bufferCont,rem);\ |
|
108 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferCont,rem);\ | |
109 | for(int i=rem;i<(ContSz);i+=buffContsize)\ |
|
109 | for(int i=rem;i<(ContSz);i+=buffContsize)\ | |
110 | {\ |
|
110 | {\ | |
111 | LCD->interface->writeGRAM(bufferCont,buffContsize);\ |
|
111 | LCD->interface.lcd_interface->writeGRAM(bufferCont,buffContsize);\ | |
112 | }\ |
|
112 | }\ | |
113 | if(ContSz<H) \ |
|
113 | if(ContSz<H) \ | |
114 | {\ |
|
114 | {\ | |
115 | rem=(H-ContSz)%buffIntsize;\ |
|
115 | rem=(H-ContSz)%buffIntsize;\ | |
116 | if(rem)LCD->interface->writeGRAM(bufferInt,rem);\ |
|
116 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferInt,rem);\ | |
117 | for(int i=rem;i<(H-ContSz);i+=buffIntsize)\ |
|
117 | for(int i=rem;i<(H-ContSz);i+=buffIntsize)\ | |
118 | {\ |
|
118 | {\ | |
119 | LCD->interface->writeGRAM(bufferInt,buffIntsize);\ |
|
119 | LCD->interface.lcd_interface->writeGRAM(bufferInt,buffIntsize);\ | |
120 | }\ |
|
120 | }\ | |
121 | }\ |
|
121 | }\ | |
122 | }\ |
|
122 | }\ | |
123 |
|
123 | |||
124 |
|
124 | |||
125 | #define ilipaintHalfBottomVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \ |
|
125 | #define ilipaintHalfBottomVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \ | |
126 | for(int l=0;l<1;l++)\ |
|
126 | for(int l=0;l<1;l++)\ | |
127 | {\ |
|
127 | {\ | |
128 | ili9328setFrame(LCD,X,Y,1,H);\ |
|
128 | ili9328setFrame(LCD,X,Y,1,H);\ | |
129 | int rem;\ |
|
129 | int rem;\ | |
130 | if(ContSz<H) \ |
|
130 | if(ContSz<H) \ | |
131 | {\ |
|
131 | {\ | |
132 | rem=(H-ContSz)%buffIntsize;\ |
|
132 | rem=(H-ContSz)%buffIntsize;\ | |
133 | if(rem)LCD->interface->writeGRAM(bufferInt,rem);\ |
|
133 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferInt,rem);\ | |
134 | for(int i=rem;i<(H-ContSz);i+=buffIntsize)\ |
|
134 | for(int i=rem;i<(H-ContSz);i+=buffIntsize)\ | |
135 | {\ |
|
135 | {\ | |
136 | LCD->interface->writeGRAM(bufferInt,buffIntsize);\ |
|
136 | LCD->interface.lcd_interface->writeGRAM(bufferInt,buffIntsize);\ | |
137 | }\ |
|
137 | }\ | |
138 | }\ |
|
138 | }\ | |
139 | rem=(ContSz)%buffContsize;\ |
|
139 | rem=(ContSz)%buffContsize;\ | |
140 | if(rem)LCD->interface->writeGRAM(bufferCont,rem);\ |
|
140 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferCont,rem);\ | |
141 | for(int i=rem;i<(ContSz);i+=buffContsize)\ |
|
141 | for(int i=rem;i<(ContSz);i+=buffContsize)\ | |
142 | {\ |
|
142 | {\ | |
143 | LCD->interface->writeGRAM(bufferCont,buffContsize);\ |
|
143 | LCD->interface.lcd_interface->writeGRAM(bufferCont,buffContsize);\ | |
144 | }\ |
|
144 | }\ | |
145 | }\ |
|
145 | }\ | |
146 |
|
146 | |||
147 |
|
147 | |||
148 | void ili9328setGRAMaddress(LCD_t* LCD,uint16_t Haddress,uint16_t Vaddress) |
|
148 | void ili9328setGRAMaddress(LCD_t* LCD,uint16_t Haddress,uint16_t Vaddress) | |
149 | { |
|
149 | { | |
150 | LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET,Haddress); |
|
150 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET,Haddress); | |
151 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALGRAMADDRESSSET,Vaddress); |
|
151 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_VERTICALGRAMADDRESSSET,Vaddress); | |
152 | } |
|
152 | } | |
153 |
|
153 | |||
154 | void ili9328refreshenable(struct LCD_t* LCD,int enable) |
|
154 | void ili9328refreshenable(struct LCD_t* LCD,int enable) | |
155 | { |
|
155 | { | |
156 | if(enable) |
|
156 | if(enable) | |
157 | { |
|
157 | { | |
158 | //LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE,0x1018); |
|
158 | //LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_ENTRYMODE,0x1018); | |
159 | } |
|
159 | } | |
160 | else |
|
160 | else | |
161 | { |
|
161 | { | |
162 | //LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE,0x1008); |
|
162 | //LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_ENTRYMODE,0x1008); | |
163 |
|
163 | |||
164 | } |
|
164 | } | |
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | void ili9328setFrame(LCD_t* LCD,uint16_t X,uint16_t Y,uint16_t W,uint16_t H) |
|
167 | void ili9328setFrame(LCD_t* LCD,uint16_t X,uint16_t Y,uint16_t W,uint16_t H) | |
168 | { |
|
168 | { | |
169 | if((X>(LCD->width-1)) || (Y>(LCD->height-1)) || ((X+W)>LCD->width) || ((Y+H)>LCD->height)) |
|
169 | if((X>(LCD->width-1)) || (Y>(LCD->height-1)) || ((X+W)>LCD->width) || ((Y+H)>LCD->height)) | |
170 | { |
|
170 | { | |
171 | while (1); |
|
171 | printf("Error painting out of screen!\n"); | |
|
172 | return; | |||
172 | } |
|
173 | } | |
173 | LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION,(uint32_t)X); |
|
174 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION,(uint32_t)X); | |
174 | LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION,(uint32_t)(W+X-1)); |
|
175 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION,(uint32_t)(W+X-1)); | |
175 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION,(uint32_t)Y); |
|
176 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION,(uint32_t)Y); | |
176 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSENDPOSITION,(uint32_t)(Y+H-1)); |
|
177 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_VERTICALADDRESSENDPOSITION,(uint32_t)(Y+H-1)); | |
177 | LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET,(uint32_t)X); |
|
178 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET,(uint32_t)X); | |
178 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALGRAMADDRESSSET,(uint32_t)Y); |
|
179 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_VERTICALGRAMADDRESSSET,(uint32_t)Y); | |
179 | } |
|
180 | } | |
180 |
|
181 | |||
181 | void ili9328paint(LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height) |
|
182 | void ili9328paint(LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height) | |
182 | { |
|
183 | { | |
183 | if((LCD!=NULL) && (LCD->interface!=NULL) && (LCD->interface->writeGRAM!=NULL) && (LCD->width>=(Xpos+Width)) && (LCD->height>=(Ypos+Height))) |
|
184 | if((LCD!=NULL) && (LCD->interface.lcd_interface!=NULL) && (LCD->interface.lcd_interface->writeGRAM!=NULL) && (LCD->width>=(Xpos+Width)) && (LCD->height>=(Ypos+Height))) | |
184 | { |
|
185 | { | |
185 | ili9328setFrame(LCD,Xpos,Ypos,Width,Height); |
|
186 | ili9328setFrame(LCD,Xpos,Ypos,Width,Height); | |
186 | LCD->interface->writeGRAM(buffer,Width*Height); |
|
187 | LCD->interface.lcd_interface->writeGRAM(buffer,Width*Height); | |
187 | } |
|
188 | } | |
188 | } |
|
189 | } | |
189 |
|
190 | |||
190 | void ili9328paintFilCirc(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor) |
|
191 | void ili9328paintFilCirc(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor) | |
191 | { |
|
192 | { | |
192 | //Based on the mid point circle algorithm from Wikipedia |
|
193 | //Based on the mid point circle algorithm from Wikipedia | |
193 | //http://en.wikipedia.org/wiki/Midpoint_circle_algorithm |
|
194 | //http://en.wikipedia.org/wiki/Midpoint_circle_algorithm | |
194 | uint16_t innerbuffer[16]; |
|
195 | uint16_t innerbuffer[16]; | |
195 | uint16_t outterbuffer[16]; |
|
196 | uint16_t outterbuffer[16]; | |
196 | for(int i=0;i<16;i++)innerbuffer[i]=fillColor; |
|
197 | for(int i=0;i<16;i++)innerbuffer[i]=fillColor; | |
197 | for(int i=0;i<16;i++)outterbuffer[i]=contColor; |
|
198 | for(int i=0;i<16;i++)outterbuffer[i]=contColor; | |
198 | if(contSz<r) |
|
199 | if(contSz<r) | |
199 | { |
|
200 | { | |
200 | int error = -r,error_int = -r+contSz; |
|
201 | int error = -r,error_int = -r+contSz; | |
201 | int x = r,x_int=r-contSz; |
|
202 | int x = r,x_int=r-contSz; | |
202 | int y = 0,y_int=0; |
|
203 | int y = 0,y_int=0; | |
203 | while (x >= y) |
|
204 | while (x >= y) | |
204 | { |
|
205 | { | |
205 | ilipaintHLineWithCont(LCD,(Xpos-x),(Ypos+y),(2*x),(x-x_int),innerbuffer,16,outterbuffer,16); |
|
206 | ilipaintHLineWithCont(LCD,(Xpos-x),(Ypos+y),(2*x),(x-x_int),innerbuffer,16,outterbuffer,16); | |
206 | ilipaintHLineWithCont(LCD,(Xpos-x),(Ypos-y),(2*x),(x-x_int),innerbuffer,16,outterbuffer,16); |
|
207 | ilipaintHLineWithCont(LCD,(Xpos-x),(Ypos-y),(2*x),(x-x_int),innerbuffer,16,outterbuffer,16); | |
207 | ilipaintHalfTopVLineWithCont(LCD,(Xpos+y),(Ypos-x),(x),(x-x_int),innerbuffer,16,outterbuffer,16); |
|
208 | ilipaintHalfTopVLineWithCont(LCD,(Xpos+y),(Ypos-x),(x),(x-x_int),innerbuffer,16,outterbuffer,16); | |
208 | ilipaintHalfTopVLineWithCont(LCD,(Xpos-y),(Ypos-x),(x),(x-x_int),innerbuffer,16,outterbuffer,16); |
|
209 | ilipaintHalfTopVLineWithCont(LCD,(Xpos-y),(Ypos-x),(x),(x-x_int),innerbuffer,16,outterbuffer,16); | |
209 | ilipaintHalfBottomVLineWithCont(LCD,(Xpos-y),(Ypos),(x),(x-x_int),innerbuffer,16,outterbuffer,16); |
|
210 | ilipaintHalfBottomVLineWithCont(LCD,(Xpos-y),(Ypos),(x),(x-x_int),innerbuffer,16,outterbuffer,16); | |
210 | ilipaintHalfBottomVLineWithCont(LCD,(Xpos+y),(Ypos),(x),(x-x_int),innerbuffer,16,outterbuffer,16); |
|
211 | ilipaintHalfBottomVLineWithCont(LCD,(Xpos+y),(Ypos),(x),(x-x_int),innerbuffer,16,outterbuffer,16); | |
211 | error += y; |
|
212 | error += y; | |
212 | ++y; |
|
213 | ++y; | |
213 | error += y; |
|
214 | error += y; | |
214 | error_int += y_int; |
|
215 | error_int += y_int; | |
215 | ++y_int; |
|
216 | ++y_int; | |
216 | error_int += y_int; |
|
217 | error_int += y_int; | |
217 | if(error >= 0) |
|
218 | if(error >= 0) | |
218 | { |
|
219 | { | |
219 | error -= x; |
|
220 | error -= x; | |
220 | --x; |
|
221 | --x; | |
221 | error -= x; |
|
222 | error -= x; | |
222 | } |
|
223 | } | |
223 | if(error_int >= 0) |
|
224 | if(error_int >= 0) | |
224 | { |
|
225 | { | |
225 | error_int -= x_int; |
|
226 | error_int -= x_int; | |
226 | --x_int; |
|
227 | --x_int; | |
227 | error_int -= x_int; |
|
228 | error_int -= x_int; | |
228 | } |
|
229 | } | |
229 | } |
|
230 | } | |
230 |
|
231 | |||
231 |
|
232 | |||
232 |
|
233 | |||
233 | } |
|
234 | } | |
234 |
|
235 | |||
235 | } |
|
236 | } | |
236 |
|
237 | |||
237 | void ili9328paintFilCirc_old(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor) |
|
238 | void ili9328paintFilCirc_old(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor) | |
238 | { |
|
239 | { | |
239 | if(contSz<r) |
|
240 | if(contSz<r) | |
240 | { |
|
241 | { | |
241 | uint16_t innerbuffer[16]; |
|
242 | uint16_t innerbuffer[16]; | |
242 | uint16_t outterbuffer[16]; |
|
243 | uint16_t outterbuffer[16]; | |
243 | int32_t rr=(r*r),rr2=((r-contSz)*(r-contSz)),contSz2,Val1,Val2,X1,W,rem; |
|
244 | int32_t rr=(r*r),rr2=((r-contSz)*(r-contSz)),contSz2,Val1,Val2,X1,W,rem; | |
244 | for(int i=0;i<16;i++)innerbuffer[i]=fillColor; |
|
245 | for(int i=0;i<16;i++)innerbuffer[i]=fillColor; | |
245 | for(int i=0;i<16;i++)outterbuffer[i]=contColor; |
|
246 | for(int i=0;i<16;i++)outterbuffer[i]=contColor; | |
246 | /* Y = b +/- sqrt[r^2 - (x - a)^2] */ |
|
247 | /* Y = b +/- sqrt[r^2 - (x - a)^2] */ | |
247 | for(int32_t line=-r;line<r;line++) |
|
248 | for(int32_t line=-r;line<r;line++) | |
248 | { |
|
249 | { | |
249 | #ifdef __OPTIMIZED_MATH |
|
250 | #ifdef __OPTIMIZED_MATH | |
250 | Val1 = (uint32_t)optimised_sqrt((float32_t)(rr - (line*line)) ); |
|
251 | Val1 = (uint32_t)optimised_sqrt((float32_t)(rr - (line*line)) ); | |
251 | Val2 = (uint32_t)optimised_sqrt((float32_t)(rr2 - (line*line)) ); |
|
252 | Val2 = (uint32_t)optimised_sqrt((float32_t)(rr2 - (line*line)) ); | |
252 | #else |
|
253 | #else | |
253 | Val1 = sqrt( (double)(rr - ((line)*(line))) ); |
|
254 | Val1 = sqrt( (double)(rr - ((line)*(line))) ); | |
254 | Val2 = sqrt( (double)(rr2 - ((line)*(line))) ); |
|
255 | Val2 = sqrt( (double)(rr2 - ((line)*(line))) ); | |
255 | #endif |
|
256 | #endif | |
256 | X1=Xpos - Val1; |
|
257 | X1=Xpos - Val1; | |
257 | contSz2= Val1-Val2; |
|
258 | contSz2= Val1-Val2; | |
258 | ili9328setFrame(LCD,X1,line+Ypos,2*Val1,1); |
|
259 | ili9328setFrame(LCD,X1,line+Ypos,2*Val1,1); | |
259 | rem=(contSz2)%16; |
|
260 | rem=(contSz2)%16; | |
260 | if(rem)LCD->interface->writeGRAM(outterbuffer,rem); |
|
261 | if(rem)LCD->interface.lcd_interface->writeGRAM(outterbuffer,rem); | |
261 | for(int i=rem;i<(contSz2);i+=16) |
|
262 | for(int i=rem;i<(contSz2);i+=16) | |
262 | { |
|
263 | { | |
263 | LCD->interface->writeGRAM(outterbuffer,16); |
|
264 | LCD->interface.lcd_interface->writeGRAM(outterbuffer,16); | |
264 | } |
|
265 | } | |
265 |
|
266 | |||
266 | W=2*Val1; |
|
267 | W=2*Val1; | |
267 | if(W>(2*contSz2)) |
|
268 | if(W>(2*contSz2)) | |
268 | { |
|
269 | { | |
269 | W-=2*contSz2; |
|
270 | W-=2*contSz2; | |
270 | rem=(W)%16; |
|
271 | rem=(W)%16; | |
271 | if(rem)LCD->interface->writeGRAM(innerbuffer,rem); |
|
272 | if(rem)LCD->interface.lcd_interface->writeGRAM(innerbuffer,rem); | |
272 | for(int i=rem;i<(W);i+=16) |
|
273 | for(int i=rem;i<(W);i+=16) | |
273 | { |
|
274 | { | |
274 | LCD->interface->writeGRAM(innerbuffer,16); |
|
275 | LCD->interface.lcd_interface->writeGRAM(innerbuffer,16); | |
275 | } |
|
276 | } | |
276 | } |
|
277 | } | |
277 |
|
278 | |||
278 | rem=(contSz2)%16; |
|
279 | rem=(contSz2)%16; | |
279 | if(rem)LCD->interface->writeGRAM(outterbuffer,rem); |
|
280 | if(rem)LCD->interface.lcd_interface->writeGRAM(outterbuffer,rem); | |
280 | for(int i=rem;i<(contSz2);i+=16) |
|
281 | for(int i=rem;i<(contSz2);i+=16) | |
281 | { |
|
282 | { | |
282 | LCD->interface->writeGRAM(outterbuffer,16); |
|
283 | LCD->interface.lcd_interface->writeGRAM(outterbuffer,16); | |
283 | } |
|
284 | } | |
284 | } |
|
285 | } | |
285 | } |
|
286 | } | |
286 | } |
|
287 | } | |
287 |
|
288 | |||
288 |
|
289 | |||
289 |
|
290 | |||
290 |
|
291 | |||
291 | void ili9328paintFilRect(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h,uint32_t contColor,uint16_t contSz,uint32_t fillColor) |
|
292 | void ili9328paintFilRect(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h,uint32_t contColor,uint16_t contSz,uint32_t fillColor) | |
292 | { |
|
293 | { | |
293 | ili9328setFrame(LCD,Xpos,Ypos,w,h); |
|
294 | ili9328setFrame(LCD,Xpos,Ypos,w,h); | |
294 | uint16_t tmp[32]; |
|
295 | uint16_t tmp[32]; | |
295 | for(int i=0;i<32;i++)tmp[i]=fillColor; |
|
296 | for(int i=0;i<32;i++)tmp[i]=fillColor; | |
296 | for(int i=0;i<(h*w);i+=32) |
|
297 | for(int i=0;i<(h*w);i+=32) | |
297 | { |
|
298 | { | |
298 | LCD->interface->writeGRAM(tmp,32); |
|
299 | LCD->interface.lcd_interface->writeGRAM(tmp,32); | |
299 | } |
|
300 | } | |
300 | int rem=(w*h)%32; |
|
301 | int rem=(w*h)%32; | |
301 | if(rem)LCD->interface->writeGRAM(tmp,rem); |
|
302 | if(rem)LCD->interface.lcd_interface->writeGRAM(tmp,rem); | |
302 | if(contSz) |
|
303 | if(contSz) | |
303 | { |
|
304 | { | |
304 | ili9328setFrame(LCD,Xpos,Ypos,w,contSz); |
|
305 | ili9328setFrame(LCD,Xpos,Ypos,w,contSz); | |
305 | for(int i=0;i<32;i++)tmp[i]=contColor; |
|
306 | for(int i=0;i<32;i++)tmp[i]=contColor; | |
306 | rem=(w*contSz)%32; |
|
307 | rem=(w*contSz)%32; | |
307 | if(rem)LCD->interface->writeGRAM(tmp,rem); |
|
308 | if(rem)LCD->interface.lcd_interface->writeGRAM(tmp,rem); | |
308 | for(int i=rem;i<(w*contSz);i+=32) |
|
309 | for(int i=rem;i<(w*contSz);i+=32) | |
309 | { |
|
310 | { | |
310 | LCD->interface->writeGRAM(tmp,32); |
|
311 | LCD->interface.lcd_interface->writeGRAM(tmp,32); | |
311 | } |
|
312 | } | |
312 |
|
313 | |||
313 | ili9328setFrame(LCD,Xpos,Ypos+h-contSz,w,contSz); |
|
314 | ili9328setFrame(LCD,Xpos,Ypos+h-contSz,w,contSz); | |
314 | rem=(w*contSz)%32; |
|
315 | rem=(w*contSz)%32; | |
315 | if(rem)LCD->interface->writeGRAM(tmp,rem); |
|
316 | if(rem)LCD->interface.lcd_interface->writeGRAM(tmp,rem); | |
316 | for(int i=rem;i<(w*contSz);i+=32) |
|
317 | for(int i=rem;i<(w*contSz);i+=32) | |
317 | { |
|
318 | { | |
318 | LCD->interface->writeGRAM(tmp,32); |
|
319 | LCD->interface.lcd_interface->writeGRAM(tmp,32); | |
319 | } |
|
320 | } | |
320 |
|
321 | |||
321 | ili9328setFrame(LCD,Xpos,Ypos,contSz,h); |
|
322 | ili9328setFrame(LCD,Xpos,Ypos,contSz,h); | |
322 | rem=(h*contSz)%32; |
|
323 | rem=(h*contSz)%32; | |
323 | if(rem)LCD->interface->writeGRAM(tmp,rem); |
|
324 | if(rem)LCD->interface.lcd_interface->writeGRAM(tmp,rem); | |
324 | for(int i=rem;i<(h*contSz);i+=32) |
|
325 | for(int i=rem;i<(h*contSz);i+=32) | |
325 | { |
|
326 | { | |
326 | LCD->interface->writeGRAM(tmp,32); |
|
327 | LCD->interface.lcd_interface->writeGRAM(tmp,32); | |
327 | } |
|
328 | } | |
328 |
|
329 | |||
329 | ili9328setFrame(LCD,Xpos+w-contSz,Ypos,contSz,h); |
|
330 | ili9328setFrame(LCD,Xpos+w-contSz,Ypos,contSz,h); | |
330 | rem=(h*contSz)%32; |
|
331 | rem=(h*contSz)%32; | |
331 | if(rem)LCD->interface->writeGRAM(tmp,rem); |
|
332 | if(rem)LCD->interface.lcd_interface->writeGRAM(tmp,rem); | |
332 | for(int i=rem;i<(h*contSz);i+=32) |
|
333 | for(int i=rem;i<(h*contSz);i+=32) | |
333 | { |
|
334 | { | |
334 | LCD->interface->writeGRAM(tmp,32); |
|
335 | LCD->interface.lcd_interface->writeGRAM(tmp,32); | |
335 | } |
|
336 | } | |
336 | } |
|
337 | } | |
337 | } |
|
338 | } | |
338 |
|
339 | |||
339 | void ili9328paintText(LCD_t* LCD,char* buffer,uint16_t Xpos,uint16_t Ypos,sFONT* font,uint32_t color) |
|
340 | void ili9328paintText(LCD_t* LCD,char* buffer,uint16_t Xpos,uint16_t Ypos,sFONT* font,uint32_t color) | |
340 | { |
|
341 | { | |
341 | int w=font->Width,h=font->Height,bpl=font->bytesPerLine,pix=0,tableoffset=0; |
|
342 | int w=font->Width,h=font->Height,bpl=font->bytesPerLine,pix=0,tableoffset=0; | |
342 | uint16_t tmp[w]; |
|
343 | uint16_t tmp[w]; | |
343 | uint16_t linenum=0,charnum=0; |
|
344 | uint16_t linenum=0,charnum=0; | |
344 | uint8_t line=0; |
|
345 | uint8_t line=0; | |
345 | while(*buffer!='\0') |
|
346 | while(*buffer!='\0') | |
346 | { |
|
347 | { | |
347 | if(*buffer<32)*buffer=32; |
|
348 | if(*buffer<32)*buffer=32; | |
348 | if(*buffer>127)*buffer=32; |
|
349 | if(*buffer>127)*buffer=32; | |
349 |
|
|
350 | LCD->setFrame(LCD,Xpos+(charnum*w),Ypos-h,w,1); | |
350 | // LCD->interface->readGRAM(tmp,w); |
|
351 | // LCD->interface->readGRAM(tmp,w); | |
351 |
|
|
352 | LCD->getPix(LCD,tmp,Xpos+(charnum*w),Ypos-h,w,1); | |
352 | for(int i=0;i<(h*w);i++) |
|
353 | for(int i=0;i<(h*w);i++) | |
353 | { |
|
354 | { | |
354 | if( ((i%w)==0) ) //read current line to apply text pixmap |
|
355 | if( ((i%w)==0) ) //read current line to apply text pixmap | |
355 | { |
|
356 | { | |
356 | if(linenum++>0) |
|
357 | if(linenum++>0) | |
357 | { |
|
358 | { | |
358 |
|
|
359 | LCD->setFrame(LCD,Xpos+(charnum*w),Ypos + linenum -h,w,1); | |
359 | LCD->interface->writeGRAM(tmp,w); |
|
360 | LCD->interface.lcd_interface->writeGRAM(tmp,w); | |
360 | //ili9328setFrame(LCD,Xpos+(charnum*w),Ypos + linenum + 1-h,w,1); |
|
361 | //ili9328setFrame(LCD,Xpos+(charnum*w),Ypos + linenum + 1-h,w,1); | |
361 | // LCD->interface->readGRAM(tmp,w); |
|
362 | // LCD->interface->readGRAM(tmp,w); | |
362 |
|
|
363 | LCD->getPix(LCD,tmp,Xpos+(charnum*w),Ypos + linenum + 1-h,w,1); | |
363 | pix=0; |
|
364 | pix=0; | |
364 | } |
|
365 | } | |
365 | } |
|
366 | } | |
366 | if((pix%8) == 0) |
|
367 | if((pix%8) == 0) | |
367 | { |
|
368 | { | |
368 | line=font->table[(((*buffer)-32)*h*bpl)+tableoffset++]; |
|
369 | line=font->table[(((*buffer)-32)*h*bpl)+tableoffset++]; | |
369 | } |
|
370 | } | |
370 | //tmp[pix]=0; |
|
371 | //tmp[pix]=0; | |
371 | if((line & (uint8_t)0x01)==(uint8_t)1)tmp[pix]=(uint16_t)color; |
|
372 | if((line & (uint8_t)0x01)==(uint8_t)1)tmp[pix]=(uint16_t)color; | |
372 | pix++; |
|
373 | pix++; | |
373 | line>>=1; |
|
374 | line>>=1; | |
374 | } |
|
375 | } | |
375 | linenum=0; |
|
376 | linenum=0; | |
376 | tableoffset=0; |
|
377 | tableoffset=0; | |
377 | charnum++; |
|
378 | charnum++; | |
378 | buffer++; |
|
379 | buffer++; | |
379 | } |
|
380 | } | |
380 | } |
|
381 | } | |
381 |
|
382 | |||
382 |
|
383 | |||
383 | void ili9328paintChar(LCD_t* LCD,char buffer,uint16_t Xpos,uint16_t Ypos,sFONT* font,uint32_t color) |
|
384 | void ili9328paintChar(LCD_t* LCD,char buffer,uint16_t Xpos,uint16_t Ypos,sFONT* font,uint32_t color) | |
384 | { |
|
385 | { | |
385 | int w=font->Width,h=font->Height,bpl=font->bytesPerLine,pix=0,tableoffset=0; |
|
386 | int w=font->Width,h=font->Height,bpl=font->bytesPerLine,pix=0,tableoffset=0; | |
386 | uint16_t tmp[w]; |
|
387 | uint16_t tmp[w]; | |
387 | uint16_t tmp2[w]; |
|
388 | uint16_t tmp2[w]; | |
388 | uint16_t linenum=0,charnum=0; |
|
389 | uint16_t linenum=0,charnum=0; | |
389 | uint8_t line=0; |
|
390 | uint8_t line=0; | |
390 | if(buffer<32)buffer=32; |
|
391 | if(buffer<32)buffer=32; | |
391 | if(buffer>127)buffer=32; |
|
392 | if(buffer>127)buffer=32; | |
392 | ili9328setFrame(LCD,Xpos,Ypos-h,w,1); |
|
393 | ili9328setFrame(LCD,Xpos,Ypos-h,w,1); | |
393 | // LCD->interface->readGRAM(tmp,w); |
|
394 | // LCD->interface->readGRAM(tmp,w); | |
394 | ili9328getPix(LCD,tmp2,Xpos,Ypos-h,w,1); |
|
395 | ili9328getPix(LCD,tmp2,Xpos,Ypos-h,w,1); | |
395 | for(int i=0;i<w;i++) |
|
396 | for(int i=0;i<w;i++) | |
396 | { |
|
397 | { | |
397 | tmp[i]=0; |
|
398 | tmp[i]=0; | |
398 | } |
|
399 | } | |
399 | for(int i=0;i<(h*w);i++) |
|
400 | for(int i=0;i<(h*w);i++) | |
400 | { |
|
401 | { | |
401 | if( ((i%w)==0) ) //read current line to apply text pixmap |
|
402 | if( ((i%w)==0) ) //read current line to apply text pixmap | |
402 | { |
|
403 | { | |
403 | if(linenum++>0) |
|
404 | if(linenum++>0) | |
404 | { |
|
405 | { | |
405 | ili9328setFrame(LCD,Xpos,Ypos + linenum -h,w,1); |
|
406 | ili9328setFrame(LCD,Xpos,Ypos + linenum -h,w,1); | |
406 | LCD->interface->writeGRAM(tmp,w); |
|
407 | LCD->interface.lcd_interface->writeGRAM(tmp,w); | |
407 | //ili9328setFrame(LCD,Xpos+(charnum*w),Ypos + linenum + 1-h,w,1); |
|
408 | //ili9328setFrame(LCD,Xpos+(charnum*w),Ypos + linenum + 1-h,w,1); | |
408 | // LCD->interface->readGRAM(tmp,w); |
|
409 | // LCD->interface->readGRAM(tmp,w); | |
409 | ili9328getPix(LCD,tmp2,Xpos,Ypos + linenum + 1-h,w,1); |
|
410 | ili9328getPix(LCD,tmp2,Xpos,Ypos + linenum + 1-h,w,1); | |
410 | for(int i=0;i<w;i++) |
|
411 | for(int i=0;i<w;i++) | |
411 | { |
|
412 | { | |
412 | tmp[i]=0; |
|
413 | tmp[i]=0; | |
413 | } |
|
414 | } | |
414 | pix=0; |
|
415 | pix=0; | |
415 | } |
|
416 | } | |
416 | } |
|
417 | } | |
417 | if((pix%8) == 0) |
|
418 | if((pix%8) == 0) | |
418 | { |
|
419 | { | |
419 | line=font->table[(((buffer)-32)*h*bpl)+tableoffset++]; |
|
420 | line=font->table[(((buffer)-32)*h*bpl)+tableoffset++]; | |
420 | } |
|
421 | } | |
421 | //tmp[pix]=0; |
|
422 | //tmp[pix]=0; | |
422 | if((line & (uint8_t)0x01)==(uint8_t)1)tmp[pix]=(uint16_t)color; |
|
423 | if((line & (uint8_t)0x01)==(uint8_t)1)tmp[pix]=(uint16_t)color; | |
423 | pix++; |
|
424 | pix++; | |
424 | line>>=1; |
|
425 | line>>=1; | |
425 | } |
|
426 | } | |
426 |
|
427 | |||
427 | } |
|
428 | } | |
428 |
|
429 | |||
429 | int ili9328init(struct LCD_t* LCD) |
|
430 | int ili9328init(struct LCD_t* LCD) | |
430 | { |
|
431 | { | |
431 | if((LCD!=NULL) && (LCD->interface!=NULL) && (LCD->interface->writereg!=NULL)) |
|
432 | if((LCD!=NULL) && (LCD->interface.lcd_interface!=NULL) && (LCD->interface.lcd_interface->writereg!=NULL)) | |
432 | { |
|
433 | { | |
433 | LCD->interface->writereg(ILI9328_REGISTER_DRIVEROUTPUTCONTROL1, 0x0100); // Driver Output Control Register (R01h) |
|
434 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_DRIVEROUTPUTCONTROL1, 0x0100); // Driver Output Control Register (R01h) | |
434 | LCD->interface->writereg(ILI9328_REGISTER_LCDDRIVINGCONTROL, 0x0700); // LCD Driving Waveform Control (R02h) |
|
435 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_LCDDRIVINGCONTROL, 0x0700); // LCD Driving Waveform Control (R02h) | |
435 | LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE, 0x0230); // Entry Mode (R03h) |
|
436 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_ENTRYMODE, 0x0230); // Entry Mode (R03h) | |
436 | LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL1, 0xC000); |
|
437 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL1, 0xC000); | |
437 | LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL2, 0x0302); |
|
438 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL2, 0x0302); | |
438 | LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL3, 0x0000); |
|
439 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL3, 0x0000); | |
439 | LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL4, 0x0000); // Fmark On |
|
440 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL4, 0x0000); // Fmark On | |
440 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL1, 0x0000); // Power Control 1 (R10h) |
|
441 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_POWERCONTROL1, 0x0000); // Power Control 1 (R10h) | |
441 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL2, 0x0007); // Power Control 2 (R11h) |
|
442 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_POWERCONTROL2, 0x0007); // Power Control 2 (R11h) | |
442 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL3, 0x0000); // Power Control 3 (R12h) |
|
443 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_POWERCONTROL3, 0x0000); // Power Control 3 (R12h) | |
443 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL4, 0x0000); // Power Control 4 (R13h) |
|
444 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_POWERCONTROL4, 0x0000); // Power Control 4 (R13h) | |
444 | delay_100us(1000); |
|
445 | delay_100us(1000); | |
445 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL1, 0x14B0); // Power Control 1 (R10h) |
|
446 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_POWERCONTROL1, 0x14B0); // Power Control 1 (R10h) | |
446 | delay_100us(500); |
|
447 | delay_100us(500); | |
447 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL2, 0x0007); // Power Control 2 (R11h) |
|
448 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_POWERCONTROL2, 0x0007); // Power Control 2 (R11h) | |
448 | delay_100us(500); |
|
449 | delay_100us(500); | |
449 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL3, 0x008E); // Power Control 3 (R12h) |
|
450 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_POWERCONTROL3, 0x008E); // Power Control 3 (R12h) | |
450 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL4, 0x0C00); // Power Control 4 (R13h) |
|
451 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_POWERCONTROL4, 0x0C00); // Power Control 4 (R13h) | |
451 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL7, 0x0015); // NVM read data 2 (R29h) |
|
452 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_POWERCONTROL7, 0x0015); // NVM read data 2 (R29h) | |
452 | delay_100us(500); |
|
453 | delay_100us(500); | |
453 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL1, 0x0000); // Gamma Control 1 |
|
454 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_GAMMACONTROL1, 0x0000); // Gamma Control 1 | |
454 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL2, 0x0107); // Gamma Control 2 |
|
455 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_GAMMACONTROL2, 0x0107); // Gamma Control 2 | |
455 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL3, 0x0000); // Gamma Control 3 |
|
456 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_GAMMACONTROL3, 0x0000); // Gamma Control 3 | |
456 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL4, 0x0203); // Gamma Control 4 |
|
457 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_GAMMACONTROL4, 0x0203); // Gamma Control 4 | |
457 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL5, 0x0402); // Gamma Control 5 |
|
458 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_GAMMACONTROL5, 0x0402); // Gamma Control 5 | |
458 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL6, 0x0000); // Gamma Control 6 |
|
459 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_GAMMACONTROL6, 0x0000); // Gamma Control 6 | |
459 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL7, 0x0207); // Gamma Control 7 |
|
460 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_GAMMACONTROL7, 0x0207); // Gamma Control 7 | |
460 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL8, 0x0000); // Gamma Control 8 |
|
461 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_GAMMACONTROL8, 0x0000); // Gamma Control 8 | |
461 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL9, 0x0203); // Gamma Control 9 |
|
462 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_GAMMACONTROL9, 0x0203); // Gamma Control 9 | |
462 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL10, 0x0403); // Gamma Control 10 |
|
463 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_GAMMACONTROL10, 0x0403); // Gamma Control 10 | |
463 | LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION, 0x0000); // Window Horizontal RAM Address Start (R50h) |
|
464 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION, 0x0000); // Window Horizontal RAM Address Start (R50h) | |
464 | LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION, LCD->width - 1); // Window Horizontal RAM Address End (R51h) |
|
465 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION, LCD->width - 1); // Window Horizontal RAM Address End (R51h) | |
465 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION, 0X0000); // Window Vertical RAM Address Start (R52h) |
|
466 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION, 0X0000); // Window Vertical RAM Address Start (R52h) | |
466 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSENDPOSITION, LCD->height - 1); // Window Vertical RAM Address End (R53h) |
|
467 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_VERTICALADDRESSENDPOSITION, LCD->height - 1); // Window Vertical RAM Address End (R53h) | |
467 | LCD->interface->writereg(ILI9328_REGISTER_DRIVEROUTPUTCONTROL2, 0xa700); // Driver Output Control (R60h) |
|
468 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_DRIVEROUTPUTCONTROL2, 0xa700); // Driver Output Control (R60h) | |
468 | LCD->interface->writereg(ILI9328_REGISTER_BASEIMAGEDISPLAYCONTROL, 0x0003); // Driver Output Control (R61h) - enable VLE |
|
469 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_BASEIMAGEDISPLAYCONTROL, 0x0003); // Driver Output Control (R61h) - enable VLE | |
469 | LCD->interface->writereg(ILI9328_REGISTER_PANELINTERFACECONTROL1, 0X0010); // Panel Interface Control 1 (R90h) |
|
470 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_PANELINTERFACECONTROL1, 0X0010); // Panel Interface Control 1 (R90h) | |
470 | // Display On |
|
471 | // Display On | |
471 | LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL1, 0x0133); // Display Control (R07h) |
|
472 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL1, 0x0133); // Display Control (R07h) | |
472 | delay_100us(500); |
|
473 | delay_100us(500); | |
473 | LCD->paintFilRect(LCD,0,0,LCD->width,LCD->height,0,0,0xFFFF); |
|
474 | LCD->paintFilRect(LCD,0,0,LCD->width,LCD->height,0,0,0xFFFF); | |
474 | } |
|
475 | } | |
475 | return 0; |
|
476 | return 0; | |
476 | } |
|
477 | } | |
477 |
|
478 | |||
478 | void ili9328cpFrame(LCD_t* LCD,void* buffer,int x,int y,int w, int h) |
|
479 | void ili9328cpFrame(LCD_t* LCD,void* buffer,int x,int y,int w, int h) | |
479 | { |
|
480 | { | |
480 | #define __set__Address__(_x_,_y_) LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET,_x_); \ |
|
481 | #define __set__Address__(_x_,_y_) LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET,_x_); \ | |
481 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALGRAMADDRESSSET,_y_) |
|
482 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_VERTICALGRAMADDRESSSET,_y_) | |
482 |
|
483 | |||
483 | uint16_t* castedBuff = (uint16_t*)buffer; |
|
484 | uint16_t* castedBuff = (uint16_t*)buffer; | |
484 | int cx=x,cy=y; |
|
485 | int cx=x,cy=y; | |
485 | for(int i=0;i<(w*h);i++) |
|
486 | for(int i=0;i<(w*h);i++) | |
486 | { |
|
487 | { | |
487 | __set__Address__(cx,cy); |
|
488 | __set__Address__(cx,cy); | |
488 | LCD->interface->readGRAM((void*)(&castedBuff[i]),1); |
|
489 | LCD->interface.lcd_interface->readGRAM((void*)(&castedBuff[i]),1); | |
489 | cx+=1; |
|
490 | cx+=1; | |
490 | if(cx>=(w+x)) |
|
491 | if(cx>=(w+x)) | |
491 | { |
|
492 | { | |
492 | cx=x; |
|
493 | cx=x; | |
493 | cy+=1; |
|
494 | cy+=1; | |
494 | } |
|
495 | } | |
495 | } |
|
496 | } | |
496 | } |
|
497 | } | |
497 |
|
498 | |||
498 |
|
499 | |||
499 |
|
500 | |||
500 | void ili9328getPix(struct LCD_t* LCD,uint16_t* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h) |
|
501 | void ili9328getPix(struct LCD_t* LCD,uint16_t* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h) | |
501 | { |
|
502 | { | |
502 | #define __set__Address__(_x_,_y_) LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET,_x_); \ |
|
503 | #define __set__Address__(_x_,_y_) LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET,_x_); \ | |
503 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALGRAMADDRESSSET,_y_) |
|
504 | LCD->interface.lcd_interface->writereg(ILI9328_REGISTER_VERTICALGRAMADDRESSSET,_y_) | |
504 |
|
505 | |||
505 | int cx=Xpos,cy=Ypos; |
|
506 | int cx=Xpos,cy=Ypos; | |
506 | ili9328setFrame(LCD,Xpos,Ypos,w,h); |
|
507 | ili9328setFrame(LCD,Xpos,Ypos,w,h); | |
507 | for(int i=0;i<(w*h);i++) |
|
508 | for(int i=0;i<(w*h);i++) | |
508 | { |
|
509 | { | |
509 | __set__Address__(cx,cy); |
|
510 | __set__Address__(cx,cy); | |
510 | LCD->interface->readGRAM((void*)(&buffer[i]),1); |
|
511 | LCD->interface.lcd_interface->readGRAM((void*)(&buffer[i]),1); | |
511 | cx+=1; |
|
512 | cx+=1; | |
512 | if(cx>=(w+Xpos)) |
|
513 | if(cx>=(w+Xpos)) | |
513 | { |
|
514 | { | |
514 | cx=Xpos; |
|
515 | cx=Xpos; | |
515 | cy+=1; |
|
516 | cy+=1; | |
516 | } |
|
517 | } | |
517 | } |
|
518 | } | |
518 |
|
519 | |||
519 | } |
|
520 | } | |
520 |
|
521 | |||
521 |
|
522 | |||
522 |
|
523 | |||
523 |
|
524 | |||
524 |
|
525 | |||
525 |
|
526 | |||
526 |
|
527 | |||
527 |
|
528 | |||
528 |
|
529 | |||
529 |
|
530 | |||
530 |
|
531 | |||
531 |
|
532 | |||
532 |
|
533 | |||
533 |
|
534 | |||
534 |
|
535 |
@@ -1,416 +1,416 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the libuc, microcontroler library |
|
2 | -- This file is a part of the libuc, microcontroler library | |
3 | -- Copyright (C) 2013, Alexis Jeandet |
|
3 | -- Copyright (C) 2013, Alexis Jeandet | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | ------------------------------------------------------------------------------- |
|
18 | ------------------------------------------------------------------------------- | |
19 | -- Author : Alexis Jeandet |
|
19 | -- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | -------------------------------------------------------------------------------*/ |
|
21 | -------------------------------------------------------------------------------*/ | |
22 | #include <ssd2119.h> |
|
22 | #include <ssd2119.h> | |
23 | #include <stdio.h> |
|
23 | #include <stdio.h> | |
24 | #include <stddef.h> |
|
24 | #include <stddef.h> | |
25 | #include <core.h> |
|
25 | #include <core.h> | |
26 | #include <math.h> |
|
26 | #include <math.h> | |
27 |
|
27 | |||
28 | #ifdef __OPTIMIZED_MATH |
|
28 | #ifdef __OPTIMIZED_MATH | |
29 | #include <optimised_math.h> |
|
29 | #include <optimised_math.h> | |
30 | #endif |
|
30 | #endif | |
31 |
|
31 | |||
32 | #define _delay_(del) for(volatile int _d_e_l_=0;_d_e_l_<(del);_d_e_l_++); |
|
32 | #define _delay_(del) for(volatile int _d_e_l_=0;_d_e_l_<(del);_d_e_l_++); | |
33 |
|
33 | |||
34 | #define ilipaintLine(LCD,X,Y,W,buffer,buffsize) \ |
|
34 | #define ilipaintLine(LCD,X,Y,W,buffer,buffsize) \ | |
35 | for(int l=0;l<1;l++)\ |
|
35 | for(int l=0;l<1;l++)\ | |
36 | {\ |
|
36 | {\ | |
37 | ssd2119setFrame(LCD,X,Y,W,1);\ |
|
37 | ssd2119setFrame(LCD,X,Y,W,1);\ | |
38 | int rem=(W)%buffsize;\ |
|
38 | int rem=(W)%buffsize;\ | |
39 | if(rem)LCD->interface->writeGRAM(buffer,rem);\ |
|
39 | if(rem)LCD->interface.lcd_interface->writeGRAM(buffer,rem);\ | |
40 | for(int i=rem;i<(W);i+=buffsize)\ |
|
40 | for(int i=rem;i<(W);i+=buffsize)\ | |
41 | {\ |
|
41 | {\ | |
42 | LCD->interface->writeGRAM(buffer,buffsize);\ |
|
42 | LCD->interface.lcd_interface->writeGRAM(buffer,buffsize);\ | |
43 | }\ |
|
43 | }\ | |
44 | } |
|
44 | } | |
45 |
|
45 | |||
46 | #define ilipaintHLineWithCont(LCD,X,Y,W,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \ |
|
46 | #define ilipaintHLineWithCont(LCD,X,Y,W,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \ | |
47 | for(int l=0;l<1;l++)\ |
|
47 | for(int l=0;l<1;l++)\ | |
48 | {\ |
|
48 | {\ | |
49 | ssd2119setFrame(LCD,X,Y,W,1);\ |
|
49 | ssd2119setFrame(LCD,X,Y,W,1);\ | |
50 | int rem=(ContSz)%buffContsize;\ |
|
50 | int rem=(ContSz)%buffContsize;\ | |
51 | if(rem)LCD->interface->writeGRAM(bufferCont,rem);\ |
|
51 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferCont,rem);\ | |
52 | for(int i=rem;i<(ContSz);i+=buffContsize)\ |
|
52 | for(int i=rem;i<(ContSz);i+=buffContsize)\ | |
53 | {\ |
|
53 | {\ | |
54 | LCD->interface->writeGRAM(bufferCont,buffContsize);\ |
|
54 | LCD->interface.lcd_interface->writeGRAM(bufferCont,buffContsize);\ | |
55 | }\ |
|
55 | }\ | |
56 | if((2*ContSz)<W) \ |
|
56 | if((2*ContSz)<W) \ | |
57 | {\ |
|
57 | {\ | |
58 | rem=(W-(2*ContSz))%buffIntsize;\ |
|
58 | rem=(W-(2*ContSz))%buffIntsize;\ | |
59 | if(rem)LCD->interface->writeGRAM(bufferInt,rem);\ |
|
59 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferInt,rem);\ | |
60 | for(int i=rem;i<(W-(2*ContSz));i+=buffIntsize)\ |
|
60 | for(int i=rem;i<(W-(2*ContSz));i+=buffIntsize)\ | |
61 | {\ |
|
61 | {\ | |
62 | LCD->interface->writeGRAM(bufferInt,buffIntsize);\ |
|
62 | LCD->interface.lcd_interface->writeGRAM(bufferInt,buffIntsize);\ | |
63 | }\ |
|
63 | }\ | |
64 | }\ |
|
64 | }\ | |
65 | rem=(ContSz)%buffContsize;\ |
|
65 | rem=(ContSz)%buffContsize;\ | |
66 | if(rem)LCD->interface->writeGRAM(bufferCont,rem);\ |
|
66 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferCont,rem);\ | |
67 | for(int i=rem;i<(ContSz);i+=buffContsize)\ |
|
67 | for(int i=rem;i<(ContSz);i+=buffContsize)\ | |
68 | {\ |
|
68 | {\ | |
69 | LCD->interface->writeGRAM(bufferCont,buffContsize);\ |
|
69 | LCD->interface.lcd_interface->writeGRAM(bufferCont,buffContsize);\ | |
70 | }\ |
|
70 | }\ | |
71 | }\ |
|
71 | }\ | |
72 |
|
72 | |||
73 |
|
73 | |||
74 | #define ilipaintVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \ |
|
74 | #define ilipaintVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \ | |
75 | for(int l=0;l<1;l++)\ |
|
75 | for(int l=0;l<1;l++)\ | |
76 | {\ |
|
76 | {\ | |
77 | ssd2119setFrame(LCD,X,Y,1,H);\ |
|
77 | ssd2119setFrame(LCD,X,Y,1,H);\ | |
78 | int rem=(ContSz)%buffContsize;\ |
|
78 | int rem=(ContSz)%buffContsize;\ | |
79 | if(rem)LCD->interface->writeGRAM(bufferCont,rem);\ |
|
79 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferCont,rem);\ | |
80 | for(int i=rem;i<(ContSz);i+=buffContsize)\ |
|
80 | for(int i=rem;i<(ContSz);i+=buffContsize)\ | |
81 | {\ |
|
81 | {\ | |
82 | LCD->interface->writeGRAM(bufferCont,buffContsize);\ |
|
82 | LCD->interface.lcd_interface->writeGRAM(bufferCont,buffContsize);\ | |
83 | }\ |
|
83 | }\ | |
84 | if((2*ContSz)<H) \ |
|
84 | if((2*ContSz)<H) \ | |
85 | {\ |
|
85 | {\ | |
86 | rem=(H-(2*ContSz))%buffIntsize;\ |
|
86 | rem=(H-(2*ContSz))%buffIntsize;\ | |
87 | if(rem)LCD->interface->writeGRAM(bufferInt,rem);\ |
|
87 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferInt,rem);\ | |
88 | for(int i=rem;i<(H-(2*ContSz));i+=buffIntsize)\ |
|
88 | for(int i=rem;i<(H-(2*ContSz));i+=buffIntsize)\ | |
89 | {\ |
|
89 | {\ | |
90 | LCD->interface->writeGRAM(bufferInt,buffIntsize);\ |
|
90 | LCD->interface.lcd_interface->writeGRAM(bufferInt,buffIntsize);\ | |
91 | }\ |
|
91 | }\ | |
92 | }\ |
|
92 | }\ | |
93 | rem=(ContSz)%buffContsize;\ |
|
93 | rem=(ContSz)%buffContsize;\ | |
94 | if(rem)LCD->interface->writeGRAM(bufferCont,rem);\ |
|
94 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferCont,rem);\ | |
95 | for(int i=rem;i<(ContSz);i+=buffContsize)\ |
|
95 | for(int i=rem;i<(ContSz);i+=buffContsize)\ | |
96 | {\ |
|
96 | {\ | |
97 | LCD->interface->writeGRAM(bufferCont,buffContsize);\ |
|
97 | LCD->interface.lcd_interface->writeGRAM(bufferCont,buffContsize);\ | |
98 | }\ |
|
98 | }\ | |
99 | }\ |
|
99 | }\ | |
100 |
|
100 | |||
101 |
|
101 | |||
102 | #define ilipaintHalfTopVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \ |
|
102 | #define ilipaintHalfTopVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \ | |
103 | for(int l=0;l<1;l++)\ |
|
103 | for(int l=0;l<1;l++)\ | |
104 | {\ |
|
104 | {\ | |
105 | ssd2119setFrame(LCD,X,Y,1,H);\ |
|
105 | ssd2119setFrame(LCD,X,Y,1,H);\ | |
106 | int rem=(ContSz)%buffContsize;\ |
|
106 | int rem=(ContSz)%buffContsize;\ | |
107 | if(rem)LCD->interface->writeGRAM(bufferCont,rem);\ |
|
107 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferCont,rem);\ | |
108 | for(int i=rem;i<(ContSz);i+=buffContsize)\ |
|
108 | for(int i=rem;i<(ContSz);i+=buffContsize)\ | |
109 | {\ |
|
109 | {\ | |
110 | LCD->interface->writeGRAM(bufferCont,buffContsize);\ |
|
110 | LCD->interface.lcd_interface->writeGRAM(bufferCont,buffContsize);\ | |
111 | }\ |
|
111 | }\ | |
112 | if(ContSz<H) \ |
|
112 | if(ContSz<H) \ | |
113 | {\ |
|
113 | {\ | |
114 | rem=(H-ContSz)%buffIntsize;\ |
|
114 | rem=(H-ContSz)%buffIntsize;\ | |
115 | if(rem)LCD->interface->writeGRAM(bufferInt,rem);\ |
|
115 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferInt,rem);\ | |
116 | for(int i=rem;i<(H-ContSz);i+=buffIntsize)\ |
|
116 | for(int i=rem;i<(H-ContSz);i+=buffIntsize)\ | |
117 | {\ |
|
117 | {\ | |
118 | LCD->interface->writeGRAM(bufferInt,buffIntsize);\ |
|
118 | LCD->interface.lcd_interface->writeGRAM(bufferInt,buffIntsize);\ | |
119 | }\ |
|
119 | }\ | |
120 | }\ |
|
120 | }\ | |
121 | }\ |
|
121 | }\ | |
122 |
|
122 | |||
123 |
|
123 | |||
124 | #define ilipaintHalfBottomVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \ |
|
124 | #define ilipaintHalfBottomVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \ | |
125 | for(int l=0;l<1;l++)\ |
|
125 | for(int l=0;l<1;l++)\ | |
126 | {\ |
|
126 | {\ | |
127 | ssd2119setFrame(LCD,X,Y,1,H);\ |
|
127 | ssd2119setFrame(LCD,X,Y,1,H);\ | |
128 | int rem;\ |
|
128 | int rem;\ | |
129 | if(ContSz<H) \ |
|
129 | if(ContSz<H) \ | |
130 | {\ |
|
130 | {\ | |
131 | rem=(H-ContSz)%buffIntsize;\ |
|
131 | rem=(H-ContSz)%buffIntsize;\ | |
132 | if(rem)LCD->interface->writeGRAM(bufferInt,rem);\ |
|
132 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferInt,rem);\ | |
133 | for(int i=rem;i<(H-ContSz);i+=buffIntsize)\ |
|
133 | for(int i=rem;i<(H-ContSz);i+=buffIntsize)\ | |
134 | {\ |
|
134 | {\ | |
135 | LCD->interface->writeGRAM(bufferInt,buffIntsize);\ |
|
135 | LCD->interface.lcd_interface->writeGRAM(bufferInt,buffIntsize);\ | |
136 | }\ |
|
136 | }\ | |
137 | }\ |
|
137 | }\ | |
138 | rem=(ContSz)%buffContsize;\ |
|
138 | rem=(ContSz)%buffContsize;\ | |
139 | if(rem)LCD->interface->writeGRAM(bufferCont,rem);\ |
|
139 | if(rem)LCD->interface.lcd_interface->writeGRAM(bufferCont,rem);\ | |
140 | for(int i=rem;i<(ContSz);i+=buffContsize)\ |
|
140 | for(int i=rem;i<(ContSz);i+=buffContsize)\ | |
141 | {\ |
|
141 | {\ | |
142 | LCD->interface->writeGRAM(bufferCont,buffContsize);\ |
|
142 | LCD->interface.lcd_interface->writeGRAM(bufferCont,buffContsize);\ | |
143 | }\ |
|
143 | }\ | |
144 | }\ |
|
144 | }\ | |
145 |
|
145 | |||
146 |
|
146 | |||
147 | void ssd2119setGRAMaddress(LCD_t* LCD,uint16_t Haddress,uint16_t Vaddress) |
|
147 | void ssd2119setGRAMaddress(LCD_t* LCD,uint16_t Haddress,uint16_t Vaddress) | |
148 | { |
|
148 | { | |
149 | LCD->interface->writereg(SSD2119_REGISTER_X_RAM_ADDR,Haddress); |
|
149 | LCD->interface.lcd_interface->writereg(SSD2119_REGISTER_X_RAM_ADDR,Haddress); | |
150 | LCD->interface->writereg(SSD2119_REGISTER_Y_RAM_ADDR,Vaddress); |
|
150 | LCD->interface.lcd_interface->writereg(SSD2119_REGISTER_Y_RAM_ADDR,Vaddress); | |
151 | } |
|
151 | } | |
152 |
|
152 | |||
153 | void ssd2119refreshenable(struct LCD_t* LCD,int enable) |
|
153 | void ssd2119refreshenable(struct LCD_t* LCD,int enable) | |
154 | { |
|
154 | { | |
155 | if(enable) |
|
155 | if(enable) | |
156 | { |
|
156 | { | |
157 | //LCD->interface->writereg(ssd2119_REGISTER_ENTRYMODE,0x1018); |
|
157 | //LCD->interface->writereg(ssd2119_REGISTER_ENTRYMODE,0x1018); | |
158 | } |
|
158 | } | |
159 | else |
|
159 | else | |
160 | { |
|
160 | { | |
161 | //LCD->interface->writereg(ssd2119_REGISTER_ENTRYMODE,0x1008); |
|
161 | //LCD->interface->writereg(ssd2119_REGISTER_ENTRYMODE,0x1008); | |
162 |
|
162 | |||
163 | } |
|
163 | } | |
164 | } |
|
164 | } | |
165 |
|
165 | |||
166 | void ssd2119setFrame(LCD_t* LCD,uint16_t X,uint16_t Y,uint16_t W,uint16_t H) |
|
166 | void ssd2119setFrame(LCD_t* LCD,uint16_t X,uint16_t Y,uint16_t W,uint16_t H) | |
167 | { |
|
167 | { | |
168 | LCD->interface->writereg(SSD2119_REGISTER_X_RAM_ADDR,(uint32_t)X); |
|
168 | LCD->interface.lcd_interface->writereg(SSD2119_REGISTER_X_RAM_ADDR,(uint32_t)X); | |
169 | LCD->interface->writereg(SSD2119_REGISTER_Y_RAM_ADDR,(uint32_t)Y); |
|
169 | LCD->interface.lcd_interface->writereg(SSD2119_REGISTER_Y_RAM_ADDR,(uint32_t)Y); | |
170 | LCD->interface->writereg(SSD2119_REGISTER_H_RAM_START,(uint32_t)X); |
|
170 | LCD->interface.lcd_interface->writereg(SSD2119_REGISTER_H_RAM_START,(uint32_t)X); | |
171 | LCD->interface->writereg(SSD2119_REGISTER_H_RAM_END,(uint32_t)(W+X-1)); |
|
171 | LCD->interface.lcd_interface->writereg(SSD2119_REGISTER_H_RAM_END,(uint32_t)(W+X-1)); | |
172 | LCD->interface->writereg(SSD2119_REGISTER_V_RAM_POS,(((uint32_t)(Y+H-1))<<8) + (uint32_t)Y); |
|
172 | LCD->interface.lcd_interface->writereg(SSD2119_REGISTER_V_RAM_POS,(((uint32_t)(Y+H-1))<<8) + (uint32_t)Y); | |
173 | } |
|
173 | } | |
174 |
|
174 | |||
175 | void ssd2119paint(LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height) |
|
175 | void ssd2119paint(LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height) | |
176 | { |
|
176 | { | |
177 | if((LCD!=NULL) && (LCD->interface!=NULL) && (LCD->interface->writeGRAM!=NULL) && (LCD->width>(Xpos+Width)) && (LCD->height>(Ypos+Height))) |
|
177 | if((LCD!=NULL) && (LCD->interface.lcd_interface!=NULL) && (LCD->interface.lcd_interface->writeGRAM!=NULL) && (LCD->width>(Xpos+Width)) && (LCD->height>(Ypos+Height))) | |
178 | { |
|
178 | { | |
179 | ssd2119setFrame(LCD,Xpos,Ypos,Width,Height); |
|
179 | ssd2119setFrame(LCD,Xpos,Ypos,Width,Height); | |
180 | LCD->interface->writeGRAM(buffer,Width*Height); |
|
180 | LCD->interface.lcd_interface->writeGRAM(buffer,Width*Height); | |
181 | } |
|
181 | } | |
182 | } |
|
182 | } | |
183 |
|
183 | |||
184 | void ssd2119paintFilCirc(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor) |
|
184 | void ssd2119paintFilCirc(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor) | |
185 | { |
|
185 | { | |
186 | //Based on the mid point circle algorithm from Wikipedia |
|
186 | //Based on the mid point circle algorithm from Wikipedia | |
187 | //http://en.wikipedia.org/wiki/Midpoint_circle_algorithm |
|
187 | //http://en.wikipedia.org/wiki/Midpoint_circle_algorithm | |
188 | uint16_t innerbuffer[16]; |
|
188 | uint16_t innerbuffer[16]; | |
189 | uint16_t outterbuffer[16]; |
|
189 | uint16_t outterbuffer[16]; | |
190 | for(int i=0;i<16;i++)innerbuffer[i]=fillColor; |
|
190 | for(int i=0;i<16;i++)innerbuffer[i]=fillColor; | |
191 | for(int i=0;i<16;i++)outterbuffer[i]=contColor; |
|
191 | for(int i=0;i<16;i++)outterbuffer[i]=contColor; | |
192 | if(contSz<r) |
|
192 | if(contSz<r) | |
193 | { |
|
193 | { | |
194 | int error = -r,error_int = -r+contSz; |
|
194 | int error = -r,error_int = -r+contSz; | |
195 | int x = r,x_int=r-contSz; |
|
195 | int x = r,x_int=r-contSz; | |
196 | int y = 0,y_int=0; |
|
196 | int y = 0,y_int=0; | |
197 | while (x >= y) |
|
197 | while (x >= y) | |
198 | { |
|
198 | { | |
199 | ilipaintHLineWithCont(LCD,(Xpos-x),(Ypos+y),(2*x),(x-x_int),innerbuffer,16,outterbuffer,16); |
|
199 | ilipaintHLineWithCont(LCD,(Xpos-x),(Ypos+y),(2*x),(x-x_int),innerbuffer,16,outterbuffer,16); | |
200 | ilipaintHLineWithCont(LCD,(Xpos-x),(Ypos-y),(2*x),(x-x_int),innerbuffer,16,outterbuffer,16); |
|
200 | ilipaintHLineWithCont(LCD,(Xpos-x),(Ypos-y),(2*x),(x-x_int),innerbuffer,16,outterbuffer,16); | |
201 | ilipaintHalfTopVLineWithCont(LCD,(Xpos+y),(Ypos-x),(x),(x-x_int),innerbuffer,16,outterbuffer,16); |
|
201 | ilipaintHalfTopVLineWithCont(LCD,(Xpos+y),(Ypos-x),(x),(x-x_int),innerbuffer,16,outterbuffer,16); | |
202 | ilipaintHalfTopVLineWithCont(LCD,(Xpos-y),(Ypos-x),(x),(x-x_int),innerbuffer,16,outterbuffer,16); |
|
202 | ilipaintHalfTopVLineWithCont(LCD,(Xpos-y),(Ypos-x),(x),(x-x_int),innerbuffer,16,outterbuffer,16); | |
203 | ilipaintHalfBottomVLineWithCont(LCD,(Xpos-y),(Ypos),(x),(x-x_int),innerbuffer,16,outterbuffer,16); |
|
203 | ilipaintHalfBottomVLineWithCont(LCD,(Xpos-y),(Ypos),(x),(x-x_int),innerbuffer,16,outterbuffer,16); | |
204 | ilipaintHalfBottomVLineWithCont(LCD,(Xpos+y),(Ypos),(x),(x-x_int),innerbuffer,16,outterbuffer,16); |
|
204 | ilipaintHalfBottomVLineWithCont(LCD,(Xpos+y),(Ypos),(x),(x-x_int),innerbuffer,16,outterbuffer,16); | |
205 | error += y; |
|
205 | error += y; | |
206 | ++y; |
|
206 | ++y; | |
207 | error += y; |
|
207 | error += y; | |
208 | error_int += y_int; |
|
208 | error_int += y_int; | |
209 | ++y_int; |
|
209 | ++y_int; | |
210 | error_int += y_int; |
|
210 | error_int += y_int; | |
211 | if(error >= 0) |
|
211 | if(error >= 0) | |
212 | { |
|
212 | { | |
213 | error -= x; |
|
213 | error -= x; | |
214 | --x; |
|
214 | --x; | |
215 | error -= x; |
|
215 | error -= x; | |
216 | } |
|
216 | } | |
217 | if(error_int >= 0) |
|
217 | if(error_int >= 0) | |
218 | { |
|
218 | { | |
219 | error_int -= x_int; |
|
219 | error_int -= x_int; | |
220 | --x_int; |
|
220 | --x_int; | |
221 | error_int -= x_int; |
|
221 | error_int -= x_int; | |
222 | } |
|
222 | } | |
223 | } |
|
223 | } | |
224 |
|
224 | |||
225 |
|
225 | |||
226 |
|
226 | |||
227 | } |
|
227 | } | |
228 |
|
228 | |||
229 | } |
|
229 | } | |
230 |
|
230 | |||
231 | void ssd2119paintFilCirc_old(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor) |
|
231 | void ssd2119paintFilCirc_old(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor) | |
232 | { |
|
232 | { | |
233 | if(contSz<r) |
|
233 | if(contSz<r) | |
234 | { |
|
234 | { | |
235 | uint16_t innerbuffer[16]; |
|
235 | uint16_t innerbuffer[16]; | |
236 | uint16_t outterbuffer[16]; |
|
236 | uint16_t outterbuffer[16]; | |
237 | int32_t rr=(r*r),rr2=((r-contSz)*(r-contSz)),contSz2,Val1,Val2,X1,W,rem; |
|
237 | int32_t rr=(r*r),rr2=((r-contSz)*(r-contSz)),contSz2,Val1,Val2,X1,W,rem; | |
238 | for(int i=0;i<16;i++)innerbuffer[i]=fillColor; |
|
238 | for(int i=0;i<16;i++)innerbuffer[i]=fillColor; | |
239 | for(int i=0;i<16;i++)outterbuffer[i]=contColor; |
|
239 | for(int i=0;i<16;i++)outterbuffer[i]=contColor; | |
240 | /* Y = b +/- sqrt[r^2 - (x - a)^2] */ |
|
240 | /* Y = b +/- sqrt[r^2 - (x - a)^2] */ | |
241 | for(int32_t line=-r;line<r;line++) |
|
241 | for(int32_t line=-r;line<r;line++) | |
242 | { |
|
242 | { | |
243 | #ifdef __OPTIMIZED_MATH |
|
243 | #ifdef __OPTIMIZED_MATH | |
244 | Val1 = (uint32_t)optimised_sqrt((float32_t)(rr - (line*line)) ); |
|
244 | Val1 = (uint32_t)optimised_sqrt((float32_t)(rr - (line*line)) ); | |
245 | Val2 = (uint32_t)optimised_sqrt((float32_t)(rr2 - (line*line)) ); |
|
245 | Val2 = (uint32_t)optimised_sqrt((float32_t)(rr2 - (line*line)) ); | |
246 | #else |
|
246 | #else | |
247 | Val1 = sqrt( (double)(rr - ((line)*(line))) ); |
|
247 | Val1 = sqrt( (double)(rr - ((line)*(line))) ); | |
248 | Val2 = sqrt( (double)(rr2 - ((line)*(line))) ); |
|
248 | Val2 = sqrt( (double)(rr2 - ((line)*(line))) ); | |
249 | #endif |
|
249 | #endif | |
250 | X1=Xpos - Val1; |
|
250 | X1=Xpos - Val1; | |
251 | contSz2= Val1-Val2; |
|
251 | contSz2= Val1-Val2; | |
252 | ssd2119setFrame(LCD,X1,line+Ypos,2*Val1,1); |
|
252 | ssd2119setFrame(LCD,X1,line+Ypos,2*Val1,1); | |
253 | rem=(contSz2)%16; |
|
253 | rem=(contSz2)%16; | |
254 | if(rem)LCD->interface->writeGRAM(outterbuffer,rem); |
|
254 | if(rem)LCD->interface.lcd_interface->writeGRAM(outterbuffer,rem); | |
255 | for(int i=rem;i<(contSz2);i+=16) |
|
255 | for(int i=rem;i<(contSz2);i+=16) | |
256 | { |
|
256 | { | |
257 | LCD->interface->writeGRAM(outterbuffer,16); |
|
257 | LCD->interface.lcd_interface->writeGRAM(outterbuffer,16); | |
258 | } |
|
258 | } | |
259 |
|
259 | |||
260 | W=2*Val1; |
|
260 | W=2*Val1; | |
261 | if(W>(2*contSz2)) |
|
261 | if(W>(2*contSz2)) | |
262 | { |
|
262 | { | |
263 | W-=2*contSz2; |
|
263 | W-=2*contSz2; | |
264 | rem=(W)%16; |
|
264 | rem=(W)%16; | |
265 | if(rem)LCD->interface->writeGRAM(innerbuffer,rem); |
|
265 | if(rem)LCD->interface.lcd_interface->writeGRAM(innerbuffer,rem); | |
266 | for(int i=rem;i<(W);i+=16) |
|
266 | for(int i=rem;i<(W);i+=16) | |
267 | { |
|
267 | { | |
268 | LCD->interface->writeGRAM(innerbuffer,16); |
|
268 | LCD->interface.lcd_interface->writeGRAM(innerbuffer,16); | |
269 | } |
|
269 | } | |
270 | } |
|
270 | } | |
271 |
|
271 | |||
272 | rem=(contSz2)%16; |
|
272 | rem=(contSz2)%16; | |
273 | if(rem)LCD->interface->writeGRAM(outterbuffer,rem); |
|
273 | if(rem)LCD->interface.lcd_interface->writeGRAM(outterbuffer,rem); | |
274 | for(int i=rem;i<(contSz2);i+=16) |
|
274 | for(int i=rem;i<(contSz2);i+=16) | |
275 | { |
|
275 | { | |
276 | LCD->interface->writeGRAM(outterbuffer,16); |
|
276 | LCD->interface.lcd_interface->writeGRAM(outterbuffer,16); | |
277 | } |
|
277 | } | |
278 | } |
|
278 | } | |
279 | } |
|
279 | } | |
280 | } |
|
280 | } | |
281 |
|
281 | |||
282 |
|
282 | |||
283 |
|
283 | |||
284 |
|
284 | |||
285 | void ssd2119paintFilRect(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h,uint32_t contColor,uint16_t contSz,uint32_t fillColor) |
|
285 | void ssd2119paintFilRect(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h,uint32_t contColor,uint16_t contSz,uint32_t fillColor) | |
286 | { |
|
286 | { | |
287 | ssd2119setFrame(LCD,Xpos,Ypos,w,h); |
|
287 | ssd2119setFrame(LCD,Xpos,Ypos,w,h); | |
288 | uint16_t tmp[32]; |
|
288 | uint16_t tmp[32]; | |
289 | for(int i=0;i<32;i++)tmp[i]=fillColor; |
|
289 | for(int i=0;i<32;i++)tmp[i]=fillColor; | |
290 | for(int i=0;i<(h*w);i+=32) |
|
290 | for(int i=0;i<(h*w);i+=32) | |
291 | { |
|
291 | { | |
292 | LCD->interface->writeGRAM(tmp,32); |
|
292 | LCD->interface.lcd_interface->writeGRAM(tmp,32); | |
293 | } |
|
293 | } | |
294 | int rem=(w*h)%32; |
|
294 | int rem=(w*h)%32; | |
295 | if(rem)LCD->interface->writeGRAM(tmp,rem); |
|
295 | if(rem)LCD->interface.lcd_interface->writeGRAM(tmp,rem); | |
296 | if(contSz) |
|
296 | if(contSz) | |
297 | { |
|
297 | { | |
298 | ssd2119setFrame(LCD,Xpos,Ypos,w,contSz); |
|
298 | ssd2119setFrame(LCD,Xpos,Ypos,w,contSz); | |
299 | for(int i=0;i<32;i++)tmp[i]=contColor; |
|
299 | for(int i=0;i<32;i++)tmp[i]=contColor; | |
300 | rem=(w*contSz)%32; |
|
300 | rem=(w*contSz)%32; | |
301 | if(rem)LCD->interface->writeGRAM(tmp,rem); |
|
301 | if(rem)LCD->interface.lcd_interface->writeGRAM(tmp,rem); | |
302 | for(int i=rem;i<(w*contSz);i+=32) |
|
302 | for(int i=rem;i<(w*contSz);i+=32) | |
303 | { |
|
303 | { | |
304 | LCD->interface->writeGRAM(tmp,32); |
|
304 | LCD->interface.lcd_interface->writeGRAM(tmp,32); | |
305 | } |
|
305 | } | |
306 |
|
306 | |||
307 | ssd2119setFrame(LCD,Xpos,Ypos+h-contSz,w,contSz); |
|
307 | ssd2119setFrame(LCD,Xpos,Ypos+h-contSz,w,contSz); | |
308 | rem=(w*contSz)%32; |
|
308 | rem=(w*contSz)%32; | |
309 | if(rem)LCD->interface->writeGRAM(tmp,rem); |
|
309 | if(rem)LCD->interface.lcd_interface->writeGRAM(tmp,rem); | |
310 | for(int i=rem;i<(w*contSz);i+=32) |
|
310 | for(int i=rem;i<(w*contSz);i+=32) | |
311 | { |
|
311 | { | |
312 | LCD->interface->writeGRAM(tmp,32); |
|
312 | LCD->interface.lcd_interface->writeGRAM(tmp,32); | |
313 | } |
|
313 | } | |
314 |
|
314 | |||
315 | ssd2119setFrame(LCD,Xpos,Ypos,contSz,h); |
|
315 | ssd2119setFrame(LCD,Xpos,Ypos,contSz,h); | |
316 | rem=(h*contSz)%32; |
|
316 | rem=(h*contSz)%32; | |
317 | if(rem)LCD->interface->writeGRAM(tmp,rem); |
|
317 | if(rem)LCD->interface.lcd_interface->writeGRAM(tmp,rem); | |
318 | for(int i=rem;i<(h*contSz);i+=32) |
|
318 | for(int i=rem;i<(h*contSz);i+=32) | |
319 | { |
|
319 | { | |
320 | LCD->interface->writeGRAM(tmp,32); |
|
320 | LCD->interface.lcd_interface->writeGRAM(tmp,32); | |
321 | } |
|
321 | } | |
322 |
|
322 | |||
323 | ssd2119setFrame(LCD,Xpos+w-contSz,Ypos,contSz,h); |
|
323 | ssd2119setFrame(LCD,Xpos+w-contSz,Ypos,contSz,h); | |
324 | rem=(h*contSz)%32; |
|
324 | rem=(h*contSz)%32; | |
325 | if(rem)LCD->interface->writeGRAM(tmp,rem); |
|
325 | if(rem)LCD->interface.lcd_interface->writeGRAM(tmp,rem); | |
326 | for(int i=rem;i<(h*contSz);i+=32) |
|
326 | for(int i=rem;i<(h*contSz);i+=32) | |
327 | { |
|
327 | { | |
328 | LCD->interface->writeGRAM(tmp,32); |
|
328 | LCD->interface.lcd_interface->writeGRAM(tmp,32); | |
329 | } |
|
329 | } | |
330 | } |
|
330 | } | |
331 | } |
|
331 | } | |
332 |
|
332 | |||
333 | void ssd2119paintText(LCD_t* LCD,char* buffer,uint16_t Xpos,uint16_t Ypos,sFONT* font,uint32_t color) |
|
333 | void ssd2119paintText(LCD_t* LCD,char* buffer,uint16_t Xpos,uint16_t Ypos,sFONT* font,uint32_t color) | |
334 | { |
|
334 | { | |
335 | int w=font->Width,h=font->Height,bpl=font->bytesPerLine,pix=0,tableoffset=0; |
|
335 | int w=font->Width,h=font->Height,bpl=font->bytesPerLine,pix=0,tableoffset=0; | |
336 | uint16_t tmp[w]; |
|
336 | uint16_t tmp[w]; | |
337 | uint16_t linenum=0,charnum=0; |
|
337 | uint16_t linenum=0,charnum=0; | |
338 | uint8_t line=0; |
|
338 | uint8_t line=0; | |
339 | while(*buffer!='\0') |
|
339 | while(*buffer!='\0') | |
340 | { |
|
340 | { | |
341 | ssd2119setFrame(LCD,Xpos+(charnum*w),Ypos-h,w,1); |
|
341 | ssd2119setFrame(LCD,Xpos+(charnum*w),Ypos-h,w,1); | |
342 | LCD->interface->readGRAM(tmp,w); |
|
342 | LCD->interface.lcd_interface->readGRAM(tmp,w); | |
343 | for(int i=0;i<(h*w);i++) |
|
343 | for(int i=0;i<(h*w);i++) | |
344 | { |
|
344 | { | |
345 | if( ((i%w)==0) ) //read current line to apply text pixmap |
|
345 | if( ((i%w)==0) ) //read current line to apply text pixmap | |
346 | { |
|
346 | { | |
347 | if(linenum++>0) |
|
347 | if(linenum++>0) | |
348 | { |
|
348 | { | |
349 | ssd2119setFrame(LCD,Xpos+(charnum*(w-10)),Ypos + linenum -h,w,1); // TODO remove -10 and generate good fonts! |
|
349 | ssd2119setFrame(LCD,Xpos+(charnum*(w-10)),Ypos + linenum -h,w,1); // TODO remove -10 and generate good fonts! | |
350 | LCD->interface->writeGRAM(tmp,w); |
|
350 | LCD->interface.lcd_interface->writeGRAM(tmp,w); | |
351 | ssd2119setFrame(LCD,Xpos+(charnum*(w-10)),Ypos + linenum + 1-h,w,1); |
|
351 | ssd2119setFrame(LCD,Xpos+(charnum*(w-10)),Ypos + linenum + 1-h,w,1); | |
352 | LCD->interface->readGRAM(tmp,w); |
|
352 | LCD->interface.lcd_interface->readGRAM(tmp,w); | |
353 | pix=0; |
|
353 | pix=0; | |
354 | } |
|
354 | } | |
355 | } |
|
355 | } | |
356 | if((pix%8) == 0) |
|
356 | if((pix%8) == 0) | |
357 | { |
|
357 | { | |
358 | line=font->table[(((*buffer)-32)*h*bpl)+tableoffset++]; |
|
358 | line=font->table[(((*buffer)-32)*h*bpl)+tableoffset++]; | |
359 | } |
|
359 | } | |
360 | if((line & (uint8_t)0x01)==(uint8_t)1)tmp[pix]=(uint16_t)color; |
|
360 | if((line & (uint8_t)0x01)==(uint8_t)1)tmp[pix]=(uint16_t)color; | |
361 | pix++; |
|
361 | pix++; | |
362 | line>>=1; |
|
362 | line>>=1; | |
363 | } |
|
363 | } | |
364 | linenum=0; |
|
364 | linenum=0; | |
365 | tableoffset=0; |
|
365 | tableoffset=0; | |
366 | charnum++; |
|
366 | charnum++; | |
367 | buffer++; |
|
367 | buffer++; | |
368 | } |
|
368 | } | |
369 | } |
|
369 | } | |
370 |
|
370 | |||
371 |
|
371 | |||
372 | int ssd2119init(struct LCD_t* LCD) |
|
372 | int ssd2119init(struct LCD_t* LCD) | |
373 | { |
|
373 | { | |
374 | if((LCD!=NULL) && (LCD->interface!=NULL) && (LCD->interface->writereg!=NULL)) |
|
374 | if((LCD!=NULL) && (LCD->interface.lcd_interface!=NULL) && (LCD->interface.lcd_interface->writereg!=NULL)) | |
375 | { |
|
375 | { | |
376 | LCD->interface->writereg(0x28,0x0006); // VCOM OTP - Page 55-56 of SSD2119 datasheet |
|
376 | LCD->interface.lcd_interface->writereg(0x28,0x0006); // VCOM OTP - Page 55-56 of SSD2119 datasheet | |
377 | LCD->interface->writereg(0x00,0x0001); // start Oscillator - Page 36 of SSD2119 datasheet |
|
377 | LCD->interface.lcd_interface->writereg(0x00,0x0001); // start Oscillator - Page 36 of SSD2119 datasheet | |
378 | LCD->interface->writereg(0x10,0x0000); // Sleep mode - Page 49 of SSD2119 datasheet |
|
378 | LCD->interface.lcd_interface->writereg(0x10,0x0000); // Sleep mode - Page 49 of SSD2119 datasheet | |
379 | LCD->interface->writereg(0x01,0x72ef); // Driver Output Control - Page 36-39 of SSD2119 datasheet |
|
379 | LCD->interface.lcd_interface->writereg(0x01,0x72ef); // Driver Output Control - Page 36-39 of SSD2119 datasheet | |
380 | LCD->interface->writereg(0x02,0x0600); // LCD Driving Waveform Control - Page 40-42 of SSD2119 datasheet |
|
380 | LCD->interface.lcd_interface->writereg(0x02,0x0600); // LCD Driving Waveform Control - Page 40-42 of SSD2119 datasheet | |
381 | LCD->interface->writereg(0x03,0x6a38); // Power Control 1 - Page 43-44 of SSD2119 datasheet |
|
381 | LCD->interface.lcd_interface->writereg(0x03,0x6a38); // Power Control 1 - Page 43-44 of SSD2119 datasheet | |
382 | LCD->interface->writereg(0x11,0x6870); // Entry Mode - Page 50-52 of SSD2119 datasheet |
|
382 | LCD->interface.lcd_interface->writereg(0x11,0x6870); // Entry Mode - Page 50-52 of SSD2119 datasheet | |
383 |
|
383 | |||
384 | // RAM WRITE DATA MASK |
|
384 | // RAM WRITE DATA MASK | |
385 | LCD->interface->writereg(0x0f,0x0000); // Gate Scan Position - Page 49 of SSD2119 datasheet |
|
385 | LCD->interface.lcd_interface->writereg(0x0f,0x0000); // Gate Scan Position - Page 49 of SSD2119 datasheet | |
386 | // RAM WRITE DATA MASK |
|
386 | // RAM WRITE DATA MASK | |
387 | LCD->interface->writereg(0x0b,0x5308); // Frame Cycle Control - Page 45 of SSD2119 datasheet |
|
387 | LCD->interface.lcd_interface->writereg(0x0b,0x5308); // Frame Cycle Control - Page 45 of SSD2119 datasheet | |
388 | LCD->interface->writereg(0x0c,0x0003); // Power Control 2 - Page 47 of SSD2119 datasheet |
|
388 | LCD->interface.lcd_interface->writereg(0x0c,0x0003); // Power Control 2 - Page 47 of SSD2119 datasheet | |
389 | LCD->interface->writereg(0x0d,0x000a); // Power Control 3 - Page 48 of SSD2119 datasheet |
|
389 | LCD->interface.lcd_interface->writereg(0x0d,0x000a); // Power Control 3 - Page 48 of SSD2119 datasheet | |
390 | LCD->interface->writereg(0x0e,0x2e00); // Power Control 4 - Page 48 of SSD2119 datasheet |
|
390 | LCD->interface.lcd_interface->writereg(0x0e,0x2e00); // Power Control 4 - Page 48 of SSD2119 datasheet | |
391 | LCD->interface->writereg(0x1e,0x00be); // Power Control 5 - Page 53 of SSD2119 datasheet |
|
391 | LCD->interface.lcd_interface->writereg(0x1e,0x00be); // Power Control 5 - Page 53 of SSD2119 datasheet | |
392 | LCD->interface->writereg(0x25,0x8000); // Frame Frequency Control - Page 53 of SSD2119 datasheet |
|
392 | LCD->interface.lcd_interface->writereg(0x25,0x8000); // Frame Frequency Control - Page 53 of SSD2119 datasheet | |
393 | LCD->interface->writereg(0x26,0x7800); // Analog setting - Page 54 of SSD2119 datasheet |
|
393 | LCD->interface.lcd_interface->writereg(0x26,0x7800); // Analog setting - Page 54 of SSD2119 datasheet | |
394 | LCD->interface->writereg(0x4e,0x0000); // Ram Address Set - Page 58 of SSD2119 datasheet |
|
394 | LCD->interface.lcd_interface->writereg(0x4e,0x0000); // Ram Address Set - Page 58 of SSD2119 datasheet | |
395 | LCD->interface->writereg(0x4f,0x0000); // Ram Address Set - Page 58 of SSD2119 datasheet |
|
395 | LCD->interface.lcd_interface->writereg(0x4f,0x0000); // Ram Address Set - Page 58 of SSD2119 datasheet | |
396 | LCD->interface->writereg(0x12,0x08d9); // Sleep mode - Page 49 of SSD2119 datasheet |
|
396 | LCD->interface.lcd_interface->writereg(0x12,0x08d9); // Sleep mode - Page 49 of SSD2119 datasheet | |
397 |
|
397 | |||
398 | // -----------------Adjust the Gamma Curve----// |
|
398 | // -----------------Adjust the Gamma Curve----// | |
399 | LCD->interface->writereg(0x30,0x0000); //0007 |
|
399 | LCD->interface.lcd_interface->writereg(0x30,0x0000); //0007 | |
400 | LCD->interface->writereg(0x31,0x0104); //0203 |
|
400 | LCD->interface.lcd_interface->writereg(0x31,0x0104); //0203 | |
401 | LCD->interface->writereg(0x32,0x0100); //0001 |
|
401 | LCD->interface.lcd_interface->writereg(0x32,0x0100); //0001 | |
402 | LCD->interface->writereg(0x33,0x0305); //0007 |
|
402 | LCD->interface.lcd_interface->writereg(0x33,0x0305); //0007 | |
403 | LCD->interface->writereg(0x34,0x0505); //0007 |
|
403 | LCD->interface.lcd_interface->writereg(0x34,0x0505); //0007 | |
404 | LCD->interface->writereg(0x35,0x0305); //0407 |
|
404 | LCD->interface.lcd_interface->writereg(0x35,0x0305); //0407 | |
405 | LCD->interface->writereg(0x36,0x0707); //0407 |
|
405 | LCD->interface.lcd_interface->writereg(0x36,0x0707); //0407 | |
406 | LCD->interface->writereg(0x37,0x0300); //0607 |
|
406 | LCD->interface.lcd_interface->writereg(0x37,0x0300); //0607 | |
407 | LCD->interface->writereg(0x3a,0x1200); //0106 |
|
407 | LCD->interface.lcd_interface->writereg(0x3a,0x1200); //0106 | |
408 | LCD->interface->writereg(0x3b,0x0800); |
|
408 | LCD->interface.lcd_interface->writereg(0x3b,0x0800); | |
409 | LCD->interface->writereg(0x07,0x0033); // Display Control - Page 45 of SSD2119 datasheet |
|
409 | LCD->interface.lcd_interface->writereg(0x07,0x0033); // Display Control - Page 45 of SSD2119 datasheet | |
410 | } |
|
410 | } | |
411 | return 0; |
|
411 | return 0; | |
412 | } |
|
412 | } | |
413 |
|
413 | |||
414 |
|
414 | |||
415 |
|
415 | |||
416 |
|
416 |
@@ -1,103 +1,107 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the libuc, microcontroler library |
|
2 | -- This file is a part of the libuc, microcontroler library | |
3 | -- Copyright (C) 2013, Alexis Jeandet |
|
3 | -- Copyright (C) 2013, Alexis Jeandet | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | ------------------------------------------------------------------------------- |
|
18 | ------------------------------------------------------------------------------- | |
19 | -- Author : Alexis Jeandet |
|
19 | -- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | -------------------------------------------------------------------------------*/ |
|
21 | -------------------------------------------------------------------------------*/ | |
22 |
|
22 | |||
23 | #include <ADS7843.h> |
|
23 | #include <ADS7843.h> | |
24 | #include <core.h> |
|
24 | #include <core.h> | |
25 |
|
25 | |||
26 | int ads7843init(ADS7843_t *dev, spi_t spidev,void (*setnCS)(char),int (*busy)()) |
|
26 | int ads7843init(ADS7843_t *dev, spi_t spidev, char config, void (*setnCS)(char), int (*busy)()) | |
27 | { |
|
27 | { | |
28 | dev->spidev = spidev; |
|
28 | dev->spidev = spidev; | |
29 | dev->setnCS = setnCS; |
|
29 | dev->setnCS = setnCS; | |
30 | dev->busy = busy; |
|
30 | dev->busy = busy; | |
31 | dev->setnCS(1); |
|
31 | dev->setnCS(1); | |
|
32 | dev->config = config & ADS7843_CONFIG_MASK; | |||
|
33 | dev->xMax = 1000; | |||
|
34 | dev->xMin = 0; | |||
|
35 | dev->yMax = 1000; | |||
|
36 | dev->yMin = 0; | |||
|
37 | dev->zeroRtouch = 0; | |||
|
38 | dev->zeroX = 500; | |||
|
39 | dev->zeroY = 500; | |||
|
40 | dev->delta = 200; | |||
|
41 | return 1; | |||
|
42 | } | |||
|
43 | ||||
|
44 | unsigned int __ads7843read(ADS7843_t *dev,char cfg) | |||
|
45 | { | |||
|
46 | unsigned int data; | |||
|
47 | dev->setnCS(0); | |||
|
48 | while(dev->busy()); | |||
|
49 | spiputw(dev->spidev,ADS7843_START|dev->config|cfg); | |||
|
50 | data= (0x0FF & spigetw2(dev->spidev,0))<<8; | |||
|
51 | data+= 0x0FF & spigetw2(dev->spidev,0); | |||
|
52 | dev->setnCS(1); | |||
|
53 | return (data>>4); | |||
|
54 | } | |||
|
55 | ||||
|
56 | int ads7843read(ADS7843_t *dev,int* x,int* y) | |||
|
57 | { | |||
|
58 | *x=0; | |||
|
59 | *y=0; | |||
|
60 | for(int i=0;i<32;i++) | |||
|
61 | { | |||
|
62 | *x += __ads7843read(dev,ADS7843_MEAS_X_POS_DIFF|ADS7843_POWER_REF_ON|ADS7843_POWER_ADC_ON); | |||
|
63 | *y += __ads7843read(dev,ADS7843_MEAS_Y_POS_DIFF|ADS7843_POWER_REF_ON|ADS7843_POWER_ADC_ON); | |||
|
64 | } | |||
|
65 | *x>>=5; | |||
|
66 | *y>>=5; | |||
|
67 | *x = ((*x-dev->xMin)*1000)/(dev->xMax-dev->xMin); | |||
|
68 | *y = ((*y-dev->yMin)*1000)/(dev->yMax-dev->yMin); | |||
32 | return 1; |
|
69 | return 1; | |
33 | } |
|
70 | } | |
34 |
|
71 | |||
35 |
|
72 | |||
36 |
|
73 | |||
37 |
|
74 | |||
38 |
int ads7843read(ADS7843_t *dev |
|
75 | int ads7843readRtouch(ADS7843_t *dev) | |
39 | { |
|
76 | { | |
40 | int data; |
|
77 | #define avg 32 | |
41 | *x=0; |
|
78 | int z1=0,z2=0,x=0; | |
42 | *y=0; |
|
79 | for(int i=0;i<avg;i++) | |
43 | spiputw(dev->spidev,0x97); |
|
|||
44 | // delay_100us(2); |
|
|||
45 | while(dev->busy()); |
|
|||
46 | spigetw2(dev->spidev,0); |
|
|||
47 | spigetw2(dev->spidev,0); |
|
|||
48 | delay_100us(100); |
|
|||
49 | for(int i=0;i<32;i++) |
|
|||
50 | { |
|
80 | { | |
51 | data=0; |
|
81 | x += __ads7843read(dev,ADS7843_MEAS_X_POS_DIFF|ADS7843_POWER_REF_ON|ADS7843_POWER_ADC_ON); | |
52 | dev->setnCS(0); |
|
82 | z1 += __ads7843read(dev,ADS7843_MEAS_Z1_POS_DIFF|ADS7843_POWER_REF_ON|ADS7843_POWER_ADC_ON); | |
53 | spiputw(dev->spidev,0x97); |
|
83 | z2 += __ads7843read(dev,ADS7843_MEAS_Z2_POS_DIFF|ADS7843_POWER_REF_ON|ADS7843_POWER_ADC_ON); | |
54 | //delay_100us(2); |
|
|||
55 | while(dev->busy()); |
|
|||
56 | data= (0x0FF & spigetw2(dev->spidev,0))<<8; |
|
|||
57 | data+= 0x0FF & spigetw2(dev->spidev,0); |
|
|||
58 | *x+=data>>4; |
|
|||
59 | dev->setnCS(1); |
|
|||
60 | delay_100us(10); |
|
|||
61 | } |
|
84 | } | |
62 | spiputw(dev->spidev,0xd7); |
|
85 | return (x/(4096/avg))*((z2/z1)-1); | |
63 | // delay_100us(2); |
|
|||
64 | while(dev->busy()); |
|
|||
65 | spigetw2(dev->spidev,0); |
|
|||
66 | spigetw2(dev->spidev,0); |
|
|||
67 | delay_100us(10); |
|
|||
68 | for(int i=0;i<32;i++) |
|
|||
69 | { |
|
|||
70 | data=0; |
|
|||
71 | dev->setnCS(0); |
|
|||
72 | spiputw(dev->spidev,0xd7); |
|
|||
73 | // delay_100us(2); |
|
|||
74 | while(dev->busy()); |
|
|||
75 | data= (spigetw2(dev->spidev,0))<<8; |
|
|||
76 | data+= spigetw2(dev->spidev,0); |
|
|||
77 | *y+=data>>4; |
|
|||
78 | dev->setnCS(1); |
|
|||
79 | delay_100us(10); |
|
|||
80 | } |
|
|||
81 | *x/=32; |
|
|||
82 | *y/=32; |
|
|||
83 | return 1; |
|
|||
84 | } |
|
86 | } | |
85 |
|
87 | |||
86 |
|
88 | |||
87 |
|
89 | int ads7843calibrate(ADS7843_t *dev, uint16_t zeroX, uint16_t zeroY, uint16_t zeroRtouch, uint16_t xMin, uint16_t xMax, uint16_t yMin, uint16_t yMax, char delta) | ||
88 |
|
90 | { | ||
89 |
|
91 | dev->xMax = xMax; | ||
90 |
|
92 | dev->xMin = xMin; | ||
91 |
|
93 | dev->yMax = yMax; | ||
92 |
|
94 | dev->yMin = yMin; | ||
93 |
|
95 | dev->zeroRtouch = zeroRtouch; | ||
|
96 | dev->zeroX = zeroX; | |||
|
97 | dev->zeroY = zeroY; | |||
|
98 | dev->delta = delta; | |||
|
99 | } | |||
94 |
|
100 | |||
95 |
|
101 | |||
96 |
|
102 | int ads7843isPenTouching(ADS7843_t *dev) | ||
97 |
|
103 | { | ||
98 |
|
104 | int rtc= ads7843readRtouch(dev); | ||
|
105 | return ((rtc+dev->delta) < dev->zeroRtouch); | |||
99 |
|
106 | |||
100 |
|
107 | } | ||
101 |
|
||||
102 |
|
||||
103 |
|
@@ -1,9 +1,13 | |||||
1 | TEMPLATE = lib |
|
1 | TEMPLATE = lib | |
2 | CONFIG += libuc2lib |
|
2 | CONFIG += libuc2lib | |
3 | TARGET = ADS7843 |
|
3 | TARGET = ADS7843 | |
4 |
|
4 | |||
5 | SOURCES += \ |
|
5 | SOURCES += \ | |
6 | ADS7843.c |
|
6 | ADS7843.c | |
7 |
|
7 | |||
|
8 | HEADERS += \ | |||
|
9 | ../../../../../include/GRAPHIC/TC_CONTROLERS/ADS7843.h | |||
8 |
|
10 | |||
9 |
|
11 | |||
|
12 | ||||
|
13 |
@@ -1,114 +1,115 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the libuc, microcontroler library |
|
2 | -- This file is a part of the libuc, microcontroler library | |
3 | -- Copyright (C) 2012, Alexis Jeandet |
|
3 | -- Copyright (C) 2012, Alexis Jeandet | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | ------------------------------------------------------------------------------- |
|
18 | ------------------------------------------------------------------------------- | |
19 | -- Author : Alexis Jeandet |
|
19 | -- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | -------------------------------------------------------------------------------*/ |
|
21 | -------------------------------------------------------------------------------*/ | |
22 | #include <ina226.h> |
|
22 | #include <ina226.h> | |
23 | #include <stdio.h> |
|
23 | #include <stdio.h> | |
24 | #include <stddef.h> |
|
24 | #include <stddef.h> | |
25 |
|
25 | |||
26 |
|
26 | |||
27 | int ina226open(INA226_t *dev, i2c_t i2cdev, uint16_t config, uint8_t A0, uint8_t A1, uint32_t shuntmOhm, uint32_t CurrentRangeuAmp) |
|
27 | int ina226open(INA226_t *dev, i2c_t i2cdev, uint16_t config, uint8_t A0, uint8_t A1, uint32_t shuntmOhm, uint32_t CurrentRangeuAmp) | |
28 | { |
|
28 | { | |
29 | if(dev != NULL) |
|
29 | if(dev != NULL) | |
30 | { |
|
30 | { | |
31 | dev->i2cdev=i2cdev; |
|
31 | dev->i2cdev=i2cdev; | |
32 | dev->devAddress = INA226_I2C_ADDRESS | (A0 & 1) | ((A1<<2) & 5); |
|
32 | dev->devAddress = INA226_I2C_ADDRESS | (A0 & 1) | ((A1<<2) & 5); | |
33 | printf("dev->devAddress = %x\n\r",dev->devAddress); |
|
33 | printf("dev->devAddress = %x\n\r",dev->devAddress); | |
34 | dev->shuntmOhm = shuntmOhm; |
|
34 | dev->shuntmOhm = shuntmOhm; | |
35 | dev->CurrentRangeuAmp = CurrentRangeuAmp; |
|
35 | dev->CurrentRangeuAmp = CurrentRangeuAmp; | |
36 | ina226setReg(dev,INA226_Configuration_Reg,0x8000); |
|
36 | ina226setReg(dev,INA226_Configuration_Reg,0x8000); | |
37 | ina226setReg(dev,INA226_Configuration_Reg,config); |
|
37 | ina226setReg(dev,INA226_Configuration_Reg,config); | |
38 | return ina226calibrate(dev,shuntmOhm,CurrentRangeuAmp); |
|
38 | return ina226calibrate(dev,shuntmOhm,CurrentRangeuAmp); | |
39 | } |
|
39 | } | |
40 | return -1; |
|
40 | return -1; | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | uint16_t ina226getID(INA226_t* dev) |
|
43 | uint16_t ina226getID(INA226_t* dev) | |
44 | { |
|
44 | { | |
45 | if(dev != NULL) |
|
45 | if(dev != NULL) | |
46 | { |
|
46 | { | |
47 | uint16_t id=ina226getReg(dev,INA226_Die_ID_Reg); |
|
47 | uint16_t id=ina226getReg(dev,INA226_Die_ID_Reg); | |
48 | return id; |
|
48 | return id; | |
49 | } |
|
49 | } | |
50 | return -1; |
|
50 | return -1; | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 |
|
53 | |||
54 | int ina226calibrate(INA226_t* dev,uint32_t shuntmOhm, uint32_t CurrentRangeuAmp) |
|
54 | int ina226calibrate(INA226_t* dev,uint32_t shuntmOhm, uint32_t CurrentRangeuAmp) | |
55 | { |
|
55 | { | |
56 | dev->shuntmOhm = shuntmOhm; |
|
56 | dev->shuntmOhm = shuntmOhm; | |
57 | dev->CurrentRangeuAmp = CurrentRangeuAmp; |
|
57 | dev->CurrentRangeuAmp = CurrentRangeuAmp; | |
58 | uint32_t CAL= (uint32_t)(5210000/(shuntmOhm*(CurrentRangeuAmp>>15))); |
|
58 | // uint32_t CAL= (uint32_t)(5210000/(shuntmOhm*(CurrentRangeuAmp>>15))); | |
|
59 | float CAL=(5210000.0/((float)shuntmOhm*((float)CurrentRangeuAmp/32768.0))); | |||
59 | return ina226setReg(dev,INA226_Calibration_Reg,(uint16_t)CAL); |
|
60 | return ina226setReg(dev,INA226_Calibration_Reg,(uint16_t)CAL); | |
60 | } |
|
61 | } | |
61 |
|
62 | |||
62 | uint32_t ina226getBusVoltage(INA226_t *dev) |
|
63 | uint32_t ina226getBusVoltage(INA226_t *dev) | |
63 | { |
|
64 | { | |
64 | uint32_t busVoltage= ina226getReg(dev,INA226_Bus_Voltage_Reg); |
|
65 | uint32_t busVoltage= ina226getReg(dev,INA226_Bus_Voltage_Reg); | |
65 | busVoltage*= 1250; |
|
66 | busVoltage*= 1250; | |
66 | return busVoltage; |
|
67 | return busVoltage; | |
67 | } |
|
68 | } | |
68 |
|
69 | |||
69 | uint32_t ina226getPower(INA226_t *dev) |
|
70 | uint32_t ina226getPower(INA226_t *dev) | |
70 | { |
|
71 | { | |
71 | uint32_t power= ina226getReg(dev,INA226_Power_Reg); |
|
72 | uint32_t power= ina226getReg(dev,INA226_Power_Reg); | |
72 | power*= ((dev->CurrentRangeuAmp>>15)*25); |
|
73 | power*= ((dev->CurrentRangeuAmp>>15)*25); | |
73 | return power; |
|
74 | return power; | |
74 | } |
|
75 | } | |
75 |
|
76 | |||
76 | int32_t ina226getCurrent(INA226_t *dev) |
|
77 | int32_t ina226getCurrent(INA226_t *dev) | |
77 | { |
|
78 | { | |
78 | int32_t current= ina226getReg(dev,INA226_Current_Reg); |
|
79 | int32_t current= ina226getReg(dev,INA226_Current_Reg); | |
79 | current<<=16; |
|
80 | current<<=16; | |
80 | current>>=16; |
|
81 | current>>=16; | |
81 | current = current*(dev->CurrentRangeuAmp>>15); |
|
82 | current = current*(dev->CurrentRangeuAmp>>15); | |
82 | return current; |
|
83 | return current; | |
83 | } |
|
84 | } | |
84 |
|
85 | |||
85 | uint16_t ina226getReg(INA226_t* dev,char reg) |
|
86 | uint16_t ina226getReg(INA226_t* dev,char reg) | |
86 | { |
|
87 | { | |
87 | if(dev != NULL) |
|
88 | if(dev != NULL) | |
88 | { |
|
89 | { | |
89 | char DATA[2]; |
|
90 | char DATA[2]; | |
90 | DATA[0]=reg; |
|
91 | DATA[0]=reg; | |
91 | i2cwrite(dev->i2cdev,dev->devAddress,DATA,1); |
|
92 | i2cwrite(dev->i2cdev,dev->devAddress,DATA,1); | |
92 | i2cread(dev->i2cdev,dev->devAddress,DATA,2); |
|
93 | i2cread(dev->i2cdev,dev->devAddress,DATA,2); | |
93 | uint16_t val=DATA[0]; |
|
94 | uint16_t val=DATA[0]; | |
94 | val=(val<<8)+DATA[1]; |
|
95 | val=(val<<8)+DATA[1]; | |
95 | return val; |
|
96 | return val; | |
96 | } |
|
97 | } | |
97 | return -1; |
|
98 | return -1; | |
98 | } |
|
99 | } | |
99 |
|
100 | |||
100 |
|
101 | |||
101 | int ina226setReg(INA226_t* dev,char reg,int16_t value) |
|
102 | int ina226setReg(INA226_t* dev,char reg,int16_t value) | |
102 | { |
|
103 | { | |
103 | if(dev != NULL) |
|
104 | if(dev != NULL) | |
104 | { |
|
105 | { | |
105 | char DATA[3]; |
|
106 | char DATA[3]; | |
106 | DATA[0]=INA226_Calibration_Reg; |
|
107 | DATA[0]=INA226_Calibration_Reg; | |
107 | DATA[1]=(char)(0xff & (value>>8)); |
|
108 | DATA[1]=(char)(0xff & (value>>8)); | |
108 | DATA[2]=(char)(0xff & value); |
|
109 | DATA[2]=(char)(0xff & value); | |
109 | if(3==i2cwrite(dev->i2cdev,dev->devAddress,DATA,3))return 1; |
|
110 | if(3==i2cwrite(dev->i2cdev,dev->devAddress,DATA,3))return 1; | |
110 | } |
|
111 | } | |
111 | return -1; |
|
112 | return -1; | |
112 | } |
|
113 | } | |
113 |
|
114 | |||
114 |
|
115 |
@@ -1,454 +1,415 | |||||
1 | #include <stdio.h> |
|
1 | #include <stdio.h> | |
2 | #include <stm32f4xx.h> |
|
2 | #include <stm32f4xx.h> | |
3 |
|
3 | |||
4 | void NMI_Handler(void) |
|
4 | void NMI_Handler(void) | |
5 | { |
|
5 | { | |
6 | printf("NMI_Handler\n"); |
|
6 | printf("NMI_Handler\n"); | |
7 | } |
|
7 | } | |
8 |
|
8 | |||
9 | void HardFault_Handler(void) |
|
9 | void HardFault_Handler(void) | |
10 | { |
|
10 | { | |
11 | printf("HardFault_Handler\n"); |
|
11 | printf("HardFault_Handler\n"); | |
12 | } |
|
12 | } | |
13 |
|
13 | |||
14 | void MemManage_Handler(void) |
|
14 | void MemManage_Handler(void) | |
15 | { |
|
15 | { | |
16 | printf("MemManage_Handler\n"); |
|
16 | printf("MemManage_Handler\n"); | |
17 | } |
|
17 | } | |
18 |
|
18 | |||
19 | void BusFault_Handler(void) |
|
19 | void BusFault_Handler(void) | |
20 | { |
|
20 | { | |
21 | printf("BusFault_Handler\n"); |
|
21 | printf("BusFault_Handler\n"); | |
22 | } |
|
22 | } | |
23 |
|
23 | |||
24 | void UsageFault_Handler(void) |
|
24 | void UsageFault_Handler(void) | |
25 | { |
|
25 | { | |
26 | printf("UsageFault_Handler\n"); |
|
26 | printf("UsageFault_Handler\n"); | |
27 | } |
|
27 | } | |
28 |
|
28 | |||
29 | void SVC_Handler(void) |
|
29 | void SVC_Handler(void) | |
30 | { |
|
30 | { | |
31 | // __set_CONTROL(2); |
|
31 | // __set_CONTROL(2); | |
32 | printf("SVC_Handler\n"); |
|
32 | printf("SVC_Handler\n"); | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | void DebugMon_Handler(void) |
|
35 | void DebugMon_Handler(void) | |
36 | { |
|
36 | { | |
37 | printf("DebugMon_Handler\n"); |
|
37 | printf("DebugMon_Handler\n"); | |
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 | void PendSV_Handler(void) |
|
40 | void PendSV_Handler(void) | |
41 | { |
|
41 | { | |
42 | printf("PendSV_Handler\n"); |
|
42 | printf("PendSV_Handler\n"); | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | void WWDG_IRQHandler(void) |
|
45 | void WWDG_IRQHandler(void) | |
46 | { |
|
46 | { | |
47 | printf("WWDG_IRQHandler\n"); |
|
47 | printf("WWDG_IRQHandler\n"); | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | void PVD_IRQHandler(void) |
|
50 | void PVD_IRQHandler(void) | |
51 | { |
|
51 | { | |
52 | printf("PVD_IRQHandler\n"); |
|
52 | printf("PVD_IRQHandler\n"); | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | void TAMP_STAMP_IRQHandler(void) |
|
55 | void TAMP_STAMP_IRQHandler(void) | |
56 | { |
|
56 | { | |
57 | printf("TAMP_STAMP_IRQHandler\n"); |
|
57 | printf("TAMP_STAMP_IRQHandler\n"); | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | void RTC_WKUP_IRQHandler(void) |
|
60 | void RTC_WKUP_IRQHandler(void) | |
61 | { |
|
61 | { | |
62 | printf("RTC_WKUP_IRQHandler\n"); |
|
62 | printf("RTC_WKUP_IRQHandler\n"); | |
63 | } |
|
63 | } | |
64 |
|
64 | |||
65 | void FLASH_IRQHandler(void) |
|
65 | void FLASH_IRQHandler(void) | |
66 | { |
|
66 | { | |
67 | printf("FLASH_IRQHandler\n"); |
|
67 | printf("FLASH_IRQHandler\n"); | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | void RCC_IRQHandler(void) |
|
70 | void RCC_IRQHandler(void) | |
71 | { |
|
71 | { | |
72 | printf("RCC_IRQHandler\n"); |
|
72 | printf("RCC_IRQHandler\n"); | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | void EXTI0_IRQHandler(void) |
|
75 | void EXTI0_IRQHandler(void) | |
76 | { |
|
76 | { | |
77 | printf("EXTI0_IRQHandler\n"); |
|
77 | printf("EXTI0_IRQHandler\n"); | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | void EXTI1_IRQHandler(void) |
|
80 | void EXTI1_IRQHandler(void) | |
81 | { |
|
81 | { | |
82 | printf("EXTI1_IRQHandler\n"); |
|
82 | printf("EXTI1_IRQHandler\n"); | |
83 | } |
|
83 | } | |
84 |
|
84 | |||
85 | void EXTI2_IRQHandler(void) |
|
85 | void EXTI2_IRQHandler(void) | |
86 | { |
|
86 | { | |
87 | printf("EXTI2_IRQHandler\n"); |
|
87 | printf("EXTI2_IRQHandler\n"); | |
88 | } |
|
88 | } | |
89 |
|
89 | |||
90 | void EXTI3_IRQHandler(void) |
|
90 | void EXTI3_IRQHandler(void) | |
91 | { |
|
91 | { | |
92 | printf("EXTI3_IRQHandler\n"); |
|
92 | printf("EXTI3_IRQHandler\n"); | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | void EXTI4_IRQHandler(void) |
|
95 | void EXTI4_IRQHandler(void) | |
96 | { |
|
96 | { | |
97 | printf("EXTI4_IRQHandler\n"); |
|
97 | printf("EXTI4_IRQHandler\n"); | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | void DMA1_Stream0_IRQHandler(void) |
|
100 | void DMA1_Stream0_IRQHandler(void) | |
101 | { |
|
101 | { | |
102 | printf("DMA1_Stream0_IRQHandler\n"); |
|
102 | printf("DMA1_Stream0_IRQHandler\n"); | |
103 | } |
|
103 | } | |
104 |
|
104 | |||
105 | void DMA1_Stream1_IRQHandler(void) |
|
105 | void DMA1_Stream1_IRQHandler(void) | |
106 | { |
|
106 | { | |
107 | printf("DMA1_Stream1_IRQHandler\n"); |
|
107 | printf("DMA1_Stream1_IRQHandler\n"); | |
108 | } |
|
108 | } | |
109 |
|
109 | |||
110 | void DMA1_Stream2_IRQHandler(void) |
|
110 | void DMA1_Stream2_IRQHandler(void) | |
111 | { |
|
111 | { | |
112 | printf("DMA1_Stream2_IRQHandler\n"); |
|
112 | printf("DMA1_Stream2_IRQHandler\n"); | |
113 | } |
|
113 | } | |
114 |
|
114 | |||
115 | void DMA1_Stream3_IRQHandler(void) |
|
115 | void DMA1_Stream3_IRQHandler(void) | |
116 | { |
|
116 | { | |
117 | printf("DMA1_Stream3_IRQHandler\n"); |
|
117 | printf("DMA1_Stream3_IRQHandler\n"); | |
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | void DMA1_Stream4_IRQHandler(void) |
|
120 | void DMA1_Stream4_IRQHandler(void) | |
121 | { |
|
121 | { | |
122 | printf("DMA1_Stream4_IRQHandler\n"); |
|
122 | printf("DMA1_Stream4_IRQHandler\n"); | |
123 | } |
|
123 | } | |
124 |
|
124 | |||
125 | void DMA1_Stream5_IRQHandler(void) |
|
125 | void DMA1_Stream5_IRQHandler(void) | |
126 | { |
|
126 | { | |
127 | printf("DMA1_Stream5_IRQHandler\n"); |
|
127 | printf("DMA1_Stream5_IRQHandler\n"); | |
128 | } |
|
128 | } | |
129 |
|
129 | |||
130 | void DMA1_Stream6_IRQHandler(void) |
|
130 | void DMA1_Stream6_IRQHandler(void) | |
131 | { |
|
131 | { | |
132 | printf("DMA1_Stream6_IRQHandler\n"); |
|
132 | printf("DMA1_Stream6_IRQHandler\n"); | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | void ADC_IRQHandler(void) |
|
135 | void ADC_IRQHandler(void) | |
136 | { |
|
136 | { | |
137 | printf("ADC_IRQHandler\n"); |
|
137 | printf("ADC_IRQHandler\n"); | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 | void CAN1_TX_IRQHandler(void) |
|
140 | void CAN1_TX_IRQHandler(void) | |
141 | { |
|
141 | { | |
142 | printf("CAN1_TX_IRQHandler\n"); |
|
142 | printf("CAN1_TX_IRQHandler\n"); | |
143 | } |
|
143 | } | |
144 |
|
144 | |||
145 | void CAN1_RX0_IRQHandler(void) |
|
145 | void CAN1_RX0_IRQHandler(void) | |
146 | { |
|
146 | { | |
147 | printf("CAN1_RX0_IRQHandler\n"); |
|
147 | printf("CAN1_RX0_IRQHandler\n"); | |
148 | } |
|
148 | } | |
149 |
|
149 | |||
150 | void CAN1_RX1_IRQHandler(void) |
|
150 | void CAN1_RX1_IRQHandler(void) | |
151 | { |
|
151 | { | |
152 | printf("CAN1_RX1_IRQHandler\n"); |
|
152 | printf("CAN1_RX1_IRQHandler\n"); | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | void CAN1_SCE_IRQHandler(void) |
|
155 | void CAN1_SCE_IRQHandler(void) | |
156 | { |
|
156 | { | |
157 | printf("CAN1_SCE_IRQHandler\n"); |
|
157 | printf("CAN1_SCE_IRQHandler\n"); | |
158 | } |
|
158 | } | |
159 |
|
159 | |||
160 | void EXTI9_5_IRQHandler(void) |
|
160 | void EXTI9_5_IRQHandler(void) | |
161 | { |
|
161 | { | |
162 | printf("EXTI9_5_IRQHandler\n"); |
|
162 | printf("EXTI9_5_IRQHandler\n"); | |
163 | } |
|
163 | } | |
164 |
|
164 | |||
165 | void TIM1_BRK_TIM9_IRQHandler(void) |
|
165 | void TIM1_BRK_TIM9_IRQHandler(void) | |
166 | { |
|
166 | { | |
167 | printf("TIM1_BRK_TIM9_IRQHandler\n"); |
|
167 | printf("TIM1_BRK_TIM9_IRQHandler\n"); | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | void TIM1_UP_TIM10_IRQHandler(void) |
|
170 | void TIM1_UP_TIM10_IRQHandler(void) | |
171 | { |
|
171 | { | |
172 | printf("TIM1_UP_TIM10_IRQHandler\n"); |
|
172 | printf("TIM1_UP_TIM10_IRQHandler\n"); | |
173 | } |
|
173 | } | |
174 |
|
174 | |||
175 | void TIM1_TRG_COM_TIM11_IRQHandlerIM11(void) |
|
175 | void TIM1_TRG_COM_TIM11_IRQHandlerIM11(void) | |
176 | { |
|
176 | { | |
177 | printf("TIM1_TRG_COM_TIM11_IRQHandlerIM11"); |
|
177 | printf("TIM1_TRG_COM_TIM11_IRQHandlerIM11"); | |
178 | } |
|
178 | } | |
179 |
|
179 | |||
180 | void TIM1_CC_IRQHandler(void) |
|
180 | void TIM1_CC_IRQHandler(void) | |
181 | { |
|
181 | { | |
182 | printf("TIM1_CC_IRQHandler\n"); |
|
182 | printf("TIM1_CC_IRQHandler\n"); | |
183 | } |
|
183 | } | |
184 |
|
184 | |||
185 | void TIM2_IRQHandler(void) |
|
185 | void TIM2_IRQHandler(void) | |
186 | { |
|
186 | { | |
187 | printf("TIM2_IRQHandler\n"); |
|
187 | printf("TIM2_IRQHandler\n"); | |
188 | } |
|
188 | } | |
189 |
|
189 | |||
190 | void TIM3_IRQHandler(void) |
|
190 | void TIM3_IRQHandler(void) | |
191 | { |
|
191 | { | |
192 | printf("TIM3_IRQHandler\n"); |
|
192 | printf("TIM3_IRQHandler\n"); | |
193 | } |
|
193 | } | |
194 |
|
194 | |||
195 | void TIM4_IRQHandler(void) |
|
195 | void TIM4_IRQHandler(void) | |
196 | { |
|
196 | { | |
197 | printf("TIM4_IRQHandler\n"); |
|
197 | printf("TIM4_IRQHandler\n"); | |
198 | } |
|
198 | } | |
199 |
|
199 | |||
200 | void I2C1_EV_IRQHandler(void) |
|
200 | void I2C1_EV_IRQHandler(void) | |
201 | { |
|
201 | { | |
202 | printf("I2C1_EV_IRQHandler\n"); |
|
202 | printf("I2C1_EV_IRQHandler\n"); | |
203 | } |
|
203 | } | |
204 |
|
204 | |||
205 | void I2C1_ER_IRQHandler(void) |
|
205 | void I2C1_ER_IRQHandler(void) | |
206 | { |
|
206 | { | |
207 | printf("I2C1_ER_IRQHandler\n"); |
|
207 | printf("I2C1_ER_IRQHandler\n"); | |
208 | } |
|
208 | } | |
209 |
|
209 | |||
210 | void I2C2_EV_IRQHandler(void) |
|
210 | void I2C2_EV_IRQHandler(void) | |
211 | { |
|
211 | { | |
212 | printf("I2C2_EV_IRQHandler\n"); |
|
212 | printf("I2C2_EV_IRQHandler\n"); | |
213 | } |
|
213 | } | |
214 |
|
214 | |||
215 | void I2C2_ER_IRQHandler(void) |
|
215 | void I2C2_ER_IRQHandler(void) | |
216 | { |
|
216 | { | |
217 | printf("I2C2_ER_IRQHandler\n"); |
|
217 | printf("I2C2_ER_IRQHandler\n"); | |
218 | } |
|
218 | } | |
219 |
|
219 | |||
220 | void SPI1_IRQHandler(void) |
|
220 | void SPI1_IRQHandler(void) | |
221 | { |
|
221 | { | |
222 | printf("SPI1_IRQHandler\n"); |
|
222 | printf("SPI1_IRQHandler\n"); | |
223 | } |
|
223 | } | |
224 |
|
224 | |||
225 | void SPI2_IRQHandler(void) |
|
225 | void SPI2_IRQHandler(void) | |
226 | { |
|
226 | { | |
227 | printf("SPI2_IRQHandler\n"); |
|
227 | printf("SPI2_IRQHandler\n"); | |
228 | } |
|
228 | } | |
229 |
|
229 | |||
230 | void USART1_IRQHandler(void) |
|
230 | void USART1_IRQHandler(void) | |
231 | { |
|
231 | { | |
232 | printf("USART1_IRQHandler\n"); |
|
232 | printf("USART1_IRQHandler\n"); | |
233 | } |
|
233 | } | |
234 |
|
234 | |||
235 | void USART2_IRQHandler(void) |
|
235 | void USART2_IRQHandler(void) | |
236 | { |
|
236 | { | |
237 | printf("USART2_IRQHandler\n"); |
|
237 | printf("USART2_IRQHandler\n"); | |
238 | } |
|
238 | } | |
239 |
|
239 | |||
240 | void USART3_IRQHandler(void) |
|
240 | void USART3_IRQHandler(void) | |
241 | { |
|
241 | { | |
242 | printf("USART3_IRQHandler\n"); |
|
242 | printf("USART3_IRQHandler\n"); | |
243 | } |
|
243 | } | |
244 |
|
244 | |||
245 | void EXTI15_10_IRQHandler(void) |
|
245 | void EXTI15_10_IRQHandler(void) | |
246 | { |
|
246 | { | |
247 | printf("EXTI15_10_IRQHandler\n"); |
|
247 | printf("EXTI15_10_IRQHandler\n"); | |
248 | } |
|
248 | } | |
249 |
|
249 | |||
250 | void RTC_Alarm_IRQHandler(void) |
|
250 | void RTC_Alarm_IRQHandler(void) | |
251 | { |
|
251 | { | |
252 | printf("RTC_Alarm_IRQHandler\n"); |
|
252 | printf("RTC_Alarm_IRQHandler\n"); | |
253 | } |
|
253 | } | |
254 |
|
254 | |||
255 | void OTG_FS_WKUP_IRQHandler(void) |
|
255 | void OTG_FS_WKUP_IRQHandler(void) | |
256 | { |
|
256 | { | |
257 | printf("OTG_FS_WKUP_IRQHandler\n"); |
|
257 | printf("OTG_FS_WKUP_IRQHandler\n"); | |
258 | } |
|
258 | } | |
259 |
|
259 | |||
260 | void TIM8_BRK_TIM12_IRQHandler(void) |
|
260 | void TIM8_BRK_TIM12_IRQHandler(void) | |
261 | { |
|
261 | { | |
262 | printf("TIM8_BRK_TIM12_IRQHandler\n"); |
|
262 | printf("TIM8_BRK_TIM12_IRQHandler\n"); | |
263 | } |
|
263 | } | |
264 |
|
264 | |||
265 | void TIM8_UP_TIM13_IRQHandler(void) |
|
265 | void TIM8_UP_TIM13_IRQHandler(void) | |
266 | { |
|
266 | { | |
267 | printf("TIM8_UP_TIM13_IRQHandler\n"); |
|
267 | printf("TIM8_UP_TIM13_IRQHandler\n"); | |
268 | } |
|
268 | } | |
269 |
|
269 | |||
270 | void TIM8_TRG_COM_TIM14_IRQHandlerIM14(void) |
|
270 | void TIM8_TRG_COM_TIM14_IRQHandlerIM14(void) | |
271 | { |
|
271 | { | |
272 | printf("TIM8_TRG_COM_TIM14_IRQHandlerIM14"); |
|
272 | printf("TIM8_TRG_COM_TIM14_IRQHandlerIM14"); | |
273 | } |
|
273 | } | |
274 |
|
274 | |||
275 | void TIM8_CC_IRQHandler(void) |
|
275 | void TIM8_CC_IRQHandler(void) | |
276 | { |
|
276 | { | |
277 | printf("TIM8_CC_IRQHandler\n"); |
|
277 | printf("TIM8_CC_IRQHandler\n"); | |
278 | } |
|
278 | } | |
279 |
|
279 | |||
280 | void DMA1_Stream7_IRQHandler(void) |
|
280 | void DMA1_Stream7_IRQHandler(void) | |
281 | { |
|
281 | { | |
282 | printf("DMA1_Stream7_IRQHandler\n"); |
|
282 | printf("DMA1_Stream7_IRQHandler\n"); | |
283 | } |
|
283 | } | |
284 |
|
284 | |||
285 | void FSMC_IRQHandler(void) |
|
285 | void FSMC_IRQHandler(void) | |
286 | { |
|
286 | { | |
287 | printf("FSMC_IRQHandler\n"); |
|
287 | printf("FSMC_IRQHandler\n"); | |
288 | } |
|
288 | } | |
289 |
|
289 | |||
290 | void SDIO_IRQHandler(void) |
|
290 | void SDIO_IRQHandler(void) | |
291 | { |
|
291 | { | |
292 | printf("SDIO_IRQHandler\n"); |
|
292 | printf("SDIO_IRQHandler\n"); | |
293 | } |
|
293 | } | |
294 |
|
294 | |||
295 | void TIM5_IRQHandler(void) |
|
295 | void TIM5_IRQHandler(void) | |
296 | { |
|
296 | { | |
297 | printf("TIM5_IRQHandler\n"); |
|
297 | printf("TIM5_IRQHandler\n"); | |
298 | } |
|
298 | } | |
299 |
|
299 | |||
300 | void SPI3_IRQHandler(void) |
|
300 | void SPI3_IRQHandler(void) | |
301 | { |
|
301 | { | |
302 | printf("SPI3_IRQHandler\n"); |
|
302 | printf("SPI3_IRQHandler\n"); | |
303 | } |
|
303 | } | |
304 |
|
304 | |||
305 | void UART4_IRQHandler(void) |
|
305 | void UART4_IRQHandler(void) | |
306 | { |
|
306 | { | |
307 | printf("UART4_IRQHandler\n"); |
|
307 | printf("UART4_IRQHandler\n"); | |
308 | } |
|
308 | } | |
309 |
|
309 | |||
310 | void UART5_IRQHandler(void) |
|
310 | void UART5_IRQHandler(void) | |
311 | { |
|
311 | { | |
312 | printf("UART5_IRQHandler\n"); |
|
312 | printf("UART5_IRQHandler\n"); | |
313 | } |
|
313 | } | |
314 |
|
314 | |||
315 | void TIM6_DAC_IRQHandler(void) |
|
315 | void TIM6_DAC_IRQHandler(void) | |
316 | { |
|
316 | { | |
317 | printf("TIM6_DAC_IRQHandler\n"); |
|
317 | printf("TIM6_DAC_IRQHandler\n"); | |
318 | } |
|
318 | } | |
319 |
|
319 | |||
320 | void TIM7_IRQHandler(void) |
|
320 | void TIM7_IRQHandler(void) | |
321 | { |
|
321 | { | |
322 | printf("TIM7_IRQHandler\n"); |
|
322 | printf("TIM7_IRQHandler\n"); | |
323 | } |
|
323 | } | |
324 |
|
324 | |||
325 | void DMA2_Stream0_IRQHandler(void) |
|
|||
326 | { |
|
|||
327 | printf("DMA2_Stream0_IRQHandler\n"); |
|
|||
328 | } |
|
|||
329 |
|
||||
330 | void DMA2_Stream1_IRQHandler(void) |
|
|||
331 | { |
|
|||
332 | printf("DMA2_Stream1_IRQHandler\n"); |
|
|||
333 | } |
|
|||
334 |
|
||||
335 | void DMA2_Stream2_IRQHandler(void) |
|
|||
336 | { |
|
|||
337 | printf("DMA2_Stream2_IRQHandler\n"); |
|
|||
338 | } |
|
|||
339 |
|
||||
340 | void DMA2_Stream3_IRQHandler(void) |
|
|||
341 | { |
|
|||
342 | printf("DMA2_Stream3_IRQHandler\n"); |
|
|||
343 | } |
|
|||
344 |
|
||||
345 | void DMA2_Stream4_IRQHandler(void) |
|
|||
346 | { |
|
|||
347 | printf("DMA2_Stream4_IRQHandler\n"); |
|
|||
348 | } |
|
|||
349 |
|
325 | |||
350 | void ETH_IRQHandler(void) |
|
326 | void ETH_IRQHandler(void) | |
351 | { |
|
327 | { | |
352 | printf("ETH_IRQHandler\n"); |
|
328 | printf("ETH_IRQHandler\n"); | |
353 | } |
|
329 | } | |
354 |
|
330 | |||
355 | void ETH_WKUP_IRQHandler(void) |
|
331 | void ETH_WKUP_IRQHandler(void) | |
356 | { |
|
332 | { | |
357 | printf("ETH_WKUP_IRQHandler\n"); |
|
333 | printf("ETH_WKUP_IRQHandler\n"); | |
358 | } |
|
334 | } | |
359 |
|
335 | |||
360 | void CAN2_TX_IRQHandler(void) |
|
336 | void CAN2_TX_IRQHandler(void) | |
361 | { |
|
337 | { | |
362 | printf("CAN2_TX_IRQHandler\n"); |
|
338 | printf("CAN2_TX_IRQHandler\n"); | |
363 | } |
|
339 | } | |
364 |
|
340 | |||
365 | void CAN2_RX0_IRQHandler(void) |
|
341 | void CAN2_RX0_IRQHandler(void) | |
366 | { |
|
342 | { | |
367 | printf("CAN2_RX0_IRQHandler\n"); |
|
343 | printf("CAN2_RX0_IRQHandler\n"); | |
368 | } |
|
344 | } | |
369 |
|
345 | |||
370 | void CAN2_RX1_IRQHandler(void) |
|
346 | void CAN2_RX1_IRQHandler(void) | |
371 | { |
|
347 | { | |
372 | printf("CAN2_RX1_IRQHandler\n"); |
|
348 | printf("CAN2_RX1_IRQHandler\n"); | |
373 | } |
|
349 | } | |
374 |
|
350 | |||
375 | void CAN2_SCE_IRQHandler(void) |
|
351 | void CAN2_SCE_IRQHandler(void) | |
376 | { |
|
352 | { | |
377 | printf("CAN2_SCE_IRQHandler\n"); |
|
353 | printf("CAN2_SCE_IRQHandler\n"); | |
378 | } |
|
354 | } | |
379 |
|
355 | |||
380 | void OTG_FS_IRQHandler(void) |
|
356 | void OTG_FS_IRQHandler(void) | |
381 | { |
|
357 | { | |
382 | printf("OTG_FS_IRQHandler\n"); |
|
358 | printf("OTG_FS_IRQHandler\n"); | |
383 | } |
|
359 | } | |
384 |
|
360 | |||
385 | void DMA2_Stream5_IRQHandler(void) |
|
|||
386 | { |
|
|||
387 | printf("DMA2_Stream5_IRQHandler\n"); |
|
|||
388 | } |
|
|||
389 |
|
||||
390 | void DMA2_Stream6_IRQHandler(void) |
|
|||
391 | { |
|
|||
392 | printf("DMA2_Stream6_IRQHandler\n"); |
|
|||
393 | } |
|
|||
394 |
|
||||
395 | void DMA2_Stream7_IRQHandler(void) |
|
|||
396 | { |
|
|||
397 | printf("DMA2_Stream7_IRQHandler\n"); |
|
|||
398 | } |
|
|||
399 |
|
||||
400 | void USART6_IRQHandler(void) |
|
361 | void USART6_IRQHandler(void) | |
401 | { |
|
362 | { | |
402 | printf("USART6_IRQHandler\n"); |
|
363 | printf("USART6_IRQHandler\n"); | |
403 | } |
|
364 | } | |
404 |
|
365 | |||
405 | void I2C3_EV_IRQHandler(void) |
|
366 | void I2C3_EV_IRQHandler(void) | |
406 | { |
|
367 | { | |
407 | printf("I2C3_EV_IRQHandler\n"); |
|
368 | printf("I2C3_EV_IRQHandler\n"); | |
408 | } |
|
369 | } | |
409 |
|
370 | |||
410 | void I2C3_ER_IRQHandler(void) |
|
371 | void I2C3_ER_IRQHandler(void) | |
411 | { |
|
372 | { | |
412 | printf("I2C3_ER_IRQHandler\n"); |
|
373 | printf("I2C3_ER_IRQHandler\n"); | |
413 | } |
|
374 | } | |
414 |
|
375 | |||
415 | void OTG_HS_EP1_OUT_IRQHandler(void) |
|
376 | void OTG_HS_EP1_OUT_IRQHandler(void) | |
416 | { |
|
377 | { | |
417 | printf("OTG_HS_EP1_OUT_IRQHandler\n"); |
|
378 | printf("OTG_HS_EP1_OUT_IRQHandler\n"); | |
418 | } |
|
379 | } | |
419 |
|
380 | |||
420 | void OTG_HS_EP1_IN_IRQHandler(void) |
|
381 | void OTG_HS_EP1_IN_IRQHandler(void) | |
421 | { |
|
382 | { | |
422 | printf("OTG_HS_EP1_IN_IRQHandler\n"); |
|
383 | printf("OTG_HS_EP1_IN_IRQHandler\n"); | |
423 | } |
|
384 | } | |
424 |
|
385 | |||
425 | void OTG_HS_WKUP_IRQHandler(void) |
|
386 | void OTG_HS_WKUP_IRQHandler(void) | |
426 | { |
|
387 | { | |
427 | printf("OTG_HS_WKUP_IRQHandler\n"); |
|
388 | printf("OTG_HS_WKUP_IRQHandler\n"); | |
428 | } |
|
389 | } | |
429 |
|
390 | |||
430 | void OTG_HS_IRQHandler(void) |
|
391 | void OTG_HS_IRQHandler(void) | |
431 | { |
|
392 | { | |
432 | printf("OTG_HS_IRQHandler\n"); |
|
393 | printf("OTG_HS_IRQHandler\n"); | |
433 | } |
|
394 | } | |
434 |
|
395 | |||
435 | void DCMI_IRQHandler(void) |
|
396 | void DCMI_IRQHandler(void) | |
436 | { |
|
397 | { | |
437 | printf("DCMI_IRQHandler\n"); |
|
398 | printf("DCMI_IRQHandler\n"); | |
438 | } |
|
399 | } | |
439 |
|
400 | |||
440 | void CRYP_IRQHandler(void) |
|
401 | void CRYP_IRQHandler(void) | |
441 | { |
|
402 | { | |
442 | printf("CRYP_IRQHandler\n"); |
|
403 | printf("CRYP_IRQHandler\n"); | |
443 | } |
|
404 | } | |
444 |
|
405 | |||
445 | void HASH_RNG_IRQHandler(void) |
|
406 | void HASH_RNG_IRQHandler(void) | |
446 | { |
|
407 | { | |
447 | printf("HASH_RNG_IRQHandler\n"); |
|
408 | printf("HASH_RNG_IRQHandler\n"); | |
448 | } |
|
409 | } | |
449 |
|
410 | |||
450 | void FPU_IRQHandler(void) |
|
411 | void FPU_IRQHandler(void) | |
451 | { |
|
412 | { | |
452 | printf("FPU_IRQHandler\n"); |
|
413 | printf("FPU_IRQHandler\n"); | |
453 | } |
|
414 | } | |
454 |
|
415 |
@@ -1,17 +1,18 | |||||
1 | TEMPLATE = subdirs |
|
1 | TEMPLATE = subdirs | |
2 | CONFIG += ordered |
|
2 | CONFIG += ordered | |
3 |
|
3 | |||
4 | SUBDIRS = CORE/core.pro \ |
|
4 | SUBDIRS = CORE/core.pro \ | |
5 | CPU/cpu.pro \ |
|
5 | CPU/cpu.pro \ | |
6 | GPIO/gpio.pro \ |
|
6 | GPIO/gpio.pro \ | |
7 | TIMER/timer.pro \ |
|
7 | TIMER/timer.pro \ | |
8 | UART/uart.pro \ |
|
8 | UART/uart.pro \ | |
9 | SPI/spi.pro \ |
|
9 | SPI/spi.pro \ | |
10 | I2C/i2c.pro \ |
|
10 | I2C/i2c.pro \ | |
11 | PWM/pwm.pro \ |
|
11 | PWM/pwm.pro \ | |
12 | DAC/dac.pro\ |
|
12 | DAC/dac.pro\ | |
|
13 | DMA/dma.pro\ | |||
13 | SDCARD-SDIO/sdcard-sdio.pro |
|
14 | SDCARD-SDIO/sdcard-sdio.pro | |
14 |
|
15 | |||
15 |
|
16 | |||
16 |
|
17 | |||
17 |
|
18 |
General Comments 0
You need to be logged in to leave comments.
Login now