This commit is contained in:
joan 2016-03-08 14:28:15 +00:00
parent 46eb4d6056
commit be8beba544
14 changed files with 426 additions and 174 deletions

View File

@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
*/
/*
This version is for pigpio version 47+
This version is for pigpio version 48+
*/
#include <stdio.h>
@ -394,7 +394,7 @@ static errInfo_t errInfo[]=
{PI_BAD_CHANNEL , "DMA channel not 0-14"},
{PI_BAD_SOCKET_PORT , "socket port not 1024-30000"},
{PI_BAD_FIFO_COMMAND , "unknown fifo command"},
{PI_BAD_SECO_CHANNEL , "DMA secondary channel not 0-6"},
{PI_BAD_SECO_CHANNEL , "DMA secondary channel not 0-14"},
{PI_NOT_INITIALISED , "function called before gpioInitialise"},
{PI_INITIALISED , "function called after gpioInitialise"},
{PI_BAD_WAVE_MODE , "waveform mode not 0-1"},
@ -455,7 +455,7 @@ static errInfo_t errInfo[]=
{PI_UNKNOWN_COMMAND , "unknown command"},
{PI_SPI_XFER_FAILED , "spi xfer/read/write failed"},
{PI_BAD_POINTER , "bad (NULL) pointer"},
{PI_NO_AUX_SPI , "need a B+ for auxiliary SPI"},
{PI_NO_AUX_SPI , "no auxiliary SPI on Pi A or B"},
{PI_NOT_PWM_GPIO , "GPIO is not in use for PWM"},
{PI_NOT_SERVO_GPIO , "GPIO is not in use for servo pulses"},
{PI_NOT_HCLK_GPIO , "GPIO has no hardware clock"},

View File

@ -5260,7 +5260,7 @@ Configures pigpio to use the specified DMA channels.
.EX
primaryChannel: 0-14
.br
secondaryChannel: 0-6
secondaryChannel: 0-14
.br
.EE
@ -5269,7 +5269,27 @@ secondaryChannel: 0-6
.br
The default setting is to use channel 14 for the primary channel and
channel 5 for the secondary channel.
channel 6 for the secondary channel.
.br
.br
The secondary channel is only used for the transmission of waves.
.br
.br
If possible use one of channels 0 to 6 for the secondary channel
(a full channel).
.br
.br
A full channel only requires one DMA control block regardless of the
length of a pulse delay. Channels 7 to 14 (lite channels) require
one DMA control block for each 16383 microseconds of delay. I.e.
a 10 second pulse delay requires one control block on a full channel
and 611 control blocks on a lite channel.
.IP "\fBint gpioCfgPermissions(uint64_t updateMask)\fP"
.IP "" 4
@ -5289,22 +5309,26 @@ updateMask: bit (1<<n) is set for each GPIO n which may be updated
.br
.br
The default setting depends upon the board revision (Type 1, 2, or 3).
The user GPIO are added to the mask. If the board revision is not
recognised then GPIO 0-31 are allowed.
The default setting depends upon the Pi model. The user GPIO are
added to the mask.
.br
.br
Unknown board PI_DEFAULT_UPDATE_MASK_R0 0xFFFFFFFF
If the board revision is not recognised then GPIO 0-31 are allowed.
.br
.br
Type 1 board PI_DEFAULT_UPDATE_MASK_R1 0x03E6CF93
Unknown board PI_DEFAULT_UPDATE_MASK_UNKNOWN 0xFFFFFFFF
.br
.br
Type 2 board PI_DEFAULT_UPDATE_MASK_R2 0xFBC6CF9C
Type 1 board PI_DEFAULT_UPDATE_MASK_B1 0x03E6CF93
.br
.br
Type 2 board PI_DEFAULT_UPDATE_MASK_A_B2 0xFBC6CF9C
.br
Type 3 board PI_DEFAULT_UPDATE_MASK_R3 0x0FFFFFFC
@ -8153,37 +8177,43 @@ A 16-bit word value.
.EX
.br
#define PI_DEFAULT_BUFFER_MILLIS 120
#define PI_DEFAULT_BUFFER_MILLIS 120
.br
#define PI_DEFAULT_CLK_MICROS 5
#define PI_DEFAULT_CLK_MICROS 5
.br
#define PI_DEFAULT_CLK_PERIPHERAL PI_CLOCK_PCM
#define PI_DEFAULT_CLK_PERIPHERAL PI_CLOCK_PCM
.br
#define PI_DEFAULT_IF_FLAGS 0
#define PI_DEFAULT_IF_FLAGS 0
.br
#define PI_DEFAULT_DMA_CHANNEL 14
#define PI_DEFAULT_DMA_CHANNEL 14
.br
#define PI_DEFAULT_DMA_PRIMARY_CHANNEL 14
#define PI_DEFAULT_DMA_PRIMARY_CHANNEL 14
.br
#define PI_DEFAULT_DMA_SECONDARY_CHANNEL 5
#define PI_DEFAULT_DMA_SECONDARY_CHANNEL 6
.br
#define PI_DEFAULT_SOCKET_PORT 8888
#define PI_DEFAULT_SOCKET_PORT 8888
.br
#define PI_DEFAULT_SOCKET_PORT_STR "8888"
#define PI_DEFAULT_SOCKET_PORT_STR "8888"
.br
#define PI_DEFAULT_SOCKET_ADDR_STR "127.0.0.1"
#define PI_DEFAULT_SOCKET_ADDR_STR "127.0.0.1"
.br
#define PI_DEFAULT_UPDATE_MASK_R0 0xFFFFFFFF
#define PI_DEFAULT_UPDATE_MASK_UNKNOWN 0xFFFFFFFF
.br
#define PI_DEFAULT_UPDATE_MASK_R1 0x03E7CF93
#define PI_DEFAULT_UPDATE_MASK_B1 0x03E7CF93
.br
#define PI_DEFAULT_UPDATE_MASK_R2 0xFBC7CF9C
#define PI_DEFAULT_UPDATE_MASK_A_B2 0xFBC7CF9C
.br
#define PI_DEFAULT_UPDATE_MASK_R3 0x0080480FFFFFFCLL
#define PI_DEFAULT_UPDATE_MASK_APLUS_BPLUS 0x0080480FFFFFFCLL
.br
#define PI_DEFAULT_UPDATE_MASK_COMPUTE 0x00FFFFFFFFFFFFLL
#define PI_DEFAULT_UPDATE_MASK_ZERO 0x0080000FFFFFFCLL
.br
#define PI_DEFAULT_MEM_ALLOC_MODE PI_MEM_ALLOC_AUTO
#define PI_DEFAULT_UPDATE_MASK_PI2B 0x0080480FFFFFFCLL
.br
#define PI_DEFAULT_UPDATE_MASK_PI3B 0x0000000FFFFFFCLL
.br
#define PI_DEFAULT_UPDATE_MASK_COMPUTE 0x00FFFFFFFFFFFFLL
.br
#define PI_DEFAULT_MEM_ALLOC_MODE PI_MEM_ALLOC_AUTO
.br
.br

