Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
174 kaklik 1
GAS LISTING /tmp/cckBHomO.s 			page 1
2
 
3
 
4
   1               	# 1 "CamInterfaceAsm.S"
5
   2               	# 1 "<built-in>"
151 kaklik 6
   1               	;
174 kaklik 7
 
8
 
151 kaklik 9
   2               	;    Copyright (C) 2004    John Orlando
10
   3               	;    
11
   4               	;   AVRcam: a small real-time image processing engine.
12
   5               	
13
   6               	;    This program is free software; you can redistribute it and/or
14
   7               	;    modify it under the terms of the GNU General Public
15
   8               	;    License as published by the Free Software Foundation; either
16
   9               	;    version 2 of the License, or (at your option) any later version.
17
  10               	
18
  11               	;    This program is distributed in the hope that it will be useful,
19
  12               	;    but WITHOUT ANY WARRANTY; without even the implied warranty of
20
  13               	;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21
  14               	;    General Public License for more details.
22
  15               	
23
  16               	;    You should have received a copy of the GNU General Public
24
  17               	;    License along with this program; if not, write to the Free Software
25
  18               	;    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
  19               	
27
  20               	;   For more information on the AVRcam, please contact:
28
  21               	
29
  22               	;   john@jrobot.net
30
  23               	
31
  24               	;   or go to www.jrobot.net for more details regarding the system.
32
  25               	;**********************************************************************
33
  26               	;       Module Name: CanInterfaceAsm.S
34
  27               	;       Module Date: 04/14/2004
35
  28               	;       Module Auth: John Orlando
36
  29               	;
37
  30               	;       Description: This module provides the low-level interface
38
  31               	;       to the OV6620 camera hardware.  It is responsible for
39
  32               	;   	acquiring each pixel block (R,G,B), performing the mapping
40
  33               	;       into an actual color (orange, purple, etc), run-length
41
  34               	;       encoding the data, and storing the info off to the appropriate
42
  35               	;       line buffer.  This routine is synchronized with the pixel data
43
  36               	;       so that no polling of the camera data needs to be done (the
44
  37               	;       OV6620 is clocked off of the same crystal source as the mega8,
45
  38               	;       thus providing inherent synchronization between the two).
46
  39               	;
47
  40               	;       Revision History:
48
  41               	;       Date        Rel Ver.    Notes
49
  42               	;       4/10/2004      0.1     Module created
50
  43               	;       6/30/2004      1.0     Initial release for Circuit Cellar
51
  44               	;                              contest.
52
  45               	;       1/16/2005      1.4     Fixed issue with the TCCR1B register
53
  46               	;                              where PCLK was getting routed to the
54
  47               	;                              timer1 even when it wasn't needed.
55
  48               	;                              This caused excessive counter overflow
56
  49               	;                              interrupts, and caused problems.  Now,
57
  50               	;                              the "PCLK" pipe feeds timer1 when needed,
58
  51               	;                              and is turned off when it isn't needed.
59
  52               	
60
  53               	#include <avr/io.h>
174 kaklik 61
GAS LISTING /tmp/cckBHomO.s 			page 2
62
 
63
 
64
   1               	/* Copyright (c) 2002,2003,2005,2006, Marek Michalkiewicz, Joerg Wunsch
65
   2               	   All rights reserved.
66
   3               	
67
   4               	   Redistribution and use in source and binary forms, with or without
68
   5               	   modification, are permitted provided that the following conditions are met:
69
   6               	
70
   7               	   * Redistributions of source code must retain the above copyright
71
   8               	     notice, this list of conditions and the following disclaimer.
72
   9               	
73
  10               	   * Redistributions in binary form must reproduce the above copyright
74
  11               	     notice, this list of conditions and the following disclaimer in
75
  12               	     the documentation and/or other materials provided with the
76
  13               	     distribution.
77
  14               	
78
  15               	   * Neither the name of the copyright holders nor the names of
79
  16               	     contributors may be used to endorse or promote products derived
80
  17               	     from this software without specific prior written permission.
81
  18               	
82
  19               	  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
83
  20               	  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
84
  21               	  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
85
  22               	  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
86
  23               	  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
87
  24               	  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
88
  25               	  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
89
  26               	  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
90
  27               	  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
91
  28               	  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
92
  29               	  POSSIBILITY OF SUCH DAMAGE. */
93
  30               	
94
  31               	/* $Id: io.h,v 1.24.2.7 2006/04/19 16:53:25 aesok Exp $ */
95
  32               	
96
  33               	/** \defgroup avr_io <avr/io.h>: AVR device-specific IO definitions
97
  34               	    \code #include <avr/io.h> \endcode
98
  35               	
99
  36               	    This header file includes the apropriate IO definitions for the
100
  37               	    device that has been specified by the <tt>-mmcu=</tt> compiler
101
  38               	    command-line switch.  This is done by diverting to the appropriate
102
  39               	    file <tt>&lt;avr/io</tt><em>XXXX</em><tt>.h&gt;</tt> which should
103
  40               	    never be included directly.  Some register names common to all
104
  41               	    AVR devices are defined directly within <tt>&lt;avr/io.h&gt;</tt>,
105
  42               	    but most of the details come from the respective include file.
106
  43               	
107
  44               	    Note that this file always includes
108
  45               	    \code #include <avr/sfr_defs.h> \endcode
109
  46               	    See \ref avr_sfr for the details.
110
  47               	
111
  48               	    Included are definitions of the IO register set and their
112
  49               	    respective bit values as specified in the Atmel documentation.
113
  50               	    Note that Atmel is not very consistent in its naming conventions,
114
  51               	    so even identical functions sometimes get different names on
115
  52               	    different devices.
116
  53               	
117
  54               	    Also included are the specific names useable for interrupt
118
  55               	    function definitions as documented
119
  56               	    \ref avr_signames "here".
120
  57               	
121
GAS LISTING /tmp/cckBHomO.s 			page 3
122
 
123
 
124
  58               	    Finally, the following macros are defined:
125
  59               	
126
  60               	    - \b RAMEND
127
  61               	    <br>
128
  62               	    A constant describing the last on-chip RAM location.
129
  63               	    <br>
130
  64               	    - \b XRAMEND
131
  65               	    <br>
132
  66               	    A constant describing the last possible location in RAM.
133
  67               	    This is equal to RAMEND for devices that do not allow for
134
  68               	    external RAM.
135
  69               	    <br>
136
  70               	    - \b E2END
137
  71               	    <br>
138
  72               	    A constant describing the address of the last EEPROM cell.
139
  73               	    <br>
140
  74               	    - \b FLASHEND
141
  75               	    <br>
142
  76               	    A constant describing the last byte address in flash ROM.
143
  77               	    <br>
144
  78               	    - \b SPM_PAGESIZE
145
  79               	    <br>
146
  80               	    For devices with bootloader support, the flash pagesize
147
  81               	    (in bytes) to be used for the \c SPM instruction. */
148
  82               	
149
  83               	#ifndef _AVR_IO_H_
150
  84               	#define _AVR_IO_H_
151
  85               	
152
  86               	#include <avr/sfr_defs.h>
153
   1               	/* Copyright (c) 2002, Marek Michalkiewicz <marekm@amelek.gda.pl>
154
   2               	   All rights reserved.
155
   3               	
156
   4               	   Redistribution and use in source and binary forms, with or without
157
   5               	   modification, are permitted provided that the following conditions are met:
158
   6               	
159
   7               	   * Redistributions of source code must retain the above copyright
160
   8               	     notice, this list of conditions and the following disclaimer.
161
   9               	
162
  10               	   * Redistributions in binary form must reproduce the above copyright
163
  11               	     notice, this list of conditions and the following disclaimer in
164
  12               	     the documentation and/or other materials provided with the
165
  13               	     distribution.
166
  14               	
167
  15               	   * Neither the name of the copyright holders nor the names of
168
  16               	     contributors may be used to endorse or promote products derived
169
  17               	     from this software without specific prior written permission.
170
  18               	
171
  19               	   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
172
  20               	   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
173
  21               	   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
174
  22               	   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
175
  23               	   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
176
  24               	   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
177
  25               	   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
178
  26               	   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
179
  27               	   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
180
  28               	   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
181
GAS LISTING /tmp/cckBHomO.s 			page 4
182
 
183
 
184
  29               	   POSSIBILITY OF SUCH DAMAGE.  */
185
  30               	
186
  31               	/* avr/sfr_defs.h - macros for accessing AVR special function registers */
187
  32               	
188
  33               	/* $Id: sfr_defs.h,v 1.16 2005/09/10 21:31:13 joerg_wunsch Exp $ */
189
  34               	
190
  35               	#ifndef _AVR_SFR_DEFS_H_
191
  36               	#define _AVR_SFR_DEFS_H_ 1
192
  37               	
193
  38               	/** \defgroup avr_sfr_notes Additional notes from <avr/sfr_defs.h>
194
  39               	    \ingroup avr_sfr
195
  40               	
196
  41               	   The \c <avr/sfr_defs.h> file is included by all of the \c <avr/ioXXXX.h>
197
  42               	   files, which use macros defined here to make the special function register
198
  43               	   definitions look like C variables or simple constants, depending on the
199
  44               	   <tt>_SFR_ASM_COMPAT</tt> define.  Some examples from \c <avr/iom128.h> to
200
  45               	   show how to define such macros:
201
  46               	
202
  47               	\code
203
  48               	#define PORTA _SFR_IO8(0x1b)
204
  49               	#define TCNT1 _SFR_IO16(0x2c)
205
  50               	#define PORTF _SFR_MEM8(0x61)
206
  51               	#define TCNT3 _SFR_MEM16(0x88)
207
  52               	\endcode
208
  53               	
209
  54               	   If \c _SFR_ASM_COMPAT is not defined, C programs can use names like
210
  55               	   <tt>PORTA</tt> directly in C expressions (also on the left side of
211
  56               	   assignment operators) and GCC will do the right thing (use short I/O
212
  57               	   instructions if possible).  The \c __SFR_OFFSET definition is not used in
213
  58               	   any way in this case.
214
  59               	
215
  60               	   Define \c _SFR_ASM_COMPAT as 1 to make these names work as simple constants
216
  61               	   (addresses of the I/O registers).  This is necessary when included in
217
  62               	   preprocessed assembler (*.S) source files, so it is done automatically if
218
  63               	   \c __ASSEMBLER__ is defined.  By default, all addresses are defined as if
219
  64               	   they were memory addresses (used in \c lds/sts instructions).  To use these
220
  65               	   addresses in \c in/out instructions, you must subtract 0x20 from them.
221
  66               	
222
  67               	   For more backwards compatibility, insert the following at the start of your
223
  68               	   old assembler source file:
224
  69               	
225
  70               	\code
226
  71               	#define __SFR_OFFSET 0
227
  72               	\endcode
228
  73               	
229
  74               	   This automatically subtracts 0x20 from I/O space addresses, but it's a
230
  75               	   hack, so it is recommended to change your source: wrap such addresses in
231
  76               	   macros defined here, as shown below.  After this is done, the
232
  77               	   <tt>__SFR_OFFSET</tt> definition is no longer necessary and can be removed.
233
  78               	
234
  79               	   Real example - this code could be used in a boot loader that is portable
235
  80               	   between devices with \c SPMCR at different addresses.
236
  81               	
237
  82               	\verbatim
238
  83               	<avr/iom163.h>: #define SPMCR _SFR_IO8(0x37)
239
  84               	<avr/iom128.h>: #define SPMCR _SFR_MEM8(0x68)
240
  85               	\endverbatim
241
GAS LISTING /tmp/cckBHomO.s 			page 5
242
 
243
 
244
  86               	
245
  87               	\code
246
  87               	
247
  88               	#ifndef __AVR_HAVE_MOVW__
248
  89               	#  if  defined(__AVR_ENHANCED__) && __AVR_ENHANCED__
249
  90               	#   define __AVR_HAVE_MOVW__ 1
250
  91               	#  endif
251
  92               	#endif
252
  93               	
253
  94               	#ifndef __AVR_HAVE_LPMX__
254
  95               	# if  defined(__AVR_ENHANCED__) && __AVR_ENHANCED__
255
  96               	#  define __AVR_HAVE_LPMX__ 1
256
  97               	# endif
257
  98               	#endif
258
  99               	
259
 100               	/*
260
 101               	 * Registers common to all AVR devices.
261
 102               	 */
