#ifndef __DEVICE_SPEED_SERVOMOTOR_H_
#define __DEVICE_SPEED_SERVOMOTOR_H_
#include "ptz_type_select.h"
#include "stdint.h"
#include "ptz_header_file.h"
#include "servoMotor.h"
#include "servoMotor_recv.h"

#ifdef PTZ_SERVO_MOTOR

enum {
    nonePriority = 0,
    highPriority,
    lowPriority,
};

enum {
    horiMotorType = 0,
    vertMotorType,
};

//发送数据缓冲区的个数
#define sendDataBufNumber 8
//发送数据缓冲区的长度
#define sendDataBufLen 25
//发送链表，当个节点最大大小
#define linkListNodeLen 50


//发送链表
typedef struct _linkList {
    //发送的数据
    uint8_t data[sendDataBufLen];
    //发送的数据长度
    uint16_t length;
    //下一个节点
    struct _linkList *next;
} linkList;

typedef struct _motorLinkList{
    //发送数据，高优先级链表头
    linkList *LinkListHead_H;
    //发送数据，低优先级链表头
    linkList *LinkListHead_L;
    //水平电机发送数据，高优先级链表尾
    linkList *LinkListTail_H;
    //水平电机发送数据，低优先级链表尾
    linkList *LinkListTail_L;
    //当前发送数据的链表优先级
    uint8_t linkListPriority;
    //放入的数据个数
    uint8_t linkListNum;
} motorLinkList;

typedef struct _ptzServoLinkList {
    motorLinkList horiMotor;
    motorLinkList vertMotor;
} ptzServoLinkList;

extern BSP_OS_SEM g_horiSpeedSem;
extern BSP_OS_SEM g_vertSpeedSem;
extern BSP_OS_SEM g_horiSpeedMutex;
extern BSP_OS_SEM g_vertSpeedMutex;

extern ptzServoLinkList g_servoMotorLinkList;

void ptz_send_speed(char dev, char speed);
void init_speed_module(void);

void servoSendData(uint8_t motor,uint8_t *data, uint8_t dataLen, uint8_t priority);
void servoHoriLinkListMemPut(uint8_t motorType);
void stopTimeOut(uint8_t motorType);
void startTimeOut(uint8_t motorType);

#endif

#endif