Skip to content

boards: nucleo_f103rb: enables I2C_1 and I2C_2 #12246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion boards/arm/nucleo_f103rb/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ config SPI_1
config SPI_2
default y

endif
endif # SPI

if I2C

config I2C_1
default y

endif # I2C

endif # BOARD_NUCLEO_F103RB
9 changes: 9 additions & 0 deletions boards/arm/nucleo_f103rb/nucleo_f103rb.dts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,13 @@ arduino_spi: &spi1 {

&idwg {
status = "ok";

arduino_i2c: &i2c1 {
status = "ok";
clock-frequency = <I2C_BITRATE_FAST>;
};

&i2c2 {
status = "ok";
clock-frequency = <I2C_BITRATE_FAST>;
};
13 changes: 13 additions & 0 deletions boards/arm/nucleo_f103rb/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <sys_io.h>

#include <pinmux/stm32/pinmux_stm32.h>
#include <stm32f1xx_ll_gpio.h>
#include <stm32f1xx_ll_bus.h>

/* pin assignments for NUCLEO-F103RB board */
static const struct pin_config pinconf[] = {
Expand Down Expand Up @@ -41,6 +43,10 @@ static const struct pin_config pinconf[] = {
{STM32_PIN_PB14, STM32F1_PINMUX_FUNC_PB14_SPI2_MASTER_MISO},
{STM32_PIN_PB15, STM32F1_PINMUX_FUNC_PB15_SPI2_MASTER_MOSI},
#endif /* CONFIG_SPI_2 */
#ifdef CONFIG_I2C_1
{STM32_PIN_PB8, STM32F1_PINMUX_FUNC_PB8_I2C1_SCL},
{STM32_PIN_PB9, STM32F1_PINMUX_FUNC_PB9_I2C1_SDA},
#endif /* CONFIG_I2C_1 */
};

static int pinmux_stm32_init(struct device *port)
Expand All @@ -49,6 +55,13 @@ static int pinmux_stm32_init(struct device *port)

stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf));

#ifdef CONFIG_I2C_1
/* AFIO clock needed for AF remap */
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_AFIO);
/* Remap I2C1 from PB6/PB7 to PB8/PB9 for Arduino pin compatibility */
LL_GPIO_AF_EnableRemap_I2C1();
#endif /* CONFIG_I2C_1 */

return 0;
}

Expand Down