Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
pcf857x.h
Go to the documentation of this file.
1/*
2 * This file is part of the Ultibo project, https://ultibo.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2026 Garry Wood <garry@softoz.com.au>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26#ifndef _ULTIBO_PCF857X_H
27#define _ULTIBO_PCF857X_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include "ultibo/gpio.h"
34#include "ultibo/i2c.h"
35
37#define PCF8574_GPIO_DESCRIPTION "NXP PCF8574 8-bit I/O Expander"
38
39#define PCF8574_GPIO_MIN_PIN GPIO_PIN_0
40#define PCF8574_GPIO_MAX_PIN GPIO_PIN_7
41#define PCF8574_GPIO_PIN_COUNT 8
42
43#define PCF857X_GPIO_MAX_LEVEL GPIO_LEVEL_HIGH
44
45#define PCF857X_GPIO_MAX_PULL GPIO_PULL_UP
46
47#define PCF857X_GPIO_MIN_FUNCTION GPIO_FUNCTION_IN
48#define PCF857X_GPIO_MAX_FUNCTION GPIO_FUNCTION_OUT
49
51#define PCF857X_CHIP_PCF8574 0
52
54#define PCF8574_I2C_RATE 100000
55
56#define PCF8574_I2C_SIZE 1
57
58#define PCF857X_I2C_MAX_SIZE 2
59
61
65{
66 // GPIO Properties
68 // PCF857X Properties
70 uint16_t address;
71 uint32_t chip;
72 uint32_t size;
73 uint32_t rate;
77};
78
80
88
95
97
98#ifdef __cplusplus
99}
100#endif
101
102#endif // _ULTIBO_PCF857X_H
#define STDCALL
Definition globaltypes.h:45
struct _GPIO_DEVICE GPIO_DEVICE
Forward declared for GPIOPin.
Definition gpio.h:85
struct _I2C_DEVICE I2C_DEVICE
Definition i2c.h:81
uint32_t STDCALL pcf857xgpio_destroy(GPIO_DEVICE *gpio)
Stop, deregister and destroy a PCF857X GPIO device created by this driver.
#define PCF857X_I2C_MAX_SIZE
Maximum number of bytes to read/write all pin values.
Definition pcf857x.h:58
struct _PCF857XGPIO PCF857XGPIO
Definition pcf857x.h:63
GPIO_DEVICE *STDCALL pcf8574gpio_create(I2C_DEVICE *i2c, uint16_t address)
Create, register and start a new PCF8574 GPIO device connected to the specified I2C device.
Definition pcf857x.h:65
GPIO_DEVICE gpio
Definition pcf857x.h:67
I2C_DEVICE * i2c
The I2C device this GPIO is connected to.
Definition pcf857x.h:69
uint8_t gpiovalues[PCF857X_I2C_MAX_SIZE]
Buffer for GPIO port values (Output only).
Definition pcf857x.h:74
uint16_t address
The I2C address of the device.
Definition pcf857x.h:70
uint8_t gppuvalues[PCF857X_I2C_MAX_SIZE]
Buffer for GPPU pull up values.
Definition pcf857x.h:75
uint32_t rate
Clock rate for this device.
Definition pcf857x.h:73
uint8_t iodirvalues[PCF857X_I2C_MAX_SIZE]
Buffer for IODIR I/O direction values.
Definition pcf857x.h:76
uint32_t size
Size of an I2C read/write for the device.
Definition pcf857x.h:72
uint32_t chip
The chip type (eg PCF857X_CHIP_PCF8574).
Definition pcf857x.h:71