Change in simtrace2[master]: firmware: octsimtest: Support SIMTRACE_MSGT_DT_CEMU_CARDINSERT

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


laforge has submitted this change. ( https://gerrit.osmocom.org/c/simtrace2/+/24536 )

Change subject: firmware: octsimtest: Support SIMTRACE_MSGT_DT_CEMU_CARDINSERT
......................................................................

firmware: octsimtest: Support SIMTRACE_MSGT_DT_CEMU_CARDINSERT

The octsimtest board can control the card-insert contact of the OCTSIM
under test via an external I2C gpio multiplexer; let's add support for
that.

Change-Id: I8c9b0c3d862a967832134b24252577739182da62
---
M firmware/libboard/octsimtest/include/board.h
M firmware/libboard/octsimtest/include/mcp23017.h
M firmware/libboard/octsimtest/source/board_octsimtest.c
M firmware/libboard/octsimtest/source/mcp23017.c
M firmware/libcommon/source/mode_cardemu.c
5 files changed, 35 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/firmware/libboard/octsimtest/include/board.h b/firmware/libboard/octsimtest/include/board.h
index ad21a1f..530f27b 100644
--- a/firmware/libboard/octsimtest/include/board.h
+++ b/firmware/libboard/octsimtest/include/board.h
@@ -111,6 +111,10 @@
 
 #define HAVE_SLOT_MUX
 
+#define HAVE_BOARD_CARDINSERT
+struct cardem_inst;
+void board_set_card_insert(struct cardem_inst *ci, bool card_insert);
+
 /** Supported modes */
 /* SIMtrace board supports sniffer mode */
 //#define HAVE_SNIFFER
diff --git a/firmware/libboard/octsimtest/include/mcp23017.h b/firmware/libboard/octsimtest/include/mcp23017.h
index c0f4b13..190588f 100644
--- a/firmware/libboard/octsimtest/include/mcp23017.h
+++ b/firmware/libboard/octsimtest/include/mcp23017.h
@@ -21,5 +21,7 @@
 int mcp23017_init(uint8_t slave, uint8_t iodira, uint8_t iodirb);
 int mcp23017_test(uint8_t slave);
 int mcp23017_toggle(uint8_t slave);
+int mcp23017_set_output_a(uint8_t slave, uint8_t val);
+int mcp23017_set_output_b(uint8_t slave, uint8_t val);
 //int mcp23017_write_byte(uint8_t slave, uint8_t addr, uint8_t byte);
 //int mcp23017_read_byte(uint8_t slave, uint8_t addr);
diff --git a/firmware/libboard/octsimtest/source/board_octsimtest.c b/firmware/libboard/octsimtest/source/board_octsimtest.c
index 404bef6..1c6a278 100644
--- a/firmware/libboard/octsimtest/source/board_octsimtest.c
+++ b/firmware/libboard/octsimtest/source/board_octsimtest.c
@@ -94,3 +94,18 @@
 	} else
 		return 0;
 }
+
+void board_set_card_insert(struct cardem_inst *ci, bool card_insert)
+{
+	int s = mux_get_slot();
+
+	/* A0 .. A7 of the MCP are each connected to the gate of a FET which closes
+	 * the sim-present signal of the respective slot */
+
+	if (mcp2317_present) {
+		/* we must enable card-presence of the active slot and disable it on all others */
+		mcp23017_set_output_a(MCP23017_ADDRESS, (1 << s));
+	} else {
+		TRACE_WARNING("No MCP23017 present; cannot set CARD_INSERT\r\n");
+	}
+}
diff --git a/firmware/libboard/octsimtest/source/mcp23017.c b/firmware/libboard/octsimtest/source/mcp23017.c
index a4d055f..bc6bd49 100644
--- a/firmware/libboard/octsimtest/source/mcp23017.c
+++ b/firmware/libboard/octsimtest/source/mcp23017.c
@@ -126,6 +126,16 @@
 	return 0;
 }
 
+int mcp23017_set_output_a(uint8_t slave, uint8_t val)
+{
+	return mcp23017_write_byte(slave, MCP23017_OLATA, val);
+}
+
+int mcp23017_set_output_b(uint8_t slave, uint8_t val)
+{
+	return mcp23017_write_byte(slave, MCP23017_OLATB, val);
+}
+
 int mcp23017_toggle(uint8_t slave)
 {
 	// example writing MSB of gpio
diff --git a/firmware/libcommon/source/mode_cardemu.c b/firmware/libcommon/source/mode_cardemu.c
index 3863767..a357f15 100644
--- a/firmware/libcommon/source/mode_cardemu.c
+++ b/firmware/libcommon/source/mode_cardemu.c
@@ -656,6 +656,9 @@
 {
 	TRACE_INFO("%u: set card_insert to %s\r\n", ci->num, card_insert ? "INSERTED" : "REMOVED");
 
+#ifdef HAVE_BOARD_CARDINSERT
+	board_set_card_insert(ci, card_insert);
+#else
 	if (!ci->pin_insert.pio) {
 		TRACE_INFO("%u: skipping unsupported card_insert to %s\r\n",
 			   ci->num, card_insert ? "INSERTED" : "REMOVED");
@@ -666,6 +669,7 @@
 		PIO_Set(&ci->pin_insert);
 	else
 		PIO_Clear(&ci->pin_insert);
+#endif
 }
 
 /* handle a single USB command as received from the USB host */

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I8c9b0c3d862a967832134b24252577739182da62
Gerrit-Change-Number: 24536
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210603/4090ca6c/attachment.htm>


More information about the gerrit-log mailing list