RIOT
RIOT copied to clipboard
drivers/motor_driver: rework motor driver
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:
make -C tests/drivers/motor_driver BOARD=native
Run the test:
$ tests/drivers/motor_driver/bin/native/tests_motor_driver.elf
RIOT native interrupts/signals initialized.
RIOT native board initialized.
RIOT native hardware initialization complete.
ztimer_init(): ZTIMER_TIMER using periph timer 0, freq 1000000, width 32
ztimer_init(): ZTIMER_MSEC convert_frac from 1000000 to 1000
main(): This is RIOT! (Version: 2024.04-devel-392-g6fff3-rework_motor_driver)
RIOT native interrupts/signals initialized.
RIOT native board initialized.
RIOT native hardware initialization complete.
ztimer_init(): ZTIMER_TIMER using periph timer 0, freq 1000000, width 32
ztimer_init(): ZTIMER_MSEC convert_frac from 1000000 to 1000
main(): This is RIOT! (Version: 2024.04-devel-392-g6fff3-rework_motor_driver)
Brake motors
Actuate Motors
MOTOR-DRIVER=0x80550e4 MOTOR_ID = 0 PWM_VALUE = 50
MOTOR-DRIVER=0x80550e4 MOTOR_ID = 1 PWM_VALUE = 50
Disable motors
Enable GPIO is not valid for motor 0, skipping disable
Enable GPIO is not valid for motor 1, skipping disable
Enable motors
Enable GPIO is not valid for motor 0, skipping enable
Enable GPIO is not valid for motor 1, skipping enable
Actuate Motors
MOTOR-DRIVER=0x80550e4 MOTOR_ID = 0 PWM_VALUE = 100
MOTOR-DRIVER=0x80550e4 MOTOR_ID = 1 PWM_VALUE = 100
Brake motors
Actuate Motors
MOTOR-DRIVER=0x80550e4 MOTOR_ID = 0 PWM_VALUE = -50
MOTOR-DRIVER=0x80550e4 MOTOR_ID = 1 PWM_VALUE = -50
Disable motors
Enable GPIO is not valid for motor 0, skipping disable
Enable GPIO is not valid for motor 1, skipping disable
Enable motors
Enable GPIO is not valid for motor 0, skipping enable
Enable GPIO is not valid for motor 1, skipping enable
Actuate Motors
MOTOR-DRIVER=0x80550e4 MOTOR_ID = 0 PWM_VALUE = -100
MOTOR-DRIVER=0x80550e4 MOTOR_ID = 1 PWM_VALUE = -100
@kfessel thx for review, I added 2 fixup commits related to your comments and few other small things. :wink:
this has minor API changes