This commit is contained in:
joan 2015-04-23 08:58:59 +01:00
parent 9e72562f27
commit b9c55009e0
8 changed files with 1008 additions and 303 deletions

View File

@ -52,7 +52,8 @@ install: $(LIB)
sudo install -m 0755 pig2vcd /usr/local/bin
sudo install -m 0755 pigpiod /usr/local/bin
sudo install -m 0755 pigs /usr/local/bin
sudo python setup.py install
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
@ -66,6 +67,12 @@ uninstall:
sudo rm -f /usr/local/bin/pig2vcd
sudo rm -f /usr/local/bin/pigpiod
sudo 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
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

View File

@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
*/
/*
This version is for pigpio version 31+
This version is for pigpio version 32+
*/
#include <stdio.h>
@ -45,6 +45,10 @@ cmdInfo_t cmdInfo[]=
{PI_CMD_BC1, "BC1", 111, 1}, // gpioWrite_Bits_0_31_Clear
{PI_CMD_BC2, "BC2", 111, 1}, // gpioWrite_Bits_32_53_Clear
{PI_CMD_BI2CC, "BI2CC", 112, 0}, // bbI2CClose
{PI_CMD_BI2CO, "BI2CO", 131, 0}, // bbI2COpen
{PI_CMD_BI2CX, "BI2CX", 193, 6}, // bbI2CXfer
{PI_CMD_BR1, "BR1", 101, 3}, // gpioRead_Bits_0_31
{PI_CMD_BR2, "BR2", 101, 3}, // gpioRead_Bits_32_53
@ -86,6 +90,8 @@ cmdInfo_t cmdInfo[]=
{PI_CMD_I2CWS, "I2CWS", 121, 0}, // i2cWriteByte
{PI_CMD_I2CWW, "I2CWW", 131, 0}, // i2cWriteWordData
{PI_CMD_I2CX, "I2CX", 131, 0}, // i2cXfer
{PI_CMD_MICS, "MICS", 112, 0}, // gpioDelay
{PI_CMD_MILS, "MILS", 112, 0}, // gpioDelay
@ -243,23 +249,23 @@ HWVER Get hardware version\n\
I2CC h Close I2C handle\n\
I2CO ib id if Open I2C bus and device with flags\n\
\n\
I2CPC h r wv smb Process Call: exchange register with word\n\
I2CPK h r bvs smb Block Process Call: exchange data bytes with register\n\
I2CPC h r wv SMBus Process Call: exchange register with word\n\
I2CPK h r bvs SMBus Block Process Call: exchange data bytes with register\n\
\n\
I2CRB h r smb Read Byte Data: read byte from register\n\
I2CRB h r SMBus Read Byte Data: read byte from register\n\
I2CRD h num i2c Read bytes\n\
I2CRI h r num smb Read I2C Block Data: read bytes from register\n\
I2CRK h r smb Read Block Data: read data from register\n\
I2CRS h smb Read Byte: read byte\n\
I2CRW h r smb Read Word Data: read word from register\n\
I2CRI h r num SMBus Read I2C Block Data: read bytes from register\n\
I2CRK h r SMBus Read Block Data: read data from register\n\
I2CRS h SMBus Read Byte: read byte\n\
I2CRW h r SMBus Read Word Data: read word from register\n\
\n\
I2CWB h r bv smb Write Byte Data: write byte to register\n\
I2CWB h r bv SMBus Write Byte Data: write byte to register\n\
I2CWD h bvs i2c Write data\n\
I2CWI h r bvs smb Write I2C Block Data\n\
I2CWK h r bvs smb Write Block Data: write data to register\n\
I2CWQ h bit smb Write Quick: write bit\n\
I2CWS h bv smb Write Byte: write byte\n\
I2CWW h r wv smb Write Word Data: write word to register\n\
I2CWI h r bvs SMBus Write I2C Block Data\n\
I2CWK h r bvs SMBus Write Block Data: write data to register\n\
I2CWQ h bit SMBus Write Quick: write bit\n\
I2CWS h bv SMBus Write Byte: write byte\n\
I2CWW h r wv SMBus Write Word Data: write word to register\n\
\n\
M/MODES g m Set gpio mode\n\
MG/MODEG g Get gpio mode\n\
@ -428,7 +434,7 @@ static errInfo_t errInfo[]=
{PI_BAD_WAVE_BAUD , "baud rate not 50-250K(RX)/50-1M(TX)"},
{PI_TOO_MANY_PULSES , "waveform has too many pulses"},
{PI_TOO_MANY_CHARS , "waveform has too many chars"},
{PI_NOT_SERIAL_GPIO , "no serial read in progress on gpio"},
{PI_NOT_SERIAL_GPIO , "no bit bang serial read in progress on gpio"},
{PI_BAD_SERIAL_STRUC , "bad (null) serial structure parameter"},
{PI_BAD_SERIAL_BUF , "bad (null) serial buf parameter"},
{PI_NOT_PERMITTED , "no permission to update gpio"},
@ -496,6 +502,8 @@ static errInfo_t errInfo[]=
{PI_BAD_MALLOC_MODE , "bad memory allocation mode"},
{PI_TOO_MANY_PARTS , "too many I2C transaction parts"},
{PI_BAD_I2C_PART , "a combined I2C transaction failed"},
{PI_BAD_SMBUS_CMD , "SMBus command not supported by driver"},
{PI_NOT_I2C_GPIO , "no bit bang I2C in progress on gpio"},
};
@ -616,7 +624,7 @@ int cmdParse(
break;
case 112: /* GDC GPW I2CC
case 112: /* BI2CC GDC GPW I2CC
I2CRB MG MICS MILS MODEG NC NP PFG PRG
PROCD PROCP PROCS PRRG R READ SLRC SPIC
WVDEL WVSC WVSM WVSP WVTX WVTXR
@ -787,7 +795,8 @@ int cmdParse(
break;
case 131: /* HP I2CO I2CPC I2CRI I2CWB I2CWW SLRO SPIO TRIG
case 131: /* BI2CO HP I2CO I2CPC I2CRI I2CWB I2CWW SLRO
SPIO TRIG
Three positive parameters.
*/
@ -884,7 +893,7 @@ int cmdParse(
break;
case 193: /* I2CWD SERW
case 193: /* BI2CX I2CWD SERW SPIW SPIX
Two or more parameters, first >=0, rest 0-255.
*/

View File

@ -2065,7 +2065,7 @@ 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
For the SMBus commands the low level transactions are shown at the end
of the function description. The following abbreviations are used.
.br
@ -2191,7 +2191,7 @@ 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
@ -2224,7 +2224,7 @@ 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
@ -2255,7 +2255,7 @@ 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
@ -2291,7 +2291,7 @@ 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
@ -2327,7 +2327,7 @@ 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
@ -2361,7 +2361,7 @@ 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
@ -2395,7 +2395,7 @@ 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
@ -2431,7 +2431,7 @@ 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]
@ -2471,7 +2471,7 @@ 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
@ -2512,7 +2512,7 @@ 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]
@ -2553,14 +2553,14 @@ PI_BAD_PARAM, or PI_I2C_READ_FAILED.
.br
.br
The smbus 2.0 documentation states that a minimum of 1 byte may be
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.
.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] ...
@ -6815,6 +6815,18 @@ A 16-bit word value.
#define PI_CMD_CF2 88
.br
.br
#define PI_CMD_BI2CC 89
.br
#define PI_CMD_BI2CO 90
.br
#define PI_CMD_BI2CX 91
.br
.br
#define PI_CMD_I2CX 92
.br
.br
#define PI_CMD_NOIB 99
.br
@ -6905,7 +6917,7 @@ A 16-bit word value.
.br
#define PI_TOO_MANY_CHARS -37 // waveform has too many chars
.br
#define PI_NOT_SERIAL_GPIO -38 // no serial read in progress on gpio
#define PI_NOT_SERIAL_GPIO -38 // no bit bang serial read in progress on gpio
.br
#define PI_BAD_SERIAL_STRUC -39 // bad (null) serial structure parameter
.br
@ -7043,7 +7055,15 @@ A 16-bit word value.
.br
#define PI_BAD_I2C_PART -106 // a combined I2C transaction failed
.br
#define PI_BAD_SMBUS_CMD -107 // SMBus command not supported by driver
.br
#define PI_NOT_I2C_GPIO -108 // no bit bang I2C in progress on gpio
.br
#define PI_BAD_BB_WLEN -109 // bad BB write length
.br
#define PI_BAD_BB_RLEN -110 // bad BB read length
.br
#define PI_BAD_BB_CMD -111 // bad BB command
.br
.br
@ -7092,7 +7112,7 @@ A 16-bit word value.
.br
#define PI_DEFAULT_UPDATE_MASK_R2 0xFBC7CF9C
.br
#define PI_DEFAULT_UPDATE_MASK_R3 0x0080400FFFFFFCLL
#define PI_DEFAULT_UPDATE_MASK_R3 0x0080480FFFFFFCLL
.br
#define PI_DEFAULT_UPDATE_MASK_COMPUTE 0x00FFFFFFFFFFFFLL
.br

