Banana Pro and SPI mode (Can not change to mode 3)

Visto 61 veces
Saltar al primer mensaje no leído

fschu...@gmail.com

no leída,
9 oct 2016, 2:47:519/10/16
a Pi4J
Hey all,

first of all, thank you very much for this awesome Java API!

Currently I am trying to communicate with an Pervasive Display 7.4" e-ink display via SPI. In order to set up the SPI communication, I need to change the SPI mode to Mode 3 (CPOL = 1 & CPHA = 1).

That's where my problem occurs. :-( I am using SpiFactory in order to get the SPI device, set the speed and mode. It compiles fine but upon execution an exception is thrown that WiringPiChangeMode is not supported.

Am I doing something wrong? Is changing the SPI mode not supported for Banana Pro? In case there is  yes for the second question, is there a workaround (e.g., on system level - I am only using SPI for the display communication)?

Thanks in advance!

Frank


That is what the display's data sheet says:


SPI Settings

  • ▪  Bitrate–upto3MHz

  • ▪  Polarity – CPOL = 1; clock transition high-to-low on the leading edge and low-to-high on the

    trailing edge

  • ▪  Phase – CPHA = 1; setup on the leading edge and sample on the trailing edge

  • ▪  Bit order – MSB first

  • ▪  Chip select polarity – active low 


 And my SpiFactory

spi = SpiFactory.getInstance(SpiChannel.CS0,
3000000, // default spi speed 1 MHz
SpiDevice.MODE_3); // default spi mode 0

fschu...@gmail.com

no leída,
9 oct 2016, 4:15:259/10/16
a Pi4J
And here is the exception I get:

java.lang.UnsupportedOperationException: This implementation of WiringPi does not support method 'wiringPiSPISetupMode'.

        at com.pi4j.wiringpi.Spi.wiringPiSPISetupMode(Native Method)

        at com.pi4j.io.spi.impl.SpiDeviceImpl.<init>(SpiDeviceImpl.java:71)

        at com.pi4j.io.spi.SpiFactory.getInstance(SpiFactory.java:112)

        at station_800.GPIO_Com.<init>(GPIO_Com.java:39)

        at station_800.main.main(main.java:21)

Exception in thread "main" java.lang.NullPointerException

        at station_800.GPIO_Com.sendCmd(GPIO_Com.java:59)

        at station_800.GPIO_Com.getDeviceInfo(GPIO_Com.java:77)

        at station_800.main.main(main.java:22)


I read a bit further in the forum and found that SPI mode selection is not supported for the Odroid boards due to missing functionality of the underlying WiringPi port. Is that the same case with the Banana boards? 

fschu...@gmail.com

no leída,
9 oct 2016, 4:20:369/10/16
a Pi4J
(sorry, I can not figure out how to edit the original post to include this information)

And a bit further down the road, the exception seems to come from:

/*
* Class: com_pi4j_wiringpi_Spi
* Method: wiringPiSPISetupMode
* Signature: (III)I
*/
JNIEXPORT jint JNICALL Java_com_pi4j_wiringpi_Spi_wiringPiSPISetupMode
(JNIEnv *env, jclass class, jint channel, jint speed, jint mode)
{
#ifdef WIRINGPI_SPI_SETUP_MODE_UNSUPPORTED
throwUnsupportedOperationException(env,
"This implementation of WiringPi does not support method 'wiringPiSPISetupMode'.");
return -1;
#else
return wiringPiSPISetupMode(channel, speed, mode);
#endif
}

Robert Savage

no leída,
9 dic 2016, 20:42:469/12/16
a Pi4J
Sorry for the delay ....  

So the issue here is that the WiringPi port (WiringBP: https://github.com/LeMaker/WiringBP) used to allow Pi4J to communicate with the BananaPi and BananaPro hardware is a bit out of date compared with the Raspberry Pi WiringPi changes and it does not have the "wiringPiSPISetupMode" function included in the native WiringBP library.  So with that function missing from the native library, we are not able to call into it to perform the advanced mode changes and thus that why we added that compiler directive to throw the error.  

If you can get the maintainers of WiringBP to update or implement this function, we can certainly enable it in Pi4J!   
(Or even better ... update it yourself on your own fork and submit the pull request to the WiringBP project :-) )

Thanks, Robert
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos