Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures 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  /* switch to high resolution */
41 }
42 
43 void baro_scp_init( void ) {
45 }
46 
47 void baro_scp_periodic( void ) {
48 
50 
53  } else if (baro_scp_status == BARO_SCP_IDLE) {
54 
55  /* init: start two byte temperature */
59  }
60 }
61 
62 void baro_scp_event( void ) {
63 
65 
67 
68  /* read two byte temperature */
71  if (baro_scp_temperature & 0x2000) {
72  baro_scp_temperature |= 0xC000;
73  }
75 
76  /* start one byte msb pressure */
80  }
81 
83 
84  /* read one byte pressure */
85  baro_scp_pressure = scp_trans.buf[0] << 16;
86 
87  /* start two byte lsb pressure */
91  }
92 
94 
95  /* read two byte pressure */
96  baro_scp_pressure |= scp_trans.buf[0] << 8;
98  baro_scp_pressure *= 25;
99 
100  float pressure = (float) baro_scp_pressure;
101  AbiSendMsgBARO_ABS(BARO_SCP_SENDER_ID, &pressure);
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:62
void baro_scp_periodic(void)
Definition: baro_scp_i2c.c:47
transaction successfully finished by I2C driver
Definition: i2c.h:57
void baro_scp_init(void)
Definition: baro_scp_i2c.c:43
I2C transaction structure.
Definition: i2c.h:93
#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:258
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:238
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
enum I2CTransactionStatus status
Transaction status.
Definition: i2c.h:126
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
Definition: i2c.h:122
unsigned char uint8_t
Definition: types.h:14
#define SCP_I2C_DEV
Definition: baro_scp_i2c.c:31
volatile uint32_t nb_sec
full seconds since startup
Definition: sys_time.h:69
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.