Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
i2cgpio.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_I2CGPIO_H
27#define _ULTIBO_I2CGPIO_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include "ultibo/gpio.h"
34#include "ultibo/i2c.h"
35
37#define I2CGPIO_I2C_DESCRIPTION "GPIO Software I2C"
38
39#define I2CGPIO_I2C_MAX_SIZE 0xFFFF
40#define I2CGPIO_I2C_MIN_CLOCK 10000
41#define I2CGPIO_I2C_MAX_CLOCK 100000
42
43#define I2CGPIO_RETRY_COUNT 3
44
45#define I2CGPIO_DEFAULT_TIMEOUT 100
46
50{
51 // I2C Properties
53 // I2CGPIO Properties
55 uint32_t sda;
56 uint32_t scl;
57 uint32_t delay;
58 uint32_t timeout;
61 // Transfer Properties
63};
64
66I2C_DEVICE * STDCALL i2cgpio_create(GPIO_DEVICE *gpio, uint32_t sda, uint32_t scl, uint32_t delay, uint32_t timeout, BOOL outputonly, BOOL opendrain);
68
70
71#ifdef __cplusplus
72}
73#endif
74
75#endif // _ULTIBO_I2CGPIO_H
int32_t LONGBOOL
Compatibility with FPC LongBool type (4 bytes).
Definition globaltypes.h:56
#define STDCALL
Definition globaltypes.h:45
_Bool BOOL
Built in Boolean type (1 byte) (Redeclared here for flexibility).
Definition globaltypes.h:55
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 i2cgpio_destroy(I2C_DEVICE *i2c)
I2C_DEVICE *STDCALL i2cgpio_create(GPIO_DEVICE *gpio, uint32_t sda, uint32_t scl, uint32_t delay, uint32_t timeout, BOOL outputonly, BOOL opendrain)
struct _I2CGPIO_DEVICE I2CGPIO_DEVICE
Definition i2cgpio.h:48
Definition i2cgpio.h:50
GPIO_DEVICE * gpio
The GPIO device this device is connected to.
Definition i2cgpio.h:54
LONGBOOL opendrain
Clock and Data are open drain, no need to simulate by switching direction.
Definition i2cgpio.h:60
uint32_t sda
GPIO pin for the SDA line.
Definition i2cgpio.h:55
uint32_t delay
Clock and Data delay in microseconds.
Definition i2cgpio.h:57
uint32_t scl
GPIO pin for the SCL line.
Definition i2cgpio.h:56
I2C_DEVICE i2c
Definition i2cgpio.h:52
LONGBOOL ignorenak
If True Ignore NAK responses and continue.
Definition i2cgpio.h:62
uint32_t timeout
Clock timeout in milliseconds.
Definition i2cgpio.h:58
LONGBOOL outputonly
Clock line is output only, no test for SCL high.
Definition i2cgpio.h:59