Rev 151 | Blame | Last modification | View Log | Download
GAS LISTING /tmp/cckBHomO.s page 11 # 1 "CamInterfaceAsm.S"2 # 1 "<built-in>"1 ;002 ; Copyright (C) 2004 John Orlando3 ;4 ; AVRcam: a small real-time image processing engine.56 ; This program is free software; you can redistribute it and/or7 ; modify it under the terms of the GNU General Public8 ; License as published by the Free Software Foundation; either9 ; version 2 of the License, or (at your option) any later version.1011 ; This program is distributed in the hope that it will be useful,12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU14 ; General Public License for more details.1516 ; You should have received a copy of the GNU General Public17 ; License along with this program; if not, write to the Free Software18 ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA1920 ; For more information on the AVRcam, please contact:2122 ; john@jrobot.net2324 ; or go to www.jrobot.net for more details regarding the system.25 ;**********************************************************************26 ; Module Name: CanInterfaceAsm.S27 ; Module Date: 04/14/200428 ; Module Auth: John Orlando29 ;30 ; Description: This module provides the low-level interface31 ; to the OV6620 camera hardware. It is responsible for32 ; acquiring each pixel block (R,G,B), performing the mapping33 ; into an actual color (orange, purple, etc), run-length34 ; encoding the data, and storing the info off to the appropriate35 ; line buffer. This routine is synchronized with the pixel data36 ; so that no polling of the camera data needs to be done (the37 ; OV6620 is clocked off of the same crystal source as the mega8,38 ; thus providing inherent synchronization between the two).39 ;40 ; Revision History:41 ; Date Rel Ver. Notes42 ; 4/10/2004 0.1 Module created43 ; 6/30/2004 1.0 Initial release for Circuit Cellar44 ; contest.45 ; 1/16/2005 1.4 Fixed issue with the TCCR1B register46 ; where PCLK was getting routed to the47 ; timer1 even when it wasn't needed.48 ; This caused excessive counter overflow49 ; interrupts, and caused problems. Now,50 ; the "PCLK" pipe feeds timer1 when needed,51 ; and is turned off when it isn't needed.5253 #include <avr/io.h>GAS LISTING /tmp/cckBHomO.s page 21 /* Copyright (c) 2002,2003,2005,2006, Marek Michalkiewicz, Joerg Wunsch2 All rights reserved.34 Redistribution and use in source and binary forms, with or without5 modification, are permitted provided that the following conditions are met:67 * Redistributions of source code must retain the above copyright8 notice, this list of conditions and the following disclaimer.910 * Redistributions in binary form must reproduce the above copyright11 notice, this list of conditions and the following disclaimer in12 the documentation and/or other materials provided with the13 distribution.1415 * Neither the name of the copyright holders nor the names of16 contributors may be used to endorse or promote products derived17 from this software without specific prior written permission.1819 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR24 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF25 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS26 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN27 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE29 POSSIBILITY OF SUCH DAMAGE. */3031 /* $Id: io.h,v 1.24.2.7 2006/04/19 16:53:25 aesok Exp $ */3233 /** \defgroup avr_io <avr/io.h>: AVR device-specific IO definitions34 \code #include <avr/io.h> \endcode3536 This header file includes the apropriate IO definitions for the37 device that has been specified by the <tt>-mmcu=</tt> compiler38 command-line switch. This is done by diverting to the appropriate39 file <tt><avr/io</tt><em>XXXX</em><tt>.h></tt> which should40 never be included directly. Some register names common to all41 AVR devices are defined directly within <tt><avr/io.h></tt>,42 but most of the details come from the respective include file.4344 Note that this file always includes45 \code #include <avr/sfr_defs.h> \endcode46 See \ref avr_sfr for the details.4748 Included are definitions of the IO register set and their49 respective bit values as specified in the Atmel documentation.50 Note that Atmel is not very consistent in its naming conventions,51 so even identical functions sometimes get different names on52 different devices.5354 Also included are the specific names useable for interrupt55 function definitions as documented56 \ref avr_signames "here".57GAS LISTING /tmp/cckBHomO.s page 358 Finally, the following macros are defined:5960 - \b RAMEND61 <br>62 A constant describing the last on-chip RAM location.63 <br>64 - \b XRAMEND65 <br>66 A constant describing the last possible location in RAM.67 This is equal to RAMEND for devices that do not allow for68 external RAM.69 <br>70 - \b E2END71 <br>72 A constant describing the address of the last EEPROM cell.73 <br>74 - \b FLASHEND75 <br>76 A constant describing the last byte address in flash ROM.77 <br>78 - \b SPM_PAGESIZE79 <br>80 For devices with bootloader support, the flash pagesize81 (in bytes) to be used for the \c SPM instruction. */8283 #ifndef _AVR_IO_H_84 #define _AVR_IO_H_8586 #include <avr/sfr_defs.h>1 /* Copyright (c) 2002, Marek Michalkiewicz <marekm@amelek.gda.pl>2 All rights reserved.34 Redistribution and use in source and binary forms, with or without5 modification, are permitted provided that the following conditions are met:67 * Redistributions of source code must retain the above copyright8 notice, this list of conditions and the following disclaimer.910 * Redistributions in binary form must reproduce the above copyright11 notice, this list of conditions and the following disclaimer in12 the documentation and/or other materials provided with the13 distribution.1415 * Neither the name of the copyright holders nor the names of16 contributors may be used to endorse or promote products derived17 from this software without specific prior written permission.1819 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR24 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF25 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS26 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN27 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEGAS LISTING /tmp/cckBHomO.s page 429 POSSIBILITY OF SUCH DAMAGE. */3031 /* avr/sfr_defs.h - macros for accessing AVR special function registers */3233 /* $Id: sfr_defs.h,v 1.16 2005/09/10 21:31:13 joerg_wunsch Exp $ */3435 #ifndef _AVR_SFR_DEFS_H_36 #define _AVR_SFR_DEFS_H_ 13738 /** \defgroup avr_sfr_notes Additional notes from <avr/sfr_defs.h>39 \ingroup avr_sfr4041 The \c <avr/sfr_defs.h> file is included by all of the \c <avr/ioXXXX.h>42 files, which use macros defined here to make the special function register43 definitions look like C variables or simple constants, depending on the44 <tt>_SFR_ASM_COMPAT</tt> define. Some examples from \c <avr/iom128.h> to45 show how to define such macros:4647 \code48 #define PORTA _SFR_IO8(0x1b)49 #define TCNT1 _SFR_IO16(0x2c)50 #define PORTF _SFR_MEM8(0x61)51 #define TCNT3 _SFR_MEM16(0x88)52 \endcode5354 If \c _SFR_ASM_COMPAT is not defined, C programs can use names like55 <tt>PORTA</tt> directly in C expressions (also on the left side of56 assignment operators) and GCC will do the right thing (use short I/O57 instructions if possible). The \c __SFR_OFFSET definition is not used in58 any way in this case.5960 Define \c _SFR_ASM_COMPAT as 1 to make these names work as simple constants61 (addresses of the I/O registers). This is necessary when included in62 preprocessed assembler (*.S) source files, so it is done automatically if63 \c __ASSEMBLER__ is defined. By default, all addresses are defined as if64 they were memory addresses (used in \c lds/sts instructions). To use these65 addresses in \c in/out instructions, you must subtract 0x20 from them.6667 For more backwards compatibility, insert the following at the start of your68 old assembler source file:6970 \code71 #define __SFR_OFFSET 072 \endcode7374 This automatically subtracts 0x20 from I/O space addresses, but it's a75 hack, so it is recommended to change your source: wrap such addresses in76 macros defined here, as shown below. After this is done, the77 <tt>__SFR_OFFSET</tt> definition is no longer necessary and can be removed.7879 Real example - this code could be used in a boot loader that is portable80 between devices with \c SPMCR at different addresses.8182 \verbatim83 <avr/iom163.h>: #define SPMCR _SFR_IO8(0x37)84 <avr/iom128.h>: #define SPMCR _SFR_MEM8(0x68)85 \endverbatimGAS LISTING /tmp/cckBHomO.s page 58687 \code8788 #ifndef __AVR_HAVE_MOVW__89 # if defined(__AVR_ENHANCED__) && __AVR_ENHANCED__90 # define __AVR_HAVE_MOVW__ 191 # endif92 #endif9394 #ifndef __AVR_HAVE_LPMX__95 # if defined(__AVR_ENHANCED__) && __AVR_ENHANCED__96 # define __AVR_HAVE_LPMX__ 197 # endif98 #endif99100 /*101 * Registers common to all AVR devices.102 */103104 #if __AVR_ARCH__ != 1105 /*106 * AVR architecture 1 has no RAM, thus no stack pointer.107 *108 * All other archs do have a stack pointer. Some devices have only109 * less than 256 bytes of possible RAM locations (128 Bytes of SRAM110 * and no option for external RAM), thus SPH is officially "reserved"111 * for them. We catch this case below after including the112 * device-specific ioXXXX.h file, by examining XRAMEND, and113 * #undef-ining SP and SPH in that case.114 */115 /* Stack Pointer */116 #define SP _SFR_IO16(0x3D)117 #define SPL _SFR_IO8(0x3D)118 #define SPH _SFR_IO8(0x3E)119 #endif /* #if __AVR_ARCH__ != 1 */120121 /* Status REGister */122 #define SREG _SFR_IO8(0x3F)123124 /* Status Register - SREG */125 #define SREG_I 7126 #define SREG_T 6127 #define SREG_H 5128 #define SREG_S 4129 #define SREG_V 3130 #define SREG_N 2131 #define SREG_Z 1132 #define SREG_C 0133134 /* Pointer definition */135 #if __AVR_ARCH__ != 1136 /* avr1 has only the Z pointer */137 #define XL r26138 #define XH r27139 #define YL r28140 #define YH r29141 #endif /* #if __AVR_ARCH__ != 1 */GAS LISTING /tmp/cckBHomO.s page 6142 #define ZL r30143 #define ZH r31144145 /*146 * Only few devices come without EEPROM. In order to assemble the147 * EEPROM library components without defining a specific device, we148 * keep the EEPROM-related definitions here.149 */150 #if defined(__COMPILING_AVR_LIBC__)151152 /* EEPROM Control Register */153 #define EECR _SFR_IO8(0x1C)154155 /* EEPROM Data Register */156 #define EEDR _SFR_IO8(0x1D)157158 /* EEPROM Address Register */159 #define EEAR _SFR_IO16(0x1E)160 #define EEARL _SFR_IO8(0x1E)161 #define EEARH _SFR_IO8(0x1F)162163 /* EEPROM Control Register */164 #define EERIE 3165 #define EEMWE 2166 #define EEWE 1167 #define EERE 0168169 #endif /* __COMPILING_AVR_LIBC__ */170171 #if defined (__AVR_AT94K__)172 # include <avr/ioat94k.h>173 #elif defined (__AVR_AT43USB320__)174 # include <avr/io43u32x.h>175 #elif defined (__AVR_AT43USB355__)176 # include <avr/io43u35x.h>177 #elif defined (__AVR_AT76C711__)178 # include <avr/io76c711.h>179 #elif defined (__AVR_AT86RF401__)180 # include <avr/io86r401.h>181 #elif defined (__AVR_AT90PWM2__)182 # include <avr/io90pwmx.h>183 #elif defined (__AVR_AT90PWM3__)184 # include <avr/io90pwmx.h>185 #elif defined (__AVR_ATmega128__)186 # include <avr/iom128.h>187 #elif defined (__AVR_ATmega1280__)188 # include <avr/iom1280.h>189 #elif defined (__AVR_ATmega1281__)190 # include <avr/iom1281.h>191 #elif defined (__AVR_AT90CAN32__)192 # include <avr/iocan32.h>193 #elif defined (__AVR_AT90CAN64__)194 # include <avr/iocan64.h>195 #elif defined (__AVR_AT90CAN128__)196 # include <avr/iocan128.h>197 #elif defined (__AVR_AT90USB646__)198 # include <avr/iousb646.h>GAS LISTING /tmp/cckBHomO.s page 7199 #elif defined (__AVR_AT90USB647__)200 # include <avr/iousb647.h>201 #elif defined (__AVR_AT90USB1286__)202 # include <avr/iousb1286.h>203 #elif defined (__AVR_AT90USB1287__)204 # include <avr/iousb1287.h>205 #elif defined (__AVR_ATmega64__)206 # include <avr/iom64.h>207 #elif defined (__AVR_ATmega640__)208 # include <avr/iom640.h>209 #elif defined (__AVR_ATmega644__)210 # include <avr/iom644.h>211 #elif defined (__AVR_ATmega644P__)212 # include <avr/iom644.h>213 #elif defined (__AVR_ATmega645__)214 # include <avr/iom645.h>215 #elif defined (__AVR_ATmega6450__)216 # include <avr/iom6450.h>217 #elif defined (__AVR_ATmega649__)218 # include <avr/iom649.h>219 #elif defined (__AVR_ATmega6490__)220 # include <avr/iom6490.h>221 #elif defined (__AVR_ATmega103__)222 # include <avr/iom103.h>223 #elif defined (__AVR_ATmega32__)224 # include <avr/iom32.h>225 #elif defined (__AVR_ATmega323__)226 # include <avr/iom323.h>227 #elif defined (__AVR_ATmega324P__)228 # include <avr/iom324.h>229 #elif defined (__AVR_ATmega325__)230 # include <avr/iom325.h>231 #elif defined (__AVR_ATmega3250__)232 # include <avr/iom3250.h>233 #elif defined (__AVR_ATmega329__)234 # include <avr/iom329.h>235 #elif defined (__AVR_ATmega3290__)236 # include <avr/iom3290.h>237 #elif defined (__AVR_ATmega406__)238 # include <avr/iom406.h>239 #elif defined (__AVR_ATmega16__)240 # include <avr/iom16.h>241 #elif defined (__AVR_ATmega161__)242 # include <avr/iom161.h>243 #elif defined (__AVR_ATmega162__)244 # include <avr/iom162.h>245 #elif defined (__AVR_ATmega163__)246 # include <avr/iom163.h>247 #elif defined (__AVR_ATmega164P__)248 # include <avr/iom164.h>249 #elif defined (__AVR_ATmega165__)250 # include <avr/iom165.h>251 #elif defined (__AVR_ATmega168__)252 # include <avr/iom168.h>253 #elif defined (__AVR_ATmega169__)254 # include <avr/iom169.h>255 #elif defined (__AVR_ATmega8__)GAS LISTING /tmp/cckBHomO.s page 8256 # include <avr/iom8.h>1 /* Copyright (c) 2002, Marek Michalkiewicz2 All rights reserved.34 Redistribution and use in source and binary forms, with or without5 modification, are permitted provided that the following conditions are met:67 * Redistributions of source code must retain the above copyright8 notice, this list of conditions and the following disclaimer.910 * Redistributions in binary form must reproduce the above copyright11 notice, this list of conditions and the following disclaimer in12 the documentation and/or other materials provided with the13 distribution.1415 * Neither the name of the copyright holders nor the names of16 contributors may be used to endorse or promote products derived17 from this software without specific prior written permission.1819 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR24 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF25 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS26 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN27 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE29 POSSIBILITY OF SUCH DAMAGE. */3031 /* $Id: iom8.h,v 1.13 2005/10/30 22:11:23 joerg_wunsch Exp $ */3233 /* avr/iom8.h - definitions for ATmega8 */3435 #ifndef _AVR_IOM8_H_36 #define _AVR_IOM8_H_ 13738 /* This file should only be included from <avr/io.h>, never directly. */3940 #ifndef _AVR_IO_H_41 # error "Include <avr/io.h> instead of this file."42 #endif4344 #ifndef _AVR_IOXXX_H_45 # define _AVR_IOXXX_H_ "iom8.h"46 #else47 # error "Attempt to include more than one <avr/ioXXX.h> file."48 #endif4950 /* I/O registers */5152 /* TWI stands for "Two Wire Interface" or "TWI Was I2C(tm)" */53 #define TWBR _SFR_IO8(0x00)54 #define TWSR _SFR_IO8(0x01)55 #define TWAR _SFR_IO8(0x02)56 #define TWDR _SFR_IO8(0x03)GAS LISTING /tmp/cckBHomO.s page 95758 /* ADC */59 #define ADCW _SFR_IO16(0x04)60 #ifndef __ASSEMBLER__61 #define ADC _SFR_IO16(0x04)62 #endif63 #define ADCL _SFR_IO8(0x04)64 #define ADCH _SFR_IO8(0x05)65 #define ADCSR _SFR_IO8(0x06)66 #define ADCSRA _SFR_IO8(0x06) /* Changed in 2486H-AVR-09/02 */67 #define ADMUX _SFR_IO8(0x07)6869 /* analog comparator */70 #define ACSR _SFR_IO8(0x08)7172 /* USART */73 #define UBRRL _SFR_IO8(0x09)74 #define UCSRB _SFR_IO8(0x0A)75 #define UCSRA _SFR_IO8(0x0B)76 #define UDR _SFR_IO8(0x0C)7778 /* SPI */79 #define SPCR _SFR_IO8(0x0D)80 #define SPSR _SFR_IO8(0x0E)81 #define SPDR _SFR_IO8(0x0F)8283 /* Port D */84 #define PIND _SFR_IO8(0x10)85 #define DDRD _SFR_IO8(0x11)86 #define PORTD _SFR_IO8(0x12)8788 /* Port C */89 #define PINC _SFR_IO8(0x13)90 #define DDRC _SFR_IO8(0x14)91 #define PORTC _SFR_IO8(0x15)9293 /* Port B */94 #define PINB _SFR_IO8(0x16)95 #define DDRB _SFR_IO8(0x17)96 #define PORTB _SFR_IO8(0x18)9798 /* EEPROM Control Register */99 #define EECR _SFR_IO8(0x1C)100101 /* EEPROM Data Register */102 #define EEDR _SFR_IO8(0x1D)103104 /* EEPROM Address Register */105 #define EEAR _SFR_IO16(0x1E)106 #define EEARL _SFR_IO8(0x1E)107 #define EEARH _SFR_IO8(0x1F)108109 #define UCSRC _SFR_IO8(0x20)110 #define UBRRH _SFR_IO8(0x20)111112 #define WDTCR _SFR_IO8(0x21)113 #define ASSR _SFR_IO8(0x22)GAS LISTING /tmp/cckBHomO.s page 10114115 /* Timer 2 */116 #define OCR2 _SFR_IO8(0x23)117 #define TCNT2 _SFR_IO8(0x24)118 #define TCCR2 _SFR_IO8(0x25)119120 /* Timer 1 */121 #define ICR1 _SFR_IO16(0x26)122 #define ICR1L _SFR_IO8(0x26)123 #define ICR1H _SFR_IO8(0x27)124 #define OCR1B _SFR_IO16(0x28)125 #define OCR1BL _SFR_IO8(0x28)126 #define OCR1BH _SFR_IO8(0x29)127 #define OCR1A _SFR_IO16(0x2A)128 #define OCR1AL _SFR_IO8(0x2A)129 #define OCR1AH _SFR_IO8(0x2B)130 #define TCNT1 _SFR_IO16(0x2C)131 #define TCNT1L _SFR_IO8(0x2C)132 #define TCNT1H _SFR_IO8(0x2D)133 #define TCCR1B _SFR_IO8(0x2E)134 #define TCCR1A _SFR_IO8(0x2F)135136 #define SFIOR _SFR_IO8(0x30)137138 #define OSCCAL _SFR_IO8(0x31)139140 /* Timer 0 */141 #define TCNT0 _SFR_IO8(0x32)142 #define TCCR0 _SFR_IO8(0x33)143144 #define MCUCSR _SFR_IO8(0x34)145 #define MCUCR _SFR_IO8(0x35)146147 #define TWCR _SFR_IO8(0x36)148149 #define SPMCR _SFR_IO8(0x37)150151 #define TIFR _SFR_IO8(0x38)152 #define TIMSK _SFR_IO8(0x39)153154 #define GIFR _SFR_IO8(0x3A)155 #define GIMSK _SFR_IO8(0x3B)156 #define GICR _SFR_IO8(0x3B) /* Changed in 2486H-AVR-09/02 */157158 /* 0x3C reserved (OCR0?) */159160 /* 0x3D..0x3E SP */161162 /* 0x3F SREG */163164 /* Interrupt vectors */165166 /* External Interrupt Request 0 */167 #define INT0_vect _VECTOR(1)168 #define SIG_INTERRUPT0 _VECTOR(1)169170 /* External Interrupt Request 1 */GAS LISTING /tmp/cckBHomO.s page 11171 #define INT1_vect _VECTOR(2)172 #define SIG_INTERRUPT1 _VECTOR(2)173174 /* Timer/Counter2 Compare Match */175 #define TIMER2_COMP_vect _VECTOR(3)176 #define SIG_OUTPUT_COMPARE2 _VECTOR(3)177178 /* Timer/Counter2 Overflow */179 #define TIMER2_OVF_vect _VECTOR(4)180 #define SIG_OVERFLOW2 _VECTOR(4)181182 /* Timer/Counter1 Capture Event */183 #define TIMER1_CAPT_vect _VECTOR(5)184 #define SIG_INPUT_CAPTURE1 _VECTOR(5)185186 /* Timer/Counter1 Compare Match A */187 #define TIMER1_COMPA_vect _VECTOR(6)188 #define SIG_OUTPUT_COMPARE1A _VECTOR(6)189190 /* Timer/Counter1 Compare Match B */191 #define TIMER1_COMPB_vect _VECTOR(7)192 #define SIG_OUTPUT_COMPARE1B _VECTOR(7)193194 /* Timer/Counter1 Overflow */195 #define TIMER1_OVF_vect _VECTOR(8)196 #define SIG_OVERFLOW1 _VECTOR(8)197198 /* Timer/Counter0 Overflow */199 #define TIMER0_OVF_vect _VECTOR(9)200 #define SIG_OVERFLOW0 _VECTOR(9)201202 /* Serial Transfer Complete */203 #define SPI_STC_vect _VECTOR(10)204 #define SIG_SPI _VECTOR(10)205206 /* USART, Rx Complete */207 #define USART_RXC_vect _VECTOR(11)208 #define SIG_UART_RECV _VECTOR(11)209210 /* USART Data Register Empty */211 #define USART_UDRE_vect _VECTOR(12)212 #define SIG_UART_DATA _VECTOR(12)213214 /* USART, Tx Complete */215 #define USART_TXC_vect _VECTOR(13)216 #define SIG_UART_TRANS _VECTOR(13)217218 /* ADC Conversion Complete */219 #define ADC_vect _VECTOR(14)220 #define SIG_ADC _VECTOR(14)221222 /* EEPROM Ready */223 #define EE_RDY_vect _VECTOR(15)224 #define SIG_EEPROM_READY _VECTOR(15)225226 /* Analog Comparator */227 #define ANA_COMP_vect _VECTOR(16)GAS LISTING /tmp/cckBHomO.s page 12228 #define SIG_COMPARATOR _VECTOR(16)229230 /* 2-wire Serial Interface */231 #define TWI_vect _VECTOR(17)232 #define SIG_2WIRE_SERIAL _VECTOR(17)233234 /* Store Program Memory Ready */235 #define SPM_RDY_vect _VECTOR(18)236 #define SIG_SPM_READY _VECTOR(18)237238 #define _VECTORS_SIZE 38239240 /* Bit numbers */241242 /* GIMSK / GICR */243 #define INT1 7244 #define INT0 6245 #define IVSEL 1246 #define IVCE 0247248 /* GIFR */249 #define INTF1 7250 #define INTF0 6251252 /* TIMSK */253 #define OCIE2 7254 #define TOIE2 6255 #define TICIE1 5256 #define OCIE1A 4257 #define OCIE1B 3257 #elif defined (__AVR_ATmega48__)258 # include <avr/iom48.h>259 #elif defined (__AVR_ATmega88__)260 # include <avr/iom88.h>261 #elif defined (__AVR_ATmega8515__)262 # include <avr/iom8515.h>263 #elif defined (__AVR_ATmega8535__)264 # include <avr/iom8535.h>265 #elif defined (__AVR_AT90S8535__)266 # include <avr/io8535.h>267 #elif defined (__AVR_AT90C8534__)268 # include <avr/io8534.h>269 #elif defined (__AVR_AT90S8515__)270 # include <avr/io8515.h>271 #elif defined (__AVR_AT90S4434__)272 # include <avr/io4434.h>273 #elif defined (__AVR_AT90S4433__)274 # include <avr/io4433.h>275 #elif defined (__AVR_AT90S4414__)276 # include <avr/io4414.h>277 #elif defined (__AVR_ATtiny22__)278 # include <avr/iotn22.h>279 #elif defined (__AVR_ATtiny26__)280 # include <avr/iotn26.h>281 #elif defined (__AVR_AT90S2343__)282 # include <avr/io2343.h>283 #elif defined (__AVR_AT90S2333__)GAS LISTING /tmp/cckBHomO.s page 13284 # include <avr/io2333.h>285 #elif defined (__AVR_AT90S2323__)286 # include <avr/io2323.h>287 #elif defined (__AVR_AT90S2313__)288 # include <avr/io2313.h>289 #elif defined (__AVR_ATtiny2313__)290 # include <avr/iotn2313.h>291 #elif defined (__AVR_ATtiny13__)292 # include <avr/iotn13.h>293 #elif defined (__AVR_ATtiny25__)294 # include <avr/iotn25.h>295 #elif defined (__AVR_ATtiny45__)296 # include <avr/iotn45.h>297 #elif defined (__AVR_ATtiny85__)298 # include <avr/iotn85.h>299 #elif defined (__AVR_ATtiny24__)300 # include <avr/iotn24.h>301 #elif defined (__AVR_ATtiny44__)302 # include <avr/iotn44.h>303 #elif defined (__AVR_ATtiny84__)304 # include <avr/iotn84.h>305 #elif defined (__AVR_ATtiny261__)306 # include <avr/iotn261.h>307 #elif defined (__AVR_ATtiny461__)308 # include <avr/iotn461.h>309 #elif defined (__AVR_ATtiny861__)310 # include <avr/iotn861.h>311 /* avr1: the following only supported for assembler programs */312 #elif defined (__AVR_ATtiny28__)313 # include <avr/iotn28.h>314 #elif defined (__AVR_AT90S1200__)315 # include <avr/io1200.h>316 #elif defined (__AVR_ATtiny15__)317 # include <avr/iotn15.h>318 #elif defined (__AVR_ATtiny12__)319 # include <avr/iotn12.h>320 #elif defined (__AVR_ATtiny11__)321 # include <avr/iotn11.h>322 #else323 # if !defined(__COMPILING_AVR_LIBC__)324 # warning "device type not defined"325 # endif326 #endif327328 #include <avr/portpins.h>1 /* Copyright (c) 2003 Theodore A. Roth2 All rights reserved.34 Redistribution and use in source and binary forms, with or without5 modification, are permitted provided that the following conditions are met:67 * Redistributions of source code must retain the above copyright8 notice, this list of conditions and the following disclaimer.910 * Redistributions in binary form must reproduce the above copyright11 notice, this list of conditions and the following disclaimer in12 the documentation and/or other materials provided with theGAS LISTING /tmp/cckBHomO.s page 1413 distribution.1415 * Neither the name of the copyright holders nor the names of16 contributors may be used to endorse or promote products derived17 from this software without specific prior written permission.1819 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR24 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF25 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS26 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN27 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE29 POSSIBILITY OF SUCH DAMAGE. */3031 /* $Id: portpins.h,v 1.3.4.1 2006/03/10 16:22:38 aesok Exp $ */3233 #ifndef _AVR_PORTPINS_H_34 #define _AVR_PORTPINS_H_ 13536 /* This file should only be included from <avr/io.h>, never directly. */3738 #ifndef _AVR_IO_H_39 # error "Include <avr/io.h> instead of this file."40 #endif4142 /* Define Generic PORTn, DDn, and PINn values. */4344 /* Port Data Register (generic) */45 #define PORT7 746 #define PORT6 647 #define PORT5 548 #define PORT4 449 #define PORT3 350 #define PORT2 251 #define PORT1 152 #define PORT0 05354 /* Port Data Direction Register (generic) */55 #define DD7 756 #define DD6 657 #define DD5 558 #define DD4 459 #define DD3 360 #define DD2 261 #define DD1 162 #define DD0 06364 /* Port Input Pins (generic) */65 #define PIN7 766 #define PIN6 667 #define PIN5 568 #define PIN4 469 #define PIN3 3GAS LISTING /tmp/cckBHomO.s page 1570 #define PIN2 271 #define PIN1 172 #define PIN0 07374 /* Define PORTxn values for all possible port pins. */7576 /* PORT A */7778 #if defined(PA0)79 # define PORTA0 PA080 #endif81 #if defined(PA1)82 # define PORTA1 PA183 #endif84 #if defined(PA2)85 # define PORTA2 PA286 #endif87 #if defined(PA3)88 # define PORTA3 PA389 #endif90 #if defined(PA4)91 # define PORTA4 PA492 #endif93 #if defined(PA5)94 # define PORTA5 PA595 #endif96 #if defined(PA6)97 # define PORTA6 PA698 #endif99 #if defined(PA7)100 # define PORTA7 PA7101 #endif102103 /* PORT B */104105 #if defined(PB0)106 # define PORTB0 PB0107 #endif108 #if defined(PB1)109 # define PORTB1 PB1110 #endif111 #if defined(PB2)112 # define PORTB2 PB2113 #endif114 #if defined(PB3)115 # define PORTB3 PB3116 #endif117 #if defined(PB4)118 # define PORTB4 PB4119 #endif120 #if defined(PB5)121 # define PORTB5 PB5122 #endif123 #if defined(PB6)124 # define PORTB6 PB6125 #endif126 #if defined(PB7)GAS LISTING /tmp/cckBHomO.s page 16127 # define PORTB7 PB7128 #endif129130 /* PORT C */131132 #if defined(PC0)133 # define PORTC0 PC0134 #endif135 #if defined(PC1)136 # define PORTC1 PC1137 #endif138 #if defined(PC2)139 # define PORTC2 PC2140 #endif141 #if defined(PC3)142 # define PORTC3 PC3143 #endif144 #if defined(PC4)145 # define PORTC4 PC4146 #endif147 #if defined(PC5)148 # define PORTC5 PC5149 #endif150 #if defined(PC6)151 # define PORTC6 PC6152 #endif153 #if defined(PC7)154 # define PORTC7 PC7155 #endif156157 /* PORT D */158159 #if defined(PD0)160 # define PORTD0 PD0161 #endif162 #if defined(PD1)163 # define PORTD1 PD1164 #endif165 #if defined(PD2)166 # define PORTD2 PD2167 #endif168 #if defined(PD3)169 # define PORTD3 PD3170 #endif171 #if defined(PD4)172 # define PORTD4 PD4173 #endif174 #if defined(PD5)175 # define PORTD5 PD5176 #endif177 #if defined(PD6)178 # define PORTD6 PD6179 #endif180 #if defined(PD7)181 # define PORTD7 PD7182 #endif183GAS LISTING /tmp/cckBHomO.s page 17184 /* PORT E */185186 #if defined(PE0)187 # define PORTE0 PE0188 #endif189 #if defined(PE1)190 # define PORTE1 PE1191 #endif192 #if defined(PE2)193 # define PORTE2 PE2194 #endif195 #if defined(PE3)196 # define PORTE3 PE3197 #endif198 #if defined(PE4)199 # define PORTE4 PE4200 #endif201 #if defined(PE5)202 # define PORTE5 PE5203 #endif204 #if defined(PE6)205 # define PORTE6 PE6206 #endif207 #if defined(PE7)208 # define PORTE7 PE7209 #endif210211 /* PORT F */212213 #if defined(PF0)214 # define PORTF0 PF0215 #endif216 #if defined(PF1)217 # define PORTF1 PF1218 #endif219 #if defined(PF2)220 # define PORTF2 PF2221 #endif222 #if defined(PF3)223 # define PORTF3 PF3224 #endif225 #if defined(PF4)226 # define PORTF4 PF4227 #endif228 #if defined(PF5)229 # define PORTF5 PF5230 #endif231 #if defined(PF6)232 # define PORTF6 PF6233 #endif234 #if defined(PF7)235 # define PORTF7 PF7236 #endif237238 /* PORT G */239240 #if defined(PG0)GAS LISTING /tmp/cckBHomO.s page 18241 # define PORTG0 PG0242 #endif243 #if defined(PG1)244 # define PORTG1 PG1245 #endif246 #if defined(PG2)247 # define PORTG2 PG2248 #endif249 #if defined(PG3)250 # define PORTG3 PG3251 #endif252 #if defined(PG4)253 # define PORTG4 PG4254 #endif255 #if defined(PG5)256 # define PORTG5 PG5257 #endif258 #if defined(PG6)259 # define PORTG6 PG6260 #endif261 #if defined(PG7)262 # define PORTG7 PG7263 #endif264265 /* PORT H */266267 #if defined(PH0)268 # define PORTH0 PH0269 #endif270 #if defined(PH1)271 # define PORTH1 PH1272 #endif273 #if defined(PH2)274 # define PORTH2 PH2275 #endif276 #if defined(PH3)277 # define PORTH3 PH3278 #endif279 #if defined(PH4)280 # define PORTH4 PH4281 #endif282 #if defined(PH5)283 # define PORTH5 PH5284 #endif285 #if defined(PH6)286 # define PORTH6 PH6287 #endif288 #if defined(PH7)289 # define PORTH7 PH7290 #endif291292 /* PORT J */293294 #if defined(PJ0)295 # define PORTJ0 PJ0296 #endif297 #if defined(PJ1)GAS LISTING /tmp/cckBHomO.s page 19298 # define PORTJ1 PJ1299 #endif300 #if defined(PJ2)301 # define PORTJ2 PJ2302 #endif303 #if defined(PJ3)304 # define PORTJ3 PJ3305 #endif306 #if defined(PJ4)307 # define PORTJ4 PJ4308 #endif309 #if defined(PJ5)310 # define PORTJ5 PJ5311 #endif312 #if defined(PJ6)313 # define PORTJ6 PJ6314 #endif315 #if defined(PJ7)316 # define PORTJ7 PJ7317 #endif318319 /* PORT K */320321 #if defined(PK0)322 # define PORTK0 PK0323 #endif324 #if defined(PK1)325 # define PORTK1 PK1326 #endif327 #if defined(PK2)328 # define PORTK2 PK2329 #endif329330 #if __AVR_ARCH__ != 1331 # if XRAMEND < 0x100 && !defined(__COMPILING_AVR_LIBC__)332 # undef SP333 # define SP _SFR_IO8(0x3D)334 # undef SPH335 # endif336 #endif337338 #include <avr/version.h>1 /* Copyright (c) 2005, Joerg Wunsch -*- c -*-2 All rights reserved.34 Redistribution and use in source and binary forms, with or without5 modification, are permitted provided that the following conditions are met:67 * Redistributions of source code must retain the above copyright8 notice, this list of conditions and the following disclaimer.910 * Redistributions in binary form must reproduce the above copyright11 notice, this list of conditions and the following disclaimer in12 the documentation and/or other materials provided with the13 distribution.1415 * Neither the name of the copyright holders nor the names ofGAS LISTING /tmp/cckBHomO.s page 2016 contributors may be used to endorse or promote products derived17 from this software without specific prior written permission.1819 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR24 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF25 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS26 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN27 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE29 POSSIBILITY OF SUCH DAMAGE. */3031 /* $Id: version.h.in,v 1.1 2005/09/12 20:18:12 joerg_wunsch Exp $ */3233 /** \defgroup avr_version <avr/version.h>: avr-libc version macros34 \code #include <avr/version.h> \endcode3536 This header file defines macros that contain version numbers and37 strings describing the current version of avr-libc.3839 The version number itself basically consists of three pieces that40 are separated by a dot: the major number, the minor number, and41 the revision number. For development versions (which use an odd42 minor number), the string representation additionally gets the43 date code (YYYYMMDD) appended.4445 This file will also be included by \c <avr/io.h>. That way,46 portable tests can be implemented using \c <avr/io.h> that can be47 used in code that wants to remain backwards-compatible to library48 versions prior to the date when the library version API had been49 added, as referenced but undefined C preprocessor macros50 automatically evaluate to 0.51 */5253 #ifndef _AVR_VERSION_H_54 #define _AVR_VERSION_H_5556 /** \ingroup avr_version57 String literal representation of the current library version. */58 #define __AVR_LIBC_VERSION_STRING__ "1.4.4"5960 /** \ingroup avr_version61 Numerical representation of the current library version.6263 In the numerical representation, the major number is multiplied by64 10000, the minor number by 100, and all three parts are then65 added. It is intented to provide a monotonically increasing66 numerical value that can easily be used in numerical checks.67 */68 #define __AVR_LIBC_VERSION__ 10404UL6970 /** \ingroup avr_version71 String literal representation of the release date. */72 #define __AVR_LIBC_DATE_STRING__ "20060420"GAS LISTING /tmp/cckBHomO.s page 217374 /** \ingroup avr_version75 Numerical representation of the release date. */76 #define __AVR_LIBC_DATE_ 20060420UL7778 /** \ingroup avr_version79 Library major version number. */80 #define __AVR_LIBC_MAJOR__ 18182 /** \ingroup avr_version83 Library minor version number. */84 #define __AVR_LIBC_MINOR__ 48586 /** \ingroup avr_version87 Library revision number. */88 #define __AVR_LIBC_REVISION__ 48990 #endif /* _AVR_VERSION_H_ */91 ...33954 #include "Events.h"1 #ifndef EVENTS_H2 #define EVENTS_H34 /*5 Copyright (C) 2004 John Orlando67 AVRcam: a small real-time image processing engine.89 This program is free software; you can redistribute it and/or10 modify it under the terms of the GNU General Public11 License as published by the Free Software Foundation; either12 version 2 of the License, or (at your option) any later version.1314 This program is distributed in the hope that it will be useful,15 but WITHOUT ANY WARRANTY; without even the implied warranty of16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU17 General Public License for more details.1819 You should have received a copy of the GNU General Public20 License along with this program; if not, write to the Free Software21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2223 For more information on the AVRcam, please contact:2425 john@jrobot.net2627 or go to www.jrobot.net for more details regarding the system.28 */29 /***********************************************************30 Module Name: Events.h31 Module Date: 05/23/200432 Module Auth: John Orlando3334 Description: This file provides the external interface35 to the events that can be published/processed in the36 system. It is specifically by itself (and nothingGAS LISTING /tmp/cckBHomO.s page 2237 else should be defined in here) so that both .c and38 .S (assembly) files can include this file without39 a problem.4041 Revision History:42 Date Rel Ver. Notes43 4/10/2004 0.1 Module created44 6/30/2004 1.0 Initial release for Circuit Cellar45 contest.46 *******************************************************/4748 /* Definitions */49 /* Originally, all events were passed in a bitmask...however,50 an event FIFO was finally used, but the coding of the event51 definitions were never translated back....doesn't make a52 difference, but looks a little weird */53 #define EV_SERIAL_DATA_RECEIVED 0x0154 #define EV_DUMP_FRAME 0x0255 #define EV_PROCESS_FRAME_COMPLETE 0x045556 .extern fastEventBitmask ; This is the flag used to indicate to the rest57 ; of the system that the line is complete5859 #define HREF_INTERRUPT_ENABLE_MASK 0x8060 #define HREF_INTERRUPT_DISABLE_MASK 0x7F61 #define ENABLE_PCLK_TIMER1_OVERFLOW_BITMASK 0x0462 #define DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK 0xFB63 #define G_PORT _SFR_IO_ADDR(PINC)64 #define RB_PORT _SFR_IO_ADDR(PINB)65 #define PIXEL_RUN_START_INITIAL 0x50 ; This value causes our pixel counter (TCNT1)66 ; to overflow after 176 (horizontal) pixels6768 #define RED_MEM_OFFSET 0x0069 #define GREEN_MEM_OFFSET 0x1070 #define BLUE_MEM_OFFSET 0x207172 ; A pixelBlock is defined as a contiguous group of 4 pixels that are combined73 ; together to form a specific color. Typically, this is formed by sampling a74 ; a green value, followed by a red and blue value (since we are dealing75 ; with Bayer color data). We could optionally sample a second green with76 ; the red and average the greens, because the eye is more sensitive to77 ; green, but for speed we don't do this. These three values (RGB) are then78 ; used as indices into the color membership lookup table (memLookup) to79 ; determine which color the pixelBlock maps into. The memLookup table is80 ; manually generated for now (though it will hopefully be modified over81 ; the serial interface eventually).82 ;83 ; Here is a pixel block:84 ; ...G G G G... (row x)85 ; ...B R B R... (row x+1)86 ; | | | |--this is skipped87 ; | | |--this is skipped88 ; | |--this is sampled89 ; |--this is sampled9091 ; As pixel blocks are sampled, the red, green, and blue values are92 ; used to index into their respective color maps. The color mapsGAS LISTING /tmp/cckBHomO.s page 2393 ; return values that can be logically ANDed together so that a94 ; particular RGB triplet will result in a single bit being set95 ; after the AND operation. This single bit indicates which color96 ; the RGB triplet represents. It is also possible for no bits to97 ; be set after the AND process, indicating that the RGB triplet98 ; does not map to any of the colors configured in the color map.99 ; This isn't quite as fast as a pure RGB lookup table, but100 ; it then again it doesn't require 2^12 (4-bits for each color101 ; channel) bytes to store the lookup table. It takes just a few102 ; more cycles, and only requires 48 bytes of precious RAM (16103 ; per color channel, since our resolution on each color channel104 ; is only 4-bits). Not bad....for more information, see:105 ; http://www.cs.cmu.edu/~trb/papers/wirevision00.pdf for more106 ; information on this color segmentation technique.107108 ; One other note: this code does depend on the colorMap residing109 ; at a well-defined position in memory; specifically, it mus110 ; start at a 256-byte boundary so that the lowest byte in the111 ; map is set to 0x00. Currently, the colorMap is forced to112 ; start at RAM location 0x300. This could potentially be changed113 ; by the developer if needed, but offsets would have to be added114 ; in to the colorMap look-up code below to make it work.115116117 ; These are the registers that will be used throughout this118 ; module for acquiring each line of pixel data119 pixelCount = 16120 pixelRunStart = 17121 lastColor = 18122 tmp1 = 19 ; be sure to not use tmp1 and color simultaneously123 tmp2 = 20124 color = 19125 greenData = 20126 blueData = 21127 colorMapLow = 22128 colorMapHigh = 23129 prevLineBuffLow = 22 ; overlaps with memLookupLow (but orthogonal)130 prevLineBuffHigh = 23 ; overlaps with memLookupHigh (but orthogonal)131 currLineBuffLow = 24132 currLineBuffHigh = 25133134 .section .text135136 ; These are the global assembly function names that are accessed via other137 ; C functions138 .global CamIntAsm_waitForNewTrackingFrame139 .global CamIntAsm_waitForNewDumpFrame140 .global CamIntAsm_acquireDumpLine141 .global CamIntAsm_acquireTrackingLine142 .global SIG_INTERRUPT0143 .global SIG_INTERRUPT1144 .global SIG_OVERFLOW0145 .global SIG_OVERFLOW1146147 ;*****************************************************************148 ; Function Name: CamIntAsm_waitForNewTrackingFrame149 ; Function Description: This function is responsible forGAS LISTING /tmp/cckBHomO.s page 24150 ; going to sleep until a new frame begins (indicated by151 ; VSYNC transitioning from low to high. This will wake152 ; the "VSYNC sleep" up and allow it to continue with153 ; the acquireLine function, where the system waits for154 ; an "HREF sleep" that we use to synchronize with the155 ; data.156 ; Inputs: r25 - MSB of currentLineBuffer157 ; r24 - LSB of currentLineBuffer158 ; r23 - MSB of colorMap159 ; r22 - LSB of colorMap160 ; Outputs: none161 ; NOTES: This function doesn't really return...it sorta just162 ; floats into the acquireLine function after the "VSYNC sleep"163 ; is awoken, then begins processing the line data. Once164 ; 176 pixels are sampled (and the counter overflows), then165 ; an interrupt will occur, the 'T' bit in the SREG will be166 ; set, and the function will return.167 ;*****************************************************************168169 CamIntAsm_waitForNewTrackingFrame:170:CamInterfaceAsm.S **** sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...171:CamInterfaceAsm.S **** cbi _SFR_IO_ADDR(PORTD),PD6172:CamInterfaceAsm.S **** sleep173174 ;*****************************************************************175 ; REMEMBER...everything from here on out is critically timed to be176 ; synchronized with the flow of pixel data from the camera...177 ;*****************************************************************178179 CamIntAsm_acquireTrackingLine:180:CamInterfaceAsm.S **** brts _cleanUp181 ;sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...182 ;cbi _SFR_IO_ADDR(PORTD),PD6183184:CamInterfaceAsm.S **** in tmp1,_SFR_IO_ADDR(TCCR1B) ; Enable the PCLK line to actually185:CamInterfaceAsm.S **** ori tmp1, 0x07 ; feed Timer1186:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TCCR1B),tmp1187 ; The line is about to start...188:CamInterfaceAsm.S **** ldi pixelCount,0 ; Initialize the RLE stats...189:CamInterfaceAsm.S **** ldi pixelRunStart,PIXEL_RUN_START_INITIAL ; Remember, we always calculate190 ; the pixel run length as191 ; TCNT1L - pixelRunStart192193:CamInterfaceAsm.S **** ldi lastColor,0x00 ; clear out the last color before we start194195:CamInterfaceAsm.S **** mov XH,currLineBuffHigh ; Load the pointer to the current line196:CamInterfaceAsm.S **** mov XL,currLineBuffLow ; buffer into the X pointer regs197198:CamInterfaceAsm.S **** mov ZH,colorMapHigh ; Load the pointers to the membership199:CamInterfaceAsm.S **** mov ZL,colorMapLow ; lookup tables (ZL and YL will be overwritten200:CamInterfaceAsm.S **** mov YH,colorMapHigh ; as soon as we start reading data) to Z and Y201202:CamInterfaceAsm.S **** in tmp1, _SFR_IO_ADDR(TIMSK) ; enable TIMER1 to start counting203:CamInterfaceAsm.S **** ori tmp1, ENABLE_PCLK_TIMER1_OVERFLOW_BITMASK ; external PCLK pulses and interrupt on204:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TIMSK),tmp1 ; overflow205206:CamInterfaceAsm.S **** ldi tmp1,PIXEL_RUN_START_INITIAL ; set up the TCNT1 to overflow (andGAS LISTING /tmp/cckBHomO.s page 25207:CamInterfaceAsm.S **** ldi tmp2,0xFF ; interrupts) after 176 pixels208:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TCNT1H),tmp2209:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TCNT1L),tmp1210211:CamInterfaceAsm.S **** mov YL,colorMapLow212213:CamInterfaceAsm.S **** in tmp1, _SFR_IO_ADDR(GICR) ; enable the HREF interrupt...remember, we214 ; only use this interrupt to synchronize215 ; the beginning of the line216:CamInterfaceAsm.S **** ori tmp1, HREF_INTERRUPT_ENABLE_MASK217:CamInterfaceAsm.S **** out _SFR_IO_ADDR(GICR), tmp1218219 ;*******************************************************************************************220 ; Track Frame handler221 ;*******************************************************************************************222223 _trackFrame:224:CamInterfaceAsm.S **** sbi _SFR_IO_ADDR(PORTD),PD6225:CamInterfaceAsm.S **** sleep ; ...And we wait...226227 ; Returning from the interrupt/sleep wakeup will consume228 ; 14 clock cycles (7 to wakeup from idle sleep, 3 to vector, and 4 to return)229230 ; Disable the HREF interrupt231:CamInterfaceAsm.S **** cbi _SFR_IO_ADDR(PORTD),PD6232:CamInterfaceAsm.S **** in tmp1, _SFR_IO_ADDR(GICR)233:CamInterfaceAsm.S **** andi tmp1, HREF_INTERRUPT_DISABLE_MASK234:CamInterfaceAsm.S **** out _SFR_IO_ADDR(GICR), tmp1235236 ; A couple of NOPs are needed here to sync up the pixel data...the number (2)237 ; of NOPs was determined emperically by trial and error.238:CamInterfaceAsm.S **** nop239:CamInterfaceAsm.S **** nop240 _acquirePixelBlock: ; Clock Cycle Count241:CamInterfaceAsm.S **** in ZL,RB_PORT ; sample the red value (PINB) (1)242:CamInterfaceAsm.S **** in YL,G_PORT ; sample the green value (PINC) (1)243:CamInterfaceAsm.S **** andi YL,0x0F ; clear the high nibble (1)244:CamInterfaceAsm.S **** ldd color,Z+RED_MEM_OFFSET ; lookup the red membership (2)245:CamInterfaceAsm.S **** in ZL,RB_PORT ; sample the blue value (PINB) (1)246:CamInterfaceAsm.S **** ldd greenData,Y+GREEN_MEM_OFFSET; lookup the green membership (2)247:CamInterfaceAsm.S **** ldd blueData,Z+BLUE_MEM_OFFSET ; lookup the blue membership (2)248:CamInterfaceAsm.S **** and color,greenData ; mask memberships together (1)249:CamInterfaceAsm.S **** and color,blueData ; to produce the final color (1)250:CamInterfaceAsm.S **** brts _cleanUpTrackingLine ; if some interrupt routine has (1...not set)251 ; come in and set our T flag in252 ; SREG, then we need to hop out253 ; and blow away this frames data (common cleanup)254:CamInterfaceAsm.S **** cp color,lastColor ; check to see if the run continues (1)255:CamInterfaceAsm.S **** breq _acquirePixelBlock ; (2...equal)256 ; ___________257 ; 16 clock cycles258 ; (16 clock cycles = 1 uS = 1 pixelBlock time)259260 ; Toggle the debug line to indicate a color change261:CamInterfaceAsm.S **** sbi _SFR_IO_ADDR(PORTD),PD6262:CamInterfaceAsm.S **** nop263:CamInterfaceAsm.S **** cbi _SFR_IO_ADDR(PORTD),PD6GAS LISTING /tmp/cckBHomO.s page 26264265:CamInterfaceAsm.S **** mov tmp2,pixelRunStart ; get the count value of the266 ; current pixel run267:CamInterfaceAsm.S **** in pixelCount,_SFR_IO_ADDR(TCNT1L) ; get the current TCNT1 value268:CamInterfaceAsm.S **** mov pixelRunStart,pixelCount ; reload pixelRunStart for the269 ; next run270:CamInterfaceAsm.S **** sub pixelCount,tmp2 ; pixelCount = TCNT1L - pixelRunStart271272:CamInterfaceAsm.S **** st X+,lastColor ; record the color run in the current line buffer273:CamInterfaceAsm.S **** st X+,pixelCount ; with its length274:CamInterfaceAsm.S **** mov lastColor,color ; set lastColor so we can figure out when it changes275276:CamInterfaceAsm.S **** nop ; waste one more cycle for a total of 16277:CamInterfaceAsm.S **** rjmp _acquirePixelBlock278279 ; _cleanUpTrackingLine is used to write the last run length block off to the currentLineBuffer so280 ; that all 176 pixels in the line are accounted for.281 _cleanUpTrackingLine:282:CamInterfaceAsm.S **** ldi pixelCount,0xFF ; the length of the last run is ALWAYS 0xFF minus the last283:CamInterfaceAsm.S **** sub pixelCount,pixelRunStart ; pixelRunStart284285:CamInterfaceAsm.S **** inc pixelCount ; increment pixelCount since we actually need to account286 ; for the overflow of TCNT1287288:CamInterfaceAsm.S **** st X+,color ; record the color run in the current line buffer289:CamInterfaceAsm.S **** st X,pixelCount290:CamInterfaceAsm.S **** rjmp _cleanUp291292 _cleanUpDumpLine:293 ; NOTE: If serial data is received, to interrupt the tracking of a line, we'll294 ; get a EV_SERIAL_DATA_RECEIVED event, and the T bit set so we will end the295 ; line's processing...however, the PCLK will keep on ticking for the rest of296 ; the frame/line, which will cause the TCNT to eventually overflow and297 ; interrupt us, generating a EV_ACQUIRE_LINE_COMPLETE event. We don't want298 ; this, so we need to actually turn off the PCLK counting each time we exit299 ; this loop, and only turn it on when we begin acquiring lines....300 ; NOT NEEDED FOR NOW...301 ;in tmp1, _SFR_IO_ADDR(TIMSK) ; disable TIMER1 to stop counting302 ;andi tmp1, DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK ; external PCLK pulses303 ;out _SFR_IO_ADDR(TIMSK),tmp1304305 _cleanUp:306 ; Disable the external clocking of the Timer1 counter307:CamInterfaceAsm.S **** in tmp1, _SFR_IO_ADDR(TCCR1B)308:CamInterfaceAsm.S **** andi tmp1, 0xF8309:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TCCR1B),tmp1310311 ; Toggle the debug line to indicate the line is complete312:CamInterfaceAsm.S **** sbi _SFR_IO_ADDR(PORTD),PD6313:CamInterfaceAsm.S **** cbi _SFR_IO_ADDR(PORTD),PD6314:CamInterfaceAsm.S **** clt ; clear out the T bit since we have detected315 ; the interruption and are exiting to handle it316 _exit:317:CamInterfaceAsm.S **** ret318319 ;*****************************************************************320 ; Function Name: CamIntAsm_waitForNewDumpFrameGAS LISTING /tmp/cckBHomO.s page 27321 ; Function Description: This function is responsible for322 ; going to sleep until a new frame begins (indicated by323 ; VSYNC transitioning from low to high. This will wake324 ; the "VSYNC sleep" up and allow it to continue with325 ; acquiring a line of pixel data to dump out to the UI.326 ; Inputs: r25 - MSB of currentLineBuffer327 ; r24 - LSB of currentLineBuffer328 ; r23 - MSB of prevLineBuffer329 ; r22 - LSB of prevLineBuffer330 ; Outputs: none331 ; NOTES: This function doesn't really return...it sorta just332 ; floats into the acquireDumpLine function after the "VSYNC sleep"333 ; is awoken.334 ;*****************************************************************335 CamIntAsm_waitForNewDumpFrame:336:CamInterfaceAsm.S **** sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...337:CamInterfaceAsm.S **** cbi _SFR_IO_ADDR(PORTD),PD6338:CamInterfaceAsm.S **** sleep339340 ;*****************************************************************341 ; REMEMBER...everything from here on out is critically timed to be342 ; synchronized with the flow of pixel data from the camera...343 ;*****************************************************************344345 CamIntAsm_acquireDumpLine:346:CamInterfaceAsm.S **** brts _cleanUp347 ;sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...348 ;cbi _SFR_IO_ADDR(PORTD),PD6349350:CamInterfaceAsm.S **** mov XH,currLineBuffHigh ; Load the pointer to the current line351:CamInterfaceAsm.S **** mov XL,currLineBuffLow ; buffer into the X pointer regs352353:CamInterfaceAsm.S **** mov YH,prevLineBuffHigh ; Load the pointer to the previous line354:CamInterfaceAsm.S **** mov YL,prevLineBuffLow ; buffer into the Y pointer regs355356:CamInterfaceAsm.S **** ldi tmp1,PIXEL_RUN_START_INITIAL ; set up the TCNT1 to overflow (and357:CamInterfaceAsm.S **** ldi tmp2,0xFF ; interrupts) after 176 pixels358:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TCNT1H),tmp2359:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TCNT1L),tmp1360361:CamInterfaceAsm.S **** in tmp1, _SFR_IO_ADDR(TCCR1B) ; Enable the PCLK line to actually362:CamInterfaceAsm.S **** ori tmp1, 0x07 ; feed Timer1363:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TCCR1B),tmp1364:CamInterfaceAsm.S **** nop365366:CamInterfaceAsm.S **** in tmp1, _SFR_IO_ADDR(TIMSK) ; enable TIMER1 to start counting367:CamInterfaceAsm.S **** ori tmp1, ENABLE_PCLK_TIMER1_OVERFLOW_BITMASK ; external PCLK pulses and interrupt on368:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TIMSK),tmp1 ; overflow369370:CamInterfaceAsm.S **** in tmp1, _SFR_IO_ADDR(GICR) ; enable the HREF interrupt...remember, we371 ; only use this interrupt to synchronize372 ; the beginning of the line373:CamInterfaceAsm.S **** ori tmp1, HREF_INTERRUPT_ENABLE_MASK374:CamInterfaceAsm.S **** out _SFR_IO_ADDR(GICR), tmp1375376 ;*******************************************************************************************377 ; Dump Frame handlerGAS LISTING /tmp/cckBHomO.s page 28378 ;*******************************************************************************************379380 _dumpFrame:381:CamInterfaceAsm.S **** sbi _SFR_IO_ADDR(PORTD),PD6382:CamInterfaceAsm.S **** sleep ; ...And we wait...383384:CamInterfaceAsm.S **** cbi _SFR_IO_ADDR(PORTD),PD6385:CamInterfaceAsm.S **** in tmp1, _SFR_IO_ADDR(GICR) ; disable the HREF interrupt386:CamInterfaceAsm.S **** andi tmp1, HREF_INTERRUPT_DISABLE_MASK ; so we don't get interrupted387:CamInterfaceAsm.S **** out _SFR_IO_ADDR(GICR), tmp1 ; while dumping the line388389:CamInterfaceAsm.S **** nop ; Remember...if we ever remove the "cbi" instruction above,390 ; we need to add two more NOPs to cover this391392 ; Ok...the following loop needs to run in 8 clock cycles, so we can get every393 ; pixel in the line...this shouldn't be a problem, since the PCLK timing was394 ; reduced by a factor of 2 whenever we go to dump a line (this is to give us395 ; enough time to do the sampling and storing of the pixel data). In addition,396 ; it is assumed that we will have to do some minor processing on the data right397 ; before we send it out, like mask off the top 4-bits of each, and then pack both398 ; low nibbles into a single byte for transmission...we just don't have time to399 ; do that here (only 8 instruction cycles :-) )400 _sampleDumpPixel:401:CamInterfaceAsm.S **** in tmp1,G_PORT ; sample the G value (1)402:CamInterfaceAsm.S **** in tmp2,RB_PORT ; sample the R/B value (1)403:CamInterfaceAsm.S **** st X+,tmp1 ; store to the currLineBuff and inc ptrs(2)404:CamInterfaceAsm.S **** st Y+,tmp2 ; store to the prevLineBuff and inc ptrs(2)405:CamInterfaceAsm.S **** brtc _sampleDumpPixel ; loop back unless flag is set (2...if not set)406 ; ___________407 ; 8 cycles normally408409 ; if we make it here, it means the T flag is set, and we must have been interrupted410 ; so we need to exit (what if we were interrupted for serial? should we disable it?)411:CamInterfaceAsm.S **** rjmp _cleanUpDumpLine412413 ;***********************************************************414 ; Function Name: <interrupt handler for External Interrupt0>415 ; Function Description: This function is responsible416 ; for handling a rising edge on the Ext Interrupt 0. This417 ; routine simply returns, since we just want to wake up418 ; whenever the VSYNC transitions (meaning the start of a new419 ; frame).420 ; Inputs: none421 ; Outputs: none422 ;***********************************************************423 SIG_INTERRUPT0:424 ; This will wake us up when VSYNC transitions high...we just want to return425:CamInterfaceAsm.S **** reti426427 ;***********************************************************428 ; Function Name: <interrupt handler for External Interrupt1>429 ; Function Description: This function is responsible430 ; for handling a falling edge on the Ext Interrupt 1. This431 ; routine simply returns, since we just want to wake up432 ; whenever the HREF transitions (meaning the pixels433 ; are starting after VSYNC transitioned, and we need to434 ; start acquiring the pixel blocksGAS LISTING /tmp/cckBHomO.s page 29435 ; Inputs: none436 ; Outputs: none437 ;***********************************************************438 SIG_INTERRUPT1:439 ; This will wake us up when HREF transitions high...we just want to return440:CamInterfaceAsm.S **** reti441442 ;***********************************************************443 ; Function Name: <interrupt handler for Timer0 overflow>444 ; Function Description: This function is responsible445 ; for handling the Timer0 overflow (hooked up to indicate446 ; when we have reached the number of HREFs required in a447 ; single frame). We set the T flag in the SREG to448 ; indicate to the _acquirePixelBlock routine that it needs449 ; to exit, and then set the appropriate action to take in450 ; the eventList of the Executive module.451 ; Inputs: none452 ; Outputs: none453 ; Note: Originally, the HREF pulses were also going to454 ; be counted by a hardware counter, but it didn't end up455 ; being necessary456 ;***********************************************************457 ;SIG_OVERFLOW0:458 ; set ; set the T bit in SREG459 ; lds tmp1,eventBitmask460 ; ori tmp1,EV_ACQUIRE_FRAME_COMPLETE461 ; sts eventBitmask,tmp1462 ; reti463464 ;***********************************************************465 ; Function Name: <interrupt handler for Timer1 overflow>466 ; Function Description: This function is responsible467 ; for handling the Timer1 overflow (hooked up to indicate468 ; when we have reached the end of a line of pixel data,469 ; since PCLK is hooked up to overflow TCNT1 after 176470 ; pixels). This routine generates an acquire line complete471 ; event in the fastEventBitmask, which is streamlined for472 ; efficiency reasons.473 ;***********************************************************474 SIG_OVERFLOW1:475:CamInterfaceAsm.S **** lds tmp1,fastEventBitmask ; set a flag indicating476:CamInterfaceAsm.S **** ori tmp1,FEV_ACQUIRE_LINE_COMPLETE ; a line is complete477:CamInterfaceAsm.S **** sts fastEventBitmask,tmp1478:CamInterfaceAsm.S **** set ; set the T bit in SREG479 ;sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...480 ;cbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...481482:CamInterfaceAsm.S **** reti483484 ; This is the default handler for all interrupts that don't485 ; have handler routines specified for them.486 .global __vector_default487 __vector_default:488:CamInterfaceAsm.S **** reti489490 .endGAS LISTING /tmp/cckBHomO.s page 30DEFINED SYMBOLS*ABS*:00000000 CamInterfaceAsm.SCamInterfaceAsm.S:119 *ABS*:00000010 pixelCountCamInterfaceAsm.S:120 *ABS*:00000011 pixelRunStartCamInterfaceAsm.S:121 *ABS*:00000012 lastColorCamInterfaceAsm.S:122 *ABS*:00000013 tmp1CamInterfaceAsm.S:123 *ABS*:00000014 tmp2CamInterfaceAsm.S:124 *ABS*:00000013 colorCamInterfaceAsm.S:125 *ABS*:00000014 greenDataCamInterfaceAsm.S:126 *ABS*:00000015 blueDataCamInterfaceAsm.S:127 *ABS*:00000016 colorMapLowCamInterfaceAsm.S:128 *ABS*:00000017 colorMapHighCamInterfaceAsm.S:129 *ABS*:00000016 prevLineBuffLowCamInterfaceAsm.S:130 *ABS*:00000017 prevLineBuffHighCamInterfaceAsm.S:131 *ABS*:00000018 currLineBuffLowCamInterfaceAsm.S:132 *ABS*:00000019 currLineBuffHighCamInterfaceAsm.S:169 .text:00000000 CamIntAsm_waitForNewTrackingFrameCamInterfaceAsm.S:335 .text:0000008e CamIntAsm_waitForNewDumpFrameCamInterfaceAsm.S:345 .text:00000094 CamIntAsm_acquireDumpLineCamInterfaceAsm.S:179 .text:00000006 CamIntAsm_acquireTrackingLineCamInterfaceAsm.S:423 .text:000000d4 __vector_1CamInterfaceAsm.S:438 .text:000000d6 __vector_2CamInterfaceAsm.S:474 .text:000000d8 __vector_8CamInterfaceAsm.S:305 .text:00000080 _cleanUpCamInterfaceAsm.S:223 .text:00000034 _trackFrameCamInterfaceAsm.S:240 .text:00000044 _acquirePixelBlockCamInterfaceAsm.S:281 .text:00000074 _cleanUpTrackingLineCamInterfaceAsm.S:292 .text:00000080 _cleanUpDumpLineCamInterfaceAsm.S:316 .text:0000008c _exitCamInterfaceAsm.S:380 .text:000000ba _dumpFrameCamInterfaceAsm.S:400 .text:000000c8 _sampleDumpPixelCamInterfaceAsm.S:487 .text:000000e6 __vector_defaultUNDEFINED SYMBOLS__vector_9fastEventBitmask