From cf15630b81868c770fd0b3e9e1ee11926c68b8c9 Mon Sep 17 00:00:00 2001 From: Jim Parziale Date: Sun, 27 Mar 2022 13:51:24 -0400 Subject: [PATCH] Add alt names --- gpio/readall.c | 354 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 245 insertions(+), 109 deletions(-) diff --git a/gpio/readall.c b/gpio/readall.c index 24e7b9b..da402c3 100644 --- a/gpio/readall.c +++ b/gpio/readall.c @@ -35,7 +35,7 @@ #include -extern int wpMode ; +extern int wpMode; #ifndef TRUE # define TRUE (1==1) @@ -52,16 +52,16 @@ extern int wpMode ; static void doReadallExternal (void) { - int pin ; + int pin; - printf ("+------+---------+--------+\n") ; - printf ("| Pin | Digital | Analog |\n") ; - printf ("+------+---------+--------+\n") ; + printf ("+------+---------+--------+\n"); + printf ("| Pin | Digital | Analog |\n"); + printf ("+------+---------+--------+\n"); - for (pin = wiringPiNodes->pinBase ; pin <= wiringPiNodes->pinMax ; ++pin) - printf ("| %4d | %4d | %4d |\n", pin, digitalRead (pin), analogRead (pin)) ; + for (pin = wiringPiNodes->pinBase; pin <= wiringPiNodes->pinMax; ++pin) + printf ("| %4d | %4d | %4d |\n", pin, digitalRead (pin), analogRead (pin)); - printf ("+------+---------+--------+\n") ; + printf ("+------+---------+--------+\n"); } @@ -75,10 +75,12 @@ static void doReadallExternal (void) ********************************************************************************* */ +// FSEL_INPT, FSEL_OUTP, FSEL_ALT5, FSEL_ALT4, FSEL_ALT0, FSEL_ALT1, FSEL_ALT2, FSEL_ALT3 +// 000, 001, 010, 011, 100, 101, 110, 111 static char *alts[] = { "IN", "OUT", "ALT5", "ALT4", "ALT0", "ALT1", "ALT2", "ALT3" -} ; +}; static int physToWpi[64] = { @@ -112,7 +114,7 @@ static int physToWpi[64] = 17, 18, 19, 20, // 53, 54 -1, -1, -1, -1, -1, -1, -1, -1, -1 -} ; +}; static char *physNames[64] = { @@ -145,8 +147,127 @@ static char *physNames[64] = "GPIO.28", "GPIO.29", "GPIO.30", "GPIO.31", NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, -} ; - +}; + +static const char *gpio_alt_names_2835[54*8] = { +// FSEL_INPT, FSEL_OUTP, FSEL_ALT5 , FSEL_ALT4 , FSEL_ALT0 , FSEL_ALT1 , FSEL_ALT2 , FSEL_ALT3 +// 000, 001, 010 , 011 , 100 , 101 , 110 , 111 + "In" , "Out" , 0 , "AVEIN_VCLK" , "SDA0" , "SA5" , "PCLK" , "AVEOUT_VCLK" , + "In" , "Out" , 0 , "AVEIN_DSYNC", "SCL0" , "SA4" , "DE" , "AVEOUT_DSYNC" , + "In" , "Out" , 0 , "AVEIN_VSYNC", "SDA1" , "SA3" , "LCD_VSYNC" , "AVEOUT_VSYNC" , + "In" , "Out" , 0 , "AVEIN_HSYNC", "SCL1" , "SA2" , "LCD_HSYNC" , "AVEOUT_HSYNC" , + "In" , "Out" , "ARM_TDI" , "AVEIN_VID0" , "GPCLK0" , "SA1" , "DPI_D0" , "AVEOUT_VID0" , + "In" , "Out" , "ARM_TDO" , "AVEIN_VID1" , "GPCLK1" , "SA0" , "DPI_D1" , "AVEOUT_VID1" , + "In" , "Out" , "ARM_RTCK" , "AVEIN_VID2" , "GPCLK2" , "SOE_N_SE" , "DPI_D2" , "AVEOUT_VID2" , + "In" , "Out" , 0 , "AVEIN_VID3" , "SPI0_CE1_N", "SWE_N_SRW_N", "DPI_D3" , "AVEOUT_VID3" , + "In" , "Out" , 0 , "AVEIN_VID4" , "SPI0_CE0_N", "SD0" , "DPI_D4" , "AVEOUT_VID4" , + "In" , "Out" , 0 , "AVEIN_VID5" , "SPI0_MISO" , "SD1" , "DPI_D5" , "AVEOUT_VID5" , + "In" , "Out" , 0 , "AVEIN_VID6" , "SPI0_MOSI" , "SD2" , "DPI_D6" , "AVEOUT_VID6" , + "In" , "Out" , 0 , "AVEIN_VID7" , "SPI0_SCLK" , "SD3" , "DPI_D7" , "AVEOUT_VID7" , + "In" , "Out" , "ARM_TMS" , "AVEIN_VID8" , "PWM0" , "SD4" , "DPI_D8" , "AVEOUT_VID8" , + "In" , "Out" , "ARM_TCK" , "AVEIN_VID9" , "PWM1" , "SD5" , "DPI_D9" , "AVEOUT_VID9" , + "In" , "Out" , "TXD1" , "AVEIN_VID10", "TXD0" , "SD6" , "DPI_D10" , "AVEOUT_VID10" , + "In" , "Out" , "RXD1" , "AVEIN_VID11", "RXD0" , "SD7" , "DPI_D11" , "AVEOUT_VID11" , + "In" , "Out" , "CTS1" , "SPI1_CE2_N" , "FL0" , "SD8" , "DPI_D12" , "CTS0" , + "In" , "Out" , "RTS1" , "SPI1_CE1_N" , "FL1" , "SD9" , "DPI_D13" , "RTS0" , + "In" , "Out" , "PWM0" , "SPI1_CE0_N" , "PCM_CLK" , "SD10" , "DPI_D14" , "I2CSL_SDA_MOSI", + "In" , "Out" , "PWM1" , "SPI1_MISO" , "PCM_FS" , "SD11" , "DPI_D15" , "I2CSL_SCL_SCLK", + "In" , "Out" , "GPCLK0" , "SPI1_MOSI" , "PCM_DIN" , "SD12" , "DPI_D16" , "I2CSL_MISO" , + "In" , "Out" , "GPCLK1" , "SPI1_SCLK" , "PCM_DOUT" , "SD13" , "DPI_D17" , "I2CSL_CE_N" , + "In" , "Out" , 0 , "ARM_TRST" , "SD0_CLK" , "SD14" , "DPI_D18" , "SD1_CLK" , + "In" , "Out" , 0 , "ARM_RTCK" , "SD0_CMD" , "SD15" , "DPI_D19" , "SD1_CMD" , + "In" , "Out" , 0 , "ARM_TDO" , "SD0_DAT0" , "SD16" , "DPI_D20" , "SD1_DAT0" , + "In" , "Out" , 0 , "ARM_TCK" , "SD0_DAT1" , "SD17" , "DPI_D21" , "SD1_DAT1" , + "In" , "Out" , 0 , "ARM_TDI" , "SD0_DAT2" , "TE0" , "DPI_D22" , "SD1_DAT2" , + "In" , "Out" , 0 , "ARM_TMS" , "SD0_DAT3" , "TE1" , "DPI_D23" , "SD1_DAT3" , + "In" , "Out" , 0 , 0 , "SDA0" , "SA5" , "PCM_CLK" , "FL0" , + "In" , "Out" , 0 , 0 , "SCL0" , "SA4" , "PCM_FS" , "FL1" , + "In" , "Out" , "CTS1" , 0 , "TE0" , "SA3" , "PCM_DIN" , "CTS0" , + "In" , "Out" , "RTS1" , 0 , "FL0" , "SA2" , "PCM_DOUT" , "RTS0" , + "In" , "Out" , "TXD1" , 0 , "GPCLK0" , "SA1" , "RING_OCLK" , "TXD0" , + "In" , "Out" , "RXD1" , 0 , "FL1" , "SA0" , "TE1" , "RXD0" , + "In" , "Out" , 0 , 0 , "GPCLK0" , "SOE_N_SE" , "TE2" , "SD1_CLK" , + "In" , "Out" , 0 , 0 , "SPI0_CE1_N", "SWE_N_SRW_N", 0 , "SD1_CMD" , + "In" , "Out" , 0 , 0 , "SPI0_CE0_N", "SD0" , "TXD0" , "SD1_DAT0" , + "In" , "Out" , 0 , 0 , "SPI0_MISO" , "SD1" , "RXD0" , "SD1_DAT1" , + "In" , "Out" , 0 , 0 , "SPI0_MOSI" , "SD2" , "RTS0" , "SD1_DAT2" , + "In" , "Out" , 0 , 0 , "SPI0_SCLK" , "SD3" , "CTS0" , "SD1_DAT3" , + "In" , "Out" , "TXD1" , "SPI2_MISO" , "PWM0" , "SD4" , 0 , "SD1_DAT4" , + "In" , "Out" , "RXD1" , "SPI2_MOSI" , "PWM1" , "SD5" , "TE0" , "SD1_DAT5" , + "In" , "Out" , "RTS1" , "SPI2_SCLK" , "GPCLK1" , "SD6" , "TE1" , "SD1_DAT6" , + "In" , "Out" , "CTS1" , "SPI2_CE0_N" , "GPCLK2" , "SD7" , "TE2" , "SD1_DAT7" , + "In" , "Out" , 0 , "SPI2_CE1_N" , "GPCLK1" , "SDA0" , "SDA1" , "TE0" , + "In" , "Out" , 0 , "SPI2_CE2_N" , "PWM1" , "SCL0" , "SCL1" , "TE1" , + "In" , "Out" , "SPI2_CE1_N", 0 , "SDA0" , "SDA1" , "SPI0_CE0_N", 0 , + "In" , "Out" , "SPI2_CE0_N", 0 , "SCL0" , "SCL1" , "SPI0_MISO" , 0 , + "In" , "Out" , "SPI2_SCLK" , "ARM_TRST" , "SD0_CLK" , "FL0" , "SPI0_MOSI" , "SD1_CLK" , + "In" , "Out" , "SPI2_MOSI" , "ARM_RTCK" , "SD0_CMD" , "GPCLK0" , "SPI0_SCLK" , "SD1_CMD" , + "In" , "Out" , 0 , "ARM_TDO" , "SD0_DAT0" , "GPCLK1" , "PCM_CLK" , "SD1_DAT0" , + "In" , "Out" , 0 , "ARM_TCK" , "SD0_DAT1" , "GPCLK2" , "PCM_FS" , "SD1_DAT1" , + "In" , "Out" , 0 , "ARM_TDI" , "SD0_DAT2" , "PWM0" , "PCM_DIN" , "SD1_DAT2" , + "In" , "Out" , 0 , "ARM_TMS" , "SD0_DAT3" , "PWM1" , "PCM_DOUT" , "SD1_DAT3" +}; + +static const char *gpio_alt_names_2711[54*8] = { +// FSEL_INPT, FSEL_OUTP, FSEL_ALT5 , FSEL_ALT4 , FSEL_ALT0 , FSEL_ALT1 , FSEL_ALT2 , FSEL_ALT3 +// 000, 001, 010 , 011 , 100 , 101 , 110 , 111 + "GPIO.00" , "GPIO.00", "SDA6" , "TXD2" , "SDA0" , "SA5" , "PCLK" , "SPI3_CE0_N" , + "GPIO.01" , "GPIO.01", "SCL6" , "RXD2" , "SCL0" , "SA4" , "DE" , "SPI3_MISO" , + "GPIO.02" , "GPIO.02", "SDA3" , "CTS2" , "SDA1" , "SA3" , "LCD_VSYNC" , "SPI3_MOSI" , + "GPIO.03" , "GPIO.03", "SCL3" , "RTS2" , "SCL1" , "SA2" , "LCD_HSYNC" , "SPI3_SCLK" , + "GPIO.04" , "GPIO.04", "SDA3" , "TXD3" , "GPCLK0" , "SA1" , "DPI_D0" , "SPI4_CE0_N" , + "GPIO.05" , "GPIO.05", "SCL3" , "RXD3" , "GPCLK1" , "SA0" , "DPI_D1" , "SPI4_MISO" , + "GPIO.06" , "GPIO.06", "SDA4" , "CTS3" , "GPCLK2" , "SOE_N_SE" , "DPI_D2" , "SPI4_MOSI" , + "GPIO.07" , "GPIO.07", "SCL4" , "RTS3" , "SPI0_CE1_N", "SWE_N_SRW_N", "DPI_D3" , "SPI4_SCLK" , + "GPIO.08" , "GPIO.08", "SDA4" , "TXD4" , "SPI0_CE0_N", "SD0" , "DPI_D4" , "I2CSL_CE_N" , + "GPIO.09" , "GPIO.09", "SCL4" , "RXD4" , "SPI0_MISO" , "SD1" , "DPI_D5" , "I2CSL_SDI_MISO", + "GPIO.10" , "GPIO.10", "SDA5" , "CTS4" , "SPI0_MOSI" , "SD2" , "DPI_D6" , "I2CSL_SDA_MOSI", + "GPIO.11" , "GPIO.11", "SCL5" , "RTS4" , "SPI0_SCLK" , "SD3" , "DPI_D7" , "I2CSL_SCL_SCLK", + "GPIO.12" , "GPIO.12", "SDA5" , "TXD5" , "PWM0_0" , "SD4" , "DPI_D8" , "SPI5_CE0_N" , + "GPIO.13" , "GPIO.13", "SCL5" , "RXD5" , "PWM0_1" , "SD5" , "DPI_D9" , "SPI5_MISO" , + "GPIO.14" , "GPIO.14", "TXD1" , "CTS5" , "TXD0" , "SD6" , "DPI_D10" , "SPI5_MOSI" , + "GPIO.15" , "GPIO.15", "RXD1" , "RTS5" , "RXD0" , "SD7" , "DPI_D11" , "SPI5_SCLK" , + "GPIO.16" , "GPIO.16", "CTS1" , "SPI1_CE2_N" , 0 , "SD8" , "DPI_D12" , "CTS0" , + "GPIO.17" , "GPIO.17", "RTS1" , "SPI1_CE1_N" , 0 , "SD9" , "DPI_D13" , "RTS0" , + "GPIO.18" , "GPIO.18", "PWM0_0" , "SPI1_CE0_N" , "PCM_CLK" , "SD10" , "DPI_D14" , "SPI6_CE0_N" , + "GPIO.19" , "GPIO.19", "PWM0_1" , "SPI1_MISO" , "PCM_FS" , "SD11" , "DPI_D15" , "SPI6_MISO" , + "GPIO.20" , "GPIO.20", "GPCLK0" , "SPI1_MOSI" , "PCM_DIN" , "SD12" , "DPI_D16" , "SPI6_MOSI" , + "GPIO.21" , "GPIO.21", "GPCLK1" , "SPI1_SCLK" , "PCM_DOUT" , "SD13" , "DPI_D17" , "SPI6_SCLK" , + "GPIO.22" , "GPIO.22", "SDA6" , "ARM_TRST" , "SD0_CLK" , "SD14" , "DPI_D18" , "SD1_CLK" , + "GPIO.23" , "GPIO.23", "SCL6" , "ARM_RTCK" , "SD0_CMD" , "SD15" , "DPI_D19" , "SD1_CMD" , + "GPIO.24" , "GPIO.24", "SPI3_CE1_N" , "ARM_TDO" , "SD0_DAT0" , "SD16" , "DPI_D20" , "SD1_DAT0" , + "GPIO.25" , "GPIO.25", "SPI4_CE1_N" , "ARM_TCK" , "SD0_DAT1" , "SD17" , "DPI_D21" , "SD1_DAT1" , + "GPIO.26" , "GPIO.26", "SPI5_CE1_N" , "ARM_TDI" , "SD0_DAT2" , 0 , "DPI_D22" , "SD1_DAT2" , + "GPIO.27" , "GPIO.27", "SPI6_CE1_N" , "ARM_TMS" , "SD0_DAT3" , 0 , "DPI_D23" , "SD1_DAT3" , + "GPIO.28" , "GPIO.28", "RGMII_MDIO" , "MII_A_RX_ERR" , "SDA0" , "SA5" , "PCM_CLK" , 0 , + "GPIO.29" , "GPIO.29", "RGMII_MDC" , "MII_A_TX_ERR" , "SCL0" , "SA4" , "PCM_FS" , 0 , + "GPIO.30" , "GPIO.30", "CTS1" , "MII_A_CRS" , 0 , "SA3" , "PCM_DIN" , "CTS0" , + "GPIO.31" , "GPIO.31", "RTS1" , "MII_A_COL" , 0 , "SA2" , "PCM_DOUT" , "RTS0" , + "GPIO.32" , "GPIO.32", "TXD1" , "SD_CARD_PRES" , "GPCLK0" , "SA1" , 0 , "TXD0" , + "GPIO.33" , "GPIO.33", "RXD1" , "SD_CARD_WRPROT" , 0 , "SA0" , 0 , "RXD0" , + "GPIO.34" , "GPIO.34", "RGMII_IRQ" , "SD_CARD_LED" , "GPCLK0" , "SOE_N_SE" , 0 , "SD1_CLK" , + "GPIO.35" , "GPIO.35", 0 , "RGMII_START_STOP", "SPI0_CE1_N", "SWE_N_SRW_N", 0 , "SD1_CMD" , + "GPIO.36" , "GPIO.36", "MII_A_RX_ERR", "RGMII_RX_OK" , "SPI0_CE0_N", "SD0" , "TXD0" , "SD1_DAT0" , + "GPIO.37" , "GPIO.37", "MII_A_TX_ERR", "RGMII_MDIO" , "SPI0_MISO" , "SD1" , "RXD0" , "SD1_DAT1" , + "GPIO.38" , "GPIO.38", "MII_A_CRS" , "RGMII_MDC" , "SPI0_MOSI" , "SD2" , "RTS0" , "SD1_DAT2" , + "GPIO.39" , "GPIO.39", "MII_A_COL" , "RGMII_IRQ" , "SPI0_SCLK" , "SD3" , "CTS0" , "SD1_DAT3" , + "GPIO.40" , "GPIO.40", "TXD1" , "SPI0_MISO" , "PWM1_0" , "SD4" , 0 , "SD1_DAT4" , + "GPIO.41" , "GPIO.41", "RXD1" , "SPI0_MOSI" , "PWM1_1" , "SD5" , 0 , "SD1_DAT5" , + "GPIO.42" , "GPIO.42", "RTS1" , "SPI0_SCLK" , "GPCLK1" , "SD6" , 0 , "SD1_DAT6" , + "GPIO.43" , "GPIO.43", "CTS1" , "SPI0_CE0_N" , "GPCLK2" , "SD7" , 0 , "SD1_DAT7" , + "GPIO.44" , "GPIO.44", "SD_CARD_VOLT", "SPI0_CE1_N" , "GPCLK1" , "SDA0" , "SDA1" , 0 , + "GPIO.45" , "GPIO.45", "SD_CARD_PWR0", "SPI0_CE2_N" , "PWM0_1" , "SCL0" , "SCL1" , 0 , + "GPIO.46" , "GPIO.46", "SPI2_CE1_N" , 0 , "SDA0" , "SDA1" , "SPI0_CE0_N", 0 , + "GPIO.47" , "GPIO.47", "SPI2_CE0_N" , 0 , "SCL0" , "SCL1" , "SPI0_MISO" , 0 , + "GPIO.48" , "GPIO.48", "SPI2_SCLK" , "ARM_TRST" , "SD0_CLK" , 0 , "SPI0_MOSI" , "SD1_CLK" , + "GPIO.49" , "GPIO.49", "SPI2_MOSI" , "ARM_RTCK" , "SD0_CMD" , "GPCLK0" , "SPI0_SCLK" , "SD1_CMD" , + "GPIO.50" , "GPIO.50", "SPI2_MISO" , "ARM_TDO" , "SD0_DAT0" , "GPCLK1" , "PCM_CLK" , "SD1_DAT0" , + "GPIO.51" , "GPIO.51", "SD_CARD_LED" , "ARM_TCK" , "SD0_DAT1" , "GPCLK2" , "PCM_FS" , "SD1_DAT1" , + "GPIO.52" , "GPIO.52", 0 , "ARM_TDI" , "SD0_DAT2" , "PWM0_0" , "PCM_DIN" , "SD1_DAT2" , + "GPIO.53" , "GPIO.53", 0 , "ARM_TMS" , "SD0_DAT3" , "PWM0_1" , "PCM_DOUT" , "SD1_DAT3" , +}; + +static const char **gpio_alt_names = gpio_alt_names_2711; /* * readallPhys: @@ -157,61 +278,67 @@ static char *physNames[64] = static void readallPhys (int physPin) { - int pin ; + int pin; + // | BCM | WPi if (physPinToGpio (physPin) == -1) - printf (" | | ") ; + printf (" | | "); else - printf (" | %3d | %3d", physPinToGpio (physPin), physToWpi[physPin]) ; - - // @TODO This should read the mode to determine the GPIO or ALT name - printf (" | %s", physNames[physPin]) ; + printf (" | %3d | %3d", physPinToGpio (physPin), physToWpi[physPin]); + // | Name | Mode if (physToWpi[physPin] == -1) - printf (" | | ") ; + { + printf (" | %10s", physNames[physPin]); + printf (" | | "); + } else { if (wpMode == WPI_MODE_GPIO) - pin = physPinToGpio (physPin) ; + pin = physPinToGpio (physPin); else if (wpMode == WPI_MODE_PHYS) - pin = physPin ; + pin = physPin; else - pin = physToWpi[physPin] ; + pin = physToWpi[physPin]; + + printf (" | %10s", gpio_alt_names[pin*8 + getAlt(pin)]); - printf (" | %4s", alts[getAlt (pin)]) ; - printf (" | %d", digitalRead (pin)) ; + printf (" | %4s", alts[getAlt (pin)]); + printf (" | %d", digitalRead (pin)); } // Pin numbers: - printf (" | %2d", physPin) ; - ++physPin ; - printf (" || %-2d", physPin) ; + printf (" | %2d", physPin); + ++physPin; + printf (" || %-2d", physPin); // Same, reversed if (physToWpi[physPin] == -1) - printf (" | | ") ; + { + printf (" | | "); + printf (" | %-10s", physNames[physPin]); + } else { if (wpMode == WPI_MODE_GPIO) - pin = physPinToGpio (physPin) ; + pin = physPinToGpio (physPin); else if (wpMode == WPI_MODE_PHYS) - pin = physPin ; + pin = physPin; else - pin = physToWpi[physPin] ; + pin = physToWpi[physPin]; - printf (" | %d", digitalRead (pin)) ; - printf (" | %-4s", alts[getAlt (pin)]) ; - } + printf (" | %d", digitalRead (pin)); + printf (" | %4s", alts[getAlt (pin)]); - // @TODO This should read the mode to determine the GPIO or ALT name - printf (" | %-5s", physNames[physPin]) ; + printf (" | %-10s", gpio_alt_names[pin*8 + getAlt(pin)]); + } if (physToWpi [physPin] == -1) - printf (" | | ") ; + printf (" | | "); else - printf (" | %-3d | %-3d", physToWpi[physPin], physPinToGpio (physPin)) ; + printf (" | %-3d | %-3d", physToWpi[physPin], physPinToGpio (physPin)); - printf (" |\n") ; + printf (" |\n"); } @@ -224,26 +351,26 @@ static void readallPhys (int physPin) static void allReadall (void) { - int pin ; + int pin; - printf ("+------+------+-------+ +------+------+-------+\n") ; - printf ("| BCM | | | | BCM | | |\n") ; - printf ("| GPIO | Mode | Value | | GPIO | Mode | Value |\n") ; - printf ("+------+------+-------+ +------+------+-------+\n") ; + printf ("+------+------+-------+ +------+------+-------+\n"); + printf ("| BCM | | | | BCM | | |\n"); + printf ("| GPIO | Mode | Value | | GPIO | Mode | Value |\n"); + printf ("+------+------+-------+ +------+------+-------+\n"); - for (pin = 0 ; pin < 27 ; ++pin) + for (pin = 0; pin < 27; ++pin) { - printf ("| %3d ", pin) ; - printf ("| %-4s ", alts[getAlt (pin)]) ; - printf ("| %s ", digitalRead (pin) == HIGH ? "High" : "Low ") ; - printf ("| ") ; - printf ("| %3d ", pin + 27) ; - printf ("| %-4s ", alts[getAlt (pin + 27)]) ; - printf ("| %s ", digitalRead (pin + 27) == HIGH ? "High" : "Low ") ; - printf ("|\n") ; + printf ("| %3d ", pin); + printf ("| %-4s ", alts[getAlt (pin)]); + printf ("| %s ", digitalRead (pin) == HIGH ? "High" : "Low "); + printf ("| "); + printf ("| %3d ", pin + 27); + printf ("| %-4s ", alts[getAlt (pin + 27)]); + printf ("| %s ", digitalRead (pin + 27) == HIGH ? "High" : "Low "); + printf ("|\n"); } - printf ("+------+------+-------+ +------+------+-------+\n") ; + printf ("+------+------+-------+ +------+------+-------+\n"); } @@ -256,33 +383,33 @@ static void allReadall (void) void abReadall (int model, int rev) { - int pin ; - char *type ; + int pin; + char *type; if (model == PI_MODEL_A) - type = " A" ; + type = " A"; else if (rev == PI_VERSION_2) - type = "B2" ; + type = "B2"; else - type = "B1" ; + type = "B1"; - printf (" +-----+-----+---------+------+---+-Model %s-+---+------+---------+-----+-----+\n", type) ; - printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n") ; - printf (" +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n") ; - for (pin = 1 ; pin <= 26 ; pin += 2) - readallPhys (pin) ; + printf (" +-----+-----+---------+------+---+-Model %s-+---+------+---------+-----+-----+\n", type); + printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n"); + printf (" +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n"); + for (pin = 1; pin <= 26; pin += 2) + readallPhys (pin); if (rev == PI_VERSION_2) // B version 2 { - printf (" +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n") ; - for (pin = 51 ; pin <= 54 ; pin += 2) - readallPhys (pin) ; + printf (" +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n"); + for (pin = 51; pin <= 54; pin += 2) + readallPhys (pin); } - printf (" +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n") ; - printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n") ; - printf (" +-----+-----+---------+------+---+-Model %s-+---+------+---------+-----+-----+\n", type) ; + printf (" +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n"); + printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n"); + printf (" +-----+-----+---------+------+---+-Model %s-+---+------+---------+-----+-----+\n", type); } @@ -295,46 +422,46 @@ void abReadall (int model, int rev) static void plus2header (int model) { /**/ if (model == PI_MODEL_AP) - printf (" +-----+-----+---------+------+---+---Pi A+--+---+------+---------+-----+-----+\n") ; + printf (" +-----+-----+---------+------+---+---Pi A+--+---+------+---------+-----+-----+\n"); else if (model == PI_MODEL_BP) - printf (" +-----+-----+---------+------+---+---Pi B+--+---+------+---------+-----+-----+\n") ; + printf (" +-----+-----+---------+------+---+---Pi B+--+---+------+---------+-----+-----+\n"); else if (model == PI_MODEL_ZERO) - printf (" +-----+-----+---------+------+---+-Pi Zero--+---+------+---------+-----+-----+\n") ; + printf (" +-----+-----+---------+------+---+-Pi Zero--+---+------+---------+-----+-----+\n"); else if (model == PI_MODEL_ZERO_W) - printf (" +-----+-----+---------+------+---+-Pi ZeroW-+---+------+---------+-----+-----+\n") ; + printf (" +-----+-----+---------+------+---+-Pi ZeroW-+---+------+---------+-----+-----+\n"); else if (model == PI_MODEL_ZERO_2W) - printf (" +-----+-----+---------+------+---+Pi Zero 2W+---+------+---------+-----+-----+\n") ; + printf (" +-----+-----+---------+------+---+Pi Zero 2W+---+------+---------+-----+-----+\n"); else if (model == PI_MODEL_2B) - printf (" +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+\n") ; + printf (" +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+\n"); else if (model == PI_MODEL_3B) - printf (" +-----+-----+---------+------+---+---Pi 3B--+---+------+---------+-----+-----+\n") ; + printf (" +-----+-----+---------+------+---+---Pi 3B--+---+------+---------+-----+-----+\n"); else if (model == PI_MODEL_3BP) - printf (" +-----+-----+---------+------+---+---Pi 3B+-+---+------+---------+-----+-----+\n") ; + printf (" +-----+-----+---------+------+---+---Pi 3B+-+---+------+---------+-----+-----+\n"); else if (model == PI_MODEL_3AP) - printf (" +-----+-----+---------+------+---+---Pi 3A+-+---+------+---------+-----+-----+\n") ; + printf (" +-----+-----+---------+------+---+---Pi 3A+-+---+------+---------+-----+-----+\n"); else if (model == PI_MODEL_4B) - printf (" +-----+-----+---------+------+---+---Pi 4B--+---+------+---------+-----+-----+\n") ; + printf (" +-----+-----+------------+------+---+---Pi 4B--+---+------+------------+-----+-----+\n"); else if (model == PI_MODEL_400) - printf (" +-----+-----+---------+------+---+---Pi 400-+---+------+---------+-----+-----+\n") ; + printf (" +-----+-----+---------+------+---+---Pi 400-+---+------+---------+-----+-----+\n"); else - printf (" +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+\n") ; + printf (" +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+\n"); } static void piPlusReadall (int model) { - int pin ; + int pin; - plus2header (model) ; + plus2header (model); - printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n") ; - printf (" +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n") ; - for (pin = 1 ; pin <= 40 ; pin += 2) - readallPhys (pin) ; - printf (" +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n") ; - printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n") ; + printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n"); + printf (" +-----+-----+------------+------+---+----++----+---+------+------------+-----+-----+\n"); + for (pin = 1; pin <= 40; pin += 2) + readallPhys (pin); + printf (" +-----+-----+------------+------+---+----++----+---+------+------------+-----+-----+\n"); + printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n"); - plus2header (model) ; + plus2header (model); } @@ -347,30 +474,39 @@ static void piPlusReadall (int model) void doReadall (void) { - int model, proc, rev, mem, maker, overVolted ; + int model, proc, rev, mem, maker, overVolted; if (wiringPiNodes != NULL) // External readall { - doReadallExternal () ; - return ; + doReadallExternal (); + return; } - piBoardId (&model, &proc, &rev, &mem, &maker, &overVolted) ; - printf ("model: %d\n", model) ; + piBoardId (&model, &proc, &rev, &mem, &maker, &overVolted); if ((model == PI_MODEL_A) || (model == PI_MODEL_B)) - abReadall (model, rev) ; - else if ((model == PI_MODEL_BP) || (model == PI_MODEL_AP) || + { + gpio_alt_names = gpio_alt_names_2835; + abReadall (model, rev); + } + else if ((model == PI_MODEL_BP) || (model == PI_MODEL_AP) || (model == PI_MODEL_2B) || (model == PI_MODEL_3AP) || - (model == PI_MODEL_3B) || (model == PI_MODEL_3BP) || - (model == PI_MODEL_4B) || (model == PI_MODEL_400) || (model == PI_MODEL_CM4) || + (model == PI_MODEL_3B) || (model == PI_MODEL_3BP) || + (model == PI_MODEL_4B) || (model == PI_MODEL_400) || (model == PI_MODEL_CM4) || (model == PI_MODEL_ZERO) || (model == PI_MODEL_ZERO_W) || (model == PI_MODEL_ZERO_2W)) - piPlusReadall (model) ; + { + gpio_alt_names = gpio_alt_names_2711; + piPlusReadall (model); + } else if ((model == PI_MODEL_CM1) || (model == PI_MODEL_CM3) || (model == PI_MODEL_CM3P) ) - allReadall () ; + { + allReadall (); + } else - printf ("Oops - unable to determine board type... model: %d\n", model) ; + { + printf ("Oops - unable to determine board type... model: %d\n", model); + } } @@ -382,7 +518,7 @@ void doReadall (void) void doAllReadall (void) { - allReadall () ; + allReadall (); } @@ -394,14 +530,14 @@ void doAllReadall (void) void doQmode (int argc, char *argv[]) { - int pin ; + int pin; if (argc != 3) { - fprintf (stderr, "Usage: %s qmode pin\n", argv[0]) ; - exit (EXIT_FAILURE) ; + fprintf (stderr, "Usage: %s qmode pin\n", argv[0]); + exit (EXIT_FAILURE); } - pin = atoi (argv[2]) ; - printf ("%s\n", alts[getAlt (pin)]) ; + pin = atoi (argv[2]); + printf ("%s\n", alts[getAlt (pin)]); }