cmd_ll.c 1.65 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
/*
 * This work is part of the White Rabbit project
 *
 * Copyright (C) 2013 CERN (www.cern.ch)
 * Author: Alessandro Rubini <rubini@gnudd.com>
 *
 * Released according to the GNU GPL, version 2 or any later version.
 */
#include <wrc.h>
#include <shell.h>
#include <storage.h>
#include <endpoint.h>
#include <ppsi/ppsi.h>
#include "wr-api.h"

static int cmd_devmem(const char *args[])
{
	uint32_t *addr, value;

	if (!args[0]) {
		pp_printf("devmem: use: \"devmem <address> [<value>]\"\n");
		return 0;
	}
	fromhex(args[0], (void *)&addr);
	if (args[1]) {
		fromhex(args[1], (void *)&value);
		*addr = value;
	} else {
		pp_printf("%08x = %08x\n", (int)addr, *addr);
	}
	return 0;
}

DEFINE_WRC_COMMAND(devmem) = {
	.name = "devmem",
	.exec = cmd_devmem,
};

39
extern struct pp_instance ppi_static[wr_num_ports];
40 41 42 43

static int cmd_delays(const char *args[])
{
	int tx, rx;
44 45 46
	int port;
	struct wr_data *wrp;
	struct wr_servo_state *s;
47 48

	if (args[0] && !args[1]) {
49
		pp_printf("delays: use: \"delays [<txdelay> <rxdelay>] [port]\"\n");
50 51 52 53 54
		return 0;
	}
	if (args[1]) {
		fromdec(args[0], &tx);
		fromdec(args[1], &rx);
55 56 57 58 59 60 61 62 63 64
		if (args[2])
			port = atoi(args[2]);
		else
			port = 0;
		if (port > 1) return -1;

		sfp_deltaTx[port] = tx;
		sfp_deltaRx[port] = rx;
		wrp = (void *)(ppi_static[port].ext_data);
		s = &wrp->servo_state;
65 66
		/* Change the active value too (add bislide here) */
		s->delta_tx_m = tx;
67
		s->delta_rx_m = rx + ep_get_bitslide(port);
68
	} else {
69 70 71 72
		for (port = 0; port < wr_num_ports; ++port)
		{
			pp_printf("port %d: tx: %i   rx: %i\n", port, sfp_deltaTx[port], sfp_deltaRx[port]);
		}
73 74 75 76 77 78 79 80
	}
	return 0;
}

DEFINE_WRC_COMMAND(delays) = {
	.name = "delays",
	.exec = cmd_delays,
};