wrs_main.c 1.58 KB
Newer Older
1 2 3 4 5 6 7 8 9
/*
 * This work is part of the White Rabbit project
 *
 * Copyright (C) 2012,2015 CERN (www.cern.ch)
 * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
 * Author: Adam Wujek <adam.wujek@cern.ch>
 *
 * Released according to the GNU GPL, version 2 or any later version.
 */
10
#include <wrc.h>
11 12 13
#include "uart.h"
#include "softpll_ng.h"
#include "minipc.h"
14
#include "revision.h"
15
#include "system_checks.h"
16 17


18 19 20 21 22 23 24 25 26 27
int scb_ver = 33;		/* SCB version */

extern struct spll_stats stats;

/* initialize functions to be called after reset in check_reset function */
void init_hw_after_reset(void)
{
	/* Ok, now init the devices so we can printf and delay */
	uart_init_hw();
}
28

29
int main(void)
30
{
31
	uint32_t start_tics = timer_get_tics();
32

33 34 35
	check_reset();
	stats.start_cnt++;
	_endram = ENDRAM_MAGIC;
36
	uart_init_hw();
37 38 39
	pp_printf("\n");
	pp_printf("WR Switch Real Time Subsystem (c) CERN 2011 - 2014\n");
	pp_printf("Revision: %s, built: %s %s.\n",
40
	      build_revision, build_date, build_time);
41 42 43
	pp_printf("SCB version: %d. %s\n", scb_ver,(scb_ver>=34)?"10 MHz SMC Output.":"" );
	pp_printf("Start counter %d\n", stats.start_cnt);
	pp_printf("--\n");
44

45
	if (stats.start_cnt > 1) {
46
		pp_printf("!!spll does not work after restart!!\n");
47 48 49 50
		/* for sure problem is in calling second time ad9516_init,
		 * but not only */
	}
	ad9516_init(scb_ver);
51 52
	rts_init();
	rtipc_init();
53
	spll_very_init();
54 55 56

	for(;;)
	{
57 58 59 60 61 62 63 64 65
		uint32_t tics = timer_get_tics();

		if (time_after(tics, start_tics + TICS_PER_SECOND/5)) {
			spll_show_stats();
			start_tics = tics;
		}

		rts_update();
		rtipc_action();
66
		spll_update();
67
		check_stack();
68 69 70 71
	}

	return 0;
}