Subversion Repositories svnkaklik

Rev

Rev 199 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

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