HOW TO ACCESS pin 5 of CONNECTOR 11 GPIO

From OpenCircuits
Jump to navigation Jump to search

HOW TO ACCESS pin 5 of CONNECTOR 11 GPIO of Odroid XU4 by modifying the excellent wiringPi library, which works with XU4 but was originally designed for XU3:

My contribution here is something I solved, which is unavailable from all my internet searches. User:Definitionofis owns the Odroid XU4 and there is a connector CONN11 not documented in wiringPi for GPIO use because the XU4 is an upgrade from XU3. https://wiki.odroid.com/odroid-xu4/software/gpio_register_map#gpio_port_register_map Also see: https://wiki.odroid.com/odroid-xu4/odroid-xu4 for operating system installation.

You can modify the C language file odroidxu3.c which has a placeholder filled with several -1 items as an error return code. The XU3 and XU4 both have 1 to 40 pins accessible from the Shifter Shield. I used all the GPIO (GPX) IN/OUT pins with success. That is the 40 pin connector. https://wiki.odroid.com/accessory/add-on_boards/xu4_shift_shield

Here is the library wiringPi which I started with: https://github.com/hardkernel/wiringPi and you will find a file odroidxu3.c in there.

See the other 12 pin connector of the XU4. Pin 5 is a GPX3.2 IN/OUT pin. I will arbitrarily call it pin 45 although the first connector has 40 pins, and this pin 5 is on the 12 pin connector. Better naming would require much more extensive edits of all the C code so live with this naming as "pin 45". The CPU register space sees it as mathematically adjacent to GPX3.1, which is pin 36, GPX3.1 and CONN11/pin 5 is GPX3.2. https://wiki.odroid.com/odroid-xu4/software/gpio_register_map#gpio_port_register_map

You can simply change one number from -1 to 34 without understanding why:

Change odroidxu3.c and recompile the library. Then you can simply do things like digitalWrite(45, 1); and pinMode (45, OUTPUT ) and instead of getting a return -1 error you will get proper success where previously the range of pins was 1 to 40.

Here is the change to odroidxu3.c See the number 34 in there, just below "//Not Used"? That was a -1. Change the -1 to a 34 and recompile. That is all you have to do. That 34 is in the 45th position thus pin 45.

static const int phyToGpio[64] = {

      // physical header pin number to native gpio number
      -1,             //  0
      -1,  -1,        //  1 |  2 : 3.3V, 5.0V
      209, -1,        //  3 |  4 : GPB3.2(I2C_1.SDA), 5.0V
      210, -1,        //  5 |  6 : GPB3.3(I2C_1.SCL), GND
      18, 172,        //  7 |  8 : GPX1.2, GPA0.1(UART_0.TXD)
      -1, 171,        //  9 | 10 : GND, GPA0.0(UART_0.RXD)
      174,173,        // 11 | 12 : GPA0.3(UART_0.CTSN), GPA0.2(UART_0.RTSN)
      21,  -1,        // 13 | 14 : GPX1.5, GND
      22,  19,        // 15 | 16 : GPX1.6, GPX1.3
      -1,  23,        // 17 | 18 : 3.3V, GPX1.7
      192, -1,        // 19 | 20 : GPA2.7(SPI_1.MOSI), GND
      191, 24,        // 21 | 22 : GPA2.6(SPI_1.MISO), GPX2.0
      189,190,        // 23 | 24 : GPA2.4(SPI_1.SCLK), GPA2.5(SPI_1.CSN)
      -1,  25,        // 25 | 26 : GND, GPX2.1
      187,188,        // 27 | 28 : GPA2.2(I2C_5.SDA), GPA2.4(I2C_5.SCL)
      28,  -1,        // 29 | 30 : GPX2.4, GND
      30,  29,        // 31 | 32 : GPX2.6, GPX2.5
      31,  -1,        // 33 | 34 : GPX2.7, GND
      -1,  33,        // 35 | 36 : PWR_ON(INPUT), GPX3.1
      -1,  -1,        // 37 | 38 : ADC_0.AIN0, 1.8V REF OUT
      -1,  -1,        // 39 | 40 : GND, AADC_0.AIN3
      // Not used  (August 2, 2019, add pin 45 to be pin 5 of CON11 Odroid Shifter Shield XU4
      -1, -1,
      -1, -1,
      34, -1, // pin 5 of CONN11 GPX3.2(#34) wiki.odroid.com/odroid-xu4/hardware/expansion_connectors#gpio_map_for_wiringpi_library_con10_2_x_15
      -1, -1, // 41...48
      -1, -1,
      -1, -1,
      -1, -1,
      -1, -1, // 49...56
      -1, -1,
      -1, -1,
      -1, -1,
      -1      // 57...63

};

I am using Phys mode. I never tested other modes.

Here is a transistor switch to upgrade the different 1.8v GPIO output to match the 3.3v of all the other GPIOs on the odroid board. [[1]]

A link to my projects: https://opencircuits.com/index.php?title=User:Definitionofis