From 71e1283508da9dfe47d8d813ae692e253d73e687 Mon Sep 17 00:00:00 2001 From: bsongis Date: Wed, 6 Jun 2012 10:24:05 +0000 Subject: [PATCH] Somo14D interrupt was blocking. pushPrompt needs a CLI to write TIMSK4 --- src/gruvin9x/somo14d.cpp | 158 +++++++++++++++++++++------------------ 1 file changed, 87 insertions(+), 71 deletions(-) diff --git a/src/gruvin9x/somo14d.cpp b/src/gruvin9x/somo14d.cpp index cd12fc61d..b62b6206d 100644 --- a/src/gruvin9x/somo14d.cpp +++ b/src/gruvin9x/somo14d.cpp @@ -59,102 +59,118 @@ volatile uint8_t somo14WIdx = 0; #ifdef SIMU #define BUSY busy -bool TIMER4_COMPA_vect() #else #define BUSY -ISR(TIMER4_COMPA_vect) //Every 0.5ms #endif + +NOINLINE uint8_t SomoWakeup() { static uint16_t somo14_current; - static uint8_t i=0; - static uint8_t busy=0; // debugging make BOOL when done - static uint8_t startstop=SOMOSSBIT; // Only the first playback can have this short delay - - OCR4A = 0x7d; //another 0.5ms + static uint8_t i = 0; + static uint8_t busy = 0; // debugging make BOOL when done + static uint8_t startstop = SOMOSSBIT; // Only the first playback can have this short delay // printf("startstop=%d i=%d\n", startstop, i); fflush(stdout); - // Send no data unless we are either not busy or it's a command +// Send no data unless we are either not busy or it's a command - // Only when stop bit is sent do we increment read pointer - // This will happen before the SOMO14D busy flag gets set - // Busy flag happens 20ms after the last data is clocked in - if (i==0 && !busy) { - if(somo14command) { // Allow a command to be send even if the SOMO is busy, i.e. STOP or PAUSE - somo14_current=somo14command; - busy=1; + // Only when stop bit is sent do we increment read pointer + // This will happen before the SOMO14D busy flag gets set + // Busy flag happens 20ms after the last data is clocked in + if (i==0 && !busy) { + if(somo14command) { // Allow a command to be send even if the SOMO is busy, i.e. STOP or PAUSE + somo14_current = somo14command; + busy = 1; + } + else if (!SOMOBUSY) { + if (somo14RIdx == somo14WIdx) { + return 1; } - else if (!SOMOBUSY) { - if (somo14RIdx == somo14WIdx) { - TIMSK4 &= ~(1<