mirror of https://github.com/joan2937/pigpio
Wave create using fixed size CB, OOL
This commit is contained in:
parent
ef48a043af
commit
f4a4b9772f
|
@ -201,7 +201,7 @@ cmdInfo_t cmdInfo[]=
|
||||||
{PI_CMD_WVBSY, "WVBSY", 101, 2, 1}, // gpioWaveTxBusy
|
{PI_CMD_WVBSY, "WVBSY", 101, 2, 1}, // gpioWaveTxBusy
|
||||||
{PI_CMD_WVCHA, "WVCHA", 197, 0, 0}, // gpioWaveChain
|
{PI_CMD_WVCHA, "WVCHA", 197, 0, 0}, // gpioWaveChain
|
||||||
{PI_CMD_WVCLR, "WVCLR", 101, 0, 1}, // gpioWaveClear
|
{PI_CMD_WVCLR, "WVCLR", 101, 0, 1}, // gpioWaveClear
|
||||||
{PI_CMD_WVCRE, "WVCRE", 101, 2, 1}, // gpioWaveCreate
|
{PI_CMD_WVCRE, "WVCRE", 112, 2, 1}, // gpioWaveCreate
|
||||||
{PI_CMD_WVDEL, "WVDEL", 112, 0, 1}, // gpioWaveDelete
|
{PI_CMD_WVDEL, "WVDEL", 112, 0, 1}, // gpioWaveDelete
|
||||||
{PI_CMD_WVGO, "WVGO" , 101, 2, 0}, // gpioWaveTxStart
|
{PI_CMD_WVGO, "WVGO" , 101, 2, 0}, // gpioWaveTxStart
|
||||||
{PI_CMD_WVGOR, "WVGOR", 101, 2, 0}, // gpioWaveTxStart
|
{PI_CMD_WVGOR, "WVGOR", 101, 2, 0}, // gpioWaveTxStart
|
||||||
|
|
39
pigpio.c
39
pigpio.c
|
@ -2432,7 +2432,7 @@ static int myDoCommand(uintptr_t *p, unsigned bufSize, char *buf)
|
||||||
|
|
||||||
case PI_CMD_WVCLR: res = gpioWaveClear(); break;
|
case PI_CMD_WVCLR: res = gpioWaveClear(); break;
|
||||||
|
|
||||||
case PI_CMD_WVCRE: res = gpioWaveCreate(); break;
|
case PI_CMD_WVCRE: res = gpioWaveCreate(p[1]); break;
|
||||||
|
|
||||||
case PI_CMD_WVDEL: res = gpioWaveDelete(p[1]); break;
|
case PI_CMD_WVDEL: res = gpioWaveDelete(p[1]); break;
|
||||||
|
|
||||||
|
@ -2992,7 +2992,7 @@ static void waveCBsOOLs(int *numCBs, int *numBOOLs, int *numTOOLs)
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int wave2Cbs(unsigned wave_mode, int *CB, int *BOOL, int *TOOL)
|
static int wave2Cbs(unsigned wave_mode, int *CB, int *BOOL, int *TOOL, int size)
|
||||||
{
|
{
|
||||||
int botCB=*CB, botOOL=*BOOL, topOOL=*TOOL;
|
int botCB=*CB, botOOL=*BOOL, topOOL=*TOOL;
|
||||||
|
|
||||||
|
@ -3130,6 +3130,25 @@ static int wave2Cbs(unsigned wave_mode, int *CB, int *BOOL, int *TOOL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* pad the wave */
|
||||||
|
botCB = *CB + NUM_WAVE_CBS / size - 1;
|
||||||
|
botOOL = *BOOL + NUM_WAVE_OOL / size - 1;
|
||||||
|
//topOOL = *TOOL - (NUM_WAVE_OOL / size / 8);
|
||||||
|
|
||||||
|
/* link the last CB to end of wave */
|
||||||
|
|
||||||
|
p->next = waveCbPOadr(botCB);
|
||||||
|
|
||||||
|
/* add dummy cb at end of DMA */
|
||||||
|
|
||||||
|
p = rawWaveCBAdr(botCB++);
|
||||||
|
p->info = NORMAL_DMA | DMA_DEST_IGNORE;
|
||||||
|
p->src = waveOOLPOadr(botOOL++);
|
||||||
|
p->dst = ((GPIO_BASE + (GPSET0*4)) & 0x00ffffff) | PI_PERI_BUS;
|
||||||
|
p->length = 4;
|
||||||
|
p->next = 0;
|
||||||
|
|
||||||
|
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
{
|
{
|
||||||
if (wave_mode == PI_WAVE_MODE_ONE_SHOT)
|
if (wave_mode == PI_WAVE_MODE_ONE_SHOT)
|
||||||
|
@ -9552,7 +9571,7 @@ int rawWaveAddSPI(
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
int gpioWaveCreate(void)
|
int gpioWaveCreate(int size) // Fix: Make variadic.
|
||||||
{
|
{
|
||||||
int i, wid;
|
int i, wid;
|
||||||
int numCB, numBOOL, numTOOL;
|
int numCB, numBOOL, numTOOL;
|
||||||
|
@ -9566,7 +9585,14 @@ int gpioWaveCreate(void)
|
||||||
|
|
||||||
/* What resources are needed? */
|
/* What resources are needed? */
|
||||||
|
|
||||||
waveCBsOOLs(&numCB, &numBOOL, &numTOOL);
|
if (size == 0)
|
||||||
|
waveCBsOOLs(&numCB, &numBOOL, &numTOOL);
|
||||||
|
|
||||||
|
else {
|
||||||
|
numCB = NUM_WAVE_CBS / size;
|
||||||
|
numBOOL = NUM_WAVE_OOL / size;
|
||||||
|
numTOOL = 0; // ignore TOOL, ie, no flags support
|
||||||
|
}
|
||||||
|
|
||||||
wid = -1;
|
wid = -1;
|
||||||
|
|
||||||
|
@ -9619,7 +9645,7 @@ int gpioWaveCreate(void)
|
||||||
BOOL = waveInfo[wid].botOOL;
|
BOOL = waveInfo[wid].botOOL;
|
||||||
TOOL = waveInfo[wid].topOOL;
|
TOOL = waveInfo[wid].topOOL;
|
||||||
|
|
||||||
wave2Cbs(PI_WAVE_MODE_ONE_SHOT, &CB, &BOOL, &TOOL);
|
wave2Cbs(PI_WAVE_MODE_ONE_SHOT, &CB, &BOOL, &TOOL, size);
|
||||||
|
|
||||||
/* Sanity check. */
|
/* Sanity check. */
|
||||||
|
|
||||||
|
@ -9633,6 +9659,9 @@ int gpioWaveCreate(void)
|
||||||
numTOOL, waveInfo[wid].topOOL-TOOL);
|
numTOOL, waveInfo[wid].topOOL-TOOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DBG(DBG_USER, "Wave Stats: wid=%d CBs %d BOOL %d TOOL %d", wid,
|
||||||
|
numCB, numBOOL, numTOOL);
|
||||||
|
|
||||||
waveInfo[wid].deleted = 0;
|
waveInfo[wid].deleted = 0;
|
||||||
|
|
||||||
/* Consume waves. */
|
/* Consume waves. */
|
||||||
|
|
2
pigpio.h
2
pigpio.h
|
@ -1933,7 +1933,7 @@ D*/
|
||||||
|
|
||||||
|
|
||||||
/*F*/
|
/*F*/
|
||||||
int gpioWaveCreate(void);
|
int gpioWaveCreate(int);
|
||||||
/*D
|
/*D
|
||||||
This function creates a waveform from the data provided by the prior
|
This function creates a waveform from the data provided by the prior
|
||||||
calls to the [*gpioWaveAdd**] functions. Upon success a wave id
|
calls to the [*gpioWaveAdd**] functions. Upon success a wave id
|
||||||
|
|
|
@ -2257,7 +2257,7 @@ class pi():
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def wave_create(self):
|
def wave_create(self, size):
|
||||||
"""
|
"""
|
||||||
Creates a waveform from the data provided by the prior calls
|
Creates a waveform from the data provided by the prior calls
|
||||||
to the [*wave_add_**] functions.
|
to the [*wave_add_**] functions.
|
||||||
|
@ -2302,7 +2302,7 @@ class pi():
|
||||||
wid = pi.wave_create()
|
wid = pi.wave_create()
|
||||||
...
|
...
|
||||||
"""
|
"""
|
||||||
return _u2i(_pigpio_command(self.sl, _PI_CMD_WVCRE, 0, 0))
|
return _u2i(_pigpio_command(self.sl, _PI_CMD_WVCRE, size, 0))
|
||||||
|
|
||||||
def wave_delete(self, wave_id):
|
def wave_delete(self, wave_id):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -391,7 +391,7 @@ To the lascivious pleasing of a lute.\n\
|
||||||
e = gpioWaveAddGeneric(4, wf);
|
e = gpioWaveAddGeneric(4, wf);
|
||||||
CHECK(5, 2, e, 4, 0, "pulse, wave add generic");
|
CHECK(5, 2, e, 4, 0, "pulse, wave add generic");
|
||||||
|
|
||||||
wid = gpioWaveCreate();
|
wid = gpioWaveCreate(0);
|
||||||
e = gpioWaveTxSend(wid, PI_WAVE_MODE_REPEAT);
|
e = gpioWaveTxSend(wid, PI_WAVE_MODE_REPEAT);
|
||||||
if (e < 14) 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");
|
else CHECK(5, 3, e, 19, 0, "wave tx repeat");
|
||||||
|
@ -413,7 +413,7 @@ To the lascivious pleasing of a lute.\n\
|
||||||
e = gpioWaveAddSerial(GPIO, BAUD, 8, 2, 5000000, strlen(TEXT), TEXT);
|
e = gpioWaveAddSerial(GPIO, BAUD, 8, 2, 5000000, strlen(TEXT), TEXT);
|
||||||
CHECK(5, 7, e, 3405, 0, "wave clear, wave add serial");
|
CHECK(5, 7, e, 3405, 0, "wave clear, wave add serial");
|
||||||
|
|
||||||
wid = gpioWaveCreate();
|
wid = gpioWaveCreate(0);
|
||||||
e = gpioWaveTxSend(wid, PI_WAVE_MODE_ONE_SHOT);
|
e = gpioWaveTxSend(wid, PI_WAVE_MODE_ONE_SHOT);
|
||||||
if (e < 6964) 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");
|
else CHECK(5, 8, e, 7116, 0, "wave tx start");
|
||||||
|
|
Loading…
Reference in New Issue