Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules 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 "subsystems/abi.h"
13 #include "led.h"
14 
15 #include "mcu_periph/uart.h"
16 #include "messages.h"
18 
19 #ifndef SENSOR_SYNC_SEND
20 #warning set SENSOR_SYNC_SEND to use baro_scp_i2c
21 #endif
22 
23 
27 
29 
30 #ifndef SCP_I2C_DEV
31 #define SCP_I2C_DEV i2c0
32 #endif
33 
34 #define SCP1000_SLAVE_ADDR 0x22
35 
37 {
38  /* switch to high resolution */
42 }
43 
44 void baro_scp_init(void)
45 {
47 }
48 
50 {
51 
53 
56  } else if (baro_scp_status == BARO_SCP_IDLE) {
57 
58  /* init: start two byte temperature */
62  }
63 }
64 
65 void baro_scp_event(void)
66 {
67 
69 
71 
72  /* read two byte temperature */
75  if (baro_scp_temperature & 0x2000) {
76  baro_scp_temperature |= 0xC000;
77  }
79 
80  /* start one byte msb pressure */
84  }
85 
87 
88  /* read one byte pressure */
89  baro_scp_pressure = scp_trans.buf[0] << 16;
90 
91  /* start two byte lsb pressure */
95  }
96 
98 
99  /* read two byte pressure */
100  baro_scp_pressure |= scp_trans.buf[0] << 8;
102  baro_scp_pressure *= 25;
103 
104  float pressure = (float) baro_scp_pressure;
105  AbiSendMsgBARO_ABS(BARO_SCP_SENDER_ID, pressure);
106 #ifdef SENSOR_SYNC_SEND
108 #endif
109 
111  }
112 
113  else { baro_scp_status = BARO_SCP_IDLE; }
114  }
115 }
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:65
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
Definition: i2c.h:122
void baro_scp_periodic(void)
Definition: baro_scp_i2c.c:49
transaction successfully finished by I2C driver
Definition: i2c.h:57
void baro_scp_init(void)
Definition: baro_scp_i2c.c:44
#define BARO_SCP_RD_TEMP
Definition: baro_scp_i2c.h:19
Main include for ABI (AirBorneInterface).
uint16_t baro_scp_temperature
Definition: baro_scp_i2c.c:26
#define BARO_SCP_RD_PRESS_1
Definition: baro_scp_i2c.h:21
#define SCP1000_TEMPOUT
Definition: baro_scp_i2c.h:15
#define BARO_SCP_RD_PRESS_0
Definition: baro_scp_i2c.h:20
bool_t i2c_transceive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len_w, uint16_t len_r)
Submit a write/read transaction.
Definition: i2c.c:278
uint32_t baro_scp_pressure
Definition: baro_scp_i2c.c:25
#define BARO_SCP_SENDER_ID
#define BARO_SCP_UNINIT
Definition: baro_scp_i2c.h:17
#define SCP1000_DATARD8
Definition: baro_scp_i2c.h:13
Architecture independent timing functions.
bool_t i2c_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction.
Definition: i2c.c:258
unsigned long uint32_t
Definition: types.h:18
static void baro_scp_start_high_res_measurement(void)
Definition: baro_scp_i2c.c:36
#define SCP1000_OPERATION
Definition: baro_scp_i2c.h:6
uint8_t baro_scp_status
Definition: baro_scp_i2c.c:24
I2C transaction structure.
Definition: i2c.h:93
enum I2CTransactionStatus status
Transaction status.
Definition: i2c.h:126
unsigned char uint8_t
Definition: types.h:14
volatile uint32_t nb_sec
full seconds since startup
Definition: sys_time.h:69
#define SCP_I2C_DEV
Definition: baro_scp_i2c.c:31
arch independent LED (Light Emitting Diodes) API
#define SCP1000_SLAVE_ADDR
Definition: baro_scp_i2c.c:34
#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:28
Architecture independent I2C (Inter-Integrated Circuit Bus) API.