Line 1... |
Line 1... |
1 |
#define VERSION "0.1" |
1 |
#define VERSION "0.1" |
2 |
#define ID "$Id: main.c 2916 2013-04-14 17:42:03Z kaklik $" |
2 |
#define ID "$Id: main.c 2916 2013-04-14 17:42:03Z kaklik $" |
3 |
|
3 |
|
4 |
#include "main.h" |
4 |
#include "main.h" |
5 |
|
5 |
|
6 |
#use i2c(master, sda=PIN_B0, scl=PIN_B1) |
6 |
#use i2c(master, sda=PIN_C4, scl=PIN_C3) |
7 |
#use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8) //rcv TXD xmit RXD |
7 |
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8) //rcv TXD xmit RXD |
8 |
|
8 |
|
9 |
#define MPL3115_ADDR_R 0xC1 //addresa pro cteni |
9 |
#define MPL3115_ADDR_R 0xC1 //addresa pro cteni |
10 |
#define MPL3115_ADDR_W 0xC0 |
10 |
#define MPL3115_ADDR_W 0xC0 |
11 |
|
11 |
|
12 |
|
12 |
|
Line 117... |
Line 117... |
117 |
|
117 |
|
118 |
void main() |
118 |
void main() |
119 |
{ |
119 |
{ |
120 |
|
120 |
|
121 |
float p, t, a; |
121 |
float p, t, a; |
122 |
printf("Tlakomer nebo vyskomer \r\n",); |
122 |
printf("\r\nMLAB Barometer and Altimeter demo code \r\n",); |
- |
|
123 |
printf("Temperature [deg C] Preassure [Pa] Altitude [m] \r\n",); |
123 |
|
124 |
|
124 |
while(TRUE) |
125 |
while(TRUE) |
125 |
{ |
126 |
{ |
126 |
mpl3115_setP(); //nastaveni pro tlak a teplotu |
127 |
mpl3115_setP(); //nastaveni pro tlak a teplotu |
127 |
delay_ms (500); |
128 |
delay_ms (500); |
Line 130... |
Line 131... |
130 |
|
131 |
|
131 |
mpl3115_setA(); //nastaveni pro vysku a teplotu |
132 |
mpl3115_setA(); //nastaveni pro vysku a teplotu |
132 |
delay_ms (500); |
133 |
delay_ms (500); |
133 |
a=mpl3115_A(); |
134 |
a=mpl3115_A(); |
134 |
|
135 |
|
135 |
|
- |
|
136 |
printf("Teplota: %1.4f\r\n", t); |
136 |
printf("%3.1f %6.1f %5.2f \r\n", t, p, a); |
137 |
printf("Tlak: %10.4f(Pa)\r\n", p); |
- |
|
138 |
printf("Výka: %10.4f(m)\r\n", a); |
- |
|
139 |
|
137 |
|
140 |
delay_ms (1000); |
138 |
delay_ms (1000); |
141 |
} |
139 |
} |
142 |
} |
140 |
} |
143 |
|
141 |
|