Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
pca95xx.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Gautier Hattenberger <gautier.hattenberger@enac.fr>
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, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
27 #ifndef PCA95XX_H
28 #define PCA95XX_H
29 
30 #include "std.h"
31 #include "mcu_periph/i2c.h"
32 
33 #define PCA95XX_DEFAULT_ADDRESS 0x40
34 
35 #define PCA95XX_INPUT_REG (0x00)
36 #define PCA95XX_OUTPUT_REG (0x01)
37 #define PCA95XX_POL_REG (0x02)
38 #define PCA95XX_CONFIG_REG (0x03)
39 
40 #define PCA95XX_P0 (1 << 0)
41 #define PCA95XX_P1 (1 << 1)
42 #define PCA95XX_P2 (1 << 2)
43 #define PCA95XX_P3 (1 << 3)
44 #define PCA95XX_P4 (1 << 4)
45 #define PCA95XX_P5 (1 << 5)
46 #define PCA95XX_P6 (1 << 6)
47 #define PCA95XX_P7 (1 << 7)
48 
49 #define PCA95XX_CLEAR_ALL 0x00
50 
53 struct pca95xx {
54  struct i2c_periph *i2c_p;
56 };
57 
63 extern void pca95xx_init(struct pca95xx *dev, struct i2c_periph *i2c_p, uint8_t addr);
64 
71 extern bool pca95xx_configure(struct pca95xx *dev, uint8_t val, bool blocking);
72 
79 extern bool pca95xx_set_output(struct pca95xx *dev, uint8_t mask, bool blocking);
80 
88 extern bool pca95xx_get_input(struct pca95xx *dev, uint8_t mask, uint8_t *result);
89 
90 #endif
91 
pca95xx::i2c_p
struct i2c_periph * i2c_p
Definition: pca95xx.h:54
val
uint16_t val[TCOUPLE_NB]
Definition: temp_tcouple_adc.c:49
pca95xx_set_output
bool pca95xx_set_output(struct pca95xx *dev, uint8_t mask, bool blocking)
Set output value.
Definition: pca95xx.c:60
std.h
dev
static const struct usb_device_descriptor dev
Definition: usb_ser_hw.c:74
uint8_t
unsigned char uint8_t
Definition: types.h:14
blocking
static const bool blocking[]
Definition: gpio_ext_pca95xx.c:94
i2c_transaction
I2C transaction structure.
Definition: i2c.h:93
pca95xx_configure
bool pca95xx_configure(struct pca95xx *dev, uint8_t val, bool blocking)
Configure PCA95XX.
Definition: pca95xx.c:42
pca95xx::i2c_trans
struct i2c_transaction i2c_trans
Definition: pca95xx.h:55
i2c_periph
Definition: i2c.h:144
i2c.h
pca95xx_get_input
bool pca95xx_get_input(struct pca95xx *dev, uint8_t mask, uint8_t *result)
Get input value.
Definition: pca95xx.c:78
pca95xx_init
void pca95xx_init(struct pca95xx *dev, struct i2c_periph *i2c_p, uint8_t addr)
Init PCA95XX.
Definition: pca95xx.c:30
pca95xx
PCA95XX structure.
Definition: pca95xx.h:53