1045 |
jacho |
1 |
#include "C:\Users\Honza\Documents\pic\serio_tlak\pic\main.h" |
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
/**** Automatic weather station 01A ****/ |
|
|
6 |
#define VERSION "0.1" |
|
|
7 |
|
|
|
8 |
#define ID "$Id: main.c 2858 2013-03-22 16:04:13Z kaklik $" |
|
|
9 |
#include <string.h> |
|
|
10 |
#use rs232(baud=9600,parity=N,xmit=PIN_B7,rcv=PIN_B6,bits=8) //rcv TXD xmit RXD |
|
|
11 |
|
|
|
12 |
#CASE // Case sensitive compiler |
|
|
13 |
|
|
|
14 |
#define SEND_DELAY 50 // Time between two characters on RS232 |
|
|
15 |
|
|
|
16 |
#define CSN_SPI PIN_C2 // preassure sensor connection |
|
|
17 |
#include "..\MPL115A1.c" |
|
|
18 |
|
|
|
19 |
void welcome(void) // Welcome message |
|
|
20 |
{ |
|
|
21 |
char REV[50]=ID; // Buffer for concatenate of a version string |
|
|
22 |
|
|
|
23 |
if (REV[strlen(REV)-1]=='$') REV[strlen(REV)-1]=0; |
|
|
24 |
|
|
|
25 |
printf("# ver seq temp[mK] hum_temp[mK] hum[%%] "); |
|
|
26 |
printf("bar_temp[mK] pressure[hPa] Anemo[pls/s]check\r\n\r\n"); |
|
|
27 |
} |
|
|
28 |
|
|
|
29 |
void main() |
|
|
30 |
{ |
|
|
31 |
|
|
|
32 |
|
|
|
33 |
setup_oscillator(OSC_8MHZ); // pri prouziti bootloaderu neni treba nastavovat |
|
|
34 |
setup_wdt(WDT_2304MS); |
|
|
35 |
restart_wdt(); //---WDT |
|
|
36 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
|
|
37 |
setup_adc(ADC_CLOCK_DIV_2); |
|
|
38 |
setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1); |
|
|
39 |
// setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1);//|T1_CLK_OUT); |
|
|
40 |
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8); |
|
|
41 |
setup_timer_2(T2_DISABLED,0,1); |
|
|
42 |
setup_ccp1(CCP_OFF); |
|
|
43 |
setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard |
|
|
44 |
//setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_64); |
|
|
45 |
output_high(CSN_SPI); |
|
|
46 |
|
|
|
47 |
welcome(); // welcome print and device indentification |
|
|
48 |
|
|
|
49 |
restart_wdt(); //---WDT |
|
|
50 |
|
|
|
51 |
|
|
|
52 |
MPL_init(); // get correction coefficients from the sensor |
|
|
53 |
|
|
|
54 |
restart_wdt(); //---WDT |
|
|
55 |
while (TRUE) |
|
|
56 |
{ |
|
|
57 |
char output[8]; // Output buffer |
|
|
58 |
int8 j; // String pointer |
|
|
59 |
int8 check=0; // Checksum is calculated between '$' and '*' |
|
|
60 |
|
|
|
61 |
float barometer_temperature, barometer_pressure; |
|
|
62 |
|
|
|
63 |
delay_ms(1000); |
|
|
64 |
|
|
|
65 |
|
|
|
66 |
//barometer_temperature = (MPL_get_temperature() + 273.15)*100; |
|
|
67 |
//barometer_pressure = MPL_get_pressure() * 10.0; // conversion to hectopascals |
|
|
68 |
printf("%5.1f \0",barometer_pressure); |
|
|
69 |
} |
|
|
70 |
} |
|
|
71 |
|