Subversion Repositories svnkaklik

Rev

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

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