Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
141 kakl 1
#include ".\camerus.h"
136 kakl 2
 
3
#use fast_io (C)
4
 
5
#define LED PIN_C0
6
#define HREF PIN_C5
7
#define PIX PIN_C6
8
 
9
void main()
10
{
11
   int8 cas;
12
 
13
   setup_adc_ports(ALL_ANALOG);
14
   setup_adc(ADC_CLOCK_INTERNAL);
15
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
16
   setup_timer_1(T1_DISABLED);
17
   setup_timer_2(T2_DIV_BY_16,62,1);
18
   setup_ccp1(CCP_PWM); // RC1
19
   setup_ccp2(CCP_PWM); // RC2
20
   setup_comparator(NC_NC_NC_NC);
21
   setup_vref(FALSE);
22
 
141 kakl 23
   set_tris_c(0x11111000);
24
 
136 kakl 25
   output_high(LED);
26
 
27
   i2c_start();      // Reset
28
   i2c_write(0xC0);
29
   i2c_write(0x12);
30
   i2c_write(0x80 | 0x24);
31
   i2c_stop();
32
 
33
   i2c_start();      // BW
34
   i2c_write(0xC0);
35
   i2c_write(0x28);
36
   i2c_write(0b01000001);
37
   i2c_stop();
38
 
39
   i2c_start();      // Contrast
40
   i2c_write(0xC0);
41
   i2c_write(0x05);
42
   i2c_write(0xFF);
43
   i2c_stop();
44
 
45
   i2c_start();      // Brightness
46
   i2c_write(0xC0);
47
   i2c_write(0x06);
48
   i2c_write(0x80);
49
   i2c_stop();
50
 
51
/*
52
   i2c_start();      // Band Filter
53
   i2c_write(0xC0);
54
   i2c_write(0x2D);
55
   i2c_write(0x04 | 0x03);
56
   i2c_stop();
57
 
58
   i2c_start();      // 4-bit, (CLK/4)
59
   i2c_write(0xC0);
60
   i2c_write(0x3E);
61
   i2c_write(0x10 | 0x80);
62
   i2c_stop();
63
*/
64
   i2c_start();      // VSTRT
65
   i2c_write(0xC0);
66
   i2c_write(0x19);
67
   i2c_write(45);
68
   i2c_stop();
69
 
70
   i2c_start();      // VEND
71
   i2c_write(0xC0);
72
   i2c_write(0x1A);
73
   i2c_write(45);
74
   i2c_stop();
75
 
76
   output_low(LED);
77
 
78
   while(true)
79
   {
80
      while(!input(HREF));
81
      set_timer0(0);
82
      while(input(PIX));
83
      set_pwm1_duty(get_timer0());
141 kakl 84
      delay_ms(1);
136 kakl 85
   };
86
}