Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Commit 3bc6ce3

Browse files
committed
fixed I2C 2 (PIN20-PIN21)
1 parent aa38338 commit 3bc6ce3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

cores/arduino/Wire.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,23 @@ void TwoWire::begin(void)
9393
else if(twi == HAL_I2C2)
9494
{
9595
/* Enable GPIO TX/RX clock */
96-
__HAL_RCC_GPIOB_CLK_ENABLE();
96+
__HAL_RCC_GPIOH_CLK_ENABLE();
9797

9898
/* Enable I2Cx clock */
99-
__HAL_RCC_I2C1_CLK_ENABLE();
99+
__HAL_RCC_I2C2_CLK_ENABLE();
100100

101101
/* I2C SCL GPIO pin configuration */
102-
GPIO_InitStruct.Pin = GPIO_PIN_6;
102+
GPIO_InitStruct.Pin = GPIO_PIN_4;
103103
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
104104
GPIO_InitStruct.Pull = GPIO_PULLUP;
105105
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
106-
GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
107-
HAL_GPIO_Init(HAL_GPIOB, &GPIO_InitStruct);
106+
GPIO_InitStruct.Alternate = GPIO_AF4_I2C2;
107+
HAL_GPIO_Init(HAL_GPIOH, &GPIO_InitStruct);
108108

109109
/* I2C SDA GPIO pin configuration */
110-
GPIO_InitStruct.Pin = GPIO_PIN_7;
111-
GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
112-
HAL_GPIO_Init(HAL_GPIOB, &GPIO_InitStruct);
110+
GPIO_InitStruct.Pin = GPIO_PIN_5;
111+
GPIO_InitStruct.Alternate = GPIO_AF4_I2C2;
112+
HAL_GPIO_Init(HAL_GPIOH, &GPIO_InitStruct);
113113

114114
HAL_NVIC_SetPriority(I2C2_ER_IRQn, 0, 1);
115115
HAL_NVIC_EnableIRQ(I2C2_ER_IRQn);

0 commit comments

Comments
 (0)