mirror of https://github.com/joan2937/pigpio
Add test cases to x_* for padded waves.
This commit is contained in:
parent
b229b67ce0
commit
c27a968bcc
45
x_pigpio.c
45
x_pigpio.c
|
@ -459,6 +459,51 @@ To the lascivious pleasing of a lute.\n\
|
||||||
|
|
||||||
c = gpioWaveGetMaxCbs();
|
c = gpioWaveGetMaxCbs();
|
||||||
CHECK(5, 21, c, 25016, 0, "wave get max cbs");
|
CHECK(5, 21, c, 25016, 0, "wave get max cbs");
|
||||||
|
|
||||||
|
/* waveCreatePad tests */
|
||||||
|
gpioWaveTxStop();
|
||||||
|
gpioWaveClear();
|
||||||
|
gpioSetAlertFunc(GPIO, t5cbf);
|
||||||
|
|
||||||
|
e = gpioWaveAddGeneric(2, (gpioPulse_t[])
|
||||||
|
{ {1<<GPIO, 0, 10000},
|
||||||
|
{0, 1<<GPIO, 30000}
|
||||||
|
});
|
||||||
|
wid = gpioWaveCreatePad(50, 50, 0);
|
||||||
|
CHECK(5, 22, wid, 0, 0, "wave create pad, count==1, wid==");
|
||||||
|
|
||||||
|
e = gpioWaveAddGeneric(4, (gpioPulse_t[])
|
||||||
|
{ {1<<GPIO, 0, 10000},
|
||||||
|
{0, 1<<GPIO, 30000},
|
||||||
|
{1<<GPIO, 0, 60000},
|
||||||
|
{0, 1<<GPIO, 100000}
|
||||||
|
});
|
||||||
|
wid = gpioWaveCreatePad(50, 50, 0);
|
||||||
|
CHECK(5, 23, wid, 1, 0, "wave create pad, count==2, wid==");
|
||||||
|
|
||||||
|
c = gpioWaveDelete(0);
|
||||||
|
CHECK(5, 24, c, 0, 0, "delete wid==0 success");
|
||||||
|
|
||||||
|
e = gpioWaveAddGeneric(6, (gpioPulse_t[])
|
||||||
|
{ {1<<GPIO, 0, 10000},
|
||||||
|
{0, 1<<GPIO, 30000},
|
||||||
|
{1<<GPIO, 0, 60000},
|
||||||
|
{0, 1<<GPIO, 100000},
|
||||||
|
{1<<GPIO, 0, 60000},
|
||||||
|
{0, 1<<GPIO, 100000}
|
||||||
|
});
|
||||||
|
c = gpioWaveCreate();
|
||||||
|
CHECK(5, 25, c, -67, 0, "No more CBs using wave create");
|
||||||
|
wid = gpioWaveCreatePad(50, 50, 0);
|
||||||
|
CHECK(5, 26, wid, 0, 0, "wave create pad, count==3, wid==");
|
||||||
|
|
||||||
|
t5_count = 0;
|
||||||
|
e = gpioWaveChain((char[]) {1,0}, 2);
|
||||||
|
CHECK(5, 27, e, 0, 0, "wave chain [1,0]");
|
||||||
|
while (gpioWaveTxBusy()) time_sleep(0.1);
|
||||||
|
CHECK(5, 28, t5_count, 5, 1, "callback count==");
|
||||||
|
|
||||||
|
gpioSetAlertFunc(GPIO, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int t6_count;
|
int t6_count;
|
||||||
|
|
41
x_pigpio.py
41
x_pigpio.py
|
@ -483,6 +483,47 @@ To the lascivious pleasing of a lute.
|
||||||
e = pi.wave_delete(0)
|
e = pi.wave_delete(0)
|
||||||
CHECK(5, 33, e, 0, 0, "wave delete")
|
CHECK(5, 33, e, 0, 0, "wave delete")
|
||||||
|
|
||||||
|
# wave_create_and_pad tests
|
||||||
|
t5cb = pi.callback(GPIO, pigpio.FALLING_EDGE, t5cbf)
|
||||||
|
pi.wave_clear()
|
||||||
|
|
||||||
|
pi.wave_add_generic([pigpio.pulse(1<<GPIO, 0, 10000),
|
||||||
|
pigpio.pulse(0, 1<<GPIO, 30000)])
|
||||||
|
wid = pi.wave_create_and_pad(50)
|
||||||
|
CHECK(5, 34, wid, 0, 0, "wave create and pad, wid==")
|
||||||
|
|
||||||
|
pi.wave_add_generic([pigpio.pulse(1<<GPIO, 0, 10000),
|
||||||
|
pigpio.pulse(0, 1<<GPIO, 30000),
|
||||||
|
pigpio.pulse(1<<GPIO, 0, 60000),
|
||||||
|
pigpio.pulse(0, 1<<GPIO, 100000)])
|
||||||
|
wid = pi.wave_create_and_pad(50)
|
||||||
|
CHECK(5, 35, wid, 1, 0, "wave create and pad, wid==")
|
||||||
|
|
||||||
|
c = pi.wave_delete(0);
|
||||||
|
CHECK(5, 36, c, 0, 0, "delete wid==0 success");
|
||||||
|
|
||||||
|
pi.wave_add_generic([pigpio.pulse(1<<GPIO, 0, 10000),
|
||||||
|
pigpio.pulse(0, 1<<GPIO, 30000),
|
||||||
|
pigpio.pulse(1<<GPIO, 0, 60000),
|
||||||
|
pigpio.pulse(0, 1<<GPIO, 100000),
|
||||||
|
pigpio.pulse(1<<GPIO, 0, 60000),
|
||||||
|
pigpio.pulse(0, 1<<GPIO, 100000)])
|
||||||
|
pigpio.exceptions = False
|
||||||
|
c = pi.wave_create()
|
||||||
|
CHECK(5, 37, c, -67, 0, "No more CBs using wave create")
|
||||||
|
pigpio.exceptions = True
|
||||||
|
|
||||||
|
wid = pi.wave_create_and_pad(50)
|
||||||
|
CHECK(5, 38, wid, 0, 0, "wave create pad, count==3, wid==")
|
||||||
|
|
||||||
|
t5_count = 0;
|
||||||
|
e = pi.wave_chain([1,0])
|
||||||
|
CHECK(5, 39, e, 0, 0, "wave chain [1,0]")
|
||||||
|
while pi.wave_tx_busy():
|
||||||
|
time.sleep(0.2)
|
||||||
|
CHECK(5, 40, t5_count, 10, 1, "callback count==")
|
||||||
|
|
||||||
|
|
||||||
t5cb.cancel()
|
t5cb.cancel()
|
||||||
|
|
||||||
t6_count=0
|
t6_count=0
|
||||||
|
|
|
@ -434,6 +434,50 @@ To the lascivious pleasing of a lute.\n\
|
||||||
CHECK(5, 21, c, 25016, 0, "wave get max cbs");
|
CHECK(5, 21, c, 25016, 0, "wave get max cbs");
|
||||||
|
|
||||||
callback_cancel(id);
|
callback_cancel(id);
|
||||||
|
|
||||||
|
/* wave create and pad tests */
|
||||||
|
id = callback(pi, GPIO, FALLING_EDGE, t5cbf);
|
||||||
|
e = wave_clear(pi);
|
||||||
|
|
||||||
|
e = wave_add_generic(pi, 2, (gpioPulse_t[])
|
||||||
|
{ {1<<GPIO, 0, 10000},
|
||||||
|
{0, 1<<GPIO, 30000}
|
||||||
|
});
|
||||||
|
wid = wave_create_and_pad(pi, 50);
|
||||||
|
CHECK(5, 22, wid, 0, 0, "wave create pad, count==1, wid==");
|
||||||
|
|
||||||
|
e = wave_add_generic(pi, 4, (gpioPulse_t[])
|
||||||
|
{ {1<<GPIO, 0, 10000},
|
||||||
|
{0, 1<<GPIO, 30000},
|
||||||
|
{1<<GPIO, 0, 60000},
|
||||||
|
{0, 1<<GPIO, 100000}
|
||||||
|
});
|
||||||
|
wid = wave_create_and_pad(pi, 50);
|
||||||
|
CHECK(5, 23, wid, 1, 0, "wave create pad, count==2, wid==");
|
||||||
|
|
||||||
|
c = wave_delete(pi, 0);
|
||||||
|
CHECK(5, 24, c, 0, 0, "delete wid==0 success");
|
||||||
|
|
||||||
|
e = wave_add_generic(pi, 6, (gpioPulse_t[])
|
||||||
|
{ {1<<GPIO, 0, 10000},
|
||||||
|
{0, 1<<GPIO, 30000},
|
||||||
|
{1<<GPIO, 0, 60000},
|
||||||
|
{0, 1<<GPIO, 100000},
|
||||||
|
{1<<GPIO, 0, 60000},
|
||||||
|
{0, 1<<GPIO, 100000}
|
||||||
|
});
|
||||||
|
c = wave_create(pi);
|
||||||
|
CHECK(5, 25, c, -67, 0, "No more CBs using wave create");
|
||||||
|
wid = wave_create_and_pad(pi, 50);
|
||||||
|
CHECK(5, 26, wid, 0, 0, "wave create pad, count==3, wid==");
|
||||||
|
|
||||||
|
t5_count = 0;
|
||||||
|
e = wave_chain(pi, (char[]) {1,0}, 2);
|
||||||
|
CHECK(5, 27, e, 0, 0, "wave chain [1,0]");
|
||||||
|
while (wave_tx_busy(pi)) time_sleep(0.1);
|
||||||
|
CHECK(5, 28, t5_count, 5, 1, "callback count==");
|
||||||
|
|
||||||
|
callback_cancel(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int t6_count=0;
|
int t6_count=0;
|
||||||
|
|
20
x_pigs
20
x_pigs
|
@ -308,3 +308,23 @@ if [[ $s -ge 310 ]]; then echo "WVSP-b ok"; else echo "WVSP-b fail ($s)"; fi
|
||||||
s=$(pigs wvsp 2)
|
s=$(pigs wvsp 2)
|
||||||
if [[ $s = 12000 ]]; then echo "WVSP-c ok"; else echo "WVSP-c fail ($s)"; fi
|
if [[ $s = 12000 ]]; then echo "WVSP-c ok"; else echo "WVSP-c fail ($s)"; fi
|
||||||
|
|
||||||
|
s=$(pigs wvclr )
|
||||||
|
s=$(pigs wvag 16 0 5000000 0 16 5000000)
|
||||||
|
wid=$(pigs wvcap 50)
|
||||||
|
if [[ $wid = 0 ]]; then echo "WVCAP-a ok"; else echo "WVCAP-a fail ($wid)"; fi
|
||||||
|
|
||||||
|
s=$(pigs wvag 16 0 5000000 0 16 5000000 16 0 5000000 0 16 5000000)
|
||||||
|
wid=$(pigs wvcap 50)
|
||||||
|
if [[ $wid = 1 ]]; then echo "WVCAP-b ok"; else echo "WVCAP-b fail ($wid)"; fi
|
||||||
|
|
||||||
|
s=$(pigs wvdel 0)
|
||||||
|
if [[ $s == "" ]]; then echo "WVCAP-c ok"; else echo "WVCAP-c fail ($s)"; fi
|
||||||
|
|
||||||
|
s=$(pigs wvag 16 0 5000000 0 16 5000000 16 0 5000000 0 16 5000000 16 0 5000000 0 16 5000000)
|
||||||
|
# Show WVCRE fails
|
||||||
|
wid=$(pigs wvcre)
|
||||||
|
if [[ $wid = -67 ]]; then echo "WVCAP-d ok"; else echo "WVCAP-d fail ($wid)"; fi
|
||||||
|
# but that WVCAP ok
|
||||||
|
wid=$(pigs wvcap 50)
|
||||||
|
if [[ $wid = 0 ]]; then echo "WVCAP-e ok"; else echo "WVCAP-e fail ($wid)"; fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue