diff --git a/Configurations/EPICS-isttok.db b/Configurations/EPICS-isttok.db index 2a167b4..82a8e85 100644 --- a/Configurations/EPICS-isttok.db +++ b/Configurations/EPICS-isttok.db @@ -41,6 +41,16 @@ record( longin, "ISTTOK:marte2:COUNTER") field(DTYP, "Soft Channel") } +record( longin, "ISTTOK:marte2:AtcaIop-Timeout-Count") +{ + field(DTYP, "Soft Channel") +} + +record( longin, "ISTTOK:marte2:AtcaIop-Timeout-Max") +{ + field(DTYP, "Soft Channel") +} + record( ai, "ISTTOK:marte2:ADC0S") { field(DTYP, "Soft Channel") diff --git a/Configurations/RTApp-AtcaIop.cfg b/Configurations/RTApp-AtcaIop.cfg index 345483e..8d8939f 100644 --- a/Configurations/RTApp-AtcaIop.cfg +++ b/Configurations/RTApp-AtcaIop.cfg @@ -306,6 +306,14 @@ $IsttokApp = { DataSource = "AtcaIopAdc_DS" Type = "uint32" } + TimeoutCount = { + DataSource = "AtcaIopAdc_DS" + Type = "uint32" + } + TimeoutMax = { + DataSource = "AtcaIopAdc_DS" + Type = "uint32" + } ADC0Decim = { DataSource = "AtcaIopAdc_DS" Type = "int32" @@ -454,6 +462,14 @@ $IsttokApp = { DataSource = "DDB1" Type = "uint32" } + TimeoutCount = { + DataSource = "DDB1" + Type = "uint32" + } + TimeoutMax = { + DataSource = "DDB1" + Type = "uint32" + } ADC0DRaw = { DataSource = "DDB1" Type = "int32" @@ -1005,11 +1021,19 @@ $IsttokApp = { +GAMCAOutput = { Class = "IOGAM" InputSignals = { + Counter = { + DataSource = "DDB1" + Type = "uint32" + } Time = { DataSource = "DDB1" Type = "uint32" } - Counter = { + TimeoutCount = { + DataSource = "DDB1" + Type = "uint32" + } + TimeoutMax = { DataSource = "DDB1" Type = "uint32" } @@ -1023,11 +1047,19 @@ $IsttokApp = { } } OutputSignals = { - Time = { + CounterLi = { DataSource = "EPICSCAOutput" Type = "uint32" } - Counter = { + TimeLi = { + DataSource = "EPICSCAOutput" + Type = "uint32" + } + TimeoutCountLi = { + DataSource = "EPICSCAOutput" + Type = "uint32" + } + TimeoutMaxLi = { DataSource = "EPICSCAOutput" Type = "uint32" } @@ -1351,6 +1383,12 @@ $IsttokApp = { Time = { Type = "uint32" } + TimeoutCount = { + Type = "uint32" + } + TimeoutMax = { + Type = "uint32" + } ADC0Decim = { Type = "int32" } @@ -1726,12 +1764,20 @@ $IsttokApp = { IgnoreBufferOverrun = "1" NumberOfBuffers = "10" Signals = { - Time = { + CounterLi = { + PVName = "ISTTOK:marte2:COUNTER" + Type = "uint32" + } + TimeLi = { PVName = "ISTTOK:marte2:TIME" Type = "uint32" } - Counter = { - PVName = "ISTTOK:marte2:COUNTER" + TimeoutCountLi = { + PVName = "ISTTOK:marte2:AtcaIop-Timeout-Count" + Type = "uint32" + } + TimeoutMaxLi = { + PVName = "ISTTOK:marte2:AtcaIop-Timeout-Max" Type = "uint32" } ADC0DecimAi = { diff --git a/DataSources/AtcaIop/AtcaIopADC.cpp b/DataSources/AtcaIop/AtcaIopADC.cpp index ea9f600..b4b55c4 100644 --- a/DataSources/AtcaIop/AtcaIopADC.cpp +++ b/DataSources/AtcaIop/AtcaIopADC.cpp @@ -46,6 +46,7 @@ /*---------------------------------------------------------------------------*/ namespace MARTe { + const uint32 POLL_EXTRA_WAIT = 10000u; //const float64 ADC_SIMULATOR_PI = 3.14159265359; const uint32 IOP_ADC_OFFSET = 2u; // in DMA Data packet in 32b. First 2 are counter. const uint32 IOP_ADC_INTEG_OFFSET = 16u; // in 64 bit words @@ -107,18 +108,20 @@ AtcaIopADC::AtcaIopADC() : timerPeriodUsecTime = 0u; counterAndTimer[0] = 0u; counterAndTimer[1] = 0u; + timeoutCount = 0u; + timeoutMax = 0u; sleepNature = Busy; sleepPercentage = 0u; - execCounter = 0u; - pollTimout = 0u; + //execCounter = 0u; + //pollTimout = 0u; adcPeriod = 0.; uint32 k; - for (k=0u; k 1u) { ok = false; @@ -534,21 +535,6 @@ bool AtcaIopADC::SetConfiguredDatabase(StructuredDataI& data) { REPORT_ERROR(ErrorManagement::ParametersError, "The ATCA-IOP signals shall have one and only one sample"); } } - /* - else if (isAdcSim) { - //How many samples to read for each cycle? - if (adcSamplesPerCycle == 0u) { - adcSamplesPerCycle = nSamples; - } - else { - if (adcSamplesPerCycle != nSamples) { - ok = false; - REPORT_ERROR(ErrorManagement::ParametersError, "All the ADC signals shall have the same number of samples"); - } - } - - } - */ else {} } } @@ -599,6 +585,12 @@ bool AtcaIopADC::GetSignalMemoryBuffer(const uint32 signalIdx, const uint32 buff else if (signalIdx == 1u) { signalAddress = &counterAndTimer[1]; } + else if (signalIdx == 2u) { + signalAddress = &timeoutCount; + } + else if (signalIdx == 3u) { + signalAddress = &timeoutMax; + } else if (signalIdx < ATCA_IOP_N_TIMCNT + ATCA_IOP_N_ADCs ) { signalAddress = &adcValues[signalIdx - ATCA_IOP_N_TIMCNT]; } @@ -671,27 +663,31 @@ ErrorManagement::ErrorType AtcaIopADC::Execute(ExecutionInfo& info) { //Sleep until the next period. Cannot be < 0 due to while(lastTimeTicks < startTicks) above uint64 sleepTicksCorrection = (startTicks - lastTimeTicks); + //uint64 deltaTicks = sleepTimeTicks - (startTicks - lastTimeTicks); uint64 deltaTicks = sleepTimeTicks - sleepTicksCorrection; + + timeoutMax = deltaTicks; // debug //volatile int32 currentDMA = 0u; oldestBufferIdx = GetOldestBufferIdx(); float32 totalSleepTime = static_cast(static_cast(deltaTicks) * HighResolutionTimer::Period()); + /* #ifdef DEBUG_POLL if((execCounter++)%DEBUG_POLL == 0) { REPORT_ERROR(ErrorManagement::Information, "Executor sleepTime: %f pollTimout: %d", totalSleepTime, pollTimout); } #endif +*/ if (sleepNature == Busy) { if (sleepPercentage > 0u) { //float32 sleepTime = totalSleepTime * 0.5; float32 sleepTime = totalSleepTime * (static_cast(sleepPercentage) / 100.F); Sleep::NoMore(sleepTime); - //currentDMA = //if(PollDma(startTicks + deltaTicks + 100000u) < 0) - //while ((HighResolutionTimer::Counter() - startTicks) < deltaTicks) { - //} } - if(PollDma(startTicks + deltaTicks + sleepTimeTicks + 10000u) < 0) - pollTimout++; // TODO check max wait + if(PollDma(startTicks + deltaTicks + sleepTimeTicks + POLL_EXTRA_WAIT) < 0){ + //pollTimout++; // TODO check max wait + timeoutCount++; // + } /* else { float32 totalSleepTime = static_cast(static_cast(deltaTicks) * HighResolutionTimer::Period()); @@ -747,7 +743,7 @@ uint32 AtcaIopADC::GetSleepPercentage() const { * */ int32 AtcaIopADC::PollDma(uint64 waitLimitTicks) const { - //uint32 oldBufferFooter = mappedDmaBase[buffIdx * RT_PCKT_SIZE + 62]; + DMA_CH1_PCKT *pdma = (DMA_CH1_PCKT *) mappedDmaBase; uint32 oldBufferFooter = pdma[oldestBufferIdx].foot_time_cnt; volatile uint32 freshBufferFooter = oldBufferFooter; @@ -758,7 +754,6 @@ int32 AtcaIopADC::PollDma(uint64 waitLimitTicks) const { return -1; } actualTime = HighResolutionTimer::Counter(); - //freshBufferFooter = mappedDmaBase[buffIdx * RT_PCKT_SIZE + 62]; freshBufferFooter = pdma[oldestBufferIdx].foot_time_cnt; } //uint32 headTimeMark = mappedDmaBase[buffIdx * RT_PCKT_SIZE]; diff --git a/DataSources/AtcaIop/AtcaIopADC.h b/DataSources/AtcaIop/AtcaIopADC.h index 1f4a4a4..d5ba012 100644 --- a/DataSources/AtcaIop/AtcaIopADC.h +++ b/DataSources/AtcaIop/AtcaIopADC.h @@ -52,10 +52,9 @@ namespace MARTe { */ const uint32 ATCA_IOP_MAX_CHANNELS = 32u; - const uint32 ATCA_IOP_N_TIMCNT = 2u; + const uint32 ATCA_IOP_N_TIMCNT = 4u; const uint32 ATCA_IOP_N_ADCs = 16u; const uint32 ATCA_IOP_N_INTEGRALS = ATCA_IOP_N_ADCs; - //const uint32 ADC_SIMULATOR_N_ADCs = 2u; const uint32 ATCA_IOP_N_SIGNALS = (ATCA_IOP_N_TIMCNT + ATCA_IOP_N_ADCs + ATCA_IOP_N_INTEGRALS); /** @@ -77,12 +76,18 @@ namespace MARTe { * ADCFrequency = 2000000 * Signals = { * Counter = { - * Type = uint32 //int32 also supported + * Type = uint32 * } * Time = { - * Type = uint32 //int32 also supported + * Type = uint32 * Frequency = 1000 * } + * TimeoutCount = { + * Type = uint32 + * } + * TimeoutMax = { + * Type = uint32 + * } * ADC0 = { * Type = uint32 * } @@ -297,14 +302,24 @@ namespace MARTe { /** * Debugging */ - uint32 execCounter; - uint32 pollTimout; + //uint32 execCounter; + //uint32 pollTimout; /** * Current counter and timer */ uint32 counterAndTimer[2]; + /** + * Timeout counter + */ + uint32 timeoutCount; + + /** + * Timeout counter + */ + uint32 timeoutMax; + /** * ADC values */