Subversion Repositories svnkaklik

Rev

Rev 870 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 870 Rev 882
1
#include "main.h"
1
#include "main.h"
2
 
2
 
3
#use fast_io (D)
3
#use fast_io (D)
4
 
4
 
5
#define START  PIN_D4
5
#define START  PIN_D4
6
#define STOP1  PIN_D5
6
#define STOP1  PIN_D5
7
#define STOP2  PIN_D7
7
#define STOP2  PIN_D7
8
 
8
 
9
#define FIRE_DETECT  PIN_D6
9
#define FIRE_DETECT  PIN_D6
10
 
10
 
11
 
11
 
12
void main()
12
void main()
13
{
13
{
14
 
14
 
15
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
15
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
16
   setup_adc(ADC_CLOCK_DIV_2);
16
   setup_adc(ADC_CLOCK_DIV_2);
17
   setup_psp(PSP_DISABLED);
17
   setup_psp(PSP_DISABLED);
18
   setup_spi(SPI_SS_DISABLED);
18
   setup_spi(SPI_SS_DISABLED);
19
   setup_wdt(WDT_OFF);
19
   setup_wdt(WDT_OFF);
20
   setup_timer_0(RTCC_INTERNAL);
20
   setup_timer_0(RTCC_INTERNAL);
21
   setup_timer_1(T1_DISABLED);
21
   setup_timer_1(T1_DISABLED);
22
   setup_timer_2(T2_DISABLED,0,1);
22
   setup_timer_2(T2_DISABLED,0,1);
23
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
23
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
24
   setup_ccp1(CCP_OFF);
24
   setup_ccp1(CCP_OFF);
25
   setup_comparator(NC_NC_NC_NC);
25
   setup_comparator(NC_NC_NC_NC);
26
   setup_vref(FALSE);
26
   setup_vref(FALSE);
27
 
27
 
28
   SET_TRIS_D( 0b00000100 );
28
   SET_TRIS_D( 0b00000100 );
29
 
29
 
30
  while(true)
30
  while(true)
31
  {
31
  {
32
      delay_ms(50);
32
      delay_ms(50);
33
      output_low(START);
33
      output_low(START);
34
      output_low(STOP1);
34
      output_low(STOP1);
35
      output_low(STOP2);
35
      output_low(STOP2);
36
 
36
 
37
// Mode 1
37
// Mode 1
38
/*      
-
 
39
      delay_ms(50);
-
 
40
      output_low(START);
38
      while(!input(FIRE_DETECT));            
41
      output_low(STOP1);
-
 
42
      output_low(STOP2);
-
 
43
            
-
 
44
      output_high(START);     // start of time measurement
39
      output_high(START);     // start of time measurement
45
 
40
 
46
      output_high(STOP2);
41
      output_high(STOP2);
47
      output_high(STOP1);
42
      output_high(STOP1);
48
 
43
 
49
      output_low(STOP1);
44
      output_low(STOP1);
50
      output_low(STOP2);
45
      output_low(STOP2);
51
      output_low(START);
46
      output_low(START);
52
 
47
 
53
*/
-
 
54
// mode 2
48
// mode 2
-
 
49
/*      
55
 
50
 
56
      output_high(STOP2);  // Merime jenom jednim kanalem (druhy musi byt v H)
51
      output_high(STOP2);  // Merime jenom jednim kanalem (druhy musi byt v H)
57
      while(!input(FIRE_DETECT));
52
      while(!input(FIRE_DETECT));
58
 
53
 
59
      output_high(START);
54
      output_high(START);
60
      output_low(START);
55
      output_low(START);
61
      delay_us(150);
56
      delay_us(150);
62
      
57
      
63
      output_high(STOP1);
58
      output_high(STOP1);
64
      output_low(STOP1);
59
      output_low(STOP1);
65
      delay_us(1);
60
      delay_us(1);
66
      
61
      
67
      output_high(STOP1);
62
      output_high(STOP1);
68
      output_low(STOP1);
63
      output_low(STOP1);
69
      delay_us(10);
64
      delay_us(10);
70
      
65
      
71
      output_high(STOP1);
66
      output_high(STOP1);
72
      output_low(STOP1);
67
      output_low(STOP1);
-
 
68
*/
-
 
69
 
73
  }
70
  }
74
}
71
}