This commit is contained in:
joan 2015-08-30 09:40:42 +01:00
parent 3fcc9b8d69
commit c1a2a9000a
12 changed files with 525 additions and 207 deletions

View File

@ -24,26 +24,32 @@ clean:
rm -f *.o *.i *.s *~ $(ALL)
install: $(LIB)
sudo install -m 0755 -d /usr/local/include
sudo install -m 0644 pigpio.h /usr/local/include
sudo install -m 0644 pigpiod_if.h /usr/local/include
sudo install -m 0755 -d /usr/local/lib
sudo install -m 0644 libpigpiod_if.so /usr/local/lib
sudo install -m 0755 -d /usr/local/bin
sudo install -m 0755 pigs /usr/local/bin
sudo python2 setup.py install
sudo python3 setup.py install
sudo install -m 0755 -d /usr/local/man/man1
sudo install -m 0644 *.1 /usr/local/man/man1
sudo install -m 0755 -d /usr/local/man/man3
sudo install -m 0644 *.3 /usr/local/man/man3
install -m 0755 -d /usr/local/include
install -m 0644 pigpio.h /usr/local/include
install -m 0644 pigpiod_if.h /usr/local/include
install -m 0755 -d /usr/local/lib
install -m 0644 libpigpiod_if.so /usr/local/lib
install -m 0755 -d /usr/local/bin
install -m 0755 pigs /usr/local/bin
python2 setup.py install
python3 setup.py install
install -m 0755 -d /usr/local/man/man1
install -m 0644 *.1 /usr/local/man/man1
install -m 0755 -d /usr/local/man/man3
install -m 0644 *.3 /usr/local/man/man3
uninstall:
sudo rm -f /usr/local/include/pigpio.h
sudo rm -f /usr/local/lib/libpigpiod_if.so
sudo rm -f /usr/local/bin/pigs
sudo rm -f /usr/local/man/man1/pig*.1
sudo rm -f /usr/local/man/man3/pig*.3
rm -f /usr/local/include/pigpio.h
rm -f /usr/local/lib/libpigpiod_if.so
echo removing python2 files
python2 setup.py install --record /tmp/pigpio >/dev/null
xargs rm -f < /tmp/pigpio >/dev/null
echo removing python3 files
python3 setup.py install --record /tmp/pigpio >/dev/null
xargs rm -f < /tmp/pigpio >/dev/null
rm -f /usr/local/bin/pigs
rm -f /usr/local/man/man1/pig*.1
rm -f /usr/local/man/man3/pig*.3
LIB = libpigpiod_if.so
OBJ = pigpiod_if.o command.o

View File

@ -52,42 +52,42 @@ clean:
rm -f *.o *.i *.s *~ $(ALL)
install: $(ALL)
sudo install -m 0755 -d /opt/pigpio/cgi
sudo install -m 0755 -d /usr/local/include
sudo install -m 0644 pigpio.h /usr/local/include
sudo install -m 0644 pigpiod_if.h /usr/local/include
sudo install -m 0755 -d /usr/local/lib
sudo install -m 0755 libpigpio.so /usr/local/lib
sudo install -m 0755 libpigpiod_if.so /usr/local/lib
sudo install -m 0755 -d /usr/local/bin
sudo install -m 0755 -s pig2vcd /usr/local/bin
sudo install -m 0755 -s pigpiod /usr/local/bin
sudo install -m 0755 -s pigs /usr/local/bin
sudo python2 setup.py install
sudo python3 setup.py install
sudo install -m 0755 -d /usr/local/man/man1
sudo install -m 0644 *.1 /usr/local/man/man1
sudo install -m 0755 -d /usr/local/man/man3
sudo install -m 0644 *.3 /usr/local/man/man3
sudo ldconfig
install -m 0755 -d /opt/pigpio/cgi
install -m 0755 -d /usr/local/include
install -m 0644 pigpio.h /usr/local/include
install -m 0644 pigpiod_if.h /usr/local/include
install -m 0755 -d /usr/local/lib
install -m 0755 libpigpio.so /usr/local/lib
install -m 0755 libpigpiod_if.so /usr/local/lib
install -m 0755 -d /usr/local/bin
install -m 0755 -s pig2vcd /usr/local/bin
install -m 0755 -s pigpiod /usr/local/bin
install -m 0755 -s pigs /usr/local/bin
python2 setup.py install
python3 setup.py install
install -m 0755 -d /usr/local/man/man1
install -m 0644 *.1 /usr/local/man/man1
install -m 0755 -d /usr/local/man/man3
install -m 0644 *.3 /usr/local/man/man3
ldconfig
uninstall:
sudo rm -f /usr/local/include/pigpio.h
sudo rm -f /usr/local/include/pigpiod_if.h
sudo rm -f /usr/local/lib/libpigpio.so
sudo rm -f /usr/local/lib/libpigpiod_if.so
sudo rm -f /usr/local/bin/pig2vcd
sudo rm -f /usr/local/bin/pigpiod
sudo rm -f /usr/local/bin/pigs
rm -f /usr/local/include/pigpio.h
rm -f /usr/local/include/pigpiod_if.h
rm -f /usr/local/lib/libpigpio.so
rm -f /usr/local/lib/libpigpiod_if.so
rm -f /usr/local/bin/pig2vcd
rm -f /usr/local/bin/pigpiod
rm -f /usr/local/bin/pigs
echo removing python2 files
sudo python2 setup.py install --record /tmp/pigpio >/dev/null
sudo xargs rm -f < /tmp/pigpio >/dev/null
python2 setup.py install --record /tmp/pigpio >/dev/null
xargs rm -f < /tmp/pigpio >/dev/null
echo removing python3 files
sudo python3 setup.py install --record /tmp/pigpio >/dev/null
sudo xargs rm -f < /tmp/pigpio >/dev/null
sudo rm -f /usr/local/man/man1/pig*.1
sudo rm -f /usr/local/man/man3/pig*.3
sudo ldconfig
python3 setup.py install --record /tmp/pigpio >/dev/null
xargs rm -f < /tmp/pigpio >/dev/null
rm -f /usr/local/man/man1/pig*.1
rm -f /usr/local/man/man3/pig*.3
ldconfig
$(LIB1): $(OBJ1)
$(SHLIB) -o $(LIB1) $(OBJ1)

