Skip to content

Commit 40f3876

Browse files
Add TWI_PINS_6_7 for Butterfly
1 parent c92cd49 commit 40f3876

File tree

7 files changed

+24
-2
lines changed

7 files changed

+24
-2
lines changed

libraries/Wire/src/Wire.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ void TwoWireEx::begin(TwoWireExPins pins)
444444
{
445445
_option = I2C_OPTION_RESET;
446446

447-
if (pins == TWI_PINS_42_43) {
447+
if (pins != TWI_PINS_20_21) {
448448
_option |= I2C_OPTION_ALTERNATE;
449449
}
450450

@@ -455,7 +455,7 @@ void TwoWireEx::begin(uint8_t address, TwoWireExPins pins)
455455
{
456456
_option = I2C_OPTION_RESET | (address << I2C_OPTION_ADDRESS_SHIFT);
457457

458-
if (pins == TWI_PINS_42_43) {
458+
if (pins != TWI_PINS_20_21) {
459459
_option |= I2C_OPTION_ALTERNATE;
460460
}
461461

libraries/Wire/src/Wire.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,13 @@ class TwoWire : public Stream
107107
friend class TwoWireEx;
108108
};
109109

110+
#if defined(STM32L433xx)
111+
enum TwoWireExPins { TWI_PINS_20_21 = 0, TWI_PINS_6_7 = 1 };
112+
#elif defined(STM32L476xx) || defined(STM32L496xx)
110113
enum TwoWireExPins { TWI_PINS_20_21 = 0, TWI_PINS_42_43 = 1 };
114+
#else
115+
enum TwoWireExPins { TWI_PINS_20_21 = 0 };
116+
#endif
111117

112118
class TwoWireEx : public TwoWire
113119
{
0 Bytes
Binary file not shown.
224 Bytes
Binary file not shown.
8 Bytes
Binary file not shown.
4 Bytes
Binary file not shown.

system/STM32L4xx/Source/stm32l4_i2c.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,14 @@ bool stm32l4_i2c_configure(stm32l4_i2c_t *i2c, uint32_t clock, uint32_t option)
914914
}
915915
#endif /* defined(STM32L476xx) */
916916

917+
#if defined(STM32L433xx)
918+
if ((i2c->option & I2C_OPTION_ALTERNATE) && (pin_scl == GPIO_PIN_PB6_I2C1_SCL) && (pin_sda == GPIO_PIN_PB7_I2C1_SDA))
919+
{
920+
pin_scl = GPIO_PIN_PB8_I2C1_SCL;
921+
pin_sda = GPIO_PIN_PB9_I2C1_SDA;
922+
}
923+
#endif /* defined(STM32L433xx) */
924+
917925
#if defined(STM32L476xx) || defined(STM32L496xx)
918926
if ((i2c->option & I2C_OPTION_ALTERNATE) && (pin_scl == GPIO_PIN_PB8_I2C1_SCL) && (pin_sda == GPIO_PIN_PB9_I2C1_SDA))
919927
{
@@ -1073,6 +1081,14 @@ bool stm32l4_i2c_reset(stm32l4_i2c_t *i2c)
10731081
pin_scl = i2c->pins.scl;
10741082
pin_sda = i2c->pins.sda;
10751083

1084+
#if defined(STM32L433xx)
1085+
if ((i2c->option & I2C_OPTION_ALTERNATE) && (pin_scl == GPIO_PIN_PB6_I2C1_SCL) && (pin_sda == GPIO_PIN_PB7_I2C1_SDA))
1086+
{
1087+
pin_scl = GPIO_PIN_PB8_I2C1_SCL;
1088+
pin_sda = GPIO_PIN_PB9_I2C1_SDA;
1089+
}
1090+
#endif /* defined(STM32L433xx) */
1091+
10761092
#if defined(STM32L476xx) || defined(STM32L496xx)
10771093
if ((i2c->option & I2C_OPTION_ALTERNATE) && (pin_scl == GPIO_PIN_PB8_I2C1_SCL) && (pin_sda == GPIO_PIN_PB9_I2C1_SDA))
10781094
{

0 commit comments

Comments
 (0)