Documente Academic
Documente Profesional
Documente Cultură
This is written for A20-OLinuXino-MICRO, but it can be used with other boards. If
you do
this we cannot guarantee proper operation of the module. Before using this
package we recommend reading the article at olimex wiki:
https://www.olimex.com/wiki/A20-OLinuXino-MICRO
When using GPIO make sure that the desired gpio is not used by another periphery.
GPIO METHODS
============
NAME - EQUALS TO
==== =========
HIGH -> 1
LOW -> 0
INPUT -> 0
OUPTUT -> 1
PULLUP -> 1
PULLDOWN -> 2
By connector name and pin number: gpio2p12, gpio3p8, lcdp18, uext1p3 and etc.
These can be imported from connector module:
Generally these constants are just an offset in the memory from the base GPIO
address, so they can
be assigned to a number type variable.
I2C METHODS
===========
init() - Make initialization of the module
open() - Begin communication with slave device
read() - Read from slave device
write() - Write data to slave device
close() - End communication with slave device
SPI METHODS
===========
Examples
========
GPIO::
#!/usr/bin/env python
while True:
if gpio.input(port.PE11) == 1:
gpio.output(port.PG9, gpio.LOW)
gpio.output(port.PG9, 0)
else:
gpio.output(port.PG9, gpio.HIGH)
gpio.output(port.PG9, 1)
I2C::
#!/usr/bin/env python
SPI::
#!/usr/bin/env python
spi.open("/dev/spidev2.0")
#Open SPI device with default settings
# mode : 0
# speed : 100000kHz
# delay : 0
# bits-per-word: 8