MG996R servo motor API definition. More...
#include <zephyr/drivers/pwm.h>
Go to the source code of this file.
Classes | |
struct | nxp_servo |
Represents the MG996R servo motor. More... | |
Macros | |
#define | MSEC_TO_NSEC(x) ((x) * NSEC_PER_MSEC) |
#define | SERVO_MSEC_LEFT MSEC_TO_NSEC(1.0f) |
#define | SERVO_MSEC_RIGHT MSEC_TO_NSEC(2.0f) |
#define | SERVO_MAX_ANGLE 180 |
Functions | |
int | servo_set_angle (struct nxp_servo *servo, uint32_t angle) |
Set the angle of the servo motor. | |
MG996R servo motor API definition.
This file offers the API required for working with the MG996R servo motor.
#define MSEC_TO_NSEC | ( | x | ) | ((x) * NSEC_PER_MSEC) |
convert miliseconds to nanoseconds
#define SERVO_MAX_ANGLE 180 |
maximum angle supported by the servo
#define SERVO_MSEC_LEFT MSEC_TO_NSEC(1.0f) |
1ms PWM duty cycle means the servo is in the most left position
#define SERVO_MSEC_RIGHT MSEC_TO_NSEC(2.0f) |
2ms PWM duty cycle means the servo is in the most right position
int servo_set_angle | ( | struct nxp_servo * | servo, |
uint32_t | angle | ||
) |
Set the angle of the servo motor.
servo | pointer to the structure representing the MG996R servo motor |
angle | angle to set (between 0 and 180 degrees) |
0 | on success |
negative | errno code if failure |