From 58c5ad756bb751fab80619ac89d19fbe8bbd8829 Mon Sep 17 00:00:00 2001 From: Guy McSwain Date: Wed, 4 Mar 2020 01:25:01 -0600 Subject: [PATCH] Skip wave padding when size = 0 --- pigpio.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/pigpio.c b/pigpio.c index 45d274f..a2aeb66 100644 --- a/pigpio.c +++ b/pigpio.c @@ -3130,24 +3130,27 @@ static int wave2Cbs(unsigned wave_mode, int *CB, int *BOOL, int *TOOL, int size) } } - /* pad the wave */ - botCB = *CB + NUM_WAVE_CBS / size - 1; - botOOL = *BOOL + NUM_WAVE_OOL / size - 1; - //topOOL = *TOOL - (NUM_WAVE_OOL / size / 8); + if (size) + { + /* pad the wave */ - /* link the last CB to end of wave */ + botCB = *CB + NUM_WAVE_CBS / size - 1; + botOOL = *BOOL + NUM_WAVE_OOL / size - 1; + //topOOL = //Fix: Ignore topOOL, flags not supported. - 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; + /* 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) {