Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers/motor_driver : Expose Configurations to Kconfig #13927

Merged
merged 2 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions drivers/Kconfig.net
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions drivers/include/motor_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
/** @} */

Expand Down Expand Up @@ -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;

Expand Down
23 changes: 23 additions & 0 deletions drivers/motor_driver/Kconfig
Original file line number Diff line number Diff line change
@@ -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