mirror of
https://github.com/xreef/PCF8574_library.git
synced 2024-08-30 18:12:18 +00:00
Add support for custom SERCOM interface of Arduino SAMD devices. Force SDA SCL to use GPIO numeration for STM32 bug (https://www.mischianti.org/forums/topic/compatible-with-stm32duino/).
This commit is contained in:
parent
77d04961ed
commit
de00a4e005
13
PCF8574.cpp
13
PCF8574.cpp
@ -53,7 +53,7 @@ PCF8574::PCF8574(uint8_t address, uint8_t interruptPin, void (*interruptFunctio
|
|||||||
_usingInterrupt = true;
|
_usingInterrupt = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(__AVR) && !defined(ARDUINO_ARCH_SAMD) && !defined(__STM32F1__) && !defined(TEENSYDUINO)
|
#if !defined(__AVR) && !defined(ARDUINO_ARCH_SAMD) && !defined(ARDUINO_ARCH_STM32) && !defined(TEENSYDUINO)
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param address: i2c address
|
* @param address: i2c address
|
||||||
@ -90,7 +90,7 @@ PCF8574::PCF8574(uint8_t address, uint8_t interruptPin, void (*interruptFunctio
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ESP32
|
#if defined(ESP32) || defined(ARDUINO_ARCH_SAMD)
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param address: i2c address
|
* @param address: i2c address
|
||||||
@ -115,7 +115,8 @@ PCF8574::PCF8574(uint8_t address, uint8_t interruptPin, void (*interruptFunctio
|
|||||||
_interruptFunction = interruptFunction;
|
_interruptFunction = interruptFunction;
|
||||||
_usingInterrupt = true;
|
_usingInterrupt = true;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
#if defined(ESP32)
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param address: i2c address
|
* @param address: i2c address
|
||||||
@ -185,10 +186,14 @@ PCF8574::PCF8574(uint8_t address, uint8_t interruptPin, void (*interruptFunctio
|
|||||||
*/
|
*/
|
||||||
bool PCF8574::begin(){
|
bool PCF8574::begin(){
|
||||||
this->transmissionStatus = 4;
|
this->transmissionStatus = 4;
|
||||||
#if !defined(__AVR) && !defined(ARDUINO_ARCH_SAMD) && !defined(__STM32F1__) && !defined(TEENSYDUINO)
|
#if !defined(__AVR) && !defined(ARDUINO_ARCH_SAMD) && !defined(ARDUINO_ARCH_STM32) && !defined(TEENSYDUINO)
|
||||||
DEBUG_PRINT(F("begin(sda, scl) -> "));DEBUG_PRINT(_sda);DEBUG_PRINT(F(" "));DEBUG_PRINTLN(_scl);
|
DEBUG_PRINT(F("begin(sda, scl) -> "));DEBUG_PRINT(_sda);DEBUG_PRINT(F(" "));DEBUG_PRINTLN(_scl);
|
||||||
// _wire->begin(_sda, _scl);
|
// _wire->begin(_sda, _scl);
|
||||||
|
#ifdef ARDUINO_ARCH_STM32
|
||||||
|
_wire->begin((uint32_t)_sda, (uint32_t)_scl);
|
||||||
|
#else
|
||||||
_wire->begin((int)_sda, (int)_scl);
|
_wire->begin((int)_sda, (int)_scl);
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
// Default pin for AVR some problem on software emulation
|
// Default pin for AVR some problem on software emulation
|
||||||
// #define SCL_PIN _scl
|
// #define SCL_PIN _scl
|
||||||
|
15
PCF8574.h
15
PCF8574.h
@ -2,7 +2,7 @@
|
|||||||
* PCF8574 GPIO Port Expand
|
* PCF8574 GPIO Port Expand
|
||||||
*
|
*
|
||||||
* AUTHOR: Renzo Mischianti
|
* AUTHOR: Renzo Mischianti
|
||||||
* VERSION: 2.3.3
|
* VERSION: 2.3.4
|
||||||
*
|
*
|
||||||
* https://www.mischianti.org/2019/01/02/pcf8574-i2c-digital-i-o-expander-fast-easy-usage/
|
* https://www.mischianti.org/2019/01/02/pcf8574-i2c-digital-i-o-expander-fast-easy-usage/
|
||||||
*
|
*
|
||||||
@ -109,17 +109,18 @@ public:
|
|||||||
PCF8574(uint8_t address);
|
PCF8574(uint8_t address);
|
||||||
PCF8574(uint8_t address, uint8_t interruptPin, void (*interruptFunction)() );
|
PCF8574(uint8_t address, uint8_t interruptPin, void (*interruptFunction)() );
|
||||||
|
|
||||||
#if !defined(__AVR) && !defined(ARDUINO_ARCH_SAMD) && !defined(__STM32F1__) && !defined(TEENSYDUINO)
|
#if !defined(__AVR) && !defined(ARDUINO_ARCH_SAMD) && !defined(ARDUINO_ARCH_STM32) && !defined(TEENSYDUINO)
|
||||||
PCF8574(uint8_t address, int sda, int scl);
|
PCF8574(uint8_t address, int sda, int scl);
|
||||||
PCF8574(uint8_t address, int sda, int scl, uint8_t interruptPin, void (*interruptFunction)());
|
PCF8574(uint8_t address, int sda, int scl, uint8_t interruptPin, void (*interruptFunction)());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ESP32
|
#if defined(ESP32) || defined(ARDUINO_ARCH_SAMD)
|
||||||
///// changes for second i2c bus
|
///// changes for second i2c bus
|
||||||
PCF8574(TwoWire *pWire, uint8_t address);
|
PCF8574(TwoWire *pWire, uint8_t address);
|
||||||
PCF8574(TwoWire *pWire, uint8_t address, int sda, int scl);
|
|
||||||
|
|
||||||
PCF8574(TwoWire *pWire, uint8_t address, uint8_t interruptPin, void (*interruptFunction)() );
|
PCF8574(TwoWire *pWire, uint8_t address, uint8_t interruptPin, void (*interruptFunction)() );
|
||||||
|
#endif
|
||||||
|
#if defined(ESP32)
|
||||||
|
PCF8574(TwoWire *pWire, uint8_t address, int sda, int scl);
|
||||||
PCF8574(TwoWire *pWire, uint8_t address, int sda, int scl, uint8_t interruptPin, void (*interruptFunction)());
|
PCF8574(TwoWire *pWire, uint8_t address, int sda, int scl, uint8_t interruptPin, void (*interruptFunction)());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -201,7 +202,7 @@ private:
|
|||||||
uint8_t _address;
|
uint8_t _address;
|
||||||
|
|
||||||
#if !defined(DEFAULT_SDA)
|
#if !defined(DEFAULT_SDA)
|
||||||
# if defined(__STM32F1__)
|
# if defined(ARDUINO_ARCH_STM32)
|
||||||
# define DEFAULT_SDA PB7
|
# define DEFAULT_SDA PB7
|
||||||
# elif defined(ESP8266)
|
# elif defined(ESP8266)
|
||||||
# define DEFAULT_SDA 4
|
# define DEFAULT_SDA 4
|
||||||
@ -212,7 +213,7 @@ private:
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#if !defined(DEFAULT_SCL)
|
#if !defined(DEFAULT_SCL)
|
||||||
# if defined(__STM32F1__)
|
# if defined(ARDUINO_ARCH_STM32)
|
||||||
# define DEFAULT_SCL PB6
|
# define DEFAULT_SCL PB6
|
||||||
# elif defined(ESP8266)
|
# elif defined(ESP8266)
|
||||||
# define DEFAULT_SCL 5
|
# define DEFAULT_SCL 5
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* PCF8574 GPIO Port Expand
|
* PCF8574 GPIO Port Expand
|
||||||
*
|
*
|
||||||
* AUTHOR: Renzo Mischianti
|
* AUTHOR: Renzo Mischianti
|
||||||
* VERSION: 2.3.3
|
* VERSION: 2.3.4
|
||||||
*
|
*
|
||||||
* https://www.mischianti.org/2019/01/02/pcf8574-i2c-digital-i-o-expander-fast-easy-usage/
|
* https://www.mischianti.org/2019/01/02/pcf8574-i2c-digital-i-o-expander-fast-easy-usage/
|
||||||
*
|
*
|
||||||
|
@ -29,6 +29,7 @@ Tutorial:
|
|||||||
To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder PCF8574. Check that the PCF8574 folder contains `PCF8574\\.cpp` and `PCF8574.h`. Place the DHT library folder your `<arduinosketchfolder>/libraries/` folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.
|
To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder PCF8574. Check that the PCF8574 folder contains `PCF8574\\.cpp` and `PCF8574.h`. Place the DHT library folder your `<arduinosketchfolder>/libraries/` folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
10/08/2022: v2.3.4 Add support for custom SERCOM interface of Arduino SAMD devices. Force SDA SCL to use GPIO numeration for STM32 bug (https://www.mischianti.org/forums/topic/compatible-with-stm32duino/).
|
||||||
28/07/2022: v2.3.3 Force SDA SCL to use GPIO numeration (https://www.mischianti.org/forums/topic/cannot-set-sda-clk-on-esp8266/).
|
28/07/2022: v2.3.3 Force SDA SCL to use GPIO numeration (https://www.mischianti.org/forums/topic/cannot-set-sda-clk-on-esp8266/).
|
||||||
28/07/2022: v2.3.2 Fix the SDA SCL type #58 and add basic support for SAMD device.
|
28/07/2022: v2.3.2 Fix the SDA SCL type #58 and add basic support for SAMD device.
|
||||||
26/04/2022: v2.3.1 Fix example for esp32 and double begin issue #56.
|
26/04/2022: v2.3.1 Fix example for esp32 and double begin issue #56.
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "PCF8574 library",
|
"name": "PCF8574 library",
|
||||||
"version": "2.3.3",
|
"version": "2.3.4",
|
||||||
"keywords": "digital, i2c, encoder, expander, pcf8574, pcf8574a, esp32, esp8266, stm32, SAMD, Arduino, wire",
|
"keywords": "digital, i2c, encoder, expander, pcf8574, pcf8574a, esp32, esp8266, stm32, SAMD, Arduino, wire",
|
||||||
"description": "i2c digital expander for Arduino, esp32, SMT32 and ESP8266. Can read write digital values with only 2 wire. Very simple to use and encoder support.",
|
"description": "Most starred PCF8574 library. i2c digital expander for Arduino, esp32, SMT32 and ESP8266. Can read write digital values with only 2 wire. Very simple to use and encoder support.",
|
||||||
"homepage": "https://www.mischianti.org/category/my-libraries/pcf8574/",
|
"homepage": "https://www.mischianti.org/category/my-libraries/pcf8574/",
|
||||||
"authors":
|
"authors":
|
||||||
[
|
[
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
name=PCF8574 library
|
name=PCF8574 library
|
||||||
version=2.3.3
|
version=2.3.4
|
||||||
author=Renzo Mischianti <renzo.mischianti@gmail.com>
|
author=Renzo Mischianti <renzo.mischianti@gmail.com>
|
||||||
maintainer=Renzo Mischianti <renzo.mischianti@gmail.com>
|
maintainer=Renzo Mischianti <renzo.mischianti@gmail.com>
|
||||||
sentence=PCF8574, library for Arduino, ESP8266, smt32 and esp32
|
sentence=Most starred PCF8574 library for Arduino (standard and SAMD), ESP8266, smt32 and esp32
|
||||||
paragraph=i2c digital expander for Arduino, esp32, SMT32 and ESP8266. Can read write digital values with only 2 wire. Very simple to use and encoder support.
|
paragraph=Most starred PCF8574 library. i2c digital expander for Arduino (standard and SAMD), esp32, SMT32 and ESP8266. Can read write digital values with only 2 wire. Very simple to use and encoder support.
|
||||||
category=Sensors
|
category=Sensors
|
||||||
url=https://www.mischianti.org/category/my-libraries/pcf8574/
|
url=https://www.mischianti.org/category/my-libraries/pcf8574/
|
||||||
repository=https://github.com/xreef/PCF8574_library
|
repository=https://github.com/xreef/PCF8574_library
|
||||||
|
Loading…
Reference in New Issue
Block a user