From 86179913129390fd98305da255ef7ae8b004005e Mon Sep 17 00:00:00 2001 From: Akshai M Date: Fri, 17 Apr 2020 11:22:40 +0530 Subject: [PATCH 1/3] drivers/at86rf215 : Add CONFIG_ Add Add CONFIG_ Prefix for AT86RF215_USE_CLOCK_OUTPUT and model it as a bool Co-Authored-By: Leandro Lanzieri --- drivers/at86rf215/at86rf215.c | 6 +++--- drivers/include/at86rf215.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/at86rf215/at86rf215.c b/drivers/at86rf215/at86rf215.c index f48e2b6000..6ece41e457 100644 --- a/drivers/at86rf215/at86rf215.c +++ b/drivers/at86rf215/at86rf215.c @@ -25,6 +25,7 @@ #include "unaligned.h" #include "at86rf215_internal.h" #include "at86rf215_netdev.h" +#include "kernel_defines.h" #define ENABLE_DEBUG (0) #include "debug.h" @@ -115,10 +116,9 @@ void at86rf215_reset(at86rf215_t *dev) } /* disable clock output */ -#if AT86RF215_USE_CLOCK_OUTPUT == 0 +if (!IS_ACTIVE(CONFIG_AT86RF215_USE_CLOCK_OUTPUT)){ at86rf215_reg_write(dev, RG_RF_CLKO, 0); -#endif - +} /* allow to configure board-specific trim */ #ifdef AT86RF215_TRIM_VAL at86rf215_reg_write(dev, RG_RF_XOC, AT86RF215_TRIM_VAL | XOC_FS_MASK); diff --git a/drivers/include/at86rf215.h b/drivers/include/at86rf215.h index 22bcf24a94..ec1d8b3f95 100644 --- a/drivers/include/at86rf215.h +++ b/drivers/include/at86rf215.h @@ -71,8 +71,8 @@ typedef void (*at86rf215_batmon_cb_t)(void *arg); * as a clock source on the board. * Otherwise it is turned off to save energy. */ -#ifndef AT86RF215_USE_CLOCK_OUTPUT -#define AT86RF215_USE_CLOCK_OUTPUT (0) +#ifdef DOXYGEN +#define CONFIG_AT86RF215_USE_CLOCK_OUTPUT #endif #if defined(DOXYGEN) && !defined(AT86RF215_TRIM_VAL) @@ -84,7 +84,7 @@ typedef void (*at86rf215_batmon_cb_t)(void *arg); * * Range: 0..15 * - * Use in conjunction with @see AT86RF215_USE_CLOCK_OUTPUT and a frequency + * Use in conjunction with @see CONFIG_AT86RF215_USE_CLOCK_OUTPUT and a frequency * meter connected to the clock output pin of the AT86RF215. * Tweak the value until the measured clock output matches 26 MHz the best. */ From 68e2fc5845991dfe46af34fef49d016a47a2b376 Mon Sep 17 00:00:00 2001 From: Akshai M Date: Fri, 17 Apr 2020 11:29:01 +0530 Subject: [PATCH 2/3] drivers/at86rf215 : Add CONFIG Add CONFIG_ Prefix for configuring AT86RF215_TRIM_VAL --- drivers/at86rf215/at86rf215.c | 4 ++-- drivers/include/at86rf215.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/at86rf215/at86rf215.c b/drivers/at86rf215/at86rf215.c index 6ece41e457..2cfbe72f45 100644 --- a/drivers/at86rf215/at86rf215.c +++ b/drivers/at86rf215/at86rf215.c @@ -120,8 +120,8 @@ if (!IS_ACTIVE(CONFIG_AT86RF215_USE_CLOCK_OUTPUT)){ at86rf215_reg_write(dev, RG_RF_CLKO, 0); } /* allow to configure board-specific trim */ -#ifdef AT86RF215_TRIM_VAL - at86rf215_reg_write(dev, RG_RF_XOC, AT86RF215_TRIM_VAL | XOC_FS_MASK); +#ifdef CONFIG_AT86RF215_TRIM_VAL + at86rf215_reg_write(dev, RG_RF_XOC, CONFIG_AT86RF215_TRIM_VAL | XOC_FS_MASK); #endif /* enable TXFE & RXFE IRQ */ diff --git a/drivers/include/at86rf215.h b/drivers/include/at86rf215.h index ec1d8b3f95..8211c5c156 100644 --- a/drivers/include/at86rf215.h +++ b/drivers/include/at86rf215.h @@ -75,7 +75,7 @@ typedef void (*at86rf215_batmon_cb_t)(void *arg); #define CONFIG_AT86RF215_USE_CLOCK_OUTPUT #endif -#if defined(DOXYGEN) && !defined(AT86RF215_TRIM_VAL) +#if defined(DOXYGEN) && !defined(CONFIG_AT86RF215_TRIM_VAL) /** * @brief Trim value for the external crystal oscillator. * @@ -88,7 +88,7 @@ typedef void (*at86rf215_batmon_cb_t)(void *arg); * meter connected to the clock output pin of the AT86RF215. * Tweak the value until the measured clock output matches 26 MHz the best. */ -#define AT86RF215_TRIM_VAL (0) +#define CONFIG_AT86RF215_TRIM_VAL (0) #endif /** @} */ From 7b2591ea09a440cbb73c1d72b25c895b1af829d5 Mon Sep 17 00:00:00 2001 From: Akshai M Date: Fri, 17 Apr 2020 12:04:33 +0530 Subject: [PATCH 3/3] drivers_at86rf215 : Expose to Kconfig Expose Configurations to Kconfig Co-Authored-By: benpicco Co-Authored-By: Leandro Lanzieri --- drivers/Kconfig.net | 1 + drivers/at86rf215/Kconfig | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 drivers/at86rf215/Kconfig diff --git a/drivers/Kconfig.net b/drivers/Kconfig.net index 8a0e81d515..dd71dd5d58 100644 --- a/drivers/Kconfig.net +++ b/drivers/Kconfig.net @@ -5,6 +5,7 @@ # directory for more details. menu "Network Device Drivers" +rsource "at86rf215/Kconfig" rsource "cc110x/Kconfig" rsource "mrf24j40/Kconfig" source "$(RIOTCPU)/nrf52/radio/nrf802154/Kconfig" diff --git a/drivers/at86rf215/Kconfig b/drivers/at86rf215/Kconfig new file mode 100644 index 0000000000..d82d6d43ca --- /dev/null +++ b/drivers/at86rf215/Kconfig @@ -0,0 +1,41 @@ +# Copyright (c) 2020 Freie Universitaet 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. +# +menuconfig KCONFIG_MODULE_AT86RF215 + bool "Configure AT86RF215 driver" + depends on MODULE_AT86RF215 + help + Configure the AT86RF215 driver using Kconfig. + +if KCONFIG_MODULE_AT86RF215 + +config AT86RF215_USE_CLOCK_OUTPUT + bool "Enable clock output" + help + Enable this to enable the clock output pin of the AT86RF215 chip. + This way it can be used as a clock source in place of a separate crystal. + You also have to enable this if you want to measure the clock frequency + for trimming. After proper trim value is applied this may be disabled + if not used otherwise. + By Default it is turned off to save energy. + +config AT86RF215_TRIM_VAL_EN + bool "Enable crystal oscillator trimming" + help + Enable crystal oscillator trimming. + +config AT86RF215_TRIM_VAL + int "Trim value for the crystal oscillator" + range 0 15 + default 0 + depends on AT86RF215_TRIM_VAL_EN + help + Each increment adds 300nF capacitance between the crystal oscillator pins + TCXO and XTAL2.Tweak the value until the measured clock output matches + 26 MHz the best. + For more information Refer Table 6-25 TRIM in Datasheet + +endif # KCONFIG_MODULE_AT86RF215