View File

@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
*/
/*
This version is for pigpio version 35+
This version is for pigpio version 37+
*/
#include <stdio.h>
@ -468,8 +468,7 @@ static errInfo_t errInfo[]=
{PI_CHAIN_NESTING , "chain counters nested too deeply"},
{PI_CHAIN_TOO_BIG , "chain is too long"},
{PI_DEPRECATED , "deprecated function removed"},
{PI_NOT_IN_SER_MODE , "gpio not opened for bit-bang serial"},
{PI_BAD_SER_INVERT , "bit-bang serial invert not 0 or 1"},
{PI_BAD_SER_INVERT , "bit bang serial invert not 0 or 1"},
};

View File

@ -1295,24 +1295,30 @@ typedef struct
.br
.br
seqno starts at 0 each time the handle is opened and then increments
seqno: starts at 0 each time the handle is opened and then increments
by one for each report.
.br
.br
flags, if bit 5 is set then bits 0-4 of the flags indicate a gpio
which has had a watchdog timeout.
flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
If bit 5 is set (PI_NTFY_FLAGS_WDOG) then bits 0-4 of the flags
indicate a gpio which has had a watchdog timeout; if bit 6 is set
(PI_NTFY_FLAGS_ALIVE) this indicates a keep alive signal on the
pipe/socket and is sent once a minute in the absence of other
notification activity.
.br
.br
tick is the number of microseconds since system boot.
tick: the number of microseconds since system boot. It wraps around
after 1h12m.
.br
.br
level indicates the level of each gpio.
level: indicates the level of each gpio. If bit 1<<x is set then
gpio x is high.
.br
@ -2135,6 +2141,40 @@ The serial data is returned in a cyclic buffer and is read using
It is the caller's responsibility to read data from the cyclic buffer
in a timely fashion.
.IP "\fBint gpioSerialReadInvert(unsigned user_gpio, unsigned invert)\fP"
.IP "" 4
This function configures the level logic for bit bang serial reads.
.br
.br
Pass PI_BB_SER_INVERT to invert the serial logic. Pass PI_BB_SER_NORMAL for
normal logic. Default is PI_BB_SER_NORMAL.
.br
.br
.EX
user_gpio: 0-31
.br
invert: 0-1
.br
.EE
.br
.br
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_GPIO_IN_USE,
PI_NOT_SERIAL_GPIO, or PI_BAD_SER_INVERT.
.br
.br
The gpio must be opened for bit bang reading of serial data using
\fBgpioSerialReadOpen\fP prior to calling this function.
.IP "\fBint gpioSerialRead(unsigned user_gpio, void *buf, size_t bufSize)\fP"
.IP "" 4
This function copies up to bufSize bytes of data read from the
@ -2175,26 +2215,6 @@ For \fBdata_bits\fP 9-16 there will be two bytes per character.
.br
For \fBdata_bits\fP 17-32 there will be four bytes per character.
.IP "\fBint gpioSerialReadInvert(unsigned user_gpio, unsigned invert)\fP"
.IP "" 4
This function inverts the serial logic for bit bang reading of serial data.
.br
.br
.EX
user_gpio: 0-31, previously opened with \fBgpioSerialReadOpen\fP.
invert: 0-1, 1 invert , 0 normal.
.br
.EE
.br
.br
Returns 0 if OK, otherwise PI_NOT_IN_SER_MODE or PI_BAD_SER_INVERT.
.IP "\fBint gpioSerialReadClose(unsigned user_gpio)\fP"
.IP "" 4
This function closes a gpio for bit bang reading of serial data.
@ -6163,6 +6183,13 @@ A whole number, negative or positive.
.br
.IP "\fBinvert\fP" 0
A flag used to set normal or inverted bit bang serial data level logic.
.br
.br
.IP "\fBlevel\fP" 0
The level of a gpio. Low or High.
@ -7589,9 +7616,7 @@ A 16-bit word value.
.br
#define PI_DEPRECATED -120 // deprecated function removed
.br
#define PI_NOT_IN_SER_MODE -121 // gpio not opened for bit-bang serial
.br
#define PI_BAD_SER_INVERT -122 // bit-bang serial invert not 0 or 1
#define PI_BAD_SER_INVERT -121 // bit bang serial invert not 0 or 1
.br
.br

View File

@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
*/
/* pigpio version 35 */
/* pigpio version 37 */
/* include ------------------------------------------------------- */
@ -9338,12 +9338,12 @@ int gpioSerialReadInvert(unsigned gpio, unsigned invert)
SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
if (wfRx[gpio].mode != PI_WFRX_SERIAL)
SOFT_ERROR(PI_NOT_IN_SER_MODE, "gpio %d is not in serial mode", gpio);
SOFT_ERROR(PI_NOT_SERIAL_GPIO, "no serial read on gpio (%d)", gpio);
if ((invert < PI_BB_SER_NORMAL) ||
(invert > PI_BB_SER_INVERT))
SOFT_ERROR(PI_BAD_SER_INVERT,
"gpio %d, invert (%d)", gpio, invert);
"bad invert level for gpio %d (%d)", gpio, invert);
wfRx[gpio].s.invert = invert;

View File

@ -31,7 +31,7 @@ For more information, please refer to <http://unlicense.org/>
#include <stdint.h>
#include <pthread.h>
#define PIGPIO_VERSION 36
#define PIGPIO_VERSION 37
/*TEXT
@ -1317,15 +1317,21 @@ typedef struct
} gpioReport_t;
. .
seqno starts at 0 each time the handle is opened and then increments
seqno: starts at 0 each time the handle is opened and then increments
by one for each report.
flags, if bit 5 is set then bits 0-4 of the flags indicate a gpio
which has had a watchdog timeout.
flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
If bit 5 is set (PI_NTFY_FLAGS_WDOG) then bits 0-4 of the flags
indicate a gpio which has had a watchdog timeout; if bit 6 is set
(PI_NTFY_FLAGS_ALIVE) this indicates a keep alive signal on the
pipe/socket and is sent once a minute in the absence of other
notification activity.
tick is the number of microseconds since system boot.
tick: the number of microseconds since system boot. It wraps around
after 1h12m.
level indicates the level of each gpio.
level: indicates the level of each gpio. If bit 1<<x is set then
gpio x is high.
...
// Start notifications for gpios 1, 4, 6, 7, 10.
@ -1828,7 +1834,7 @@ D*/
/*F*/
int gpioSerialReadInvert(unsigned user_gpio, unsigned invert);
/*D
This function configures the level logci for bit bang serial reads.
This function configures the level logic for bit bang serial reads.
Pass PI_BB_SER_INVERT to invert the serial logic. Pass PI_BB_SER_NORMAL for
normal logic. Default is PI_BB_SER_NORMAL.
@ -1839,7 +1845,7 @@ invert: 0-1
. .
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_GPIO_IN_USE,
PI_NOT_IN_SER_MODE, or PI_BAD_SER_INVERT.
PI_NOT_SERIAL_GPIO, or PI_BAD_SER_INVERT.
The gpio must be opened for bit bang reading of serial data using
[*gpioSerialReadOpen*] prior to calling this function.
@ -4103,6 +4109,9 @@ The number of bytes of data in a buffer.
int::
A whole number, negative or positive.
invert::
A flag used to set normal or inverted bit bang serial data level logic.
level::
The level of a gpio. Low or High.
@ -4792,8 +4801,7 @@ after this command is issued.
#define PI_CHAIN_NESTING -118 // chain counters nested too deeply
#define PI_CHAIN_TOO_BIG -119 // chain is too long
#define PI_DEPRECATED -120 // deprecated function removed
#define PI_NOT_IN_SER_MODE -121 // gpio not opened for bit-bang serial
#define PI_BAD_SER_INVERT -122 // bit-bang serial invert not 0 or 1
#define PI_BAD_SER_INVERT -121 // bit bang serial invert not 0 or 1
#define PI_PIGIF_ERR_0 -2000
#define PI_PIGIF_ERR_99 -2099

147
pigpio.py
View File

@ -264,7 +264,7 @@ import threading
import os
import atexit
VERSION = "1.20"
VERSION = "1.21"
exceptions = True
@ -558,8 +558,7 @@ PI_BAD_CHAIN_DELAY =-117
PI_CHAIN_NESTING =-118
PI_CHAIN_TOO_BIG =-119
PI_DEPRECATED =-120
PI_NOT_IN_SER_MODE =-121
PI_BAD_SER_INVERT =-122
PI_BAD_SER_INVERT =-121
# pigpio error text
@ -682,8 +681,7 @@ _errors=[
[PI_CHAIN_NESTING , "chain counters nested too deeply"],
[PI_CHAIN_TOO_BIG , "chain is too long"],
[PI_DEPRECATED , "deprecated function removed"],
[PI_NOT_IN_SER_MODE , "gpio not opened for bit-bang serial"],
[PI_BAD_SER_INVERT , "bit-bang serial invert not 0 or 1"],
[PI_BAD_SER_INVERT , "bit bang serial invert not 0 or 1"],
]
@ -1316,13 +1314,28 @@ class pi():
Notifications have the following structure.
. .
I seqno - increments for each report
I flags - flags, if bit 5 is set then bits 0-4 of the flags
indicate a gpio which has had a watchdog timeout.
I tick - time of sample.
I level - 32 bits of levels for gpios 0-31.
I seqno
I flags
I tick
I level
. .
seqno: starts at 0 each time the handle is opened and then
increments by one for each report.
flags: two flags are defined, PI_NTFY_FLAGS_WDOG and
PI_NTFY_FLAGS_ALIVE. If bit 5 is set (PI_NTFY_FLAGS_WDOG)
then bits 0-4 of the flags indicate a gpio which has had a
watchdog timeout; if bit 6 is set (PI_NTFY_FLAGS_ALIVE) this
indicates a keep alive signal on the pipe/socket and is sent
once a minute in the absence of other notification activity.
tick: the number of microseconds since system boot. It wraps
around after 1h12m.
level: indicates the level of each gpio. If bit 1<<x is set
then gpio x is high.
...
h = pi.notify_open()
if h >= 0:
@ -2143,6 +2156,23 @@ class pi():
you will always run on the local Pi use the standard SMBus
module instead.
For the SMBus commands the low level transactions are shown
at the end of the function description. The following
abbreviations are used.
. .
S (1 bit) : Start bit
P (1 bit) : Stop bit
Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
A, NA (1 bit) : Accept and not accept bit.
Addr (7 bits): I2C 7 bit address.
Comm (8 bits): Command byte, which often selects a register.
Data (8 bits): A data byte.
Count (8 bits): A byte containing the length of a block operation.
[..]: Data sent by the device.
. .
...
h = pi.i2c_open(1, 0x53) # open device at address 0x53 on bus 1
...
@ -2172,11 +2202,14 @@ class pi():
"""
Sends a single bit to the device associated with handle.
SMBus 2.0 5.5.1 - Quick command.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
bit:= 0 or 1, the value to write.
SMBus 2.0 5.5.1 - Quick command.
. .
S Addr Rd/Wr [A] P
. .
...
pi.i2c_write_quick(0, 1) # send 1 to device 0
pi.i2c_write_quick(3, 0) # send 0 to device 3
@ -2188,11 +2221,14 @@ class pi():
"""
Sends a single byte to the device associated with handle.
SMBus 2.0 5.5.2 - Send byte.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
byte_val:= 0-255, the value to write.
SMBus 2.0 5.5.2 - Send byte.
. .
S Addr Wr [A] Data [A] P
. .
...
pi.i2c_write_byte(1, 17) # send byte 17 to device 1
pi.i2c_write_byte(2, 0x23) # send byte 0x23 to device 2
@ -2205,10 +2241,13 @@ class pi():
"""
Reads a single byte from the device associated with handle.
SMBus 2.0 5.5.3 - Receive byte.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
SMBus 2.0 5.5.3 - Receive byte.
. .
S Addr Rd [A] [Data] NA P
. .
...
b = pi.i2c_read_byte(2) # read a byte from device 2
...
@ -2220,12 +2259,15 @@ class pi():
Writes a single byte to the specified register of the device
associated with handle.
SMBus 2.0 5.5.4 - Write byte.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
byte_val:= 0-255, the value to write.
SMBus 2.0 5.5.4 - Write byte.
. .
S Addr Wr [A] Comm [A] Data [A] P
. .
...
# send byte 0xC5 to reg 2 of device 1
pi.i2c_write_byte_data(1, 2, 0xC5)
@ -2248,12 +2290,15 @@ class pi():
Writes a single 16 bit word to the specified register of the
device associated with handle.
SMBus 2.0 5.5.4 - Write word.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
word_val:= 0-65535, the value to write.
SMBus 2.0 5.5.4 - Write word.
. .
S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P
. .
...
# send word 0xA0C5 to reg 5 of device 4
pi.i2c_write_word_data(4, 5, 0xA0C5)
@ -2276,11 +2321,14 @@ class pi():
Reads a single byte from the specified register of the device
associated with handle.
SMBus 2.0 5.5.5 - Read byte.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
SMBus 2.0 5.5.5 - Read byte.
. .
S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
. .
...
# read byte from reg 17 of device 2
b = pi.i2c_read_byte_data(2, 17)
@ -2296,11 +2344,14 @@ class pi():
Reads a single 16 bit word from the specified register of the
device associated with handle.
SMBus 2.0 5.5.5 - Read word.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
SMBus 2.0 5.5.5 - Read word.
. .
S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
. .
...
# read word from reg 2 of device 3
w = pi.i2c_read_word_data(3, 2)
@ -2316,12 +2367,16 @@ class pi():
Writes 16 bits of data to the specified register of the device
associated with handle and reads 16 bits of data in return.
SMBus 2.0 5.5.6 - Process call.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
word_val:= 0-65535, the value to write.
SMBus 2.0 5.5.6 - Process call.
. .
S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]
S Addr Rd [A] [DataLow] A [DataHigh] NA P
. .
...
r = pi.i2c_process_call(h, 4, 0x1231)
r = pi.i2c_process_call(h, 6, 0)
@ -2341,12 +2396,16 @@ class pi():
Writes up to 32 bytes to the specified register of the device
associated with handle.
SMBus 2.0 5.5.7 - Block write.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
data:= the bytes to write.
SMBus 2.0 5.5.7 - Block write.
. .
S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A]
Data [A] P
. .
...
pi.i2c_write_block_data(4, 5, b'hello')
@ -2373,11 +2432,15 @@ class pi():
Reads a block of up to 32 bytes from the specified register of
the device associated with handle.
SMBus 2.0 5.5.7 - Block read.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
SMBus 2.0 5.5.7 - Block read.
. .
S Addr Wr [A] Comm [A]
S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
. .
The amount of returned data is set by the device.
The returned value is a tuple of the number of bytes read and a
@ -2408,8 +2471,6 @@ class pi():
associated with handle and reads a device specified number
of bytes of data in return.
SMBus 2.0 5.5.8 - Block write-block read.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
data:= the bytes to write.
@ -2418,6 +2479,12 @@ class pi():
be sent and a minimum of 1 byte may be received. The total
number of bytes sent/received must be 32 or less.
SMBus 2.0 5.5.8 - Block write-block read.
. .
S Addr Wr [A] Comm [A] Count [A] Data [A] ...
S Addr Rd [A] [Count] A [Data] ... A P
. .
The returned value is a tuple of the number of bytes read and a
bytearray containing the bytes. If there was an error the
number of bytes read will be less than zero (and will contain
@ -2458,6 +2525,11 @@ class pi():
reg:= >=0, the device register.
data:= the bytes to write.
. .
S Addr Wr [A] Comm [A]
S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
. .
...
pi.i2c_write_i2c_block_data(4, 5, 'hello')
@ -2488,6 +2560,10 @@ class pi():
reg:= >=0, the device register.
count:= >0, the number of bytes to read.
. .
S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
. .
The returned value is a tuple of the number of bytes read and a
bytearray containing the bytes. If there was an error the
number of bytes read will be less than zero (and will contain
@ -3738,8 +3814,7 @@ def xref():
PI_CHAIN_NESTING = -118
PI_CHAIN_TOO_BIG = -119
PI_DEPRECATED = -120
PI_NOT_IN_SER_MODE =-121
PI_BAD_SER_INVERT =-122
PI_BAD_SER_INVERT = -121
. .
frequency: 0-40000
@ -3809,6 +3884,10 @@ def xref():
i2c_flags: 32 bit
No I2C flags are currently defined.
invert: 0-1
A flag used to set normal or inverted bit bang serial data
level logic.
level: 0-1 (2)
CLEAR = 0
HIGH = 1

View File

@ -2189,7 +2189,7 @@ Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SERIAL_GPIO.
.IP "\fBint bb_serial_invert(unsigned user_gpio, unsigned invert)\fP"
.IP "" 4
This function inverts the serial logic for bit bang reading of serial data.
This function inverts serial logic for big bang serial reads.
.br
@ -2197,7 +2197,8 @@ This function inverts the serial logic for bit bang reading of serial data.
.EX
user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP.
invert: 0-1, 1 invert , 0 normal.
.br
invert: 0-1, 1 invert, 0 normal.
.br
.EE
@ -2205,7 +2206,7 @@ user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP.
.br
.br
Returns 0 if OK, otherwise PI_NOT_IN_SER_MODE or PI_BAD_SER_INVERT.
Returns 0 if OK, otherwise PI_NOT_SERIAL_GPIO or PI_BAD_SER_INVERT.
.IP "\fBint i2c_open(unsigned i2c_bus, unsigned i2c_addr, unsigned i2c_flags)\fP"
.IP "" 4
@ -2236,6 +2237,42 @@ No flags are currently defined. This parameter should be set to zero.
Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR,
PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED.
.br
.br
For the SMBus commands the low level transactions are shown at the end
of the function description. The following abbreviations are used.
.br
.br
.EX
S (1 bit) : Start bit
.br
P (1 bit) : Stop bit
.br
Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
.br
A, NA (1 bit) : Accept and not accept bit.
.br
.br
.br
Addr (7 bits): I2C 7 bit address.
.br
Comm (8 bits): Command byte, a data byte which often selects a register.
.br
Data (8 bits): A data byte.
.br
Count (8 bits): A data byte containing the length of a block operation.
.br
.br
[..]: Data sent by the device.
.br
.EE
.IP "\fBint i2c_close(unsigned handle)\fP"
.IP "" 4
This closes the I2C device associated with the handle.
@ -2281,7 +2318,13 @@ PI_I2C_WRITE_FAILED.
.br
.br
Quick command. smbus 2.0 5.5.1
Quick command. SMBus 2.0 5.5.1
.EX
S Addr Rd/Wr [A] P
.br
.EE
.IP "\fBint i2c_write_byte(unsigned handle, unsigned bVal)\fP"
.IP "" 4
@ -2308,7 +2351,13 @@ PI_I2C_WRITE_FAILED.
.br
.br
Send byte. smbus 2.0 5.5.2
Send byte. SMBus 2.0 5.5.2
.EX
S Addr Wr [A] Data [A] P
.br
.EE
.IP "\fBint i2c_read_byte(unsigned handle)\fP"
.IP "" 4
@ -2333,7 +2382,13 @@ or PI_I2C_READ_FAILED.
.br
.br
Receive byte. smbus 2.0 5.5.3
Receive byte. SMBus 2.0 5.5.3
.EX
S Addr Rd [A] [Data] NA P
.br
.EE
.IP "\fBint i2c_write_byte_data(unsigned handle, unsigned i2c_reg, unsigned bVal)\fP"
.IP "" 4
@ -2363,7 +2418,13 @@ PI_I2C_WRITE_FAILED.
.br
.br
Write byte. smbus 2.0 5.5.4
Write byte. SMBus 2.0 5.5.4
.EX
S Addr Wr [A] Comm [A] Data [A] P
.br
.EE
.IP "\fBint i2c_write_word_data(unsigned handle, unsigned i2c_reg, unsigned wVal)\fP"
.IP "" 4
@ -2393,7 +2454,13 @@ PI_I2C_WRITE_FAILED.
.br
.br
Write word. smbus 2.0 5.5.4
Write word. SMBus 2.0 5.5.4
.EX
S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P
.br
.EE
.IP "\fBint i2c_read_byte_data(unsigned handle, unsigned i2c_reg)\fP"
.IP "" 4
@ -2421,7 +2488,13 @@ PI_BAD_PARAM, or PI_I2C_READ_FAILED.
.br
.br
Read byte. smbus 2.0 5.5.5
Read byte. SMBus 2.0 5.5.5
.EX
S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
.br
.EE
.IP "\fBint i2c_read_word_data(unsigned handle, unsigned i2c_reg)\fP"
.IP "" 4
@ -2449,7 +2522,13 @@ PI_BAD_PARAM, or PI_I2C_READ_FAILED.
.br
.br
Read word. smbus 2.0 5.5.5
Read word. SMBus 2.0 5.5.5
.EX
S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
.br
.EE
.IP "\fBint i2c_process_call(unsigned handle, unsigned i2c_reg, unsigned wVal)\fP"
.IP "" 4
@ -2479,7 +2558,15 @@ PI_BAD_PARAM, or PI_I2C_READ_FAILED.
.br
.br
Process call. smbus 2.0 5.5.6
Process call. SMBus 2.0 5.5.6
.EX
S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]
.br
S Addr Rd [A] [DataLow] A [DataHigh] NA P
.br
.EE
.IP "\fBint i2c_write_block_data(unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP"
.IP "" 4
@ -2511,7 +2598,13 @@ PI_I2C_WRITE_FAILED.
.br
.br
Block write. smbus 2.0 5.5.7
Block write. SMBus 2.0 5.5.7
.EX
S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P
.br
.EE
.IP "\fBint i2c_read_block_data(unsigned handle, unsigned i2c_reg, char *buf)\fP"
.IP "" 4
@ -2546,7 +2639,15 @@ PI_BAD_PARAM, or PI_I2C_READ_FAILED.
.br
.br
Block read. smbus 2.0 5.5.7
Block read. SMBus 2.0 5.5.7
.EX
S Addr Wr [A] Comm [A]
.br
S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
.br
.EE
.IP "\fBint i2c_block_process_call(unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP"
.IP "" 4
@ -2590,7 +2691,15 @@ bytes sent/received must be 32 or less.
.br
.br
Block write-block read. smbus 2.0 5.5.8
Block write-block read. SMBus 2.0 5.5.8
.EX
S Addr Wr [A] Comm [A] Count [A] Data [A] ...
.br
S Addr Rd [A] [Count] A [Data] ... A P
.br
.EE
.IP "\fBint i2c_read_i2c_block_data(unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP"
.IP "" 4
@ -2619,6 +2728,18 @@ i2c_reg: 0-255, the register to read.
Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE,
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
.br
.br
.EX
S Addr Wr [A] Comm [A]
.br
S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
.br
.EE
.IP "\fBint i2c_write_i2c_block_data(unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP"
.IP "" 4
This writes 1 to 32 bytes to the specified register of the device
@ -2646,6 +2767,16 @@ i2c_reg: 0-255, the register to write.
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
PI_I2C_WRITE_FAILED.
.br
.br
.EX
S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
.br
.EE
.IP "\fBint i2c_read_device(unsigned handle, char *buf, unsigned count)\fP"
.IP "" 4
This reads count bytes from the raw device into buf.
@ -4010,6 +4141,13 @@ A whole number, negative or positive.
.br
.IP "\fBinvert\fP" 0
A flag used to set normal or inverted bit bang serial data level logic.
.br
.br
.IP "\fBlevel\fP" 0
The level of a gpio. Low or High.

View File

@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
*/
/* PIGPIOD_IF_VERSION 17 */
/* PIGPIOD_IF_VERSION 18 */
#include <stdio.h>
#include <stdlib.h>

View File

@ -30,7 +30,7 @@ For more information, please refer to <http://unlicense.org/>
#include "pigpio.h"
#define PIGPIOD_IF_VERSION 17
#define PIGPIOD_IF_VERSION 18
/*TEXT
@ -1512,7 +1512,7 @@ user_gpio: 0-31, previously opened with [*bb_serial_read_open*].
invert: 0-1, 1 invert, 0 normal.
. .
Returns 0 if OK, otherwise PI_NOT_IN_SER_MODE or PI_BAD_SER_INVERT.
Returns 0 if OK, otherwise PI_NOT_SERIAL_GPIO or PI_BAD_SER_INVERT.
D*/
/*F*/
@ -1530,6 +1530,22 @@ No flags are currently defined. This parameter should be set to zero.
Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR,
PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED.
For the SMBus commands the low level transactions are shown at the end
of the function description. The following abbreviations are used.
. .
S (1 bit) : Start bit
P (1 bit) : Stop bit
Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
A, NA (1 bit) : Accept and not accept bit.
Addr (7 bits): I2C 7 bit address.
Comm (8 bits): Command byte, a data byte which often selects a register.
Data (8 bits): A data byte.
Count (8 bits): A data byte containing the length of a block operation.
[..]: Data sent by the device.
. .
D*/
/*F*/
@ -1558,7 +1574,10 @@ handle: >=0, as returned by a call to [*i2c_open*].
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
PI_I2C_WRITE_FAILED.
Quick command. smbus 2.0 5.5.1
Quick command. SMBus 2.0 5.5.1
. .
S Addr Rd/Wr [A] P
. .
D*/
/*F*/
@ -1574,7 +1593,10 @@ handle: >=0, as returned by a call to [*i2c_open*].
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
PI_I2C_WRITE_FAILED.
Send byte. smbus 2.0 5.5.2
Send byte. SMBus 2.0 5.5.2
. .
S Addr Wr [A] Data [A] P
. .
D*/
/*F*/
@ -1589,7 +1611,10 @@ handle: >=0, as returned by a call to [*i2c_open*].
Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE,
or PI_I2C_READ_FAILED.
Receive byte. smbus 2.0 5.5.3
Receive byte. SMBus 2.0 5.5.3
. .
S Addr Rd [A] [Data] NA P
. .
D*/
/*F*/
@ -1607,7 +1632,10 @@ i2c_reg: 0-255, the register to write.
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
PI_I2C_WRITE_FAILED.
Write byte. smbus 2.0 5.5.4
Write byte. SMBus 2.0 5.5.4
. .
S Addr Wr [A] Comm [A] Data [A] P
. .
D*/
/*F*/
@ -1625,7 +1653,10 @@ i2c_reg: 0-255, the register to write.
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
PI_I2C_WRITE_FAILED.
Write word. smbus 2.0 5.5.4
Write word. SMBus 2.0 5.5.4
. .
S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P
. .
D*/
/*F*/
@ -1642,7 +1673,10 @@ i2c_reg: 0-255, the register to read.
Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE,
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
Read byte. smbus 2.0 5.5.5
Read byte. SMBus 2.0 5.5.5
. .
S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
. .
D*/
/*F*/
@ -1659,7 +1693,10 @@ i2c_reg: 0-255, the register to read.
Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE,
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
Read word. smbus 2.0 5.5.5
Read word. SMBus 2.0 5.5.5
. .
S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
. .
D*/
/*F*/
@ -1677,7 +1714,11 @@ i2c_reg: 0-255, the register to write/read.
Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE,
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
Process call. smbus 2.0 5.5.6
Process call. SMBus 2.0 5.5.6
. .
S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]
S Addr Rd [A] [DataLow] A [DataHigh] NA P
. .
D*/
/*F*/
@ -1697,7 +1738,10 @@ i2c_reg: 0-255, the register to write.
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
PI_I2C_WRITE_FAILED.
Block write. smbus 2.0 5.5.7
Block write. SMBus 2.0 5.5.7
. .
S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P
. .
D*/
/*F*/
@ -1717,7 +1761,11 @@ The amount of returned data is set by the device.
Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
Block read. smbus 2.0 5.5.7
Block read. SMBus 2.0 5.5.7
. .
S Addr Wr [A] Comm [A]
S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
. .
D*/
/*F*/
@ -1743,7 +1791,11 @@ The smbus 2.0 documentation states that a minimum of 1 byte may be
sent and a minimum of 1 byte may be received. The total number of
bytes sent/received must be 32 or less.
Block write-block read. smbus 2.0 5.5.8
Block write-block read. SMBus 2.0 5.5.8
. .
S Addr Wr [A] Comm [A] Count [A] Data [A] ...
S Addr Rd [A] [Count] A [Data] ... A P
. .
D*/
/*F*/
@ -1762,6 +1814,11 @@ i2c_reg: 0-255, the register to read.
Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE,
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
. .
S Addr Wr [A] Comm [A]
S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
. .
D*/
@ -1781,6 +1838,10 @@ i2c_reg: 0-255, the register to write.
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
PI_I2C_WRITE_FAILED.
. .
S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
. .
D*/
/*F*/
@ -2518,6 +2579,9 @@ The number of bytes of data in a buffer.
int::
A whole number, negative or positive.
invert::
A flag used to set normal or inverted bit bang serial data level logic.
level::
The level of a gpio. Low or High.

