Subversion Repositories svnkaklik

Rev

Rev 199 | Blame | Last modification | View Log | Download

#include ".\camerus.h"

#define  CAMERA_ADR   0xC4


void main()
{
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);

   output_high(PIN_C0);
   output_low(PIN_C6);

   Delay_ms(200);
   output_low(PIN_C0);
   Delay_ms(200);
   output_high(PIN_C0);

   i2c_start();      // Reset
   i2c_write(CAMERA_ADR);
   i2c_write(0x12);
   i2c_write(0x80 | 0x24);
   i2c_stop();

// **** Write data => Adr($13) = 0x05 ****
// This will tri-state the Y and UV busses on the OV6620, which
// will allow re-programming of the atmega8 to proceed at startup
// if needed.

   i2c_start();
   i2c_write(CAMERA_ADR);
   i2c_write(0x13);
   i2c_write(0x05);
   i2c_stop();

   Delay_ms(250);

//**** Write data => Adr($3F) = 0x42 ****
// This will turn on the external clock for the atmega8 to use.

   i2c_start();
   i2c_write(CAMERA_ADR);
   i2c_write(0x3F);
   i2c_write(0x42);
   i2c_stop();

// Wait for a short amount of time for the external clock
// to stabilize

   Delay_ms(250);


   output_low(PIN_C0);

// turn on the mega8 by releasing the reset line
   output_high(PIN_C6);

   while(true);
}