From 540aaccc48f757a7cdd00295b480b47832ee20f3 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Mon, 2 Jul 2012 09:38:29 +1000 Subject: [PATCH] SICS-486: When in timer mode only stop the multicounter when all of the slaves are idle or at the first slave which reports a fault. NOTE: If slave[0] == pause and slave[1] == fault then the multicounter will pause and then possibly fail if slave[1] is still in fault when slave[0] continues. r3626 | ffr | 2012-07-02 09:38:29 +1000 (Mon, 02 Jul 2012) | 5 lines --- multicounter.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/multicounter.c b/multicounter.c index c617b193..a1cf907a 100644 --- a/multicounter.c +++ b/multicounter.c @@ -108,7 +108,7 @@ static int MMCCStart(void *pData, SConnection *pCon) } /*-------------------------------------------------------------------------*/ static int MMCCStatus(void *pData, SConnection *pCon){ - int status,i, controlMonitor; + int status, slaveStatus, i, controlMonitor; pCounter pCountController = NULL; pCounter pCount = NULL; pMultiCounter self = NULL; @@ -127,7 +127,21 @@ static int MMCCStatus(void *pData, SConnection *pCon){ controlMonitor = GetControlMonitor((pCounter)pCount); pCountController = (pCounter)self->slaveData[controlMonitor]; - status = self->slaves[controlMonitor]->CheckCountStatus(pCountController,pCon); + if ( pCountController->pDriv->eMode == ePreset ) { + status = self->slaves[controlMonitor]->CheckCountStatus(pCountController,pCon); + } else { + status = HWIdle; + for(i = 0; i < self->nSlaves; i++){ + slaveStatus = self->slaves[i]->CheckCountStatus(pCountController,pCon); + if (slaveStatus == HWFault) { + status = HWFault; + break; + } else if (slaveStatus != HWIdle) { + status = slaveStatus; + break; + } + } + } if(status == HWIdle || status == HWFault){ /* stop counting on slaves when finished or when an error