From 4ff610950acbd4f33db60f23d79e6568b63219c6 Mon Sep 17 00:00:00 2001 From: Mk16kawai <1041324852hzq@sina.com> Date: Mon, 17 Jun 2024 11:48:44 +0800 Subject: [PATCH] fixed spi docs --- docs/doc/en/peripheral/spi.md | 12 +++++++++++- docs/doc/zh/peripheral/spi.md | 12 +++++++++++- examples/peripheral/spi/spi_loopback.py | 10 ++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/docs/doc/en/peripheral/spi.md b/docs/doc/en/peripheral/spi.md index 32d39ead..b349aeeb 100644 --- a/docs/doc/en/peripheral/spi.md +++ b/docs/doc/en/peripheral/spi.md @@ -57,7 +57,7 @@ This is the pinout of MaixCAM. You need to use `maix.peripheral.pinmap` to complete the pin mapping for SPI before use. -**Note: The MaixCAM's SPI can only be used as an SPI master device. MaixCAM's SPI does not support modifying the valid level of the hardware CS pins at this time. The active level of all SPI hardware CS is high. If you need to use other CS active levels, configure the software CS pins and their active levels in the SPI API. SPI4 is the software simulated SPI, the measured maximum rate is 1.25MHz, and the usage is the same as hardware SPI.** +**Note: The MaixCAM's SPI can only be used as an SPI master device. MaixCAM's SPI does not support modifying the valid level of the hardware CS pins at this time. The active level of all SPI hardware CS is low. If you need to use other CS active levels, configure the software CS pins and their active levels in the SPI API. SPI4 is the software simulated SPI, the measured maximum rate is 1.25MHz, and the usage is the same as hardware SPI.** Using SPI with MaixPy is easy: @@ -79,6 +79,16 @@ for pin, func in pin_function.items(): spidev = spi.SPI(4, spi.Mode.MASTER, 1250000) +### Example of full parameter passing. +# spidev = spi.SPI(id=4, # SPI ID +# mode=spi.Mode.MASTER, # SPI mode +# freq=1250000, # SPI speed +# polarity=0, # CPOL 0/1, default is 0 +# phase=0, # CPHA 0/1, default is 0 +# bits=8, # Bits of SPI, default is 8 +# cs_enable=True, # Use soft CS pin? True/False, default is False +# cs='GPIOA19') # Soft cs pin number, default is 'GPIOA19' + b = bytes(range(0, 8)) res = spidev.write_read(b, len(b)) diff --git a/docs/doc/zh/peripheral/spi.md b/docs/doc/zh/peripheral/spi.md index 771eaa6c..2c11c49f 100644 --- a/docs/doc/zh/peripheral/spi.md +++ b/docs/doc/zh/peripheral/spi.md @@ -59,7 +59,7 @@ MaixCAM 的引脚分布如下: 使用前需要 `maix.peripheral.pinmap` 完成对 SPI 的管脚映射。 -**注意:MaixCAM 由于其 SPI 外设的限制,只能作为 SPI 主设备使用。MaixCAM 的 SPI 暂时不支持修改硬件 CS 引脚有效电平,所有 SPI 硬件 CS 的有效电平为高电平。如需要使用其他的 CS 有效电平,请在 SPI API 中配置软件 CS 引脚及其有效电平。SPI4 为软件模拟的 SPI,实测最大速率为 1.25MHz,使用方法与硬件 SPI 无异。** +**注意:MaixCAM 由于其 SPI 外设的限制,只能作为 SPI 主设备使用。MaixCAM 的 SPI 暂时不支持修改硬件 CS 引脚有效电平,所有 SPI 硬件 CS 的有效电平为低电平。如需要使用其他的 CS 有效电平,请在 SPI API 中配置软件 CS 引脚及其有效电平。SPI4 为软件模拟的 SPI,实测最大速率为 1.25MHz,使用方法与硬件 SPI 无异。** 通过 MaixPy 使用 SPI 很简单: @@ -81,6 +81,16 @@ for pin, func in pin_function.items(): spidev = spi.SPI(4, spi.Mode.MASTER, 1250000) +### Example of full parameter passing. +# spidev = spi.SPI(id=4, # SPI ID +# mode=spi.Mode.MASTER, # SPI mode +# freq=1250000, # SPI speed +# polarity=0, # CPOL 0/1, default is 0 +# phase=0, # CPHA 0/1, default is 0 +# bits=8, # Bits of SPI, default is 8 +# cs_enable=True, # Use soft CS pin? True/False, default is False +# cs='GPIOA19') # Soft cs pin number, default is 'GPIOA19' + b = bytes(range(0, 8)) res = spidev.write_read(b, len(b)) diff --git a/examples/peripheral/spi/spi_loopback.py b/examples/peripheral/spi/spi_loopback.py index 88b639eb..3e5d7088 100755 --- a/examples/peripheral/spi/spi_loopback.py +++ b/examples/peripheral/spi/spi_loopback.py @@ -15,6 +15,16 @@ spidev = spi.SPI(4, spi.Mode.MASTER, 1250000) +### Example of full parameter passing. +# spidev = spi.SPI(id=4, # SPI ID +# mode=spi.Mode.MASTER, # SPI mode +# freq=1250000, # SPI speed +# polarity=0, # CPOL 0/1, default is 0 +# phase=0, # CPHA 0/1, default is 0 +# bits=8, # Bits of SPI, default is 8 +# cs_enable=True, # Use soft CS pin? True/False, default is False +# cs='GPIOA19') # Soft cs pin number, default is 'GPIOA19' + b = bytes(range(0, 8)) res = spidev.write_read(b, len(b))