mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-12-26 21:00:48 +02:00
ubb-patgen/ubb-patgen.c: run at realtime priority while waiting for trigger
This commit is contained in:
parent
6d749fafb8
commit
4729d00b30
@ -18,6 +18,7 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <sched.h>
|
||||
#include <assert.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
@ -248,6 +249,36 @@ static const char *load_pattern(const char *s)
|
||||
}
|
||||
|
||||
|
||||
/* ----- Real-time mode ---------------------------------------------------- */
|
||||
|
||||
|
||||
void realtimize(void)
|
||||
{
|
||||
struct sched_param prm;
|
||||
|
||||
prm.sched_priority = sched_get_priority_max(SCHED_FIFO);
|
||||
if (prm.sched_priority < 0) {
|
||||
perror("sched_get_priority_max SCHED_FIFO");
|
||||
exit(1);
|
||||
}
|
||||
if (sched_setscheduler(0, SCHED_FIFO, &prm) < 0) {
|
||||
perror("sched_setscheduler SCHED_FIFO");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void unrealtime(void)
|
||||
{
|
||||
struct sched_param prm = { .sched_priority = 0 };
|
||||
|
||||
if (sched_setscheduler(0, SCHED_OTHER, &prm) < 0) {
|
||||
perror("sched_setscheduler SCHED_OTHER");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ----- DMA control ------------------------------------------------------- */
|
||||
|
||||
|
||||
@ -409,6 +440,8 @@ static void mmc_buffer(const struct mmcclk *clk,
|
||||
|
||||
PDFUNS = mask;
|
||||
|
||||
realtimize();
|
||||
|
||||
if (trigger != -1)
|
||||
wait_trigger(trigger, debounce, debounce_ns);
|
||||
if (wait_ns->tv_sec || wait_ns->tv_nsec)
|
||||
@ -425,6 +458,8 @@ static void mmc_buffer(const struct mmcclk *clk,
|
||||
(1 << 31) | /* no descriptor */
|
||||
1; /* enable transfer */
|
||||
|
||||
unrealtime();
|
||||
|
||||
wait_dma_done();
|
||||
wait_fifo_empty();
|
||||
wait_shifted(clk);
|
||||
|
Loading…
Reference in New Issue
Block a user