Rev Author Line No. Line
2764 kaklik 1 #include <main.h>
2763 kaklik 2  
3 #define CSN_SPI PIN_C2
4 int8 address, uiTadc, data ;
5  
6  
7 // SPI mode definitions.
8 #define SPI_MODE_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)
9 #define SPI_MODE_1 (SPI_L_TO_H)
10 #define SPI_MODE_2 (SPI_H_TO_L)
11 #define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H)
12  
13  
14 void main()
15 {
16 printf("Start\n\r");
17  
18 setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_64);
19  
20 output_high(CSN_SPI);
21  
22 delay_ms(100);
23  
24 while(true)
25 {
26 data = 5; //just to be sure that the value is updated
27  
28 //Start temperature and pressure conversion
29 address = 0x24;
30 address &= 0x7F;
31  
32 output_low(CSN_SPI);
33 delay_ms(1);
34 spi_write(address);
35 delay_ms(1);
36 spi_write(0x00);
37 delay_ms(1);
38 output_high(CSN_SPI);
39 delay_ms(2);
40  
41  
42 // get MSB for Pressure
43 address = 0x00;
44 address |= 0x80;
45  
46 output_low(CSN_SPI);
47 delay_ms(1);
48 spi_write(address);
49 delay_ms(1);
50 data = spi_read(0x00);
51 delay_ms(1);
52 output_high(CSN_SPI);
53  
54 printf("%u\n\r", data);
55  
56 //uiTadc = (unsigned int) data << 8;
57 //printf("%u\n\r", uiTadc);
58  
59  
60 delay_ms(100);
61 }
62  
63 }