Skip to content

Commit

Permalink
boards/nucleo-f0xx: use common i2c configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
aabadie committed Jan 2, 2019
1 parent 541fc7f commit 24bc5ae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 50 deletions.
15 changes: 13 additions & 2 deletions boards/common/stm32/include/cfg_i2c1_pb8_pb9.h
Expand Up @@ -35,10 +35,15 @@ static const i2c_conf_t i2c_config[] = {
.speed = I2C_SPEED_NORMAL,
.scl_pin = GPIO_PIN(PORT_B, 8),
.sda_pin = GPIO_PIN(PORT_B, 9),
#if CPU_FAM_STM32F0
.scl_af = GPIO_AF1,
.sda_af = GPIO_AF1,
#else
.scl_af = GPIO_AF4,
.sda_af = GPIO_AF4,
#endif
.bus = APB1,
#if CPU_FAM_STM32F4
#if CPU_FAM_STM32F4 || CPU_FAM_STM32F2
.rcc_mask = RCC_APB1ENR_I2C1EN,
.clk = CLOCK_APB1,
.irqn = I2C1_EV_IRQn,
Expand All @@ -48,14 +53,20 @@ static const i2c_conf_t i2c_config[] = {
#elif CPU_FAM_STM32F7
.rcc_mask = RCC_APB1ENR_I2C1EN,
.irqn = I2C1_ER_IRQn,
#elif CPU_FAM_STM32F0
.rcc_mask = RCC_APB1ENR_I2C1EN,
.rcc_sw_mask = RCC_CFGR3_I2C1SW,
.irqn = I2C1_IRQn,
#endif
}
};

#if CPU_FAM_STM32F4
#if CPU_FAM_STM32F4 || CPU_FAM_STM32F2
#define I2C_0_ISR isr_i2c1_ev
#elif CPU_FAM_STM32L4 || CPU_FAM_STM32F7
#define I2C_0_ISR isr_i2c1_er
#elif CPU_FAM_STM32F0
#define I2C_0_ISR isr_i2c1
#endif

#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0]))
Expand Down
25 changes: 1 addition & 24 deletions boards/nucleo-f070rb/include/periph_conf.h
Expand Up @@ -24,6 +24,7 @@
#define PERIPH_CONF_H

#include "periph_cpu.h"
#include "cfg_i2c1_pb8_pb9.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -151,30 +152,6 @@ static const pwm_conf_t pwm_config[] = {
#define PWM_NUMOF (sizeof(pwm_config) / sizeof(pwm_config[0]))
/** @} */

/**
* @name I2C configuration
* @{
*/
static const i2c_conf_t i2c_config[] = {
{
.dev = I2C1,
.speed = I2C_SPEED_NORMAL,
.scl_pin = GPIO_PIN(PORT_B, 8),
.sda_pin = GPIO_PIN(PORT_B, 9),
.scl_af = GPIO_AF1,
.sda_af = GPIO_AF1,
.bus = APB1,
.rcc_mask = RCC_APB1ENR_I2C1EN,
.rcc_sw_mask = RCC_CFGR3_I2C1SW,
.irqn = I2C1_IRQn,
}
};

#define I2C_0_ISR isr_i2c1

#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0]))
/** @} */

/**
* @name ADC configuration
* @{
Expand Down
25 changes: 1 addition & 24 deletions boards/nucleo-f091rc/include/periph_conf.h
Expand Up @@ -22,6 +22,7 @@
#define PERIPH_CONF_H

#include "periph_cpu.h"
#include "cfg_i2c1_pb8_pb9.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -159,30 +160,6 @@ static const spi_conf_t spi_config[] = {
#define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
/** @} */

/**
* @name I2C configuration
* @{
*/
static const i2c_conf_t i2c_config[] = {
{
.dev = I2C1,
.speed = I2C_SPEED_NORMAL,
.scl_pin = GPIO_PIN(PORT_B, 8),
.sda_pin = GPIO_PIN(PORT_B, 9),
.scl_af = GPIO_AF1,
.sda_af = GPIO_AF1,
.bus = APB1,
.rcc_mask = RCC_APB1ENR_I2C1EN,
.rcc_sw_mask = RCC_CFGR3_I2C1SW,
.irqn = I2C1_IRQn,
}
};

#define I2C_0_ISR isr_i2c1

#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0]))
/** @} */

/**
* @name PWM configuration
* @{
Expand Down

0 comments on commit 24bc5ae

Please sign in to comment.