diff --git a/boards/common/iotlab/include/periph_conf_common.h b/boards/common/iotlab/include/periph_conf_common.h index b69ee112faa1646548966385f8806e53b0e27fea..406a38a7e8b957a8dbda7054bcff37c8ea98d995 100644 --- a/boards/common/iotlab/include/periph_conf_common.h +++ b/boards/common/iotlab/include/periph_conf_common.h @@ -143,22 +143,22 @@ static const uart_conf_t uart_config[] = { * @name I2C configuration * @{ */ -#define I2C_NUMOF (1U) -#define I2C_0_EN 1 -#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_EV_IRQn -#define I2C_0_EVT_ISR isr_i2c1_ev -#define I2C_0_ERR_IRQ I2C1_ER_IRQn -#define I2C_0_ERR_ISR isr_i2c1_er -/* I2C 0 pin configuration */ -#define I2C_0_SCL_PIN GPIO_PIN(PORT_B,6) -#define I2C_0_SDA_PIN GPIO_PIN(PORT_B,7) +static const i2c_conf_t i2c_config[] = { + { + .dev = I2C1, + .speed = I2C_SPEED_NORMAL, + .scl_pin = GPIO_PIN(PORT_B, 6), + .sda_pin = GPIO_PIN(PORT_B, 7), + .bus = APB1, + .rcc_mask = RCC_APB1ENR_I2C1EN, + .clk = CLOCK_APB1, + .irqn = I2C1_EV_IRQn + } +}; + +#define I2C_0_ISR isr_i2c1_ev + +#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0])) /** @} */ /** diff --git a/boards/common/stm32f103c8/include/periph_conf.h b/boards/common/stm32f103c8/include/periph_conf.h index 08bfaedaba69438ea294f90f2cebf428df10ba0c..bbd0119b41a3d877ba58f94818583bcea1b23a8e 100644 --- a/boards/common/stm32f103c8/include/periph_conf.h +++ b/boards/common/stm32f103c8/include/periph_conf.h @@ -158,35 +158,33 @@ static const uart_conf_t uart_config[] = { * @name I2C configuration * @{ */ -#define I2C_NUMOF (2U) -#define I2C_0_EN 1 -#define I2C_1_EN 0 /* Disabled by default since pins collide with USART3. */ -#define I2C_IRQ_PRIO 1 -#define I2C_APBCLK (CLOCK_APB1) +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), + .bus = APB1, + .rcc_mask = RCC_APB1ENR_I2C1EN, + .clk = CLOCK_APB1, + .irqn = I2C1_EV_IRQn + }, + { + .dev = I2C2, + .speed = I2C_SPEED_NORMAL, + .scl_pin = GPIO_PIN(PORT_B, 10), + .sda_pin = GPIO_PIN(PORT_B, 11), + .bus = APB1, + .rcc_mask = RCC_APB1ENR_I2C2EN, + .clk = CLOCK_APB1, + .irqn = I2C2_EV_IRQn + } +}; -/* 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_EV_IRQn -#define I2C_0_EVT_ISR isr_i2c1_ev -#define I2C_0_ERR_IRQ I2C1_ER_IRQn -#define I2C_0_ERR_ISR isr_i2c1_er -/* I2C 0 pin configuration */ -#define I2C_0_SCL_PIN GPIO_PIN(PORT_B, 6) -#define I2C_0_SDA_PIN GPIO_PIN(PORT_B, 7) +#define I2C_0_ISR isr_i2c1_ev +#define I2C_1_ISR isr_i2c2_ev -/* I2C 1 device configuration */ -#define I2C_1_DEV I2C2 -#define I2C_1_CLKEN() (periph_clk_en(APB1, RCC_APB1ENR_I2C2EN)) -#define I2C_1_CLKDIS() (periph_clk_dis(APB1, RCC_APB1ENR_I2C2EN)) -#define I2C_1_EVT_IRQ I2C2_EV_IRQn -#define I2C_1_EVT_ISR isr_i2c2_ev -#define I2C_1_ERR_IRQ I2C2_ER_IRQn -#define I2C_1_ERR_ISR isr_i2c2_er -/* I2C 1 pin configuration */ -#define I2C_1_SCL_PIN GPIO_PIN(PORT_B, 10) -#define I2C_1_SDA_PIN GPIO_PIN(PORT_B, 11) +#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0])) /** @} */ /** diff --git a/boards/fox/include/periph_conf.h b/boards/fox/include/periph_conf.h index b3e120db273234bf1c7e56d0a69ee9f29fd219c9..524761ba9627012969b559231c9e28ad12683d6c 100644 --- a/boards/fox/include/periph_conf.h +++ b/boards/fox/include/periph_conf.h @@ -180,22 +180,22 @@ static const spi_conf_t spi_config[] = { * @name I2C configuration * @{ */ -#define I2C_NUMOF (1U) -#define I2C_0_EN 1 -#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_EV_IRQn -#define I2C_0_EVT_ISR isr_i2c1_ev -#define I2C_0_ERR_IRQ I2C1_ER_IRQn -#define I2C_0_ERR_ISR isr_i2c1_er -/* I2C 0 pin configuration */ -#define I2C_0_SCL_PIN GPIO_PIN(PORT_B,6) -#define I2C_0_SDA_PIN GPIO_PIN(PORT_B,7) +static const i2c_conf_t i2c_config[] = { + { + .dev = I2C1, + .speed = I2C_SPEED_NORMAL, + .scl_pin = GPIO_PIN(PORT_B, 6), + .sda_pin = GPIO_PIN(PORT_B, 7), + .bus = APB1, + .rcc_mask = RCC_APB1ENR_I2C1EN, + .clk = CLOCK_APB1, + .irqn = I2C1_EV_IRQn + } +}; + +#define I2C_0_ISR isr_i2c1_ev + +#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0])) /** @} */ #ifdef __cplusplus diff --git a/boards/maple-mini/include/periph_conf.h b/boards/maple-mini/include/periph_conf.h index 8e3e413897f13c3ac51399a96c7ce0561f4501f7..e9780929e2d99be7df00f3e9ee8346bf8bbbfbbf 100644 --- a/boards/maple-mini/include/periph_conf.h +++ b/boards/maple-mini/include/periph_conf.h @@ -135,35 +135,33 @@ static const uart_conf_t uart_config[] = { * @name I2C configuration * @{ */ -#define I2C_NUMOF (2U) -#define I2C_0_EN 1 -#define I2C_1_EN 0 -#define I2C_IRQ_PRIO 1 -#define I2C_APBCLK (CLOCK_APB1) - -/* I2C 0 device configuration */ -#define I2C_0_DEV I2C1 -#define I2C_0_CLKEN() (RCC->APB1ENR |= RCC_APB1ENR_I2C1EN) -#define I2C_0_CLKDIS() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C1EN)) -#define I2C_0_EVT_IRQ I2C1_EV_IRQn -#define I2C_0_EVT_ISR isr_i2c1_ev -#define I2C_0_ERR_IRQ I2C1_ER_IRQn -#define I2C_0_ERR_ISR isr_i2c1_er -/* I2C 0 pin configuration */ -#define I2C_0_SCL_PIN GPIO_PIN(PORT_B, 6) /* D15 */ -#define I2C_0_SDA_PIN GPIO_PIN(PORT_B, 7) /* D16 */ - -/* I2C 1 device configuration */ -#define I2C_1_DEV I2C2 -#define I2C_1_CLKEN() (RCC->APB1ENR |= RCC_APB1ENR_I2C2EN) -#define I2C_1_CLKDIS() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C2EN)) -#define I2C_1_EVT_IRQ I2C2_EV_IRQn -#define I2C_1_EVT_ISR isr_i2c2_ev -#define I2C_1_ERR_IRQ I2C2_ER_IRQn -#define I2C_1_ERR_ISR isr_i2c2_er -/* I2C 1 pin configuration */ -#define I2C_1_SCL_PIN GPIO_PIN(PORT_B, 10) /* D1 */ -#define I2C_1_SDA_PIN GPIO_PIN(PORT_B, 11) /* D0 */ +static const i2c_conf_t i2c_config[] = { + { + .dev = I2C1, + .speed = I2C_SPEED_NORMAL, + .scl_pin = GPIO_PIN(PORT_B, 8), /* D15 */ + .sda_pin = GPIO_PIN(PORT_B, 9), /* D16 */ + .bus = APB1, + .rcc_mask = RCC_APB1ENR_I2C1EN, + .clk = CLOCK_APB1, + .irqn = I2C1_EV_IRQn + }, + { + .dev = I2C2, + .speed = I2C_SPEED_NORMAL, + .scl_pin = GPIO_PIN(PORT_B, 10), /* D1 */ + .sda_pin = GPIO_PIN(PORT_B, 11), /* D0 */ + .bus = APB1, + .rcc_mask = RCC_APB1ENR_I2C2EN, + .clk = CLOCK_APB1, + .irqn = I2C2_EV_IRQn + } +}; + +#define I2C_0_ISR isr_i2c1_ev +#define I2C_1_ISR isr_i2c2_ev + +#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0])) /** @} */ /** diff --git a/boards/nucleo-f103rb/include/periph_conf.h b/boards/nucleo-f103rb/include/periph_conf.h index 78b0ea4ac766795dc40bd605becdaf6dbd7fcb96..3863bfbed59a93986efc252ae2047955ce99bd74 100644 --- a/boards/nucleo-f103rb/include/periph_conf.h +++ b/boards/nucleo-f103rb/include/periph_conf.h @@ -147,35 +147,33 @@ static const uart_conf_t uart_config[] = { * @name I2C configuration * @{ */ -#define I2C_NUMOF (2U) -#define I2C_0_EN 1 -#define I2C_1_EN 0 -#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_EV_IRQn -#define I2C_0_EVT_ISR isr_i2c1_ev -#define I2C_0_ERR_IRQ I2C1_ER_IRQn -#define I2C_0_ERR_ISR isr_i2c1_er -/* I2C 0 pin configuration */ -#define I2C_0_SCL_PIN GPIO_PIN(PORT_B, 8) /* remapped */ -#define I2C_0_SDA_PIN GPIO_PIN(PORT_B, 9) /* remapped */ - -/* I2C 1 device configuration */ -#define I2C_1_DEV I2C2 -#define I2C_1_CLKEN() (periph_clk_en(APB1, RCC_APB1ENR_I2C2EN)) -#define I2C_1_CLKDIS() (periph_clk_dis(APB1, RCC_APB1ENR_I2C2EN)) -#define I2C_1_EVT_IRQ I2C2_EV_IRQn -#define I2C_1_EVT_ISR isr_i2c2_ev -#define I2C_1_ERR_IRQ I2C2_ER_IRQn -#define I2C_1_ERR_ISR isr_i2c2_er -/* I2C 1 pin configuration */ -#define I2C_1_SCL_PIN GPIO_PIN(PORT_B, 10) -#define I2C_1_SDA_PIN GPIO_PIN(PORT_B, 11) +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), + .bus = APB1, + .rcc_mask = RCC_APB1ENR_I2C1EN, + .clk = CLOCK_APB1, + .irqn = I2C1_EV_IRQn + }, + { + .dev = I2C2, + .speed = I2C_SPEED_NORMAL, + .scl_pin = GPIO_PIN(PORT_B, 10), + .sda_pin = GPIO_PIN(PORT_B, 11), + .bus = APB1, + .rcc_mask = RCC_APB1ENR_I2C2EN, + .clk = CLOCK_APB1, + .irqn = I2C2_EV_IRQn + } +}; + +#define I2C_0_ISR isr_i2c1_ev +#define I2C_1_ISR isr_i2c2_ev + +#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0])) /** @} */ /**