172 lines
4.2 KiB
C
172 lines
4.2 KiB
C
|
|
#ifndef __COLORCONTROL_H__
|
|
#define __COLORCONTROL_H__
|
|
|
|
#include "controlbus.h"
|
|
|
|
#if (CONTROL_BUS == COMM_CAN)
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
typedef struct
|
|
{
|
|
u8 nodeId;
|
|
|
|
CtrlBusPacket ctrlCmd; // 发给外围板的控制命令
|
|
CtrlBusPacket exbSta; // 外围板返回的状态命令
|
|
BoardRegVal regVal; // 外围板寄存器值
|
|
CtrlBusPacket rdReg; // 读取外围板寄存器值
|
|
|
|
int cmdFlag; // 有新命令标志
|
|
int staFlag; // 有新状态标志
|
|
|
|
int refSta; // 刷新状态标志
|
|
|
|
int verFlag; // 有新程序版本标志
|
|
int refVer; // 刷新程序版本标志
|
|
|
|
int transFlag; // 数据传输标志 发送数据
|
|
|
|
u8 exbupdateFlag; // 外围板程序升级标志
|
|
|
|
u8 refNvPara; // 刷新非易失性参数
|
|
u8 nvParaFlag; // 接收到非易失性参数标志
|
|
|
|
}ColorControl;
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
typedef union
|
|
{
|
|
u8 buff[CAN_DATA_LEN];
|
|
|
|
//---------------
|
|
|
|
struct
|
|
{
|
|
u16 cmd;
|
|
u8 subcmd;
|
|
u8 para[5];
|
|
} __attribute__ ((packed)) colorCtrl; // 控制
|
|
|
|
struct
|
|
{
|
|
u16 cmd;
|
|
u8 needleNums; // 针杆数量
|
|
u8 rev[5]; // 预留
|
|
} __attribute__ ((packed)) colorPara; // 参数
|
|
|
|
struct
|
|
{
|
|
u16 cmd;
|
|
u8 parablockID; // 参数块ID
|
|
u8 paraID; // 参数ID
|
|
s32 paraval; // 参数值
|
|
} __attribute__ ((packed)) colorNvPara; // 非易失性参数
|
|
|
|
struct
|
|
{
|
|
u16 staBits; // 状态位
|
|
u16 potValue; // 电位器值
|
|
s8 curNeedle; // 当前针位
|
|
s8 needleNums; // 针杆数量
|
|
u8 rev[2];
|
|
} __attribute__ ((packed)) colorSta; // 状态
|
|
|
|
//-----------------------------------------------
|
|
|
|
struct
|
|
{
|
|
u16 cmd;
|
|
u8 subcmd; // 子命令
|
|
u8 para[5];
|
|
} __attribute__ ((packed)) chenilleCtrl; // 毛巾绣控制
|
|
|
|
struct
|
|
{
|
|
u16 staBits; // 状态位
|
|
u16 potValue; // 电位器值(松紧线电机电位器)
|
|
s8 curNeedle; // 当前针位
|
|
s8 needleNums; // 针杆数量
|
|
s8 elasticWirePos; // 松紧线电机位置
|
|
u8 rev;
|
|
} __attribute__ ((packed)) chenilleSta; // 毛巾绣状态
|
|
|
|
struct
|
|
{
|
|
u16 cmd;
|
|
u8 para[6]; // 预留
|
|
} __attribute__ ((packed)) chenillePara; // 毛巾绣参数
|
|
|
|
}ColorCommand;
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
// 命令
|
|
|
|
/*
|
|
#define CTRL_CMD_EMB_HEAD_CTRL 0x1000 // 平绣机头板控制
|
|
#define CTRL_CMD_EMB_HEAD_PARA 0x1001 // 平绣机头板参数设置
|
|
#define CTRL_CMD_HEAD_NVPARA 0x1002 // 平绣机头非易失性参数设置
|
|
|
|
#define CTRL_CMD_CHENILLE_HEAD_CTRL 0x1010 // 毛巾机头板控制
|
|
#define CTRL_CMD_CHENILLE_HEAD_PARA 0x1011 // 毛巾机头板参数设置
|
|
#define CTRL_CMD_CHENILLE_NVPARA 0x1012 // 毛巾机头非易失性参数设置
|
|
|
|
#define CTRL_CMD_COIL_HEAD_CTRL 0x1020 // 缠绕机头板控制
|
|
#define CTRL_CMD_COIL_HEAD_PARA 0x1021 // 缠绕机头板参数设置
|
|
#define CTRL_CMD_COIL_NVPARA 0x1022 // 缠绕机头非易失性参数设置
|
|
*/
|
|
|
|
#define CTRL_CMD_COLOR_CTRL 0x1100 // 控制命令
|
|
#define CTRL_CMD_COLOR_PARA 0x1101 // 参数设置命令
|
|
#define CTRL_CMD_COLOR_NVPARA 0x1102 // 非易失性参数设置
|
|
|
|
// 控制命令的子命令
|
|
#define CTRL_SUBCMD_SWITCH_NEEDLE 0x01 // 换色控制
|
|
#define CTRL_SUBCMD_CHG_MOTO_CTRL 0x02 // 换色电机控制
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
//-------------------------------------------------------------------------------
|
|
// 毛巾绣控制
|
|
#define CTRL_CMD_CHENILLE_CTRL 0x1110 //毛巾控制
|
|
|
|
// 子命令
|
|
#define CTRL_SUBCMD_ELASTIC_CTRL 0x01 // 松紧线控制
|
|
#define CTRL_SUBCMD_CHENILLE_COLOR 0x02 // 毛巾换色控制
|
|
|
|
// 松紧线控制para[0]定义
|
|
#define ELASTICWIRE_COLORCHANGE_POS 1 // 松紧线电机换色位
|
|
#define ELASTICWIRE_TRIMMING_POS 2 // 松紧线电机剪线位
|
|
#define ELASTICWIRE_CHAIN_POS 3 // 松紧线电机链式位
|
|
#define ELASTICWIRE_CHENILLE_POS 4 // 松紧线电机毛巾位
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
void InitColorControl(ColorControl * pCtrl);
|
|
|
|
void SendColorCommand(ColorControl * pCtrl, ColorCommand * pCmd);
|
|
|
|
void RequestColorStatus(ColorControl * pCtrl);
|
|
|
|
void RequestColorVersion(ColorControl * pCtrl);
|
|
|
|
void RequestColorNvPara(ColorControl * pCtrl);
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
#endif
|
|
#endif
|