I am working on a custom PCBA and attempting to figure out how to read a defined value from the CPLD from Linux. I have an SPI bus connected between an AM335x processor and a MAX V CPLD, wherein the following is defined within the CPLD:
version : STD_LOGIC_VECTOR := x"0100"); --data width in bits
COMPONENT spi_slave
GENERIC ( cpol : STD_LOGIC := '0'; cpha : STD_LOGIC := '1'; d_width : INTEGER := 16 );
PORT
(
data : IN STD_LOGIC_VECTOR(d_width-1 DOWNTO 0);
sclk : IN STD_LOGIC;
ss_n : IN STD_LOGIC;
mosi : IN STD_LOGIC;
miso : OUT STD_LOGIC
);
END COMPONENT;
And the following is the configuration in the device tree:
spi@481a0000 {
compatible = "ti, omap4-mcspi;
#address-cells = <0x1>;
#size-cells = <0x0>;
reg = <0x481a0000 0x400>;
interrupts = <0x7d>;
ti, spi-num-cs = <0x2>;
ti, hwmods = "spi1";
dmas = <0x2c 0x2a 0x0 0x2c 0x2b 0x0 0x2c 0x2c 0x0 0x2c 0x2d 0x0>;
dma-names = "tx0", "rx0", "tx1", "rx1";
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <0x3c>;
ti,pindir-d0-out-d1-in;
cpld_spidev@0 {
status = "okay";
compatible = "linux,spidev";
spi-max-frequency = <0xf4240>;
reg = <0x0>;
};
};
I have been able to send messages to spidev0.0, but most of what I have been getting back is garbage. How do I get 0x0100 back from the SPI slave?
question from:
https://stackoverflow.com/questions/65848327/how-to-read-std-logic-vector-from-spi-bus 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…