This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
products:sbc:common:applications:gpio:spi [2022/12/01 21:20] ivan [Edge2] |
products:sbc:common:applications:gpio:spi [2025/02/17 21:40] (current) nick [Enable SPI] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== SPI ====== | ||
- | SPI interface usage examples on [[products: | + | ===== SPI Reference table ===== |
- | ===== Reference table ===== | + | | |
- | + | ^ VIM3/ | |
- | | | + | | ::: | ::: |
- | ^ VIM3/ | + | | ::: | ::: |
- | | ::: | ::: | + | | ::: | ::: |
- | | ::: | ::: | + | ^ VIM4 |
- | | ::: | ::: | + | | ::: | ::: |
- | ^ VIM4 | + | | ::: | ::: |
- | ^ Edge2 | SPI1 | | + | | ::: | ::: |
- | | ::: | ::: | + | ^ VIM1S |
- | | ::: | ::: | + | | ::: | ::: |
- | | ::: | ::: | + | | ::: | ::: |
+ | | ::: | ::: | ||
===== Enable SPI ===== | ===== Enable SPI ===== | ||
Line 42: | Line 42: | ||
``` | ``` | ||
- | < | + | < |
- | TODO. | + | Edit ''/ |
- | <tabbox Edge2> | + | e.g. Enable |
- | Edit ''/ | + | |
- | To enable | + | ```shell |
+ | fdt_overlays=spi1 | ||
+ | ``` | ||
+ | |||
+ | After reboot, you will see the SPI device node. | ||
+ | |||
+ | ```shell | ||
+ | $ ls / | ||
+ | / | ||
+ | ``` | ||
+ | |||
+ | <tabbox VIM3L with 5.15 kernel> | ||
+ | |||
+ | Edit '' | ||
+ | |||
+ | |||
+ | e.g. Enable '' | ||
```shell | ```shell | ||
fdt_overlays=spi1 | fdt_overlays=spi1 | ||
+ | |||
``` | ``` | ||
- | <WRAP important > | ||
- | As SPI pins are also used for other function, e.g. UART7, PWM14, so that you also need to remove node '' | ||
- | </ | ||
+ | After reboot, you will see the SPI device node. | ||
- | After reboot, you will see the spi device node. | ||
```shell | ```shell | ||
- | $ ls /dev/spidev1.1 | + | $ ls /dev/spidev2.1 |
- | /dev/spidev1.1 | + | /dev/spidev2.1 |
+ | ``` | ||
+ | |||
+ | <tabbox VIM4> | ||
+ | |||
+ | Edit ''/ | ||
+ | |||
+ | |||
+ | e.g. Enable '' | ||
+ | |||
+ | ```shell | ||
+ | fdt_overlays=spi0 | ||
+ | |||
+ | ``` | ||
+ | |||
+ | After reboot, you will see the SPI device node. | ||
+ | |||
+ | ```shell | ||
+ | $ ls / | ||
+ | / | ||
+ | ``` | ||
+ | <tabbox VIM1S> | ||
+ | |||
+ | Edit ''/ | ||
+ | |||
+ | |||
+ | e.g. Enable '' | ||
+ | |||
+ | ```shell | ||
+ | fdt_overlays=spi0 | ||
+ | |||
+ | ``` | ||
+ | |||
+ | After reboot, you will see the SPI device node. | ||
+ | |||
+ | ```shell | ||
+ | $ ls / | ||
+ | / | ||
``` | ``` | ||
Line 108: | Line 158: | ||
} | } | ||
- | static const char *device = "/ | + | static const char *device = "/ |
static uint32_t mode; | static uint32_t mode; | ||
static uint8_t bits = 8; | static uint8_t bits = 8; | ||
Line 571: | Line 621: | ||
``` | ``` | ||
- | Run '' | + | Connect PIN36(MOSI), |
+ | |||
```shell | ```shell | ||
- | $ ./ | + | $ ./ |
spi mode: 0x0 | spi mode: 0x0 | ||
bits per word: 8 | bits per word: 8 | ||
max speed: 500000 Hz (500 KHz) | max speed: 500000 Hz (500 KHz) | ||
``` | ``` | ||
+ | |||
+ | <WRAP important > | ||
+ | Please choose the correct spi device node. | ||
+ | </ | ||
+ | |||
Check output data: | Check output data: |