This commit is contained in:
joan 2014-04-19 13:00:51 +01:00
parent 306b9ad30b
commit 590274dc7f
2 changed files with 40 additions and 12 deletions

View File

@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
*/
/* pigpio version 14 */
/* pigpio version 15 */
#include <stdio.h>
#include <string.h>
@ -774,7 +774,7 @@ static struct timespec libStarted;
static uint64_t gpioMask;
static gpioWave_t wf[3][PI_WAVE_MAX_PULSES];
static rawWave_t wf[3][PI_WAVE_MAX_PULSES];
static int wfc[3]={0, 0, 0};
@ -1107,6 +1107,7 @@ static int myDoCommand(uint32_t *p, gpioExtent_t *oExt)
case PI_CMD_HWVER: res = gpioHardwareRevision(); break;
case PI_CMD_MICS:
DBG(0,"mics %d", p[1]);
if (p[1] <= PI_MAX_MICS_DELAY) myGpioDelay(p[1]);
else res = PI_BAD_MICS_DELAY;
break;
@ -1636,7 +1637,7 @@ static int wave2Cbs(unsigned mode)
unsigned numWaves;
gpioWave_t * waves;
rawWave_t * waves;
numWaves = wfc[wfcur];
waves = wf [wfcur];
@ -1862,7 +1863,7 @@ static void waveRxBit(int gpio, int level, uint32_t tick)
/* ----------------------------------------------------------------------- */
static int waveMerge(unsigned numIn1, gpioWave_t *in1)
int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
{
unsigned inPos1=0, inPos2=0, outPos=0, level = NUM_WAVE_OOL;
@ -1872,7 +1873,7 @@ static int waveMerge(unsigned numIn1, gpioWave_t *in1)
uint32_t tNow, tNext1, tNext2, tDelay;
gpioWave_t *in2, *out;
rawWave_t *in2, *out;
numIn2 = wfc[wfcur];
in2 = wf[wfcur];
@ -4416,7 +4417,7 @@ void rawDumpWave(void)
unsigned numWaves, t;
gpioWave_t *waves;
rawWave_t *waves;
numWaves = wfc[wfcur];
waves = wf [wfcur];
@ -5058,7 +5059,7 @@ int gpioWaveAddGeneric(unsigned numPulses, gpioPulse_t *pulses)
wf[2][p].flags = 0;
}
return waveMerge(numPulses, wf[2]);
return rawWaveAddGeneric(numPulses, wf[2]);
}
/* ----------------------------------------------------------------------- */
@ -5171,7 +5172,7 @@ int gpioWaveAddSerial(unsigned gpio,
wf[2][p].usDelay = bitDelay[0];
wf[2][p].flags = 0;
return waveMerge(p, wf[2]);
return rawWaveAddGeneric(p, wf[2]);
}
/* ----------------------------------------------------------------------- */
@ -5311,7 +5312,7 @@ int rawWaveAddSPI(
p++;
return waveMerge(p, wf[2]);
return rawWaveAddGeneric(p, wf[2]);
}
/* ----------------------------------------------------------------------- */

View File

@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
*/
/*
This version is for pigpio version 14
This version is for pigpio version 15
*/
#ifndef PIGPIO_H
@ -86,7 +86,7 @@ This version is for pigpio version 14
#include <stdint.h>
#include <pthread.h>
#define PIGPIO_VERSION 14
#define PIGPIO_VERSION 15
/*-------------------------------------------------------------------------*/
@ -276,7 +276,7 @@ typedef struct
uint32_t gpioOff;
uint32_t usDelay;
uint32_t flags;
} gpioWave_t;
} rawWave_t;
typedef struct
{
@ -1981,6 +1981,33 @@ int rawWaveAddSPI(
Not intended for general use.
*/
/*-------------------------------------------------------------------------*/
int rawWaveAddGeneric(unsigned numPulses, rawWave_t *pulses);
/*-------------------------------------------------------------------------*/
/* This function adds a number of pulses to the current waveform.
Returns the new total number of pulses in the current waveform if OK,
otherwise PI_TOO_MANY_PULSES.
NOTES:
The advantage of this function over gpioWaveAddGeneric is that it
allows the setting of the flags field.
The pulses are interleaved in time order within the existing waveform
(if any).
Merging allows the waveform to be built in parts, that is the settings
for gpio#1 can be added, and then gpio#2 etc.
If the added waveform is intended to start after or within the existing
waveform then the first pulse should consist of a delay.
Not intended for general use.
*/
/* ----------------------------------------------------------------------- */
unsigned rawWaveCB(void);
/* ----------------------------------------------------------------------- */