Skip to content

Commit

Permalink
Merge pull request #18 from MK16kawai/dev
Browse files Browse the repository at this point in the history
fixed spi docs
  • Loading branch information
Neutree authored Jun 17, 2024
2 parents 554a8ce + 4ff6109 commit 4e0becc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
12 changes: 11 additions & 1 deletion docs/doc/en/peripheral/spi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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))
Expand Down
12 changes: 11 additions & 1 deletion docs/doc/zh/peripheral/spi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 很简单:

Expand All @@ -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))
Expand Down
10 changes: 10 additions & 0 deletions examples/peripheral/spi/spi_loopback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 4e0becc

Please sign in to comment.