mirror of https://gerrit.osmocom.org/simtrace2
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
This commit is contained in:
parent
f69a60f255
commit
731e199fc4
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -94,3 +94,18 @@ int board_override_enter_dfu(void)
|
|||
} 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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,6 +126,16 @@ int mcp23017_test(uint8_t slave)
|
|||
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
|
||||
|
|
|
@ -656,6 +656,9 @@ static void process_card_insert(struct cardem_inst *ci, bool card_insert)
|
|||
{
|
||||
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 @@ static void process_card_insert(struct cardem_inst *ci, bool card_insert)
|
|||
PIO_Set(&ci->pin_insert);
|
||||
else
|
||||
PIO_Clear(&ci->pin_insert);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* handle a single USB command as received from the USB host */
|
||||
|
|
Loading…
Reference in New Issue