view rvinterf/tmsh/abbtm3.c @ 497:74610c4f10f7

target-utils: added 10 ms delay at the end of abb_power_off() The deosmification of the ABB access code (replacement of osmo_delay_ms() bogus delays with correctly-timed ones, which are significantly shorter) had one annoying side effect: when executing the poweroff command from any of the programs, one last '=' prompt character was being sent (and received by the x86 host) as the Calypso board powers off. With delays being shorter now, the abb_power_off() function was returning and the standalone program's main loop was printing its prompt before the Iota chip fully executed the switch-off sequence! I thought about inserting an endless tight loop at the end of the abb_power_off() function, but the implemented solution of a 10 ms delay is a little nicer IMO because if the DEVOFF operation doesn't happen for some reason in a manual hacking scenario, there won't be an artificial blocker in the form of a tight loop keeping us from further poking around.
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 25 May 2019 20:44:05 +0000
parents 74b9aeb25d79
children
line wrap: on
line source

/*
 * Old TM3 versions of ABB register read and write commands
 */

#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include "pktmux.h"
#include "limits.h"
#include "localtypes.h"
#include "tm3.h"
#include "exitcodes.h"

extern u_char rvi_msg[];
extern int rvi_msg_len;

void
handle_oabbr_response()
{
	char buf[80];
	unsigned val;

	if (rvi_msg[3]) {
		if (rvi_msg_len == 5) {
			sprintf(buf, "oabbr error %u (0x%02X)",
				rvi_msg[3], rvi_msg[3]);
			async_msg_output(buf);
		} else
			print_etm_pkt_raw("oabbr long error response");
		return;
	}
	if (rvi_msg_len != 7) {
		print_etm_pkt_raw("oabbr response wrong length");
		return;
	}
	val = rvi_msg[4] | (rvi_msg[5] << 8);
	sprintf(buf, "oabbr: %04X", val);
	async_msg_output(buf);
}

cmd_oabbr(argc, argv)
	char **argv;
{
	u32 page, reg;
	u_char cmdpkt[5];

	page = strtoul(argv[1], 0, 0);
	reg = strtoul(argv[2], 0, 0);
	if (page > 1 || reg > 31) {
		printf("error: argument(s) out of range\n");
		return(ERROR_USAGE);
	}
	cmdpkt[1] = CODEC_READ;
	cmdpkt[2] = page << 5 | reg;
	cmdpkt[3] = 0;
	send_etm_cmd(cmdpkt, 3);
	return(0);
}

cmd_oabbw(argc, argv)
	char **argv;
{
	u32 page, reg, val;
	u_char cmdpkt[7];

	page = strtoul(argv[1], 0, 0);
	reg = strtoul(argv[2], 0, 0);
	val = strtoul(argv[3], 0, 16);
	if (page > 1 || reg > 31 || val > 0x3FF) {
		printf("error: argument(s) out of range\n");
		return(ERROR_USAGE);
	}
	cmdpkt[1] = CODEC_WRITE;
	cmdpkt[2] = page << 5 | reg;
	cmdpkt[3] = 0;
	cmdpkt[4] = val;
	cmdpkt[5] = val >> 8;
	send_etm_cmd(cmdpkt, 5);
	return(0);
}