beautypg.com

Rainbow Electronics GM862-GPS User Manual

Page 52

background image





Easy Script

in Python

80000ST10020a Rev.8 - 01/10/08

Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved

page 52 of 100

The SS_pin is optional because not all SPI devices have a Slave Select line, otherwise named Chip
Select (CS) line.

Return value is the Python custom SPI object pointer that will be used further to interface with this
specific SPI object created.

Example:

mySPIobject = SPI.new(6, 7, 8, 9, 10)

Creates an SPI object “mySPIobject” where SCLK=GPIO6, MOSI=GPIO7, MISO=GPIO8 and
SS0=GPIO9, SS1=GPIO10

NOTE: available pins for the SPI bus are GPIO1 - GPIO13. The only exception is the module family
GM862 where available pins are GPIO3 - GPIO13.

2.9.2 SPI object method: init (CPOL, CPHA, , )


This command performs the initialization on the SPI bus previously created, and can be reused as
many time as necessary if some of its parameters need changes during work.
First input parameter CPOL represents clock polarity and is controlled in the following way:

CPOL = 0 - clock polarity low

CPOL = 1 - clock polarity high

Second input parameter CPHA represents clock phase transmission and is controlled in the following
way:

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.


The combinations of polarity and phases are often referred to as SPI modes.

Third parameter SSPOL is optional and represents the Slave Select Polarity and can assume the
following values:

SSPOL = 0 - polarity low (default)

SSPOL = 1 - polarity high


Fourth parameter SS is optional and represents the Default Slave Select line number to use among
the already defined slave select (SS) lines for this SPI object and then it can assume values from 0 to
7.

SS = unused - means that if not SS settled in readwrite() parameter’s function, no SS will be

moved.

SS = 0…7 – Defined the default SS line to move if not SS settled in readwrite() parameter’s

function.


Return value is a Python integer, which is -1 if an error occurred, otherwise is 1.