cfg_i2c1_pb8_pb9.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Inria
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
19 #ifndef CFG_I2C1_PB8_PB9_H
20 #define CFG_I2C1_PB8_PB9_H
21 
22 #include "periph_cpu.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
32 static const i2c_conf_t i2c_config[] = {
33  {
34  .dev = I2C1,
35  .speed = I2C_SPEED_NORMAL,
36  .scl_pin = GPIO_PIN(PORT_B, 8),
37  .sda_pin = GPIO_PIN(PORT_B, 9),
38 #if CPU_FAM_STM32F0
39  .scl_af = GPIO_AF1,
40  .sda_af = GPIO_AF1,
41 #elif CPU_FAM_STM32G0
42  .scl_af = GPIO_AF6,
43  .sda_af = GPIO_AF6,
44 #else
45  .scl_af = GPIO_AF4,
46  .sda_af = GPIO_AF4,
47 #endif
48  .bus = APB1,
49 #if CPU_FAM_STM32F4 || CPU_FAM_STM32F2
50  .rcc_mask = RCC_APB1ENR_I2C1EN,
51  .clk = CLOCK_APB1,
52  .irqn = I2C1_EV_IRQn,
53 #elif CPU_FAM_STM32L4 || CPU_FAM_STM32WB || CPU_FAM_STM32G4 || CPU_FAM_STM32L5
54  .rcc_mask = RCC_APB1ENR1_I2C1EN,
55  .irqn = I2C1_ER_IRQn,
56 #elif CPU_FAM_STM32G0
57  .rcc_mask = RCC_APBENR1_I2C1EN,
58  .irqn = I2C1_IRQn,
59 #elif CPU_FAM_STM32F7
60  .rcc_mask = RCC_APB1ENR_I2C1EN,
61  .irqn = I2C1_ER_IRQn,
62 #elif CPU_FAM_STM32F0 || CPU_FAM_STM32L0
63  .rcc_mask = RCC_APB1ENR_I2C1EN,
64 #if CPU_FAM_STM32F0
65  .rcc_sw_mask = RCC_CFGR3_I2C1SW,
66 #endif
67  .irqn = I2C1_IRQn,
68 #endif
69  }
70 };
71 
72 #if CPU_FAM_STM32F4 || CPU_FAM_STM32F2
73 #define I2C_0_ISR isr_i2c1_ev
74 #elif CPU_FAM_STM32L4 || CPU_FAM_STM32F7 || CPU_FAM_STM32WB || CPU_FAM_STM32L5
75 #define I2C_0_ISR isr_i2c1_er
76 #elif CPU_FAM_STM32F0 || CPU_FAM_STM32L0 || CPU_FAM_STM32G0
77 #define I2C_0_ISR isr_i2c1
78 #endif
79 
80 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
81 
83 #ifdef __cplusplus
84 }
85 #endif
86 
87 #endif /* CFG_I2C1_PB8_PB9_H */
88 
GPIO_AF4
@ GPIO_AF4
use alternate function 4
Definition: periph_cpu_common.h:90
I2C_SPEED_NORMAL
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: i2c.h:177
GPIO_AF1
@ GPIO_AF1
use alternate function 1
Definition: periph_cpu_common.h:87
GPIO_PIN
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:35
GPIO_AF6
@ GPIO_AF6
use alternate function 6
Definition: periph_cpu_common.h:92
i2c_conf_t
I2C configuration options.
Definition: periph_cpu.h:128
PORT_B
@ PORT_B
port B
Definition: periph_cpu.h:37
i2c_conf_t::dev
I2C_TypeDef * dev
USART device used.
Definition: periph_cpu.h:247
APB1
@ APB1
APB1 bus.
Definition: periph_cpu.h:176