DeterministicESPAsyncWebServer
v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
i2c.h
Go to the documentation of this file.
1
// Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2
// SPDX-License-Identifier: AGPL-3.0-or-later
3
4
/**
5
* @file i2c.h
6
* @brief The one owner of the shared I2C bus bring-up for the peripheral drivers.
7
*
8
* The sensor / peripheral drivers (RTC, SHT3x, MPR121, ADS1115, INA219, PCA9685) all share a
9
* single I2C bus, so they all initialize it through detws_i2c_begin() rather than calling
10
* Wire.begin() themselves. That gives one place to choose the pins: DETWS_I2C_SDA_PIN /
11
* DETWS_I2C_SCL_PIN (default -1 = the platform default GPIO 21 / 22). Move them off 21/22 when
12
* those pins are needed elsewhere - most importantly a wired-Ethernet PHY: the LAN8720 RMII on
13
* the classic ESP32 (WROOM/WROVER) and the ESP32-P4 uses GPIO 21 and 22 (the S3/C3 have no RMII
14
* EMAC and use an SPI Ethernet such as the W5500 instead). Re-begin is idempotent, so per-driver
15
* calls are harmless.
16
*
17
* Host builds compile this to nothing (there is no Wire); the I2C transfer is ESP32-only.
18
*
19
* @author Douglas Quigg (dstroy0)
20
* @date 2026
21
*/
22
23
#ifndef DETERMINISTICESPASYNCWEBSERVER_DET_I2C_H
24
#define DETERMINISTICESPASYNCWEBSERVER_DET_I2C_H
25
26
#include "
ServerConfig.h
"
27
28
#if defined(ARDUINO)
29
30
#include <Wire.h>
31
32
/** @brief Bring up the shared I2C bus on DETWS_I2C_SDA_PIN / DETWS_I2C_SCL_PIN (-1 = default). */
33
inline
void
detws_i2c_begin
()
34
{
35
Wire.begin((
int
)
DETWS_I2C_SDA_PIN
, (
int
)
DETWS_I2C_SCL_PIN
);
36
}
37
38
#endif
// ARDUINO
39
40
#endif
// DETERMINISTICESPASYNCWEBSERVER_DET_I2C_H
ServerConfig.h
User-facing configuration for DeterministicESPAsyncWebServer.
DETWS_I2C_SCL_PIN
#define DETWS_I2C_SCL_PIN
Definition
ServerConfig.h:2379
DETWS_I2C_SDA_PIN
#define DETWS_I2C_SDA_PIN
Shared I2C bus pins for the sensor / peripheral drivers (RTC, SHT3x, MPR121, ADS1115,...
Definition
ServerConfig.h:2376
detws_i2c_begin
void detws_i2c_begin()
Bring up the shared I2C bus on DETWS_I2C_SDA_PIN / DETWS_I2C_SCL_PIN (-1 = default).
Definition
i2c.h:33
src
services
i2c.h
Generated by
1.9.8