262
 103               	
263
 104               	#if __AVR_ARCH__ != 1
264
 105               	/*
265
 106               	 * AVR architecture 1 has no RAM, thus no stack pointer.
266
 107               	 *
267
 108               	 * All other archs do have a stack pointer.  Some devices have only
268
 109               	 * less than 256 bytes of possible RAM locations (128 Bytes of SRAM
269
 110               	 * and no option for external RAM), thus SPH is officially "reserved"
270
 111               	 * for them.  We catch this case below after including the
271
 112               	 * device-specific ioXXXX.h file, by examining XRAMEND, and
272
 113               	 * #undef-ining SP and SPH in that case.
273
 114               	 */
274
 115               	/* Stack Pointer */
275
 116               	#define SP        _SFR_IO16(0x3D)
276
 117               	#define SPL       _SFR_IO8(0x3D)
277
 118               	#define SPH       _SFR_IO8(0x3E)
278
 119               	#endif /* #if __AVR_ARCH__ != 1 */
279
 120               	
280
 121               	/* Status REGister */
281
 122               	#define SREG      _SFR_IO8(0x3F)
282
 123               	
283
 124               	/* Status Register - SREG */
284
 125               	#define    SREG_I       7
285
 126               	#define    SREG_T       6
286
 127               	#define    SREG_H       5
287
 128               	#define    SREG_S       4
288
 129               	#define    SREG_V       3
289
 130               	#define    SREG_N       2
290
 131               	#define    SREG_Z       1
291
 132               	#define    SREG_C       0
292
 133               	
293
 134               	/* Pointer definition */
294
 135               	#if __AVR_ARCH__ != 1
295
 136               	/* avr1 has only the Z pointer */
296
 137               	#define    XL           r26
297
 138               	#define    XH           r27
298
 139               	#define    YL           r28
299
 140               	#define    YH           r29
300
 141               	#endif /* #if __AVR_ARCH__ != 1 */
301
GAS LISTING /tmp/cckBHomO.s 			page 6
302
 
303
 
304
 142               	#define    ZL           r30
305
 143               	#define    ZH           r31
306
 144               	
307
 145               	/*
308
 146               	 * Only few devices come without EEPROM.  In order to assemble the
309
 147               	 * EEPROM library components without defining a specific device, we
310
 148               	 * keep the EEPROM-related definitions here.
311
 149               	 */
312
 150               	#if defined(__COMPILING_AVR_LIBC__)
313
 151               	
314
 152               	/* EEPROM Control Register */
315
 153               	#define EECR	_SFR_IO8(0x1C)
316
 154               	
317
 155               	/* EEPROM Data Register */
318
 156               	#define EEDR	_SFR_IO8(0x1D)
319
 157               	
320
 158               	/* EEPROM Address Register */
321
 159               	#define EEAR	_SFR_IO16(0x1E)
322
 160               	#define EEARL	_SFR_IO8(0x1E)
323
 161               	#define EEARH	_SFR_IO8(0x1F)
324
 162               	
325
 163               	/* EEPROM Control Register */
326
 164               	#define    EERIE        3
327
 165               	#define    EEMWE        2
328
 166               	#define    EEWE         1
329
 167               	#define    EERE         0
330
 168               	
331
 169               	#endif /* __COMPILING_AVR_LIBC__ */
332
 170               	
333
 171               	#if defined (__AVR_AT94K__)
334
 172               	#  include <avr/ioat94k.h>
335
 173               	#elif defined (__AVR_AT43USB320__)
336
 174               	#  include <avr/io43u32x.h>
337
 175               	#elif defined (__AVR_AT43USB355__)
338
 176               	#  include <avr/io43u35x.h>
339
 177               	#elif defined (__AVR_AT76C711__)
340
 178               	#  include <avr/io76c711.h>
341
 179               	#elif defined (__AVR_AT86RF401__)
342
 180               	#  include <avr/io86r401.h>
343
 181               	#elif defined (__AVR_AT90PWM2__)
344
 182               	#  include <avr/io90pwmx.h>
345
 183               	#elif defined (__AVR_AT90PWM3__)
346
 184               	#  include <avr/io90pwmx.h>
347
 185               	#elif defined (__AVR_ATmega128__)
348
 186               	#  include <avr/iom128.h>
349
 187               	#elif defined (__AVR_ATmega1280__)
350
 188               	#  include <avr/iom1280.h>
351
 189               	#elif defined (__AVR_ATmega1281__)
352
 190               	#  include <avr/iom1281.h>
353
 191               	#elif defined (__AVR_AT90CAN32__)
354
 192               	#  include <avr/iocan32.h>
355
 193               	#elif defined (__AVR_AT90CAN64__)
356
 194               	#  include <avr/iocan64.h>
357
 195               	#elif defined (__AVR_AT90CAN128__)
358
 196               	#  include <avr/iocan128.h>
359
 197               	#elif defined (__AVR_AT90USB646__)
360
 198               	#  include <avr/iousb646.h>
361
GAS LISTING /tmp/cckBHomO.s 			page 7
362
 
363
 
364
 199               	#elif defined (__AVR_AT90USB647__)
365
 200               	#  include <avr/iousb647.h>
366
 201               	#elif defined (__AVR_AT90USB1286__)
367
 202               	#  include <avr/iousb1286.h>
368
 203               	#elif defined (__AVR_AT90USB1287__)
369
 204               	#  include <avr/iousb1287.h>
370
 205               	#elif defined (__AVR_ATmega64__)
371
 206               	#  include <avr/iom64.h>
372
 207               	#elif defined (__AVR_ATmega640__)
373
 208               	#  include <avr/iom640.h>
374
 209               	#elif defined (__AVR_ATmega644__)
375
 210               	#  include <avr/iom644.h>
376
 211               	#elif defined (__AVR_ATmega644P__)
377
 212               	#  include <avr/iom644.h>
378
 213               	#elif defined (__AVR_ATmega645__)
379
 214               	#  include <avr/iom645.h>
380
 215               	#elif defined (__AVR_ATmega6450__)
381
 216               	#  include <avr/iom6450.h>
382
 217               	#elif defined (__AVR_ATmega649__)
383
 218               	#  include <avr/iom649.h>
384
 219               	#elif defined (__AVR_ATmega6490__)
385
 220               	#  include <avr/iom6490.h>
386
 221               	#elif defined (__AVR_ATmega103__)
387
 222               	#  include <avr/iom103.h>
388
 223               	#elif defined (__AVR_ATmega32__)
389
 224               	#  include <avr/iom32.h>
390
 225               	#elif defined (__AVR_ATmega323__)
391
 226               	#  include <avr/iom323.h>
392
 227               	#elif defined (__AVR_ATmega324P__)
393
 228               	#  include <avr/iom324.h>
394
 229               	#elif defined (__AVR_ATmega325__)
395
 230               	#  include <avr/iom325.h>
396
 231               	#elif defined (__AVR_ATmega3250__)
397
 232               	#  include <avr/iom3250.h>
398
 233               	#elif defined (__AVR_ATmega329__)
399
 234               	#  include <avr/iom329.h>
400
 235               	#elif defined (__AVR_ATmega3290__)
401
 236               	#  include <avr/iom3290.h>
402
 237               	#elif defined (__AVR_ATmega406__)
403
 238               	#  include <avr/iom406.h>
404
 239               	#elif defined (__AVR_ATmega16__)
405
 240               	#  include <avr/iom16.h>
406
 241               	#elif defined (__AVR_ATmega161__)
407
 242               	#  include <avr/iom161.h>
408
 243               	#elif defined (__AVR_ATmega162__)
409
 244               	#  include <avr/iom162.h>
410
 245               	#elif defined (__AVR_ATmega163__)
411
 246               	#  include <avr/iom163.h>
412
 247               	#elif defined (__AVR_ATmega164P__)
413
 248               	#  include <avr/iom164.h>
414
 249               	#elif defined (__AVR_ATmega165__)
415
 250               	#  include <avr/iom165.h>
416
 251               	#elif defined (__AVR_ATmega168__)
417
 252               	#  include <avr/iom168.h>
418
 253               	#elif defined (__AVR_ATmega169__)
419
 254               	#  include <avr/iom169.h>
420
 255               	#elif defined (__AVR_ATmega8__)
421
GAS LISTING /tmp/cckBHomO.s 			page 8
422
 
423
 
424
 256               	#  include <avr/iom8.h>
425
   1               	/* Copyright (c) 2002, Marek Michalkiewicz
426
   2               	   All rights reserved.
427
   3               	
428
   4               	   Redistribution and use in source and binary forms, with or without
429
   5               	   modification, are permitted provided that the following conditions are met:
430
   6               	
431
   7               	   * Redistributions of source code must retain the above copyright
432
   8               	     notice, this list of conditions and the following disclaimer.
433
   9               	
434
  10               	   * Redistributions in binary form must reproduce the above copyright
435
  11               	     notice, this list of conditions and the following disclaimer in
436
  12               	     the documentation and/or other materials provided with the
437
  13               	     distribution.
438
  14               	
439
  15               	   * Neither the name of the copyright holders nor the names of
440
  16               	     contributors may be used to endorse or promote products derived
441
  17               	     from this software without specific prior written permission.
442
  18               	
443
  19               	  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
444
  20               	  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
445
  21               	  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
446
  22               	  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
447
  23               	  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
448
  24               	  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
449
  25               	  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
450
  26               	  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
451
  27               	  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
452
  28               	  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
453
  29               	  POSSIBILITY OF SUCH DAMAGE. */
454
  30               	
455
  31               	/* $Id: iom8.h,v 1.13 2005/10/30 22:11:23 joerg_wunsch Exp $ */
456
  32               	
457
  33               	/* avr/iom8.h - definitions for ATmega8 */
458
  34               	
459
  35               	#ifndef _AVR_IOM8_H_
460
  36               	#define _AVR_IOM8_H_ 1
461
  37               	
462
  38               	/* This file should only be included from <avr/io.h>, never directly. */
463
  39               	
464
  40               	#ifndef _AVR_IO_H_
465
  41               	#  error "Include <avr/io.h> instead of this file."
466
  42               	#endif
467
  43               	
468
  44               	#ifndef _AVR_IOXXX_H_
469
  45               	#  define _AVR_IOXXX_H_ "iom8.h"
470
  46               	#else
471
  47               	#  error "Attempt to include more than one <avr/ioXXX.h> file."
472
  48               	#endif 
473
  49               	
474
  50               	/* I/O registers */
475
  51               	
476
  52               	/* TWI stands for "Two Wire Interface" or "TWI Was I2C(tm)" */
477
  53               	#define TWBR	_SFR_IO8(0x00)
478
  54               	#define TWSR	_SFR_IO8(0x01)
479
  55               	#define TWAR	_SFR_IO8(0x02)
480
  56               	#define TWDR	_SFR_IO8(0x03)
481
GAS LISTING /tmp/cckBHomO.s 			page 9
482
 
483
 
484
  57               	
485
  58               	/* ADC */
486
  59               	#define ADCW	_SFR_IO16(0x04)
