HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
  • SC-3568HA

    • Introduction

      • SC-3568HA Overview
    • Quick Start Guide

      • OpenHarmony Overview
      • Image Flashing
      • Setting Up the Development Environment
      • Hello World Application and Deployment
    • Application Development

      • ArkUI

        • Chapter 1 Introduction to ArkTS Language
        • Chapter 2 Introduction to UI Components and Practical Applications (Part 1)
        • Chapter 3 Introduction to UI Components and Practical Applications (Part 2)
        • Chapter 4 Introduction to UI Components and Practical Applications (Part 3)
      • Expand

        • Chapter 1 Getting Started Guide
        • Chapter 2 Referencing and Using Third-Party Libraries
        • Chapter 3: Application Compilation and Deployment
        • Chapter 4: Command-Line Factory Reset
        • Chapter 5: System Debugging -- HDC (Huawei Device Connector) Debugging
        • Chapter 6 APP Stability Testing
        • Chapter 7 Application Testing
    • Device Development

      • Chapter 1 Environment Setup
      • Chapter 2 Download Source Code
      • Chapter 3 Compiling Source Code
    • Peripheral And Iinterface

      • Raspberry Pi interface
      • GPIO Interface
      • I2C Interface
      • SPI communication
      • PWM (Pulse Width Modulation) control
      • Serial port communication
      • TF Card
      • Display Screen
      • Touch
      • Audio
      • RTC
      • Ethernet
      • M.2
      • MINI-PCIE
      • Camera
      • WIFI&BT
      • Raspberry Pi expansion board
    • Frequently Asked Questions

      • Resource Downloads
  • M-K1HSE

    • Introduction

      • M-K1HSE Introduction
    • Quick Start

      • Development environment construction
      • Source code acquisition
      • Compilation Notes
      • Burning Guide
    • Peripherals and interfaces

      • 01 Audio
      • 02 RS485
      • 03 Display
    • System customization development

      • System transplant
      • System customization
      • Driver Development
      • System Debugging
      • OTA Update

SPI communication

1. SPI functional features

SPI (serial peripheral interface). The following are some features supported by the Linux 4.4 SPI driver:

  • The Motorola SPI protocol is adopted by default.
  • Supports 8-bit and 16-bit.
  • The software-programmable clock frequency and transmission rate can reach up to 50MHz.
  • Supports the configuration of 4 SPI transmission modes.
  • Each SPI controller supports one to two chip selects.
  • The framework supports both slave and master modes.

2. SPI pins

TOOL
SPIPINFunctions
MOSI19Master Output/Slave Input (MOSI)
MISO21Master Input/Slave Output (MISO)
CLOCK23Clock Signal Line
CS024Chip Select Signal Line 0

Warning

spidev3.0 controls CS0

3. Device Tree Source (DTS) configuration

Enable SPI in arch/arm64/boot/dts/rockchip/rk3568-toybrick-x0-linux.dts.

    &spi3 {
        status = "okay";
        pinctrl-0 = <&spi3m1_cs0  &spi3m1_pins>;
        pinctrl-1 = <&spi3m1_cs0  &spi3m1_pins_hs>;
        spidev:spidev@0 {
                compatible = "rockchip,spidev";
                reg = <0>;
                spi-max-frequency = <10000000>;
                status = "okay";
        };
    };

4. Check the SPI device

Enter the following commands in the board's terminal to check whether the SPI device is created

TOOL

5. SPI loopback test

Short-circuit the MOSI and MISO (it is recommended to use a jumper cap for short-circuiting to ensure data stability).

TOOL

Use the loopback test program available online to test whether the SPI is working properly.

When short-circuiting, the data is correct.

TOOL

When there is no short-circuiting, the data appears as garbled characters.

TOOL
Edit this page on GitHub
Last Updated:
Contributors: zsl, zwhuang
Prev
I2C Interface
Next
PWM (Pulse Width Modulation) control