Merge pull request #35 from ecdr/MiscUpdates

Misc updates
Add status return to can.send() and underlying platform_can_send() functions.

Now, can.send() returns a boolean result to indicate whether the message
was successfully sent or not. The various platform functions differ in how
they handled the situation where all CAN transmitters are occupied. In
particular, the STM32x and STR9 implementations ignored the status returns
from the underlying libraries and so if all the CAN transmitters were busy,
the latest message simply got thrown away. Now, can.send() returns true/false
to indicate if the message really did get queued for transmission. All
platforms should behave the same as before.
Merge pull request #36 from smartavionics/mb-can-send-result

Add status return to can.send() and underlying platform_can_send() functions.
Missed from recent commit that added status return to platform_can_send() - sorry!
Merge pull request #37 from smartavionics/master

Missed from recent commit that added status return to platform_can_send() - sorry!
Add support for the second stm32f4 CAN interface.

This is copied from the stm32f2 code with some #if's added so that you can
select the MCU pins used for the CAN signals at compile time. Four configurations
are supported.

For example, the board config file can contain this:

  macros = { 'ELUA_BOARD_STM32F4_CAN_PIN_CONFIG_2' }
Merge pull request #38 from smartavionics/mb-stm32f4-can2

Add support for the second stm32f4 CAN interface.
Avoid 64 bit mul+div in platform_timer_get_diff_us() when timer rate is 1 MHz.
Now clears FIFO empty interrupt mask in DCD_WriteEmptyTxFifo() when transfer completes.

This fixes a problem whereby outputting to the USB UART when the host is
connected but the USB UART is not open would cause the interrupt
handler to be called continuously so it would consume 100% of the CPU.
Avoid 64 bit divide in cmd_systimer_get().
Avoid losing time when cmn_systimer_counter exceeds PLATFORM_TIMER_SYS_MAX.

Setting cmn_systimer_counter to zero when the systimer exceeded
PLATFORM_TIMER_SYS_MAX would cause time to jump backwards if
cmn_systimer_counter was already greater than PLATFORM_TIMER_SYS_MAX.

So now, instead of zeroing it, we subtract PLATFORM_TIMER_SYS_MAX.
Correct value of PLATFORM_TIMER_SYS_MAX for lua long builds.

It was being set to ( ( 1LL << 31 ) - 2 ) which only used 31 bits when 32
are available. By setting it to ( ( 1LL << 32 ) - 2 ) the range of the timer
is doubled to around 4295 seconds. Note that time values greater than
approx 2147 seconds will have the top bit (1 << 31) set and so will appear
to be negative as all numbers are considered to be signed.
Add CAN bit timing values for use with 120 MHz and 96 MHz system clocks.

The values used produce sampling points around 65-70% which is similar
to the original set of values.

Values courtesy of http://www.bittiming.can-wiki.info/
Merge pull request #40 from smartavionics/mb-stm32f4-can-timing

Add CAN bit timing values for use with 120 MHz and 96 MHz system clocks.
Merge pull request #39 from smartavionics/mb-misc-mods

Mb misc mods
Change a couple of #warn directives to #warning.
Merge pull request #42 from smartavionics/mb-misc-mods

Change a couple of #warn directives to #warning.
For STM32, use CAN_NO_MB instead of CAN_TxStatus_NoMailBox.
Reorder assignments in cmn_systimer_get() to avoid race.

Before, it was possible for the system timer counter to wrap from high to low
after its value had been read but before the value of cmn_systimer_counter
was read and so the resulting sum of those values would be too large.

By reordering the assignments, we can now detect if cmn_systimer_counter has
been advanced while reading the system timer counter value and, if so, repeat
the assignments to ensure consistent values.
Merge pull request #43 from smartavionics/mb-misc-mods

Fixes for a compilation problem and a race in the system timer code.