SPI port for VOXL2 SLPI DSP
-
Hello,
I am using VOXL2 with system image 1.4.1. I want to integrate sensor over SPI bus of voxl2 SLPI DSP in order to integrate it with PX4 firmware. This sensor which I am trying to integrate is optical flow sensor. I am aware of external SPI bus available over J10 as mentioned on this page but I want to have SPI bus directly talking with SLPI DSP for seemless integration.-
Do we have SPI pins exposed for sensor integration with SLPI DSP? If yes where to find them?
-
If I want to use J10 apps_proc SPI bus then in that case how can I proceed with sensor integration? I guess I would have to write some code on SLPI end and apps_proc end to send over the sensor data.
Please help @Eric-Katzfey
-
-
@Aks Unfortunately, there is only a single SPI port connected to the DSP and it is wired directly to the onboard IMU. So your driver would have to use a SPI available on the apps processor. Typically device drivers in PX4 submit their data to the rest of the system via topic publication. The VOXL2 PX4 implementation is a split architecture in that some of the code runs on the applications processor and some (all the real time flight code) runs on the DSP. But the implementation has a bridge (the muorb module) that allows topic data to flow between the two processors so you won't need to write any special code to do that.
-
@Aks This is the library to use in order to access the SPI from apps processor: https://gitlab.com/voxl-public/voxl-sdk/core-libs/libqrb5165-io
-
@Aks And here is an example of a device driver using that library code for SPI access: https://gitlab.com/voxl-public/voxl-sdk/services/voxl-lepton-server
-
@Eric-Katzfey Thanks alot for your prompt response and all the links. I would go through the same and come back for further queries.
-
@Eric-Katzfey I was going through the optical flow device driver on PX4 firmware side and had some thoughts which would need some validation.
- I would have to write device driver for optical flow sensor similar to voxl-lepton-server on apps_proc side and then publish results over muorb topic as you said, but muorb topics publication and subscription would be part of PX4 process running on apps_proc side then how can my driver seamlessly interact with PX4?
-
@Aks The first question would be which optical flow sensor are you using? Is there already a PX4 driver for it? If so, maybe you can just try to get that working on the applications processor. If you need to write a completely new driver for it then you can follow the example of one of the other PX4 optical flow sensor drivers. Does it also have an integrated distance sensor? The links I provided were just to show you how we use the SPI bus on the applications processor. But you wouldn't want to have it as an external process like that. You would want your device driver to be integrated as a PX4 device driver.
-
@Eric-Katzfey Thank you for the response. I am using this optical flow sensor. It works on PWM3901 and already has optical flow driver for the same in PX4. This sensor also has distance sensor over I2C where I can use J19 I2C port for getting distance sensor data into PX4. Now I can get optical flow SPI driver working on application processor but my query is how can I publish optical flow data over muorb from application processor process which is not running inside PX4 application?
-
EDIT :
I would rephrase my question a bit since I would need to run optical flow device driver integrated inside PX4. How can I run optical flow device driver on PX4 application processor side of code by accessing J10 SPI port?
-
@Aks I think you would add the vl53l1x driver to the DSP build and add the pmw3901 driver to the apps build. That way the distance sensor can use the i2c bus available on j19 and the optical flow sensor can use the spi on the applications processor.
-
@Eric-Katzfey Thank you for the inputs. I did the changes to build distance sensor on DSP build and assigned I2C port also to it. Now I have enabled optical flow on application processor side but I dont know how to link SPI port J10 to optical flow driver in the code. Please help.
-
@Aks Looks like
/dev/spidev14.0
is the one mapped to J10. We haven't used that port in PX4, only in our own applications. That is why I sent those links above. They show you how we use the SPI port on the applications processor in a non-PX4 application. You would need to look at how the SPI port is used and compare that against the Posix platform implementation of the SPI driver in PX4 to see if you can use it as is or if you will need to make modifications to it. -
@Eric-Katzfey Hi Eric, I am working on same above integration and stuck at adding SPI section to posix device driver of PX4. Do you have any guidance on integrating PMW3901 over application processor SPI bus on J10?
-
@Aaky Have you reviewed this documentation from PX4: https://docs.px4.io/main/en/sensor/pmw3901.html?
-
@Eric-Katzfey Yes I have reviwed this document in PX4 and also I got the driver compiled atleast on application processor side. Now I need to hookup the sensor to J10 with distance sensor on J19 I2C and check if its working.
-
@Eric-Katzfey One last doubt I have is as attached in snapshot below I am setting first argument to initSPIBus function as 14 since J10 has SPI device file as /dev/spidev14.0. Also the second argument to initSPIDevice function is 0. I think this is chip select for SPI but I read somewhere for posix drivers, chip select isnt used by SPI peripherals. Is my understanding correct?
This is spi.cpp file which I have added in boards/modalai/voxl2/src folder in voxl-px4 repository.
-
@Aaky Unfortunately, we have not done any integration between PX4 and SPI devices on the apps processor. I would get an oscilloscope and see what is happening on the bus.