boards/nucleo-f0xx: use common i2c configuration
This commit is contained in:
parent
541fc7f93f
commit
24bc5ae254
@ -35,10 +35,15 @@ static const i2c_conf_t i2c_config[] = {
|
|||||||
.speed = I2C_SPEED_NORMAL,
|
.speed = I2C_SPEED_NORMAL,
|
||||||
.scl_pin = GPIO_PIN(PORT_B, 8),
|
.scl_pin = GPIO_PIN(PORT_B, 8),
|
||||||
.sda_pin = GPIO_PIN(PORT_B, 9),
|
.sda_pin = GPIO_PIN(PORT_B, 9),
|
||||||
|
#if CPU_FAM_STM32F0
|
||||||
|
.scl_af = GPIO_AF1,
|
||||||
|
.sda_af = GPIO_AF1,
|
||||||
|
#else
|
||||||
.scl_af = GPIO_AF4,
|
.scl_af = GPIO_AF4,
|
||||||
.sda_af = GPIO_AF4,
|
.sda_af = GPIO_AF4,
|
||||||
|
#endif
|
||||||
.bus = APB1,
|
.bus = APB1,
|
||||||
#if CPU_FAM_STM32F4
|
#if CPU_FAM_STM32F4 || CPU_FAM_STM32F2
|
||||||
.rcc_mask = RCC_APB1ENR_I2C1EN,
|
.rcc_mask = RCC_APB1ENR_I2C1EN,
|
||||||
.clk = CLOCK_APB1,
|
.clk = CLOCK_APB1,
|
||||||
.irqn = I2C1_EV_IRQn,
|
.irqn = I2C1_EV_IRQn,
|
||||||
@ -48,14 +53,20 @@ static const i2c_conf_t i2c_config[] = {
|
|||||||
#elif CPU_FAM_STM32F7
|
#elif CPU_FAM_STM32F7
|
||||||
.rcc_mask = RCC_APB1ENR_I2C1EN,
|
.rcc_mask = RCC_APB1ENR_I2C1EN,
|
||||||
.irqn = I2C1_ER_IRQn,
|
.irqn = I2C1_ER_IRQn,
|
||||||
|
#elif CPU_FAM_STM32F0
|
||||||
|
.rcc_mask = RCC_APB1ENR_I2C1EN,
|
||||||
|
.rcc_sw_mask = RCC_CFGR3_I2C1SW,
|
||||||
|
.irqn = I2C1_IRQn,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if CPU_FAM_STM32F4
|
#if CPU_FAM_STM32F4 || CPU_FAM_STM32F2
|
||||||
#define I2C_0_ISR isr_i2c1_ev
|
#define I2C_0_ISR isr_i2c1_ev
|
||||||
#elif CPU_FAM_STM32L4 || CPU_FAM_STM32F7
|
#elif CPU_FAM_STM32L4 || CPU_FAM_STM32F7
|
||||||
#define I2C_0_ISR isr_i2c1_er
|
#define I2C_0_ISR isr_i2c1_er
|
||||||
|
#elif CPU_FAM_STM32F0
|
||||||
|
#define I2C_0_ISR isr_i2c1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0]))
|
#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0]))
|
||||||
|
|||||||
@ -24,6 +24,7 @@
|
|||||||
#define PERIPH_CONF_H
|
#define PERIPH_CONF_H
|
||||||
|
|
||||||
#include "periph_cpu.h"
|
#include "periph_cpu.h"
|
||||||
|
#include "cfg_i2c1_pb8_pb9.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -151,30 +152,6 @@ static const pwm_conf_t pwm_config[] = {
|
|||||||
#define PWM_NUMOF (sizeof(pwm_config) / sizeof(pwm_config[0]))
|
#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
|
* @name ADC configuration
|
||||||
* @{
|
* @{
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
#define PERIPH_CONF_H
|
#define PERIPH_CONF_H
|
||||||
|
|
||||||
#include "periph_cpu.h"
|
#include "periph_cpu.h"
|
||||||
|
#include "cfg_i2c1_pb8_pb9.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -159,30 +160,6 @@ static const spi_conf_t spi_config[] = {
|
|||||||
#define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
|
#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
|
* @name PWM configuration
|
||||||
* @{
|
* @{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user