core: Fix some C99/C90 warnings

If these files were used by a project which compiled using C90 with -Wall,
warnings would be emitted about declarations in the middle of blocks.
cores: Added PORTA to atmega32

Inspired by sealibora@github

Signed-off-by: Michel Pollet <buserror@gmail.com>
cores: Added mega16

No idea why it wasn't there already. Uncommon part.

Signed-off-by: Michel Pollet <buserror@gmail.com>
core: Fix a possible buffer overrun

From bsekisser@github

Signed-off-by: Michel Pollet <buserror@gmail.com>
simavr: Removed the avr_global_logger global

It was not very clean; Instead there is a new accessor for
setting/getting a global logging function pointer.
Also made sure it is not compiled for the cores, since they use AVR
headers and have no stdarg.h anyway

Signed-off-by: Michel Pollet <buserror@gmail.com>
avr: Make vector trace work

Somehow the vector list was erased at avr_reset time, luckily only the
trace code in run_avr was using it.

Signed-off-by: Michel Pollet <buserror@gmail.com>
Makefile: Test multiple AVR roots for Linux and error out if none found

Inspired by thors@github.

This should find correct paths for at least Arch, Debian, Fedora, Gentoo, OpenSUSE, Ubuntu.
timer: Tweak traces

Display the period in uS as well as cycles

Signed-off-by: Michel Pollet <buserror@gmail.com>
core: Declare avr_pending_sleep_usec

This was meant to be declared for 'boards' to use

Signed-off-by: Michel Pollet <buserror@gmail.com>
Merge remote-tracking branch 'pwithnalls/warning-fixes' into dev-home
spi: Clear SPIF when writing to SPDR

The manual says the SPIF bit is cleared when accessing (i.e. reading _or_
writing) the SPDR register after an interrupt is raised. By clearing SPIF
on a write to SPDR, the following code starts to work:

   SPDR = 0xff; loop_until_bit_is_set (SPSR, SPIF);
   SPDR = 0x00; loop_until_bit_is_set (SPSR, SPIF);

(where the bytes are arbitrarily chosen). This didn’t work before as the
SPIF bit wasn’t cleared by the second write to SPDR, so the second loop
turned into a no-op. This caused the write timer for the first byte to be
overwritten by the write timer for the second. Consequently, the first byte
never got transmitted.

Signed-off-by: Michel Pollet <buserror@gmail.com>
cores: Added atmega1284.c

That one has an extra timer, it seems.

Signed-off-by: Michel Pollet <buserror@gmail.com>
Merge remote-tracking branch 'thomasa88/feature/detect_avr_root' into dev-home
fifo: cleaned warnings and removed volatile

Should not need the volatile declaration anymore.
Also use the "unused" designation to prevent clang to complain
about unused static functions.

Signed-off-by: Michel Pollet <buserror@gmail.com>
twi: Fix a clang error

clang doesn't like unused static functions at all.

Signed-off-by: Michel Pollet <buserror@gmail.com>
uart_pty: Fix the race condition

There had been a race condition in there for a rather long while,
I've finaly tracked it down to a small idiotic change of trying to
flush a buffer from the wrong thread.
Removing that flush makes it works properly as intended, without the
mutex.

Signed-off-by: Michel Pollet <buserror@gmail.com>