Files
tronone-h7-scaffold/User_Code/module/periph/servo/mg996/mg996.h

68 lines
1.4 KiB
C
Raw Normal View History

2025-12-24 14:11:50 +08:00
/**
* @file mg996.h
* @author TuxMonkey (https://github.com/TuxMonkey)
* @brief MG996 servo motor driver header (MG996舵机驱动头文件)
* @version 1.0
* @date 2024-06-10
**/
2025-11-17 16:27:19 +08:00
2025-12-24 14:11:50 +08:00
#ifndef MG996_H
#define MG996_H
2025-11-17 16:27:19 +08:00
2025-12-24 14:11:50 +08:00
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
2026-01-09 03:05:55 +08:00
#include "bsp_pwm.h"
2025-12-24 14:11:50 +08:00
/**
* @brief MG996舵机初始化配置结构体
*/
typedef struct
{
void *pwm_config; /**< PWM配置参数 */
float min_dutyratio; /**< 最小占空比 (0.0 - 1.0) */
float max_dutyratio; /**< 最大占空比 (0.0 - 1.0) */
float min_angle; /**< 最小角度 (度) */
float max_angle; /**< 最大角度 (度) */
} MG996_Init_Config_s;
/**
* @brief MG996舵机实例结构体
*/
typedef struct
{
PWMInstance *pwm; /**< PWM控制器实例指针类型与bsp_pwm.h中的PWMInstance一致 */
float min_dutyratio; /**< 最小占空比 */
float max_dutyratio; /**< 最大占空比 */
float min_angle; /**< 最小角度 (度) */
float max_angle; /**< 最大角度 (度) */
} MG996Instance;
/**
* @brief MG996舵机
*
* @param config
* @return MG996Instance* NULL
*/
MG996Instance *MG996Register(MG996_Init_Config_s *config);
/**
* @brief
*
* @param mg996
* @param angle ()
*/
void MG996SetAngle(MG996Instance *mg996, float angle);
#ifdef __cplusplus
}
#endif
#endif /* MG996_H */