Rev 2778 Rev 3074
1 #include <main.h> 1 #include <main.h>
2   2  
3 /* 3 /*
4 MPL115A1 SDN - +3.3V (always power on) 4 MPL115A1 SDN - +3.3V (always power on)
5 MPL115A1 #CS - PIN_C2 5 MPL115A1 #CS - PIN_C2
6 MPL115A1 DOUT - PIN_C4 6 MPL115A1 DOUT - PIN_C4
7 MPL115A1 DIN - PIN_C5 7 MPL115A1 DIN - PIN_C5
8 MPL115A1 SCLK - PIN_C3 8 MPL115A1 SCLK - PIN_C3
9 MPL115A1 GND - GND 9 MPL115A1 GND - GND
10 MPL115A1 VDD - +3.3V 10 MPL115A1 VDD - +3.3V
11 */ 11 */
12   12  
13 #define CSN_SPI PIN_C2 13 #define CSN_SPI PIN_C2
14 #include "MPL115A1.c" 14 #include "MPL115A1.c"
15   15  
16 void main() 16 void main()
17 { 17 {
18 printf("Start \r\n"); 18 printf("Start \r\n");
19 setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_64); 19 setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_64);
20 output_high(CSN_SPI); 20 output_high(CSN_SPI);
21 delay_ms(100); 21 delay_ms(100);
22   22  
23 MPL_init(); // get correction coefficients from the sensor 23 MPL_init(); // get correction coefficients from the sensor
24   24  
25 while(true) 25 while(true)
26 { 26 {
27 printf("%f %f \r\n", MPL_get_pressure(), MPL_get_temperature()); 27 printf("%f %f \r\n", MPL_get_pressure(), MPL_get_temperature());
28 delay_ms(500); 28 delay_ms(500);
29 } 29 }
30 } 30 }