Subversion Repositories svnkaklik

Rev

Rev 199 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 199 Rev 251
Line 1... Line 1...
1
#include ".\camerus.h"
1
#include ".\camerus.h"
2
 
2
 
-
 
3
#define  CAMERA_ADR   0xC0
-
 
4
 
3
 
5
 
4
void main()
6
void main()
5
{
7
{
6
   setup_adc_ports(NO_ANALOGS);
8
   setup_adc_ports(NO_ANALOGS);
7
   setup_adc(ADC_OFF);
9
   setup_adc(ADC_OFF);
Line 10... Line 12...
10
   setup_timer_2(T2_DISABLED,0,1);
12
   setup_timer_2(T2_DISABLED,0,1);
11
 
13
 
12
   output_high(PIN_C0);
14
   output_high(PIN_C0);
13
   output_low(PIN_C6);
15
   output_low(PIN_C6);
14
 
16
 
-
 
17
   Delay_ms(200);
-
 
18
   output_low(PIN_C0);
-
 
19
   Delay_ms(200);
-
 
20
   output_high(PIN_C0);
-
 
21
 
15
   i2c_start();      // Reset
22
   i2c_start();      // Reset
16
   i2c_write(0xC0);
23
   i2c_write(CAMERA_ADR);
17
   i2c_write(0x12);
24
   i2c_write(0x12);
18
   i2c_write(0x80 | 0x24);
25
   i2c_write(0x80 | 0x24);
19
   i2c_stop();
26
   i2c_stop();
20
 
27
 
21
// **** Write data => Adr($13) = 0x05 ****
28
// **** Write data => Adr($13) = 0x05 ****
22
// This will tri-state the Y and UV busses on the OV6620, which
29
// This will tri-state the Y and UV busses on the OV6620, which
23
// will allow re-programming of the mega8 to proceed at startup
30
// will allow re-programming of the atmega8 to proceed at startup
24
// if needed.
31
// if needed.
25
 
32
 
26
   i2c_start();      
33
   i2c_start();
27
   i2c_write(0xC0);
34
   i2c_write(CAMERA_ADR);
28
   i2c_write(0x13);
35
   i2c_write(0x13);
29
   i2c_write(0x05);
36
   i2c_write(0x05);
30
   i2c_stop();
37
   i2c_stop();
31
   
38
 
32
   Delay_ms(250);
39
   Delay_ms(250);
33
 
40
 
34
//**** Write data => Adr($3F) = 0x42 ****
41
//**** Write data => Adr($3F) = 0x42 ****
35
// This will turn on the external clock for the mega8 to use.
42
// This will turn on the external clock for the atmega8 to use.
36
 
43
 
37
   i2c_start();     
44
   i2c_start();
38
   i2c_write(0xC0);
45
   i2c_write(CAMERA_ADR);
39
   i2c_write(0x3F);
46
   i2c_write(0x3F);
40
   i2c_write(0x42);
47
   i2c_write(0x42);
41
   i2c_stop();
48
   i2c_stop();
42
   
49
 
43
// Wait for a short amount of time for the external clock
50
// Wait for a short amount of time for the external clock
44
// to stabilize   
51
// to stabilize
45
 
52
 
46
   Delay_ms(250);
53
   Delay_ms(250);
47
 
54
 
48
 
55
 
49
   output_low(PIN_C0);
56
   output_low(PIN_C0);
50
   
57
 
51
// turn on the mega8 by releasing the reset line
58
// turn on the mega8 by releasing the reset line
52
   output_high(PIN_C6);
59
   output_high(PIN_C6);
53
 
60
 
54
   while(true);
61
   while(true);
55
}
62
}