AvrWiz
------

AvrWiz is a code generator for Atmel Avr cpus.

modules:
--------
the modules shown in the tabs on the main screen are stored externally and can be edited.
when AvrWiz starts, all files matching "AvrWiz\*.module" are read and parsed.
module file description:
	<module>
		<file name="...FILE1..." />
		<file name="...FILE2..." />
		<file name="...FILE3..." />
		<item type="DropDownList|TextBox|CheckBox|USART|Timer" source="...DATASOURCE..." bind="...CONTROL TO BIND..." name="...VISIBLE NAME..." value="...INITIAL VALUE..." mode="...SHOW MODE..." />
	</module>
for an example see the existing module files.
when a module file is changed with the internal editor it will be reloaded.
the files in '<file name="...">' are source code templates
they can be of any (text-)type: c-files, txt-files, asm-files, ...
in these files AvrWiz looks for "<?P("<");?>?" and "?<?P(">");?>" and replaces it with the code inside.

syntax of "item" in a *.module file:

DropDownList:
	name="name for the control"
	value="the selected value"
	source=":8bits|:ports|:usart|:cpus|:sleep|:watchdog|:timer|:usarts"
		if "source" does not start with ":" a "," separated list is used to fill the dropdownlist
		":cpus" = the available cpus from "AvrWiz.cpus"
		":8bits" = the same as "0,1,2,3,4,5,6,7"
		":ports" = the available ports of the current cpu (e.g. "B,C,D")
		":usarts" = the available usarts of the current cpu (e.g. "0,1")
		":timer" = the available timer of the current cpu (e.g. "0,1,2")
		":sleep" = the available sleep modes of the the current cpu
		":watchdog" = the available watchdog timings of the the current cpu
	mode="hidden" hides the control
TextBox:
	name="name for the control"
	value="any text"
	source=":mhz"
		":mhz" = cpu speed in mhz
	mode="hidden" hides the control
CheckBox:
	name="name for the control"
	value="true|false"
		true = checked
		false = unchecked
	mode="hidden" hides the control
USART:
	name="name for the control"
	value="<the usart num>"
Timer:
	name="name for the control"
	value="<the timer num>"

example:
	<item type="DropDownList" source=":timer" name="timer" value="0" />
	<item type="Timer" name="timer0" source="timer" value="0" />
binds the Timer-control to the dropdownlist
	<item type="DropDownList" source=":usarts" name="usart" value="0" />
	<item type="USART" name="usart0" source="usart" value="0" />
binds the Usart-control to the dropdownlist
	<item type="DropDownList" source="0,1,2,3,4,5,6,7" name="t1" bind="t2,t3" value="7" />
	<item type="TextBox" name="t2" value="" />
	<item type="TextBox" name="t3" value="" />
binds the controls "t2" and "t3" to the control "t1"

supported languages:
--------------------
c#, vb (not yet), js (not yet)

code in the template files surrounded by "<?P("<");?>?" and "?<?P(">");?>" is executed.
example:
---
Hello <?P("<");?>?print("World");?<?P(">");?> !
---
prints "Hello World !" to the output textbox

example:
---
[<?P("<");?>?P(S("1wire:port"));?<?P(">");?>]
[<?P("<");?>?P(I("1wire:bit"));?<?P(">");?>]
---
prints "[B]"
and "[7]"
(depending on the settings "port" and "bit" of course)

there is a shortcut: "$"
<?P("<");?>?$XXX?<?P(">");?> is the same as <?P("<");?>?print(getString("XXX"));?<?P(">");?> (or <?P("<");?>?P(S("XXX"));?<?P(">");?>)

items (see module-file description <item ... />) from other modules can be accessed.
example:
---
<?P("<");?>?$hello:item?<?P(">");?> <?P("<");?>?$world:item?<?P(">");?> !
---
prints "Hello World" (if item "item" in module hello is "Hello" and item "item" in module "world" is "World")


this is the used environment for C# code:
	using System;
	using System.Collections.Generic;
	using System.Xml;

	// include a file
	void include(string file);

	// enable/disable printing
	void hide();
	void show();

	// print text to the generated code
	void print(string data);
	void print(int data);
	void print(bool data);
	void P(string data);
	void P(int data);
	void P(bool data);

	// print a help topic to the generated code (from "AvrWiz\AvrWiz.cpus" in <help>)
	// see "eeprom.c" for an example
	void help(string what);
	void H(string what);

	// get a string/integer/bool value
	string getString(string what);
	int getInt(string what);
	bool getBool(string what);
	string S(string what);
	int I(string what);
	bool B(string what);

	// the cpu config node itself
	XmlNode CPU;

	// format numbers
	string hex8(int value);
	string hex16(int value);



these are predefined values for "<?P("<");?>?$...?<?P(">");?>":
	? [get help all available items including their values]
well, its to much work to update the documentation everytime i implement something, so i implemented this function :-)
this is a sample output of "<?P("<");?>?$??<?P(">");?>":
	version [AvrWiz version] = 0.22.2799.7569
--> [<?P("<");?>?$version?<?P(">");?>] will print [0.22.2799.7569] to the output
	projectinfo [the value of the project info textbox] = generated with AvrWiz
	debug [true=generate debug code] = true
	cpu:cpu [cpu name] = ATmega8
	cpu:basecpu = ATmega8
	cpu:speed [speed in hz] = 16000000
	cpu:maxspeed [maximum speed in hz] = 16000000
	cpu:mhz [speed in mhz] = 16
	cpu:voltage [voltage] = 5
	cpu:ramsize [size of ram in bytes] = 1024
	cpu:ramstart [start of ram in hex] = 0x0060
	cpu:ramend [end of ram in hex] = 0x045f
	cpu:romsize [size of rom in bytes] = 4096
	cpu:romstart [start of rom in hex] = 0x0000
	cpu:romend [end of rom in hex] = 0x0fff
	cpu:eepromsize [size of eeprom in bytes] = 512
	cpu:eepromstart [start of eeprom in hex] = 0x0000
	cpu:eepromend [end of eeprom in hex] = 0x01ff
	cpu:watchdog:wdtcsr [name of the watchdog timer control register] = WDTCR
	cpu:mcusr[name of the MCU status register] = MCUCSR
	cpu:eeprom:writeenable [name of the EEPROM write enable bit] = EEWE
	cpu:eeprom:masterwriteenable [name of the EEPROM master write enable bit] = EEMWE
	cpu:jtag [true=has jtag support] = false
	cpu:spi [true=has spi support] = true
	cpu:sleep:index [the currently selected sleepmode (0=disabled)] = 0
	cpu:watchdog:index [the currently selected watchdog mode (0=disabled)] = 0
...






this is a complete output of "<?P("<");?>?$...?<?P(">");?>":
------------------------------------------------------------
<?$??>------------------------------------------------------------
