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   0xC4
-
 
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 9... Line 11...
9
   setup_timer_1(T1_DISABLED);
11
   setup_timer_1(T1_DISABLED);
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
 
15
   Delay_ms(200);
17
   Delay_ms(200);
16
   output_low(PIN_C0);
18
   output_low(PIN_C0);
17
   Delay_ms(200);
19
   Delay_ms(200);
18
   output_high(PIN_C0);
20
   output_high(PIN_C0);
19
 
21
 
20
   i2c_start();      // Reset
22
   i2c_start();      // Reset
21
   i2c_write(0xC0);
23
   i2c_write(CAMERA_ADR);
22
   i2c_write(0x12);
24
   i2c_write(0x12);
23
   i2c_write(0x80 | 0x24);
25
   i2c_write(0x80 | 0x24);
24
   i2c_stop();
26
   i2c_stop();
25
 
27
 
26
// **** Write data => Adr($13) = 0x05 ****
28
// **** Write data => Adr($13) = 0x05 ****
27
// 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
28
// will allow re-programming of the mega8 to proceed at startup
30
// will allow re-programming of the atmega8 to proceed at startup
29
// if needed.
31
// if needed.
30
 
32
 
31
   i2c_start();      
33
   i2c_start();
32
   i2c_write(0xC0);
34
   i2c_write(CAMERA_ADR);
33
   i2c_write(0x13);
35
   i2c_write(0x13);
34
   i2c_write(0x05);
36
   i2c_write(0x05);
35
   i2c_stop();
37
   i2c_stop();
36
   
38
 
37
   Delay_ms(250);
39
   Delay_ms(250);
38
 
40
 
39
//**** Write data => Adr($3F) = 0x42 ****
41
//**** Write data => Adr($3F) = 0x42 ****
40
// 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.
41
 
43
 
42
   i2c_start();     
44
   i2c_start();
43
   i2c_write(0xC0);
45
   i2c_write(CAMERA_ADR);
44
   i2c_write(0x3F);
46
   i2c_write(0x3F);
45
   i2c_write(0x42);
47
   i2c_write(0x42);
46
   i2c_stop();
48
   i2c_stop();
47
   
49
 
48
// Wait for a short amount of time for the external clock
50
// Wait for a short amount of time for the external clock
49
// to stabilize   
51
// to stabilize
50
 
52
 
51
   Delay_ms(250);
53
   Delay_ms(250);
52
 
54
 
53
 
55
 
54
   output_low(PIN_C0);
56
   output_low(PIN_C0);
55
   
57
 
56
// turn on the mega8 by releasing the reset line
58
// turn on the mega8 by releasing the reset line
57
   output_high(PIN_C6);
59
   output_high(PIN_C6);
58
 
60
 
59
   while(true);
61
   while(true);
60
}
62
}