231
pigpio.c
View File

@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
*/
/* pigpio version 47 */
/* pigpio version 48 */
/* include ------------------------------------------------------- */
@ -365,9 +365,11 @@ bit 0 READ_LAST_NOT_SET_ERROR
#define DMA_BURST_LENGTH(x) ((x)<<12)
#define DMA_SRC_IGNORE (1<<11)
#define DMA_SRC_DREQ (1<<10)
#define DMA_SRC_WIDTH (1<< 9)
#define DMA_SRC_INC (1<< 8)
#define DMA_DEST_IGNORE (1<< 7)
#define DMA_DEST_DREQ (1<< 6)
#define DMA_DEST_WIDTH (1<< 5)
#define DMA_DEST_INC (1<< 4)
#define DMA_WAIT_RESP (1<< 3)
@ -375,6 +377,9 @@ bit 0 READ_LAST_NOT_SET_ERROR
#define DMA_DEBUG_FIFO_ERR (1<<1)
#define DMA_DEBUG_RD_LST_NOT_SET_ERR (1<<0)
#define DMA_LITE_FIRST 7
#define DMA_LITE_MAX 0xfffc
#define PWM_CTL 0
#define PWM_STA 1
#define PWM_DMAC 2
@ -742,6 +747,8 @@ Assumes two counters per block. Each counter 4 * 16 (16^4=65536)
#define PI_WF_MICROS 1
#define BPD 4
#define MAX_REPORT 120
#define MAX_SAMPLE 4000
@ -1123,7 +1130,7 @@ typedef struct
/* initialise once then preserve */
static volatile uint32_t piModel = 1;
static volatile uint32_t piCores = 0;
static volatile uint32_t pi_peri_phys = 0x20000000;
static volatile uint32_t pi_dram_bus = 0x40000000;
static volatile uint32_t pi_mem_flag = 0x0C;
@ -1655,7 +1662,7 @@ static void spinWhileStarting(void)
{
while (runState == PI_STARTING)
{
if (piModel == 1) myGpioDelay(1000);
if (piCores == 1) myGpioDelay(1000);
else flushMemory();
}
}
@ -2603,6 +2610,17 @@ static void waveBitDelay
bitDelay[i] = diff;
}
static int waveDelayCBs(uint32_t delay)
{
uint32_t cbs;
if (!delay) return 0;
if (gpioCfg.DMAsecondaryChannel < DMA_LITE_FIRST) return 1;
cbs = BPD * delay / DMA_LITE_MAX;
if ((BPD * delay) % DMA_LITE_MAX) cbs++;
return cbs;
}
/* ----------------------------------------------------------------------- */
static void waveCBsOOLs(int *numCBs, int *numBOOLs, int *numTOOLs)
@ -2628,7 +2646,8 @@ static void waveCBsOOLs(int *numCBs, int *numBOOLs, int *numTOOLs)
if (waves[i].gpioOff) {numCB++; numBOOL++;}
if (waves[i].flags & WAVE_FLAG_READ) {numCB++; numTOOL++;}
if (waves[i].flags & WAVE_FLAG_TICK) {numCB++; numTOOL++;}
if (waves[i].usDelay) {numCB++; }
numCB += waveDelayCBs(waves[i].usDelay);
}
*numCBs = numCB;
@ -2646,17 +2665,19 @@ static int wave2Cbs(unsigned wave_mode, int *CB, int *BOOL, int *TOOL)
rawCbs_t *p=NULL;
unsigned i, half, repeatCB;
unsigned i, repeatCB;
unsigned numWaves;
unsigned delayCBs, dcb;
uint32_t delayLeft;
rawWave_t * waves;
numWaves = wfc[wfcur];
waves = wf [wfcur];
half = PI_WF_MICROS/2;
/* add delay cb at start of DMA */
p = rawWaveCBAdr(botCB++);
@ -2675,7 +2696,7 @@ static int wave2Cbs(unsigned wave_mode, int *CB, int *BOOL, int *TOOL)
}
p->src = (uint32_t) (&dmaOBus[0]->periphData);
p->length = 4 * 20 / PI_WF_MICROS; /* 20 micros delay */
p->length = BPD * 20 / PI_WF_MICROS; /* 20 micros delay */
p->next = waveCbPOadr(botCB);
repeatCB = botCB;
@ -2732,24 +2753,41 @@ static int wave2Cbs(unsigned wave_mode, int *CB, int *BOOL, int *TOOL)
if (waves[i].usDelay)
{
p = rawWaveCBAdr(botCB++);
delayLeft = waves[i].usDelay;
/* use the secondary clock */
delayCBs = waveDelayCBs(delayLeft);
if (gpioCfg.clockPeriph != PI_CLOCK_PCM)
for (dcb=0; dcb<delayCBs; dcb++)
{
p->info = NORMAL_DMA | TIMED_DMA(2);
p->dst = PCM_TIMER;
}
else
{
p->info = NORMAL_DMA | TIMED_DMA(5);
p->dst = PWM_TIMER;
}
p = rawWaveCBAdr(botCB++);
p->src = (uint32_t) (&dmaOBus[0]->periphData);
p->length = 4 * ((waves[i].usDelay+half)/PI_WF_MICROS);
p->next = waveCbPOadr(botCB);
/* use the secondary clock */
if (gpioCfg.clockPeriph != PI_CLOCK_PCM)
{
p->info = NORMAL_DMA | TIMED_DMA(2);
p->dst = PCM_TIMER;
}
else
{
p->info = NORMAL_DMA | TIMED_DMA(5);
p->dst = PWM_TIMER;
}
p->src = (uint32_t) (&dmaOBus[0]->periphData);
p->length = BPD * delayLeft / PI_WF_MICROS;
if ((gpioCfg.DMAsecondaryChannel >= DMA_LITE_FIRST) &&
(p->length > DMA_LITE_MAX))
{
p->length = DMA_LITE_MAX;
}
delayLeft -= (p->length / BPD);
p->next = waveCbPOadr(botCB);
}
}
}
@ -2940,7 +2978,7 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
out[outPos].usDelay = tDelay;
cbs++; /* one cb for delay */
cbs += waveDelayCBs(tDelay);
if (out[outPos].gpioOn) cbs++; /* one cb if gpio on */
@ -4301,7 +4339,7 @@ int spiOpen(unsigned spiChan, unsigned baud, unsigned spiFlags)
if (PI_SPI_FLAGS_GET_AUX_SPI(spiFlags))
{
if (gpioHardwareRevision() < 16)
SOFT_ERROR(PI_NO_AUX_SPI, "no auxiliary SPI, need a A+/B+");
SOFT_ERROR(PI_NO_AUX_SPI, "no auxiliary SPI on Pi A or B");
i = PI_NUM_AUX_SPI_CHANNEL;
}
@ -5567,7 +5605,6 @@ static void alertEmit(
}
else
{
gpioCfg.internals |= PI_CFG_STATS;
gpioStats.shortPipeWrite++;
DBG(DBG_ALWAYS, "emitted %d, asked for %d",
err/sizeof(gpioReport_t), max_emits);
@ -5608,7 +5645,6 @@ static void alertEmit(
}
else
{
gpioCfg.internals |= PI_CFG_STATS;
gpioStats.shortPipeWrite++;
DBG(DBG_ALWAYS, "emitted %d, asked for %d",
err/sizeof(gpioReport_t), emit);
@ -7505,7 +7541,7 @@ static void initReleaseResources(void)
int initInitialise(void)
{
int rev, i;
int rev, i, model;
struct sockaddr_in server;
char * portStr;
unsigned port;
@ -7531,11 +7567,32 @@ int initInitialise(void)
if (!gpioMaskSet)
{
if (rev == 0) gpioMask = PI_DEFAULT_UPDATE_MASK_R0;
if (rev == 0) gpioMask = PI_DEFAULT_UPDATE_MASK_UNKNOWN;
else if (rev == 17) gpioMask = PI_DEFAULT_UPDATE_MASK_COMPUTE;
else if (rev < 4) gpioMask = PI_DEFAULT_UPDATE_MASK_R1;
else if (rev < 16) gpioMask = PI_DEFAULT_UPDATE_MASK_R2;
else gpioMask = PI_DEFAULT_UPDATE_MASK_R3;
else if (rev < 4) gpioMask = PI_DEFAULT_UPDATE_MASK_B1;
else if (rev < 16) gpioMask = PI_DEFAULT_UPDATE_MASK_A_B2;
else
{
model = (rev >> 4) & 0xFF;
/* model
0=A 1=B
2=A+ 3=B+
4=Pi2B
5=Alpha
6=Compute Module
7=Unknown
8=Pi3B
9=Zero
*/
if (model < 2) gpioMask = PI_DEFAULT_UPDATE_MASK_A_B2;
else if (model < 4) gpioMask = PI_DEFAULT_UPDATE_MASK_APLUS_BPLUS;
else if (model == 4) gpioMask = PI_DEFAULT_UPDATE_MASK_PI2B;
else if (model == 6) gpioMask = PI_DEFAULT_UPDATE_MASK_COMPUTE;
else if (model == 8) gpioMask = PI_DEFAULT_UPDATE_MASK_PI3B;
else if (model == 9) gpioMask = PI_DEFAULT_UPDATE_MASK_ZERO;
else gpioMask = PI_DEFAULT_UPDATE_MASK_UNKNOWN;
}
gpioMaskSet = 1;
}
@ -9118,7 +9175,7 @@ int gpioWaveChain(char *buf, unsigned bufSize)
int cb, chaincb;
rawCbs_t *p;
int i, wid, cmd, loop, counters;
unsigned cycles;
unsigned cycles, delayCBs, dcb, delayLeft;
uint32_t repeat, next, *endPtr;
int stk_pos[10], stk_lev=0;
@ -9159,7 +9216,7 @@ int gpioWaveChain(char *buf, unsigned bufSize)
}
p->src = (uint32_t) (&dmaOBus[0]->periphData);
p->length = 4 * 20 / PI_WF_MICROS; /* 20 micros delay */
p->length = BPD * 20 / PI_WF_MICROS; /* 20 micros delay */
p->next = waveCbPOadr(chainGetCB(cb));
counters = 0;
@ -9275,29 +9332,45 @@ int gpioWaveChain(char *buf, unsigned bufSize)
if (cycles)
{
chaincb = chainGetCB(cb++);
if (chaincb < 0)
SOFT_ERROR(PI_CHAIN_TOO_BIG, "chain is too long (%d)", cb);
p = rawWaveCBAdr(chaincb);
/* use the secondary clock */
if (gpioCfg.clockPeriph != PI_CLOCK_PCM)
delayLeft = cycles;
delayCBs = waveDelayCBs(delayLeft);
for (dcb=0; dcb<delayCBs; dcb++)
{
p->info = NORMAL_DMA | TIMED_DMA(2);
p->dst = PCM_TIMER;
}
else
{
p->info = NORMAL_DMA | TIMED_DMA(5);
p->dst = PWM_TIMER;
}
chaincb = chainGetCB(cb++);
p->src = (uint32_t) (&dmaOBus[0]->periphData);
p->length = 4 * cycles / PI_WF_MICROS;
p->next = waveCbPOadr(chainGetCB(cb));
if (chaincb < 0)
SOFT_ERROR(
PI_CHAIN_TOO_BIG, "chain is too long (%d)", cb);
p = rawWaveCBAdr(chaincb);
/* use the secondary clock */
if (gpioCfg.clockPeriph != PI_CLOCK_PCM)
{
p->info = NORMAL_DMA | TIMED_DMA(2);
p->dst = PCM_TIMER;
}
else
{
p->info = NORMAL_DMA | TIMED_DMA(5);
p->dst = PWM_TIMER;
}
p->src = (uint32_t) (&dmaOBus[0]->periphData);
p->length = BPD * delayLeft / PI_WF_MICROS;
if ((gpioCfg.DMAsecondaryChannel >= DMA_LITE_FIRST) &&
(p->length > DMA_LITE_MAX))
{
p->length = DMA_LITE_MAX;
}
delayLeft -= (p->length / BPD);
p->next = waveCbPOadr(chainGetCB(cb));
}
}
}
else if (cmd == 3) /* repeat loop forever */
@ -11506,6 +11579,28 @@ unsigned gpioVersion(void)
/* ----------------------------------------------------------------------- */
/*
2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
W W S M M M B B B B P P P P T T T T T T T T R R R R
W warranty void if either bit is set
S 0=old (bits 0-22 are revision number) 1=new (following fields apply)
M 0=256 1=512 2=1024
B 0=Sony 1=Egoman 2=Embest 3=Unknown 4=Embest
P 0=2835, 1=2836, 2=2837
T 0=A 1=B 2=A+ 3=B+ 4=Pi2B 5=Alpha 6=Compute Module 7=Unknown 8=Pi3B 9=Zero
R PCB board revision
*/
unsigned gpioHardwareRevision(void)
{
static unsigned rev = 0;
@ -11513,13 +11608,12 @@ unsigned gpioHardwareRevision(void)
FILE * filp;
char buf[512];
char term;
int chars=4; /* number of chars in revision string */
DBG(DBG_USER, "");
if (rev) return rev;
piModel = 0;
piCores = 0;
filp = fopen ("/proc/cpuinfo", "r");
@ -11527,22 +11621,27 @@ unsigned gpioHardwareRevision(void)
{
while (fgets(buf, sizeof(buf), filp) != NULL)
{
if (piModel == 0)
if (piCores == 0)
{
if (!strncasecmp("model name", buf, 10))
{
if (strstr (buf, "ARMv6") != NULL)
{
piModel = 1;
chars = 4;
piCores = 1;
pi_peri_phys = 0x20000000;
pi_dram_bus = 0x40000000;
pi_mem_flag = 0x0C;
}
else if (strstr (buf, "ARMv7") != NULL)
{
piModel = 2;
chars = 6;
piCores = 4;
pi_peri_phys = 0x3F000000;
pi_dram_bus = 0xC0000000;
pi_mem_flag = 0x04;
}
else if (strstr (buf, "ARMv8") != NULL)
{
piCores = 4;
pi_peri_phys = 0x3F000000;
pi_dram_bus = 0xC0000000;
pi_mem_flag = 0x04;
@ -11550,10 +11649,9 @@ unsigned gpioHardwareRevision(void)
}
}
if (!strncasecmp("revision", buf, 8))
if (!strncasecmp("revision\t:", buf, 10))
{
if (sscanf(buf+strlen(buf)-(chars+1),
"%x%c", &rev, &term) == 2)
if (sscanf(buf+10, "%x%c", &rev, &term) == 2)
{
if (term != '\n') rev = 0;
}
@ -11633,11 +11731,12 @@ int gpioCfgDMAchannels(unsigned primaryChannel, unsigned secondaryChannel)
CHECK_NOT_INITED;
if (primaryChannel > PI_MAX_PRIMARY_CHANNEL)
if (primaryChannel > PI_MAX_DMA_CHANNEL)
SOFT_ERROR(PI_BAD_PRIM_CHANNEL, "bad primary channel (%d)",
primaryChannel);
if (secondaryChannel > PI_MAX_SECONDARY_CHANNEL)
if ((secondaryChannel > PI_MAX_DMA_CHANNEL) ||
(secondaryChannel == primaryChannel))
SOFT_ERROR(PI_BAD_SECO_CHANNEL, "bad secondary channel (%d)",
secondaryChannel);

View File

@ -31,7 +31,7 @@ For more information, please refer to <http://unlicense.org/>
#include <stdint.h>
#include <pthread.h>
#define PIGPIO_VERSION 47
#define PIGPIO_VERSION 48
/*TEXT
@ -726,9 +726,6 @@ typedef void *(gpioThreadFunc_t) (void *);
#define PI_MIN_DMA_CHANNEL 0
#define PI_MAX_DMA_CHANNEL 14
#define PI_MAX_PRIMARY_CHANNEL 14
#define PI_MAX_SECONDARY_CHANNEL 6
/* port */
#define PI_MIN_SOCKET_PORT 1024
@ -3705,11 +3702,22 @@ Configures pigpio to use the specified DMA channels.
. .
primaryChannel: 0-14
secondaryChannel: 0-6
secondaryChannel: 0-14
. .
The default setting is to use channel 14 for the primary channel and
channel 5 for the secondary channel.
channel 6 for the secondary channel.
The secondary channel is only used for the transmission of waves.
If possible use one of channels 0 to 6 for the secondary channel
(a full channel).
A full channel only requires one DMA control block regardless of the
length of a pulse delay. Channels 7 to 14 (lite channels) require
one DMA control block for each 16383 microseconds of delay. I.e.
a 10 second pulse delay requires one control block on a full channel
and 611 control blocks on a lite channel.
D*/
@ -3723,13 +3731,14 @@ GPIO specified by the mask.
updateMask: bit (1<<n) is set for each GPIO n which may be updated
. .
The default setting depends upon the board revision (Type 1, 2, or 3).
The user GPIO are added to the mask. If the board revision is not
recognised then GPIO 0-31 are allowed.
The default setting depends upon the Pi model. The user GPIO are
added to the mask.
Unknown board @ PI_DEFAULT_UPDATE_MASK_R0 @ 0xFFFFFFFF
Type 1 board @ PI_DEFAULT_UPDATE_MASK_R1 @ 0x03E6CF93
Type 2 board @ PI_DEFAULT_UPDATE_MASK_R2 @ 0xFBC6CF9C
If the board revision is not recognised then GPIO 0-31 are allowed.
Unknown board @ PI_DEFAULT_UPDATE_MASK_UNKNOWN @ 0xFFFFFFFF
Type 1 board @ PI_DEFAULT_UPDATE_MASK_B1 @ 0x03E6CF93
Type 2 board @ PI_DEFAULT_UPDATE_MASK_A_B2 @ 0xFBC6CF9C
Type 3 board @ PI_DEFAULT_UPDATE_MASK_R3 @ 0x0FFFFFFC
D*/
@ -5156,22 +5165,25 @@ after this command is issued.
/*DEF_S Defaults*/
#define PI_DEFAULT_BUFFER_MILLIS 120
#define PI_DEFAULT_CLK_MICROS 5
#define PI_DEFAULT_CLK_PERIPHERAL PI_CLOCK_PCM
#define PI_DEFAULT_IF_FLAGS 0
#define PI_DEFAULT_DMA_CHANNEL 14
#define PI_DEFAULT_DMA_PRIMARY_CHANNEL 14
#define PI_DEFAULT_DMA_SECONDARY_CHANNEL 5
#define PI_DEFAULT_SOCKET_PORT 8888
#define PI_DEFAULT_SOCKET_PORT_STR "8888"
#define PI_DEFAULT_SOCKET_ADDR_STR "127.0.0.1"
#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 0x0080480FFFFFFCLL
#define PI_DEFAULT_UPDATE_MASK_COMPUTE 0x00FFFFFFFFFFFFLL
#define PI_DEFAULT_MEM_ALLOC_MODE PI_MEM_ALLOC_AUTO
#define PI_DEFAULT_BUFFER_MILLIS 120
#define PI_DEFAULT_CLK_MICROS 5
#define PI_DEFAULT_CLK_PERIPHERAL PI_CLOCK_PCM
#define PI_DEFAULT_IF_FLAGS 0
#define PI_DEFAULT_DMA_CHANNEL 14
#define PI_DEFAULT_DMA_PRIMARY_CHANNEL 14
#define PI_DEFAULT_DMA_SECONDARY_CHANNEL 6
#define PI_DEFAULT_SOCKET_PORT 8888
#define PI_DEFAULT_SOCKET_PORT_STR "8888"
#define PI_DEFAULT_SOCKET_ADDR_STR "127.0.0.1"
#define PI_DEFAULT_UPDATE_MASK_UNKNOWN 0xFFFFFFFF
#define PI_DEFAULT_UPDATE_MASK_B1 0x03E7CF93
#define PI_DEFAULT_UPDATE_MASK_A_B2 0xFBC7CF9C
#define PI_DEFAULT_UPDATE_MASK_APLUS_BPLUS 0x0080480FFFFFFCLL
#define PI_DEFAULT_UPDATE_MASK_ZERO 0x0080000FFFFFFCLL
#define PI_DEFAULT_UPDATE_MASK_PI2B 0x0080480FFFFFFCLL
#define PI_DEFAULT_UPDATE_MASK_PI3B 0x0000000FFFFFFCLL
#define PI_DEFAULT_UPDATE_MASK_COMPUTE 0x00FFFFFFFFFFFFLL
#define PI_DEFAULT_MEM_ALLOC_MODE PI_MEM_ALLOC_AUTO
#define PI_DEFAULT_CFG_INTERNALS 0
@ -5179,4 +5191,3 @@ after this command is issued.
#endif

View File

@ -270,7 +270,7 @@ import threading
import os
import atexit
VERSION = "1.29"
VERSION = "1.30"
exceptions = True
@ -458,7 +458,7 @@ _PI_CMD_FG =97
_PI_CMD_FN =98
_PI_CMD_WVTXM=100
_PI_CMD_WVAT =101
_PI_CMD_WVTAT=101
# pigpio error numbers
@ -622,7 +622,7 @@ _errors=[
[_PI_BAD_CHANNEL , "DMA channel not 0-14"],
[_PI_BAD_SOCKET_PORT , "socket port not 1024-30000"],
[_PI_BAD_FIFO_COMMAND , "unknown fifo command"],
[_PI_BAD_SECO_CHANNEL , "DMA secondary channel not 0-6"],
[_PI_BAD_SECO_CHANNEL , "DMA secondary channel not 0-14"],
[_PI_NOT_INITIALISED , "function called before gpioInitialise"],
[_PI_INITIALISED , "function called after gpioInitialise"],
[_PI_BAD_WAVE_MODE , "waveform mode not 0-1"],

View File

@ -51,8 +51,8 @@ default 14
.IP "\fB-e value\fP"
secondary DMA channel
0-6
default 5
0-14
default 6
.IP "\fB-f\fP"
disable fifo interface
@ -137,11 +137,11 @@ Only the user GPIO for the board type or those specified by the -x option may be
.br
.EX
Type 1 boards 0x03E6CF93
Type 1 boards 0x03E6CF93 (26 pin header)
.br
Type 2 boards 0xFBC6CF9C
Type 2 boards 0xFBC6CF9C (26 pin + 8 pin header)
.br
Type 3 boards 0x0FFFFFFC
Type 3 boards 0x0FFFFFFC (40 pin header)
.br
.EE
@ -173,23 +173,78 @@ affect updateable GPIO.
.br
.br
There are several special cases.
.SS Exceptions
.br
.br
The following exceptions are made for particular models.
.br
.br
The activity LED (green) may be written (GPIO 16 for type 1 and 2
boards, GPIO 47 for type 3 boards)
.SS Models A and B
.br
.br
The green activity LED (GPIO 16) may be written.
.br
.SS Models A+ and B+
.br
.br
The green activity LED (GPIO 47) may be written.
.br
The red power LED (GPIO 35) may be written.
.br
The high USB power mode (GPIO 38) may be written.
.br
.SS Pi Zero
.br
.br
The green activity LED (GPIO 47) may be written.
.br
.SS Pi2B
.br
.br
The green activity LED (GPIO 47) may be written.
.br
The red power LED (GPIO 35) may be written.
.br
The high USB power mode (GPIO 38) may be written.
.br
.SS Pi3B
.br
.br
The green activity LED and the red power LED are not writable.
.br
The USB power mode is fixed at 1.2 amps (high power).
.br
.br
.br
The power LED (red) may be written on type 3 boards (GPIO 35).
.SS DMA Channels
.br
.br
The secondary channel is only used for the transmission of waves.
.br
.br
If possible use one of channels 0 to 6 for the secondary channel (a full channel).
.br
.br
A full channel only requires one DMA control block regardless of the length of a pulse delay. Channels 7 to 14 (lite channels) require one DMA control block for each 16383 microseconds of delay. I.e. a 10 second pulse delay requires one control block on a full channel and 611 control blocks on a lite channel.
.br
.br
The high USB power mode GPIO may be written (GPIO 38 for type 3 boards).
.SH SEE ALSO

View File

@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
*/
/*
This version is for pigpio version 43+
This version is for pigpio version 48+
*/
#include <sys/types.h>
@ -90,7 +90,7 @@ void usage()
" -b value, gpio sample buffer in milliseconds, default 120\n" \
" -c value, library internal settings, default 0\n" \
" -d value, primary DMA channel, 0-14, default 14\n" \
" -e value, secondary DMA channel, 0-6, default 5\n" \
" -e value, secondary DMA channel, 0-14, default 6\n" \
" -f, disable fifo interface, default enabled\n" \
" -k, disable socket interface, default enabled\n" \
" -l, localhost socket only default all interfaces\n" \
@ -149,14 +149,14 @@ static void initOpts(int argc, char *argv[])
case 'd':
i = getNum(optarg, &err);
if ((i >= PI_MIN_DMA_CHANNEL) && (i <= PI_MAX_PRIMARY_CHANNEL))
if ((i >= PI_MIN_DMA_CHANNEL) && (i <= PI_MAX_DMA_CHANNEL))
DMAprimaryChannel = i;
else fatal("invalid -d option (%d)", i);
break;
case 'e':
i = getNum(optarg, &err);
if ((i >= PI_MIN_DMA_CHANNEL) && (i <= PI_MAX_SECONDARY_CHANNEL))
if ((i >= PI_MIN_DMA_CHANNEL) && (i <= PI_MAX_DMA_CHANNEL))
DMAsecondaryChannel = i;
else fatal("invalid -e option (%d)", i);
break;

View File

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

View File

@ -1,5 +1,5 @@
/*
gcc -o x_pigpio x_pigpio.c -lpigpio -lrt -lpthread
gcc -Wall -pthread -o x_pigpio x_pigpio.c -lpigpio
sudo ./x_pigpio
*** WARNING ************************************************
@ -45,7 +45,7 @@ void CHECK(int t, int st, int got, int expect, int pc, char *desc)
void t0()
{
printf("Version.\n");
printf("\nTesting pigpio C I/F\n");
printf("pigpio version %d.\n", gpioVersion());
@ -392,7 +392,8 @@ To the lascivious pleasing of a lute.\n\
wid = gpioWaveCreate();
e = gpioWaveTxSend(wid, PI_WAVE_MODE_REPEAT);
CHECK(5, 3, e, 9, 0, "wave tx repeat");
if (e < 14) CHECK(5, 3, e, 9, 0, "wave tx repeat");
else CHECK(5, 3, e, 19, 0, "wave tx repeat");
oc = t5_count;
time_sleep(5);
@ -413,7 +414,8 @@ To the lascivious pleasing of a lute.\n\
wid = gpioWaveCreate();
e = gpioWaveTxSend(wid, PI_WAVE_MODE_ONE_SHOT);
CHECK(5, 8, e, 6811, 0, "wave tx start");
if (e < 6964) CHECK(5, 8, e, 6811, 0, "wave tx start");
else CHECK(5, 8, e, 7116, 0, "wave tx start");
CHECK(5, 9, 0, 0, 0, "NOT APPLICABLE");
@ -447,10 +449,12 @@ To the lascivious pleasing of a lute.\n\
CHECK(5, 18, c, 12000, 0, "wave get max pulses");
c = gpioWaveGetCbs();
CHECK(5, 19, c, 6810, 0, "wave get cbs");
if (e < 6963) CHECK(5, 19, c, 6810, 0, "wave get cbs");
else CHECK(5, 19, c, 7115, 0, "wave get cbs");
c = gpioWaveGetHighCbs();
CHECK(5, 20, c, 6810, 0, "wave get high cbs");
if (e < 6963) CHECK(5, 20, c, 6810, 0, "wave get high cbs");
else CHECK(5, 20, c, 7115, 0, "wave get high cbs");
c = gpioWaveGetMaxCbs();
CHECK(5, 21, c, 25016, 0, "wave get max cbs");

View File

@ -45,14 +45,14 @@ def CHECK(t, st, got, expect, pc, desc):
def t0():
print("Version.")
print("\nTesting pigpio Python module {}".format(pigpio.VERSION))
print("Python {}".format(sys.version.replace("\n", " ")))
print("pigpio version {}.".format(pi.get_pigpio_version()))
print("Hardware revision {}.".format(pi.get_hardware_revision()))
print("Python version {}.".format(sys.version.replace("\n", " ")))
def t1():
print("Mode/PUD/read/write tests.")
@ -361,7 +361,10 @@ To the lascivious pleasing of a lute.
wid = pi.wave_create()
e = pi.wave_send_repeat(wid)
CHECK(5, 3, e, 9, 0, "wave send repeat")
if e < 14:
CHECK(5, 3, e, 9, 0, "wave send repeat")
else:
CHECK(5, 3, e, 19, 0, "wave send repeat")
oc = t5_count
time.sleep(5)
@ -380,7 +383,10 @@ To the lascivious pleasing of a lute.
wid = pi.wave_create()
e = pi.wave_send_once(wid)
CHECK(5, 8, e, 6811, 0, "wave send once")
if e < 6964:
CHECK(5, 8, e, 6811, 0, "wave send once")
else:
CHECK(5, 8, e, 7116, 0, "wave send once")
oc = t5_count
time.sleep(3)
@ -417,7 +423,10 @@ To the lascivious pleasing of a lute.
CHECK(5, 18, c, 12000, 0, "wave get max pulses")
c = pi.wave_get_cbs()
CHECK(5, 19, c, 6810, 0, "wave get cbs")
if c < 6963:
CHECK(5, 19, c, 6810, 0, "wave get cbs")
else:
CHECK(5, 19, c, 7115, 0, "wave get cbs")
CHECK(5, 20, 0, 0, 0, "NOT APPLICABLE")
@ -434,7 +443,10 @@ To the lascivious pleasing of a lute.
CHECK(5, 24, w1, 0, 0, "wave create")
e = pi.wave_send_repeat(w1)
CHECK(5, 25, e, 9, 0, "wave send repeat")
if e < 14:
CHECK(5, 25, e, 9, 0, "wave send repeat")
else:
CHECK(5, 25, e, 19, 0, "wave send repeat")
oc = t5_count
time.sleep(5)
@ -451,7 +463,10 @@ To the lascivious pleasing of a lute.
CHECK(5, 29, w2, 1, 0, "wave create")
e = pi.wave_send_once(w2)
CHECK(5, 30, e, 6811, 0, "wave send once")
if e < 6964:
CHECK(5, 30, e, 6811, 0, "wave send once")
else:
CHECK(5, 30, e, 7116, 0, "wave send once")
oc = t5_count
time.sleep(3)

View File

@ -1,5 +1,5 @@
/*
gcc -o x_pigpiod_if x_pigpiod_if.c -lpigpiod_if -lrt -lpthread
gcc -Wall -pthread -o x_pigpiod_if x_pigpiod_if.c -lpigpiod_if
./x_pigpiod_if
*** WARNING ************************************************
@ -42,7 +42,7 @@ void CHECK(int t, int st, int got, int expect, int pc, char *desc)
void t0()
{
printf("Version.\n");
printf("\nTesting pigpiod C I/F 1\n");
printf("pigpio version %d.\n", get_pigpio_version());
@ -360,7 +360,8 @@ To the lascivious pleasing of a lute.\n\
wid = wave_create();
e = wave_send_repeat(wid);
CHECK(5, 3, e, 9, 0, "wave tx repeat");
if (e < 14) CHECK(5, 3, e, 9, 0, "wave tx repeat");
else CHECK(5, 3, e, 19, 0, "wave tx repeat");
oc = t5_count;
time_sleep(5.05);
@ -379,7 +380,8 @@ To the lascivious pleasing of a lute.\n\
wid = wave_create();
e = wave_send_once(wid);
CHECK(5, 8, e, 6811, 0, "wave tx start");
if (e < 6964) CHECK(5, 8, e, 6811, 0, "wave tx start");
else CHECK(5, 8, e, 7116, 0, "wave tx start");
oc = t5_count;
time_sleep(3);
@ -419,10 +421,12 @@ To the lascivious pleasing of a lute.\n\
CHECK(5, 18, c, 12000, 0, "wave get max pulses");
c = wave_get_cbs();
CHECK(5, 19, c, 6810, 0, "wave get cbs");
if (c < 6963) CHECK(5, 19, c, 6810, 0, "wave get cbs");
else CHECK(5, 19, c, 7115, 0, "wave get cbs");
c = wave_get_high_cbs();
CHECK(5, 20, c, 6810, 0, "wave get high cbs");
if (c < 6963) CHECK(5, 20, c, 6810, 0, "wave get high cbs");
else CHECK(5, 20, c, 7115, 0, "wave get high cbs");
c = wave_get_max_cbs();
CHECK(5, 21, c, 25016, 0, "wave get max cbs");

View File

@ -1,5 +1,5 @@
/*
gcc -o x_pigpiod_if2 x_pigpiod_if2.c -lpigpiod_if2 -lpthread
gcc -Wall -pthread -o x_pigpiod_if2 x_pigpiod_if2.c -lpigpiod_if2
./x_pigpiod_if2
*** WARNING ************************************************
@ -42,7 +42,7 @@ void CHECK(int t, int st, int got, int expect, int pc, char *desc)
void t0(int pi)
{
printf("Version.\n");
printf("\nTesting pigpiod C I/F 2\n");
printf("pigpio version %d.\n", get_pigpio_version(pi));
@ -364,7 +364,8 @@ To the lascivious pleasing of a lute.\n\
wid = wave_create(pi);
e = wave_send_repeat(pi, wid);
CHECK(5, 3, e, 9, 0, "wave tx repeat");
if (e < 14) CHECK(5, 3, e, 9, 0, "wave tx repeat");
else CHECK(5, 3, e, 19, 0, "wave tx repeat");
oc = t5_count;
time_sleep(5.05);
@ -383,7 +384,8 @@ To the lascivious pleasing of a lute.\n\
wid = wave_create(pi);
e = wave_send_once(pi, wid);
CHECK(5, 8, e, 6811, 0, "wave tx start");
if (e < 6964) CHECK(5, 8, e, 6811, 0, "wave tx start");
else CHECK(5, 8, e, 7116, 0, "wave tx start");
oc = t5_count;
time_sleep(3);
@ -423,10 +425,12 @@ To the lascivious pleasing of a lute.\n\
CHECK(5, 18, c, 12000, 0, "wave get max pulses");
c = wave_get_cbs(pi);
CHECK(5, 19, c, 6810, 0, "wave get cbs");
if (c < 6963) CHECK(5, 19, c, 6810, 0, "wave get cbs");
else CHECK(5, 19, c, 7115, 0, "wave get cbs");
c = wave_get_high_cbs(pi);
CHECK(5, 20, c, 6810, 0, "wave get high cbs");
if (c < 6963) CHECK(5, 20, c, 6810, 0, "wave get high cbs");
else CHECK(5, 20, c, 7115, 0, "wave get high cbs");
c = wave_get_max_cbs(pi);
CHECK(5, 21, c, 25016, 0, "wave get max cbs");

22
x_pigs
View File

@ -19,7 +19,8 @@ GPIO=25
# of tests indicate a problem.
#
echo "Testing pigs I/F"
echo
echo "Testing pigpio pigs"
s=$(pigs pigpv)
echo "pigpio version $s"
@ -250,8 +251,13 @@ s=$(pigs wvag 16 0 5000000 0 16 5000000)
if [[ $s = 310 ]]; then echo "WVAG ok"; else echo "WVAG fail ($s)"; fi
w=$(pigs wvcre)
if [[ $w -ge 0 ]]; then echo "WVCRE ok"; else echo "WVCRE fail ($s)"; fi
s=$(pigs wvtx $w)
if [[ $s = 621 ]]; then echo "WVTX ok"; else echo "WVTX fail ($s)"; fi
if [[ ($s = 621) || ($s = 1137) ]]
then echo "WVTX ok"
else echo "WVTX fail ($s)"
fi
s=$(pigs wvbsy)
if [[ $s = 1 ]]; then echo "WVBSY-a ok"; else echo "WVBSY-a fail ($s)"; fi
sleep 1
@ -262,7 +268,11 @@ if [[ $s = "" ]]; then echo "WVHLT ok"; else echo "WVHLT fail ($s)"; fi
s=$(pigs wvbsy)
if [[ $s = 0 ]]; then echo "WVBSY-c ok"; else echo "WVBSY-c fail ($s)"; fi
s=$(pigs wvtxr $w)
if [[ $s = 621 ]]; then echo "WVTXR ok"; else echo "WVTXR fail ($s)"; fi
if [[ ($s = 621) || ($s = 1137) ]]
then echo "WVTXR ok"
else echo "WVTXR fail ($s)"
fi
s=$(pigs wvbsy)
if [[ $s = 1 ]]; then echo "WVBSY-d ok"; else echo "WVBSY-d fail ($s)"; fi
s=$(pigs wvhlt)
@ -271,7 +281,11 @@ s=$(pigs wvbsy)
if [[ $s = 0 ]]; then echo "WVBSY-e ok"; else echo "WVBSY-e fail ($s)"; fi
s=$(pigs wvsc 0)
if [[ $s = 620 ]]; then echo "WVSC-a ok"; else echo "WVSC-a fail ($s)"; fi
if [[ ($s = 620) || ($s = 933) ]]
then echo "WVSC-a ok"
else echo "WVSC-a fail ($s)"
fi
s=$(pigs wvsc 1)
if [[ $s -ge 620 ]]; then echo "WVSC-b ok"; else echo "WVSC-b fail ($s)"; fi
s=$(pigs wvsc 2)

24
x_pipe
View File

@ -18,7 +18,8 @@ GPIO=25
# of tests indicate a problem.
#
echo "Testing pipe I/F"
echo
echo "Testing pigpio pipe I/F"
echo "pigpv" >/dev/pigpio
read -t 1 s </dev/pigout
@ -347,7 +348,12 @@ read -t 1 w </dev/pigout
if [[ $w -ge 0 ]]; then echo "WVCRE ok"; else echo "WVCRE fail ($s)"; fi
echo "wvtx $w" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 433 ]]; then echo "WVTX ok"; else echo "WVTX fail ($s)"; fi
if [[ ($s = 433) || ($s = 977) ]]
then echo "WVTX ok"
else echo "WVTX fail ($s)"
fi
echo "wvbsy" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 1 ]]; then echo "WVBSY-a ok"; else echo "WVBSY-a fail ($s)"; fi
@ -363,7 +369,12 @@ read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "WVBSY-c ok"; else echo "WVBSY-c fail ($s)"; fi
echo "wvtxr $w" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 433 ]]; then echo "WVTXR ok"; else echo "WVTXR fail ($s)"; fi
if [[ ($s = 433) || ($s = 977) ]]
then echo "WVTXR ok"
else echo "WVTXR fail ($s)"
fi
echo "wvbsy" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 1 ]]; then echo "WVBSY-d ok"; else echo "WVBSY-d fail ($s)"; fi
@ -376,7 +387,12 @@ if [[ $s = 0 ]]; then echo "WVBSY-e ok"; else echo "WVBSY-e fail ($s)"; fi
echo "wvsc 0" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 432 ]]; then echo "WVSC-a ok"; else echo "WVSC-a fail ($s)"; fi
if [[ ($s = 432) || ($s = 743) ]]
then echo "WVSC-a ok"
else echo "WVSC-a fail ($s)"
fi
echo "wvsc 1" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s -ge 432 ]]; then echo "WVSC-b ok"; else echo "WVSC-b fail ($s)"; fi