Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
365 kakl 1
#include "test.h"
2
 
3
#define H1 PIN_A1
4
#define L1 PIN_A2
5
#define H2 PIN_A3
6
#define L2 PIN_A4
7
 
8
char command;
9
 
10
int n;
11
 
12
#INT_SSP
13
void ssp_interupt ()
14
{
15
   BYTE incoming, state;
16
 
17
   output_low(H1);
18
   output_low(L1);
19
   output_low(H2);
20
   output_low(L2);
21
 
22
	state = i2c_isr_state();
23
 
24
	if(state < 0x80)							//Master is sending data
25
	{
26
      output_toggle(PIN_A0);
27
		command = i2c_read();
28
	}
29
 
30
	if(state == 0x80)							//Master is requesting data
31
	{
32
		i2c_write(command);
33
	}
34
}
35
 
36
void main()
37
{
38
 
39
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
40
   setup_adc(ADC_OFF);
41
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
42
   setup_timer_1(T1_DISABLED);
43
   setup_timer_2(T2_DISABLED,0,1);
44
   setup_comparator(NC_NC_NC_NC);
45
   setup_vref(FALSE);
46
   setup_oscillator(False);
47
 
48
   enable_interrupts(GLOBAL);
49
   enable_interrupts(INT_SSP);
50
 
51
   while(true)
52
   {
53
      if(command=='a')
54
      {
55
         output_high(H1);
56
         output_low(H2);
57
         output_low(L1);
58
         output_high(L2);
59
      }
60
      else
61
      {
62
         output_low(H1);
63
         output_high(H2);
64
         output_high(L1);
65
         output_low(L2);
66
      };
67
      delay_us(60);
68
      output_low(H1);
69
      output_low(H2);
70
      output_low(L1);
71
      output_low(L2);
72
   }
73
}