openMMC
Open Source Modular MMC for AMCs
Loading...
Searching...
No Matches
pca9554.h
Go to the documentation of this file.
1/*
2 * openMMC -- Open Source modular IPM Controller firmware
3 *
4 * Copyright (C) 2015 Henrique Silva <henrique.silva@lnls.br>
5 *
6 * This program 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 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>
20 */
21
31#ifndef PCA9554_H_
32#define PCA9554_H_
33
49#define PCA9554_INPUT_REG 0
50
55#define PCA9554_OUTPUT_REG 1
56
61#define PCA9554_POLARITY_REG 2
62
67#define PCA9554_CFG_REG 3
68
73/* Pins Read/Write */
82uint8_t pca9554_read_port( uint8_t chip_id, uint8_t *readout );
83
93uint8_t pca9554_read_pin( uint8_t chip_id, uint8_t pin, uint8_t *status );
94
103uint8_t pca9554_write_port( uint8_t chip_id, uint8_t data );
104
114uint8_t pca9554_write_pin( uint8_t chip_id, uint8_t pin, bool data );
115
116/* Polarity Control */
125uint8_t pca9554_set_port_pol( uint8_t chip_id, uint8_t pol );
126
136uint8_t pca9554_set_pin_pol( uint8_t chip_id, uint8_t pin, bool pol );
137
146uint8_t pca9554_get_port_pol( uint8_t chip_id, uint8_t *pol );
147
157uint8_t pca9554_get_pin_pol( uint8_t chip_id, uint8_t pin, uint8_t *pol );
158
159/* Pins direction (output/input) */
168uint8_t pca9554_set_port_dir( uint8_t chip_id, uint8_t dir );
169
179uint8_t pca9554_set_pin_dir( uint8_t chip_id, uint8_t pin, bool dir );
180
189uint8_t pca9554_get_port_dir( uint8_t chip_id, uint8_t *dir );
190
200uint8_t pca9554_get_pin_dir( uint8_t chip_id, uint8_t pin, uint8_t *dir );
201
202#endif
uint8_t pca9554_write_port(uint8_t chip_id, uint8_t data)
Write all output pins.
Definition pca9554.c:109
uint8_t pca9554_read_pin(uint8_t chip_id, uint8_t pin, uint8_t *status)
Read a pin status.
Definition pca9554.c:96
uint8_t pca9554_get_port_pol(uint8_t chip_id, uint8_t *pol)
Read all pins polarity.
Definition pca9554.c:142
uint8_t pca9554_set_pin_pol(uint8_t chip_id, uint8_t pin, bool pol)
Set pin polarity.
Definition pca9554.c:131
uint8_t pca9554_get_pin_dir(uint8_t chip_id, uint8_t pin, uint8_t *dir)
Read pin direction.
Definition pca9554.c:181
uint8_t pca9554_set_pin_dir(uint8_t chip_id, uint8_t pin, bool dir)
Set pin direction.
Definition pca9554.c:165
uint8_t pca9554_write_pin(uint8_t chip_id, uint8_t pin, bool data)
Write a output pin.
Definition pca9554.c:114
uint8_t pca9554_set_port_dir(uint8_t chip_id, uint8_t dir)
Set all pins direction.
Definition pca9554.c:160
uint8_t pca9554_set_port_pol(uint8_t chip_id, uint8_t pol)
Set all pins polarity.
Definition pca9554.c:126
uint8_t pca9554_read_port(uint8_t chip_id, uint8_t *readout)
Read all pins status.
Definition pca9554.c:91
uint8_t pca9554_get_port_dir(uint8_t chip_id, uint8_t *dir)
Read all pins direction.
Definition pca9554.c:176
uint8_t pca9554_get_pin_pol(uint8_t chip_id, uint8_t pin, uint8_t *pol)
Read pin polarity.
Definition pca9554.c:147