Skip to content

Commit fdd5b18

Browse files
david-poirierdpgeorge
authored andcommitted
docs: Replace master/slave with controller/peripheral in I2C and SPI.
See https://www.oshwa.org/a-resolution-to-redefine-spi-signal-names
1 parent cbc8d5b commit fdd5b18

12 files changed

Lines changed: 86 additions & 86 deletions

File tree

docs/esp32/quickref.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ accessed via the :ref:`machine.SoftI2C <machine.SoftI2C>` class::
361361
i2c.writeto(0x3a, '12') # write '12' to device with address 0x3a
362362

363363
buf = bytearray(10) # create a buffer with 10 bytes
364-
i2c.writeto(0x3a, buf) # write the given buffer to the slave
364+
i2c.writeto(0x3a, buf) # write the given buffer to the peripheral
365365

366366
Hardware I2C bus
367367
----------------

docs/esp8266/quickref.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,11 @@ alias of :ref:`machine.SoftI2C <machine.SoftI2C>`)::
270270
# construct an I2C bus
271271
i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)
272272

273-
i2c.readfrom(0x3a, 4) # read 4 bytes from slave device with address 0x3a
274-
i2c.writeto(0x3a, '12') # write '12' to slave device with address 0x3a
273+
i2c.readfrom(0x3a, 4) # read 4 bytes from peripheral device with address 0x3a
274+
i2c.writeto(0x3a, '12') # write '12' to peripheral device with address 0x3a
275275

276276
buf = bytearray(10) # create a buffer with 10 bytes
277-
i2c.writeto(0x3a, buf) # write the given buffer to the slave
277+
i2c.writeto(0x3a, buf) # write the given buffer to the peripheral
278278

279279
Real time clock (RTC)
280280
---------------------

docs/library/machine.I2C.rst

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ Example usage::
2828
# depending on the port, extra parameters may be required
2929
# to select the peripheral and/or pins to use
3030

31-
i2c.scan() # scan for slaves, returning a list of 7-bit addresses
31+
i2c.scan() # scan for peripherals, returning a list of 7-bit addresses
3232

33-
i2c.writeto(42, b'123') # write 3 bytes to slave with 7-bit address 42
34-
i2c.readfrom(42, 4) # read 4 bytes from slave with 7-bit address 42
33+
i2c.writeto(42, b'123') # write 3 bytes to peripheral with 7-bit address 42
34+
i2c.readfrom(42, 4) # read 4 bytes from peripheral with 7-bit address 42
3535

36-
i2c.readfrom_mem(42, 8, 3) # read 3 bytes from memory of slave 42,
37-
# starting at memory-address 8 in the slave
38-
i2c.writeto_mem(42, 2, b'\x10') # write 1 byte to memory of slave 42
39-
# starting at address 2 in the slave
36+
i2c.readfrom_mem(42, 8, 3) # read 3 bytes from memory of peripheral 42,
37+
# starting at memory-address 8 in the peripheral
38+
i2c.writeto_mem(42, 2, b'\x10') # write 1 byte to memory of peripheral 42
39+
# starting at address 2 in the peripheral
4040

4141
Constructors
4242
------------
@@ -95,7 +95,7 @@ General Methods
9595
Primitive I2C operations
9696
------------------------
9797

98-
The following methods implement the primitive I2C master bus operations and can
98+
The following methods implement the primitive I2C controller bus operations and can
9999
be combined to make any I2C transaction. They are provided if you need more
100100
control over the bus, otherwise the standard methods (see below) can be used.
101101

@@ -115,7 +115,7 @@ These methods are only available on the `machine.SoftI2C` class.
115115
read is the length of *buf*. An ACK will be sent on the bus after
116116
receiving all but the last byte. After the last byte is received, if *nack*
117117
is true then a NACK will be sent, otherwise an ACK will be sent (and in this
118-
case the slave assumes more bytes are going to be read in a later call).
118+
case the peripheral assumes more bytes are going to be read in a later call).
119119

120120
.. method:: I2C.write(buf)
121121

@@ -126,34 +126,34 @@ These methods are only available on the `machine.SoftI2C` class.
126126
Standard bus operations
127127
-----------------------
128128

