Line 1... |
Line 1... |
1 |
#include "main.h" |
1 |
#include "main.h" |
2 |
|
2 |
|
3 |
#include "GP2.h" |
- |
|
4 |
|
- |
|
5 |
#define VERSION 0.1 |
3 |
#define VERSION 0.1 |
6 |
|
4 |
|
7 |
#define START PIN_D4 |
5 |
#define START PIN_D4 |
8 |
#define STOP1 PIN_D5 |
6 |
#define STOP1 PIN_D5 |
9 |
#define STOP2 PIN_D6 |
7 |
#define STOP2 PIN_D6 |
- |
|
8 |
#include "GP2.h" |
- |
|
9 |
|
- |
|
10 |
#define ONE_WIRE_PIN PIN_E2 |
- |
|
11 |
#include "ds1820.c" |
10 |
|
12 |
|
11 |
void main() |
13 |
void main() |
12 |
{ |
14 |
{ |
- |
|
15 |
float temperature; |
- |
|
16 |
|
13 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
17 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
14 |
setup_adc(ADC_CLOCK_DIV_2); |
18 |
setup_adc(ADC_CLOCK_DIV_2); |
15 |
setup_psp(PSP_DISABLED); |
19 |
setup_psp(PSP_DISABLED); |
16 |
setup_spi(SPI_SS_DISABLED); |
20 |
setup_spi(SPI_SS_DISABLED); |
17 |
setup_wdt(WDT_OFF); |
21 |
setup_wdt(WDT_OFF); |
Line 43... |
Line 47... |
43 |
TDC_start_cal(); |
47 |
TDC_start_cal(); |
44 |
delay_ms(50); |
48 |
delay_ms(50); |
45 |
|
49 |
|
46 |
while(true) |
50 |
while(true) |
47 |
{ |
51 |
{ |
- |
|
52 |
temperature = ds1820_read(); |
48 |
|
53 |
|
49 |
/* delay_ms(500); |
- |
|
50 |
hit2=0x00; |
- |
|
51 |
hit1=0x00; |
- |
|
52 |
TDC_update_registers(); |
- |
|
53 |
printf("reg1: %X \n", TDC_get_reg1()); |
- |
|
54 |
|
- |
|
55 |
TDC_reset(); |
- |
|
56 |
delay_ms(50); |
- |
|
57 |
printf("reg1: %X \n", TDC_get_reg1()); |
- |
|
58 |
*/ |
- |
|
59 |
TDC_init(); |
54 |
TDC_init(); |
60 |
delay_ms(50); |
55 |
delay_ms(50); |
- |
|
56 |
printf("Temp: %f \r\n", temperature); |
- |
|
57 |
delay_ms(50); |
61 |
printf("status: %LX \n", TDC_get_status()); |
58 |
printf("status: %LX \r\n", TDC_get_status()); |
62 |
delay_us(10); |
59 |
delay_us(10); |
63 |
TDC_start_cycle(); |
60 |
TDC_start_cycle(); |
64 |
delay_us(10); |
61 |
delay_us(10); |
65 |
output_high(START); |
62 |
output_high(START); |
66 |
delay_us(1); |
63 |
delay_us(1); |
Line 79... |
Line 76... |
79 |
output_high(STOP1); |
76 |
output_high(STOP1); |
80 |
delay_us(10); |
77 |
delay_us(10); |
81 |
output_low(STOP1); |
78 |
output_low(STOP1); |
82 |
|
79 |
|
83 |
delay_ms(100); |
80 |
delay_ms(100); |
84 |
printf("status: %LX \n", TDC_get_status()); |
81 |
printf("status: %LX \r\n", TDC_get_status()); |
85 |
delay_ms(50); |
82 |
delay_ms(50); |
86 |
printf("measured: %LX, %LX, %LX, %LX \n", TDC_get_measurement(1), TDC_get_measurement(2), TDC_get_measurement(3), TDC_get_measurement(4)); |
83 |
printf("measured: %LX, %LX, %LX, %LX \r\n", TDC_get_measurement(1), TDC_get_measurement(2), TDC_get_measurement(3), TDC_get_measurement(4)); |
87 |
delay_ms(500); |
84 |
delay_ms(500); |
88 |
|
85 |
|
89 |
}; |
86 |
}; |
90 |
} |
87 |
} |