Commit 0f120a43 authored by Alessandro Rubini's avatar Alessandro Rubini

arch-wrs: allow building without WR

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 9c71d3f2
......@@ -18,7 +18,6 @@ OBJ-y += $A/wrs-startup.o \
# The user can set TIME=, but wrs is default
TIME ?= wrs
PROTO_EXT = whiterabbit
include time-$(TIME)/Makefile
......
......@@ -4,6 +4,12 @@
*
* Released to the public domain
*/
#ifdef CONFIG_EXT_WRS
# define BUILT_WITH_WHITERABBIT 1
#else
# define BUILT_WITH_WHITERABBIT 0
#endif
/*
* These are the functions provided by the various wrs files
......
......@@ -52,7 +52,8 @@ static int run_all_state_machines(struct pp_globals *ppg)
ppi->n_ops->exit(ppi);
ppi->frgn_rec_num = 0;
ppi->frgn_rec_best = -1;
if (ppg->ebest_idx == ppi->port_idx)
if (BUILT_WITH_WHITERABBIT
&& ppg->ebest_idx == ppi->port_idx)
wr_servo_reset();
}
}
......
......@@ -39,7 +39,7 @@ static struct minipc_pd __rpcdef_cmd = {
/* Fill struct ptpdexp_sync_state_t with current servo state */
static int wrsipc_get_sync_state(ptpdexp_sync_state_t *state)
{
if(servo_state_valid) {
if (BUILT_WITH_WHITERABBIT && servo_state_valid) {
memcpy(state, &cur_servo_state, sizeof(ptpdexp_sync_state_t));
state->valid = 1;
} else
......@@ -51,11 +51,13 @@ static int wrsipc_get_sync_state(ptpdexp_sync_state_t *state)
/* Execute command coming ipc */
static int wrsipc_cmd(int cmd, int value)
{
if(cmd == PTPDEXP_COMMAND_TRACKING)
wr_servo_enable_tracking(value);
if (BUILT_WITH_WHITERABBIT) {
if(cmd == PTPDEXP_COMMAND_TRACKING)
wr_servo_enable_tracking(value);
if(cmd == PTPDEXP_COMMAND_MAN_ADJUST_PHASE)
wr_servo_man_adjust_phase(value);
if(cmd == PTPDEXP_COMMAND_MAN_ADJUST_PHASE)
wr_servo_man_adjust_phase(value);
}
return 0;
}
......
......@@ -25,7 +25,12 @@
#include <ppsi/ppsi.h>
#include <ppsi-wrs.h>
#define WRSW_HAL_RETRIES 1000
#if BUILT_WITH_WHITERABBIT
# define WRSW_HAL_RETRIES 1000
#else
# define WRSW_HAL_RETRIES 0
#endif
#define WRSW_HAL_TIMEOUT 2000000 /* us */
static struct wr_operations wrs_wr_operations = {
......@@ -75,15 +80,12 @@ int main(int argc, char **argv)
/* try connecting to HAL multiple times in case it's still not ready */
hal_retries = WRSW_HAL_RETRIES;
for(;;) {
while (hal_retries) { /* may be never, if built without WR extension */
hal_ch = minipc_client_create(WRSW_HAL_SERVER_ADDR,
MINIPC_FLAG_VERBOSE);
if (!hal_ch)
hal_retries--;
if(hal_ch || !hal_retries)
if (hal_ch)
break;
hal_retries--;
usleep(WRSW_HAL_TIMEOUT);
}
......@@ -92,12 +94,14 @@ int main(int argc, char **argv)
exit(__LINE__);
}
ppsi_ch = minipc_server_create("ptpd", 0);
if (!ppsi_ch) { /* FIXME should we retry with minipc_server_create? */
pp_printf("Fatal: could not create minipc server");
exit(__LINE__);
if (BUILT_WITH_WHITERABBIT) {
ppsi_ch = minipc_server_create("ptpd", 0);
if (!ppsi_ch) { /* FIXME should we retry ? */
pp_printf("Fatal: could not create minipc server");
exit(__LINE__);
}
wrs_init_ipcserver(ppsi_ch);
}
wrs_init_ipcserver(ppsi_ch);
ppg = &ppg_static;
ppg->defaultDS = &defaultDS;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment