Template EFM32JG1B, derived from previous EFM32 projects
20191213 Andreas Buchinger
--------------------------------------------------------

main.c, leds.c
--------------
RTC - set up to wake up core every ~1ms. Minimal scheduler for periodically
1ms, 10ms, 25ms... tasks. If all tasks are finished go to EM2.

On STK3401A only 2 LEDs are mounted. Driven by GPIO [PF4] and PF5. PF4 is needed
for Trace so only LED2 is used with STK3401A.
[LED0 / PF4: Alive, switched on in main every second for 10ms]
[LED1: Switched on during ADC conversion and during filtering (AdcFinishedIRQ)]
LED2 / PF5: Shows when EFM is out of EM2 (EM1 JADE), switched on in every IRQ
handler, switched off when entering EM2 (EM1 JADE)


TraceLeUart.c, Commands.c
-------------------------
PF3, PF4
Minimal terminal functions via LEUART0 running in EM2 (before JADE). Debug
message output. Routed to 10pin header pin 2/3 on Olimex board and at DEBUG
connector on all own boards. 9600bps for older boards. Starting with JADE
115200bps, 1 stop, no parity, no handshake. JADE/PEARL (JG1B) does have
terrible jitter on LFRCO so debug out does not work relialbe with more than
2400bps. So switching LEUART clock to HFRCO and using 115200bps. Drawback -
switching to EM2 is not possible when debug data are sent out. This may
significantly increase energy consumption depending on debug data.

Debug messages are defined by simple use of TRACE(), TRACE_L2() and TRACE_L3()
macros. Message format in printf style. \r\n is automatically added with every
TRACE message. Debug level from 0 to 3 is defined in trace.h for every single
module. Level 0 means no logging at all and NO ADDITIONAL CODE. It is not
necessary to clean up sources for release builds but only set log level to 0 in
trace.h (or uncomment NO_TRACE) and there is no code overhead anymore.

Trace messages are copied into a ring buffer and sent out in background via
LEUART0 IRQ handler (even in EM2 before JADE). Buffer copying and sprintf used
with TRACE uses only little time but do have small influence on execution speed.
If too much logging info is requested as with 9600bps can be sent out, buffer
fills up and overflow may occure. *** is inserted in output stream in such cases
and trace info is lost. For Ring buffer size see LOG_TX_RING_BUF_SIZE in
TraceLeUart.c.

!!! ARM Cortex-M3 Hard Fault Handler !!!
tries to write readable fault information to debug out and restart system


Hardware.c
----------
Hardware dependant functions. Version/Revision, UID, DIP-Switches, ...


Adc.c
-----
Starting with JADE ADC is configured to run in EM2 without any CPU
intervention. LETIMER0 is used to trigger ADC via PRS and LDMA transfers
results into adcBuffer. LETIMER0 runs at 1kHz. Every 1ms new ADC samples
for all configured inputs (AdcInit) are transferd to the buffer.
Based on github adc_scan_letimer_prs_dma sample



Used Ressources:
----------------
main.c
  RTC     ... system clock, wakes up every ~1ms, running from LFRCO

TraceLeUart.c
  LEUART0 ... trace output with 115200bps routed at 10pin header

Adc.c
  LETIMER0... triggers ADC every 1ms

  LDMA_CHANNEL 0
  PRS_CHANNEL  0

IRQs Priority   Modul
  RTC       7   main
  LEUART0   7   TraceLeUart
  GPIO_EVEN 7   TraceLeUart
  LDMA      6   Adc

Valid priority values are 0..7 where 7 is the lowest priority. Default 0.




