This is the highest level module import for the RPiSoC API, which the user should import into their scripts for full use of it. It is used to keep records of some globally used variables between all classes.
It is also used to send data to, and receive data from the RPiSoC using a user chosen communication protocol.
At the beginning of each script, insert the following two lines:
from rpisoc import * #This will handle dependencies
RPiSoC('SPI') #for SPI
#or RPiSoC('I2C')
#or RPiSoC('USB') or RPiSoC ('SERIAL') for USB UART
Class: | This class is used to define the register locations of each component on the RPiSoC, it defines which communication protocol will be utilized by the API, and it collects compiled data from the RPiSoC. The class is not to be assigned to an object; it only needs to be called so that addresses can be defined, compiled data on the RPiSoC can be verified, and so that the communication protocol can be initialized. Optionally, one can construct the object with a DEBUG parameter, as described in the __new__() description, which will print diagnostic information to the terminal. |
---|
Method | __new__ |
---|---|
Description |
|
Parameters |
|
Optional Parameters |
|
protocol | USB, SPI, or I2C |
baud | baud rate for use use with the SERIAL protocol. Any standard baud rate supported |
DEBUG |
|
Returns | No return |
Class: | Provides a serial (USB UART) interface for communicating with the RPiSoC |
---|---|
Note: | pyserial 2.7 must be available to use this class |
Method | __init__ |
---|---|
Description |
|
Optional Parameters | int baudr |
baudr |
|
Returns | No return |
Method | PrepareData |
---|---|
Description | Makes sure that the data being sent is correctly formatted, so that the RPiSoC is able to more easily decode the received words |
Parameters | tuple dat |
dat |
|
Returns | list dat_l |
dat_l |
|
Method | cleanup |
---|---|
Description | Forces a software reset on the RPiSoC and then closes and cleans up the serial port |
Parameters | None |
Returns | No return |
Method | disconnect |
---|---|
Description | Forces a clean disconnection from the RPiSoC |
Parameters | None |
Returns | No return |
Method | isConnected |
---|---|
Description | Checks to see if the serial port is open, and that it is connected to an RPiSoC |
Parameters | None |
Returns | bool status* |
status |
|
Method | receiveData |
---|---|
Description | Called when a returned value is desired from the RPiSoC. It will send a command, and then wait for a response |
Parameters | tuple vals |
vals | A tuple which will be sent to PrepareData() to be restructured into a list of length 4, and then sent to the RPiSoC over serial |
Returns | int dat |
dat |
|
Raises |
Method | reconnect |
---|---|
Description | Used to reestablish a connection to the RPiSoC after it has been lost |
Parameters | None |
Returns | bool status |
status |
|
Method | sendData |
---|---|
Description | Sends data to the RPiSoC, without waiting for a return |
Parameters | tuple vals |
val | A tuple which will be sent to PrepareData() to be restructured into a list of length 4, and then sent to the RPiSoC over serial |
Returns | No return |
Raises |
Class: | This class defines usage of the SPI bus for transfer between the RPi and the PSoC. __init__ is called as soon as an RPiSoC object is defined, and it opens and configures the SPI bus. |
---|---|
Note: | The spidev libraries with its python wrapper must be installed to use this class |
Method | __init__ |
---|---|
Description | Constructs and initializes an SPI object |
Parameters | None |
Returns | No return |
Method | PrepareData |
---|---|
Description | Makes sure that the data being sent is correctly formatted, so that the RPiSoC is able to more easily decode the received words |
Parameters | tuple dat |
dat |
|
Returns | list dat_l |
dat_l |
|
Method | cleanup |
---|---|
Description | Forces a software reset on the RPiSoC and then closes and cleans up the SPI bus |
Parameters | None |
Returns | No return |
Method | receiveData |
---|---|
Description | Called when the RPi desires a returned value from the RPiSoC. It will send a command, and then wait for a response |
Parameters |
|
Optional Parameters |
|
vals | A tuple which will be sent to PrepareData() to be restructured into a list of length 4, and then sent to the RPiSoC over SPI |
delay |
|
Returns | int dat |
dat |
|
Method | sendData |
---|---|
Description | Sends data to the RPiSoC, without waiting for a return |
Parameters | tuple vals |
val | A tuple which will be sent to PrepareData() to be restructured into a list of length 4, and then sent to the RPiSoC over SPI |
Returns | No return |
Class: | This class defines usage of the I2C bus for transfer between the RPi and the PSoC. __init__ is called as soon as an RPiSoC object is defined, and it opens and configures the bus. |
---|---|
Note: | i2c must be configured and the smbus libraries must be installed to call this class |
Method | __init__ |
---|---|
Description | Constructs and initializes an I2C object |
Optional Parameters |
|
bus_location |
|
bus_location |
|
Returns | No return |
Method | PrepareData |
---|---|
Description | Makes sure that the data being sent is correctly formatted, so that the RPiSoC is able to more easily decode the received words |
Parameters | tuple dat |
dat |
|
Returns | list dat_l |
dat_l |
|
Method | cleanup |
---|---|
Description | Forces a software reset on the RPiSoC and then closes and cleans up the I2C bus |
Parameters | None |
Returns | No return |
Method | receiveData |
---|---|
Description | Called when the RPi desires a returned value from the RPiSoC. It will send a command, and then wait for a response |
Parameters |
|
Optional Parameters |
|
vals | A tuple which will be sent to PrepareData() to be restructured into a list of length 4, and then sent to the RPiSoC over I2C |
delay |
|
Returns | int dat |
dat |
|
Method | sendData |
---|---|
Description | Sends data to the RPiSoC, without waiting for a return |
Parameters | tuple vals |
val | A tuple which will be sent to PrepareData() to be restructured into a list of length 4, and then sent to the RPiSoC over I2C |
Returns | No return |