Telit EZ10-GPRS/-PCS
Product Description
80269ST10014a, Rev. 3 – 26/09/05
Reproduction forbidden without written authorization by Telit Communications S.p.A.
Page 54 of 74
All Rights reserved – Right of modification reserved
then you can create the new bus over the GPIO pins (for example over the pins GPIO3, GPIO4,
GPIO5 ) and then use SPI built-in module methods like in the following example:
SPIbus = SPI.new(3,4,5)
SPIbus.init(0,0)
res = SPIbus.send('test')
c = SPIbus.sendbyte(0x0d)
d = SPIbus.readbyte()
which sends 'test' followed by CR and receives data waiting for one second.
More details about SPI built-in module object methods are in the following paragraphs.
3.3.5.6.1 SPI.new(SCLK_pin, MOSI_pin, MISO_pin, <SS0>, <SS1>,…<SS7>)
Creates a new SPI bus object on the GPIO pins number corresponding.
Input parameter SCLK_pin, MOSI_pin and MISO_pin are Python bytes which are the GPIO pin
number where the SCLK (Serial CLocK), MOSI (Master Output Slave Input), MISO (Master Input
Slave Output) lines are mapped. The same is for the SS0 .. SS9 which are OPTIONAL Python
bytes which are the GPIO pin number where the corresponding Slave Select line is mapped. Up to
8 slave select lines can be defined (also none if only 1 slave is used).
Return value is the Python custom SPI bus object pointer which then shall be used to interface with
the SPI bus created.
Example:
bus3 = SPI.new(3,4,5)
bus4 = SPI.new(6,7,8,9,10)
This creates two SPI bus, one over the GPIO3, GPIO4, GPIO5 and one over the GPIO6, GPIO7,
GPIO8, GPIO9, GPIO10 where the GPIO9 is the Slave 0 select and GPIO10 is the Slave 1 select
pin.
Available pins for the SPI bus are GPIO3 - GPIO13, while GPIO1 and GPIO2 are not available
for SPI. SPI object method: init(CPOL, CPHA)
Does the first pin initialisation on the SPI bus previously created.
Bus clock polarity is controlled by CPOL value:
CPOL = 0 - clock polarity low
CPOL = 1 - clock polarity high
Bus clock phase transmission is controlled by CPHA value:
CPHA = 0 - data bit is clocked/latched on the first edge of the SCLK.
CPHA = 1 - data bit is clocked/latched on the second edge of the SCLK.
Return value is a Python integer which is -1 if an error occurred otherwise is 1.
Example:
a = bus3.init(0,0)
3.3.5.6.2 SPI object method: sendbyte(byte, <SS_number>)