IMX8M Mini EVK,How does spi work in slave mode

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

IMX8M Mini EVK,How does spi work in slave mode

2,430件の閲覧回数
Joshua2
Contributor II

We need to use the spi1 port to communicate with peripherals and configure it in slave mode. How to configure it in slave mode?

ラベル(1)
0 件の賞賛
返信
3 返答(返信)

2,425件の閲覧回数
igorpadykov
NXP Employee
NXP Employee

Hi Joshua

 

one can try guidelines below as i.MX8M Mini has the same ecspi module :

https://www.digi.com/resources/documentation/digidocs/90001547/reference/bsp/v4-1_6ul/r_spi_v4-1.htm...

 

Best regards
igor

0 件の賞賛
返信

2,385件の閲覧回数
Joshua2
Contributor II

Hi igor,

Thank you for your reply!
I tried but failed. Please help to check what went wrong.
1) dts modification
pinctrl_spi1: spi1 {
fsl,pins = <
MX8MM_IOMUXC_ECSPI1_SCLK_ECSPI1_SCLK 0x1d0
MX8MM_IOMUXC_ECSPI1_MOSI_ECSPI1_MOSI 0x1d0
MX8MM_IOMUXC_ECSPI1_MISO_ECSPI1_MISO 0x1d0
MX8MM_IOMUXC_ECSPI1_SS0_GPIO5_IO9 0x1d0
>;
};
&ecspi1 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_spi1>;
spi-slave;

/*
* Unique slave node. Property'compatible' must be set to the
* slave driver that will be registered by default.
*/
slave@0 {
reg = <0>; /* must match the used CS line */
compatible = "spidev";
spi-max-frequency = <1000000>;
};
};
2) echo spidev >/sys/class/spi_slave/spi0/slave, you can find the spidev0.0 device.
3) Run spidev_test
root@okmx8mm:/usr/bin/cmd# spidev_test /dev/spidev0.0
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)
transfer size 1
4) The master starts to send data, and the oscilloscope can capture the waveform and send it normally. But the slave cannot receive it.

The attachment is the file modified by DTS.

 

Thanks,

Joshua

0 件の賞賛
返信

2,383件の閲覧回数
Joshua2
Contributor II

Hi igor,

Thank you for your answer!

I tried it but it didn't work, and the slave did not receive the data. The following is my modification, please help analyze the error.

Linux kernel version: Linux version 4.14.78

:1) dts modification

/***********************************************/

pinctrl_spi1: spi1 {
fsl,pins = <
MX8MM_IOMUXC_ECSPI1_SCLK_ECSPI1_SCLK 0x1d0
MX8MM_IOMUXC_ECSPI1_MOSI_ECSPI1_MOSI 0x1d0
MX8MM_IOMUXC_ECSPI1_MISO_ECSPI1_MISO 0x1d0
MX8MM_IOMUXC_ECSPI1_SS0_GPIO5_IO9 0x1d0
/*
MX8MM_IOMUXC_SPDIF_TX_GPIO5_IO3 0x159
*/
>;

&ecspi1 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_spi1>;
spi-slave;

/*
* Unique slave node. Property 'compatible' must be set to the
* slave driver that will be registered by default.
*/
slave@0 {
reg = <0>; /* must match the used CS line */
compatible = "spidev";
spi-max-frequency = <1000000>;
};
};

/***********************************************/

2) echo spidev > /sys/class/spi_slave/spi0/slave, the device of /dev/spidev0.0 can be found.

3)Run the spidev_test test program 

root@okmx8mm:/usr/bin/cmd# spidev_test /dev/spidev0.0
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)
transfer size 1

4)The master starts to send data, but the slave does not receive any data.

The attachment is the dts file.

 

Thanks,

Joshua

タグ(1)
0 件の賞賛
返信