Forum > Embedded
LCD Displays on Pi or Beaglebone
engkin:
Regarding fpioctl failure, the returned value is important. I just checked the source code for spidev. fpioctl is going to end in spidev_ioctl.
spidev_ioctl which it checks for and the errno it could return:
SPI_IOC_MAGIC ===> -ENOTTY
access right (_IOC_WRITE in this case) ===> -EFAULT
device availability ===> -ESHUTDOWN
correct size: (the size) mod sizeof(struct spi_ioc_transfer) = 0 ===> -EINVAL
available kernel memory ===> -ENOMEM
copy the data kernel memory ===> -EFAULT
and finally it executes the command.
As you noted in your previous post, the driver path could be wrong. You might want to correct this code in PXL sample:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---constructor TApplication.Create;begin FGPIO := TSysfsGPIO.Create; FDataPort := TSysfsSPI.Create('/dev/spidev1.0');
jcdammeyer:
--- Quote from: engkin on May 26, 2021, 08:50:50 pm ---Regarding fpioctl failure, the returned value is important. I just checked the source code for spidev. fpioctl is going to end in spidev_ioctl.
spidev_ioctl which it checks for and the errno it could return:
and finally it executes the command.
As you noted in your previous post, the driver path could be wrong. You might want to correct this code in PXL sample:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---constructor TApplication.Create;begin FGPIO := TSysfsGPIO.Create; FDataPort := TSysfsSPI.Create('/dev/spidev1.0');
--- End quote ---
I'll check that error number.
I've tested it with both. /dev/spidev1.0 and /dev/spi/0.0 and either is fine. Not sure why the Beagle creates spidev1.0 while the Pi does spidev0.0. One of those little mysteries I guess.
For now I'm investigating how portable the examples are for the different types of displays. I've added this into the uses part of DisplaySPI app but at the moment work-work calls...
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$IFDEF DISPLAY_ILI9340} PXL.Displays.ILI9340; {$ELSE}PXL.Displays.SSD1351;{$ENDIF}
John
engkin:
One of the links posted above by Avra explains:
--- Quote ---For a SPI device with chipselect C on bus B, you should see:
/dev/spidevB.C
--- End quote ---
jcdammeyer:
--- Quote from: engkin on May 26, 2021, 10:01:35 pm ---One of the links posted above by Avra explains:
--- Quote ---For a SPI device with chipselect C on bus B, you should see:
/dev/spidevB.C
--- End quote ---
--- End quote ---
That document is written for the low level Linux expert and doesn't help someone who has no idea how to 'bind' something. Nor does it give any clue as to whether it's referring to a Beagle or a Pi or one of the other ARM based systems. Unfortunately.
For example:
Which one to choose?
pi@raspberrypi:~/projects/lazarus/TC $ ls /dev/spi*
/dev/spidev0.0 /dev/spidev0.1
Or here:
debian@ebb:~/lazarus/TC$ ls /dev/spi*
/dev/spidev1.0 /dev/spidev1.1 /dev/spidev2.0 /dev/spidev2.1
/dev/spi:
0.0 0.1 1.0 1.1
We know from reading Python programs (and some C examples) that for the Pi we use 0.0. For the Beagle unless you disable the HDMI you don't have access to the second SPI port so theoretically it should also be 0.0 but not quite...
avra:
--- Quote from: jcdammeyer on May 26, 2021, 10:59:48 pm ---Which one to choose?
pi@raspberrypi:~/projects/lazarus/TC $ ls /dev/spi*
/dev/spidev0.0 /dev/spidev0.1
Or here:
debian@ebb:~/lazarus/TC$ ls /dev/spi*
/dev/spidev1.0 /dev/spidev1.1 /dev/spidev2.0 /dev/spidev2.1
/dev/spi:
0.0 0.1 1.0 1.1
--- End quote ---
If we have a system with a single SPI bus where 3 chip select lines are available for that bus, we would have 0.0, 0.1 and 0.2. Choosing one of them will actually just select which one of the 3 predefined chip select lines will be used.
If we have a system with 3 SPI buses where buses 1 and 2 have 2 chip select lines each, while bus 3 has 4 chip select lines, then we would have 0.0 0.1 for the first bus, 1.0 1.1 for the 2nd bus, and 2.0 2.1 2.2 2.3 for the third bus. Choosing to connect our device to 2.3 would mean that we need to take a look at the documentation to find where are SPI3 MOSI/MISO/SCLK pins, and where is SPI3 CE3 pin. So, our software for 2.3 device will work only if we connect it to appropriate pins.
You can find more info here:
https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md
https://www.emcraft.com/stm32f429discovery/accessing-spi-devices-in-linux
--- Quote from: jcdammeyer on May 26, 2021, 10:59:48 pm ---I also want to port this:https://github.com/botheredbybees/kilnController
along with it's parent reflow oven controller to Lazarus.
--- End quote ---
Nice and useful Pi project, although I would have personally done it with ESP32.
--- Quote from: jcdammeyer on May 26, 2021, 10:59:48 pm ---The more of these types of projects out there the more we can bring people into the much easier Delphi/Lazarus programming world. IMHO.
--- End quote ---
That's why I decided to bring SocketCAN to FreePascal when I saw in the forum thread (which has started it all) that many tried but gave up because of lack of SocketCAN experience, although I had everything I needed in C and Python already.
Btw. Although PXL has set SPI default speed at 8MHz for the Pi, according to https://elinux.org/RPi_SPI it seams that Pi will actually use 7.8MHz (because of the clock divider 32). You could enable SPI_DIAGNOSTICS define in PXL.Sysfs.SPI.pas to check that on console output. That link also explains how to do SPI loopback test and how to send bytes from command line to SPI.
Navigation
[0] Message Index
[#] Next page
[*] Previous page