| 151 | kaklik | 1 | #ifndef CAMINTERFACE_H
 | 
        
           |  |  | 2 | #define CAMINTERFACE_H
 | 
        
           |  |  | 3 |   | 
        
           |  |  | 4 | /*
 | 
        
           |  |  | 5 |     Copyright (C) 2004    John Orlando
 | 
        
           |  |  | 6 |   | 
        
           |  |  | 7 |    AVRcam: a small real-time image processing engine.
 | 
        
           |  |  | 8 |   | 
        
           |  |  | 9 |     This program is free software; you can redistribute it and/or
 | 
        
           |  |  | 10 |     modify it under the terms of the GNU General Public
 | 
        
           |  |  | 11 |     License as published by the Free Software Foundation; either
 | 
        
           |  |  | 12 |     version 2 of the License, or (at your option) any later version.
 | 
        
           |  |  | 13 |   | 
        
           |  |  | 14 |     This program is distributed in the hope that it will be useful,
 | 
        
           |  |  | 15 |     but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
        
           |  |  | 16 |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
        
           |  |  | 17 |     General Public License for more details.
 | 
        
           |  |  | 18 |   | 
        
           |  |  | 19 |     You should have received a copy of the GNU General Public
 | 
        
           |  |  | 20 |     License along with this program; if not, write to the Free Software
 | 
        
           |  |  | 21 |     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
        
           |  |  | 22 |   | 
        
           |  |  | 23 |    For more information on the AVRcam, please contact:
 | 
        
           |  |  | 24 |   | 
        
           |  |  | 25 |    john@jrobot.net
 | 
        
           |  |  | 26 |   | 
        
           |  |  | 27 |    or go to www.jrobot.net for more details regarding the system.
 | 
        
           |  |  | 28 | */
 | 
        
           |  |  | 29 | /***********************************************************
 | 
        
           |  |  | 30 | 	Module Name: CamInterface.h
 | 
        
           |  |  | 31 | 	Module Date: 04/14/2004
 | 
        
           |  |  | 32 | 	Module Auth: John Orlando
 | 
        
           |  |  | 33 |   | 
        
           |  |  | 34 | 	Description: This file is responsible for providing the
 | 
        
           |  |  | 35 | 	external interface to the CamInterface module.
 | 
        
           |  |  | 36 |   | 
        
           |  |  | 37 |     Revision History:
 | 
        
           |  |  | 38 |     Date        Rel Ver.    Notes
 | 
        
           |  |  | 39 |     4/10/2004      0.1     Module created
 | 
        
           |  |  | 40 |     6/30/2004      1.0     Initial release for Circuit Cellar
 | 
        
           |  |  | 41 |                            contest.
 | 
        
           |  |  | 42 | ***********************************************************/
 | 
        
           |  |  | 43 |   | 
        
           |  |  | 44 | #define NUM_PIXELS_IN_A_TRACKED_LINE 	88
 | 
        
           |  |  | 45 | #define NUM_PIXELS_IN_A_DUMP_LINE    	176
 | 
        
           |  |  | 46 | #define ACTUAL_NUM_PIXELS_IN_A_LINE		176
 | 
        
           |  |  | 47 | #define ACTUAL_NUM_LINES_IN_A_FRAME		144
 | 
        
           |  |  | 48 | #define LENGTH_OF_RUN_LENGTH_BLOCK 2
 | 
        
           |  |  | 49 | #define LENGTH_OF_LINE_BUFFER NUM_PIXELS_IN_A_DUMP_LINE
 | 
        
           |  |  | 50 |   | 
        
           |  |  | 51 | #define WAIT_FOR_VSYNC_LOW() 	while( (PIND & 0x04) != 0)
 | 
        
           |  |  | 52 | #define WAIT_FOR_VSYNC_HIGH()	while( (PIND & 0x04) == 0)
 | 
        
           |  |  | 53 |   | 
        
           |  |  | 54 | #define WAIT_FOR_HREF_LOW()		while( (PIND & 0x10) != 0)
 | 
        
           |  |  | 55 | #define WAIT_FOR_HREF_HIGH()	while( (PIND & 0x10) == 0)
 | 
        
           |  |  | 56 |   | 
        
           |  |  | 57 | #define WAIT_FOR_PCLK_LOW()		while( (PIND & 0x20) != 0)
 | 
        
           |  |  | 58 | #define WAIT_FOR_PCLK_HIGH()	while( (PIND & 0x20) == 0)
 | 
        
           |  |  | 59 |   | 
        
           |  |  | 60 | #define NUM_COLOR_STEPS     16
 | 
        
           |  |  | 61 | #define NUM_COLOR_CHANNELS	3
 | 
        
           |  |  | 62 | #define NUM_ELEMENTS_IN_COLOR_MAP (NUM_COLOR_STEPS * NUM_COLOR_CHANNELS)
 | 
        
           |  |  | 63 |   | 
        
           |  |  | 64 | #define RED_OFFSET		0
 | 
        
           |  |  | 65 | #define GREEN_OFFSET	16
 | 
        
           |  |  | 66 | #define BLUE_OFFSET		32
 | 
        
           |  |  | 67 |   | 
        
           |  |  | 68 | extern unsigned char currentLineBuffer[];
 | 
        
           |  |  | 69 | extern unsigned char previousLineBuffer[];
 | 
        
           |  |  | 70 | extern unsigned char colorMap[];
 | 
        
           |  |  | 71 | extern unsigned char frameCount;
 | 
        
           |  |  | 72 |   | 
        
           |  |  | 73 | /* Extern functions */
 | 
        
           |  |  | 74 | extern void CamInt_init(void);
 | 
        
           |  |  | 75 | extern void CamInt_resetCam(void);
 | 
        
           |  |  | 76 | extern void CamInt_waitForNewDumpFrame(void);
 | 
        
           |  |  | 77 | extern void CamInt_waitForNewTrackingFrame(void);
 | 
        
           |  |  | 78 | extern void CamInt_acquireTrackingLine(void);
 | 
        
           |  |  | 79 | extern void CamInt_acquireDumpLine(void);
 | 
        
           |  |  | 80 |   | 
        
           |  |  | 81 | #endif	
 | 
        
           |  |  | 82 |   |