From 2a27cb245a264d2ab128cb03211ebfd936ffd54a Mon Sep 17 00:00:00 2001 From: Alexandre Abadie <alexandre.abadie@inria.fr> Date: Thu, 8 Jun 2017 09:39:20 +0200 Subject: [PATCH] boards/nucleo-l073: add configuration for I2C periph --- boards/nucleo-l073/Makefile.features | 1 + boards/nucleo-l073/include/periph_conf.h | 45 ++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/boards/nucleo-l073/Makefile.features b/boards/nucleo-l073/Makefile.features index 58200e3051..bba9f6e210 100644 --- a/boards/nucleo-l073/Makefile.features +++ b/boards/nucleo-l073/Makefile.features @@ -2,6 +2,7 @@ FEATURES_PROVIDED += periph_cpuid FEATURES_PROVIDED += periph_gpio FEATURES_PROVIDED += periph_hwrng +FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_rtc FEATURES_PROVIDED += periph_spi diff --git a/boards/nucleo-l073/include/periph_conf.h b/boards/nucleo-l073/include/periph_conf.h index d8ee7c2b49..29e405f86f 100644 --- a/boards/nucleo-l073/include/periph_conf.h +++ b/boards/nucleo-l073/include/periph_conf.h @@ -189,6 +189,51 @@ static const spi_conf_t spi_config[] = { #define DAC_NUMOF (0) /** @} */ +/** + * @name I2C configuration + * @{ + */ +#define I2C_0_EN 1 +#define I2C_1_EN 1 +#define I2C_NUMOF (I2C_0_EN + I2C_1_EN) +#define I2C_IRQ_PRIO 1 +#define I2C_APBCLK (CLOCK_APB1) + +/* I2C 0 device configuration */ +#define I2C_0_DEV I2C1 +#define I2C_0_CLKEN() (periph_clk_en(APB1, RCC_APB1ENR_I2C1EN)) +#define I2C_0_CLKDIS() (periph_clk_dis(APB1, RCC_APB1ENR_I2C1EN)) +#define I2C_0_EVT_IRQ I2C1_IRQn +#define I2C_0_EVT_ISR isr_i2c1 +/* I2C 0 pin configuration */ +#define I2C_0_SCL_PORT PORT_B +#define I2C_0_SCL_PIN 8 +#define I2C_0_SCL_AF 4 +#define I2C_0_SCL_CLKEN() (periph_clk_en(AHB, RCC_IOPENR_GPIOBEN)) +#define I2C_0_SDA_PORT PORT_B +#define I2C_0_SDA_PIN 9 +#define I2C_0_SDA_AF 4 +#define I2C_0_SDA_CLKEN() (periph_clk_en(AHB, RCC_IOPENR_GPIOBEN)) + +/* I2C 1 device configuration */ +#define I2C_1_DEV I2C3 +#define I2C_1_CLKEN() (periph_clk_en(APB1, RCC_APB1ENR_I2C3EN)) +#define I2C_1_CLKDIS() (periph_clk_dis(APB1, RCC_APB1ENR_I2C3EN)) +#define I2C_1_EVT_IRQ I2C3_IRQn +#define I2C_1_EVT_ISR isr_i2c3 +/* I2C 1 pin configuration */ +#define I2C_1_SCL_PORT PORT_A +#define I2C_1_SCL_PIN 8 +#define I2C_1_SCL_AF 3 +#define I2C_1_SCL_CLKEN() (periph_clk_en(AHB, RCC_IOPENR_GPIOAEN)) +#define I2C_1_SDA_PORT PORT_B +#define I2C_1_SDA_PIN 5 +#define I2C_1_SDA_AF 8 +#define I2C_1_SDA_CLKEN() (periph_clk_en(AHB, RCC_IOPENR_GPIOBEN)) +/** @} */ + +/** @} */ + /** * @name RTC configuration * @{ -- GitLab