Add getclksfreq(), wfe(), wfi(), rnd.setup() and rnd.read() functions.

wfe() and wfi() just call the underlying ARM functions.

getclksfreq() returns a table containing these clock frequencies: SYSCLK,
HCLK, PCLK1 and PCLK2.

rnd.setup() initialises the random number generator. rnd.read() will call
this anyway if the RNG hasn't been initialised before you read from it. If
rng.read() ever returns nil to signify a problem, you can call rnd.setup()
to re-initialise the RNG.

rnd.read() returns a 32 bit random number or nil if the generator signals
an error.
Change stm32f4.cpu.rng.read() to return a number rather than an integer.

This ensures the result is always positive when numbers are not 32 integers.
Merge branch 'master' into mb-stm32f4-cpu-additions
Add functions to read STM32F4 MCU id and unique device id.

stm32f4.cpu.read_mcu_device_id() returns a number containing the 32 bit id.

stm32f4.cpu.read_unique_device_id() returns an array of 3 numbers. The first
number contains bits 0-31, the second number contains bits 32-63 and the
last number contains bits 64-95 of the unique device id.
Reduce the flash latency to 2WS as that is sufficient for the 84MHz clock.
Can't use HSE clock on the Nucleo board as it's not populated.

The board as supplied does not provide any external clock to the F4.
It could supply an 8MHz clock from the STLINK part but, by default, it
isn't configured to do that.

So just use the HSI instead of the HSE - it won't be good for USB or fast
CAN bit rates but should be fine for bit banging, etc.
Now determines the required flash latency from the system clock frequency.

This assumes that the MCU supply voltage is at least 2.7V.
Rework configuration of STM32F4 HSI clock.

Now, to use the HSI clock, specify an internal clock frequency in the
"clocks" config section, like this...

clocks = { internal = 16000000, cpu = 84000000 }

Don't specify an external frequency as well as the internal frequency.
Merge pull request #41 from smartavionics/mb-stm32f4-cpu-additions

Add getclksfreq(), wfe(), wfi(), rnd.setup() and rnd.read() functions.
Merge pull request #45 from ecdr/MiscUpdates

Misc updates
Merge pull request #47 from smartavionics/stm32f4-nucleo

Stm32f4 nucleo
Add support for 32 bit timers TIM2 and TIM5 (id 1 and 4).

These timers now handle 32 bit counts & delays.
Fix platform_s_timer_delay() so it doesn't hang when specified delay is too large.

Previously, if the specified delay resulted in a final value that
was wider than the timer width, the code would loop forever because the
timer counter would never reach the value of final.

Now, it checks to see if the timer has wrapped and, if so, reduces the value
of final by the timer's max count value.

An added benefit is that now all timers can delay for up to the maximum
delay handled by the target whereas previously the maximum delay was limited
by the width of the counter.
In platform_s_timer_delay() don't assume timer reload value is all ones.

If the timer has been used to clock ADC or PWM or to generate interrupts
the reload value is unlikely to be all ones. The reload value will be
all ones if the timer has just been used as an elua timer.

So, when the timer wraps use the real reload value which is in ARR rather
than assuming it is 0xFFFF or 0xFFFFFFFF.
Keep the timer running when stopping timer generated cyclic interrupts.

For some reason (unknown to me) platform_s_timer_set_match_int() was clearing
the timer's CR1 and CR2 regs when the interrupts are to be stopped. This
had the effect of stopping the timer completely so a delay() on that timer
would hang forever. Now the timer keeps running and can be used normally
after the interrupts have been stopped.
Merge pull request #49 from smartavionics/mb-stm32f4-timer-mods

Mb stm32f4 timer mods
Don't optimize numbers for compressed romfs on integer builds

- luasrcdiet uses 'e' notation which doesn't work in integer builds
Fix missing element in external ints for stm32

- stm32, stm32f2 & stm32f4 were missing EXTI_Line11 in external
  interrupts source list, causing out of bounds & interrupt source
  identification
Make LuaRPC funcname long enough for null termination
pio.c - remove redundant include (lualib.h includes lua.h)