2019-01-02 10:12:29 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 Inria
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup boards_common_stm32
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Common configuration for STM32 I2C
|
|
|
|
*
|
|
|
|
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CFG_I2C1_PB8_PB9_H
|
|
|
|
#define CFG_I2C1_PB8_PB9_H
|
|
|
|
|
|
|
|
#include "periph_cpu.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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),
|
2019-01-02 14:20:35 +01:00
|
|
|
#if CPU_FAM_STM32F0
|
|
|
|
.scl_af = GPIO_AF1,
|
|
|
|
.sda_af = GPIO_AF1,
|
|
|
|
#else
|
2019-01-02 10:12:29 +01:00
|
|
|
.scl_af = GPIO_AF4,
|
|
|
|
.sda_af = GPIO_AF4,
|
2019-01-02 14:20:35 +01:00
|
|
|
#endif
|
2019-01-02 10:12:29 +01:00
|
|
|
.bus = APB1,
|
2019-01-02 14:20:35 +01:00
|
|
|
#if CPU_FAM_STM32F4 || CPU_FAM_STM32F2
|
2019-01-02 10:12:29 +01:00
|
|
|
.rcc_mask = RCC_APB1ENR_I2C1EN,
|
|
|
|
.clk = CLOCK_APB1,
|
2019-01-02 11:25:32 +01:00
|
|
|
.irqn = I2C1_EV_IRQn,
|
2019-07-15 16:37:31 +02:00
|
|
|
#elif CPU_FAM_STM32L4 || CPU_FAM_STM32WB
|
2019-01-02 11:25:32 +01:00
|
|
|
.rcc_mask = RCC_APB1ENR1_I2C1EN,
|
|
|
|
.irqn = I2C1_ER_IRQn,
|
|
|
|
#elif CPU_FAM_STM32F7
|
|
|
|
.rcc_mask = RCC_APB1ENR_I2C1EN,
|
|
|
|
.irqn = I2C1_ER_IRQn,
|
2019-05-18 20:12:18 +02:00
|
|
|
#elif CPU_FAM_STM32F0 || CPU_FAM_STM32L0
|
2019-01-02 14:20:35 +01:00
|
|
|
.rcc_mask = RCC_APB1ENR_I2C1EN,
|
2019-05-18 20:12:18 +02:00
|
|
|
#if CPU_FAM_STM32F0
|
2019-01-02 14:20:35 +01:00
|
|
|
.rcc_sw_mask = RCC_CFGR3_I2C1SW,
|
2019-05-18 20:12:18 +02:00
|
|
|
#endif
|
2019-01-02 14:20:35 +01:00
|
|
|
.irqn = I2C1_IRQn,
|
2019-01-02 11:25:32 +01:00
|
|
|
#endif
|
2019-01-02 10:12:29 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-01-02 14:20:35 +01:00
|
|
|
#if CPU_FAM_STM32F4 || CPU_FAM_STM32F2
|
2019-01-02 10:12:29 +01:00
|
|
|
#define I2C_0_ISR isr_i2c1_ev
|
2019-07-15 16:37:31 +02:00
|
|
|
#elif CPU_FAM_STM32L4 || CPU_FAM_STM32F7 || CPU_FAM_STM32WB
|
2019-01-02 11:25:32 +01:00
|
|
|
#define I2C_0_ISR isr_i2c1_er
|
2019-05-18 20:12:18 +02:00
|
|
|
#elif CPU_FAM_STM32F0 || CPU_FAM_STM32L0
|
2019-01-02 14:20:35 +01:00
|
|
|
#define I2C_0_ISR isr_i2c1
|
2019-01-02 11:25:32 +01:00
|
|
|
#endif
|
2019-01-02 10:12:29 +01:00
|
|
|
|
2019-07-18 15:14:29 +02:00
|
|
|
#define I2C_NUMOF ARRAY_SIZE(i2c_config)
|
2019-01-02 10:12:29 +01:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* CFG_I2C1_PB8_PB9_H */
|
|
|
|
/** @} */
|