diff --git a/pigpio.c b/pigpio.c index 0c540d2..cd38591 100644 --- a/pigpio.c +++ b/pigpio.c @@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to */ -/* pigpio version 14 */ +/* pigpio version 15 */ #include #include @@ -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]); } /* ----------------------------------------------------------------------- */ diff --git a/pigpio.h b/pigpio.h index 6b163dd..012868a 100644 --- a/pigpio.h +++ b/pigpio.h @@ -26,7 +26,7 @@ For more information, please refer to */ /* -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 #include -#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); /* ----------------------------------------------------------------------- */