From e672ca20103ca8cccf8629c29a4ca9e575756e90 Mon Sep 17 00:00:00 2001 From: Akshai M Date: Mon, 4 May 2020 22:56:01 +0530 Subject: [PATCH] drivers/at : Expose to Kconfig Expose configurations to Kconfig: Model choice for CONFIG_AT_SEND_EOL Allow value to be configured as exponent for AT_BUF_SIZE --- drivers/Kconfig | 5 +++- drivers/at/Kconfig | 63 ++++++++++++++++++++++++++++++++++++++++++++ drivers/include/at.h | 34 +++++++++++++++++++----- 3 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 drivers/at/Kconfig diff --git a/drivers/Kconfig b/drivers/Kconfig index 77d60ab5fd..4ee259895b 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -10,8 +10,11 @@ menu "Actuator Device Drivers" rsource "motor_driver/Kconfig" endmenu # Actuator Device Drivers -rsource "Kconfig.net" +menu "Miscellaneous Device Drivers" +rsource "at/Kconfig" +endmenu # Miscellaneous Device Drivers +rsource "Kconfig.net" rsource "periph_common/Kconfig" menu "Sensor Device Drivers" diff --git a/drivers/at/Kconfig b/drivers/at/Kconfig new file mode 100644 index 0000000000..d1925f228d --- /dev/null +++ b/drivers/at/Kconfig @@ -0,0 +1,63 @@ +# 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_AT + bool "Configure AT driver" + depends on MODULE_AT + help + Configure the AT driver using Kconfig. + +if KCONFIG_MODULE_AT + +choice + bool "End of line character" + default AT_SEND_EOL_MAC + help + Select the EOL character to send after the AT command. + The character sequence depends on target device. + By default "\r", aka carriage return, is used. + +config AT_SEND_EOL_WINDOWS + bool "\\r\\n" + +config AT_SEND_EOL_UNIX + bool "\\n" + +config AT_SEND_EOL_MAC + bool "\\r" + +endchoice + +config AT_SEND_SKIP_ECHO + bool "Disable check for echo" + help + Enable this to disable check for echo after an AT + command is sent. + +config AT_RECV_OK + string "OK reply string" + default "OK" + help + Change okay response of the AT device. + +config AT_RECV_ERROR + string "Error reply string" + default "ERROR" + help + Change error response of the AT device. + +config AT_BUF_SIZE_EXP + int "Exponent for the buffer size (resulting in the queue size 2^n)" + range 0 31 + default 7 + depends on MODULE_AT_URC + help + Size of buffer used to process unsolicited result code data. (as + exponent of 2^n). As the buffer size ALWAYS needs to be power of two, + this option represents the exponent of 2^n, which will be used as the + size of the buffer. + +endif # KCONFIG_MODULE_AT diff --git a/drivers/include/at.h b/drivers/include/at.h index cae30ec487..820704dd62 100644 --- a/drivers/include/at.h +++ b/drivers/include/at.h @@ -54,12 +54,21 @@ extern "C" { /** * @brief End of line character to send after the AT command. */ +#if IS_ACTIVE(CONFIG_AT_SEND_EOL_WINDOWS) +#define CONFIG_AT_SEND_EOL "\r\n" +#elif IS_ACTIVE(CONFIG_AT_SEND_EOL_UNIX) +#define CONFIG_AT_SEND_EOL "\n" +#elif IS_ACTIVE(CONFIG_AT_SEND_EOL_MAC) +#define CONFIG_AT_SEND_EOL "\r" +#endif + #ifndef CONFIG_AT_SEND_EOL #define CONFIG_AT_SEND_EOL "\r" #endif /** - * @brief Disable echo after an AT command is sent. + * @brief Enable this to disable check for echo after an AT + * command is sent. */ #ifdef DOXYGEN #define CONFIG_AT_SEND_SKIP_ECHO @@ -107,15 +116,28 @@ extern "C" { #define CONFIG_AT_RECV_ERROR "ERROR" #endif -/** - * @brief Internal buffer size used to process unsolicited result code data. - */ #if defined(MODULE_AT_URC) || DOXYGEN -#ifndef AT_BUF_SIZE -#define AT_BUF_SIZE (128) + +/** + * @brief Default buffer size used to process unsolicited result code data. + * (as exponent of 2^n). + * + * As the buffer size ALWAYS needs to be power of two, this option + * represents the exponent of 2^n, which will be used as the size of + * the buffer. + */ +#ifndef CONFIG_AT_BUF_SIZE_EXP +#define CONFIG_AT_BUF_SIZE_EXP (7U) #endif /** @} */ +/** + * @brief Size of buffer used to process unsolicited result code data. + */ +#ifndef AT_BUF_SIZE +#define AT_BUF_SIZE (1 << CONFIG_AT_BUF_SIZE_EXP) +#endif + /** * @brief Unsolicited result code callback *