Change in simtrace2[master]: firmware: octsimtest: Make slot mux configurable via USB

laforge gerrit-no-reply at lists.osmocom.org
Thu Jun 3 12:38:02 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/simtrace2/+/24533 )


Change subject: firmware: octsimtest: Make slot mux configurable via USB
......................................................................

firmware: octsimtest: Make slot mux configurable via USB

Change-Id: I4cdb250d2e1dbc5b8b0169f8b7c21e288b492e1d
---
M firmware/libboard/octsimtest/include/board.h
M firmware/libboard/octsimtest/include/mux.h
M firmware/libboard/octsimtest/source/mux.c
M firmware/libcommon/include/simtrace_prot.h
M firmware/libcommon/source/card_emu.c
5 files changed, 36 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/33/24533/1

diff --git a/firmware/libboard/octsimtest/include/board.h b/firmware/libboard/octsimtest/include/board.h
index 171b2c1..ad21a1f 100644
--- a/firmware/libboard/octsimtest/include/board.h
+++ b/firmware/libboard/octsimtest/include/board.h
@@ -109,6 +109,8 @@
 #define VCC_UV_THRESH_1V8	(1500000*47)/(47+30)
 #define VCC_UV_THRESH_3V	(2500000*47)/(47+30)
 
+#define HAVE_SLOT_MUX
+
 /** Supported modes */
 /* SIMtrace board supports sniffer mode */
 //#define HAVE_SNIFFER
diff --git a/firmware/libboard/octsimtest/include/mux.h b/firmware/libboard/octsimtest/include/mux.h
index ba7ae9f..3181478 100644
--- a/firmware/libboard/octsimtest/include/mux.h
+++ b/firmware/libboard/octsimtest/include/mux.h
@@ -1,7 +1,8 @@
 #pragma once
 
 void mux_init(void);
-void mux_set_slot(uint8_t s);
+int mux_set_slot(uint8_t s);
+int mux_get_slot(void);
 void mux_set_freq(uint8_t s);
 
 /* this reflects the wiring between U5 and U4 */
diff --git a/firmware/libboard/octsimtest/source/mux.c b/firmware/libboard/octsimtest/source/mux.c
index 8d9f625..54c6cb6 100644
--- a/firmware/libboard/octsimtest/source/mux.c
+++ b/firmware/libboard/octsimtest/source/mux.c
@@ -20,6 +20,7 @@
 #include "board.h"
 #include "mux.h"
 #include <stdbool.h>
+#include <errno.h>
 
 /* 3-bit S0..S2 signal for slot selection */
 static const Pin pin_in_sel[3] = {
@@ -38,6 +39,8 @@
 /* low-active output enable for all muxes */
 static const Pin pin_oe = { PIO_PA19, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT };
 
+static uint8_t g_mux_slot = 0;
+
 /* initialize the external 1:8 multiplexers */
 void mux_init(void)
 {
@@ -49,10 +52,13 @@
 }
 
 /* set the slot selection mux */
-void mux_set_slot(uint8_t s)
+int mux_set_slot(uint8_t s)
 {
 	printf("%s(%u)\r\n", __func__, s);
 
+	if (s > 7)
+		return -EINVAL;
+
 	/* !OE = H: disconnect input and output of muxes */
 	PIO_Set(&pin_oe);
 
@@ -71,6 +77,14 @@
 
 	/* !OE = L: (re-)enable the output of muxes */
 	PIO_Clear(&pin_oe);
+
+	g_mux_slot = s;
+	return s;
+}
+
+int mux_get_slot(void)
+{
+	return g_mux_slot;
 }
 
 /* set the frequency divider mux */
diff --git a/firmware/libcommon/include/simtrace_prot.h b/firmware/libcommon/include/simtrace_prot.h
index e550616..5eb4f59 100644
--- a/firmware/libcommon/include/simtrace_prot.h
+++ b/firmware/libcommon/include/simtrace_prot.h
@@ -269,6 +269,8 @@
 struct cardemu_usb_msg_config {
 	/* bit-mask of CEMU_FEAT_F flags */
 	uint32_t features;
+	/* the selected slot number (if an external mux is present) */
+	uint8_t slot_mux_nr;
 } __attribute__ ((packed));
 
 /***********************************************************************
diff --git a/firmware/libcommon/source/card_emu.c b/firmware/libcommon/source/card_emu.c
index bcd5fd6..4b84039 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -33,6 +33,9 @@
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/core/msgb.h>
 
+#ifdef HAVE_SLOT_MUX
+#include "mux.h"
+#endif
 
 #define NUM_SLOTS		2
 
@@ -1079,6 +1082,12 @@
 
 	cfg = (struct cardemu_usb_msg_config *) msgb_put(msg, sizeof(*cfg));
 	cfg->features = ch->features;
+#ifdef HAVE_SLOT_MUX
+	cfg->slot_mux_nr = mux_get_slot();
+#else
+	cfg->slot_mux_nr = 0;
+#endif
+
 
 	usb_buf_upd_len_and_submit(msg);
 }
@@ -1241,6 +1250,12 @@
 	if (scfg_len >= sizeof(uint32_t))
 		ch->features = (scfg->features & SUPPORTED_FEATURES);
 
+#ifdef HAVE_SLOT_MUX
+	if (scfg_len >= sizeof(uint32_t)+sizeof(uint8_t)) {
+		mux_set_slot(scfg->slot_mux_nr);
+	}
+#endif
+
 	/* send back a report of our current configuration */
 	card_emu_report_config(ch);
 

-- 
To view, visit https://gerrit.osmocom.org/c/simtrace2/+/24533
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I4cdb250d2e1dbc5b8b0169f8b7c21e288b492e1d
Gerrit-Change-Number: 24533
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210603/9f4edc59/attachment.htm>


More information about the gerrit-log mailing list