From 39826d6e5b0734c701fdd2cc707c10ef69092bb8 Mon Sep 17 00:00:00 2001 From: Akshai M Date: Wed, 22 Apr 2020 21:54:33 +0530 Subject: [PATCH 1/2] drivers/motor_driver : Add CONFIG_ Add CONFIG_ Prefix for MOTOR_DRIVER_MAX --- drivers/include/motor_driver.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/include/motor_driver.h b/drivers/include/motor_driver.h index a51f602c88..38a1326b58 100644 --- a/drivers/include/motor_driver.h +++ b/drivers/include/motor_driver.h @@ -17,9 +17,9 @@ * Mainly designed for H-bridge, it could also drive some brushless drivers. * * Some H-bridge driver circuits handle several motors. - * Maximum motor number by H-bridge is set to 2 with MOTOR_DRIVER_MAX macro. + * Maximum motor number by H-bridge is set to 2 with CONFIG_MOTOR_DRIVER_MAX macro. * This macro can be overridden to support H-bridge drivers with more outputs. - * However, MOTOR_DRIVER_MAX should not exceed PWM channels number. + * However, CONFIG_MOTOR_DRIVER_MAX should not exceed PWM channels number. * * motor_driver_t structure represents an H-bridge. * As several H-bridge can share a same PWM device, motor_driver_t can @@ -99,8 +99,8 @@ extern "C" { /** * @brief Maximum number of motors by motor driver */ -#ifndef MOTOR_DRIVER_MAX -#define MOTOR_DRIVER_MAX (2) +#ifndef CONFIG_MOTOR_DRIVER_MAX +#define CONFIG_MOTOR_DRIVER_MAX (2) #endif /** @} */ @@ -173,7 +173,7 @@ typedef struct { uint32_t pwm_frequency; /**< PWM device frequency */ uint32_t pwm_resolution; /**< PWM device resolution */ uint8_t nb_motors; /**< number of moros */ - motor_t motors[MOTOR_DRIVER_MAX]; /**< motors array */ + motor_t motors[CONFIG_MOTOR_DRIVER_MAX]; /**< motors array */ motor_driver_cb_t cb; /**< callback on motor_set */ } motor_driver_config_t; From c654b4ea3c68cbfeccb3315d43327bb75c23b900 Mon Sep 17 00:00:00 2001 From: Akshai M Date: Wed, 22 Apr 2020 22:21:41 +0530 Subject: [PATCH 2/2] drivers/motor_driver : Expose to Kconfig Expose Configurations to Kconfig Co-Authored-By: Leandro Lanzieri --- drivers/Kconfig.net | 4 ++++ drivers/motor_driver/Kconfig | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 drivers/motor_driver/Kconfig diff --git a/drivers/Kconfig.net b/drivers/Kconfig.net index e8b39cac99..266df42ad5 100644 --- a/drivers/Kconfig.net +++ b/drivers/Kconfig.net @@ -4,6 +4,10 @@ # General Public License v2.1. See the file LICENSE in the top level # directory for more details. +menu "Actuator Device Drivers" +rsource "motor_driver/Kconfig" +endmenu # Actuator Device Drivers + menu "Network Device Drivers" rsource "at86rf215/Kconfig" rsource "cc110x/Kconfig" diff --git a/drivers/motor_driver/Kconfig b/drivers/motor_driver/Kconfig new file mode 100644 index 0000000000..8741f70d19 --- /dev/null +++ b/drivers/motor_driver/Kconfig @@ -0,0 +1,23 @@ +# 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_MOTOR_DRIVER + bool "Configure the DC Motor driver" + depends on MODULE_MOTOR_DRIVER + help + Configure the DC Motor driver using Kconfig. + +if KCONFIG_MODULE_MOTOR_DRIVER + +config MOTOR_DRIVER_MAX + int "Maximum number of motors" + default 2 + help + Maximum number of motors depends on the H-bridge. + The value should not exceed the number of PWM channels + Default value is set to 2. + +endif # KCONFIG_MODULE_MOTOR_DRIVER