/*
 * Settings.cpp
 *
 *  Created on: 12 мая 2015 г.
 *      Author: esaulenko
 */

#include "Settings.h"
#include "IO.h"
#include "Utils.h"
#include "CanFwInterface.h"


// строки с названиями настроек
#define SETTING(...)
#define SETTING_CAN(...)
#define SETTING_RSRV(...)
#define SETTING_NAME(name, string)	\
	__attribute__ ((section(".SettingsVarName"))) \
	static const char name ## String[] = string;
#include SRC_SETTINGS

#undef SETTING
#undef SETTING_RSRV
#undef SETTING_ALIAS
#undef SETTING_CAN
#undef SETTING_NAME


// таблица с настройками CAN-прошивки
__attribute__ ((section(".SettingsTable")))
const CSettings::TCANSettingsTable CSettings::CanSettingsTable = {
	#define SETTING(name, attr, type, def_val...)	\
		name, kind_ ## type, attr, sizeof(THeader)+sizeof(type), def_val,
	#define SETTING_CAN(name, attr, type, def_val, description)	\
		name, kind_ ## type, attr, sizeof(THeader)+sizeof(type), def_val,
	#define SETTING_RSRV(...)								// не используется
	#define SETTING_NAME(name, string)	\
		name, 0x1F, NotFixed,  sizeof(THeader)+sizeof(char*), name ## String,

	#include SRC_SETTINGS

//		0xffff //LastVal
	CSettings::LastVal
};
#undef SETTING
#undef SETTING_RSRV
#undef SETTING_ALIAS
#undef SETTING_CAN
#undef SETTING_NAME


__attribute__ ((section(".SettingsCanName")))
const char * const CSettings::CanSettingsName[] = {
	#define SETTING(...)	// names not used
	#define SETTING_CAN(name, attr, type, def_val, description)		description,
	#define SETTING_RSRV(...)								// не используется
	#define SETTING_NAME(...)								// не используется

		#include SRC_SETTINGS
};
#undef SETTING
#undef SETTING_RSRV
#undef SETTING_ALIAS
#undef SETTING_CAN
#undef SETTING_NAME

