#include "modbus_table_v2.h"

#include "DSP281x_Examples.h"   // DSP281x Examples Include File
#include "DSP281x_Device.h"     // DSP281x Headerfile Include File
#include "RS_Functions.h"
#include "xp_project.h"
//#include "modbus_fill_table.h"
//#include "adc_tools.h"
//#include "can_setup.h"
//#include "isolation.h"
//#include "rotation_speed.h"

// #include "IQmathLib.h"
//#include "errors.h"
//#include "params.h"
//#include "can_watercool.h"
// #include "doors_control.h"

#pragma DATA_SECTION(modbus_table_rs_in,".logs");
MODBUS_REG_STRUCT modbus_table_rs_in[SIZE_MODBUS_TABLE];


#pragma DATA_SECTION(modbus_table_rs_out,".logs");
MODBUS_REG_STRUCT modbus_table_rs_out[SIZE_MODBUS_TABLE];


#pragma DATA_SECTION(modbus_table_can_in,".logs");
MODBUS_REG_STRUCT modbus_table_can_in[SIZE_MODBUS_TABLE];


#pragma DATA_SECTION(modbus_table_can_out,".logs");
MODBUS_REG_STRUCT modbus_table_can_out[SIZE_MODBUS_TABLE];




void clear_modbus_table_in()
{
int i;

  for (i=0;i<SIZE_MODBUS_TABLE;i++)
  { 
    modbus_table_rs_in[i].all=0;
    modbus_table_can_in[i].all=0;
  }


}

void clear_modbus_table_out()
{
  int i;

  for (i=0;i<SIZE_MODBUS_TABLE;i++)
  { 
    modbus_table_rs_out[i].all= 0;
    modbus_table_can_out[i].all= 0;
  }
}


void initModbusTable(void) {
/*    modbus_table_rs_in = modbus_table_mpu_in;
    modbus_table_can_in = modbus_table_mpu_in;
    modbus_table_rs_out = modbus_table_mpu_out;
    modbus_table_can_out = modbus_table_mpu_out;
*/
    clear_modbus_table_in();
    clear_modbus_table_out();
}


void copy_from_can_out_to_rs_out(void)
{
	int i;

//	modbus_table_can_out[0].all = 0;

	for (i=0;i<SIZE_MODBUS_TABLE;i++)
	{
		modbus_table_rs_out[i].all = modbus_table_can_out[i].all;
	}
}