drivers/motor_driver: rework motor driver#20429
Conversation
43ad42f to
f975209
Compare
f975209 to
6c4dbb8
Compare
drivers/motor_driver/motor_driver.c
Outdated
| if ((gpio_is_valid(motor->gpio_dir0)) | ||
| && (gpio_is_valid(motor->gpio_dir1_or_brake))) { | ||
| gpio_write(motor->gpio_dir0, direction); | ||
| gpio_write(motor->gpio_dir1_or_brake, direction ^ 0x1); |
There was a problem hiding this comment.
the XOR 0x01 seems a little non generic
There was a problem hiding this comment.
not sure to understand, xor is not ok or 0x01 ?
I replaced with: direction ^ 1
drivers/motor_driver/motor_driver.c
Outdated
|
|
||
| return 0; | ||
| /* Set callbacks according to driver type */ | ||
| switch(motor_driver_params->mode) { |
There was a problem hiding this comment.
wouldn't it make more sense do a switch when the brake or direction function is called instead of storing an extra function pointer?
There was a problem hiding this comment.
The first idea was to make this two callbacks configurables with motor_driver_params_t. However as the driver is able to support most of existing motor drivers, I did not find really relevant to expose this callbacks inside motor_driver_params_t.
But I kept them internally, because it allows less lines of code at the price of 2 pointers, indeed.
As I do not have a real opinion about this, I follow your review. 😉
|
@kfessel thx for review, I added 2 fixup commits related to your comments and few other small things. 😉 |
kfessel
left a comment
There was a problem hiding this comment.
some nitpicks by our static_tests
|
this has minor API changes |
6fff369 to
3e5dec2
Compare
|
@gdoffe are you still interested in getting this merged? I (unknowingly) did a subset of this PR, but yours is superior. I rebased your PR to the current Edit: The merge conflict was caused by #21626, but I think this PR replaces that part of the code anyway. |
|
Hi @crasbe ! I left a few outdated PRs that I should update, this one is one of them. |
|
Thank you. I just rebased my branch again after merging #21337 yesterday, so it should be good to go again. |
3e5dec2 to
342333e
Compare
|
@crasbe fixup applied, seems ok for native. I will do real tests next week, I cannot test before. But I dont worry. 😉 |
58b731c to
3a30592
Compare
|
@crasbe I fixed the issue from merge queue Murdock CI. But is it different from the Murdock triggered by the merge request ? 🤔 |
|
The quick build only builds a selection of boards and the merge builds all boards. Therefore not all issues show up in the quick build. The specific error showed up with the Bitcraze Crazyflie, because that uses the |
3a30592 to
dd6701a
Compare
|
Arf sorry I missed your suggestions, I already pushed fixes. 😉 Do you want me to apply them ? |
Don't worry about those, I made new suggestions about the indentation for the |
dd6701a to
ac3b403
Compare
|
You'll have to add a BOARD_INSUFFICIENT_MEMORY := \
arduino-duemilanove \
arduino-nano \
arduino-uno \
atmega328p \
atmega328p-xplained-mini \
atmega8 \
#I ran |
The motor_driver device driver is developed as a periph driver and it should not. Make this driver compliant with RIOT device driver development guide [1]. Also make some cleanups and fix some typos. [1] https://doc.riot-os.org/driver-guide.html Signed-off-by: Gilles DOFFE <[email protected]> Co-authored-by: crasbe <[email protected]>
Rework the test as the motor_driver module has been reworked to be compliant with RIOT device driver development guide. Mainly keep same behavior and use a simpler callback to illustrate post motor_set() callback use. Signed-off-by: Gilles DOFFE <[email protected]> Co-authored-by: crasbe <[email protected]>
XTIMER_BACKOFF and XTIMER_ISR_BACKOFF were defined in periph_conf.h since 2016 for the legacy xtimer module, which required high backoff values (200) on native to prevent timer underflow issues. However, since the migration to ztimer, all code now uses MODULE_ZTIMER_XTIMER_COMPAT which includes ztimer/xtimer_compat.h before periph_conf.h. This means xtimer_compat.h always defines XTIMER_BACKOFF=1 first, and the periph_conf.h definitions are never used. Remove these unused definitions as they serve no purpose with the current ztimer-based implementation. Signed-off-by: Gilles DOFFE <[email protected]>
The motor_driver module has been reworked in a previous commit to be compliant with RIOT device driver guide. Thus declaration in board.h is no more needed and should not work anymore. Moreover the driver test was calling a callback specific to the native architecture to simulate the native QDEC periph driver according to motors speed. This is not relevant as a test should only test the feature it has been developed for. Signed-off-by: Gilles DOFFE <[email protected]>
The motor_driver module has been reworked in a previous commit to be compliant with RIOT device driver guide. Thus declaration in board.h is no more needed and should not work anymore. Signed-off-by: Gilles DOFFE <[email protected]>
Migrate motor driver configuration from inline definition in board.h to the new board-specific motor_driver_params.h header file. The old approach defined motor_driver_config[] directly in board.h and unconditionally included motor_driver.h, causing compilation failures for applications that do not use the motor_driver module. This allows the motor driver header to be included only when the module is actually used, while board-specific parameters take precedence over driver defaults due to include path ordering. Configuration migrated: - Driver 0: PWM device 1, 3 motors (channels 1, 3, 0) - Driver 1: PWM device 2, 1 motor (channel 0) - Mode: MOTOR_DRIVER_1_DIR with inverted brake for both drivers Signed-off-by: Gilles DOFFE <[email protected]>
Remove redundant macros since CONFIG_ZTIMER_USEC_TYPE and CONFIG_ZTIMER_USEC_DEV were already set to their default values. Signed-off-by: Gilles DOFFE <[email protected]>
ac3b403 to
22c6b2b
Compare
|
Thank you for pulling this through :) |
Thank to you for your help ! |
Contribution description
The motor_driver device driver is developed as a periph driver and it should not.
Make this driver compliant with RIOT device driver development guide [1].
Also make some cleanups and fix some typos.
[1] https://doc.riot-os.org/driver-guide.html
Testing procedure
Build for native architecture:
Run the test: