drivers: move the generic upper-half motor driver from drivers/power to drivers/motor

This commit is contained in:
raiden00pl
2021-04-16 10:57:14 +02:00
committed by Alin Jerpelea
parent b01ddef61b
commit 3fb78a8299
7 changed files with 145 additions and 147 deletions
+50
View File
@@ -9,6 +9,56 @@ menuconfig MOTOR
if MOTOR if MOTOR
config MOTOR_UPPER
bool "Motor generic upper-half driver"
default n
---help---
Enables building of a motor generic upper half driver.
if MOTOR_UPPER
config MOTOR_UPPER_HAVE_POSITION
bool "Have position control"
default n
config MOTOR_UPPER_HAVE_DIRECTION
bool "Have direction control"
default n
config MOTOR_UPPER_HAVE_SPEED
bool "Have speed control"
default n
config MOTOR_UPPER_HAVE_TORQUE
bool "Have torque control (rotary motors)"
default n
config MOTOR_UPPER_HAVE_FORCE
bool "Have force control (linear motors)"
default n
config MOTOR_UPPER_HAVE_ACCELERATION
bool "Have acceleration control"
default n
config MOTOR_UPPER_HAVE_DECELERATION
bool "Have deceleration control"
default n
config MOTOR_UPPER_HAVE_INPUT_VOLTAGE
bool "Have input voltage protection"
default n
config MOTOR_UPPER_HAVE_INPUT_CURRENT
bool "Have input current protection"
default n
config MOTOR_UPPER_HAVE_INPUT_POWER
bool "Have input power protection"
default n
endif
source "drivers/motor/foc/Kconfig" source "drivers/motor/foc/Kconfig"
endif # MOTOR endif # MOTOR
+6
View File
@@ -24,6 +24,12 @@ ifeq ($(CONFIG_MOTOR_FOC),y)
include motor$(DELIM)foc$(DELIM)Make.defs include motor$(DELIM)foc$(DELIM)Make.defs
endif endif
# Add generic upper-half motor driver
ifeq ($(CONFIG_MOTOR_UPPER),y)
CSRCS += motor.c
endif
# Include motor drivers in the build # Include motor drivers in the build
MOTOR_DEPPATH := --dep-path motor MOTOR_DEPPATH := --dep-path motor
+52 -52
View File
@@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* drivers/power/motor.c * drivers/motor/motor.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@@ -35,7 +35,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/fs/fs.h> #include <nuttx/fs/fs.h>
#include <nuttx/power/motor.h> #include <nuttx/motor/motor.h>
#include <nuttx/irq.h> #include <nuttx/irq.h>
@@ -214,7 +214,7 @@ static int motor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
switch (cmd) switch (cmd)
{ {
case PWRIOC_START: case MTRIOC_START:
{ {
/* Allow motor start only when some limits available /* Allow motor start only when some limits available
* and structure is locked. * and structure is locked.
@@ -222,30 +222,30 @@ static int motor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
if ((motor->limits.lock == false) || if ((motor->limits.lock == false) ||
( (
#ifdef CONFIG_MOTOR_HAVE_POSITION #ifdef CONFIG_MOTOR_UPPER_HAVE_POSITION
motor->limits.position <= 0.0 && motor->limits.position <= 0.0 &&
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_SPEED #ifdef CONFIG_MOTOR_UPPER_HAVE_SPEED
motor->limits.speed <= 0.0 && motor->limits.speed <= 0.0 &&
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_TORQUE #ifdef CONFIG_MOTOR_UPPER_HAVE_TORQUE
motor->limits.torque <= 0.0 && motor->limits.torque <= 0.0 &&
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_FORCE #ifdef CONFIG_MOTOR_UPPER_HAVE_FORCE
motor->limits.force <= 0.0 && motor->limits.force <= 0.0 &&
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_INPUT_VOLTAGE #ifdef CONFIG_MOTOR_UPPER_HAVE_INPUT_VOLTAGE
motor->limits.v_in <= 0.0 && motor->limits.v_in <= 0.0 &&
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_INPUT_CURRENT #ifdef CONFIG_MOTOR_UPPER_HAVE_INPUT_CURRENT
motor->limits.i_in <= 0.0 && motor->limits.i_in <= 0.0 &&
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_INPUT_POWER #ifdef CONFIG_MOTOR_UPPER_HAVE_INPUT_POWER
motor->limits.p_in <= 0.0 && motor->limits.p_in <= 0.0 &&
#endif #endif
1)) 1))
{ {
pwrerr("ERROR: motor limits data must be set" mtrerr("Motor limits data must be set"
" and locked before motor start\n"); " and locked before motor start\n");
ret = -EPERM; ret = -EPERM;
@@ -256,7 +256,7 @@ static int motor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
if (motor->opmode == MOTOR_OPMODE_INIT) if (motor->opmode == MOTOR_OPMODE_INIT)
{ {
pwrerr("ERROR: motor operation mode not specified\n"); mtrerr("Motor operation mode not specified\n");
ret = -EPERM; ret = -EPERM;
goto errout; goto errout;
@@ -269,43 +269,43 @@ static int motor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
ret = dev->ops->start(dev); ret = dev->ops->start(dev);
if (ret != OK) if (ret != OK)
{ {
pwrerr("ERROR: PWRIOC_START failed %d\n", ret); mtrerr("MTRIOC_START failed %d\n", ret);
} }
break; break;
} }
case PWRIOC_STOP: case MTRIOC_STOP:
{ {
/* Call stop from lower-half driver */ /* Call stop from lower-half driver */
ret = dev->ops->stop(dev); ret = dev->ops->stop(dev);
if (ret != OK) if (ret != OK)
{ {
pwrerr("ERROR: PWRIOC_STOP failed %d\n", ret); mtrerr("MTRIOC_STOP failed %d\n", ret);
} }
break; break;
} }
case PWRIOC_SET_MODE: case MTRIOC_SET_MODE:
{ {
uint8_t mode = ((uint8_t)arg); uint8_t mode = ((uint8_t)arg);
ret = dev->ops->mode_set(dev, mode); ret = dev->ops->mode_set(dev, mode);
if (ret != OK) if (ret != OK)
{ {
pwrerr("ERROR: PWRIOC_SET_MODE failed %d\n", ret); mtrerr("MTRIOC_SET_MODE failed %d\n", ret);
} }
break; break;
} }
case PWRIOC_SET_LIMITS: case MTRIOC_SET_LIMITS:
{ {
FAR struct motor_limits_s *limits = FAR struct motor_limits_s *limits =
(FAR struct motor_limits_s *)((uintptr_t)arg); (FAR struct motor_limits_s *)((uintptr_t)arg);
if (motor->limits.lock == true) if (motor->limits.lock == true)
{ {
pwrerr("ERROR: motor limits locked!\n"); mtrerr("Motor limits locked!\n");
ret = -EPERM; ret = -EPERM;
goto errout; goto errout;
@@ -316,12 +316,12 @@ static int motor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
ret = dev->ops->limits_set(dev, limits); ret = dev->ops->limits_set(dev, limits);
if (ret != OK) if (ret != OK)
{ {
pwrerr("ERROR: PWRIOC_SET_LIMITS failed %d\n", ret); mtrerr("MTRIOC_SET_LIMITS failed %d\n", ret);
} }
break; break;
} }
case PWRIOC_GET_STATE: case MTRIOC_GET_STATE:
{ {
FAR struct motor_state_s *state = FAR struct motor_state_s *state =
(FAR struct motor_state_s *)((uintptr_t)arg); (FAR struct motor_state_s *)((uintptr_t)arg);
@@ -329,55 +329,55 @@ static int motor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
ret = dev->ops->state_get(dev, state); ret = dev->ops->state_get(dev, state);
if (ret != OK) if (ret != OK)
{ {
pwrerr("ERROR: PWRIOC_GET_STATE failed %d\n", ret); mtrerr("MTRIOC_GET_STATE failed %d\n", ret);
} }
break; break;
} }
case PWRIOC_SET_FAULT: case MTRIOC_SET_FAULT:
{ {
uint8_t fault = ((uint8_t)arg); uint8_t fault = ((uint8_t)arg);
ret = dev->ops->fault_set(dev, fault); ret = dev->ops->fault_set(dev, fault);
if (ret != OK) if (ret != OK)
{ {
pwrerr("ERROR: PWRIOC_SET_FAULT failed %d\n", ret); mtrerr("MTRIOC_SET_FAULT failed %d\n", ret);
} }
break; break;
} }
case PWRIOC_GET_FAULT: case MTRIOC_GET_FAULT:
{ {
FAR uint8_t *fault = ((FAR uint8_t *)arg); FAR uint8_t *fault = ((FAR uint8_t *)arg);
ret = dev->ops->fault_get(dev, fault); ret = dev->ops->fault_get(dev, fault);
if (ret != OK) if (ret != OK)
{ {
pwrerr("ERROR: PWRIOC_GET_FAULT failed %d\n", ret); mtrerr("MTRIOC_GET_FAULT failed %d\n", ret);
} }
break; break;
} }
case PWRIOC_CLEAN_FAULT: case MTRIOC_CLEAR_FAULT:
{ {
uint8_t fault = ((uint8_t)arg); uint8_t fault = ((uint8_t)arg);
ret = dev->ops->fault_clean(dev, fault); ret = dev->ops->fault_clear(dev, fault);
if (ret != OK) if (ret != OK)
{ {
pwrerr("ERROR: PWRIOC_CLEAN_FAULT failed %d\n", ret); mtrerr("MTRIOC_CLEAR_FAULT failed %d\n", ret);
} }
break; break;
} }
case PWRIOC_SET_PARAMS: case MTRIOC_SET_PARAMS:
{ {
FAR struct motor_params_s *params = FAR struct motor_params_s *params =
(FAR struct motor_params_s *)((uintptr_t)arg); (FAR struct motor_params_s *)((uintptr_t)arg);
if (motor->param.lock == true) if (motor->param.lock == true)
{ {
pwrerr("ERROR: motor params locked!\n"); mtrerr("Motor params locked!\n");
ret = -EPERM; ret = -EPERM;
goto errout; goto errout;
@@ -385,42 +385,42 @@ static int motor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
if ((motor->limits.lock == false) || if ((motor->limits.lock == false) ||
( (
#ifdef CONFIG_MOTOR_HAVE_POSITION #ifdef CONFIG_MOTOR_UPPER_HAVE_POSITION
motor->limits.position <= 0.0 && motor->limits.position <= 0.0 &&
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_SPEED #ifdef CONFIG_MOTOR_UPPER_HAVE_SPEED
motor->limits.speed <= 0.0 && motor->limits.speed <= 0.0 &&
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_TORQUE #ifdef CONFIG_MOTOR_UPPER_HAVE_TORQUE
motor->limits.torque <= 0.0 && motor->limits.torque <= 0.0 &&
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_FORCE #ifdef CONFIG_MOTOR_UPPER_HAVE_FORCE
motor->limits.force <= 0.0 && motor->limits.force <= 0.0 &&
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_INPUT_VOLTAGE #ifdef CONFIG_MOTOR_UPPER_HAVE_INPUT_VOLTAGE
motor->limits.v_in <= 0.0 && motor->limits.v_in <= 0.0 &&
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_INPUT_CURRENT #ifdef CONFIG_MOTOR_UPPER_HAVE_INPUT_CURRENT
motor->limits.i_in <= 0.0 && motor->limits.i_in <= 0.0 &&
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_INPUT_POWER #ifdef CONFIG_MOTOR_UPPER_HAVE_INPUT_POWER
motor->limits.p_in <= 0.0 && motor->limits.p_in <= 0.0 &&
#endif #endif
1)) 1))
{ {
pwrerr("ERROR: limits must be set prior to params!\n"); mtrerr("Limits must be set prior to params!\n");
ret = -EPERM; ret = -EPERM;
goto errout; goto errout;
} }
#ifdef CONFIG_MOTOR_HAVE_DIRECTION #ifdef CONFIG_MOTOR_UPPER_HAVE_DIRECTION
/* Check direction configuration */ /* Check direction configuration */
if (params->direction != MOTOR_DIR_CCW && if (params->direction != MOTOR_DIR_CCW &&
params->direction != MOTOR_DIR_CW) params->direction != MOTOR_DIR_CW)
{ {
pwrerr("ERROR: invalid direction value %d\n", mtrerr("Invalid direction value %d\n",
params->direction); params->direction);
ret = -EPERM; ret = -EPERM;
@@ -428,13 +428,13 @@ static int motor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
} }
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_POSITION #ifdef CONFIG_MOTOR_UPPER_HAVE_POSITION
/* Check position configuration */ /* Check position configuration */
if (params->position < 0.0 || if (params->position < 0.0 ||
params->position > motor->limits.position) params->position > motor->limits.position)
{ {
pwrerr("ERROR: params->position > limits.position: " mtrerr("params->position > limits.position: "
"%.2f > %.2f\n", "%.2f > %.2f\n",
params->position, motor->limits.position); params->position, motor->limits.position);
@@ -443,13 +443,13 @@ static int motor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
} }
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_SPEED #ifdef CONFIG_MOTOR_UPPER_HAVE_SPEED
/* Check speed configuration */ /* Check speed configuration */
if (motor->limits.speed > 0.0 && if (motor->limits.speed > 0.0 &&
params->speed > motor->limits.speed) params->speed > motor->limits.speed)
{ {
pwrerr("ERROR: params->speed > limits.speed: %.2f > %.2f\n", mtrerr("params->speed > limits.speed: %.2f > %.2f\n",
params->speed, motor->limits.speed); params->speed, motor->limits.speed);
ret = -EPERM; ret = -EPERM;
@@ -457,13 +457,13 @@ static int motor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
} }
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_TORQUE #ifdef CONFIG_MOTOR_UPPER_HAVE_TORQUE
/* Check torque configuration */ /* Check torque configuration */
if (motor->limits.torque > 0.0 && if (motor->limits.torque > 0.0 &&
params->torque > motor->limits.torque) params->torque > motor->limits.torque)
{ {
pwrerr("ERROR: params->torque > limits.torque: %.2f > %.2f\n", mtrerr("params->torque > limits.torque: %.2f > %.2f\n",
params->torque, motor->limits.torque); params->torque, motor->limits.torque);
ret = -EPERM; ret = -EPERM;
@@ -471,13 +471,13 @@ static int motor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
} }
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_FORCE #ifdef CONFIG_MOTOR_UPPER_HAVE_FORCE
/* Check force configuration */ /* Check force configuration */
if (motor->limits.force > 0.0 && if (motor->limits.force > 0.0 &&
params->force > motor->limits.force) params->force > motor->limits.force)
{ {
pwrerr("ERROR: params->force > limits.force: %.2f > %.2f\n", mtrerr("params->force > limits.force: %.2f > %.2f\n",
params->force, motor->limits.force); params->force, motor->limits.force);
ret = -EPERM; ret = -EPERM;
@@ -488,14 +488,14 @@ static int motor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
ret = dev->ops->params_set(dev, params); ret = dev->ops->params_set(dev, params);
if (ret != OK) if (ret != OK)
{ {
pwrerr("ERROR: PWRIOC_SET_PARAMS failed %d\n", ret); mtrerr("MTRIOC_SET_PARAMS failed %d\n", ret);
} }
break; break;
} }
default: default:
{ {
pwrinfo("Forwarding unrecognized cmd: %d arg: %ld\n", cmd, arg); mtrinfo("Forwarding unrecognized cmd: %d arg: %ld\n", cmd, arg);
ret = dev->ops->ioctl(dev, cmd, arg); ret = dev->ops->ioctl(dev, cmd, arg);
break; break;
} }
@@ -537,7 +537,7 @@ int motor_register(FAR const char *path, FAR struct motor_dev_s *dev,
DEBUGASSERT(dev->ops->fault_set != NULL); DEBUGASSERT(dev->ops->fault_set != NULL);
DEBUGASSERT(dev->ops->state_get != NULL); DEBUGASSERT(dev->ops->state_get != NULL);
DEBUGASSERT(dev->ops->fault_get != NULL); DEBUGASSERT(dev->ops->fault_get != NULL);
DEBUGASSERT(dev->ops->fault_clean != NULL); DEBUGASSERT(dev->ops->fault_clear != NULL);
DEBUGASSERT(dev->ops->ioctl != NULL); DEBUGASSERT(dev->ops->ioctl != NULL);
/* Initialize the motor device structure */ /* Initialize the motor device structure */
-50
View File
@@ -334,56 +334,6 @@ config SMPS_HAVE_EFFICIENCY
endif endif
config DRIVERS_MOTOR
bool "Motor driver"
default n
---help---
Enables building of a motor upper half driver.
if DRIVERS_MOTOR
config MOTOR_HAVE_POSITION
bool "Have position control"
default n
config MOTOR_HAVE_DIRECTION
bool "Have direction control"
default n
config MOTOR_HAVE_SPEED
bool "Have speed control"
default n
config MOTOR_HAVE_TORQUE
bool "Have torque control (rotary motors)"
default n
config MOTOR_HAVE_FORCE
bool "Have force control (linear motors)"
default n
config MOTOR_HAVE_ACCELERATION
bool "Have acceleration control"
default n
config MOTOR_HAVE_DECELERATION
bool "Have deceleration control"
default n
config MOTOR_HAVE_INPUT_VOLTAGE
bool "Have input voltage protection"
default n
config MOTOR_HAVE_INPUT_CURRENT
bool "Have input current protection"
default n
config MOTOR_HAVE_INPUT_POWER
bool "Have input power protection"
default n
endif
menuconfig POWER menuconfig POWER
bool "Power Management Support" bool "Power Management Support"
default n default n
-12
View File
@@ -71,18 +71,6 @@ POWER_CFLAGS := ${shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)power}
endif endif
# Add motor driver
ifeq ($(CONFIG_DRIVERS_MOTOR),y)
CSRCS += motor.c
POWER_DEPPATH := --dep-path power
POWER_VPATH := :power
POWER_CFLAGS := ${shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)power}
endif
# Add battery charger drivers # Add battery charger drivers
ifeq ($(CONFIG_BATTERY_CHARGER),y) ifeq ($(CONFIG_BATTERY_CHARGER),y)
@@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* include/nuttx/power/motor.h * include/nuttx/motor/motor.h
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@@ -18,8 +18,8 @@
* *
****************************************************************************/ ****************************************************************************/
#ifndef __INCLUDE_NUTTX_DRIVERS_POWER_MOTOR_H #ifndef __INCLUDE_NUTTX_DRIVERS_MOTOR_MOTOR_H
#define __INCLUDE_NUTTX_DRIVERS_POWER_MOTOR_H #define __INCLUDE_NUTTX_DRIVERS_MOTOR_MOTOR_H
/* The motor driver is split into two parts: /* The motor driver is split into two parts:
* *
@@ -42,10 +42,10 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <nuttx/compiler.h> #include <nuttx/compiler.h>
#include <nuttx/power/power_ioctl.h> #include <nuttx/motor/motor_ioctl.h>
#include <nuttx/semaphore.h> #include <nuttx/semaphore.h>
#ifdef CONFIG_DRIVERS_MOTOR #ifdef CONFIG_MOTOR_UPPER
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
@@ -103,25 +103,25 @@ enum motor_direction_e
struct motor_feedback_s struct motor_feedback_s
{ {
#ifdef CONFIG_MOTOR_HAVE_POSITION #ifdef CONFIG_MOTOR_UPPER_HAVE_POSITION
float position; /* Current motor position */ float position; /* Current motor position */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_SPEED #ifdef CONFIG_MOTOR_UPPER_HAVE_SPEED
float speed; /* Current motor speed */ float speed; /* Current motor speed */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_TORQUE #ifdef CONFIG_MOTOR_UPPER_HAVE_TORQUE
float torque; /* Current motor torque (rotary motor) */ float torque; /* Current motor torque (rotary motor) */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_FORCE #ifdef CONFIG_MOTOR_UPPER_HAVE_FORCE
float force; /* Current motor force (linear motor) */ float force; /* Current motor force (linear motor) */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_INPUT_VOLTAGE #ifdef CONFIG_MOTOR_UPPER_HAVE_INPUT_VOLTAGE
float v_in; /* Current input voltage */ float v_in; /* Current input voltage */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_INPUT_CURRENT #ifdef CONFIG_MOTOR_UPPER_HAVE_INPUT_CURRENT
float i_in; /* Current input current */ float i_in; /* Current input current */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_INPUT_POWER #ifdef CONFIG_MOTOR_UPPER_HAVE_INPUT_POWER
float p_in; /* Current input power */ float p_in; /* Current input power */
#endif #endif
}; };
@@ -145,31 +145,31 @@ struct motor_limits_s
bool lock; /* This bit must be set after bool lock; /* This bit must be set after
* limits configuration. * limits configuration.
*/ */
#ifdef CONFIG_MOTOR_HAVE_POSITION #ifdef CONFIG_MOTOR_UPPER_HAVE_POSITION
float position; /* Maximum motor position */ float position; /* Maximum motor position */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_SPEED #ifdef CONFIG_MOTOR_UPPER_HAVE_SPEED
float speed; /* Maximum motor speed */ float speed; /* Maximum motor speed */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_TORQUE #ifdef CONFIG_MOTOR_UPPER_HAVE_TORQUE
float torque; /* Maximum motor torque (rotary motor) */ float torque; /* Maximum motor torque (rotary motor) */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_FORCE #ifdef CONFIG_MOTOR_UPPER_HAVE_FORCE
float force; /* Maximum motor force (linear motor) */ float force; /* Maximum motor force (linear motor) */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_ACCELERATION #ifdef CONFIG_MOTOR_UPPER_HAVE_ACCELERATION
float acceleration; /* Maximum motor acceleration */ float acceleration; /* Maximum motor acceleration */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_DECELERATION #ifdef CONFIG_MOTOR_UPPER_HAVE_DECELERATION
float deceleration; /* Maximum motor decelaration */ float deceleration; /* Maximum motor decelaration */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_INPUT_VOLTAGE #ifdef CONFIG_MOTOR_UPPER_HAVE_INPUT_VOLTAGE
float v_in; /* Maximum input voltage */ float v_in; /* Maximum input voltage */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_INPUT_CURRENT #ifdef CONFIG_MOTOR_UPPER_HAVE_INPUT_CURRENT
float i_in; /* Maximum input current */ float i_in; /* Maximum input current */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_INPUT_POWER #ifdef CONFIG_MOTOR_UPPER_HAVE_INPUT_POWER
float p_in; /* Maximum input power */ float p_in; /* Maximum input power */
#endif #endif
}; };
@@ -184,7 +184,7 @@ struct motor_params_s
* if there is no need to change motor * if there is no need to change motor
* parameter during run-time. * parameter during run-time.
*/ */
#ifdef CONFIG_MOTOR_HAVE_DIRECTION #ifdef CONFIG_MOTOR_UPPER_HAVE_DIRECTION
int8_t direction; /* Motor movement direction. We do not int8_t direction; /* Motor movement direction. We do not
* support negative values for parameters, * support negative values for parameters,
* so this flag can be used to allow movement * so this flag can be used to allow movement
@@ -192,22 +192,22 @@ struct motor_params_s
* a given coordinate system. * a given coordinate system.
*/ */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_POSITION #ifdef CONFIG_MOTOR_UPPER_HAVE_POSITION
float position; /* Motor position */ float position; /* Motor position */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_SPEED #ifdef CONFIG_MOTOR_UPPER_HAVE_SPEED
float speed; /* Motor speed */ float speed; /* Motor speed */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_TORQUE #ifdef CONFIG_MOTOR_UPPER_HAVE_TORQUE
float torque; /* Motor torque (rotary motor) */ float torque; /* Motor torque (rotary motor) */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_FORCE #ifdef CONFIG_MOTOR_UPPER_HAVE_FORCE
float force; /* Motor force (linear motor) */ float force; /* Motor force (linear motor) */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_ACCELERATION #ifdef CONFIG_MOTOR_UPPER_HAVE_ACCELERATION
float acceleration; /* Motor acceleration */ float acceleration; /* Motor acceleration */
#endif #endif
#ifdef CONFIG_MOTOR_HAVE_DECELERATION #ifdef CONFIG_MOTOR_UPPER_HAVE_DECELERATION
float deceleration; /* Motor deceleration */ float deceleration; /* Motor deceleration */
#endif #endif
}; };
@@ -268,15 +268,15 @@ struct motor_ops_s
/* Get motor state */ /* Get motor state */
CODE int (*state_get)(FAR struct motor_dev_s *dev, CODE int (*state_get)(FAR struct motor_dev_s *dev,
FAR struct motor_state_s *state); FAR struct motor_state_s *state);
/* Get current fault state */ /* Get current fault state */
CODE int (*fault_get)(FAR struct motor_dev_s *dev, FAR uint8_t *fault); CODE int (*fault_get)(FAR struct motor_dev_s *dev, FAR uint8_t *fault);
/* Clean fault state */ /* Clear fault state */
CODE int (*fault_clean)(FAR struct motor_dev_s *dev, uint8_t fault); CODE int (*fault_clear)(FAR struct motor_dev_s *dev, uint8_t fault);
/* Lower-half logic may support platform-specific ioctl commands */ /* Lower-half logic may support platform-specific ioctl commands */
@@ -331,5 +331,5 @@ int motor_register(FAR const char *path, FAR struct motor_dev_s *dev,
} }
#endif #endif
#endif /* CONFIG_DRIVERS_MOTOR */ #endif /* CONFIG_MOTOR_UPPER */
#endif /* __INCLUDE_NUTTX_DRIVERS_POWER_MOTOR_H */ #endif /* __INCLUDE_NUTTX_DRIVERS_MOTOR_MOTOR_H */
+4
View File
@@ -45,5 +45,9 @@
#define MTRIOC_SET_PARAMS _MTRIOC(5) #define MTRIOC_SET_PARAMS _MTRIOC(5)
#define MTRIOC_SET_CONFIG _MTRIOC(6) #define MTRIOC_SET_CONFIG _MTRIOC(6)
#define MTRIOC_GET_INFO _MTRIOC(7) #define MTRIOC_GET_INFO _MTRIOC(7)
#define MTRIOC_SET_MODE _MTRIOC(8)
#define MTRIOC_SET_LIMITS _MTRIOC(9)
#define MTRIOC_SET_FAULT _MTRIOC(10)
#define MTRIOC_GET_FAULT _MTRIOC(11)
#endif /* __INCLUDE_NUTTX_MOTOR_MOTOR_IOCTL_H */ #endif /* __INCLUDE_NUTTX_MOTOR_MOTOR_IOCTL_H */