<p>laforge would like tsaitgaist to <strong>review</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/simtrace2/+/23621">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">cardem: ensure VCC_PHONE is floating<br><br>this change is mainly relevant for the SIMtrace board, but also<br>affects the others.<br>First we ensure VCC_PHONE is not forwarded to VCC_SIM because the<br>card could affect the signal (card could draw too much current or<br>feed back current in).<br>next we disable VCC_SIM. the card slot does not need to be<br>powered, and the FPF2019 leaks current back to VCC_PHONE, even<br>with forwarding disabled (the reverse current protection only<br>kicks in when VCC_PHONE is briefly shorted to ground, but still<br>leaks 0.6V).<br>enable the ADC channels normally used to measure VCC, even if<br>not used. the dedicated ADC pins leak current when left<br>unconfigured. enabling them puts them in high impedance.<br><br>Change-Id: If1487c1c191838aaa08b654e49cd31c7180ffc19<br><br>XX pin reconfig<br><br>Change-Id: Ib261073e3779ae7d98de18ce78b34ff37eafeaa2<br>---<br>M firmware/libboard/simtrace/include/board.h<br>M firmware/libcommon/source/mode_cardemu.c<br>2 files changed, 17 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/21/23621/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/firmware/libboard/simtrace/include/board.h b/firmware/libboard/simtrace/include/board.h</span><br><span>index 65e6197..bdc1eb7 100644</span><br><span>--- a/firmware/libboard/simtrace/include/board.h</span><br><span>+++ b/firmware/libboard/simtrace/include/board.h</span><br><span>@@ -120,6 +120,14 @@</span><br><span> /* ISO7816-communication related pins */</span><br><span> #define PINS_ISO7816            PIN_SIM_IO,  PIN_SIM_CLK,  PIN_ISO7816_RSTMC // SIM_PWEN_PIN, PIN_SIM_IO2, PIN_SIM_CLK2</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/** card emulation configuration */</span><br><span style="color: hsl(120, 100%, 40%);">+/* Disable power converter 4.5-6V to 3.3V (active high) */</span><br><span style="color: hsl(120, 100%, 40%);">+#define PIN_SIM_PWEN_CARDEMU   {PIO_PA5, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}</span><br><span style="color: hsl(120, 100%, 40%);">+/* Disable power switch to forward VCC_PHONE to VCC_SIM (active high) */</span><br><span style="color: hsl(120, 100%, 40%);">+#define PIN_VCC_FWD_CARDEMU    {PIO_PA26, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}</span><br><span style="color: hsl(120, 100%, 40%);">+/* Disable power to SIM */</span><br><span style="color: hsl(120, 100%, 40%);">+#define PINS_PWR_CARDEMU        PIN_SIM_PWEN_CARDEMU, PIN_VCC_FWD_CARDEMU</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /** External SPI flash interface   **/</span><br><span> /* SPI MISO pin definition */</span><br><span> #define PIN_SPI_MISO  {PIO_PA12A_MISO, PIOA, PIOA, PIO_PERIPH_A, PIO_PULLUP}</span><br><span>diff --git a/firmware/libcommon/source/mode_cardemu.c b/firmware/libcommon/source/mode_cardemu.c</span><br><span>index 32d3b17..50fe668 100644</span><br><span>--- a/firmware/libcommon/source/mode_cardemu.c</span><br><span>+++ b/firmware/libcommon/source/mode_cardemu.c</span><br><span>@@ -546,12 +546,20 @@</span><br><span> </span><br><span>      TRACE_ENTRY();</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef PINS_PWR_CARDEMU</span><br><span style="color: hsl(120, 100%, 40%);">+   // enable power on required peripherals, else disable</span><br><span style="color: hsl(120, 100%, 40%);">+ Pin pins_pwr_cardemu[] = { PINS_PWR_CARDEMU };</span><br><span style="color: hsl(120, 100%, 40%);">+        PIO_Configure(pins_pwr_cardemu, PIO_LISTSIZE(pins_pwr_cardemu));</span><br><span style="color: hsl(120, 100%, 40%);">+#endif /* PINS_PWR_CARDEMU */</span><br><span> #ifdef PINS_CARDSIM</span><br><span>       PIO_Configure(pins_cardsim, PIO_LISTSIZE(pins_cardsim));</span><br><span> #endif</span><br><span style="color: hsl(120, 100%, 40%);">+    // ADC channel 6 and 7 are used to measure VCC (else they are grounded)</span><br><span style="color: hsl(120, 100%, 40%);">+       ADC->ADC_CHER |= ADC_CHER_CH6 | ADC_CHER_CH7; // enable the ADC channels to put them in high impedance (else they leak current)</span><br><span> #ifdef DETECT_VCC_BY_ADC</span><br><span style="color: hsl(0, 100%, 40%);">-  card_vcc_adc_init();</span><br><span style="color: hsl(120, 100%, 40%);">+  card_vcc_adc_init(); // configure the ADC to measure VCC</span><br><span> #endif /* DETECT_VCC_BY_ADC */</span><br><span style="color: hsl(120, 100%, 40%);">+    // TODO pull SIMtrace board SIM lines low, else they can leak current back to VCC</span><br><span> </span><br><span>        INIT_LLIST_HEAD(&cardem_inst[0].usb_out_queue);</span><br><span>  rbuf_reset(&cardem_inst[0].rb);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/simtrace2/+/23621">change 23621</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/simtrace2/+/23621"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: simtrace2 </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ib261073e3779ae7d98de18ce78b34ff37eafeaa2 </div>
<div style="display:none"> Gerrit-Change-Number: 23621 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: tsaitgaist <kredon@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>