mirror of https://github.com/joan2937/pigpio
V15
This commit is contained in:
parent
306b9ad30b
commit
590274dc7f
19
pigpio.c
19
pigpio.c
|
@ -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 14 */
|
/* pigpio version 15 */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -774,7 +774,7 @@ static struct timespec libStarted;
|
||||||
|
|
||||||
static uint64_t gpioMask;
|
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};
|
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_HWVER: res = gpioHardwareRevision(); break;
|
||||||
|
|
||||||
case PI_CMD_MICS:
|
case PI_CMD_MICS:
|
||||||
|
DBG(0,"mics %d", p[1]);
|
||||||
if (p[1] <= PI_MAX_MICS_DELAY) myGpioDelay(p[1]);
|
if (p[1] <= PI_MAX_MICS_DELAY) myGpioDelay(p[1]);
|
||||||
else res = PI_BAD_MICS_DELAY;
|
else res = PI_BAD_MICS_DELAY;
|
||||||
break;
|
break;
|
||||||
|
@ -1636,7 +1637,7 @@ static int wave2Cbs(unsigned mode)
|
||||||
|
|
||||||
unsigned numWaves;
|
unsigned numWaves;
|
||||||
|
|
||||||
gpioWave_t * waves;
|
rawWave_t * waves;
|
||||||
|
|
||||||
numWaves = wfc[wfcur];
|
numWaves = wfc[wfcur];
|
||||||
waves = wf [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;
|
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;
|
uint32_t tNow, tNext1, tNext2, tDelay;
|
||||||
|
|
||||||
gpioWave_t *in2, *out;
|
rawWave_t *in2, *out;
|
||||||
|
|
||||||
numIn2 = wfc[wfcur];
|
numIn2 = wfc[wfcur];
|
||||||
in2 = wf[wfcur];
|
in2 = wf[wfcur];
|
||||||
|
@ -4416,7 +4417,7 @@ void rawDumpWave(void)
|
||||||
|
|
||||||
unsigned numWaves, t;
|
unsigned numWaves, t;
|
||||||
|
|
||||||
gpioWave_t *waves;
|
rawWave_t *waves;
|
||||||
|
|
||||||
numWaves = wfc[wfcur];
|
numWaves = wfc[wfcur];
|
||||||
waves = wf [wfcur];
|
waves = wf [wfcur];
|
||||||
|
@ -5058,7 +5059,7 @@ int gpioWaveAddGeneric(unsigned numPulses, gpioPulse_t *pulses)
|
||||||
wf[2][p].flags = 0;
|
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].usDelay = bitDelay[0];
|
||||||
wf[2][p].flags = 0;
|
wf[2][p].flags = 0;
|
||||||
|
|
||||||
return waveMerge(p, wf[2]);
|
return rawWaveAddGeneric(p, wf[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
@ -5311,7 +5312,7 @@ int rawWaveAddSPI(
|
||||||
|
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
return waveMerge(p, wf[2]);
|
return rawWaveAddGeneric(p, wf[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
33
pigpio.h
33
pigpio.h
|
@ -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
|
#ifndef PIGPIO_H
|
||||||
|
@ -86,7 +86,7 @@ This version is for pigpio version 14
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#define PIGPIO_VERSION 14
|
#define PIGPIO_VERSION 15
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ typedef struct
|
||||||
uint32_t gpioOff;
|
uint32_t gpioOff;
|
||||||
uint32_t usDelay;
|
uint32_t usDelay;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
} gpioWave_t;
|
} rawWave_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -1981,6 +1981,33 @@ int rawWaveAddSPI(
|
||||||
Not intended for general use.
|
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);
|
unsigned rawWaveCB(void);
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
Loading…
Reference in New Issue