optical/EMBOS/Users/EmbFunc/extendboards/extendboards.h
2025-09-04 09:45:08 +08:00

185 lines
4.7 KiB
C

#ifndef __EXTENDBOARDS_H__
#define __EXTENDBOARDS_H__
//------------------------------------------------------------------------------------
// 管理主控通过控制总线控制的外围板卡
//------------------------------------------------------------------------------------
#include "corecontrol.h"
#include "headcontrol.h"
#include "colorcontrol.h"
#include "extiocontrol.h"
#include "sewhdcontrol.h"
#include "transdata.h"
#include "operator.h"
//------------------------------------------------------------------------------------
#define BN_ID_CORE_1 0x01
#define BN_ID_CORE_2 0x02
#define BN_ID_CORE_3 0x03
//------------------------------------------------------------------------------------
#ifndef MAX_SUPPORT_CORE
#define MAX_SUPPORT_CORE 1
#endif
#ifndef CUR_COREBOARD_ID
#define CUR_COREBOARD_ID BN_ID_CORE_1
#endif
#ifndef CUR_CORE_IDX
#define CUR_CORE_IDX 0
#endif
//------------------------------------------------------------------------------------
#ifndef RD_HEAD_PARA_NUM
#define RD_HEAD_PARA_NUM 0
#endif
#ifndef MAX_SUPPORT_HEAD
#define MAX_SUPPORT_HEAD 0
#endif
//------------------------------------------------
#ifndef MAX_SUPPORT_SEWHD
#define MAX_SUPPORT_SEWHD 0
#endif
#ifndef MAX_SUPPORT_COLOR
#define MAX_SUPPORT_COLOR 0
#endif
#ifndef MAX_SUPPORT_EXTIO
#define MAX_SUPPORT_EXTIO 0
#endif
#ifndef HEAD_NODEID_BASE
#define HEAD_NODEID_BASE 21 // 机头板起始ID
#endif
#ifndef COLOR_NODEID_BASE
#define COLOR_NODEID_BASE 18 // 换色板起始ID
#endif
#ifndef EXTIO_NODEID_BASE
#define EXTIO_NODEID_BASE 2 // IO扩展板起始ID
#endif
#ifndef SEWHD_NODEID_BASE
#define SEWHD_NODEID_BASE 21 // 机头板起始ID
#endif
//------------------------------------------------------------------------------------
#define BOARD_PARA_SIZE 256 // 暂定256个字节(一个参数块的大小)
//------------------------------------------------------------------------------------
void InitBoardsList(void);
void InitExtendBoards(void);
void InputsTask(void);
void OutputsTask(void);
void ExtendBoardTask(void);
//------------------------------------------------------------------------------------
CoreControl * GetCoreFromList(u8 id);
HeadControl * GetHeadFromList(u8 id);
ColorControl * GetColorFromList(u8 id);
ExtIOControl * GetExtIOFromList(u8 id);
int GetCurBoardID(void);
//------------------------------------------------------------------------------------
#if (MAX_SUPPORT_CORE > 0)
int IsNewControlCommand(void);
void RequestExStatus(void);
#endif
//------------------------------------------------------------------------------------
void StartBoardUpdate(u8 protocol, u8 nodetype, u8 nodeid);
void SetBoardNvPara(int protocolType, int nodetype, int nodeId, u8 parablockID, u8 paraID, s32 paraVal);
//------------------------------------------------------------------------------------
#if (MAX_SUPPORT_HEAD > 0)
// 遍历功能相关
void EnterTraverse(void);
int TraverseSingleNode(u8 traNodeType, u8 traNodeId); // 总线遍历
int CurNodeTraverseAlready(u32 nodeid);
void ExitTravers(void); // 退出遍历
void InquireBusSta(int idx);
u32 GetHeadStatus(int idx);
void CleanHeadStatus(int idx);
void RequestHeadsStatus(void);
void RequestHeadsVersion(void);
void RequestAHeadNvPara(int idx);
void SendHeadAngCmd(int idx, u8 para1, u16 para2, u8 para3);
void SetHeadNvParaCmd(int nodetype, int idx, u8 parablockid, u8 paraid, s32 paraval);
u16 GetHeadPotValue(int idx);
int GetHeadCurrentNeele(int idx);
#endif
#if (MAX_SUPPORT_COLOR > 0)
void RequestColorsVersion(void);
void RequestAColorNvPara(int idx);
void SendColorCtrlCmd(int idx, u8 subcmd, u8 para1, u8 para2); // 换色板控制命令
void SetColorNvParaCmd(int idx, u8 parablockid, u8 paraid, s32 paraval);
void SendColorParaCmd(int idx, u8 para1);
void CleanColorSta(int idx);
u16 GetColorStatus(int idx);
u16 GetColorPotValue(int idx);
int GetColorCurrentNeele(int idx);
void RequestColorsStatus(void);
#endif
#if (MAX_SUPPORT_EXTIO > 0)
u16 GetExtIOStatus(int idx);
void CleanExtIOStatus(int idx);
void RequestExtIOsStatus(void);
void RequestExtIOsVersion(void);
void SetExtOutputOn(int idx, u16 bit);
void SetExtOutputOff(int idx, u16 bit);
#endif
#if (MAX_SUPPORT_SEWHD > 0)
void RequestSewHeadsStatus(void);
void RequestSewHeadsVersion(void);
u16 GetSewHeadStatus(int idx);
void SendSewHeadCtrlCmd(int idx, u8 subcmd, u8 para1, u8 para2);
void CleanSewHeadSta(int idx);
#endif
#if (RD_HEAD_PARA_NUM > 0)
int ReceiveBoardNvParaProc(CanRxMsg rxMsg, int id, u8 nodetype);
u8* GetBoardNvPara(int id);
#endif
void ParaDataFromOperToCan(u8 protocol, OperPacket * pPkt, BoardFilePacketCtrl * pBoard);
void SendPacketDataWithCanFrame(u32 exid, BoardFilePacketCtrl * pBoard);
s32 GetHeadPara(void);
//------------------------------------------------------------------------------------
#endif /* __EXTENDBOARDS_H__ */