Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
baro_scp_i2c.c
Go to the documentation of this file.
1 
8 #include "baro_scp_i2c.h"
9 
10 #include "mcu_periph/sys_time.h"
11 #include "mcu_periph/i2c.h"
12 #include "led.h"
13 
14 #include "mcu_periph/uart.h"
15 #include "messages.h"
17 
18 #ifndef SENSOR_SYNC_SEND
19 #warning set SENSOR_SYNC_SEND to use baro_scp_i2c
20 #endif
21 
22 #ifndef DOWNLINK_DEVICE
23 #define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
24 #endif
25 
29 
31 
32 #ifndef SCP_I2C_DEV
33 #define SCP_I2C_DEV i2c0
34 #endif
35 
36 #define SCP1000_SLAVE_ADDR 0x22
37 
39  /* switch to high resolution */
43 }
44 
45 void baro_scp_init( void ) {
47 }
48 
49 void baro_scp_periodic( void ) {
50 
52 
55  } else if (baro_scp_status == BARO_SCP_IDLE) {
56 
57  /* init: start two byte temperature */
61  }
62 }
63 
64 void baro_scp_event( void ) {
65 
67 
69 
70  /* read two byte temperature */
73  if (baro_scp_temperature & 0x2000) {
74  baro_scp_temperature |= 0xC000;
75  }
77 
78  /* start one byte msb pressure */
82  }
83 
85 
86  /* read one byte pressure */
87  baro_scp_pressure = scp_trans.buf[0] << 16;
88 
89  /* start two byte lsb pressure */
93  }
94 
96 
97  /* read two byte pressure */
98  baro_scp_pressure |= scp_trans.buf[0] << 8;
100  baro_scp_pressure *= 25;
101 
102 #ifdef SENSOR_SYNC_SEND
104 #endif
105 
107  }
108 
110  }
111 }
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
#define SCP1000_DATARD16
Definition: baro_scp_i2c.h:14
void baro_scp_event(void)
Definition: baro_scp_i2c.c:64
void baro_scp_periodic(void)
Definition: baro_scp_i2c.c:49
void baro_scp_init(void)
Definition: baro_scp_i2c.c:45
#define I2CTransmit(_p, _t, _s_addr, _len)
Definition: i2c.h:148
#define BARO_SCP_RD_TEMP
Definition: baro_scp_i2c.h:19
uint16_t baro_scp_temperature
Definition: baro_scp_i2c.c:28
#define BARO_SCP_RD_PRESS_1
Definition: baro_scp_i2c.h:21
#define cpu_time_sec
Definition: sys_time.h:64
#define SCP1000_TEMPOUT
Definition: baro_scp_i2c.h:15
#define BARO_SCP_RD_PRESS_0
Definition: baro_scp_i2c.h:20
uint32_t baro_scp_pressure
Definition: baro_scp_i2c.c:27
#define BARO_SCP_UNINIT
Definition: baro_scp_i2c.h:17
#define SCP1000_DATARD8
Definition: baro_scp_i2c.h:13
Architecture independent timing functions.
unsigned long uint32_t
Definition: types.h:18
static void baro_scp_start_high_res_measurement(void)
Definition: baro_scp_i2c.c:38
#define SCP1000_OPERATION
Definition: baro_scp_i2c.h:6
uint8_t baro_scp_status
Definition: baro_scp_i2c.c:26
enum I2CTransactionStatus status
Definition: i2c.h:47
volatile uint8_t buf[I2C_BUF_LEN]
Definition: i2c.h:46
unsigned char uint8_t
Definition: types.h:14
#define I2CTransceive(_p, _t, _s_addr, _len_w, _len_r)
Definition: i2c.h:156
#define SCP_I2C_DEV
Definition: baro_scp_i2c.c:33
arch independent LED (Light Emitting Diodes) API
#define SCP1000_SLAVE_ADDR
Definition: baro_scp_i2c.c:36
#define BARO_SCP_IDLE
Definition: baro_scp_i2c.h:18
#define SCP1000_HIGH_RES
Definition: baro_scp_i2c.h:9
struct i2c_transaction scp_trans
Definition: baro_scp_i2c.c:30