Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:common:applications:gpio:spi

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
products:sbc:common:applications:gpio:spi [2022/12/02 01:03]
ivan
products:sbc:common:applications:gpio:spi [2023/11/07 05:07] (current)
nick [Enable SPI]
Line 1: Line 1:
-====== SPI ====== 
  
-SPI interface usage examples on [[products:sbc:common:applications:gpio:40pin-header|40-Pin Header]].+===== SPI Reference table =====
  
-<WRAP important > +|            SPI    ^ Pin  ^ Pin name     ^  GPIO name  ^  DT overlay node  ^  Device node     ^ 
-Because Edge2 IO GPIO header is different from other series. please click [[products:sbc:edge2:applications:gpio:40pin-header|16-pin Header]] . +^  VIM3/3L  |  SPI_B  |  15  | SPIB_SS      |  GPIOH_6    |  spi1             |  /dev/spidev1.1 
-</WRAP> +| :::       | :::      16  | SPIB_SCLK    |  GPIOH_7    | :::               | :::              | 
- +| :::       | :::      35  | SPIB_MISO    |  GPIOH_5    | :::               | :::              | 
-===== Reference table ===== +| :::       | :::      37  | SPIB_MOSI    |  GPIOH_4    | :::               | :::              | 
- +^  VIM4     |  SPI_A  |  25  |  SPI_A_SCLK  |  GPIOT_20   |  spi0             |  /dev/spidev1.0 
-|            SPI    ^ Pin ^ Pin name ^  GPIO name   GPIO num   DT overlay node  ^  Device node     ^ +| :::       | :::     |  26  |  SPI_A_SS0   |  GPIOT_21   | :::               | :::              | 
-^  VIM3/3L  |  SPI_B  |  15  |SPIB_SS    |  GPIOH_6   |  433         |  spi1              |  /dev/spidev1.1 +| :::       | :::      36  |  SPI_A_MOSI  |  GPIOT_18   | :::               | :::              | 
-| :::       | :::      16  |SPIB_SCLK  |  GPIOH_7   |  434         | :::                | :::              | +| :::       | :::     |  37   SPI_A_MISO  |  GPIOT_19   | :::               | :::              | 
-| :::       | :::      35  |SPIB_MISO  |  GPIOH_5   |  432         | :::                | :::              | + VIM1S    |  SPI_A  |  29  |  SPI_A_MOSI  |  GPIOZ_1    | :::               | :::              | 
-| :::       | :::      37  |SPIB_MOSI  |  GPIOH_4   |  431         | :::                | :::              | +| :::       | :::     |  31   SPI_A_CLK   |  GPIOZ_2    | :::               | :::              | 
-^  VIM4             |      |                      |              |                    |                  | +| :::       | :::      32  |  SPI_A_MISO  |  GPIOZ_0    | :::               | :::              | 
- Edge2    |  SPI1   |  11  |SPI1_MOSI  |  GPIO3_B7  |  111         |  spi1              |  /dev/spidev1.0 +| :::       | :::      33  |  SPI_A_SS0    GPIOZ_3    | :::               | :::              |
-| :::       | :::     |  12  |SPIB_MISO  |  GPIO3_C0  |  112         | :::                | :::              | +
-| :::       | :::     |  13  |SPIB_CSO   |  GPIO3_C1  |  113         | :::                | :::              | +
-| :::       | :::     |  14  |SPIB_CLK   |  GPIO3_C2  |  114         | :::                | :::              |+
  
 ===== Enable SPI ===== ===== Enable SPI =====
Line 46: Line 42:
 ``` ```
  
-<tabbox VIM4>+<tabbox VIM3 with 5.15 kernel>
  
-TODO.+Edit ''/boot/dtb/amlogic/kvim3.dtb.overlay.env'' to add spi node to ''fdt_overlays'' node if it doesn't exist.
  
  
-<tabbox Edge2> +e.gEnable ''SPI_B'', you need to add ''spi1'' to node ''fdt_overlays'' if it doesn't exist.
-Edit ''/boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlay.env'' to add the SPI node to ''overlays'' node if it doesn't exist.+
  
-To enable ''SPI1'', you need to add ''spi1'' node to ''overlays'' node if it doesn't exist.+```shell 
 +fdt_overlays=spi1 
 + 
 +``` 
 + 
 +After reboot, you will see the SPI device node. 
 + 
 +<tabbox VIM3L with 5.15 kernel> 
 + 
 +Edit ''/boot/dtb/amlogic/kvim3l.dtb.overlay.env'' to add spi node to ''fdt_overlays'' node if it doesn't exist. 
 + 
 + 
 +e.g. Enable ''SPI_B'', you need to add ''spi1'' to node ''fdt_overlays'' if it doesn't exist.
  
 ```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 ''uart7'' and ''pwm14''. 
-</WRAP> 
  
 +After reboot, you will see the SPI device node.
 +
 +<tabbox VIM4>
 +
 +Edit ''/boot/dtb/amlogic/kvim4.dtb.overlay.env'' to add spi node to ''fdt_overlays'' node if it doesn't exist.
 +
 +
 +e.g. Enable ''SPI_A'', you need to add ''spi0'' to node ''fdt_overlays'' if it doesn't exist.
 +
 +```shell
 +fdt_overlays=spi0
 +
 +```
 +
 +After reboot, you will see the SPI device node.
 +
 +```shell
 +$ ls /dev/spidev1.0 
 +/dev/spidev1.0
 +```
 +<tabbox VIM1S>
 +
 +Edit ''/boot/dtb/amlogic/kvim1s.dtb.overlay.env'' to add spi node to ''fdt_overlays'' node if it doesn't exist.
 +
 +
 +e.g. Enable ''SPI_A'', you need to add ''spi0'' to node ''fdt_overlays'' if it doesn't exist.
 +
 +```shell
 +fdt_overlays=spi0
 +
 +```
 +
 +After reboot, you will see the SPI device node.
  
-After reboot, you will see the spi device node. 
 ```shell ```shell
-$ ls /dev/spidev1.0+$ ls /dev/spidev1.0 
 /dev/spidev1.0 /dev/spidev1.0
 ``` ```
Line 112: Line 149:
 } }
  
-static const char *device = "/dev/spidev1.1";+static const char *device = "/dev/spidev1.0";
 static uint32_t mode; static uint32_t mode;
 static uint8_t bits = 8; static uint8_t bits = 8;
Line 575: Line 612:
 ``` ```
  
-Run ''spidev_test'':+Connect PIN36(MOSI), PIN37(MISO) then run ''spidev_test'':
  
 ```shell ```shell
Last modified: 2022/12/02 01:03 by ivan