487
  60               	#ifndef __ASSEMBLER__
488
  61               	#define ADC	_SFR_IO16(0x04)
489
  62               	#endif
490
  63               	#define ADCL	_SFR_IO8(0x04)
491
  64               	#define ADCH	_SFR_IO8(0x05)
492
  65               	#define ADCSR	_SFR_IO8(0x06)
493
  66               	#define ADCSRA	_SFR_IO8(0x06)  /* Changed in 2486H-AVR-09/02 */
494
  67               	#define ADMUX	_SFR_IO8(0x07)
495
  68               	
496
  69               	/* analog comparator */
497
  70               	#define ACSR	_SFR_IO8(0x08)
498
  71               	
499
  72               	/* USART */
500
  73               	#define UBRRL	_SFR_IO8(0x09)
501
  74               	#define UCSRB	_SFR_IO8(0x0A)
502
  75               	#define UCSRA	_SFR_IO8(0x0B)
503
  76               	#define UDR	_SFR_IO8(0x0C)
504
  77               	
505
  78               	/* SPI */
506
  79               	#define SPCR	_SFR_IO8(0x0D)
507
  80               	#define SPSR	_SFR_IO8(0x0E)
508
  81               	#define SPDR	_SFR_IO8(0x0F)
509
  82               	
510
  83               	/* Port D */
511
  84               	#define PIND	_SFR_IO8(0x10)
512
  85               	#define DDRD	_SFR_IO8(0x11)
513
  86               	#define PORTD	_SFR_IO8(0x12)
514
  87               	
515
  88               	/* Port C */
516
  89               	#define PINC	_SFR_IO8(0x13)
517
  90               	#define DDRC	_SFR_IO8(0x14)
518
  91               	#define PORTC	_SFR_IO8(0x15)
519
  92               	
520
  93               	/* Port B */
521
  94               	#define PINB	_SFR_IO8(0x16)
522
  95               	#define DDRB	_SFR_IO8(0x17)
523
  96               	#define PORTB	_SFR_IO8(0x18)
524
  97               	
525
  98               	/* EEPROM Control Register */
526
  99               	#define EECR	_SFR_IO8(0x1C)
527
 100               	
528
 101               	/* EEPROM Data Register */
529
 102               	#define EEDR	_SFR_IO8(0x1D)
530
 103               	
531
 104               	/* EEPROM Address Register */
532
 105               	#define EEAR	_SFR_IO16(0x1E)
533
 106               	#define EEARL	_SFR_IO8(0x1E)
534
 107               	#define EEARH	_SFR_IO8(0x1F)
535
 108               	
536
 109               	#define UCSRC	_SFR_IO8(0x20)
537
 110               	#define UBRRH	_SFR_IO8(0x20)
538
 111               	
539
 112               	#define WDTCR	_SFR_IO8(0x21)
540
 113               	#define ASSR	_SFR_IO8(0x22)
541
GAS LISTING /tmp/cckBHomO.s 			page 10
542
 
543
 
544
 114               	
545
 115               	/* Timer 2 */
546
 116               	#define OCR2	_SFR_IO8(0x23)
547
 117               	#define TCNT2	_SFR_IO8(0x24)
548
 118               	#define TCCR2	_SFR_IO8(0x25)
549
 119               	
550
 120               	/* Timer 1 */
551
 121               	#define ICR1	_SFR_IO16(0x26)
552
 122               	#define ICR1L	_SFR_IO8(0x26)
553
 123               	#define ICR1H	_SFR_IO8(0x27)
554
 124               	#define OCR1B	_SFR_IO16(0x28)
555
 125               	#define OCR1BL	_SFR_IO8(0x28)
556
 126               	#define OCR1BH	_SFR_IO8(0x29)
557
 127               	#define OCR1A	_SFR_IO16(0x2A)
558
 128               	#define OCR1AL	_SFR_IO8(0x2A)
559
 129               	#define OCR1AH	_SFR_IO8(0x2B)
560
 130               	#define TCNT1	_SFR_IO16(0x2C)
561
 131               	#define TCNT1L	_SFR_IO8(0x2C)
562
 132               	#define TCNT1H	_SFR_IO8(0x2D)
563
 133               	#define TCCR1B	_SFR_IO8(0x2E)
564
 134               	#define TCCR1A	_SFR_IO8(0x2F)
565
 135               	
566
 136               	#define SFIOR	_SFR_IO8(0x30)
567
 137               	
568
 138               	#define OSCCAL	_SFR_IO8(0x31)
569
 139               	
570
 140               	/* Timer 0 */
571
 141               	#define TCNT0	_SFR_IO8(0x32)
572
 142               	#define TCCR0	_SFR_IO8(0x33)
573
 143               	
574
 144               	#define MCUCSR	_SFR_IO8(0x34)
575
 145               	#define MCUCR	_SFR_IO8(0x35)
576
 146               	
577
 147               	#define TWCR	_SFR_IO8(0x36)
578
 148               	
579
 149               	#define SPMCR	_SFR_IO8(0x37)
580
 150               	
581
 151               	#define TIFR	_SFR_IO8(0x38)
582
 152               	#define TIMSK	_SFR_IO8(0x39)
583
 153               	
584
 154               	#define GIFR	_SFR_IO8(0x3A)
585
 155               	#define GIMSK	_SFR_IO8(0x3B)
586
 156               	#define GICR	_SFR_IO8(0x3B)   /* Changed in 2486H-AVR-09/02 */
587
 157               	
588
 158               	/* 0x3C reserved (OCR0?) */
589
 159               	
590
 160               	/* 0x3D..0x3E SP */
591
 161               	
592
 162               	/* 0x3F SREG */
593
 163               	
594
 164               	/* Interrupt vectors */
595
 165               	
596
 166               	/* External Interrupt Request 0 */
597
 167               	#define INT0_vect			_VECTOR(1)
598
 168               	#define SIG_INTERRUPT0			_VECTOR(1)
599
 169               	
600
 170               	/* External Interrupt Request 1 */
601
GAS LISTING /tmp/cckBHomO.s 			page 11
602
 
603
 
604
 171               	#define INT1_vect			_VECTOR(2)
605
 172               	#define SIG_INTERRUPT1			_VECTOR(2)
606
 173               	
607
 174               	/* Timer/Counter2 Compare Match */
608
 175               	#define TIMER2_COMP_vect		_VECTOR(3)
609
 176               	#define SIG_OUTPUT_COMPARE2		_VECTOR(3)
610
 177               	
611
 178               	/* Timer/Counter2 Overflow */
612
 179               	#define TIMER2_OVF_vect			_VECTOR(4)
613
 180               	#define SIG_OVERFLOW2			_VECTOR(4)
614
 181               	
615
 182               	/* Timer/Counter1 Capture Event */
616
 183               	#define TIMER1_CAPT_vect		_VECTOR(5)
617
 184               	#define SIG_INPUT_CAPTURE1		_VECTOR(5)
618
 185               	
619
 186               	/* Timer/Counter1 Compare Match A */
620
 187               	#define TIMER1_COMPA_vect		_VECTOR(6)
621
 188               	#define SIG_OUTPUT_COMPARE1A		_VECTOR(6)
622
 189               	
623
 190               	/* Timer/Counter1 Compare Match B */
624
 191               	#define TIMER1_COMPB_vect		_VECTOR(7)
625
 192               	#define SIG_OUTPUT_COMPARE1B		_VECTOR(7)
626
 193               	
627
 194               	/* Timer/Counter1 Overflow */
628
 195               	#define TIMER1_OVF_vect			_VECTOR(8)
629
 196               	#define SIG_OVERFLOW1			_VECTOR(8)
630
 197               	
631
 198               	/* Timer/Counter0 Overflow */
632
 199               	#define TIMER0_OVF_vect			_VECTOR(9)
633
 200               	#define SIG_OVERFLOW0			_VECTOR(9)
634
 201               	
635
 202               	/* Serial Transfer Complete */
636
 203               	#define SPI_STC_vect			_VECTOR(10)
637
 204               	#define SIG_SPI				_VECTOR(10)
638
 205               	
639
 206               	/* USART, Rx Complete */
640
 207               	#define USART_RXC_vect			_VECTOR(11)
641
 208               	#define SIG_UART_RECV			_VECTOR(11)
642
 209               	
643
 210               	/* USART Data Register Empty */
644
 211               	#define USART_UDRE_vect			_VECTOR(12)
645
 212               	#define SIG_UART_DATA			_VECTOR(12)
646
 213               	
647
 214               	/* USART, Tx Complete */
648
 215               	#define USART_TXC_vect			_VECTOR(13)
649
 216               	#define SIG_UART_TRANS			_VECTOR(13)
650
 217               	
651
 218               	/* ADC Conversion Complete */
652
 219               	#define ADC_vect			_VECTOR(14)
653
 220               	#define SIG_ADC				_VECTOR(14)
654
 221               	
655
 222               	/* EEPROM Ready */
656
 223               	#define EE_RDY_vect			_VECTOR(15)
657
 224               	#define SIG_EEPROM_READY		_VECTOR(15)
658
 225               	
659
 226               	/* Analog Comparator */
660
 227               	#define ANA_COMP_vect			_VECTOR(16)
661
GAS LISTING /tmp/cckBHomO.s 			page 12
662
 
663
 
664
 228               	#define SIG_COMPARATOR			_VECTOR(16)
665
 229               	
666
 230               	/* 2-wire Serial Interface */
667
 231               	#define TWI_vect			_VECTOR(17)
668
 232               	#define SIG_2WIRE_SERIAL		_VECTOR(17)
669
 233               	
670
 234               	/* Store Program Memory Ready */
671
 235               	#define SPM_RDY_vect			_VECTOR(18)
672
 236               	#define SIG_SPM_READY			_VECTOR(18)
673
 237               	
674
 238               	#define _VECTORS_SIZE 38
675
 239               	
676
 240               	/* Bit numbers */
677
 241               	
678
 242               	/* GIMSK / GICR */
679
 243               	#define INT1	7
680
 244               	#define INT0	6
681
 245               	#define IVSEL	1
682
 246               	#define IVCE	0
683
 247               	
684
 248               	/* GIFR */
685
 249               	#define INTF1	7
686
 250               	#define INTF0	6
687
 251               	
688
 252               	/* TIMSK */
689
 253               	#define OCIE2	7
690
 254               	#define TOIE2	6
691
 255               	#define TICIE1	5
692
 256               	#define OCIE1A	4
693
 257               	#define OCIE1B	3
694
 257               	#elif defined (__AVR_ATmega48__)
695
 258               	#  include <avr/iom48.h>
696
 259               	#elif defined (__AVR_ATmega88__)
697
 260               	#  include <avr/iom88.h>
698
 261               	#elif defined (__AVR_ATmega8515__)
699
 262               	#  include <avr/iom8515.h>
700
 263               	#elif defined (__AVR_ATmega8535__)
701
 264               	#  include <avr/iom8535.h>
702
 265               	#elif defined (__AVR_AT90S8535__)
703
 266               	#  include <avr/io8535.h>
704
 267               	#elif defined (__AVR_AT90C8534__)
705
 268               	#  include <avr/io8534.h>
706
 269               	#elif defined (__AVR_AT90S8515__)
707
 270               	#  include <avr/io8515.h>
708
 271               	#elif defined (__AVR_AT90S4434__)
709
 272               	#  include <avr/io4434.h>
710
 273               	#elif defined (__AVR_AT90S4433__)
711
 274               	#  include <avr/io4433.h>
712
 275               	#elif defined (__AVR_AT90S4414__)
713
 276               	#  include <avr/io4414.h>
714
 277               	#elif defined (__AVR_ATtiny22__)
715
 278               	#  include <avr/iotn22.h>