922
pigpio.c

File diff suppressed because it is too large Load Diff

197
pigpio.h
View File

@ -31,7 +31,7 @@ For more information, please refer to <http://unlicense.org/>
#include <stdint.h>
#include <pthread.h>
#define PIGPIO_VERSION 31
#define PIGPIO_VERSION 3202
/*TEXT
@ -225,20 +225,20 @@ i2cClose Closes an I2C device
i2cReadDevice Reads the raw I2C device
i2cWriteDevice Writes the raw I2C device
i2cWriteQuick smbus write quick
i2cWriteByte smbus write byte
i2cReadByte smbus read byte
i2cWriteByteData smbus write byte data
i2cWriteWordData smbus write word data
i2cReadByteData smbus read byte data
i2cReadWordData smbus read word data
i2cProcessCall smbus process call
i2cWriteBlockData smbus write block data
i2cReadBlockData smbus read block data
i2cBlockProcessCall smbus block process call
i2cWriteQuick SMBus write quick
i2cWriteByte SMBus write byte
i2cReadByte SMBus read byte
i2cWriteByteData SMBus write byte data
i2cWriteWordData SMBus write word data
i2cReadByteData SMBus read byte data
i2cReadWordData SMBus read word data
i2cProcessCall SMBus process call
i2cWriteBlockData SMBus write block data
i2cReadBlockData SMBus read block data
i2cBlockProcessCall SMBus block process call
i2cWriteI2CBlockData smbus write I2C block data
i2cReadI2CBlockData smbus read I2C block data
i2cWriteI2CBlockData SMBus write I2C block data
i2cReadI2CBlockData SMBus read I2C block data
SPI
@ -327,36 +327,36 @@ extern "C" {
typedef struct
{
uint16_t func;
uint16_t size;
uint16_t func;
uint16_t size;
} gpioHeader_t;
typedef struct
{
size_t size;
void *ptr;
uint32_t data;
size_t size;
void *ptr;
uint32_t data;
} gpioExtent_t;
typedef struct
{
uint32_t tick;
uint32_t level;
uint32_t tick;
uint32_t level;
} gpioSample_t;
typedef struct
{
uint16_t seqno;
uint16_t flags;
uint32_t tick;
uint32_t level;
uint16_t seqno;
uint16_t flags;
uint32_t tick;
uint32_t level;
} gpioReport_t;
typedef struct
{
uint32_t gpioOn;
uint32_t gpioOff;
uint32_t usDelay;
uint32_t gpioOn;
uint32_t gpioOff;
uint32_t usDelay;
} gpioPulse_t;
#define WAVE_FLAG_READ 1
@ -365,10 +365,10 @@ uint32_t usDelay;
typedef struct
{
uint32_t gpioOn;
uint32_t gpioOff;
uint32_t usDelay;
uint32_t flags;
uint32_t gpioOn;
uint32_t gpioOff;
uint32_t usDelay;
uint32_t flags;
} rawWave_t;
typedef struct
@ -381,41 +381,26 @@ typedef struct
typedef struct
{
int clk; /* gpio for clock */
int mosi; /* gpio for MOSI */
int miso; /* gpio for MISO */
int ss_pol; /* slave select off state */
int ss_us; /* delay after slave select */
int clk_pol; /* clock off state */
int clk_pha; /* clock phase */
int clk_us; /* clock micros */
int clk; /* gpio for clock */
int mosi; /* gpio for MOSI */
int miso; /* gpio for MISO */
int ss_pol; /* slave select off state */
int ss_us; /* delay after slave select */
int clk_pol; /* clock off state */
int clk_pha; /* clock phase */
int clk_us; /* clock micros */
} rawSPI_t;
typedef struct { /* linux/arch/arm/mach-bcm2708/include/mach/dma.h */
uint32_t info;
uint32_t src;
uint32_t dst;
uint32_t length;
uint32_t stride;
uint32_t next;
uint32_t pad[2];
uint32_t info;
uint32_t src;
uint32_t dst;
uint32_t length;
uint32_t stride;
uint32_t next;
uint32_t pad[2];
} rawCbs_t;
/* max pi_i2c_msg_t per transaction */
#define PI_I2C_RDRW_IOCTL_MAX_MSGS 42
/* flags for pi_i2c_msg_t */
#define PI_I2C_M_WR 0x0000 /* write data */
#define PI_I2C_M_RD 0x0001 /* read data */
#define PI_I2C_M_TEN 0x0010 /* ten bit chip address */
#define PI_I2C_M_RECV_LEN 0x0400 /* length will be first received byte */
#define PI_I2C_M_NO_RD_ACK 0x0800 /* if I2C_FUNC_PROTOCOL_MANGLING */
#define PI_I2C_M_IGNORE_NAK 0x1000 /* if I2C_FUNC_PROTOCOL_MANGLING */
#define PI_I2C_M_REV_DIR_ADDR 0x2000 /* if I2C_FUNC_PROTOCOL_MANGLING */
#define PI_I2C_M_NOSTART 0x4000 /* if I2C_FUNC_PROTOCOL_MANGLING */
typedef struct
{
uint16_t addr; /* slave address */
@ -521,6 +506,7 @@ typedef void *(gpioThreadFunc_t) (void *);
#define PI_NOTIFY_SLOTS 32
#define PI_NTFY_FLAGS_ALIVE (1 <<6)
#define PI_NTFY_FLAGS_WDOG (1 <<5)
#define PI_NTFY_FLAGS_BIT(x) (((x)<<0)&31)
@ -564,6 +550,43 @@ typedef void *(gpioThreadFunc_t) (void *);
#define PI_MAX_I2C_DEVICE_COUNT (1<<16)
#define PI_MAX_SPI_DEVICE_COUNT (1<<16)
/* max pi_i2c_msg_t per transaction */
#define PI_I2C_RDRW_IOCTL_MAX_MSGS 42
/* flags for pi_i2c_msg_t */
#define PI_I2C_M_WR 0x0000 /* write data */
#define PI_I2C_M_RD 0x0001 /* read data */
#define PI_I2C_M_TEN 0x0010 /* ten bit chip address */
#define PI_I2C_M_RECV_LEN 0x0400 /* length will be first received byte */
#define PI_I2C_M_NO_RD_ACK 0x0800 /* if I2C_FUNC_PROTOCOL_MANGLING */
#define PI_I2C_M_IGNORE_NAK 0x1000 /* if I2C_FUNC_PROTOCOL_MANGLING */
#define PI_I2C_M_REV_DIR_ADDR 0x2000 /* if I2C_FUNC_PROTOCOL_MANGLING */
#define PI_I2C_M_NOSTART 0x4000 /* if I2C_FUNC_PROTOCOL_MANGLING */
/* bit bang I2C commands */
#define PI_I2C_END 0
#define PI_I2C_START 1
#define PI_I2C_STOP 2
#define PI_I2C_READ 3
#define PI_I2C_WRITE 4
#define PI_I2C_READ16 5
#define PI_I2C_WRITE16 6
/* combined transaction I2C flag commands */
#define PI_I2C_F_CLEAR 40 /* clear flags */
#define PI_I2C_F_TEN 41 /* ten bit chip address */
#define PI_I2C_F_RECV_LEN 42 /* length will be first received byte */
#define PI_I2C_F_NO_RD_ACK 43 /* if I2C_FUNC_PROTOCOL_MANGLING */
#define PI_I2C_F_IGNORE_NAK 44 /* if I2C_FUNC_PROTOCOL_MANGLING */
#define PI_I2C_F_REV_DIR_ADDR 45 /* if I2C_FUNC_PROTOCOL_MANGLING */
#define PI_I2C_F_NOSTART 46 /* if I2C_FUNC_PROTOCOL_MANGLING */
/* SPI */
#define PI_SPI_FLAGS_BITLEN(x) ((x&63)<<16)
#define PI_SPI_FLAGS_RX_LSB(x) ((x&1)<<15)
#define PI_SPI_FLAGS_TX_LSB(x) ((x&1)<<14)
@ -1740,7 +1763,7 @@ 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
For the SMBus commands the low level transactions are shown at the end
of the function description. The following abbreviations are used.
. .
@ -1821,7 +1844,7 @@ handle: >=0, as returned by a call to [*i2cOpen*]
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
. .
@ -1841,7 +1864,7 @@ handle: >=0, as returned by a call to [*i2cOpen*]
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
. .
@ -1860,7 +1883,7 @@ handle: >=0, as returned by a call to [*i2cOpen*]
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
. .
@ -1882,7 +1905,7 @@ i2cReg: 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
. .
@ -1904,7 +1927,7 @@ i2cReg: 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
. .
@ -1925,7 +1948,7 @@ i2cReg: 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
. .
@ -1946,7 +1969,7 @@ i2cReg: 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
. .
@ -1968,7 +1991,7 @@ i2cReg: 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
@ -1993,7 +2016,7 @@ i2cReg: 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
. .
@ -2017,7 +2040,7 @@ 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
@ -2043,11 +2066,11 @@ i2cReg: 0-255, the register to write/read
Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
The smbus 2.0 documentation states that a minimum of 1 byte may be
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
@ -2101,6 +2124,14 @@ S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
. .
D*/
int bbI2COpen(unsigned SDA, unsigned SCL, unsigned bbBaud);
int bbI2CClose(unsigned SDA);
int bbI2CXfer(
unsigned SDA,
char *inBuf, unsigned inLen, char *outBuf, unsigned outLen);
/*F*/
int spiOpen(unsigned spiChan, unsigned spiBaud, unsigned spiFlags);
@ -4252,6 +4283,12 @@ PARAMS*/
#define PI_CMD_CF1 87
#define PI_CMD_CF2 88
#define PI_CMD_BI2CC 89
#define PI_CMD_BI2CO 90
#define PI_CMD_BI2CX 91
#define PI_CMD_I2CX 92
#define PI_CMD_NOIB 99
/*DEF_E*/
@ -4354,7 +4391,7 @@ after this command is issued.
#define PI_BAD_WAVE_BAUD -35 // baud rate not 50-250K(RX)/50-1M(TX)
#define PI_TOO_MANY_PULSES -36 // waveform has too many pulses
#define PI_TOO_MANY_CHARS -37 // waveform has too many chars
#define PI_NOT_SERIAL_GPIO -38 // no serial read in progress on gpio
#define PI_NOT_SERIAL_GPIO -38 // no bit bang serial read in progress on gpio
#define PI_BAD_SERIAL_STRUC -39 // bad (null) serial structure parameter
#define PI_BAD_SERIAL_BUF -40 // bad (null) serial buf parameter
#define PI_NOT_PERMITTED -41 // gpio operation not permitted
@ -4423,7 +4460,11 @@ after this command is issued.
#define PI_BAD_MALLOC_MODE -104 // bad memory allocation mode
#define PI_TOO_MANY_PARTS -105 // too many I2C transaction parts
#define PI_BAD_I2C_PART -106 // a combined I2C transaction failed
#define PI_BAD_SMBUS_CMD -107 // SMBus command not supported by driver
#define PI_NOT_I2C_GPIO -108 // no bit bang I2C in progress on gpio
#define PI_BAD_BB_WLEN -109 // bad BB write length
#define PI_BAD_BB_RLEN -110 // bad BB read length
#define PI_BAD_BB_CMD -111 // bad BB command
#define PI_PIGIF_ERR_0 -2000
#define PI_PIGIF_ERR_99 -2099
@ -4448,7 +4489,7 @@ after this command is issued.
#define PI_DEFAULT_UPDATE_MASK_R0 0xFFFFFFFF
#define PI_DEFAULT_UPDATE_MASK_R1 0x03E7CF93
#define PI_DEFAULT_UPDATE_MASK_R2 0xFBC7CF9C
#define PI_DEFAULT_UPDATE_MASK_R3 0x0080400FFFFFFCLL
#define PI_DEFAULT_UPDATE_MASK_R3 0x0080480FFFFFFCLL
#define PI_DEFAULT_UPDATE_MASK_COMPUTE 0x00FFFFFFFFFFFFLL
#define PI_DEFAULT_MEM_ALLOC_MODE PI_MEM_ALLOC_AUTO

View File

@ -197,20 +197,20 @@ i2c_close Closes an I2C device
i2c_read_device Reads the raw I2C device
i2c_write_device Writes the raw I2C device
i2c_write_quick smbus write quick
i2c_write_byte smbus write byte
i2c_read_byte smbus read byte
i2c_write_byte_data smbus write byte data
i2c_write_word_data smbus write word data
i2c_read_byte_data smbus read byte data
i2c_read_word_data smbus read word data
i2c_process_call smbus process call
i2c_write_block_data smbus write block data
i2c_read_block_data smbus read block data
i2c_block_process_call smbus block process call
i2c_write_quick SMBus write quick
i2c_write_byte SMBus write byte
i2c_read_byte SMBus read byte
i2c_write_byte_data SMBus write byte data
i2c_write_word_data SMBus write word data
i2c_read_byte_data SMBus read byte data
i2c_read_word_data SMBus read word data
i2c_process_call SMBus process call
i2c_write_block_data SMBus write block data
i2c_read_block_data SMBus read block data
i2c_block_process_call SMBus block process call
i2c_read_i2c_block_data smbus read I2C block data
i2c_write_i2c_block_data smbus write I2C block data
i2c_read_i2c_block_data SMBus read I2C block data
i2c_write_i2c_block_data SMBus write I2C block data
SPI
@ -257,7 +257,7 @@ import threading
import os
import atexit
VERSION = "1.16"
VERSION = "1.17"
exceptions = True
@ -304,6 +304,12 @@ PI_SCRIPT_RUNNING=2
PI_SCRIPT_WAITING=3
PI_SCRIPT_FAILED =4
# notification flags
NTFY_FLAGS_ALIVE = (1 << 6)
NTFY_FLAGS_WDOG = (1 << 5)
NTFY_FLAGS_GPIO = 31
# pigpio command numbers
_PI_CMD_MODES= 0
@ -519,6 +525,10 @@ PI_BAD_DATABITS =-101
PI_BAD_STOPBITS =-102
PI_MSG_TOOBIG =-103
PI_BAD_MALLOC_MODE =-104
_PI_TOO_MANY_PARTS =-105
_PI_BAD_I2C_PART =-106
PI_BAD_SMBUS_CMD =-107
PI_NOT_I2C_GPIO =-108
# pigpio error text
@ -560,7 +570,7 @@ _errors=[
[PI_BAD_WAVE_BAUD , "baud rate not 50-250000(RX)/1000000(TX)"],
[PI_TOO_MANY_PULSES , "waveform has too many pulses"],
[PI_TOO_MANY_CHARS , "waveform has too many chars"],
[PI_NOT_SERIAL_GPIO , "no serial read in progress on gpio"],
[PI_NOT_SERIAL_GPIO , "no bit bang serial read in progress on gpio"],
[PI_NOT_PERMITTED , "no permission to update gpio"],
[PI_SOME_PERMITTED , "no permission to update one or more gpios"],
[PI_BAD_WVSC_COMMND , "bad WVSC subcommand"],
@ -625,6 +635,10 @@ _errors=[
[PI_BAD_STOPBITS , "serial (half) stop bits not 2-8"],
[PI_MSG_TOOBIG , "socket/pipe message too big"],
[PI_BAD_MALLOC_MODE , "bad memory allocation mode"],
[_PI_TOO_MANY_PARTS , "too many I2C transaction parts"],
[_PI_BAD_I2C_PART , "a combined I2C transaction failed"],
[PI_BAD_SMBUS_CMD , "SMBus command not supported"],
[PI_NOT_I2C_GPIO , "no bit bang I2C in progress on gpio"],
]
@ -867,10 +881,11 @@ class _callback_thread(threading.Thread):
if (cb.edge ^ newLevel):
cb.func(cb.gpio, newLevel, tick)
else:
gpio = flags & 31
for cb in self.callbacks:
if cb.gpio == gpio:
cb.func(cb.gpio, TIMEOUT, tick)
if flags & NTFY_FLAGS_WDOG:
gpio = flags & NTFY_FLAGS_GPIO
for cb in self.callbacks:
if cb.gpio == gpio:
cb.func(cb.gpio, TIMEOUT, tick)
self.sl.s.close()
@ -1993,7 +2008,7 @@ class pi():
Normally you would only use the [*i2c_**] functions if
you are or will be connecting to the Pi over a network. If
you will always run on the local Pi use the standard smbus
you will always run on the local Pi use the standard SMBus
module instead.
...
@ -2080,7 +2095,7 @@ class pi():
"""
Sends a single bit to the device associated with handle.
smbus 2.0 5.5.1 - Quick command.
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.
@ -2096,7 +2111,7 @@ class pi():
"""
Sends a single byte to the device associated with handle.
smbus 2.0 5.5.2 - Send byte.
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.
@ -2113,7 +2128,7 @@ class pi():
"""
Reads a single byte from the device associated with handle.
smbus 2.0 5.5.3 - Receive byte.
SMBus 2.0 5.5.3 - Receive byte.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
@ -2128,7 +2143,7 @@ class pi():
Writes a single byte to the specified register of the device
associated with handle.
smbus 2.0 5.5.4 - Write byte.
SMBus 2.0 5.5.4 - Write byte.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
@ -2156,7 +2171,7 @@ 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.
SMBus 2.0 5.5.4 - Write word.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
@ -2184,7 +2199,7 @@ class pi():
Reads a single byte from the specified register of the device
associated with handle.
smbus 2.0 5.5.5 - Read byte.
SMBus 2.0 5.5.5 - Read byte.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
@ -2204,7 +2219,7 @@ 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.
SMBus 2.0 5.5.5 - Read word.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
@ -2224,7 +2239,7 @@ 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.
SMBus 2.0 5.5.6 - Process call.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
@ -2249,7 +2264,7 @@ 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.
SMBus 2.0 5.5.7 - Block write.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
@ -2281,7 +2296,7 @@ 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.
SMBus 2.0 5.5.7 - Block read.
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
@ -2316,13 +2331,13 @@ 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.
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.
The smbus 2.0 documentation states that a minimum of 1 byte may
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.

5
pigs.c
View File

@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
*/
/*
This version is for pigpio version 26+
This version is for pigpio version 32+
*/
#include <stdio.h>
@ -141,7 +141,7 @@ void print_result(int sock, int rv, cmdCmd_t cmd)
printf(cmdUsage);
break;
case 6: /* CF2 I2CPK I2CRD I2CRI I2CRK SERR SLR SPIX SPIR */
case 6: /* BI2CX CF2 I2CPK I2CRD I2CRI I2CRK SERR SLR SPIX SPIR */
printf("%d", r);
if (r < 0) fatal("ERROR: %s", cmdErrStr(r));
if (r > 0)
@ -178,6 +178,7 @@ void get_extensions(int sock, int command, int res)
{
switch (command)
{
case PI_CMD_BI2CX:
case PI_CMD_CF2:
case PI_CMD_I2CPK:
case PI_CMD_I2CRD:

View File

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