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 
9 #pragma once
10 
21 #include "periph_cpu.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
31 static const i2c_conf_t i2c_config[] = {
32  {
33  .dev = I2C1,
34  .speed = I2C_SPEED_NORMAL,
35  .scl_pin = GPIO_PIN(PORT_B, 8),
36  .sda_pin = GPIO_PIN(PORT_B, 9),
37 #if CPU_FAM_STM32F0
38  .scl_af = GPIO_AF1,
39  .sda_af = GPIO_AF1,
40 #elif CPU_FAM_STM32G0 || CPU_FAM_STM32C0
41  .scl_af = GPIO_AF6,
42  .sda_af = GPIO_AF6,
43 #else
44  .scl_af = GPIO_AF4,
45  .sda_af = GPIO_AF4,
46 #endif
47  .bus = APB1,
48 #if CPU_FAM_STM32F4 || CPU_FAM_STM32F2
49  .rcc_mask = RCC_APB1ENR_I2C1EN,
50  .clk = CLOCK_APB1,
51  .irqn = I2C1_EV_IRQn,
52 #elif CPU_FAM_STM32L4 || CPU_FAM_STM32WB || CPU_FAM_STM32G4
53  .rcc_mask = RCC_APB1ENR1_I2C1EN,
54  .rcc_sw_mask = RCC_CCIPR_I2C1SEL_1, /* HSI (16 MHz) */
55  .irqn = I2C1_ER_IRQn,
56 #elif CPU_FAM_STM32L5
57  .rcc_mask = RCC_APB1ENR1_I2C1EN,
58  .rcc_sw_mask = RCC_CCIPR1_I2C1SEL_1, /* HSI (16 MHz) */
59  .irqn = I2C1_ER_IRQn,
60 #elif CPU_FAM_STM32G0 || CPU_FAM_STM32C0
61  .rcc_mask = RCC_APBENR1_I2C1EN,
62  .rcc_sw_mask = RCC_CCIPR_I2C1SEL_1, /* HSI (16 MHz) */
63  .irqn = I2C1_IRQn,
64 #elif CPU_FAM_STM32F7
65  .rcc_mask = RCC_APB1ENR_I2C1EN,
66  .rcc_sw_mask = RCC_DCKCFGR2_I2C1SEL_1, /* HSI (16 MHz) */
67  .irqn = I2C1_ER_IRQn,
68 #elif CPU_FAM_STM32F0 || CPU_FAM_STM32L0
69  .rcc_mask = RCC_APB1ENR_I2C1EN,
70 #if CPU_FAM_STM32F0
71  .rcc_sw_mask = RCC_CFGR3_I2C1SW,
72 #endif
73  .irqn = I2C1_IRQn,
74 #endif
75  }
76 };
77 
78 #if CPU_FAM_STM32F4 || CPU_FAM_STM32F2
79 #define I2C_0_ISR isr_i2c1_ev
80 #elif CPU_FAM_STM32L4 || CPU_FAM_STM32F7 || CPU_FAM_STM32WB || CPU_FAM_STM32L5
81 #define I2C_0_ISR isr_i2c1_er
82 #elif CPU_FAM_STM32F0 || CPU_FAM_STM32L0 || CPU_FAM_STM32G0 || CPU_FAM_STM32C0
83 #define I2C_0_ISR isr_i2c1
84 #endif
85 
86 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
89 #ifdef __cplusplus
90 }
91 #endif
92 
@ PORT_B
port B
Definition: periph_cpu.h:47
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:45
@ GPIO_AF1
use alternate function 1
Definition: cpu_gpio.h:102
@ GPIO_AF4
use alternate function 4
Definition: cpu_gpio.h:105
@ GPIO_AF6
use alternate function 6
Definition: cpu_gpio.h:107
@ APB1
Advanced Peripheral Bus 1
Definition: periph_cpu.h:78
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:277
#define CLOCK_APB1
Half AHB clock.
I2C configuration structure.
Definition: periph_cpu.h:298
TWI_t * dev
Pointer to hardware module registers.
Definition: periph_cpu.h:299