151 |
kaklik |
1 |
; Module Name: CanInterface.S
|
|
|
2 |
; Module Date: 04/14/2004
|
|
|
3 |
; Module Auth: John O.
|
|
|
4 |
;
|
|
|
5 |
; Description: This module provides the low-level interface
|
|
|
6 |
; to the OV6620 camera hardware. It is responsible for
|
|
|
7 |
; acquiring each pixel block (RG,GB), performing the mapping
|
|
|
8 |
; into an actual color (orange, purple, etc), run-length
|
|
|
9 |
; encoding the data, and storing the info off to the appropriate
|
|
|
10 |
; line buffer. This routine is synchronized with the pixel data
|
|
|
11 |
; so that no polling of the camera data needs to be done (the
|
|
|
12 |
; OV6620 is clocked off of the same crystal source as the mega8,
|
|
|
13 |
; thus providing inherent synchronization between the two).
|
|
|
14 |
|
|
|
15 |
#include <avr/io.h>
|
|
|
16 |
|
|
|
17 |
#define PCLK_INTERRUPT_ENABLE_MASK $40
|
|
|
18 |
#define PCLK_INTERRUPT_DISABLE_MASK $BF
|
|
|
19 |
|
|
|
20 |
.section .text
|
|
|
21 |
|
|
|
22 |
.global CamInt_waitForNewFrame
|
|
|
23 |
.global CamInt_acquireLine
|
|
|
24 |
.global SIG_INTERRUPT0
|
|
|
25 |
.global SIG_INTERRUPT1
|
|
|
26 |
|
|
|
27 |
;*****************************************************************
|
|
|
28 |
; Function Name: CamInt_waitForNewFrame
|
|
|
29 |
; Function Description: This function is responsible for
|
|
|
30 |
; going to sleep until a new frame begins (indicated by
|
|
|
31 |
; VSYNC transitioning from high to low. This will wake
|
|
|
32 |
; the "VSYNC sleep" up and allow it to continue with
|
|
|
33 |
; the acquireLine function, where the system waits for
|
|
|
34 |
; a "PCLK sleep" that we use to synchronize with the
|
|
|
35 |
; data.
|
|
|
36 |
; Inputs: none
|
|
|
37 |
; Outputs: none
|
|
|
38 |
; NOTES: This function doesn't really return...it sorta just
|
|
|
39 |
; floats into the acquireLine function after the "VSYNC sleep"
|
|
|
40 |
; is awoken.
|
|
|
41 |
;*****************************************************************
|
|
|
42 |
|
|
|
43 |
CamInt_waitForNewFrame:
|
|
|
44 |
sleep ; sleep mode already set to sleep idle
|
|
|
45 |
|
|
|
46 |
CamInt_acquireLine:
|
|
|
47 |
in r1,_SFR_IO_ADDR(GICR) ;enable the PCLK interrupt
|
|
|
48 |
or r1,PCLK_INTERRUPT_ENABLE_MASK
|
|
|
49 |
out _SFR_IO_ADDR(GICR),r1
|
|
|
50 |
sleep
|
|
|
51 |
|
|
|
52 |
in r1,_SFR_IO_ADDR(GICR) ;disable the PCLK interrupt
|
|
|
53 |
and r1,PCLK_INTERRUPT_DISABLE_MASK
|
|
|
54 |
out _SFR_IO_ADDR(GICR),r1
|
|
|
55 |
|
|
|
56 |
_acquirePixelBlock:
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
_exit:
|
|
|
60 |
ret
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
SIG_INTERRUPT0:
|
|
|
64 |
; This will wake us up when VSYNC transitions low...we just want to return
|
|
|
65 |
reti
|
|
|
66 |
|
|
|
67 |
SIG_INTERRUPT1:
|
|
|
68 |
; This will wake us up when PCLK transitions low...we just want to return
|
|
|
69 |
reti
|
|
|
70 |
|
|
|
71 |
|
|
|
72 |
.global __vector_default ; Note [10]
|
|
|
73 |
__vector_default:
|
|
|
74 |
reti
|
|
|
75 |
|
|
|
76 |
.end
|