//#include "RS_Functions_modbus.h"
#include "options_table.h"

#include "DSP281x_Device.h"
#include "MemoryFunctions.h"



#pragma DATA_SECTION(options_controller, ".slow_vars")
MODBUS_REG_STRUCT options_controller[SIZE_OPTIONS_TABLE];



int store_data_flash(MODBUS_REG_STRUCT *modbus_t, unsigned int size)
{
    volatile unsigned long Address1, Address2;
    volatile unsigned long Length, LengthW;
    unsigned int cerr, repl, count_ok;

    Address1 = (unsigned long)modbus_t;
    Address2 = ADR_STORE_OPTION_TO_FLASH;

    LengthW =  size;

    if( (Address2 < 0x100000) || (Address2 > 0x180000)  || ((Address2+LengthW) > 0x180000)  )
    {
      return 1;
    }

    RunFlashData(Address1,Address2,LengthW, &cerr, &repl, &count_ok );


    return 0;

}