40pin - Pin mapping in mraa changed ?
I used UPBoard/ubuilinux/c/mraa until now. The pin mapping was clear for me.
It was like this :
mraa-gpio list
03 I2C_SDA: GPIO I2C
05 I2C_SCL: GPIO I2C
07 ADC0: GPIO AIO
08 UART_TX: GPIO UART
10 UART_RX: GPIO UART
11 UART_RTS: GPIO UART
12 I2S_CLK: GPIO
13 GPIO27: GPIO
15 GPIO22: GPIO I2C
16 GPIO23: GPIO
18 GPIO24: GPIO
19 SPI_MOSI: GPIO SPI
21 SPI_MISO: GPIO SPI
22 GPIO25: GPIO
23 SPI_CLK: GPIO SPI
24 SPI_CS0: GPIO SPI
26 SPI_CS1: GPIO SPI
27 ID_SD: GPIO I2C
28 ID_SC: GPIO I2C
29 GPIO5: GPIO
31 GPIO6: GPIO
32 PWM0: GPIO PWM
33 PWM1: GPIO PWM
35 I2S_FRM: GPIO
36 UART_CTS: GPIO UART
37 GPIO26: GPIO
38 I2S_DIN: GPIO
40 I2S_DOUT: GPIO
and I used pin 32 in my sw - initialized with MRAA_EnableIO( .... , 32) function.
But now I switched to UP4000 and there is something different. I am not able to initialize hw pin 32 (GPIO12) any more.
The MRAA_EnableIO( .... , 32) function returns me error :
Error exporting pin 32!
List of pins from mraa on UP4000/Ubuntu/pinctrl-upboard is like this:
mraa-gpio list
00 ID_SD: GPIO I2C
01 ID_SC: GPIO I2C
02 I2C_SDA: GPIO I2C
03 I2C_SCL: GPIO I2C
04 ADC0: GPIO AIO
05 GPIO5: GPIO
06 GPIO6: GPIO
07 SPI_CS1: GPIO SPI
08 SPI_CS0: GPIO SPI
09 SPI_MISO: GPIO SPI
10 SPI_MOSI: GPIO SPI
11 SPI_CLK: GPIO SPI
12 PWM0: GPIO PWM
13 PWM1: GPIO PWM
14 UART_TX: GPIO UART
15 UART_RX: GPIO UART
16 UART_CTS: GPIO UART
17 UART_RTS: GPIO UART
18 I2S_CLK: GPIO
19 I2S_FRM: GPIO
20 I2S_DIN: GPIO
21 I2S_DOUT: GPIO
22 GPIO22: GPIO I2C
23 GPIO23: GPIO
24 GPIO24: GPIO
25 GPIO25: GPIO
26 GPIO26: GPIO
27 GPIO27: GPIO
So I am confused... should I remap all may pins to different numbers ? I assume that I should use
MRAA_EnableIO( .... , 12) instead of UPBoard MRAA_EnableIO( .... , 32) ?
Or different issue is there ?
Answers
-
@Lubo
the original mraa is using pin number 1~40, the new mraa just change to GPIO number,
because the most usage is using GPIO number like sysfs or uAPI V2 to access GPIO.it's easy to modify mraa back to use pin number, you can check mraa/src/x86 up.c and up_boards.c
change up_boards.c like the up.c's set_pininfo
mraa_up_set_pininfo(b, 0, "INVALID", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1); mraa_up_set_pininfo(b, 1, "3.3v", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1); mraa_up_set_pininfo(b, 2, "5v", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1); mraa_up_set_pininfo(b, 3, "I2C_SDA", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 }, 2); mraa_up_set_pininfo(b, 4, "5v", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1); mraa_up_set_pininfo(b, 5, "I2C_SCL", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 }, 3); mraa_up_set_pininfo(b, 6, "GND", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1); mraa_up_set_pininfo(b, 7, "ADC0", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 }, 4); mraa_up_set_pininfo(b, 8, "UART_TX", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 }, 14); mraa_up_set_pininfo(b, 9, "GND", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1); mraa_up_set_pininfo(b, 10, "UART_RX", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 }, 15); mraa_up_set_pininfo(b, 11, "UART_RTS", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 }, 17); mraa_up_set_pininfo(b, 12, "I2S_CLK", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 18); mraa_up_set_pininfo(b, 13, "GPIO27", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 27); mraa_up_set_pininfo(b, 14, "GND", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1); mraa_up_set_pininfo(b, 15, "GPIO22", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 }, 22); mraa_up_set_pininfo(b, 16, "GPIO23", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 23); mraa_up_set_pininfo(b, 17, "3.3v", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1); mraa_up_set_pininfo(b, 18, "GPIO24", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 24); mraa_up_set_pininfo(b, 19, "SPI_MOSI", (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 }, 10); mraa_up_set_pininfo(b, 20, "GND", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1); mraa_up_set_pininfo(b, 21, "SPI_MISO", (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 }, 9); mraa_up_set_pininfo(b, 22, "GPIO25", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 25); mraa_up_set_pininfo(b, 23, "SPI_CLK", (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 }, 11); mraa_up_set_pininfo(b, 24, "SPI_CS0", (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 }, 8); mraa_up_set_pininfo(b, 25, "GND", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1); mraa_up_set_pininfo(b, 26, "SPI_CS1", (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 }, 7); mraa_up_set_pininfo(b, 27, "ID_SD", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 }, 0); mraa_up_set_pininfo(b, 28, "ID_SC", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 }, 1); mraa_up_set_pininfo(b, 29, "GPIO5", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 5); mraa_up_set_pininfo(b, 30, "GND", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1); mraa_up_set_pininfo(b, 31, "GPIO6", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 6); mraa_up_set_pininfo(b, 32, "PWM0", (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 }, 12); mraa_up_set_pininfo(b, 33, "PWM1", (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 }, 13); mraa_up_set_pininfo(b, 34, "GND", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1); mraa_up_set_pininfo(b, 35, "I2S_FRM", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 19); mraa_up_set_pininfo(b, 36, "UART_CTS", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 }, 16); mraa_up_set_pininfo(b, 37, "GPIO26", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 26); mraa_up_set_pininfo(b, 38, "I2S_DIN", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 20); mraa_up_set_pininfo(b, 39, "GND", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1); mraa_up_set_pininfo(b, 40, "I2S_DOUT", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 21);
-
Thank you !
I expected that mapping is changed now. Its better for me to change my app source code pin mapping and to use new mraa mapping. It will be better for possible new mraa updates.
However, I am just woundering why I did not notice this change in documentation. Maybe its my fault, but maybe this fact is not higlighted enough in new mraa documentation https://github.com/up-division/mraa/tree/up-rpi ?
We can find there link for supported boards - UP - https://github.com/up-division/mraa/blob/master/docs/up.md
and there is "MRAA number", which is something different now....