This commit is contained in:
joan 2014-09-09 22:58:39 +01:00
parent 948734ccb1
commit 67ff6379b4
11 changed files with 125 additions and 48 deletions

11
README
View File

@ -49,7 +49,8 @@ x_pigpio.c, pig2vcd.c, and pigpiod.c show examples of interfacing
with the pigpio library. with the pigpio library.
pigs.c, pigpio.py, x_pigpiod_if.c, x_pigpio.py, x_pigs, and x_pipe pigs.c, pigpio.py, x_pigpiod_if.c, x_pigpio.py, x_pigs, and x_pipe
show examples of interfacing with the pigpio daemon. show examples of interfacing with the pigpio daemon. x_pipe uses
the pipe interface, the others use the socket interface.
DAEMON DAEMON
@ -57,7 +58,7 @@ To launch the daemon do
sudo pigpiod (pigpiod -? for options) sudo pigpiod (pigpiod -? for options)
Once the daemon is launched the socket and fifo interfaces will be Once the daemon is launched the socket and pipe interfaces will be
available. available.
When the library starts it locks When the library starts it locks
@ -70,15 +71,15 @@ SOCKET INTERFACE
Use pigs for the socket interface (pigs help for help). Use pigs for the socket interface (pigs help for help).
FIFO INTERFACE PIPE INTERFACE
The fifo interface accepts commands written to /dev/pigpio. The pipe interface accepts commands written to /dev/pigpio.
Results are read from /dev/pigout. Results are read from /dev/pigout.
Errors are output on /dev/pigerr. Errors are output on /dev/pigerr.
To test the fifo interface perhaps do To test the pipe interface perhaps do
cat /dev/pigout & cat /dev/pigout &
cat /dev/pigerr & cat /dev/pigerr &

View File

@ -2380,9 +2380,9 @@ device has 3 chip selects and a selectable word size in bits.
.br .br
.EX .EX
spiChan: 0-1 spiChan: 0-1 (0-2 for B+ auxiliary device)
.br .br
spiBaud: >1 spiBaud: 32K-125M (values above 30M are unlikely to work)
.br .br
spiFlags: see below spiFlags: see below
.br .br
@ -4254,6 +4254,25 @@ lVal: the value to write
.br .br
Not intended for general use. Not intended for general use.
.IP "\fBrawWaveInfo_t rawWaveInfo(int wave_id)\fP"
.IP "" 4
Gets details about the wave with id wave_id.
.br
.br
.EX
wave_id: the wave of interest
.br
.EE
.br
.br
Not intended for general use.
.IP "\fBint getBitInBytes(int bitPos, char *buf, int numBits)\fP" .IP "\fBint getBitInBytes(int bitPos, char *buf, int numBits)\fP"
.IP "" 4 .IP "" 4
Returns the value of the bit bitPos bits from the start of buf. Returns Returns the value of the bit bitPos bits from the start of buf. Returns
@ -5376,6 +5395,30 @@ typedef struct
.br .br
.IP "\fBrawWaveInfo_t\fP" 0
.EX
typedef struct
.br
{
.br
uint16_t botCB; // first CB used by wave
.br
uint16_t topCB; // last CB used by wave
.br
uint16_t botOOL; // last OOL used by wave
.br
uint16_t topOOL; // first OOL used by wave
.br
} rawWaveInfo_t;
.br
.EE
.br
.br
.IP "\fB*rxBuf\fP" 0 .IP "\fB*rxBuf\fP" 0
.br .br
@ -5567,7 +5610,7 @@ The number of bits to transfer in a raw SPI transaction.
.br .br
.br .br
A SPI channel, 0 or 1. A SPI channel, 0-2.
.br .br

View File

