From 39695afeb4cb3933a16aa7e34472acff7bf11c2b Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Wed, 31 Jul 2019 10:05:04 +0200 Subject: [PATCH 1/3] boards/nrf52840-mdk: use TWIM1 for i2c - SPIM0/SPIS0/TWIM0/TWIS0 have the same priority and are mutually exclusive, to allow concurrent use we change the default TWIM used for i2c to TWIM1 since spi uses SPI0 by default --- boards/nrf52840-mdk/include/periph_conf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/nrf52840-mdk/include/periph_conf.h b/boards/nrf52840-mdk/include/periph_conf.h index 1bbb63e555..c85691a4ca 100644 --- a/boards/nrf52840-mdk/include/periph_conf.h +++ b/boards/nrf52840-mdk/include/periph_conf.h @@ -56,7 +56,7 @@ static const uart_conf_t uart_config[] = { */ static const i2c_conf_t i2c_config[] = { { - .dev = NRF_TWIM0, + .dev = NRF_TWIM1, .scl = 27, .sda = 26, .speed = I2C_SPEED_NORMAL From 618ca3abcc1e66ec8b6aa54a6a4bce5bb19c793c Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Wed, 31 Jul 2019 10:14:12 +0200 Subject: [PATCH 2/3] boards/common/nrf52: add default i2c config --- boards/common/nrf52/include/cfg_i2c_default.h | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 boards/common/nrf52/include/cfg_i2c_default.h diff --git a/boards/common/nrf52/include/cfg_i2c_default.h b/boards/common/nrf52/include/cfg_i2c_default.h new file mode 100644 index 0000000000..24f461ab97 --- /dev/null +++ b/boards/common/nrf52/include/cfg_i2c_default.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2016-2018 Freie Universität Berlin + * + * 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_nrf52 + * @{ + * + * @file + * @brief Default I2C config for nRF52 based boards + * + * @author Hauke Petersen + * + */ + +#ifndef CFG_I2C_DEFAULT_H +#define CFG_I2C_DEFAULT_H + +#include "periph_cpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name I2C configuration + * @{ + */ +static const i2c_conf_t i2c_config[] = { + { + .dev = NRF_TWIM1, + .scl = 27, + .sda = 26, + .speed = I2C_SPEED_NORMAL + } +}; +#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0])) +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* CFG_I2C_DEFAULT_H */ +/** @} */ From 8a4b4f9005eb389395556ca10dd57ae2d061b6ff Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Wed, 31 Jul 2019 10:15:20 +0200 Subject: [PATCH 3/3] boards: use of default_i2c_cfg for nrf52 based boards --- .../nrf52xxxdk/include/periph_conf_common.h | 16 +--------------- .../particle-mesh/include/periph_conf_common.h | 16 +--------------- boards/nrf52840-mdk/include/periph_conf.h | 16 +--------------- boards/reel/include/periph_conf.h | 16 +--------------- 4 files changed, 4 insertions(+), 60 deletions(-) diff --git a/boards/common/nrf52xxxdk/include/periph_conf_common.h b/boards/common/nrf52xxxdk/include/periph_conf_common.h index aef7fac8f5..3b8f2cec21 100644 --- a/boards/common/nrf52xxxdk/include/periph_conf_common.h +++ b/boards/common/nrf52xxxdk/include/periph_conf_common.h @@ -23,6 +23,7 @@ #include "periph_cpu.h" #include "cfg_clock_32_1.h" +#include "cfg_i2c_default.h" #include "cfg_rtt_default.h" #include "cfg_timer_default.h" @@ -30,21 +31,6 @@ extern "C" { #endif -/** - * @name I2C configuration - * @{ - */ -static const i2c_conf_t i2c_config[] = { - { - .dev = NRF_TWIM1, - .scl = 27, - .sda = 26, - .speed = I2C_SPEED_NORMAL - } -}; -#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0])) -/** @} */ - /** * @name PWM configuration * @{ diff --git a/boards/common/particle-mesh/include/periph_conf_common.h b/boards/common/particle-mesh/include/periph_conf_common.h index e4737b4168..829bf70b15 100644 --- a/boards/common/particle-mesh/include/periph_conf_common.h +++ b/boards/common/particle-mesh/include/periph_conf_common.h @@ -22,6 +22,7 @@ #include "periph_cpu.h" #include "cfg_clock_32_1.h" +#include "cfg_i2c_default.h" #include "cfg_rtt_default.h" #include "cfg_timer_default.h" @@ -45,21 +46,6 @@ static const spi_conf_t spi_config[] = { #define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0])) /** @} */ -/** - * @name I2C configuration - * @{ - */ -static const i2c_conf_t i2c_config[] = { - { - .dev = NRF_TWIM1, - .scl = 27, - .sda = 26, - .speed = I2C_SPEED_NORMAL - } -}; -#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0])) -/** @} */ - #ifdef __cplusplus } #endif diff --git a/boards/nrf52840-mdk/include/periph_conf.h b/boards/nrf52840-mdk/include/periph_conf.h index c85691a4ca..8bf2448f7a 100644 --- a/boards/nrf52840-mdk/include/periph_conf.h +++ b/boards/nrf52840-mdk/include/periph_conf.h @@ -22,6 +22,7 @@ #include "periph_cpu.h" #include "cfg_clock_32_1.h" +#include "cfg_i2c_default.h" #include "cfg_rtt_default.h" #include "cfg_spi_default.h" #include "cfg_timer_default.h" @@ -50,21 +51,6 @@ static const uart_conf_t uart_config[] = { #define UART_NUMOF (sizeof(uart_config) / sizeof(uart_config[0])) /** @} */ -/** - * @name I2C configuration - * @{ - */ -static const i2c_conf_t i2c_config[] = { - { - .dev = NRF_TWIM1, - .scl = 27, - .sda = 26, - .speed = I2C_SPEED_NORMAL - } -}; -#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0])) -/** @} */ - #ifdef __cplusplus } #endif diff --git a/boards/reel/include/periph_conf.h b/boards/reel/include/periph_conf.h index 8ddd949df6..ed67d8dd9d 100644 --- a/boards/reel/include/periph_conf.h +++ b/boards/reel/include/periph_conf.h @@ -22,6 +22,7 @@ #include "periph_cpu.h" #include "cfg_clock_32_1.h" +#include "cfg_i2c_default.h" #include "cfg_rtt_default.h" #include "cfg_timer_default.h" @@ -65,21 +66,6 @@ static const spi_conf_t spi_config[] = { #define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0])) /** @} */ -/** - * @name I2C configuration - * @{ - */ -static const i2c_conf_t i2c_config[] = { - { - .dev = NRF_TWIM1, - .scl = GPIO_PIN(0, 27), - .sda = GPIO_PIN(0, 26), - .speed = I2C_SPEED_NORMAL - } -}; -#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0])) -/** @} */ - #ifdef __cplusplus } #endif