Paparazzi UAS  v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
pca95x4.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 PCA95X4_H
28 #define PCA95X4_H
29 
30 #include "std.h"
31 #include "mcu_periph/i2c.h"
32 
33 #define PCA95X4_DEFAULT_ADDRESS 0x40
34 
35 #define PCA95X4_INPUT_REG (0x00)
36 #define PCA95X4_OUTPUT_REG (0x01)
37 #define PCA95X4_POL_REG (0x02)
38 #define PCA95X4_CONFIG_REG (0x03)
39 
40 #define PCA95X4_P0 (1 << 0)
41 #define PCA95X4_P1 (1 << 1)
42 #define PCA95X4_P2 (1 << 2)
43 #define PCA95X4_P3 (1 << 3)
44 #define PCA95X4_P4 (1 << 4)
45 #define PCA95X4_P5 (1 << 5)
46 #define PCA95X4_P6 (1 << 6)
47 #define PCA95X4_P7 (1 << 7)
48 
49 #define PCA95X4_CLEAR_ALL 0x00
50 
53 struct pca95x4 {
54  struct i2c_periph *i2c_p;
56 };
57 
63 extern void pca95x4_init(struct pca95x4 *dev, struct i2c_periph *i2c_p, uint8_t addr);
64 
71 extern bool pca95x4_configure(struct pca95x4 *dev, uint8_t val, bool blocking);
72 
79 extern bool pca95x4_set_output(struct pca95x4 *dev, uint8_t mask, bool blocking);
80 
81 #endif
82 
bool pca95x4_set_output(struct pca95x4 *dev, uint8_t mask, bool blocking)
Set output value.
Definition: pca95x4.c:60
PCA95X4 structure.
Definition: pca95x4.h:53
bool pca95x4_configure(struct pca95x4 *dev, uint8_t val, bool blocking)
Configure PCA95X4.
Definition: pca95x4.c:42
void pca95x4_init(struct pca95x4 *dev, struct i2c_periph *i2c_p, uint8_t addr)
Init PCA95X4.
Definition: pca95x4.c:30
struct i2c_transaction i2c_trans
Definition: pca95x4.h:55
uint16_t val[TCOUPLE_NB]
struct i2c_periph * i2c_p
Definition: pca95x4.h:54
I2C transaction structure.
Definition: i2c.h:93
static const struct usb_device_descriptor dev
Definition: usb_ser_hw.c:73
unsigned char uint8_t
Definition: types.h:14
Architecture independent I2C (Inter-Integrated Circuit Bus) API.