Line 18... |
Line 18... |
18 |
#include "..\SHT.c" |
18 |
#include "..\SHT.c" |
19 |
|
19 |
|
20 |
#define CSN_SPI PIN_C2 // preassure sensor connection |
20 |
#define CSN_SPI PIN_C2 // preassure sensor connection |
21 |
#include "..\MPL115A1.c" |
21 |
#include "..\MPL115A1.c" |
22 |
|
22 |
|
- |
|
23 |
unsigned int16 timer0_overflow_count=0; |
- |
|
24 |
float anemo=0; |
- |
|
25 |
|
- |
|
26 |
|
- |
|
27 |
#int_TIMER1 |
- |
|
28 |
void TIMER1_isr(void) |
- |
|
29 |
{ |
- |
|
30 |
output_toggle(PIN_D1); |
- |
|
31 |
anemo = ((timer0_overflow_count * 0xFF) + get_timer0())/(32768.0/0xFFFF); |
- |
|
32 |
} |
- |
|
33 |
|
- |
|
34 |
#int_TIMER0 |
- |
|
35 |
void TIMER0_isr(void) |
- |
|
36 |
{ |
- |
|
37 |
timer0_overflow_count++; |
- |
|
38 |
} |
- |
|
39 |
|
- |
|
40 |
|
- |
|
41 |
|
23 |
void welcome(void) // Welcome message |
42 |
void welcome(void) // Welcome message |
24 |
{ |
43 |
{ |
25 |
char REV[50]=ID; // Buffer for concatenate of a version string |
44 |
char REV[50]=ID; // Buffer for concatenate of a version string |
26 |
|
45 |
|
27 |
if (REV[strlen(REV)-1]=='$') REV[strlen(REV)-1]=0; |
46 |
if (REV[strlen(REV)-1]=='$') REV[strlen(REV)-1]=0; |
Line 43... |
Line 62... |
43 |
{ |
62 |
{ |
44 |
unsigned int16 seq=0; |
63 |
unsigned int16 seq=0; |
45 |
|
64 |
|
46 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
65 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
47 |
setup_adc(ADC_CLOCK_DIV_2); |
66 |
setup_adc(ADC_CLOCK_DIV_2); |
48 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
67 |
setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1); |
49 |
setup_timer_1(T1_DISABLED); |
68 |
setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1|T1_CLK_OUT); |
50 |
setup_timer_2(T2_DISABLED,0,1); |
69 |
setup_timer_2(T2_DISABLED,0,1); |
51 |
setup_ccp1(CCP_OFF); |
70 |
setup_ccp1(CCP_OFF); |
52 |
setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard |
71 |
setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard |
53 |
setup_oscillator(OSC_8MHZ); |
72 |
setup_oscillator(OSC_8MHZ); |
- |
|
73 |
setup_wdt(WDT_1152MS|WDT_DIV_16); |
54 |
setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_64); |
74 |
setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_64); |
55 |
output_high(CSN_SPI); |
75 |
output_high(CSN_SPI); |
- |
|
76 |
enable_interrupts(INT_TIMER1); |
- |
|
77 |
enable_interrupts(INT_TIMER0); |
- |
|
78 |
enable_interrupts(GLOBAL); |
- |
|
79 |
|
- |
|
80 |
|
56 |
delay_ms(100); |
81 |
delay_ms(100); |
57 |
|
82 |
|
58 |
welcome(); |
83 |
welcome(); |
59 |
|
84 |
|
60 |
sht_init(); |
85 |
sht_init(); |
Line 93... |
Line 118... |
93 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
118 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
94 |
sprintf(output,"%f \0", barometer_temperature); |
119 |
sprintf(output,"%f \0", barometer_temperature); |
95 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
120 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
96 |
sprintf(output,"%5.1f \0", barometer_pressure); |
121 |
sprintf(output,"%5.1f \0", barometer_pressure); |
97 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
122 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
- |
|
123 |
sprintf(output,"%3.1f \0", anemo); |
- |
|
124 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
98 |
sprintf(output,"*%X\r\n\0", check); |
125 |
sprintf(output,"*%X\r\n\0", check); |
99 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j++]); } |
126 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j++]); } |
100 |
delay_us(SEND_DELAY); |
127 |
delay_us(SEND_DELAY); |
101 |
} |
128 |
} |
102 |
|
129 |
|