Skip to content

Commit 9ebf11f

Browse files
committed
wip
Signed-off-by: Jilay Pandya <[email protected]>
1 parent db1fe60 commit 9ebf11f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1043
-2023
lines changed

drivers/stepper/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ add_subdirectory_ifdef(CONFIG_STEPPER_ADI_TMC adi_tmc)
88
add_subdirectory_ifdef(CONFIG_STEPPER_ALLEGRO allegro)
99
add_subdirectory_ifdef(CONFIG_STEPPER_TI ti)
1010
add_subdirectory_ifdef(CONFIG_STEP_DIR_STEPPER step_dir)
11+
add_subdirectory_ifdef(CONFIG_ZEPHYR_STEPPER_MOTION_CONTROL stepper_motion_controllers)
1112
# zephyr-keep-sorted-stop
1213

1314
zephyr_library()

drivers/stepper/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ config STEPPER_SHELL
2727
comment "Stepper Driver Common"
2828

2929
rsource "step_dir/Kconfig"
30+
rsource "stepper_motion_controllers/Kconfig"
3031

3132
comment "Stepper Drivers"
3233

drivers/stepper/adi_tmc/tmc22xx.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,25 @@ struct tmc22xx_config {
1919
};
2020

2121
struct tmc22xx_data {
22-
struct step_dir_stepper_common_data common;
2322
enum stepper_micro_step_resolution resolution;
2423
};
2524

26-
STEP_DIR_STEPPER_STRUCT_CHECK(struct tmc22xx_config, struct tmc22xx_data);
25+
STEP_DIR_STEPPER_STRUCT_CHECK(struct tmc22xx_config);
2726

2827
static int tmc22xx_stepper_enable(const struct device *dev)
2928
{
3029
const struct tmc22xx_config *config = dev->config;
3130

3231
LOG_DBG("Enabling Stepper motor controller %s", dev->name);
33-
return gpio_pin_set_dt(&config->enable_pin, 1);
32+
return gpio_pin_set_dt(&config->enable_pin, 0);
3433
}
3534

3635
static int tmc22xx_stepper_disable(const struct device *dev)
3736
{
3837
const struct tmc22xx_config *config = dev->config;
3938

4039
LOG_DBG("Disabling Stepper motor controller %s", dev->name);
41-
return gpio_pin_set_dt(&config->enable_pin, 0);
40+
return gpio_pin_set_dt(&config->enable_pin, 1);
4241
}
4342

4443
static int tmc22xx_stepper_set_micro_step_res(const struct device *dev,
@@ -150,15 +149,8 @@ static int tmc22xx_stepper_init(const struct device *dev)
150149
static DEVICE_API(stepper, tmc22xx_stepper_api) = {
151150
.enable = tmc22xx_stepper_enable,
152151
.disable = tmc22xx_stepper_disable,
153-
.move_by = step_dir_stepper_common_move_by,
154-
.is_moving = step_dir_stepper_common_is_moving,
155-
.set_reference_position = step_dir_stepper_common_set_reference_position,
156-
.get_actual_position = step_dir_stepper_common_get_actual_position,
157-
.move_to = step_dir_stepper_common_move_to,
158-
.set_microstep_interval = step_dir_stepper_common_set_microstep_interval,
159-
.run = step_dir_stepper_common_run,
160-
.stop = step_dir_stepper_common_stop,
161-
.set_event_callback = step_dir_stepper_common_set_event_callback,
152+
.step = step_dir_stepper_common_step,
153+
.set_direction = step_dir_stepper_common_set_direction,
162154
.set_micro_step_res = tmc22xx_stepper_set_micro_step_res,
163155
.get_micro_step_res = tmc22xx_stepper_get_micro_step_res,
164156
};
@@ -183,7 +175,6 @@ static DEVICE_API(stepper, tmc22xx_stepper_api) = {
183175
(.msx_pins = tmc22xx_stepper_msx_pins_##inst)) \
184176
}; \
185177
static struct tmc22xx_data tmc22xx_data_##inst = { \
186-
.common = STEP_DIR_STEPPER_DT_INST_COMMON_DATA_INIT(inst), \
187178
.resolution = DT_INST_PROP(inst, micro_step_res), \
188179
}; \
189180
DEVICE_DT_INST_DEFINE(inst, tmc22xx_stepper_init, NULL, &tmc22xx_data_##inst, \

drivers/stepper/allegro/a4979.c

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ static int a4979_stepper_disable(const struct device *dev)
9393
return ret;
9494
}
9595

96-
config->common.timing_source->stop(dev);
9796
data->enabled = false;
9897

9998
return 0;
@@ -121,7 +120,6 @@ static int a4979_stepper_set_micro_step_res(const struct device *dev,
121120
case STEPPER_MICRO_STEP_4:
122121
m0_value = 0;
123122
m1_value = 1;
124-
break;
125123
case STEPPER_MICRO_STEP_16:
126124
m0_value = 1;
127125
m1_value = 1;
@@ -153,42 +151,6 @@ static int a4979_stepper_get_micro_step_res(const struct device *dev,
153151
return 0;
154152
}
155153

156-
static int a4979_move_to(const struct device *dev, int32_t target)
157-
{
158-
struct a4979_data *data = dev->data;
159-
160-
if (!data->enabled) {
161-
LOG_ERR("Failed to move to target position, device is not enabled");
162-
return -ECANCELED;
163-
}
164-
165-
return step_dir_stepper_common_move_to(dev, target);
166-
}
167-
168-
static int a4979_stepper_move_by(const struct device *dev, const int32_t micro_steps)
169-
{
170-
struct a4979_data *data = dev->data;
171-
172-
if (!data->enabled) {
173-
LOG_ERR("Failed to move by delta, device is not enabled");
174-
return -ECANCELED;
175-
}
176-
177-
return step_dir_stepper_common_move_by(dev, micro_steps);
178-
}
179-
180-
static int a4979_run(const struct device *dev, enum stepper_direction direction)
181-
{
182-
struct a4979_data *data = dev->data;
183-
184-
if (!data->enabled) {
185-
LOG_ERR("Failed to run stepper, device is not enabled");
186-
return -ECANCELED;
187-
}
188-
189-
return step_dir_stepper_common_run(dev, direction);
190-
}
191-
192154
static int a4979_init(const struct device *dev)
193155
{
194156
const struct a4979_config *config = dev->config;
@@ -269,17 +231,10 @@ static int a4979_init(const struct device *dev)
269231
static DEVICE_API(stepper, a4979_stepper_api) = {
270232
.enable = a4979_stepper_enable,
271233
.disable = a4979_stepper_disable,
272-
.move_by = a4979_stepper_move_by,
273-
.move_to = a4979_move_to,
274-
.is_moving = step_dir_stepper_common_is_moving,
275-
.set_reference_position = step_dir_stepper_common_set_reference_position,
276-
.get_actual_position = step_dir_stepper_common_get_actual_position,
277-
.set_microstep_interval = step_dir_stepper_common_set_microstep_interval,
278-
.run = a4979_run,
279-
.stop = step_dir_stepper_common_stop,
280234
.set_micro_step_res = a4979_stepper_set_micro_step_res,
281235
.get_micro_step_res = a4979_stepper_get_micro_step_res,
282-
.set_event_callback = step_dir_stepper_common_set_event_callback,
236+
.step = step_dir_stepper_common_step,
237+
.set_direction = step_dir_stepper_common_set_direction,
283238
};
284239

285240
#define A4979_DEVICE(inst) \

0 commit comments

Comments
 (0)