Fix double where.
Remove suprious HTML from end of file

avra didn't mind, but avrasm2.exe does not like it
Add a simple BSDmakefile for testing

This "BSDmakefile" works for both gmake
and BSD make (also probably other makes);
so once programming commands are implemented
here it can replace original Makefile.

It requires avra git version containing
a6e8b2957953810dae6467eeb4905bfc5ea6c33e
(Aug 8 2012 or later), so that -o, -e and -d
switches work.
Add .obj files to .gitignore
Assembler can be overriden on the commandline

Now you can do

make clean afro2.hex ASM=avrasm2.exe

or

gmake -f BSDmakefile clean afro2.hex ASM=avrasm2.exe

if you want to use some other assembler instead
of the default avra.
Replace .ifdefs with #ifdefs

avra currently does not care, but avrasm2
treats defined() in the assembler macros (.if)
and defined() in preprocess macros (#if) differently.

Assembler definition is:

http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRASM/Html/expressions.html#DEFINED(symbol

DEFINED(symbol) Returns true if symbol is previously defined using
.equ/.set/.def directives. Normally used in conjunction with .if
directives (.if defined(foo)), but may be used in any context. It
differs from other functions in that parentheses around its argument are
not required, and that it only makes sense to use a single symbol as
argument.

But by the time we reach the assembler, our "-D afro2_esc"
symbol gets expanded by the preprocessor to integer 1.

This causes the following error with avrasm2:

tgy.asm(53): Including file 'm8def.inc'
tgy.asm(85): error: syntax error, unexpected INTEGER, expecting SYMBOL

This can be avoided by using -D afro2_esc=SOMETHING but
this in turn is not (yet) supported by avra, which has no
real C preprocessor yet.

AVRASM2 documentation explains further:

http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRASM/Html/AVR_Assembler_2_-_Known_Issues.htm#defined

* The preprocessor 'defined' keyword only relates to symbols defined
with #define, and correctly does this only in preprocessor conditionals
(#if/#elif).

* In all remaining code, the assembler's notion of defined is used,
the correct behaviour would be to only recognize it in assembler
conditionals (.if/.elif).

So the solution is to change assembler conditionals (.if/.endif)
with C preprocessor conditionals (#if/#endif) which will work
with both assemblers correctly.
Merge remote-tracking branch 'saper/master'

Some fixups for building on BSD and with avrasm2.
BSDmakefile will need a yet-released avra for now,
but I will soon change it to drop all of the includes
in tgy.asm and use "-i" options instead.
Port missing Makefile targets to BSDmakefile.

It still doesn't depend on tgy.asm, so it doesn't quite work yet.
Comment and typo fixes.
Simplify and optimize rcp_int by using OCR1B instead of tracking 24 bits.

MAX_RC_PULS * CPU_MHZ easily fits in two bytes anyway, so this just
cleans things up by changing the timeout case to an interrupt and the
common case to not need any range checking, with the same end result.
Stop using 4 registers just to avoid 4 extra cycles in PWM interrupt,
and implement optional complementary PWM.

pwm_off and pwm_on were as optimized as they could possibly get, save one
cycle possible from using "out" instead of "st" on boards that have all
N-channel FETs on the same port. This was just silly compared for how
many registers were needed just to do this. Also, it's not possible to do
complementary this way without stealing yet another 4 registers. Using
bit flags for FETs instead also and makes the commutation routines much
smaller.

Note: No adjustable dead time for complementary PWM yet. Most boards with
all-N-channel FETs but no dedicated gate driver ICs seem to be worst at
the turn-on time for the high side (2-5 microseconds), but everything
else is reasonable.