changeset 844:4694c7686ccd

fc-tmsync: add mpr command
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 31 Jul 2021 21:57:48 +0000
parents 6a0fcbca8ac7
children aec320fe2653
files rvinterf/etmsync/l1tmcmd.c rvinterf/etmsync/l1tmops.c rvinterf/etmsync/tmscmdtab.c
diffstat 3 files changed, 91 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/etmsync/l1tmcmd.c	Sat Jul 31 21:00:26 2021 +0000
+++ b/rvinterf/etmsync/l1tmcmd.c	Sat Jul 31 21:57:48 2021 +0000
@@ -261,3 +261,66 @@
 	fclose(of);
 	return(0);
 }
+
+static struct kwtab misc_param_arg[] = {
+	{"adc-interval", ADC_INTERVAL},
+	{"adc-enable", ADC_ENA_FLAG},
+	{"converted-adc0", CONVERTED_ADC0},
+	{"converted-adc1", CONVERTED_ADC1},
+	{"converted-adc2", CONVERTED_ADC2},
+	{"converted-adc3", CONVERTED_ADC3},
+	{"converted-adc4", CONVERTED_ADC4},
+	{"converted-adc5", CONVERTED_ADC5},
+	{"converted-adc6", CONVERTED_ADC6},
+	{"converted-adc7", CONVERTED_ADC7},
+	{"converted-adc8", CONVERTED_ADC8},
+	{"raw-adc0", RAW_ADC0},
+	{"raw-adc1", RAW_ADC1},
+	{"raw-adc2", RAW_ADC2},
+	{"raw-adc3", RAW_ADC3},
+	{"raw-adc4", RAW_ADC4},
+	{"raw-adc5", RAW_ADC5},
+	{"raw-adc6", RAW_ADC6},
+	{"raw-adc7", RAW_ADC7},
+	{"raw-adc8", RAW_ADC8},
+	{"adc0-coeff-a", ADC0_COEFF_A},
+	{"adc1-coeff-a", ADC1_COEFF_A},
+	{"adc2-coeff-a", ADC2_COEFF_A},
+	{"adc3-coeff-a", ADC3_COEFF_A},
+	{"adc4-coeff-a", ADC4_COEFF_A},
+	{"adc5-coeff-a", ADC5_COEFF_A},
+	{"adc6-coeff-a", ADC6_COEFF_A},
+	{"adc7-coeff-a", ADC7_COEFF_A},
+	{"adc8-coeff-a", ADC8_COEFF_A},
+	{"adc0-coeff-b", ADC0_COEFF_B},
+	{"adc1-coeff-b", ADC1_COEFF_B},
+	{"adc2-coeff-b", ADC2_COEFF_B},
+	{"adc3-coeff-b", ADC3_COEFF_B},
+	{"adc4-coeff-b", ADC4_COEFF_B},
+	{"adc5-coeff-b", ADC5_COEFF_B},
+	{"adc6-coeff-b", ADC6_COEFF_B},
+	{"adc7-coeff-b", ADC7_COEFF_B},
+	{"adc8-coeff-b", ADC8_COEFF_B},
+	{"sleep-mode", SLEEP_MODE},
+	{"current-tm-mode", CURRENT_TM_MODE},
+	{0, 0}
+};
+
+cmd_mpr(argc, argv)
+	char **argv;
+{
+	u16 index, val;
+	int rc;
+
+	if (keyword_or_num(argv[1], misc_param_arg, &index))
+		return(ERROR_USAGE);
+	rc = do_mpr(index, &val);
+	if (rc)
+		return(rc);
+	if (val >= 0x8000)
+		printf("read value: 0x%04X (%u or %d)\n", val, val,
+			(int)val - 65536);
+	else
+		printf("read value: 0x%04X (%u)\n", val, val);
+	return(0);
+}
--- a/rvinterf/etmsync/l1tmops.c	Sat Jul 31 21:00:26 2021 +0000
+++ b/rvinterf/etmsync/l1tmops.c	Sat Jul 31 21:57:48 2021 +0000
@@ -137,3 +137,29 @@
 	bcopy(rvi_msg + 5, buf, 32);
 	return(0);
 }
+
+do_mpr(index, retp)
+	u_short *retp;
+{
+	u_char cmdpkt[5];
+
+	cmdpkt[1] = MISC_PARAM_READ;
+	cmdpkt[2] = index;
+	cmdpkt[3] = index >> 8;
+	etm_pkt_exch(cmdpkt, 3);
+	if (rvi_msg[3]) {
+		fprintf(stderr, "target error %u in response to mpr\n",
+			rvi_msg[3]);
+		return(ERROR_TARGET);
+	}
+	if (rvi_msg_len < 8) {
+		fprintf(stderr, "target error: mpr response too short\n");
+		return(ERROR_TARGET);
+	}
+	if (rvi_msg[4] != index) {
+		fprintf(stderr, "target error: mpr response wrong index\n");
+		return(ERROR_TARGET);
+	}
+	*retp = rvi_msg[5] | (rvi_msg[6] << 8);
+	return(0);
+}
--- a/rvinterf/etmsync/tmscmdtab.c	Sat Jul 31 21:00:26 2021 +0000
+++ b/rvinterf/etmsync/tmscmdtab.c	Sat Jul 31 21:57:48 2021 +0000
@@ -10,6 +10,7 @@
 extern int cmd_exec();
 extern int cmd_exit();
 extern int cmd_memdump();
+extern int cmd_mpr();
 extern int cmd_omemdump();
 extern int cmd_rfpr();
 extern int cmd_rfpw();
@@ -28,6 +29,7 @@
 	{"exec", 1, 1, cmd_exec},
 	{"exit", 0, 0, cmd_exit},
 	{"memdump", 2, 2, cmd_memdump},
+	{"mpr", 1, 1, cmd_mpr},
 	{"omemdump", 2, 2, cmd_omemdump},
 	{"pirelli-get-imei", 0, 0, get_pirelli_imei},
 	{"pirelli-vbat-cal", 0, 0, get_pirelli_vbat_cal},