716
 279               	#elif defined (__AVR_ATtiny26__)
717
 280               	#  include <avr/iotn26.h>
718
 281               	#elif defined (__AVR_AT90S2343__)
719
 282               	#  include <avr/io2343.h>
720
 283               	#elif defined (__AVR_AT90S2333__)
721
GAS LISTING /tmp/cckBHomO.s 			page 13
722
 
723
 
724
 284               	#  include <avr/io2333.h>
725
 285               	#elif defined (__AVR_AT90S2323__)
726
 286               	#  include <avr/io2323.h>
727
 287               	#elif defined (__AVR_AT90S2313__)
728
 288               	#  include <avr/io2313.h>
729
 289               	#elif defined (__AVR_ATtiny2313__)
730
 290               	#  include <avr/iotn2313.h>
731
 291               	#elif defined (__AVR_ATtiny13__)
732
 292               	#  include <avr/iotn13.h>
733
 293               	#elif defined (__AVR_ATtiny25__)
734
 294               	#  include <avr/iotn25.h>
735
 295               	#elif defined (__AVR_ATtiny45__)
736
 296               	#  include <avr/iotn45.h>
737
 297               	#elif defined (__AVR_ATtiny85__)
738
 298               	#  include <avr/iotn85.h>
739
 299               	#elif defined (__AVR_ATtiny24__)
740
 300               	#  include <avr/iotn24.h>
741
 301               	#elif defined (__AVR_ATtiny44__)
742
 302               	#  include <avr/iotn44.h>
743
 303               	#elif defined (__AVR_ATtiny84__)
744
 304               	#  include <avr/iotn84.h>
745
 305               	#elif defined (__AVR_ATtiny261__)
746
 306               	#  include <avr/iotn261.h>
747
 307               	#elif defined (__AVR_ATtiny461__)
748
 308               	#  include <avr/iotn461.h>
749
 309               	#elif defined (__AVR_ATtiny861__)
750
 310               	#  include <avr/iotn861.h>
751
 311               	/* avr1: the following only supported for assembler programs */
752
 312               	#elif defined (__AVR_ATtiny28__)
753
 313               	#  include <avr/iotn28.h>
754
 314               	#elif defined (__AVR_AT90S1200__)
755
 315               	#  include <avr/io1200.h>
756
 316               	#elif defined (__AVR_ATtiny15__)
757
 317               	#  include <avr/iotn15.h>
758
 318               	#elif defined (__AVR_ATtiny12__)
759
 319               	#  include <avr/iotn12.h>
760
 320               	#elif defined (__AVR_ATtiny11__)
761
 321               	#  include <avr/iotn11.h>
762
 322               	#else
763
 323               	#  if !defined(__COMPILING_AVR_LIBC__)
764
 324               	#    warning "device type not defined"
765
 325               	#  endif
766
 326               	#endif
767
 327               	
768
 328               	#include <avr/portpins.h>
769
   1               	/* Copyright (c) 2003  Theodore A. Roth
770
   2               	   All rights reserved.
771
   3               	
772
   4               	   Redistribution and use in source and binary forms, with or without
773
   5               	   modification, are permitted provided that the following conditions are met:
774
   6               	
775
   7               	   * Redistributions of source code must retain the above copyright
776
   8               	     notice, this list of conditions and the following disclaimer.
777
   9               	
778
  10               	   * Redistributions in binary form must reproduce the above copyright
779
  11               	     notice, this list of conditions and the following disclaimer in
780
  12               	     the documentation and/or other materials provided with the
781
GAS LISTING /tmp/cckBHomO.s 			page 14
782
 
783
 
784
  13               	     distribution.
785
  14               	
786
  15               	   * Neither the name of the copyright holders nor the names of
787
  16               	     contributors may be used to endorse or promote products derived
788
  17               	     from this software without specific prior written permission.
789
  18               	
790
  19               	  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
791
  20               	  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
792
  21               	  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
793
  22               	  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
794
  23               	  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
795
  24               	  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
796
  25               	  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
797
  26               	  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
798
  27               	  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
799
  28               	  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
800
  29               	  POSSIBILITY OF SUCH DAMAGE. */
801
  30               	
802
  31               	/* $Id: portpins.h,v 1.3.4.1 2006/03/10 16:22:38 aesok Exp $ */
803
  32               	
804
  33               	#ifndef _AVR_PORTPINS_H_
805
  34               	#define _AVR_PORTPINS_H_ 1
806
  35               	
807
  36               	/* This file should only be included from <avr/io.h>, never directly. */
808
  37               	
809
  38               	#ifndef _AVR_IO_H_
810
  39               	#  error "Include <avr/io.h> instead of this file."
811
  40               	#endif
812
  41               	
813
  42               	/* Define Generic PORTn, DDn, and PINn values. */
814
  43               	
815
  44               	/* Port Data Register (generic) */
816
  45               	#define    PORT7        7
817
  46               	#define    PORT6        6
818
  47               	#define    PORT5        5
819
  48               	#define    PORT4        4
820
  49               	#define    PORT3        3
821
  50               	#define    PORT2        2
822
  51               	#define    PORT1        1
823
  52               	#define    PORT0        0
824
  53               	
825
  54               	/* Port Data Direction Register (generic) */
826
  55               	#define    DD7          7
827
  56               	#define    DD6          6
828
  57               	#define    DD5          5
829
  58               	#define    DD4          4
830
  59               	#define    DD3          3
831
  60               	#define    DD2          2
832
  61               	#define    DD1          1
833
  62               	#define    DD0          0
834
  63               	
835
  64               	/* Port Input Pins (generic) */
836
  65               	#define    PIN7         7
837
  66               	#define    PIN6         6
838
  67               	#define    PIN5         5
839
  68               	#define    PIN4         4
840
  69               	#define    PIN3         3
841
GAS LISTING /tmp/cckBHomO.s 			page 15
842
 
843
 
844
  70               	#define    PIN2         2
845
  71               	#define    PIN1         1
846
  72               	#define    PIN0         0
847
  73               	
848
  74               	/* Define PORTxn values for all possible port pins. */
849
  75               	
850
  76               	/* PORT A */
851
  77               	
852
  78               	#if defined(PA0)
853
  79               	#  define PORTA0 PA0
854
  80               	#endif
855
  81               	#if defined(PA1)
856
  82               	#  define PORTA1 PA1
857
  83               	#endif
858
  84               	#if defined(PA2)
859
  85               	#  define PORTA2 PA2
860
  86               	#endif
861
  87               	#if defined(PA3)
862
  88               	#  define PORTA3 PA3
863
  89               	#endif
864
  90               	#if defined(PA4)
865
  91               	#  define PORTA4 PA4
866
  92               	#endif
867
  93               	#if defined(PA5)
868
  94               	#  define PORTA5 PA5
869
  95               	#endif
870
  96               	#if defined(PA6)
871
  97               	#  define PORTA6 PA6
872
  98               	#endif
873
  99               	#if defined(PA7)
874
 100               	#  define PORTA7 PA7
875
 101               	#endif
876
 102               	
877
 103               	/* PORT B */
878
 104               	
879
 105               	#if defined(PB0)
880
 106               	#  define PORTB0 PB0
881
 107               	#endif
882
 108               	#if defined(PB1)
883
 109               	#  define PORTB1 PB1
884
 110               	#endif
885
 111               	#if defined(PB2)
886
 112               	#  define PORTB2 PB2
887
 113               	#endif
888
 114               	#if defined(PB3)
889
 115               	#  define PORTB3 PB3
890
 116               	#endif
891
 117               	#if defined(PB4)
892
 118               	#  define PORTB4 PB4
893
 119               	#endif
894
 120               	#if defined(PB5)
895
 121               	#  define PORTB5 PB5
896
 122               	#endif
897
 123               	#if defined(PB6)
898
 124               	#  define PORTB6 PB6
899
 125               	#endif
900
 126               	#if defined(PB7)
901
GAS LISTING /tmp/cckBHomO.s 			page 16
902
 
903
 
904
 127               	#  define PORTB7 PB7
905
 128               	#endif
906
 129               	
907
 130               	/* PORT C */
908
 131               	
909
 132               	#if defined(PC0)
910
 133               	#  define PORTC0 PC0
911
 134               	#endif
912
 135               	#if defined(PC1)
913
 136               	#  define PORTC1 PC1
914
 137               	#endif
915
 138               	#if defined(PC2)
916
 139               	#  define PORTC2 PC2
917
 140               	#endif
918
 141               	#if defined(PC3)
919
 142               	#  define PORTC3 PC3
920
 143               	#endif
921
 144               	#if defined(PC4)
922
 145               	#  define PORTC4 PC4
923
 146               	#endif
924
 147               	#if defined(PC5)
925
 148               	#  define PORTC5 PC5
926
 149               	#endif
927
 150               	#if defined(PC6)
928
 151               	#  define PORTC6 PC6
929
 152               	#endif
930
 153               	#if defined(PC7)
931
 154               	#  define PORTC7 PC7
932
 155               	#endif
933
 156               	
934
 157               	/* PORT D */
935
 158               	
936
 159               	#if defined(PD0)
937
 160               	#  define PORTD0 PD0
938
 161               	#endif
939
 162               	#if defined(PD1)
940
 163               	#  define PORTD1 PD1
941
 164               	#endif
942
 165               	#if defined(PD2)
943
 166               	#  define PORTD2 PD2
944
 167               	#endif
945
 168               	#if defined(PD3)
946
 169               	#  define PORTD3 PD3
947
 170               	#endif
948
 171               	#if defined(PD4)
949
 172               	#  define PORTD4 PD4
950
 173               	#endif
951
 174               	#if defined(PD5)
952
 175               	#  define PORTD5 PD5
953
 176               	#endif
954
 177               	#if defined(PD6)
955
 178               	#  define PORTD6 PD6
956
 179               	#endif
957
 180               	#if defined(PD7)
958
 181               	#  define PORTD7 PD7
959
 182               	#endif
960
 183               	
961
GAS LISTING /tmp/cckBHomO.s 			page 17
962
 
963
 
964
 184               	/* PORT E */
965
 185               	
966
 186               	#if defined(PE0)
967
 187               	#  define PORTE0 PE0
968
 188               	#endif
969
 189               	#if defined(PE1)
970
 190               	#  define PORTE1 PE1
971
 191               	#endif
972
 192               	#if defined(PE2)
973
 193               	#  define PORTE2 PE2
974
 194               	#endif
975
 195               	#if defined(PE3)
976
 196               	#  define PORTE3 PE3
977
 197               	#endif
978
 198               	#if defined(PE4)
979
 199               	#  define PORTE4 PE4
980
 200               	#endif
981
 201               	#if defined(PE5)
982
 202               	#  define PORTE5 PE5
983
 203               	#endif
984
 204               	#if defined(PE6)
985
 205               	#  define PORTE6 PE6
986
 206               	#endif
987
 207               	#if defined(PE7)
988
 208               	#  define PORTE7 PE7
989
 209               	#endif
990
 210               	
991
 211               	/* PORT F */
992
 212               	
993
 213               	#if defined(PF0)
994
 214               	#  define PORTF0 PF0
995
 215               	#endif
996
 216               	#if defined(PF1)
997
 217               	#  define PORTF1 PF1
998
 218               	#endif
999
 219               	#if defined(PF2)
1000
 220               	#  define PORTF2 PF2
1001
 221               	#endif
1002
 222               	#if defined(PF3)
1003
 223               	#  define PORTF3 PF3
1004
 224               	#endif
1005
 225               	#if defined(PF4)
1006
 226               	#  define PORTF4 PF4
1007
 227               	#endif
1008
 228               	#if defined(PF5)
1009
 229               	#  define PORTF5 PF5
