* fix mbedtls bad pointer in function call (prototype mismatch) * fix issue with weak families functions implemented in static library, it will never be linked. fixed by redefining prototypes inside families * [ln882x] add support for lightning ln882x & ln882h families * add i2c (wire) support * add analog (adc) support * add watchdog support * [ln882x] changed default uart 0/1 pins; added board wl2s * [ln882x] fix IRQ & ADC pins * [ln882x] boards cosmetic * [ln882x] wifi sta use otp mac addr by default; re-enabled wifi powersave mode * [ln882x] clang-format clean code * [ln882x] clang-format clean code * Update families.json * Apply suggestions from code review * [ln882x] reformat json board files * [ln882x] os_queue cleanup * [ln882x] removed Beken auto-download command * [ln882x] removed personal script file * [ln882x] removed unusefull pi section in debugging.md * [ln882x] removed Arduino.h and changed private I2C definition * [ln882x] updated README.md * [ln882x] changed pin naming scheme to PA/PB * [ln882x] clean code * [ln882x] clean code * [ln882x] add ota image verification * Update push-dev.yml * [ln882x] fix boards ADC missing inputs] * [ln882x] removed reg_xxx fixup files and use include guards instead * [ln882x] cleanup code * [ln882x] cleanup code * [ln882x] fix lt_init weak functions linking * [ln882x] revert lt_api.h modification, fixed with previous commit * [ln882x] setup UF2 firmware for flasher with partitions * [ln882x] update README.md * [ln882x] include ln_wifi.h and ln_serial.h to avoid including bad headers on case insensitive systems * [ln882x] Replace RingBuffer by SerialRingBuffer * [ln882x] clang-format * [ln882x] update README.md * Apply suggestions from code review * Reformat board JSON files * Add mkdocs link redirect * Update ltchiptool to v4.12.0 --------- Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>
67 lines
1.3 KiB
C++
67 lines
1.3 KiB
C++
/* Copyright (c) Etienne Le Cousin 2025-01-19. */
|
|
|
|
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
#include <HardwareI2C.h>
|
|
#include <api/RingBuffer.h>
|
|
|
|
#define Wire1 Wire
|
|
|
|
#define WIRE_HAS_END 1
|
|
#define WIRE_DEFAULT_FREQ 100000
|
|
|
|
#ifndef I2C_PRIV
|
|
#define I2C_PRIV void
|
|
#endif
|
|
|
|
using arduino::RingBuffer;
|
|
|
|
class TwoWire : public HardwareI2C {
|
|
private:
|
|
I2C_PRIV *_i2c = NULL;
|
|
|
|
RingBuffer _rxBuf;
|
|
RingBuffer _txBuf;
|
|
uint8_t _txAddr = 0;
|
|
bool _inSetPins = false;
|
|
|
|
public:
|
|
TwoWire();
|
|
TwoWire(int8_t sda, int8_t scl);
|
|
~TwoWire();
|
|
|
|
bool setPins(int8_t sda, int8_t scl);
|
|
|
|
bool begin(int8_t sda, int8_t scl, uint32_t frequency = 0);
|
|
bool begin(uint8_t address, int8_t sda, int8_t scl, uint32_t frequency = 0);
|
|
bool end();
|
|
|
|
bool setClock(uint32_t freq);
|
|
|
|
void beginTransmission(uint8_t address);
|
|
uint8_t endTransmission(bool stopBit);
|
|
|
|
size_t requestFrom(uint8_t address, size_t len, bool stopBit);
|
|
size_t write(uint8_t data);
|
|
size_t write(const uint8_t *data, size_t len);
|
|
|
|
int available();
|
|
int read();
|
|
int peek();
|
|
void flush();
|
|
|
|
using HardwareI2C::begin;
|
|
using HardwareI2C::endTransmission;
|
|
using HardwareI2C::requestFrom;
|
|
using HardwareI2C::write;
|
|
using Print::write;
|
|
};
|
|
|
|
#ifdef PIN_WIRE0_SDA
|
|
extern TwoWire Wire;
|
|
#endif
|
|
#ifdef PIN_WIRE1_SDA
|
|
extern TwoWire Wire1;
|
|
#endif
|