This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
products:sbc:edge-2l:applications:gpio:spi [2025/11/27 02:30] gray ↷ Page moved from local:users:start:applications:gpio:spi to local:users:gray:products:sbc:edge-2l:applications:gpio:spi |
products:sbc:edge-2l:applications:gpio:spi [2026/05/11 02:08] (current) nick ↷ Page moved from local:users:gray:products:sbc:edge-2l:applications:gpio:spi to products:sbc:edge-2l:applications:gpio:spi |
||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ====== Edge-2L SPI ====== | ====== Edge-2L SPI ====== | ||
| - | SPI interface can be founded | + | The Serial Peripheral Interface (SPI) is available |
| - | /* WHY this information was there ???? | ||
| - | <WRAP important > | ||
| - | For Edge-2L, in order to use the UART , you need to attach the IO extension board. | ||
| - | </ | ||
| - | */ | ||
| ===== Reference table ===== | ===== Reference table ===== | ||
| Line 20: | Line 15: | ||
| ===== Enable SPI ===== | ===== Enable SPI ===== | ||
| - | In order to use the SPI, you need to enable | + | To use the hardware |
| - | Edit ''/ | + | Edit the file ''/ |
| To enable '' | To enable '' | ||
| Line 29: | Line 24: | ||
| fdt_overlays=edge-2l-io-spi | fdt_overlays=edge-2l-io-spi | ||
| ``` | ``` | ||
| - | <WRAP important > | + | |
| - | As SPI pins are also can used for other function, | + | <WRAP important > |
| + | The SPI pins are multiplexed and can also be used for other functions (e.g., '' | ||
| </ | </ | ||
| - | After reboot, you will see the spi device node. | + | Reboot the system for the change to take effect. |
| ```shell | ```shell | ||
| $ ls / | $ ls / | ||
| Line 42: | Line 38: | ||
| ===== Disable SPI ===== | ===== Disable SPI ===== | ||
| - | If you want to use normal GPIO instead of SPI, you can remove the SPI node in [[products: | + | If you wish to use the SPI pins as standard GPIOs, remove the '' |
| - | + | ||
| - | + | ||
| - | ===== Demo Source Code ===== | + | |
| + | ===== Demo source code ===== | ||
| + | Below is a standard Linux spidev test program for SPI communication: | ||
| ```c spidev_test.c | ```c spidev_test.c | ||
| // SPDX-License-Identifier: | // SPDX-License-Identifier: | ||
| Line 529: | Line 524: | ||
| ``` | ``` | ||
| - | Compile test code: | + | Compile |
| ```shell | ```shell | ||
| Line 537: | Line 532: | ||
| ===== Test demonstration ===== | ===== Test demonstration ===== | ||
| - | Prepare input text file: | + | 1. Prepare |
| ```shell | ```shell | ||
| Line 543: | Line 538: | ||
| ``` | ``` | ||
| - | Connect PIN11, PIN12 then run '' | + | 2. Connect |
| + | Short PIN11 (MOSI) to PIN12 (MISO) to create a loopback for testing. | ||
| + | |||
| + | 3. Run the SPI test program: | ||
| ```shell | ```shell | ||
| $ ./ | $ ./ | ||
| + | ``` | ||
| + | Example output: | ||
| + | ```shell | ||
| spi mode: 0x0 | spi mode: 0x0 | ||
| bits per word: 8 | bits per word: 8 | ||
| Line 552: | Line 553: | ||
| ``` | ``` | ||
| - | Check output | + | 4. Verify the received |
| ```shell | ```shell | ||
| $ cat ./ | $ cat ./ | ||
| + | ``` | ||
| + | Output should be: | ||
| + | ``` | ||
| Amazing Khadas! | Amazing Khadas! | ||
| ``` | ``` | ||