1010
 230               	#endif
1011
 231               	#if defined(PF6)
1012
 232               	#  define PORTF6 PF6
1013
 233               	#endif
1014
 234               	#if defined(PF7)
1015
 235               	#  define PORTF7 PF7
1016
 236               	#endif
1017
 237               	
1018
 238               	/* PORT G */
1019
 239               	
1020
 240               	#if defined(PG0)
1021
GAS LISTING /tmp/cckBHomO.s 			page 18
1022
 
1023
 
1024
 241               	#  define PORTG0 PG0
1025
 242               	#endif
1026
 243               	#if defined(PG1)
1027
 244               	#  define PORTG1 PG1
1028
 245               	#endif
1029
 246               	#if defined(PG2)
1030
 247               	#  define PORTG2 PG2
1031
 248               	#endif
1032
 249               	#if defined(PG3)
1033
 250               	#  define PORTG3 PG3
1034
 251               	#endif
1035
 252               	#if defined(PG4)
1036
 253               	#  define PORTG4 PG4
1037
 254               	#endif
1038
 255               	#if defined(PG5)
1039
 256               	#  define PORTG5 PG5
1040
 257               	#endif
1041
 258               	#if defined(PG6)
1042
 259               	#  define PORTG6 PG6
1043
 260               	#endif
1044
 261               	#if defined(PG7)
1045
 262               	#  define PORTG7 PG7
1046
 263               	#endif
1047
 264               	
1048
 265               	/* PORT H */
1049
 266               	
1050
 267               	#if defined(PH0)
1051
 268               	#  define PORTH0 PH0
1052
 269               	#endif
1053
 270               	#if defined(PH1)
1054
 271               	#  define PORTH1 PH1
1055
 272               	#endif
1056
 273               	#if defined(PH2)
1057
 274               	#  define PORTH2 PH2
1058
 275               	#endif
1059
 276               	#if defined(PH3)
1060
 277               	#  define PORTH3 PH3
1061
 278               	#endif
1062
 279               	#if defined(PH4)
1063
 280               	#  define PORTH4 PH4
1064
 281               	#endif
1065
 282               	#if defined(PH5)
1066
 283               	#  define PORTH5 PH5
1067
 284               	#endif
1068
 285               	#if defined(PH6)
1069
 286               	#  define PORTH6 PH6
1070
 287               	#endif
1071
 288               	#if defined(PH7)
1072
 289               	#  define PORTH7 PH7
1073
 290               	#endif
1074
 291               	
1075
 292               	/* PORT J */
1076
 293               	
1077
 294               	#if defined(PJ0)
1078
 295               	#  define PORTJ0 PJ0
1079
 296               	#endif
1080
 297               	#if defined(PJ1)
1081
GAS LISTING /tmp/cckBHomO.s 			page 19
1082
 
1083
 
1084
 298               	#  define PORTJ1 PJ1
1085
 299               	#endif
1086
 300               	#if defined(PJ2)
1087
 301               	#  define PORTJ2 PJ2
1088
 302               	#endif
1089
 303               	#if defined(PJ3)
1090
 304               	#  define PORTJ3 PJ3
1091
 305               	#endif
1092
 306               	#if defined(PJ4)
1093
 307               	#  define PORTJ4 PJ4
1094
 308               	#endif
1095
 309               	#if defined(PJ5)
1096
 310               	#  define PORTJ5 PJ5
1097
 311               	#endif
1098
 312               	#if defined(PJ6)
1099
 313               	#  define PORTJ6 PJ6
1100
 314               	#endif
1101
 315               	#if defined(PJ7)
1102
 316               	#  define PORTJ7 PJ7
1103
 317               	#endif
1104
 318               	
1105
 319               	/* PORT K */
1106
 320               	
1107
 321               	#if defined(PK0)
1108
 322               	#  define PORTK0 PK0
1109
 323               	#endif
1110
 324               	#if defined(PK1)
1111
 325               	#  define PORTK1 PK1
1112
 326               	#endif
1113
 327               	#if defined(PK2)
1114
 328               	#  define PORTK2 PK2
1115
 329               	#endif
1116
 329               	
1117
 330               	#if __AVR_ARCH__ != 1
1118
 331               	#  if XRAMEND < 0x100 && !defined(__COMPILING_AVR_LIBC__)
1119
 332               	#    undef SP
1120
 333               	#    define SP     _SFR_IO8(0x3D)
1121
 334               	#    undef SPH
1122
 335               	#  endif
1123
 336               	#endif
1124
 337               	
1125
 338               	#include <avr/version.h>
1126
   1               	/* Copyright (c) 2005, Joerg Wunsch                               -*- c -*-
1127
   2               	   All rights reserved.
1128
   3               	
1129
   4               	   Redistribution and use in source and binary forms, with or without
1130
   5               	   modification, are permitted provided that the following conditions are met:
1131
   6               	
1132
   7               	   * Redistributions of source code must retain the above copyright
1133
   8               	     notice, this list of conditions and the following disclaimer.
1134
   9               	
1135
  10               	   * Redistributions in binary form must reproduce the above copyright
1136
  11               	     notice, this list of conditions and the following disclaimer in
1137
  12               	     the documentation and/or other materials provided with the
1138
  13               	     distribution.
1139
  14               	
1140
  15               	   * Neither the name of the copyright holders nor the names of
1141
GAS LISTING /tmp/cckBHomO.s 			page 20
1142
 
1143
 
1144
  16               	     contributors may be used to endorse or promote products derived
1145
  17               	     from this software without specific prior written permission.
1146
  18               	
1147
  19               	  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1148
  20               	  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1149
  21               	  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1150
  22               	  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
1151
  23               	  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1152
  24               	  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1153
  25               	  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1154
  26               	  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1155
  27               	  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1156
  28               	  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1157
  29               	  POSSIBILITY OF SUCH DAMAGE. */
1158
  30               	
1159
  31               	/* $Id: version.h.in,v 1.1 2005/09/12 20:18:12 joerg_wunsch Exp $ */
1160
  32               	
1161
  33               	/** \defgroup avr_version <avr/version.h>: avr-libc version macros
1162
  34               	    \code #include <avr/version.h> \endcode
1163
  35               	
1164
  36               	    This header file defines macros that contain version numbers and
1165
  37               	    strings describing the current version of avr-libc.
1166
  38               	
1167
  39               	    The version number itself basically consists of three pieces that
1168
  40               	    are separated by a dot: the major number, the minor number, and
1169
  41               	    the revision number.  For development versions (which use an odd
1170
  42               	    minor number), the string representation additionally gets the
1171
  43               	    date code (YYYYMMDD) appended.
1172
  44               	
1173
  45               	    This file will also be included by \c <avr/io.h>.  That way,
1174
  46               	    portable tests can be implemented using \c <avr/io.h> that can be
1175
  47               	    used in code that wants to remain backwards-compatible to library
1176
  48               	    versions prior to the date when the library version API had been
1177
  49               	    added, as referenced but undefined C preprocessor macros
1178
  50               	    automatically evaluate to 0.
1179
  51               	*/
1180
  52               	
1181
  53               	#ifndef _AVR_VERSION_H_
1182
  54               	#define _AVR_VERSION_H_
1183
  55               	
1184
  56               	/** \ingroup avr_version
1185
  57               	    String literal representation of the current library version. */
1186
  58               	#define __AVR_LIBC_VERSION_STRING__ "1.4.4"
1187
  59               	
1188
  60               	/** \ingroup avr_version
1189
  61               	    Numerical representation of the current library version.
1190
  62               	
1191
  63               	    In the numerical representation, the major number is multiplied by
1192
  64               	    10000, the minor number by 100, and all three parts are then
1193
  65               	    added.  It is intented to provide a monotonically increasing
1194
  66               	    numerical value that can easily be used in numerical checks.
1195
  67               	 */
1196
  68               	#define __AVR_LIBC_VERSION__        10404UL
1197
  69               	
1198
  70               	/** \ingroup avr_version
1199
  71               	    String literal representation of the release date. */
1200
  72               	#define __AVR_LIBC_DATE_STRING__    "20060420"
1201
GAS LISTING /tmp/cckBHomO.s 			page 21
1202
 
1203
 
1204
  73               	
1205
  74               	/** \ingroup avr_version
1206
  75               	    Numerical representation of the release date. */
1207
  76               	#define __AVR_LIBC_DATE_            20060420UL
1208
  77               	
1209
  78               	/** \ingroup avr_version
1210
  79               	    Library major version number. */
1211
  80               	#define __AVR_LIBC_MAJOR__          1
1212
  81               	
1213
  82               	/** \ingroup avr_version
1214
  83               	    Library minor version number. */
1215
  84               	#define __AVR_LIBC_MINOR__          4
1216
  85               	
1217
  86               	/** \ingroup avr_version
1218
  87               	    Library revision number. */
1219
  88               	#define __AVR_LIBC_REVISION__       4
1220
  89               	
1221
  90               	#endif /* _AVR_VERSION_H_ */
1222
  91               	...
1223
 339               	
151 kaklik 1224
  54               	#include "Events.h"
1225
   1               	#ifndef EVENTS_H
1226
   2               	#define EVENTS_H
1227
   3               	
1228
   4               	/*
1229
   5               	    Copyright (C) 2004    John Orlando
1230
   6               	    
1231
   7               	   AVRcam: a small real-time image processing engine.
1232
   8               	
1233
   9               	    This program is free software; you can redistribute it and/or
1234
  10               	    modify it under the terms of the GNU General Public
1235
  11               	    License as published by the Free Software Foundation; either
1236
  12               	    version 2 of the License, or (at your option) any later version.
1237
  13               	
1238
  14               	    This program is distributed in the hope that it will be useful,
1239
  15               	    but WITHOUT ANY WARRANTY; without even the implied warranty of
1240
  16               	    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1241
  17               	    General Public License for more details.
1242
  18               	
1243
  19               	    You should have received a copy of the GNU General Public
1244
  20               	    License along with this program; if not, write to the Free Software
1245
  21               	    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1246
  22               	
1247
  23               	   For more information on the AVRcam, please contact:
1248
  24               	
1249
  25               	   john@jrobot.net
1250
  26               	
1251
  27               	   or go to www.jrobot.net for more details regarding the system.
1252
  28               	*/
1253
  29               	/*********************************************************** 
1254
  30               		Module Name: Events.h
1255
  31               		Module Date: 05/23/2004
1256
  32               		Module Auth: John Orlando
1257
  33               		
1258
  34               		Description: This file provides the external interface
1259
  35               		to the events that can be published/processed in the
1260
  36               		system.  It is specifically by itself (and nothing
174 kaklik 1261
GAS LISTING /tmp/cckBHomO.s 			page 22
1262
 
1263
 
151 kaklik 1264
  37               		else should be defined in here) so that both .c and
1265
  38               		.S (assembly) files can include this file without
1266
  39               		a problem.
1267
  40               	    
1268
  41               	    Revision History:
1269
  42               	    Date        Rel Ver.    Notes
1270
  43               	    4/10/2004      0.1     Module created
1271
  44               	    6/30/2004      1.0     Initial release for Circuit Cellar
1272
  45               	                           contest.
1273
  46               	    *******************************************************/
1274
  47               	
1275
  48               	/* Definitions */
1276
  49               	/* Originally, all events were passed in a bitmask...however,
1277
  50               	an event FIFO was finally used, but the coding of the event
1278
  51               	definitions were never translated back....doesn't make a
1279
  52               	difference, but looks a little weird */
1280
  53               	#define EV_SERIAL_DATA_RECEIVED		0x01
1281
  54               	#define EV_DUMP_FRAME				0x02
1282
  55               	#define EV_PROCESS_FRAME_COMPLETE	0x04
1283
  55               			