129-
The following methods implement the standard I2C master read and write
130-
operations that target a given slave device.
129+
The following methods implement the standard I2C controller read and write
130+
operations that target a given peripheral device.
131131

132132
.. method:: I2C.readfrom(addr, nbytes, stop=True, /)
133133

134-
Read *nbytes* from the slave specified by *addr*.
134+
Read *nbytes* from the peripheral specified by *addr*.
135135
If *stop* is true then a STOP condition is generated at the end of the transfer.
136136
Returns a `bytes` object with the data read.
137137

138138
.. method:: I2C.readfrom_into(addr, buf, stop=True, /)
139139

140-
Read into *buf* from the slave specified by *addr*.
140+
Read into *buf* from the peripheral specified by *addr*.
141141
The number of bytes read will be the length of *buf*.
142142
If *stop* is true then a STOP condition is generated at the end of the transfer.
143143

144144
The method returns ``None``.
145145

146146
.. method:: I2C.writeto(addr, buf, stop=True, /)
147147

148-
Write the bytes from *buf* to the slave specified by *addr*. If a
148+
Write the bytes from *buf* to the peripheral specified by *addr*. If a
149149
NACK is received following the write of a byte from *buf* then the
150150
remaining bytes are not sent. If *stop* is true then a STOP condition is
151151
generated at the end of the transfer, even if a NACK is received.
152152
The function returns the number of ACKs that were received.
153153

154154
.. method:: I2C.writevto(addr, vector, stop=True, /)
155155

156-
Write the bytes contained in *vector* to the slave specified by *addr*.
156+
Write the bytes contained in *vector* to the peripheral specified by *addr*.
157157
*vector* should be a tuple or list of objects with the buffer protocol.
158158
The *addr* is sent once and then the bytes from each object in *vector*
159159
are written out sequentially. The objects in *vector* may be zero bytes
@@ -170,19 +170,19 @@ Memory operations
170170

171171
Some I2C devices act as a memory device (or set of registers) that can be read
172172
from and written to. In this case there are two addresses associated with an
173-
I2C transaction: the slave address and the memory address. The following
173+
I2C transaction: the peripheral address and the memory address. The following
174174
methods are convenience functions to communicate with such devices.
175175

176176
.. method:: I2C.readfrom_mem(addr, memaddr, nbytes, *, addrsize=8)
177177

178-
Read *nbytes* from the slave specified by *addr* starting from the memory
178+
Read *nbytes* from the peripheral specified by *addr* starting from the memory
179179
address specified by *memaddr*.
180180
The argument *addrsize* specifies the address size in bits.
181181
Returns a `bytes` object with the data read.
182182

183183
.. method:: I2C.readfrom_mem_into(addr, memaddr, buf, *, addrsize=8)
184184

