esp32-servo/lib/uart/uart_handler.h

36 lines
682 B
C
Raw Normal View History

2025-08-21 14:44:24 +08:00
#pragma once
#include "driver/uart.h"
#include "driver/gpio.h"
#include "pca9685.h"
#ifdef __cplusplus
extern "C" {
#endif
// 舵机设备配置结构
typedef struct {
i2c_port_t port;
uint8_t addr;
} PCA9685_Device;
// 舵机角度状态
typedef struct {
uint8_t addr;
uint8_t channel;
float angle;
} ServoAngle;
// 舵机控制指令
typedef struct {
uint8_t addr; // PCA9685 地址
uint8_t channel; // 舵机通道
float angle; // 目标角度 (0~180)
uint16_t duration; // 转动持续时间 (ms)
} ServoCommand;
void uart_handler_init(uart_port_t uart_num);
void uart_handler_task(void *param);
#ifdef __cplusplus
}
#endif