Add freq_ctr app

The freq_ctr app is a small application that is implementing a
simplistic direct-mode frequency counter using the internal 32.768kHz
oscillator and two TC blocks. One of them is used to generate a 1Hz
signal, which is then subsequently used by the other TC to trigger
a counter read after exactly 1s.

This is in itself not something useful on a simtrace2 device.  However,
it is a separate 'app' and I prefer to have the code here in master
over some obscure branch that's easy to forget about.

Change-Id: I2249bfb8dd6a88d85d406f3b33537377133d0939
diff --git a/firmware/apps/freq_ctr/main.c b/firmware/apps/freq_ctr/main.c
new file mode 100644
index 0000000..761bc17
--- /dev/null
+++ b/firmware/apps/freq_ctr/main.c
@@ -0,0 +1,54 @@
+
+#include "board.h"
+#include "utils.h"
+#include "osmocom/core/timer.h"
+
+extern void freq_ctr_init(void);
+
+/* returns '1' in case we should break any endless loop */
+static void check_exec_dbg_cmd(void)
+{
+	int ch;
+
+	if (!UART_IsRxReady())
+		return;
+
+	ch = UART_GetChar();
+
+	board_exec_dbg_cmd(ch);
+}
+
+
+extern int main(void)
+{
+	led_init();
+	led_blink(LED_RED, BLINK_ALWAYS_ON);
+	led_blink(LED_GREEN, BLINK_ALWAYS_ON);
+
+	/* Enable watchdog for 2000 ms, with no window */
+	WDT_Enable(WDT, WDT_MR_WDRSTEN | WDT_MR_WDDBGHLT | WDT_MR_WDIDLEHLT |
+		   (WDT_GetPeriod(2000) << 16) | WDT_GetPeriod(2000));
+
+	PIO_InitializeInterrupts(0);
+
+
+	printf("\n\r\n\r"
+		"=============================================================================\n\r"
+		"Freq Ctr firmware " GIT_VERSION " (C) 2019 by Harald Welte\n\r"
+		"=============================================================================\n\r");
+
+	board_main_top();
+
+	TRACE_INFO("starting frequency counter...\n\r");
+	freq_ctr_init();
+
+	TRACE_INFO("entering main loop...\n\r");
+	while (1) {
+		WDT_Restart(WDT);
+
+		check_exec_dbg_cmd();
+		osmo_timers_prepare();
+		osmo_timers_update();
+	}
+
+}