<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
		<id>http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=MicroMV_SPI%E9%80%9A%E4%BF%A1</id>
		<title>MicroMV SPI通信 - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=MicroMV_SPI%E9%80%9A%E4%BF%A1"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=MicroMV_SPI%E9%80%9A%E4%BF%A1&amp;action=history"/>
		<updated>2026-05-05T11:40:02Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=MicroMV_SPI%E9%80%9A%E4%BF%A1&amp;diff=26822&amp;oldid=prev</id>
		<title>2018年12月7日 (五) 03:11 502748957@qq.com</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=MicroMV_SPI%E9%80%9A%E4%BF%A1&amp;diff=26822&amp;oldid=prev"/>
				<updated>2018-12-07T03:11:32Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;zh-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;2018年12月7日 (五) 03:11的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l183&quot; &gt;第183行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第183行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:更多SPI通讯参考：http://docs.openmv.io/library/pyb.SPI.html&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:更多SPI通讯参考：http://docs.openmv.io/library/pyb.SPI.html&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;MicroMV目录&lt;/del&gt;|返回MicroMV目录页面]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;MicroMV 简介&lt;/ins&gt;|返回MicroMV目录页面]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>502748957@qq.com</name></author>	</entry>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=MicroMV_SPI%E9%80%9A%E4%BF%A1&amp;diff=25624&amp;oldid=prev</id>
		<title>2018年5月15日 (二) 05:58 Radiumray9@gmail.com</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=MicroMV_SPI%E9%80%9A%E4%BF%A1&amp;diff=25624&amp;oldid=prev"/>
				<updated>2018-05-15T05:58:01Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;zh-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;2018年5月15日 (二) 05:58的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l12&quot; &gt;第12行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第12行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;from pyb import Pin, SPI&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;from pyb import Pin, SPI&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;cs &lt;del class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/del&gt;= Pin(&amp;quot;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;P3&lt;/del&gt;&amp;quot;, Pin.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;OUT_OD&lt;/del&gt;)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;cs = Pin(&amp;quot;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;P8&lt;/ins&gt;&amp;quot;, Pin.&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;OUT_PP&lt;/ins&gt;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;rst = Pin(&amp;quot;P7&amp;quot;, Pin&lt;/del&gt;.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;OUT_PP)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;cs&lt;/ins&gt;.&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;high&lt;/ins&gt;()&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;rs&amp;#160; = Pin&lt;/del&gt;(&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot;P8&amp;quot;, Pin.OUT_PP&lt;/del&gt;)&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# The hardware SPI bus for your OpenMV Cam is always SPI bus 2.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# The hardware SPI bus for your OpenMV Cam is always SPI bus 2.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;spi = SPI(2, SPI.MASTER, baudrate=int(1000000000/66), polarity=0, phase=0)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;spi = SPI(2, SPI.MASTER, baudrate=int(1000000000/66), polarity=0, phase=0)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Radiumray9@gmail.com</name></author>	</entry>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=MicroMV_SPI%E9%80%9A%E4%BF%A1&amp;diff=25623&amp;oldid=prev</id>
		<title>Radiumray9@gmail.com：创建页面，内容为“&lt;p style=&quot;font-size:135%&quot;&gt;'''MicroMV上的SPI通讯'''&lt;/p&gt;  *'''做为SPI主机''' :&lt;source lang=&quot;py&quot;&gt; # SPI Control # # This example shows how to use the SPI bus on…”</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=MicroMV_SPI%E9%80%9A%E4%BF%A1&amp;diff=25623&amp;oldid=prev"/>
				<updated>2018-05-15T05:55:35Z</updated>
		
		<summary type="html">&lt;p&gt;创建页面，内容为“&amp;lt;p style=&amp;quot;font-size:135%&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;MicroMV上的SPI通讯&amp;#039;&amp;#039;&amp;#039;&amp;lt;/p&amp;gt;  *&amp;#039;&amp;#039;&amp;#039;做为SPI主机&amp;#039;&amp;#039;&amp;#039; :&amp;lt;source lang=&amp;quot;py&amp;quot;&amp;gt; # SPI Control # # This example shows how to use the SPI bus on…”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;p style=&amp;quot;font-size:135%&amp;quot;&amp;gt;'''MicroMV上的SPI通讯'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*'''做为SPI主机'''&lt;br /&gt;
:&amp;lt;source lang=&amp;quot;py&amp;quot;&amp;gt;&lt;br /&gt;
# SPI Control&lt;br /&gt;
#&lt;br /&gt;
# This example shows how to use the SPI bus on your OpenMV Cam to directly&lt;br /&gt;
# the LCD shield without using the built-in lcd shield driver. You will need&lt;br /&gt;
# the LCD shield to run this example.&lt;br /&gt;
&lt;br /&gt;
import sensor, image, time&lt;br /&gt;
from pyb import Pin, SPI&lt;br /&gt;
&lt;br /&gt;
cs  = Pin(&amp;quot;P3&amp;quot;, Pin.OUT_OD)&lt;br /&gt;
rst = Pin(&amp;quot;P7&amp;quot;, Pin.OUT_PP)&lt;br /&gt;
rs  = Pin(&amp;quot;P8&amp;quot;, Pin.OUT_PP)&lt;br /&gt;
# The hardware SPI bus for your OpenMV Cam is always SPI bus 2.&lt;br /&gt;
spi = SPI(2, SPI.MASTER, baudrate=int(1000000000/66), polarity=0, phase=0)&lt;br /&gt;
&lt;br /&gt;
def write_command_byte(c):&lt;br /&gt;
    cs.low()&lt;br /&gt;
    rs.low()&lt;br /&gt;
    spi.send(c)&lt;br /&gt;
    cs.high()&lt;br /&gt;
&lt;br /&gt;
def write_data_byte(c):&lt;br /&gt;
    cs.low()&lt;br /&gt;
    rs.high()&lt;br /&gt;
    spi.send(c)&lt;br /&gt;
    cs.high()&lt;br /&gt;
&lt;br /&gt;
def write_command(c, *data):&lt;br /&gt;
    write_command_byte(c)&lt;br /&gt;
    if data:&lt;br /&gt;
        for d in data: write_data_byte(d)&lt;br /&gt;
&lt;br /&gt;
def write_image(img):&lt;br /&gt;
    cs.low()&lt;br /&gt;
    rs.high()&lt;br /&gt;
    spi.send(img)&lt;br /&gt;
    cs.high()&lt;br /&gt;
&lt;br /&gt;
# Reset the LCD.&lt;br /&gt;
rst.low()&lt;br /&gt;
time.sleep(100)&lt;br /&gt;
rst.high()&lt;br /&gt;
time.sleep(100)&lt;br /&gt;
&lt;br /&gt;
write_command(0x11) # Sleep Exit&lt;br /&gt;
time.sleep(120)&lt;br /&gt;
&lt;br /&gt;
# Memory Data Access Control&lt;br /&gt;
write_command(0x36, 0xC0)&lt;br /&gt;
&lt;br /&gt;
# Interface Pixel Format&lt;br /&gt;
write_command(0x3A, 0x05)&lt;br /&gt;
&lt;br /&gt;
# Display On&lt;br /&gt;
write_command(0x29)&lt;br /&gt;
&lt;br /&gt;
sensor.reset() # Initialize the camera sensor.&lt;br /&gt;
sensor.set_pixformat(sensor.RGB565) # must be this&lt;br /&gt;
sensor.set_framesize(sensor.QQVGA2) # must be this&lt;br /&gt;
sensor.skip_frames(time = 2000) # Let new settings take affect.&lt;br /&gt;
clock = time.clock() # Tracks FPS.&lt;br /&gt;
&lt;br /&gt;
while(True):&lt;br /&gt;
    clock.tick() # Track elapsed milliseconds between snapshots().&lt;br /&gt;
    img = sensor.snapshot() # Take a picture and return the image.&lt;br /&gt;
&lt;br /&gt;
    write_command(0x2C) # Write image command...&lt;br /&gt;
    write_image(img)&lt;br /&gt;
&lt;br /&gt;
    print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while&lt;br /&gt;
    # connected to your computer. The FPS should increase once disconnected.&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''做为SPI从机'''&lt;br /&gt;
:&amp;lt;source lang=&amp;quot;py&amp;quot;&amp;gt;&lt;br /&gt;
# SPI with the Arduino as the master device and the OpenMV Cam as the slave.&lt;br /&gt;
#&lt;br /&gt;
# Please wire up your OpenMV Cam to your Arduino like this:&lt;br /&gt;
#&lt;br /&gt;
# OpenMV Cam Master Out Slave In (P0) - Arduino Uno MOSI (11)&lt;br /&gt;
# OpenMV Cam Master In Slave Out (P1) - Arduino Uno MISO (12)&lt;br /&gt;
# OpenMV Cam Serial Clock        (P2) - Arduino Uno SCK  (13)&lt;br /&gt;
# OpenMV Cam Slave Select        (P3) - Arduino Uno SS   (10)&lt;br /&gt;
# OpenMV Cam Ground                   - Arduino Ground&lt;br /&gt;
&lt;br /&gt;
import pyb, ustruct&lt;br /&gt;
&lt;br /&gt;
text = &amp;quot;Hello World!\n&amp;quot;&lt;br /&gt;
data = ustruct.pack(&amp;quot;&amp;lt;bi%ds&amp;quot; % len(text), 85, len(text), text) # 85 is a sync char.&lt;br /&gt;
# Use &amp;quot;ustruct&amp;quot; to build data packets to send.&lt;br /&gt;
# &amp;quot;&amp;lt;&amp;quot; puts the data in the struct in little endian order.&lt;br /&gt;
# &amp;quot;b&amp;quot; puts a signed char in the data stream.&lt;br /&gt;
# &amp;quot;i&amp;quot; puts a signed integer in the data stream.&lt;br /&gt;
# &amp;quot;%ds&amp;quot; puts a string in the data stream. E.g. &amp;quot;13s&amp;quot; for &amp;quot;Hello World!\n&amp;quot; (13 chars).&lt;br /&gt;
# See https://docs.python.org/3/library/struct.html&lt;br /&gt;
&lt;br /&gt;
# Zero pad data to a multiple of 4 bytes plus 4 bytes.&lt;br /&gt;
data += &amp;quot;\x00&amp;quot; * (4 + (len(data) % 4))&lt;br /&gt;
&lt;br /&gt;
# READ ME!!!&lt;br /&gt;
#&lt;br /&gt;
# Please understand that when your OpenMV Cam is not the SPI master it may miss responding to&lt;br /&gt;
# sending data as a SPI slave no matter if you call &amp;quot;spi.send()&amp;quot; in an interrupt callback or in the&lt;br /&gt;
# main loop below. Because of this you must absolutely design your communications protocol such&lt;br /&gt;
# that if the slave device (the OpenMV Cam) doesn't call &amp;quot;spi.send()&amp;quot; in time that garbage data&lt;br /&gt;
# read from the SPI peripheral by the master (the Arduino) is tossed. To accomplish this we use a&lt;br /&gt;
# sync character of 85 (binary 01010101) which the Arduino will look for as the first byte read.&lt;br /&gt;
# If it doesn't see this then it aborts the SPI transaction and will try again. Second, in order to&lt;br /&gt;
# clear out the SPI peripheral state we always send a multiple of four bytes and an extra four zero&lt;br /&gt;
# bytes to make sure that the SPI peripheral doesn't hold any stale data which could be 85. Note&lt;br /&gt;
# that the OpenMV Cam will miss the &amp;quot;spi.send()&amp;quot; window randomly because it has to service&lt;br /&gt;
# interrupts. Interrupts will happen a lot more while connected to your PC.&lt;br /&gt;
&lt;br /&gt;
# The hardware SPI bus for your OpenMV Cam is always SPI bus 2.&lt;br /&gt;
# polarity = 0 -&amp;gt; clock is idle low.&lt;br /&gt;
# phase = 0 -&amp;gt; sample data on rising clock edge, output data on falling clock edge.&lt;br /&gt;
spi = pyb.SPI(2, pyb.SPI.SLAVE, polarity=0, phase=0)&lt;br /&gt;
pin = pyb.Pin(&amp;quot;P3&amp;quot;, pyb.Pin.IN, pull=pyb.Pin.PULL_UP)&lt;br /&gt;
print(&amp;quot;Waiting for Arduino...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Note that for sync up to work correctly the OpenMV Cam must be running this script before the&lt;br /&gt;
# Arduino starts to poll the OpenMV Cam for data. Otherwise the SPI byte framing gets messed up,&lt;br /&gt;
# and etc. So, keep the Arduino in reset until the OpenMV Cam is &amp;quot;Waiting for Arduino...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
while(True):&lt;br /&gt;
    while(pin.value()): pass&lt;br /&gt;
    try:&lt;br /&gt;
        spi.send(data, timeout=1000)&lt;br /&gt;
        # If we failed to sync up the first time we'll sync up the next time.&lt;br /&gt;
        print(&amp;quot;Sent Data!&amp;quot;) # Only reached on no error.&lt;br /&gt;
    except OSError as err:&lt;br /&gt;
        pass # Don't care about errors - so pass.&lt;br /&gt;
        # Note that there are 3 possible errors. A timeout error, a general purpose error, or&lt;br /&gt;
        # a busy error. The error codes are 116, 5, 16 respectively for &amp;quot;err.arg[0]&amp;quot;.&lt;br /&gt;
    while(not pin.value()): pass&lt;br /&gt;
&lt;br /&gt;
###################################################################################################&lt;br /&gt;
# Arduino Code&lt;br /&gt;
###################################################################################################&lt;br /&gt;
#&lt;br /&gt;
# #include &amp;lt;SPI.h&amp;gt;&lt;br /&gt;
# #define SS_PIN 10&lt;br /&gt;
# #define BAUD_RATE 19200&lt;br /&gt;
# #define CHAR_BUF 128&lt;br /&gt;
#&lt;br /&gt;
# void setup() {&lt;br /&gt;
#   pinMode(SS_PIN, OUTPUT);&lt;br /&gt;
#   Serial.begin(BAUD_RATE);&lt;br /&gt;
#   SPI.begin();&lt;br /&gt;
#   SPI.setBitOrder(MSBFIRST);&lt;br /&gt;
#   SPI.setClockDivider(SPI_CLOCK_DIV16);&lt;br /&gt;
#   SPI.setDataMode(SPI_MODE0);&lt;br /&gt;
#   delay(1000); // Give the OpenMV Cam time to bootup.&lt;br /&gt;
# }&lt;br /&gt;
#&lt;br /&gt;
# void loop() {&lt;br /&gt;
#   int32_t temp = 0;&lt;br /&gt;
#   char buff[CHAR_BUF] = {0};&lt;br /&gt;
#   digitalWrite(SS_PIN, LOW);&lt;br /&gt;
#   delay(1); // Give the OpenMV Cam some time to setup to send data.&lt;br /&gt;
#&lt;br /&gt;
#   if(SPI.transfer(1) == 85) { // saw sync char?&lt;br /&gt;
#     SPI.transfer(&amp;amp;temp, 4); // get length&lt;br /&gt;
#     int zero_legnth = 4 + ((temp + 1) % 4);&lt;br /&gt;
#     if (temp) {&lt;br /&gt;
#       SPI.transfer(&amp;amp;buff, min(temp, CHAR_BUF));&lt;br /&gt;
#       temp -= min(temp, CHAR_BUF);&lt;br /&gt;
#     }&lt;br /&gt;
#     while (temp--) SPI.transfer(0); // eat any remaining bytes&lt;br /&gt;
#     while (zero_legnth--) SPI.transfer(0); // eat zeros.&lt;br /&gt;
#   }&lt;br /&gt;
#&lt;br /&gt;
#   digitalWrite(SS_PIN, HIGH);&lt;br /&gt;
#   Serial.print(buff);&lt;br /&gt;
#   delay(1); // Don't loop to quickly.&lt;br /&gt;
# }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:更多SPI通讯参考：http://docs.openmv.io/library/pyb.SPI.html&lt;br /&gt;
&lt;br /&gt;
[[MicroMV目录|返回MicroMV目录页面]]&lt;/div&gt;</summary>
		<author><name>Radiumray9@gmail.com</name></author>	</entry>

	</feed>