185-
Read into *buf* from the slave specified by *addr* starting from the
185+
Read into *buf* from the peripheral specified by *addr* starting from the
186186
memory address specified by *memaddr*. The number of bytes read is the
187187
length of *buf*.
188188
The argument *addrsize* specifies the address size in bits (on ESP8266
@@ -192,7 +192,7 @@ methods are convenience functions to communicate with such devices.
192192

193193
.. method:: I2C.writeto_mem(addr, memaddr, buf, *, addrsize=8)
194194

195-
Write *buf* to the slave specified by *addr* starting from the
195+
Write *buf* to the peripheral specified by *addr* starting from the
196196
memory address specified by *memaddr*.
197197
The argument *addrsize* specifies the address size in bits (on ESP8266
198198
this argument is not recognised and the address size is always 8 bits).

docs/library/machine.I2S.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class I2S -- Inter-IC Sound bus protocol
66

77
I2S is a synchronous serial protocol used to connect digital audio devices.
88
At the physical level, a bus consists of 3 lines: SCK, WS, SD.
9-
The I2S class supports Master operation. Slave operation is not supported.
9+
The I2S class supports controller operation. Peripheral operation is not supported.
1010

1111
The I2S class is currently available as a Technical Preview. During the preview period, feedback from
1212
users is encouraged. Based on this feedback, the I2S class API and implementation may be changed.

docs/library/machine.SPI.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
.. currentmodule:: machine
22
.. _machine.SPI:
33

4-
class SPI -- a Serial Peripheral Interface bus protocol (master side)
5-
=====================================================================
4+
class SPI -- a Serial Peripheral Interface bus protocol (controller side)
5+
=========================================================================
66

7-
SPI is a synchronous serial protocol that is driven by a master. At the
7+
SPI is a synchronous serial protocol that is driven by a controller. At the
88
physical level, a bus consists of 3 lines: SCK, MOSI, MISO. Multiple devices
99
can share the same bus. Each device should have a separate, 4th signal,
10-
SS (Slave Select), to select a particular device on a bus with which
11-
communication takes place. Management of an SS signal should happen in
10+
CS (Chip Select), to select a particular device on a bus with which
11+
communication takes place. Management of a CS signal should happen in
1212
user code (via machine.Pin class).
1313

1414
Both hardware and software SPI implementations exist via the
@@ -102,9 +102,9 @@ Methods
102102
Constants
103103
---------
104104

105-
.. data:: SPI.MASTER
105+
.. data:: SPI.CONTROLLER
106106

107-
for initialising the SPI bus to master; this is only used for the WiPy
107+
for initialising the SPI bus to controller; this is only used for the WiPy
108108

109109
.. data:: SPI.MSB
110110

docs/library/pyb.I2C.rst

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ Example::
1414

1515
from pyb import I2C
1616

17-
i2c = I2C(1) # create on bus 1
18-
i2c = I2C(1, I2C.MASTER) # create and init as a master
19-
i2c.init(I2C.MASTER, baudrate=20000) # init as a master
20-
i2c.init(I2C.SLAVE, addr=0x42) # init as a slave with given address
21-
i2c.deinit() # turn off the peripheral
17+
i2c = I2C(1) # create on bus 1
18+
i2c = I2C(1, I2C.CONTROLLER) # create and init as a controller
19+
i2c.init(I2C.CONTROLLER, baudrate=20000) # init as a controller
20+
i2c.init(I2C.PERIPHERAL, addr=0x42) # init as a peripheral with given address
21+
i2c.deinit() # turn off the I2C unit
2222

2323
Printing the i2c object gives you information about its configuration.
2424

@@ -37,21 +37,21 @@ You can specify a timeout (in ms)::
3737

3838
i2c.send(b'123', timeout=2000) # timeout after 2 seconds
3939

40-
A master must specify the recipient's address::
40+
A controller must specify the recipient's address::
4141

42-
i2c.init(I2C.MASTER)
43-
i2c.send('123', 0x42) # send 3 bytes to slave with address 0x42
42+
i2c.init(I2C.CONTROLLER)
43+
i2c.send('123', 0x42) # send 3 bytes to peripheral with address 0x42
4444
i2c.send(b'456', addr=0x42) # keyword for address
4545

4646
Master also has other methods::
4747

48-
i2c.is_ready(0x42) # check if slave 0x42 is ready
49-
i2c.scan() # scan for slaves on the bus, returning
48+
i2c.is_ready(0x42) # check if peripheral 0x42 is ready
49+
i2c.scan() # scan for peripherals on the bus, returning
5050
# a list of valid addresses
51-
i2c.mem_read(3, 0x42, 2) # read 3 bytes from memory of slave 0x42,
52-
# starting at address 2 in the slave
53-
i2c.mem_write('abc', 0x42, 2, timeout=1000) # write 'abc' (3 bytes) to memory of slave 0x42
54-
# starting at address 2 in the slave, timeout after 1 second
51+
i2c.mem_read(3, 0x42, 2) # read 3 bytes from memory of peripheral 0x42,
52+
# starting at address 2 in the peripheral
53+
i2c.mem_write('abc', 0x42, 2, timeout=1000) # write 'abc' (3 bytes) to memory of peripheral 0x42
54+
# starting at address 2 in the peripheral, timeout after 1 second
5555

5656
Constructors
5757
------------
@@ -88,17 +88,17 @@ Methods
8888

8989
Initialise the I2C bus with the given parameters:
9090

91-
- ``mode`` must be either ``I2C.MASTER`` or ``I2C.SLAVE``
92-
- ``addr`` is the 7-bit address (only sensible for a slave)
93-
- ``baudrate`` is the SCL clock rate (only sensible for a master)
91+
- ``mode`` must be either ``I2C.CONTROLLER`` or ``I2C.PERIPHERAL``
92+
- ``addr`` is the 7-bit address (only sensible for a peripheral)
93+
- ``baudrate`` is the SCL clock rate (only sensible for a controller)
9494
- ``gencall`` is whether to support general call mode
9595
- ``dma`` is whether to allow the use of DMA for the I2C transfers (note
9696
that DMA transfers have more precise timing but currently do not handle bus
9797
errors properly)
9898

9999
.. method:: I2C.is_ready(addr)
100100

101-
Check if an I2C device responds to the given address. Only valid when in master mode.
101+
Check if an I2C device responds to the given address. Only valid when in controller mode.
102102

103103
.. method:: I2C.mem_read(data, addr, memaddr, *, timeout=5000, addr_size=8)
104104

@@ -111,7 +111,7 @@ Methods
111111
- ``addr_size`` selects width of memaddr: 8 or 16 bits
112112

113113
Returns the read data.
114-
This is only valid in master mode.
114+
This is only valid in controller mode.
115115

116116
.. method:: I2C.mem_write(data, addr, memaddr, *, timeout=5000, addr_size=8)
117117

@@ -124,15 +124,15 @@ Methods
124124
- ``addr_size`` selects width of memaddr: 8 or 16 bits
125125

126126
Returns ``None``.
127-
This is only valid in master mode.
127+
This is only valid in controller mode.
128128

129129
.. method:: I2C.recv(recv, addr=0x00, *, timeout=5000)
130130

131131
Receive data on the bus:
132132

133133
- ``recv`` can be an integer, which is the number of bytes to receive,
134134
or a mutable buffer, which will be filled with received bytes
135-
- ``addr`` is the address to receive from (only required in master mode)
135+
- ``addr`` is the address to receive from (only required in controller mode)
136136
- ``timeout`` is the timeout in milliseconds to wait for the receive
137137

138138
Return value: if ``recv`` is an integer then a new buffer of the bytes received,
@@ -143,23 +143,23 @@ Methods
143143
Send data on the bus:
144144

145145
- ``send`` is the data to send (an integer to send, or a buffer object)
146-
- ``addr`` is the address to send to (only required in master mode)
146+
- ``addr`` is the address to send to (only required in controller mode)
147147
- ``timeout`` is the timeout in milliseconds to wait for the send
148148

149149
Return value: ``None``.
150150

151151
.. method:: I2C.scan()
152152

153153
Scan all I2C addresses from 0x01 to 0x7f and return a list of those that respond.
154-
Only valid when in master mode.
154+
Only valid when in controller mode.
155155

156156
Constants
157157
---------
158158

159-
.. data:: I2C.MASTER
159+
.. data:: I2C.CONTROLLER
160160

161-
for initialising the bus to master mode
161+
for initialising the bus to controller mode
162162

163-
.. data:: I2C.SLAVE
163+
.. data:: I2C.PERIPHERAL
164164

165-
for initialising the bus to slave mode
165+
for initialising the bus to peripheral mode

docs/library/pyb.SPI.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
.. currentmodule:: pyb
22
.. _pyb.SPI:
33

4-
class SPI -- a master-driven serial protocol
5-
============================================
4+
class SPI -- a controller-driven serial protocol
5+
================================================
66

7-
SPI is a serial protocol that is driven by a master. At the physical level
7+
SPI is a serial protocol that is driven by a controller. At the physical level
88
there are 3 lines: SCK, MOSI, MISO.
99

1010
See usage model of I2C; SPI is very similar. Main difference is
1111
parameters to init the SPI bus::
1212

1313
from pyb import SPI
14-
spi = SPI(1, SPI.MASTER, baudrate=600000, polarity=1, phase=0, crc=0x7)
14+
spi = SPI(1, SPI.CONTROLLER, baudrate=600000, polarity=1, phase=0, crc=0x7)
1515

16-
Only required parameter is mode, SPI.MASTER or SPI.SLAVE. Polarity can be
16+
Only required parameter is mode, SPI.CONTROLLER or SPI.PERIPHERAL. Polarity can be
1717
0 or 1, and is the level the idle clock line sits at. Phase can be 0 or 1
1818
to sample data on the first or second clock edge respectively. Crc can be
1919
None for no CRC, or a polynomial specifier.
@@ -55,8 +55,8 @@ Methods
5555

5656
Initialise the SPI bus with the given parameters:
5757

58-
- ``mode`` must be either ``SPI.MASTER`` or ``SPI.SLAVE``.
59-
- ``baudrate`` is the SCK clock rate (only sensible for a master).
58+
- ``mode`` must be either ``SPI.CONTROLLER`` or ``SPI.PERIPHERAL``.
59+
- ``baudrate`` is the SCK clock rate (only sensible for a controller).
6060
- ``prescaler`` is the prescaler to use to derive SCK from the APB bus frequency;
6161
use of ``prescaler`` overrides ``baudrate``.
6262
- ``polarity`` can be 0 or 1, and is the level the idle clock line sits at.
@@ -112,10 +112,10 @@ Methods
112112
Constants
113113
---------
114114

115-
.. data:: SPI.MASTER
116-
.. data:: SPI.SLAVE
115+
.. data:: SPI.CONTROLLER
116+
.. data:: SPI.PERIPHERAL
117117

118-
for initialising the SPI bus to master or slave mode
118+
for initialising the SPI bus to controller or peripheral mode
119119

120120
.. data:: SPI.LSB
121121
.. data:: SPI.MSB

docs/pyboard/quickref.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ See :ref:`pyb.SPI <pyb.SPI>`. ::
191191

192192
from pyb import SPI
193193

194-
spi = SPI(1, SPI.MASTER, baudrate=200000, polarity=1, phase=0)
194+
spi = SPI(1, SPI.CONTROLLER, baudrate=200000, polarity=1, phase=0)
195195
spi.send('hello')
196196
spi.recv(5) # receive 5 bytes on the bus
197197
spi.send_recv('hello') # send and receive 5 bytes
@@ -210,12 +210,12 @@ eg ``I2C(1)``. Software I2C is also available by explicitly specifying the
210210
i2c = I2C('X', freq=400000) # create hardware I2c object
211211
i2c = I2C(scl='X1', sda='X2', freq=100000) # create software I2C object
212212

213-
i2c.scan() # returns list of slave addresses
214-
i2c.writeto(0x42, 'hello') # write 5 bytes to slave with address 0x42
215-
i2c.readfrom(0x42, 5) # read 5 bytes from slave
213+
i2c.scan() # returns list of peripheral addresses
214+
i2c.writeto(0x42, 'hello') # write 5 bytes to peripheral with address 0x42
215+
i2c.readfrom(0x42, 5) # read 5 bytes from peripheral
216216

217-
i2c.readfrom_mem(0x42, 0x10, 2) # read 2 bytes from slave 0x42, slave memory 0x10
218-
i2c.writeto_mem(0x42, 0x10, 'xy') # write 2 bytes to slave 0x42, slave memory 0x10
217+
i2c.readfrom_mem(0x42, 0x10, 2) # read 2 bytes from peripheral 0x42, peripheral memory 0x10
218+
i2c.writeto_mem(0x42, 0x10, 'xy') # write 2 bytes to peripheral 0x42, peripheral memory 0x10
219219

220220
Note: for legacy I2C support see :ref:`pyb.I2C <pyb.I2C>`.
221221

docs/pyboard/tutorial/amp_skin.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ To set the volume, define the following function::
3030

3131
import pyb
3232
def volume(val):
33-
pyb.I2C(1, pyb.I2C.MASTER).mem_write(val, 46, 0)
33+
pyb.I2C(1, pyb.I2C.CONTROLLER).mem_write(val, 46, 0)
3434

3535
Then you can do::
3636

0 commit comments

Comments
 (0)