@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/> For more information, please refer to <http://unlicense.org/>
*/ */
/* pigpio version 21 */ /* pigpio version 22 */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -925,14 +925,6 @@ typedef struct
int mode; int mode;
} wfRx_t; } wfRx_t;
typedef struct
{
uint16_t botCB; /* first CB used by wave */
uint16_t topCB; /* last CB used by wave */
uint16_t botOOL;
uint16_t topOOL;
} waveInfo_t;
union my_smbus_data union my_smbus_data
{ {
uint8_t byte; uint8_t byte;
@ -991,7 +983,7 @@ static wfStats_t wfStats=
0, 0, (DMAO_PAGES * CBS_PER_OPAGE) 0, 0, (DMAO_PAGES * CBS_PER_OPAGE)
}; };
static waveInfo_t waveInfo[PI_MAX_WAVES]; static rawWaveInfo_t waveInfo[PI_MAX_WAVES];
static volatile wfRx_t wfRx[PI_MAX_USER_GPIO+1]; static volatile wfRx_t wfRx[PI_MAX_USER_GPIO+1];
@ -3179,7 +3171,6 @@ static void spiGoS(
unsigned cnt, cnt4w, cnt3w; unsigned cnt, cnt4w, cnt3w;
uint32_t spiDefaults; uint32_t spiDefaults;
unsigned mode, channel, cspol, cspols, flag3w, ren3w; unsigned mode, channel, cspol, cspols, flag3w, ren3w;
uint32_t status;
channel = PI_SPI_FLAGS_GET_CHANNEL(flags); channel = PI_SPI_FLAGS_GET_CHANNEL(flags);
mode = PI_SPI_FLAGS_GET_MODE (flags); mode = PI_SPI_FLAGS_GET_MODE (flags);
@ -3221,16 +3212,14 @@ static void spiGoS(
while((txCnt < cnt) || (rxCnt < cnt)) while((txCnt < cnt) || (rxCnt < cnt))
{ {
status = spiReg[SPI_CS]; while((rxCnt < cnt) && ((spiReg[SPI_CS] & SPI_CS_RXD)))
while((rxCnt < cnt) && ((status & SPI_CS_RXD)))
{ {
if (rxBuf) rxBuf[rxCnt] = spiReg[SPI_FIFO]; if (rxBuf) rxBuf[rxCnt] = spiReg[SPI_FIFO];
else spi_dummy = spiReg[SPI_FIFO]; else spi_dummy = spiReg[SPI_FIFO];
rxCnt++; rxCnt++;
} }
while((txCnt < cnt) && ((status & SPI_CS_TXD))) while((txCnt < cnt) && ((spiReg[SPI_CS] & SPI_CS_TXD)))
{ {
if (txBuf) spiReg[SPI_FIFO] = txBuf[txCnt]; if (txBuf) spiReg[SPI_FIFO] = txBuf[txCnt];
else spiReg[SPI_FIFO] = 0; else spiReg[SPI_FIFO] = 0;
@ -3248,16 +3237,14 @@ static void spiGoS(
while((txCnt < cnt) || (rxCnt < cnt)) while((txCnt < cnt) || (rxCnt < cnt))
{ {
status = spiReg[SPI_CS]; while((rxCnt < cnt) && ((spiReg[SPI_CS] & SPI_CS_RXD)))
while((rxCnt < cnt) && ((status & SPI_CS_RXD)))
{ {
if (rxBuf) rxBuf[rxCnt] = spiReg[SPI_FIFO]; if (rxBuf) rxBuf[rxCnt] = spiReg[SPI_FIFO];
else spi_dummy = spiReg[SPI_FIFO]; else spi_dummy = spiReg[SPI_FIFO];
rxCnt++; rxCnt++;
} }
while((txCnt < cnt) && ((status & SPI_CS_TXD))) while((txCnt < cnt) && ((spiReg[SPI_CS] & SPI_CS_TXD)))
{ {
if (txBuf) spiReg[SPI_FIFO] = txBuf[txCnt]; if (txBuf) spiReg[SPI_FIFO] = txBuf[txCnt];
else spiReg[SPI_FIFO] = 0; else spiReg[SPI_FIFO] = 0;
@ -5924,7 +5911,7 @@ uint32_t rawWaveGetOut(int pos)
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
void waveSetRawOut(int pos, uint32_t value) void rawWaveSetOut(int pos, uint32_t value)
{ {
int page, slot; int page, slot;
@ -5966,6 +5953,16 @@ void rawWaveSetIn(int pos, uint32_t value)
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
rawWaveInfo_t rawWaveInfo(int wave_id)
{
rawWaveInfo_t dummy = {-1, -1, -1, -1};
if ((wave_id >=0) && (wave_id < PI_MAX_WAVES)) return waveInfo[wave_id];
else return dummy;
}
/* ----------------------------------------------------------------------- */
double time_time(void) double time_time(void)
{ {
struct timeval tv; struct timeval tv;

View File

@ -31,7 +31,7 @@ For more information, please refer to <http://unlicense.org/>
#include <stdint.h> #include <stdint.h>
#include <pthread.h> #include <pthread.h>
#define PIGPIO_VERSION 21 #define PIGPIO_VERSION 22
/*TEXT /*TEXT
@ -291,6 +291,7 @@ rawWaveGetOut Not intended for general use
rawWaveSetOut Not intended for general use rawWaveSetOut Not intended for general use
rawWaveGetIn Not intended for general use rawWaveGetIn Not intended for general use
rawWaveSetIn Not intended for general use rawWaveSetIn Not intended for general use
rawWaveInfo Not intended for general use
rawDumpWave Not intended for general use rawDumpWave Not intended for general use
rawDumpScript Not intended for general use rawDumpScript Not intended for general use
@ -354,6 +355,14 @@ uint32_t usDelay;
uint32_t flags; uint32_t flags;
} rawWave_t; } rawWave_t;
typedef struct
{
uint16_t botCB; /* first CB used by wave */
uint16_t topCB; /* last CB used by wave */
uint16_t botOOL; /* last OOL used by wave */
uint16_t topOOL; /* first OOL used by wave */
} rawWaveInfo_t;
typedef struct typedef struct
{ {
int clk; /* gpio for clock */ int clk; /* gpio for clock */
@ -1901,8 +1910,8 @@ selected by setting the A bit in the flags. The auxiliary
device has 3 chip selects and a selectable word size in bits. device has 3 chip selects and a selectable word size in bits.
. . . .
spiChan: 0-1 spiChan: 0-1 (0-2 for B+ auxiliary device)
spiBaud: >1 spiBaud: 32K-125M (values above 30M are unlikely to work)
spiFlags: see below spiFlags: see below
. . . .
@ -3017,6 +3026,18 @@ lVal: the value to write
Not intended for general use. Not intended for general use.
D*/ D*/
/*F*/
rawWaveInfo_t rawWaveInfo(int wave_id);
/*D
Gets details about the wave with id wave_id.
. .
wave_id: the wave of interest
. .
Not intended for general use.
D*/
/*F*/ /*F*/
int getBitInBytes(int bitPos, char *buf, int numBits); int getBitInBytes(int bitPos, char *buf, int numBits);
/*D /*D
@ -3510,6 +3531,17 @@ typedef struct
} rawWave_t; } rawWave_t;
. . . .
rawWaveInfo_t::
. .
typedef struct
{
uint16_t botCB; // first CB used by wave
uint16_t topCB; // last CB used by wave
uint16_t botOOL; // last OOL used by wave
uint16_t topOOL; // first OOL used by wave
} rawWaveInfo_t;
. .
*rxBuf:: *rxBuf::
A pointer to a buffer to receive data. A pointer to a buffer to receive data.
@ -3582,7 +3614,7 @@ The number of bits to transfer in a raw SPI transaction.
spiChan:: spiChan::
A SPI channel, 0 or 1. A SPI channel, 0-2.
spiFlags:: spiFlags::

View File

@ -246,7 +246,7 @@ import os
import atexit import atexit
import codecs import codecs
VERSION = "1.11" VERSION = "1.12"
exceptions = True exceptions = True
@ -2193,8 +2193,8 @@ class pi():
device has 3 chip selects and a selectable word size in bits. device has 3 chip selects and a selectable word size in bits.
spi_channel:= 0 or 1, the SPI channel. spi_channel:= 0-1 (0-2 for B+ auxiliary device).
spi_baud:= >0, the transmission rate in bits per second. spi_baud:= 32K-125M (values above 30M are unlikely to work).
spi_flags:= see below. spi_flags:= see below.
Normally you would only use the [*spi_**] functions if Normally you would only use the [*spi_**] functions if
@ -3086,10 +3086,10 @@ def xref():
spi_*: spi_*:
One of the spi_ functions. One of the spi_ functions.
spi_baud: 1- spi_baud: 32K-125M
The transmission rate in bits per second. The transmission rate in bits per second.
spi_channel: 0-1 spi_channel: 0-2
A SPI channel. A SPI channel.
spi_flags: 32 bit spi_flags: 32 bit

View File

@ -2238,9 +2238,9 @@ device has 3 chip selects and a selectable word size in bits.
.br .br
.EX .EX
spi_channel: 0-1. spi_channel: 0-1 (0-2 for B+ auxiliary device).
.br .br
spi_baud: >1. spi_baud: 32K-125M (values above 30M are unlikely to work).
.br .br
spi_flags: see below. spi_flags: see below.
.br .br
@ -3310,7 +3310,7 @@ The speed in bits per second to use for the SPI device.
.br .br
.IP "\fBspi_channel\fP" 0 .IP "\fBspi_channel\fP" 0
A SPI channel, 0 or 1. A SPI channel, 0-2.
.br .br

View File

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

View File

@ -30,7 +30,7 @@ For more information, please refer to <http://unlicense.org/>
#include "pigpio.h" #include "pigpio.h"
#define PIGPIOD_IF_VERSION 9 #define PIGPIOD_IF_VERSION 10
/*TEXT /*TEXT
@ -1569,8 +1569,8 @@ selected by setting the A bit in the flags. The auxiliary
device has 3 chip selects and a selectable word size in bits. device has 3 chip selects and a selectable word size in bits.
. . . .
spi_channel: 0-1. spi_channel: 0-1 (0-2 for B+ auxiliary device).
spi_baud: >1. spi_baud: 32K-125M (values above 30M are unlikely to work).
spi_flags: see below. spi_flags: see below.
. . . .
@ -2117,7 +2117,7 @@ spi_baud::
The speed in bits per second to use for the SPI device. The speed in bits per second to use for the SPI device.
spi_channel:: spi_channel::
A SPI channel, 0 or 1. A SPI channel, 0-2.
spi_flags:: spi_flags::
See [*spi_open*]. See [*spi_open*].

View File

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

4
x_pigs
View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
VERSION=22
GPIO=4 GPIO=4
# #
@ -86,7 +88,7 @@ s=$(pigs pfs $GPIO 800)
if [[ $s = 800 ]]; then echo "PFS-b ok"; else echo "PFS-b fail ($s)"; fi if [[ $s = 800 ]]; then echo "PFS-b ok"; else echo "PFS-b fail ($s)"; fi
s=$(pigs pigpv) s=$(pigs pigpv)
if [[ $s = 21 ]]; then echo "PIGPV ok"; else echo "PIGPV fail ($s)"; fi if [[ $s = $VERSION ]]; then echo "PIGPV ok"; else echo "PIGPV fail ($s)"; fi
s=$(pigs prs $GPIO 255) s=$(pigs prs $GPIO 255)
if [[ $s = 250 ]]; then echo "PRG-a ok"; else echo "PRG-a fail ($s)"; fi if [[ $s = 250 ]]; then echo "PRG-a ok"; else echo "PRG-a fail ($s)"; fi

4
x_pipe
View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
VERSION=22
GPIO=4 GPIO=4
# #
@ -119,7 +121,7 @@ if [[ $s = 800 ]]; then echo "PFS-b ok"; else echo "PFS-b fail ($s)"; fi
echo "pigpv" >/dev/pigpio echo "pigpv" >/dev/pigpio
read -t 1 s </dev/pigout read -t 1 s </dev/pigout
if [[ $s = 21 ]]; then echo "PIGPV ok"; else echo "PIGPV fail ($s)"; fi if [[ $s = $VERSION ]]; then echo "PIGPV ok"; else echo "PIGPV fail ($s)"; fi
echo "prs $GPIO 255" >/dev/pigpio echo "prs $GPIO 255" >/dev/pigpio
read -t 1 s </dev/pigout read -t 1 s </dev/pigout