Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ads1114.c
Go to the documentation of this file.
1  /*
2  * Copyright (C) 2010 ENAC
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
23 
24 /* driver for the ADC ads1114 (16 bits I2C 860SpS max) from Texas instruments
25  * Navarro & Gorraz & Hattenberger
26  */
27 
28 #include "peripherals/ads1114.h"
29 
30 #if USE_ADS1114_1
31 struct ads1114_periph ads1114_1;
32 #endif
33 #if USE_ADS1114_2
34 struct ads1114_periph ads1114_2;
35 #endif
36 
37 void ads1114_init( void ) {
38  /* configure the ads1114_1 */
39 #if USE_ADS1114_1
40  ads1114_1.i2c_addr = ADS1114_1_I2C_ADDR;
41  ads1114_1.trans.buf[0] = ADS1114_POINTER_CONFIG_REG;
42  ads1114_1.trans.buf[1] = ADS1114_1_CONFIG_MSB;
43  ads1114_1.trans.buf[2] = ADS1114_1_CONFIG_LSB;
45  ads1114_1.config_done = FALSE;
46  ads1114_1.data_available = FALSE;
47 #endif
48 
49  /* configure the ads1114_2 */
50 #if USE_ADS1114_2
51  ads1114_2.i2c_addr = ADS1114_2_I2C_ADDR;
52  ads1114_2.trans.buf[0] = ADS1114_POINTER_CONFIG_REG;
53  ads1114_2.trans.buf[1] = ADS1114_2_CONFIG_MSB;
54  ads1114_2.trans.buf[2] = ADS1114_2_CONFIG_LSB;
56  ads1114_2.config_done = FALSE;
57  ads1114_2.data_available = FALSE;
58 #endif
59 }
60 
61 
62 void ads1114_read( struct ads1114_periph * p ) {
63  // Config done with success
64  // start new reading when previous is done (and read if success)
65  if (p->config_done && p->trans.status == I2CTransDone) {
68  }
69 }
70 
71 
#define ADS1114_1_I2C_ADDR
Definition: ads1114.h:36
#define ADS1114_2_I2C_ADDR
Definition: ads1114.h:39
#define I2CTransmit(_p, _t, _s_addr, _len)
Definition: i2c.h:148
#define ADS1114_2_CONFIG_LSB
Definition: ads1114.h:108
#define ADS1114_POINTER_CONFIG_REG
Definition: ads1114.h:44
#define ADS1114_2_CONFIG_MSB
Definition: ads1114.h:107
bool_t config_done
Definition: ads1114.h:119
void ads1114_read(struct ads1114_periph *p)
Definition: ads1114.c:62
#define FALSE
Definition: imu_chimu.h:141
void ads1114_init(void)
Definition: ads1114.c:37
uint8_t i2c_addr
Definition: ads1114.h:118
enum I2CTransactionStatus status
Definition: i2c.h:47
struct i2c_transaction trans
Definition: ads1114.h:117
#define ADS1114_1_CONFIG_LSB
Definition: ads1114.h:76
volatile uint8_t buf[I2C_BUF_LEN]
Definition: i2c.h:46
#define ADS1114_POINTER_CONV_REG
Definition: ads1114.h:43
#define I2CTransceive(_p, _t, _s_addr, _len_w, _len_r)
Definition: i2c.h:156
#define ADS1114_I2C_DEVICE
Definition: ads1114.h:113
#define ADS1114_1_CONFIG_MSB
Definition: ads1114.h:75