1284
  56               			.extern fastEventBitmask    ; This is the flag used to indicate to the rest
1285
  57               										; of the system that the line is complete
1286
  58               									
1287
  59               	#define HREF_INTERRUPT_ENABLE_MASK   0x80
1288
  60               	#define HREF_INTERRUPT_DISABLE_MASK  0x7F
1289
  61               	#define ENABLE_PCLK_TIMER1_OVERFLOW_BITMASK  0x04
1290
  62               	#define DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK 0xFB
1291
  63               	#define G_PORT						_SFR_IO_ADDR(PINC)  
1292
  64               	#define RB_PORT						_SFR_IO_ADDR(PINB)  
1293
  65               	#define PIXEL_RUN_START_INITIAL     0x50     	; This value causes our pixel counter (TCNT1)
1294
  66               													; to overflow after 176 (horizontal) pixels
1295
  67               	
1296
  68               	#define RED_MEM_OFFSET				0x00
1297
  69               	#define GREEN_MEM_OFFSET			0x10
1298
  70               	#define BLUE_MEM_OFFSET				0x20
1299
  71               	
1300
  72               	; A pixelBlock is defined as a contiguous group of 4 pixels that are combined 
1301
  73               	; together to form a specific color.  Typically, this is formed by sampling a
1302
  74               	; a green value, followed by a red and blue value (since we are dealing
1303
  75               	; with Bayer color data).  We could optionally sample a second green with
1304
  76               	; the red and average the greens, because the eye is more sensitive to
1305
  77               	; green, but for speed we don't do this.  These three values (RGB) are then
1306
  78               	; used as indices into the color membership lookup table (memLookup) to
1307
  79               	; determine which color the pixelBlock maps into.  The memLookup table is
1308
  80               	; manually generated for now (though it will hopefully be modified over
1309
  81               	; the serial interface eventually).
1310
  82               	;
1311
  83               	; Here is a pixel block:
1312
  84               	; ...G  G  G  G...  (row x)
1313
  85               	; ...B  R  B  R...  (row x+1)
1314
  86               	;    |  |  |  |--this is skipped 
1315
  87               	;    |  |  |--this is skipped
1316
  88               	;    |  |--this is sampled
1317
  89               	;    |--this is sampled
1318
  90               	
1319
  91               	; As pixel blocks are sampled, the red, green, and blue values are
1320
  92               	; used to index into their respective color maps.  The color maps
174 kaklik 1321
GAS LISTING /tmp/cckBHomO.s 			page 23
1322
 
1323
 
151 kaklik 1324
  93               	; return values that can be logically ANDed together so that a 
1325
  94               	; particular RGB triplet will result in a single bit being set
1326
  95               	; after the AND operation.  This single bit indicates which color
1327
  96               	; the RGB triplet represents.  It is also possible for no bits to
1328
  97               	; be set after the AND process, indicating that the RGB triplet
1329
  98               	; does not map to any of the colors configured in the color map.
1330
  99               	; This isn't quite as fast as a pure RGB lookup table, but
1331
 100               	; it then again it doesn't require 2^12 (4-bits for each color
1332
 101               	; channel) bytes to store the lookup table.  It takes just a few
1333
 102               	; more cycles, and only requires 48 bytes of precious RAM (16
1334
 103               	; per color channel, since our resolution on each color channel
1335
 104               	; is only 4-bits).  Not bad....for more information, see:
1336
 105               	; http://www.cs.cmu.edu/~trb/papers/wirevision00.pdf for more
1337
 106               	; information on this color segmentation technique.
1338
 107               	
1339
 108               	; One other note: this code does depend on the colorMap residing
1340
 109               	; at a well-defined position in memory; specifically, it mus
1341
 110               	; start at a 256-byte boundary so that the lowest byte in the
1342
 111               	; map is set to 0x00.  Currently, the colorMap is forced to
1343
 112               	; start at RAM location 0x300.  This could potentially be changed
1344
 113               	; by the developer if needed, but offsets would have to be added
1345
 114               	; in to the colorMap look-up code below to make it work.
1346
 115               	
1347
 116               	
1348
 117               	; These are the registers that will be used throughout this
1349
 118               	; module for acquiring each line of pixel data
1350
 119               	pixelCount			= 16
1351
 120               	pixelRunStart		= 17
1352
 121               	lastColor     		= 18
1353
 122               	tmp1				= 19	; be sure to not use tmp1 and color simultaneously
1354
 123               	tmp2				= 20
1355
 124               	color           	= 19
1356
 125               	greenData       	= 20
1357
 126               	blueData        	= 21
1358
 127               	colorMapLow	  		= 22
1359
 128               	colorMapHigh		= 23
1360
 129               	prevLineBuffLow  	= 22  	; overlaps with memLookupLow (but orthogonal)
1361
 130               	prevLineBuffHigh	= 23	; overlaps with memLookupHigh (but orthogonal)
1362
 131               	currLineBuffLow     = 24
1363
 132               	currLineBuffHigh  	= 25
1364
 133               	
1365
 134               	        .section .text
1366
 135               	
1367
 136               	; These are the global assembly function names that are accessed via other
1368
 137               	; C functions
1369
 138               	        .global CamIntAsm_waitForNewTrackingFrame
1370
 139               			.global CamIntAsm_waitForNewDumpFrame
1371
 140               			.global CamIntAsm_acquireDumpLine
1372
 141               			.global CamIntAsm_acquireTrackingLine
1373
 142               			.global SIG_INTERRUPT0
1374
 143               			.global SIG_INTERRUPT1
1375
 144               			.global SIG_OVERFLOW0
1376
 145               			.global SIG_OVERFLOW1
1377
 146               			
1378
 147               	;*****************************************************************		
1379
 148               	;   	Function Name: CamIntAsm_waitForNewTrackingFrame
1380
 149               	;       Function Description: This function is responsible for
174 kaklik 1381
GAS LISTING /tmp/cckBHomO.s 			page 24
1382
 
1383
 
