FRDM-IMX93 for NXP CUP
FRDM-IMX93 support for NXP CUP
 
Loading...
Searching...
No Matches
servo.h File Reference

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.
 

Detailed Description

MG996R servo motor API definition.

This file offers the API required for working with the MG996R servo motor.

Macro Definition Documentation

◆ MSEC_TO_NSEC

#define MSEC_TO_NSEC (   x)    ((x) * NSEC_PER_MSEC)

convert miliseconds to nanoseconds

◆ SERVO_MAX_ANGLE

#define SERVO_MAX_ANGLE   180

maximum angle supported by the servo

◆ SERVO_MSEC_LEFT

#define SERVO_MSEC_LEFT   MSEC_TO_NSEC(1.0f)

1ms PWM duty cycle means the servo is in the most left position

◆ SERVO_MSEC_RIGHT

#define SERVO_MSEC_RIGHT   MSEC_TO_NSEC(2.0f)

2ms PWM duty cycle means the servo is in the most right position

Function Documentation

◆ servo_set_angle()

int servo_set_angle ( struct nxp_servo servo,
uint32_t  angle 
)

Set the angle of the servo motor.

Parameters
servopointer to the structure representing the MG996R servo motor
angleangle to set (between 0 and 180 degrees)
Return values
0on success
negativeerrno code if failure