forked from espressif/arduino-esp32
Update IDF to aaf1239 (#1539)
* fix sdmmc config * Fix warnings in EEPROM from @Curclamas * remove leftover TAG in EEPROM * Initial add of @stickbreaker i2c * Add log_n * fix warnings when log is off * i2c code clean up and reorganization * add flags to interrupt allocator * fix sdmmc config * Fix warnings in EEPROM from @Curclamas * remove leftover TAG in EEPROM * fix errors with latest IDF * fix debug optimization (#1365) incorrect optimization for debugging tick markers. * Fix some missing BT header * Change BTSerial log calls * Update BLE lib * Arduino-ESP32 release management scripted (#1515) * Calculate an absolute path for a custom partitions table (#1452) * * Arduino-ESP32 release management scripted (ready-to-merge) * * secure env for espressif/arduino-esp32 * * build tests enabled * gitter webhook enabled * * gitter room link fixed * better comment * * filepaths fixed * BT Serial adjustments * * don't run sketch builds & tests for tagged builds * Return false from WiFi.hostByName() if hostname is not resolved * Free BT Memory when BT is not used * WIFI_MODE_NULL is not supported anymore * Select some key examples to build with PlatformIO to save some time * Update BLE lib * Fixed BLE lib * Major WiFi overhaul - auto reconnect on connection loss now works - moved to event groups - some code clean up and procedure optimizations - new methods to get a more elaborate system ststus * Add cmake tests to travis * Add initial AsyncUDP * Add NetBIOS lib and fix CMake includes * Add Initial WebServer * Fix WebServer and examples * travis not quiting on build fail * Try different travis build * Update IDF to aaf1239 * Fix WPS Example * fix script permission and add some fail tests to sketch builder * Add missing space in WiFiClient::write(Stream &stream)
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
|
||||
Modified December 2014 by Ivan Grokhotkov (ivan@esp8266.com) - esp8266 support
|
||||
Modified April 2015 by Hrsto Gochkov (ficeto@ficeto.com) - alternative esp8266 support
|
||||
Modified November 2017 by Chuck Todd <stickbreaker on GitHub> to use ISR and increase stability.
|
||||
*/
|
||||
|
||||
#ifndef TwoWire_h
|
||||
@ -29,7 +30,10 @@
|
||||
#include "freertos/queue.h"
|
||||
#include "Stream.h"
|
||||
|
||||
#define STICKBREAKER V0.2.2
|
||||
#define I2C_BUFFER_LENGTH 128
|
||||
typedef void(*user_onRequest)(void);
|
||||
typedef void(*user_onReceive)(uint8_t*, int);
|
||||
|
||||
class TwoWire: public Stream
|
||||
{
|
||||
@ -42,28 +46,57 @@ protected:
|
||||
uint8_t rxBuffer[I2C_BUFFER_LENGTH];
|
||||
uint16_t rxIndex;
|
||||
uint16_t rxLength;
|
||||
uint16_t rxQueued; //@stickBreaker
|
||||
|
||||
uint8_t txBuffer[I2C_BUFFER_LENGTH];
|
||||
uint16_t txIndex;
|
||||
uint16_t txLength;
|
||||
uint8_t txAddress;
|
||||
uint16_t txAddress;
|
||||
uint16_t txQueued; //@stickbreaker
|
||||
|
||||
uint8_t transmitting;
|
||||
/* slave Mode, not yet Stickbreaker
|
||||
static user_onRequest uReq[2];
|
||||
static user_onReceive uRcv[2];
|
||||
void onRequestService(void);
|
||||
void onReceiveService(uint8_t*, int);
|
||||
*/
|
||||
i2c_err_t last_error; // @stickBreaker from esp32-hal-i2c.h
|
||||
uint16_t _timeOutMillis;
|
||||
|
||||
public:
|
||||
TwoWire(uint8_t bus_num);
|
||||
void begin(int sda=-1, int scl=-1, uint32_t frequency=100000);
|
||||
void setClock(uint32_t);
|
||||
void beginTransmission(uint8_t);
|
||||
void beginTransmission(int);
|
||||
uint8_t endTransmission(void);
|
||||
uint8_t endTransmission(uint8_t);
|
||||
size_t requestFrom(uint8_t address, size_t size, bool sendStop);
|
||||
~TwoWire();
|
||||
void begin(int sda=-1, int scl=-1, uint32_t frequency=0);
|
||||
|
||||
uint8_t requestFrom(uint8_t, uint8_t);
|
||||
uint8_t requestFrom(uint8_t, uint8_t, uint8_t);
|
||||
uint8_t requestFrom(int, int);
|
||||
uint8_t requestFrom(int, int, int);
|
||||
void setClock(uint32_t frequency); // change bus clock without initing hardware
|
||||
size_t getClock(); // current bus clock rate in hz
|
||||
|
||||
void setTimeOut(uint16_t timeOutMillis);
|
||||
uint16_t getTimeOut();
|
||||
|
||||
uint8_t lastError();
|
||||
char * getErrorText(uint8_t err);
|
||||
|
||||
//@stickBreaker for big blocks and ISR model
|
||||
i2c_err_t writeTransmission(uint16_t address, uint8_t* buff, uint16_t size, bool sendStop=true);
|
||||
i2c_err_t readTransmission(uint16_t address, uint8_t* buff, uint16_t size, bool sendStop=true, uint32_t *readCount=NULL);
|
||||
|
||||
void beginTransmission(uint16_t address);
|
||||
void beginTransmission(uint8_t address);
|
||||
void beginTransmission(int address);
|
||||
|
||||
uint8_t endTransmission(bool sendStop);
|
||||
uint8_t endTransmission(uint8_t sendStop);
|
||||
uint8_t endTransmission(void);
|
||||
|
||||
uint8_t requestFrom(uint16_t address, uint8_t size, bool sendStop);
|
||||
uint8_t requestFrom(uint16_t address, uint8_t size, uint8_t sendStop);
|
||||
uint8_t requestFrom(uint16_t address, uint8_t size);
|
||||
uint8_t requestFrom(uint8_t address, uint8_t size, uint8_t sendStop);
|
||||
uint8_t requestFrom(uint8_t address, uint8_t size);
|
||||
uint8_t requestFrom(int address, int size, int sendStop);
|
||||
uint8_t requestFrom(int address, int size);
|
||||
|
||||
size_t write(uint8_t);
|
||||
size_t write(const uint8_t *, size_t);
|
||||
@ -72,8 +105,6 @@ public:
|
||||
int peek(void);
|
||||
void flush(void);
|
||||
|
||||
void reset(void);
|
||||
|
||||
inline size_t write(const char * s)
|
||||
{
|
||||
return write((uint8_t*) s, strlen(s));
|
||||
@ -94,8 +125,19 @@ public:
|
||||
{
|
||||
return write((uint8_t)n);
|
||||
}
|
||||
|
||||
void onReceive( void (*)(int) );
|
||||
void onRequest( void (*)(void) );
|
||||
|
||||
void dumpInts();
|
||||
void dumpI2C();
|
||||
};
|
||||
|
||||
extern TwoWire Wire;
|
||||
|
||||
|
||||
/*
|
||||
V0.2.2 13APR2018 preserve custom SCL,SDA,Frequency when no parameters passed to begin()
|
||||
V0.2.1 15MAR2018 Hardware reset, Glitch prevention, adding destructor for second i2c testing
|
||||
*/
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user