151 kaklik 1384
 150               	;       going to sleep until a new frame begins (indicated by
1385
 151               	;    	VSYNC transitioning from low to high.  This will wake
1386
 152               	;       the "VSYNC sleep" up and allow it to continue with 
1387
 153               	;       the acquireLine function, where the system waits for
1388
 154               	;       an "HREF sleep" that we use to synchronize with the
1389
 155               	;       data.  
1390
 156               	;       Inputs:  r25 - MSB of currentLineBuffer
1391
 157               	;                r24 - LSB of currentLineBuffer
1392
 158               	;				 r23 - MSB of colorMap
1393
 159               	; 				 r22 - LSB of colorMap
1394
 160               	;       Outputs: none
1395
 161               	;       NOTES: This function doesn't really return...it sorta just
1396
 162               	;       floats into the acquireLine function after the "VSYNC sleep"
1397
 163               	;       is awoken, then begins processing the line data.  Once
1398
 164               	;		176 pixels are sampled (and the counter overflows), then
1399
 165               	;		an interrupt will occur, the 'T' bit in the SREG will be
1400
 166               	;		set, and the function will return.
1401
 167               	;*****************************************************************
1402
 168               			
1403
 169               	CamIntAsm_waitForNewTrackingFrame:
1404
 170:CamInterfaceAsm.S **** 		sbi		_SFR_IO_ADDR(PORTD),PD6  ; For testing...
1405
 171:CamInterfaceAsm.S **** 		cbi		_SFR_IO_ADDR(PORTD),PD6		
1406
 172:CamInterfaceAsm.S **** 		sleep
1407
 173               	
1408
 174               	;*****************************************************************
1409
 175               	; REMEMBER...everything from here on out is critically timed to be
1410
 176               	; synchronized with the flow of pixel data from the camera...
1411
 177               	;*****************************************************************
1412
 178               	
1413
 179               	CamIntAsm_acquireTrackingLine:
1414
 180:CamInterfaceAsm.S **** 		brts	_cleanUp
1415
 181               			;sbi		_SFR_IO_ADDR(PORTD),PD6 ; For testing...
1416
 182               			;cbi		_SFR_IO_ADDR(PORTD),PD6
1417
 183               	        
1418
 184:CamInterfaceAsm.S ****         in      tmp1,_SFR_IO_ADDR(TCCR1B) ; Enable the PCLK line to actually
1419
 185:CamInterfaceAsm.S ****         ori     tmp1, 0x07                 ; feed Timer1
1420
 186:CamInterfaceAsm.S ****         out     _SFR_IO_ADDR(TCCR1B),tmp1 
1421
 187               											; The line is about to start...		
1422
 188:CamInterfaceAsm.S **** 		ldi     pixelCount,0			; Initialize the RLE stats...
1423
 189:CamInterfaceAsm.S **** 		ldi		pixelRunStart,PIXEL_RUN_START_INITIAL  	; Remember, we always calculate
1424
 190               															; the pixel run length as
1425
 191               															; TCNT1L - pixelRunStart
1426
 192               			
1427
 193:CamInterfaceAsm.S **** 		ldi		lastColor,0x00				; clear out the last color before we start
1428
 194               			
1429
 195:CamInterfaceAsm.S **** 		mov   	XH,currLineBuffHigh    	; Load the pointer to the current line
1430
 196:CamInterfaceAsm.S **** 		mov		XL,currLineBuffLow		; buffer into the X pointer regs		 
1431
 197               			
1432
 198:CamInterfaceAsm.S **** 		mov   	ZH,colorMapHigh      	; Load the pointers to the membership
1433
 199:CamInterfaceAsm.S **** 		mov		ZL,colorMapLow			; lookup tables (ZL and YL will be overwritten
1434
 200:CamInterfaceAsm.S **** 		mov 	YH,colorMapHigh	 		; as soon as we start reading data) to Z and Y
1435
 201               			
1436
 202:CamInterfaceAsm.S **** 		in		tmp1, _SFR_IO_ADDR(TIMSK)			; enable TIMER1 to start counting
1437
 203:CamInterfaceAsm.S **** 		ori		tmp1, ENABLE_PCLK_TIMER1_OVERFLOW_BITMASK 	; external PCLK pulses and interrupt on 
1438
 204:CamInterfaceAsm.S **** 		out		_SFR_IO_ADDR(TIMSK),tmp1			; overflow
1439
 205               			
1440
 206:CamInterfaceAsm.S **** 		ldi 	tmp1,PIXEL_RUN_START_INITIAL	; set up the TCNT1 to overflow (and
174 kaklik 1441
GAS LISTING /tmp/cckBHomO.s 			page 25
1442
 
1443
 
151 kaklik 1444
 207:CamInterfaceAsm.S **** 		ldi 	tmp2,0xFF 						; interrupts) after 176 pixels		
1445
 208:CamInterfaceAsm.S **** 		out 	_SFR_IO_ADDR(TCNT1H),tmp2		
1446
 209:CamInterfaceAsm.S **** 		out 	_SFR_IO_ADDR(TCNT1L),tmp1				
1447
 210               			
1448
 211:CamInterfaceAsm.S **** 		mov		YL,colorMapLow		
1449
 212               			
1450
 213:CamInterfaceAsm.S **** 		in 		tmp1, _SFR_IO_ADDR(GICR)	; enable the HREF interrupt...remember, we
1451
 214               												; only use this interrupt to synchronize
1452
 215               												; the beginning of the line
1453
 216:CamInterfaceAsm.S **** 		ori 	tmp1, HREF_INTERRUPT_ENABLE_MASK
1454
 217:CamInterfaceAsm.S **** 		out		_SFR_IO_ADDR(GICR), tmp1
1455
 218               			
1456
 219               	;*******************************************************************************************
1457
 220               	;   Track Frame handler 
1458
 221               	;*******************************************************************************************		
1459
 222               			
1460
 223               	_trackFrame:		
1461
 224:CamInterfaceAsm.S **** 		sbi		_SFR_IO_ADDR(PORTD),PD6
1462
 225:CamInterfaceAsm.S **** 		sleep   ; ...And we wait...
1463
 226               			
1464
 227               		; Returning from the interrupt/sleep wakeup will consume
1465
 228               		; 14 clock cycles (7 to wakeup from idle sleep, 3 to vector, and 4 to return)	
1466
 229               	
1467
 230               		; Disable the HREF interrupt
1468
 231:CamInterfaceAsm.S **** 		cbi		_SFR_IO_ADDR(PORTD),PD6
1469
 232:CamInterfaceAsm.S **** 		in 		tmp1, _SFR_IO_ADDR(GICR)
1470
 233:CamInterfaceAsm.S **** 		andi 	tmp1, HREF_INTERRUPT_DISABLE_MASK
1471
 234:CamInterfaceAsm.S **** 		out		_SFR_IO_ADDR(GICR), tmp1
1472
 235               			
1473
 236               		; A couple of NOPs are needed here to sync up the pixel data...the number (2)
1474
 237               		; of NOPs was determined emperically by trial and error.
1475
 238:CamInterfaceAsm.S **** 		nop
1476
 239:CamInterfaceAsm.S **** 		nop
1477
 240               	_acquirePixelBlock:							;							Clock Cycle Count
1478
 241:CamInterfaceAsm.S **** 		in		ZL,RB_PORT         			; sample the red value (PINB)		(1)
1479
 242:CamInterfaceAsm.S **** 		in		YL,G_PORT         			; sample the green value (PINC)		(1)
1480
 243:CamInterfaceAsm.S **** 		andi	YL,0x0F            			; clear the high nibble				(1)
1481
 244:CamInterfaceAsm.S **** 		ldd		color,Z+RED_MEM_OFFSET  	; lookup the red membership			(2)
1482
 245:CamInterfaceAsm.S **** 		in		ZL,RB_PORT         			; sample the blue value (PINB)		(1)
1483
 246:CamInterfaceAsm.S **** 		ldd		greenData,Y+GREEN_MEM_OFFSET; lookup the green membership		(2)
1484
 247:CamInterfaceAsm.S **** 		ldd		blueData,Z+BLUE_MEM_OFFSET	; lookup the blue membership		(2)
1485
 248:CamInterfaceAsm.S **** 		and		color,greenData 			; mask memberships together			(1)
1486
 249:CamInterfaceAsm.S **** 		and		color,blueData  			; to produce the final color		(1)
1487
 250:CamInterfaceAsm.S **** 		brts    _cleanUpTrackingLine		; if some interrupt routine has		(1...not set)
1488
 251               												; come in and set our T flag in 
1489
 252               												; SREG, then we need to hop out
1490
 253               												; and blow away this frames data (common cleanup)									
1491
 254:CamInterfaceAsm.S **** 		cp		color,lastColor     		; check to see if the run continues	(1)
1492
 255:CamInterfaceAsm.S **** 		breq    _acquirePixelBlock  		;									(2...equal)
1493
 256               												;									___________
1494
 257               												;								16 clock cycles 		
1495
 258               												; (16 clock cycles = 1 uS = 1 pixelBlock time)
1496
 259               			
1497
 260               			; Toggle the debug line to indicate a color change
1498
 261:CamInterfaceAsm.S **** 		sbi     _SFR_IO_ADDR(PORTD),PD6
1499
 262:CamInterfaceAsm.S **** 		nop
1500
 263:CamInterfaceAsm.S **** 		cbi		_SFR_IO_ADDR(PORTD),PD6
174 kaklik 1501
GAS LISTING /tmp/cckBHomO.s 			page 26
1502
 
1503
 
151 kaklik 1504
 264               			
1505
 265:CamInterfaceAsm.S **** 		mov		tmp2,pixelRunStart				; get the count value of the
1506
 266               													; current pixel run
1507
 267:CamInterfaceAsm.S **** 		in		pixelCount,_SFR_IO_ADDR(TCNT1L)	; get the current TCNT1 value 
1508
 268:CamInterfaceAsm.S **** 		mov   	pixelRunStart,pixelCount		; reload pixelRunStart for the
1509
 269               													; next run
1510
 270:CamInterfaceAsm.S **** 		sub		pixelCount,tmp2     			; pixelCount = TCNT1L - pixelRunStart
1511
 271               											
1512
 272:CamInterfaceAsm.S **** 		st		X+,lastColor			; record the color run in the current line buffer
1513
 273:CamInterfaceAsm.S **** 		st		X+,pixelCount			; with its length
1514
 274:CamInterfaceAsm.S **** 		mov		lastColor,color			; set lastColor so we can figure out when it changes
1515
 275               			
1516
 276:CamInterfaceAsm.S **** 		nop								; waste one more cycle for a total of 16
1517
 277:CamInterfaceAsm.S **** 		rjmp	_acquirePixelBlock	
1518
 278               			
1519
 279               	; _cleanUpTrackingLine is used to write the last run length block off to the currentLineBuffer so
1520
 280               	; that all 176 pixels in the line are accounted for.
1521
 281               	_cleanUpTrackingLine:		
1522
 282:CamInterfaceAsm.S **** 		ldi		pixelCount,0xFF		; the length of the last run is ALWAYS 0xFF minus the last
1523
 283:CamInterfaceAsm.S **** 		sub		pixelCount,pixelRunStart  	; pixelRunStart
1524
 284               			
1525
 285:CamInterfaceAsm.S **** 		inc		pixelCount				; increment pixelCount since we actually need to account
1526
 286               											; for the overflow of TCNT1
1527
 287               											
1528
 288:CamInterfaceAsm.S **** 		st		X+,color				; record the color run in the current line buffer
1529
 289:CamInterfaceAsm.S **** 		st		X,pixelCount		
1530
 290:CamInterfaceAsm.S **** 		rjmp	_cleanUp
1531
 291               			
1532
 292               	_cleanUpDumpLine:		
1533
 293               			; NOTE: If serial data is received, to interrupt the tracking of a line, we'll
1534
 294               			; get a EV_SERIAL_DATA_RECEIVED event, and the T bit set so we will end the
1535
 295               			; line's processing...however, the PCLK will keep on ticking for the rest of
1536
 296               			; the frame/line, which will cause the TCNT to eventually overflow and
1537
 297               			; interrupt us, generating a EV_ACQUIRE_LINE_COMPLETE event.  We don't want
1538
 298               			; this, so we need to actually turn off the PCLK counting each time we exit
1539
 299               			; this loop, and only turn it on when we begin acquiring lines....
1540
 300               	        ; NOT NEEDED FOR NOW...
1541
 301               			;in		tmp1, _SFR_IO_ADDR(TIMSK)			; disable TIMER1 to stop counting
1542
 302               			;andi	tmp1, DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK 	; external PCLK pulses
1543
 303               			;out		_SFR_IO_ADDR(TIMSK),tmp1
1544
 304               	
1545
 305               	_cleanUp:
1546
 306               	        ; Disable the external clocking of the Timer1 counter 
1547
 307:CamInterfaceAsm.S ****         in      tmp1, _SFR_IO_ADDR(TCCR1B)
1548
 308:CamInterfaceAsm.S ****         andi    tmp1, 0xF8
1549
 309:CamInterfaceAsm.S ****         out     _SFR_IO_ADDR(TCCR1B),tmp1
1550
 310               			
1551
 311               			; Toggle the debug line to indicate the line is complete
1552
 312:CamInterfaceAsm.S **** 		sbi     _SFR_IO_ADDR(PORTD),PD6
1553
 313:CamInterfaceAsm.S **** 		cbi		_SFR_IO_ADDR(PORTD),PD6
1554
 314:CamInterfaceAsm.S **** 		clt				; clear out the T bit since we have detected
1555
 315               							; the interruption and are exiting to handle it
1556
 316               	_exit:
1557
 317:CamInterfaceAsm.S **** 		ret
1558
 318               			
1559
 319               	;*****************************************************************		
1560
 320               	;   	Function Name: CamIntAsm_waitForNewDumpFrame
174 kaklik 1561
GAS LISTING /tmp/cckBHomO.s 			page 27
1562
 
1563
 
151 kaklik 1564
 321               	;       Function Description: This function is responsible for
1565
 322               	;       going to sleep until a new frame begins (indicated by
1566
 323               	;    	VSYNC transitioning from low to high.  This will wake
1567
 324               	;       the "VSYNC sleep" up and allow it to continue with 
1568
 325               	;       acquiring a line of pixel data to dump out to the UI.
1569
 326               	;       Inputs:  r25 - MSB of currentLineBuffer
1570
 327               	;                r24 - LSB of currentLineBuffer
1571
 328               	;				 r23 - MSB of prevLineBuffer
1572
 329               	;				 r22 - LSB of prevLineBuffer
1573
 330               	;       Outputs: none
1574
 331               	;       NOTES: This function doesn't really return...it sorta just
1575
 332               	;       floats into the acquireDumpLine function after the "VSYNC sleep"
1576
 333               	;       is awoken.
1577
 334               	;*****************************************************************		
1578
 335               	CamIntAsm_waitForNewDumpFrame:
1579
 336:CamInterfaceAsm.S **** 		sbi		_SFR_IO_ADDR(PORTD),PD6  ; For testing...
1580
 337:CamInterfaceAsm.S **** 		cbi		_SFR_IO_ADDR(PORTD),PD6
1581
 338:CamInterfaceAsm.S **** 		sleep
1582
 339               	
1583
 340               	;*****************************************************************
1584
 341               	; REMEMBER...everything from here on out is critically timed to be
1585
 342               	; synchronized with the flow of pixel data from the camera...
1586
 343               	;*****************************************************************
1587
 344               	
1588
 345               	CamIntAsm_acquireDumpLine:
1589
 346:CamInterfaceAsm.S **** 		brts	_cleanUp
1590
 347               			;sbi		_SFR_IO_ADDR(PORTD),PD6 ; For testing...
1591
 348               			;cbi		_SFR_IO_ADDR(PORTD),PD6
1592
 349               			
1593
 350:CamInterfaceAsm.S **** 		mov   	XH,currLineBuffHigh    	; Load the pointer to the current line
1594
 351:CamInterfaceAsm.S **** 		mov		XL,currLineBuffLow		; buffer into the X pointer regs
1595
 352               	
1596
 353:CamInterfaceAsm.S **** 		mov		YH,prevLineBuffHigh		; Load the pointer to the previous line
1597
 354:CamInterfaceAsm.S **** 		mov		YL,prevLineBuffLow  	; buffer into the Y pointer regs
1598
 355               			
1599
 356:CamInterfaceAsm.S **** 		ldi 	tmp1,PIXEL_RUN_START_INITIAL	; set up the TCNT1 to overflow (and
1600
 357:CamInterfaceAsm.S **** 		ldi 	tmp2,0xFF 						; interrupts) after 176 pixels		
1601
 358:CamInterfaceAsm.S **** 		out 	_SFR_IO_ADDR(TCNT1H),tmp2		
1602
 359:CamInterfaceAsm.S **** 		out 	_SFR_IO_ADDR(TCNT1L),tmp1		
1603
 360               			
1604
 361:CamInterfaceAsm.S ****         in      tmp1, _SFR_IO_ADDR(TCCR1B) ; Enable the PCLK line to actually
1605
 362:CamInterfaceAsm.S ****         ori     tmp1, 0x07                 ; feed Timer1
1606
 363:CamInterfaceAsm.S ****         out     _SFR_IO_ADDR(TCCR1B),tmp1
1607
 364:CamInterfaceAsm.S ****         nop
1608
 365               	        
1609
 366:CamInterfaceAsm.S **** 		in		tmp1, _SFR_IO_ADDR(TIMSK)			; enable TIMER1 to start counting
1610
 367:CamInterfaceAsm.S **** 		ori		tmp1, ENABLE_PCLK_TIMER1_OVERFLOW_BITMASK 	; external PCLK pulses and interrupt on 
1611
 368:CamInterfaceAsm.S **** 		out		_SFR_IO_ADDR(TIMSK),tmp1			; overflow			
1612
 369               			
1613
 370:CamInterfaceAsm.S **** 		in 		tmp1, _SFR_IO_ADDR(GICR)	; enable the HREF interrupt...remember, we
1614
 371               												; only use this interrupt to synchronize
1615
 372               												; the beginning of the line
1616
 373:CamInterfaceAsm.S **** 		ori 	tmp1, HREF_INTERRUPT_ENABLE_MASK
1617
 374:CamInterfaceAsm.S **** 		out		_SFR_IO_ADDR(GICR), tmp1
1618
 375               			
1619
 376               	;*******************************************************************************************
1620
 377               	;   Dump Frame handler 
174 kaklik 1621
GAS LISTING /tmp/cckBHomO.s 			page 28
1622
 
1623
 
151 kaklik 1624
 378               	;*******************************************************************************************		
1625
 379               			
1626
 380               	_dumpFrame:		
1627
 381:CamInterfaceAsm.S **** 		sbi		_SFR_IO_ADDR(PORTD),PD6
1628
 382:CamInterfaceAsm.S **** 		sleep   ; ...And we wait...
1629
 383               	
1630
 384:CamInterfaceAsm.S **** 		cbi		_SFR_IO_ADDR(PORTD),PD6
1631
 385:CamInterfaceAsm.S **** 		in 		tmp1, _SFR_IO_ADDR(GICR)			; disable the HREF interrupt
1632
 386:CamInterfaceAsm.S **** 		andi 	tmp1, HREF_INTERRUPT_DISABLE_MASK  	; so we don't get interrupted
1633
 387:CamInterfaceAsm.S **** 		out		_SFR_IO_ADDR(GICR), tmp1			; while dumping the line
1634
 388               		
1635
 389:CamInterfaceAsm.S **** 		nop		; Remember...if we ever remove the "cbi" instruction above,
1636
 390               					; we need to add two more NOPs to cover this
1637
 391               	    
1638
 392               	; Ok...the following loop needs to run in 8 clock cycles, so we can get every
1639
 393               	; pixel in the line...this shouldn't be a problem, since the PCLK timing was
1640
 394               	; reduced by a factor of 2 whenever we go to dump a line (this is to give us
1641
 395               	; enough time to do the sampling and storing of the pixel data).  In addition,
1642
 396               	; it is assumed that we will have to do some minor processing on the data right
1643
 397               	; before we send it out, like mask off the top 4-bits of each, and then pack both
1644
 398               	; low nibbles into a single byte for transmission...we just don't have time to
1645
 399               	; do that here (only 8 instruction cycles :-)  )
1646
 400               	_sampleDumpPixel:
1647
 401:CamInterfaceAsm.S **** 		in		tmp1,G_PORT				; sample the G value					(1)
1648
 402:CamInterfaceAsm.S **** 		in		tmp2,RB_PORT			; sample the R/B value					(1)
1649
 403:CamInterfaceAsm.S **** 		st		X+,tmp1					; store to the currLineBuff and inc ptrs(2)
1650
 404:CamInterfaceAsm.S **** 		st		Y+,tmp2					; store to the prevLineBuff and inc ptrs(2)
1651
 405:CamInterfaceAsm.S **** 		brtc	_sampleDumpPixel		; loop back unless flag is set			(2...if not set)
1652
 406               											;									___________
1653
 407               											;									8 cycles normally
1654
 408               																				
1655
 409               			; if we make it here, it means the T flag is set, and we must have been interrupted
1656
 410               			; so we need to exit (what if we were interrupted for serial? should we disable it?)
1657
 411:CamInterfaceAsm.S **** 		rjmp	_cleanUpDumpLine
1658
 412               	
1659
 413               	;***********************************************************
1660
 414               	;	Function Name: <interrupt handler for External Interrupt0> 
1661
 415               	;	Function Description: This function is responsible
1662
 416               	;	for handling a rising edge on the Ext Interrupt 0.  This
1663
 417               	;	routine simply returns, since we just want to wake up
1664
 418               	;	whenever the VSYNC transitions (meaning the start of a new
1665
 419               	;	frame).
1666
 420               	;	Inputs:  none
1667
 421               	;	Outputs: none
1668
 422               	;***********************************************************
1669
 423               	SIG_INTERRUPT0:
1670
 424               	; This will wake us up when VSYNC transitions high...we just want to return
1671
 425:CamInterfaceAsm.S **** 		reti
1672
 426               			
1673
 427               	;***********************************************************
1674
 428               	;	Function Name: <interrupt handler for External Interrupt1> 
1675
 429               	;	Function Description: This function is responsible
1676
 430               	;	for handling a falling edge on the Ext Interrupt 1.  This
1677
 431               	;	routine simply returns, since we just want to wake up
1678
 432               	;	whenever the HREF transitions (meaning the pixels 
1679
 433               	;	are starting after VSYNC transitioned, and we need to
1680
 434               	; 	start acquiring the pixel blocks
174 kaklik 1681
GAS LISTING /tmp/cckBHomO.s 			page 29
1682
 
1683
 
151 kaklik 1684
 435               	;	Inputs:  none
1685
 436               	;	Outputs: none
1686
 437               	;***********************************************************	
1687
 438               	SIG_INTERRUPT1:
1688
 439               	; This will wake us up when HREF transitions high...we just want to return
1689
 440:CamInterfaceAsm.S **** 		reti
1690
 441               			
1691
 442               	;***********************************************************
1692
 443               	;	Function Name: <interrupt handler for Timer0 overflow>
1693
 444               	;	Function Description: This function is responsible
1694
 445               	;	for handling the Timer0 overflow (hooked up to indicate
1695
 446               	;	when we have reached the number of HREFs required in a
1696
 447               	;	single frame).  We set the T flag in the SREG to
1697
 448               	;	indicate to the _acquirePixelBlock routine that it needs
1698
 449               	;	to exit, and then set the appropriate action to take in
1699
 450               	;	the eventList of the Executive module.
1700
 451               	;	Inputs:  none
1701
 452               	;	Outputs: none
1702
 453               	;   Note: Originally, the HREF pulses were also going to
1703
 454               	;   be counted by a hardware counter, but it didn't end up
1704
 455               	;   being necessary
1705
 456               	;***********************************************************
1706
 457               	;SIG_OVERFLOW0:
1707
 458               	;		set				; set the T bit in SREG
1708
 459               	;		lds		tmp1,eventBitmask
1709
 460               	;		ori		tmp1,EV_ACQUIRE_FRAME_COMPLETE
1710
 461               	;		sts		eventBitmask,tmp1
1711
 462               	;		reti
1712
 463               			
1713
 464               	;***********************************************************
1714
 465               	;	Function Name: <interrupt handler for Timer1 overflow>
1715
 466               	;	Function Description: This function is responsible
1716
 467               	;	for handling the Timer1 overflow (hooked up to indicate
1717
 468               	;	when we have reached the end of a line of pixel data,
1718
 469               	;	since PCLK is hooked up to overflow TCNT1 after 176 
1719
 470               	;	pixels).  This routine generates an acquire line complete
1720
 471               	;	event in the fastEventBitmask, which is streamlined for
1721
 472               	;	efficiency reasons.
1722
 473               	;***********************************************************
1723
 474               	SIG_OVERFLOW1:				
1724
 475:CamInterfaceAsm.S **** 		lds		tmp1,fastEventBitmask   		; set a flag indicating
1725
 476:CamInterfaceAsm.S **** 		ori		tmp1,FEV_ACQUIRE_LINE_COMPLETE	; a line is complete
1726
 477:CamInterfaceAsm.S **** 		sts		fastEventBitmask,tmp1
1727
 478:CamInterfaceAsm.S **** 		set		; set the T bit in SREG 
1728
 479               			;sbi		_SFR_IO_ADDR(PORTD),PD6 ; For testing...
1729
 480               			;cbi		_SFR_IO_ADDR(PORTD),PD6 ; For testing...
1730
 481               	
1731
 482:CamInterfaceAsm.S **** 		reti
1732
 483               	
1733
 484               	; This is the default handler for all interrupts that don't
1734
 485               	; have handler routines specified for them.
1735
 486               	        .global __vector_default              
1736
 487               	__vector_default:
1737
 488:CamInterfaceAsm.S ****         reti
1738
 489               	
1739
 490               	        .end
174 kaklik 1740
GAS LISTING /tmp/cckBHomO.s 			page 30
1741
 
1742
 
1743
DEFINED SYMBOLS
1744
                            *ABS*:00000000 CamInterfaceAsm.S
1745
   CamInterfaceAsm.S:119    *ABS*:00000010 pixelCount
1746
   CamInterfaceAsm.S:120    *ABS*:00000011 pixelRunStart
1747
   CamInterfaceAsm.S:121    *ABS*:00000012 lastColor
1748
   CamInterfaceAsm.S:122    *ABS*:00000013 tmp1
1749
   CamInterfaceAsm.S:123    *ABS*:00000014 tmp2
1750
   CamInterfaceAsm.S:124    *ABS*:00000013 color
1751
   CamInterfaceAsm.S:125    *ABS*:00000014 greenData
1752
   CamInterfaceAsm.S:126    *ABS*:00000015 blueData
1753
   CamInterfaceAsm.S:127    *ABS*:00000016 colorMapLow
1754
   CamInterfaceAsm.S:128    *ABS*:00000017 colorMapHigh
1755
   CamInterfaceAsm.S:129    *ABS*:00000016 prevLineBuffLow
1756
   CamInterfaceAsm.S:130    *ABS*:00000017 prevLineBuffHigh
1757
   CamInterfaceAsm.S:131    *ABS*:00000018 currLineBuffLow
1758
   CamInterfaceAsm.S:132    *ABS*:00000019 currLineBuffHigh
1759
   CamInterfaceAsm.S:169    .text:00000000 CamIntAsm_waitForNewTrackingFrame
1760
   CamInterfaceAsm.S:335    .text:0000008e CamIntAsm_waitForNewDumpFrame
1761
   CamInterfaceAsm.S:345    .text:00000094 CamIntAsm_acquireDumpLine
1762
   CamInterfaceAsm.S:179    .text:00000006 CamIntAsm_acquireTrackingLine
1763
   CamInterfaceAsm.S:423    .text:000000d4 __vector_1
1764
   CamInterfaceAsm.S:438    .text:000000d6 __vector_2
1765
   CamInterfaceAsm.S:474    .text:000000d8 __vector_8
1766
   CamInterfaceAsm.S:305    .text:00000080 _cleanUp
1767
   CamInterfaceAsm.S:223    .text:00000034 _trackFrame
1768
   CamInterfaceAsm.S:240    .text:00000044 _acquirePixelBlock
1769
   CamInterfaceAsm.S:281    .text:00000074 _cleanUpTrackingLine
1770
   CamInterfaceAsm.S:292    .text:00000080 _cleanUpDumpLine
1771
   CamInterfaceAsm.S:316    .text:0000008c _exit
1772
   CamInterfaceAsm.S:380    .text:000000ba _dumpFrame
1773
   CamInterfaceAsm.S:400    .text:000000c8 _sampleDumpPixel
1774
   CamInterfaceAsm.S:487    .text:000000e6 __vector_default
1775
 
1776
UNDEFINED SYMBOLS
1777
__vector_9
1778
fastEventBitmask