changeset 630:b639f7ab0007

Leonardo GPIO 2 fix
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 03 Jan 2020 07:13:51 +0000
parents 3231dd9b38c1
children 597869e59805
files doc/Leonardo-target src/cs/drivers/drv_core/armio/armio.c targets/leonardo.h
diffstat 3 files changed, 41 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/doc/Leonardo-target	Thu Jan 02 05:38:26 2020 +0000
+++ b/doc/Leonardo-target	Fri Jan 03 07:13:51 2020 +0000
@@ -76,3 +76,40 @@
 leonardo-dsp34 because your board has an older Calypso chip version on it, then
 you will need to specify the build target as just stated - see the
 Calypso-version-override article.
+
+Calypso GPIO 2 configuration
+============================
+
+On TI's C-Sample and D-Sample boards Calypso GPIO 2 is wired to serve as the DCD
+output for the MODEM UART (Calypso device as DCE), and our FC Magnetite firmware
+drives it as such on D-Sample, FCDEV3B and GTM900 targets.  But this same config
+does NOT apply to Leonardo: on the latter boards GPIO 2 is wired in a way that
+requires it to be configured as an input to Calypso, not an output.
+
+TI's TCS211 firmware had this Leonardo GPIO 2 situation handled in a very
+bizarre manner: the main GPIO init code in AI_InitIOConfig() in armio.c made no
+differentiation between D-Sample and Leonardo and configured GPIO 2 as an
+output, then the init code in uartfax.c did the same setup again, but at the
+end of the Init_Serial_Flows() function in the init module (which we only got
+as init.obj, with init.c censored out) they inserted a bit of code that switches
+GPIO 2 to be an input.  What a mess.
+
+Our handling of this GPIO 2 situation in FC Magnetite is much cleaner: we have
+put an #ifndef CONFIG_TARGET_LEONARDO around the AI_ConfigBitAsOutput(2) call
+in AI_InitIOConfig() so this GPIO line never becomes an output in the first
+place, and our targets/leonardo.h configuration header defines
+UARTFAX_CLASSIC_DTR_DCD to 0 on this target, disabling that code in the
+uartfax.c driver.
+
+Other GPIO and multifunction pins
+=================================
+
+Our Magnetite-Leonardo fw is unchanged from TI's TCS211 original in that GPIO0,
+TSPDI/GPIO4 and DSR_MODEM/LPG pins are left configured as inputs, even though
+the schematics we've got show GPIO0 as an output and the other two pins as
+unconnected, in which case they should also be configured as outputs in order
+to not float.  We are leaving this aspect unchanged currently because this
+Magnetite-Leonardo fw build target is really just a reference for practically
+non-existent hw, and given the unknown of what other Leonardo variants may have
+existed once beyond our known schematics, we would rather leave a few floating
+inputs than risk causing a driver conflict on some unknown board.
--- a/src/cs/drivers/drv_core/armio/armio.c	Thu Jan 02 05:38:26 2020 +0000
+++ b/src/cs/drivers/drv_core/armio/armio.c	Fri Jan 03 07:13:51 2020 +0000
@@ -283,7 +283,9 @@
       AI_ConfigBitAsOutput(0);
     #endif
     AI_ConfigBitAsOutput(1);
-    AI_ConfigBitAsOutput(2);
+    #ifndef CONFIG_TARGET_LEONARDO	/* GPIO 2 is an input on Leonardo! */
+      AI_ConfigBitAsOutput(2);
+    #endif
     #ifdef CONFIG_TARGET_GTAMODEM
       AI_ConfigBitAsOutput(3);
     #endif
--- a/targets/leonardo.h	Thu Jan 02 05:38:26 2020 +0000
+++ b/targets/leonardo.h	Fri Jan 03 07:13:51 2020 +0000
@@ -1,3 +1,3 @@
 #define	CONFIG_TARGET_LEONARDO	1
 #define	GPIO1_SPEAKER_CTRL	1
-#define	UARTFAX_CLASSIC_DTR_DCD	1
+#define	UARTFAX_CLASSIC_DTR_DCD	0