Generating square wave to be inputted into a MCU
For standard IO the STM32F103 datasheet section 5.3.13 says:


\$ V_{IL(max)} = 0.28 (V_{DD} -2 \ \text V) + 0.8 \ \text V \$. For a 3.3 V supply this is 1.16 V.
\$ V_{IH(min)} = 0.41 (V_{DD} -2 \ \text V) + 1.3 \ \text V \$. For a 3.3 V supply this is 1.83 V. 



  Offset DC about 800mV, Vmax = 2.4V.


        0         1         2         3  3.3 V
        |    .    |    .    |    .    |  |     
GPIO:   |           ===.===              |
Signal: |       =================        |


Since your signal low &lt; GPIO VIL min and your signal high > GPIO VIH max I think you can feed your signal straight in.

Additional component count: 0.









simulate this circuit &ndash; Schematic created using CircuitLab

Figure 2. A comparator with auto-reference adjust.

The idea here is that C1 will charge to a reference voltage a little higher than the low signal due to the duty-cycle of the signal. R3 helps pull it a little higher but may not be required.

Most comparators have open collector outputs so R1 has been added but the GPIO internal pull-up may suffice.