99
pigs.1
View File

@ -645,7 +645,7 @@ The gpio must be one of the following.
5 clock 1 A+/B+/Pi2 and compute module only (reserved for system use)
6 clock 2 A+/B+/Pi2 and compute module only
20 clock 0 A+/B+/Pi2 and compute module only
21 clock 1 All models but Type 2 B (reserved for system use)
21 clock 1 All models but Type 2 (reserved for system use)
.EE
@ -742,7 +742,7 @@ The gpio must be one of the following.
This command returns the hardware revision of the Pi.
.br
The hardware revision is found in the last 4 characters on the Type sion
The hardware revision is found in the last 4 characters on the revision
line of /proc/cpuinfo.
.br
@ -2570,6 +2570,35 @@ ERROR: no serial read in progress on gpio
.br
.IP "\fBSLRI u v\fP - Sets bit bang serial data logic levels"
.IP "" 4
.br
This command sets the logic level for reading bit bang serial data
on gpio \fBu\fP.
.br
Upon success nothing is returned. On error a negative status code
will be returned.
.br
The invert parameter \fBv\fP is 1 for inverted signal, 0 for normal.
\fBExample\fP
.br
.EX
$ pigs slri 17 1 # invert logic on gpio 17
.br
.br
$ pigs slri 23 0 # use normal logic on gpio 23
.br
.EE
.br
.IP "\fBSLRO u b db\fP - Open gpio for bit bang serial data"
.IP "" 4
@ -2612,36 +2641,6 @@ ERROR: gpio already in use
.br
.IP "\fBSLRI u i\fP - Invert serial logic for bit bang serial data"
.IP "" 4
.br
This command inverts the serial logic when reading bit bang serial data.
.br
Upon success nothing is returned. On error a negative status code
will be returned.
.br
The invert parameter is 1 for inverted signal, 0 for normal.
.br
\fBExample\fP
.br
.EX
$ pigs slri 17 1
.br
.br
$ pigs slri 17 0
.br
.EE
.br
.IP "\fBSPIC h\fP - SPI close handle"
.IP "" 4
@ -3246,35 +3245,35 @@ done
.br
.br
pigs wvcha \\
pigs wvcha \
.br
${w[4]} ${w[3]} ${w[2]} \\
${w[4]} ${w[3]} ${w[2]} \
.br
255 0 \\
255 0 \
.br
${w[0]} ${w[0]} ${w[0]} \\
${w[0]} ${w[0]} ${w[0]} \
.br
255 0 \\
255 0 \
.br
${w[0]} ${w[1]} \\
${w[0]} ${w[1]} \
.br
255 2 0x88 0x13 \\
255 2 0x88 0x13 \
.br
255 1 30 0 \\
255 1 30 0 \
.br
255 0 \\
255 0 \
.br
${w[2]} ${w[3]} ${w[0]} \\
${w[2]} ${w[3]} ${w[0]} \
.br
${w[3]} ${w[1]} ${w[2]} \\
${w[3]} ${w[1]} ${w[2]} \
.br
255 1 10 0 \\
255 1 10 0 \
.br
255 1 5 0 \\
255 1 5 0 \
.br
${w[4]} ${w[4]} ${w[4]} \\
${w[4]} ${w[4]} ${w[4]} \
.br
255 2 0x20 0x4E \\
255 2 0x20 0x4E \
.br
${w[0]} ${w[0]} ${w[0]}
.br
@ -3399,7 +3398,7 @@ ERROR: attempt to create an empty waveform
.br
.IP "\fBWVDEL wid\fP - Delete selected waveforms"
.IP "\fBWVDEL wid\fP - Delete selected waveform"
.IP "" 4
.br
@ -4123,7 +4122,7 @@ Again, ignore the details for now.
.br
.EX
time (pigs procr 0 10000000; while a=$(pigs procp 0); [[ ${a::1} -eq 2 ]];\\
time (pigs procr 0 10000000; while a=$(pigs procp 0); [[ ${a::1} -eq 2 ]];\
.br
do sleep 0.2; done)
.br
@ -4163,7 +4162,7 @@ jp 999 jumps to tag 999 if the result is positive.
.br
.EX
time (pigs procr 0 10000000; while a=$(pigs procp 0); [[ ${a::1} -eq 2 ]];\\
time (pigs procr 0 10000000; while a=$(pigs procp 0); [[ ${a::1} -eq 2 ]];\
.br
do sleep 0.2; done)
.br

View File

@ -3,7 +3,7 @@
from distutils.core import setup
setup(name='pigpio',
version='1.20',
version='1.21',
author='joan',
author_email='joan@abyz.co.uk',
maintainer='joan',