Mercurial > hg > beaglert
diff core/PRU.cpp @ 50:be427da6fb9c newapi
Removed old testing code that stopped audio after 10 seconds; command line parameter updates; D-Box updates (not fully working yet)
author | andrewm |
---|---|
date | Sat, 30 May 2015 12:34:32 -0500 |
parents | 579c86316008 |
children | a6d223473ea2 |
line wrap: on
line diff
--- a/core/PRU.cpp Thu May 28 17:48:42 2015 -0400 +++ b/core/PRU.cpp Sat May 30 12:34:32 2015 -0500 @@ -420,10 +420,13 @@ // Main loop to read and write data from/to PRU void PRU::loop(RT_INTR *pru_interrupt, void *userData) { +#ifdef BEAGLERT_USE_XENOMAI_INTERRUPTS + RTIME irqTimeout = PRU_SAMPLE_INTERVAL_NS * 1024; // Timeout for PRU interrupt: about 10ms, much longer than any expected period +#else // Polling interval is 1/4 of the period - //RTIME sleepTime = PRU_SAMPLE_INTERVAL_NS * (context->analogChannels / 2) * context->analogFrames / 4; + RTIME sleepTime = PRU_SAMPLE_INTERVAL_NS * (context->analogChannels / 2) * context->analogFrames / 4; +#endif - RTIME irqTimeout = PRU_SAMPLE_INTERVAL_NS * 1024; // Timeout for PRU interrupt: about 10ms, much longer than any expected period float *lastAnalogOutFrame; uint32_t *digitalBuffer0, *digitalBuffer1, *lastDigitalBuffer; uint32_t pru_audio_offset, pru_spi_offset; @@ -468,10 +471,16 @@ } // TESTING - uint32_t testCount = 0; + // uint32_t testCount = 0; // RTIME startTime = rt_timer_read(); +#ifndef BEAGLERT_USE_XENOMAI_INTERRUPTS + // Which buffer the PRU was last processing + uint32_t lastPRUBuffer = 0; +#endif + while(!gShouldStop) { +#ifdef BEAGLERT_USE_XENOMAI_INTERRUPTS // Wait for PRU to move to change buffers; // PRU will send an interrupts which we wait for rt_intr_enable(pru_interrupt); @@ -489,6 +498,14 @@ // Clear pending PRU interrupt prussdrv_pru_clear_event(PRU_EVTOUT_1, PRU1_ARM_INTERRUPT); +#else + // Poll + while(pru_buffer_comm[PRU_CURRENT_BUFFER] == lastPRUBuffer && !gShouldStop) { + rt_task_sleep(sleepTime); + } + + lastPRUBuffer = pru_buffer_comm[PRU_CURRENT_BUFFER]; +#endif if(gShouldStop) break; @@ -512,7 +529,7 @@ // FIXME: some sort of margin is needed here to prevent the audio // code from completely eating the Linux system - testCount++; + // testCount++; //rt_task_sleep(sleepTime*4); //rt_task_sleep(sleepTime/4); @@ -605,12 +622,14 @@ } // FIXME: TESTING!! - if(testCount > 100000) - break; + // if(testCount > 100000) + // break; } +#ifdef BEAGLERT_USE_XENOMAI_INTERRUPTS // Turn off the interrupt for the PRU if it isn't already off rt_intr_disable(pru_interrupt); +#endif // FIXME: TESTING // RTIME endTime = rt_timer_read();