You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

210 lines
7.1 KiB
C

/*****************************************************************************
* File Name:framework.c
* Author:Zhangdi
* Brief:
* Note:
* Last Updated for Version:
* Date of the Last Update:
*****************************************************************************/
#include"framework.h"
/*****************************************************************************
** Constants
*****************************************************************************/
/*****************************************************************************
** Maco Define
*****************************************************************************/
/*****************************************************************************
** Data Type Define
*****************************************************************************/
/*****************************************************************************
** Global Variable Declare
*****************************************************************************/
BaudRate comModbusBaudRateSet;
Uint16 comModbusADDRSet;
ParityMode comModbusParitySet;
Uint16 cpuCpldVersion;
/*****************************************************************************
* Brief: Analog input
* Note:
*****************************************************************************/
AnalogInput analogInput = { 0 };
/*****************************************************************************
* Brief: Analog output
* Note:
*****************************************************************************/
Uint16 a2001_2005 = 0;
Uint16 a2002_2006 = 0;
Uint16 a2003_2007 = 0;
Uint16 a2004_2008 = 0;
/*****************************************************************************
* Brief: Digital input interface
* Note:
*****************************************************************************/
DigitalInput digitalInput = { 0 };
/*****************************************************************************
* Brief: Digital output interface
* Note:
*****************************************************************************/
DigitalOuput digitalOutput = { 0xffff };
/*****************************************************************************
* Brief: modbus output coils buffer
* Note:
*****************************************************************************/
Uint16 readCoils[300] = { 0 };
/*****************************************************************************
* Brief: modbus input coils buffer
* Note:
*****************************************************************************/
Uint16 writeCoils[300] = { 0 };
/*****************************************************************************
* Brief: modbus output registers buffer
* Note:
*****************************************************************************/
Uint16 readRegisters[300] = { 0 };
/*****************************************************************************
* Brief: modbus input registers buffer
* Note:
*****************************************************************************/
Uint16 writeRegisters[300] = { 0 };
/*****************************************************************************
* Brief: Event for modbus state machine
* Note:
*****************************************************************************/
hsmEvent etmp;
/*****************************************************************************
* Brief: modbus object
* Note:
*****************************************************************************/
MODBUS_RTU_SLAVE modbusHMI;
/*****************************************************************************
* Brief: modbus event list
* Note:
*****************************************************************************/
hsmEvent eBufferHMI[50];
/*****************************************************************************
* Brief: modbus port object
* Note:
*****************************************************************************/
MODBUS_RTU_PORT_INFOR modbusHMIPort = { 5, B9600, NO_PARITY,
&(ScibRegs.SCIRXBUF.all), &(ScibRegs.SCITXBUF), 21, &(ScibRegs) };
/*****************************************************************************
* Brief: Ecan data buffer. These data transport from cpu to communication
* board.
* Note: These data used for communication board modbus output coils.
*****************************************************************************/
Uint16 canData_cpu2com_coils[16] = { 0 };
/*****************************************************************************
* Brief: Ecan data buffer. These data transport from cpu to communication
* board.
* Note: These data used for communication board modbus output registers.
*****************************************************************************/
Uint16 canData_cpu2com_registers[50] = { 0 };
/*****************************************************************************
* Brief: Ecan data buffer. These data transport from communication board to
* cpu board.
* Note: These data are input coils data received by communication board modbus.
*****************************************************************************/
Uint16 canData_com2cpu_coils[16] = { 0 };
/*****************************************************************************
* Brief: Ecan data buffer. These data transport from communication board to
* cpu board.
* Note: These data are input registers data received by communication board
* modbus.
*****************************************************************************/
Uint16 canData_com2cpu_registers[50] = { 0 };
/*****************************************************************************
** Global Function Declare
*****************************************************************************/
void frameworkDataInit(void)
{
Uint32 i;
int16 *p;
p = (int16 *)&analogInput;
for(i = 0; i < sizeof(analogInput) / sizeof(int16); i++)
{
p[i] = 0;
}
a2001_2005 = 0;
a2002_2006 = 0;
a2003_2007 = 0;
a2004_2008 = 0;
digitalInput.all = 0xffffffff;
digitalOutput.all = 0xffffffff;
p = (int16 *)readCoils;
for(i = 0; i < sizeof(readCoils) / sizeof(Uint16); i++)
{
p[i] = 0;
}
p = (int16 *)writeCoils;
for(i = 0; i < sizeof(writeCoils) / sizeof(Uint16); i++)
{
p[i] = 0;
}
p = (int16 *)readRegisters;
for(i = 0; i < sizeof(readRegisters) / sizeof(Uint16); i++)
{
p[i] = 0;
}
p = (int16 *)writeRegisters;
for(i = 0; i < sizeof(writeRegisters) / sizeof(Uint16); i++)
{
p[i] = 0;
}
etmp.signal = 0;
p = (int16 *)canData_cpu2com_coils;
for(i = 0; i < sizeof(canData_cpu2com_coils) / sizeof(Uint16); i++)
{
p[i] = 0;
}
p = (int16 *)canData_cpu2com_registers;
for(i = 0; i < sizeof(canData_cpu2com_registers) / sizeof(Uint16); i++)
{
p[i] = 0;
}
p = (int16 *)canData_com2cpu_coils;
for(i = 0; i < sizeof(canData_com2cpu_coils) / sizeof(Uint16); i++)
{
p[i] = 0;
}
p = (int16 *)canData_com2cpu_registers;
for(i = 0; i < sizeof(canData_com2cpu_registers) / sizeof(Uint16); i++)
{
p[i] = 0;
}
}
/*****************************************************************************
** Local Function Declare
*****************************************************************************/