📄 fbhart.c
字号:
/**********************************************************************
* Function Block Factory Files Generator V 1.0 *
* This file was generated automatically! *
* ============================================== *
* DO NEVER MAKE CHANGES IN THIS FILE MANUALLY!!! *
* ============================================== *
* Date/Time: 31.07.00 12:54:23 *
* *
* *
* Copyright 2000, Borst Automation, Fachingen *
* All Rights Reserved *
* *
* File Name: FbHart.c *
* Device: MyDevice *
* Author(s): *
* Walter Borst *
* *
* Revision History *
* ================ *
* 1.11.1999, W.Borst: *
* Initial Version *
* *
**********************************************************************/
/**********************************************************************
* The standard include *
**********************************************************************/
#define __FBHART_H__
#include "..\FbHart\FbHart.h"
/**********************************************************************
* User Includes and Definitions *
**********************************************************************/
#include "..\Iout\Iout.h"
#include "..\Common\Hart.h"
#include "..\Protocol\HartLoL.h"
#include "..\Common\PcComPrt.h"
#include "..\Api\HartApi.h"
static T_BOOL m_bColdStart = T_TRUE;
/**********************************************************************
* Function Block Parameters *
**********************************************************************/
/*
* Funny number of command 0
*/
ROM UINT8 co_ui8FbHartCmd0ID = 254;
/*
* Manufacturer's HART Identifier
*/
ROM UINT8 co_ui8FbHartMfrID = 251;
/*
* Manufacturer's Device Type
*/
ROM UINT8 co_ui8FbHartMfrDevType = 0x01;
/*
* Number of Request Preambles
*/
ROM UINT8 co_ui8FbHartNoReqPreAmbs = 5;
/*
* Version of HART Command Specification
*/
ROM UINT8 co_ui8FbHartUnivCmdRev = 5;
/*
* Transmitter Specific Revision
*/
ROM UINT8 co_ui8FbHartTransmSpecRev = 10;
/*
* Software Version
*/
ROM UINT8 co_ui8FbHartSoftwRev = 10;
/*
* Hardware Version (0x08 = 1.0)
*/
ROM UINT8 co_ui8FbHartHardwRev = 0x08;
/*
* Device has no Flags
*/
ROM UINT8 co_ui8FbHartFlags = 0;
/*
* Remark: The Device ID Number has
* to be unique because it is used to build the unique identifier.
*/
ROM UINT24 co_ui24FbHartDeviceIDnum = 4711;
/*
* Used by the HART low level communication driver.
*/
RAM BYTE rs_osFbHartUniqueID[5]
= { 0x0, 0x0, 0x0, 0x0, 0x0 };
/*
* Used to store response code 2 for the HART protocol
*/
RAM UINT8 rs_ui8FbHartResponse2 = 0;
/*
* Only stored for HART environment,
* Default Value = 'WALTER__'
*/
EEPROM BYTE ee_paFbHartTagName[6];
RAM BYTE re_paFbHartTagName[6];
RAM BYTE rl_paFbHartTagName[6]
= { 92,19,20,21,39,223 };
/*
* Only stored for HART environment,
* Default Value: Spaces
*/
EEPROM BYTE ee_paFbHartDescription[12];
RAM BYTE rs_paFbHartDescription[12]
= { 130,8,32,130,8,32,130,8,32,130,8,32 };
/*
* Only stored for HART environment
*/
EEPROM UINT8 ee_ui8FbHartDayOfMonth;
RAM UINT8 rs_ui8FbHartDayOfMonth = 7;
/*
* Only stored for HART environment
*/
EEPROM UINT8 ee_ui8FbHartMonthOfYear;
RAM UINT8 rs_ui8FbHartMonthOfYear = 11;
/*
* Only stored for HART environment
*/
EEPROM UINT8 ee_ui8FbHartYearSince1900;
RAM UINT8 rs_ui8FbHartYearSince1900 = 99;
/*
* Configuration change flag for master 1
*/
EEPROM UINT8 ee_ui8FbHartCfgChangeM1;
RAM UINT8 rs_ui8FbHartCfgChangeM1 = TRUE;
/*
* Configuration change flag for master 2
*/
EEPROM UINT8 ee_ui8FbHartCfgChangeM2;
RAM UINT8 rs_ui8FbHartCfgChangeM2 = TRUE;
/*
* Not used
*/
ROM UINT8 co_ui8FbHartAlmSelCode = 250;
/*
* Not used
*/
ROM UINT8 co_ui8FbHartXferFuncCode = 250;
/*
* 251 = not used
*/
ROM UINT8 co_ui8FbHartPrivLabDistCode = 251;
/*
* Short address for HART communication
*/
EEPROM UINT8 ee_ui8FbHartAddress;
RAM UINT8 re_ui8FbHartAddress;
RAM UINT8 rl_ui8FbHartAddress = 0;
/*
* User notes stored in EE
*/
EEPROM BYTE ee_paFbHartMessage[24];
RAM BYTE rs_paFbHartMessage[24]
= { 0x34,0x54,0x92,0x66,0x06,0x0D,0x05,0x38,0x39,0xE6,0x07,0xE0,0x20,0x14,0x10,0x66,0x03,0x85,0x5E,0x0C,0xB0,0xC3,0x07,0xDF };
/*
* Kind of ser num stored by user
*/
EEPROM UINT24 ee_ui24FbHartFinAssNum;
RAM UINT24 rs_ui24FbHartFinAssNum = 654321;
/*
* Status if device is write protected
*/
RAM UINT8 rs_ui8FbHartWrProtCode = 0;
/**********************************************************************
* Automatically generated semaphores *
**********************************************************************/
RAM BOOL se_bFbHartParamChanged;
/**********************************************************************
* Standard Methods *
**********************************************************************/
/*IIIIIIIIII*/
void FbHartInit(void)
/*IIIIIIIIII*/
{ if (!M_API_IS_EE_VALID)
{ M_API_EE_WRITE(&ee_paFbHartTagName[0],&rl_paFbHartTagName[0],6);
M_API_EE_WRITE(&ee_paFbHartDescription[0],&rs_paFbHartDescription[0],12);
M_API_EE_WRITE(&ee_ui8FbHartDayOfMonth,&rs_ui8FbHartDayOfMonth,1);
M_API_EE_WRITE(&ee_ui8FbHartMonthOfYear,&rs_ui8FbHartMonthOfYear,1);
M_API_EE_WRITE(&ee_ui8FbHartYearSince1900,&rs_ui8FbHartYearSince1900,1);
M_API_EE_WRITE(&ee_ui8FbHartCfgChangeM1,&rs_ui8FbHartCfgChangeM1,1);
M_API_EE_WRITE(&ee_ui8FbHartCfgChangeM2,&rs_ui8FbHartCfgChangeM2,1);
M_API_EE_WRITE(&ee_ui8FbHartAddress,&rl_ui8FbHartAddress,1);
M_API_EE_WRITE(&ee_paFbHartMessage[0],&rs_paFbHartMessage[0],24);
M_API_EE_WRITE(&ee_ui24FbHartFinAssNum,&rs_ui24FbHartFinAssNum,3);
}
else
{ M_API_EE_READ(&rl_paFbHartTagName[0],&ee_paFbHartTagName[0],6);
M_API_EE_READ(&rs_paFbHartDescription[0],&ee_paFbHartDescription[0],12);
M_API_EE_READ(&rs_ui8FbHartDayOfMonth,&ee_ui8FbHartDayOfMonth,1);
M_API_EE_READ(&rs_ui8FbHartMonthOfYear,&ee_ui8FbHartMonthOfYear,1);
M_API_EE_READ(&rs_ui8FbHartYearSince1900,&ee_ui8FbHartYearSince1900,1);
M_API_EE_READ(&rs_ui8FbHartCfgChangeM1,&ee_ui8FbHartCfgChangeM1,1);
M_API_EE_READ(&rs_ui8FbHartCfgChangeM2,&ee_ui8FbHartCfgChangeM2,1);
M_API_EE_READ(&rl_ui8FbHartAddress,&ee_ui8FbHartAddress,1);
M_API_EE_READ(&rs_paFbHartMessage[0],&ee_paFbHartMessage[0],24);
M_API_EE_READ(&rs_ui24FbHartFinAssNum,&ee_ui24FbHartFinAssNum,3);
}
/* Always set semaphore to transfer settings to the event level */
se_bFbHartParamChanged = TRUE;
/*
* User Initialization
*/
rs_osFbHartUniqueID[0] = co_ui8FbHartMfrID;
rs_osFbHartUniqueID[1] = co_ui8FbHartMfrDevType;
memcpy(&rs_osFbHartUniqueID[2],&co_ui24FbHartDeviceIDnum,3);
#ifdef VC_STUDIO
sysSwap3(&rs_osFbHartUniqueID[2]);
#endif
/* Trigger watchdog in initialization routines, system not yet running */
M_API_TRIGGER_WATCHDOG;
}
/*############*/
void FbHartVerify(void)
/*############*/
{ if (se_bFbHartParamChanged)
{ M_API_MEMCPY(&re_paFbHartTagName[0],&rl_paFbHartTagName[0],6);
re_ui8FbHartAddress = rl_ui8FbHartAddress;
se_bFbHartParamChanged = FALSE;
}
}
/**********************************************************************
* User Methods *
**********************************************************************/
/*##################*/
UINT8 FbHartGetResponse2(
/*##################*/
)
/*
* To be called by the command interpreter
*/
{
T_UCHR ucResponse2 = 0;
/* Automatically generated call */
FbHartVerify();
/* User's function body */
if (g_bConfChange)
ucResponse2 |= HRT_CONFIGURATION_CHANGED;
if (rl_ui8FbHartAddress)
ucResponse2 |= HRT_ANALOG_OUTPUT_FIXED;
if (m_bColdStart)
{ ucResponse2 |= HRT_COLD_START;
m_bColdStart = T_FALSE;
}
return ucResponse2;
}
/******************/
UINT8 FbHartGetRspCmd1(
/******************/
)
/*
* Deliver response to command 1
*/
{
// to be defined
return 0;
}
/*******************/
UINT8 FbHartGetRspCmd35(
/*******************/
)
/*
* Plausibility check of range values
*/
{
//to be defined
return 0;
}
/******************/
UINT8 FbHartGetRspCmd6(
/******************/
)
{
if (strHrtAppIf.byData[0] > 15)
{
g_bNoData = T_TRUE;
return HRT_INVALID_SELECTION;
}
return 0;
}
/*********************/
UINT8 FbHartGetWrProtCode(
/*********************/
void
)
/*
* Returns the write protect code for HART command 15
*/
{
return rs_ui8FbHartWrProtCode;
}
/*################*/
VOID FbHartSendStream(
/*################*/
PBYTE pbyBuf,
UINT uiBufSize
)
/*
* Prepares data to be send by the propper entity
*/
{
/* Automatically generated call */
FbHartVerify();
/* User's function body */
M_HRT_START_SEND(pbyBuf,uiBufSize);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -