Page 1 of 2

SPI

Posted: Thu Oct 23, 2014 10:38 am
by anto
Hi,
where can i find some instruction to connect a slave device to my Red Pitaya and communicate with it?

Re: SPI

Posted: Wed Dec 17, 2014 12:44 pm
by wa4557
I'd be interested in this as well, seems funny that there's a SPI interface without any use. Where could start to develop a driver?

Re: SPI

Posted: Sat Dec 20, 2014 12:26 am
by Nils Roos
Well, the SPI bus on the extension connector E2 is connected to the ZYNQ's SPI 1 interface, which in turn is made available to the linux kernel by the following block in the devicetree:

Code: Select all

		ps7_spi_1: ps7-spi@e0007000 {
			bus-num = <2>;
			compatible = "xlnx,ps7-spi-1.00.a";
			interrupt-parent = <&ps7_scugic_0>;
			interrupts = < 0 49 4 >;
			num-chip-select = <4>;
			reg = < 0xe0007000 0x1000 >;
			speed-hz = <166666672>;
			xlnx,has-ss0 = <0x1>;
			xlnx,has-ss1 = <0x0>;
			xlnx,has-ss2 = <0x0>;
			xlnx,spi-clk-freq-hz = <0x9ef21b0>;
		} ;
So, you would probably start by writing a module that registers a new class on this spi-bus, then searches the bus for your specific device and register itself as the driver if found.

Re: SPI

Posted: Fri Jan 16, 2015 12:09 pm
by rajat
In place of making changes in fpga code can be write code in arm and run it to get data on fpga spi pins .........

Re: SPI

Posted: Fri Jan 16, 2015 12:17 pm
by rajat
Can you please let me know where this code is present in the red pitaya folder that you have mentioned.

Re: SPI

Posted: Fri Jan 16, 2015 1:19 pm
by Nils Roos
This code was from the "devicetree.dts" file that's being generated dynamically during the Red Pitaya build process.

The relevant Makefile targets are "devicetree" from RedPitaya/FPGA/release1/fpga/Makefile:

Code: Select all

devicetree:
	make -C $(SDK_DIR)/device-tree_bsp_0/ -k all
and RedPitaya/FPGA/release1/fpga/vivado/red_pitaya.sdk/SDK/SDK_Export/device-tree_bsp_0/Makefile:

Code: Select all

# Makefile generated by Xilinx SDK.

-include libgen.options

LIBRARIES = ${PROCESSOR}/lib/libxil.a
MSS = system.mss

all: libs
	@echo 'Finished building libraries'

libs: $(LIBRARIES)

$(LIBRARIES): $(MSS)
	libgen -hw ${HWSPEC}\
	       ${REPOSITORIES}\
	       -pe ${PROCESSOR} \
	       -log libgen.log \
	       $(MSS)

clean:
	rm -rf ${PROCESSOR}
The compiled devicetree is part of the ecosystem, so if you booted your Red Pitaya with the standard ecosystem, linux already knows about the SPI bus on E2.
Loading another FPGA *.bin into /dev/xdevcfg will not change this.

Re: SPI

Posted: Fri Jan 16, 2015 1:51 pm
by rajat
Can be write data from arm processor and get the spi output on the pins....

Re: SPI

Posted: Fri Jan 16, 2015 7:24 pm
by Nils Roos
rajat wrote:Can be write data from arm processor and get the spi output on the pins....
???
I don't understand you.

Re: SPI

Posted: Fri Oct 25, 2019 7:51 pm
by dreaguns
I'm currently working on the same thing.
Is there a way to write code so that the SPI gets information as soon as the RP turns on?
I need the RP to communicate with an external device at turn on.

Re: SPI

Posted: Mon Oct 28, 2019 4:32 pm
by Petricshone
great thing