Added Timout PVs
Signed-off-by: Bernardo Carvalho <bernardo.carvalho@tecnico.ulisboa.pt>
This commit is contained in:
@@ -41,6 +41,16 @@ record( longin, "ISTTOK:marte2:COUNTER")
|
|||||||
field(DTYP, "Soft Channel")
|
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")
|
record( ai, "ISTTOK:marte2:ADC0S")
|
||||||
{
|
{
|
||||||
field(DTYP, "Soft Channel")
|
field(DTYP, "Soft Channel")
|
||||||
|
|||||||
@@ -306,6 +306,14 @@ $IsttokApp = {
|
|||||||
DataSource = "AtcaIopAdc_DS"
|
DataSource = "AtcaIopAdc_DS"
|
||||||
Type = "uint32"
|
Type = "uint32"
|
||||||
}
|
}
|
||||||
|
TimeoutCount = {
|
||||||
|
DataSource = "AtcaIopAdc_DS"
|
||||||
|
Type = "uint32"
|
||||||
|
}
|
||||||
|
TimeoutMax = {
|
||||||
|
DataSource = "AtcaIopAdc_DS"
|
||||||
|
Type = "uint32"
|
||||||
|
}
|
||||||
ADC0Decim = {
|
ADC0Decim = {
|
||||||
DataSource = "AtcaIopAdc_DS"
|
DataSource = "AtcaIopAdc_DS"
|
||||||
Type = "int32"
|
Type = "int32"
|
||||||
@@ -454,6 +462,14 @@ $IsttokApp = {
|
|||||||
DataSource = "DDB1"
|
DataSource = "DDB1"
|
||||||
Type = "uint32"
|
Type = "uint32"
|
||||||
}
|
}
|
||||||
|
TimeoutCount = {
|
||||||
|
DataSource = "DDB1"
|
||||||
|
Type = "uint32"
|
||||||
|
}
|
||||||
|
TimeoutMax = {
|
||||||
|
DataSource = "DDB1"
|
||||||
|
Type = "uint32"
|
||||||
|
}
|
||||||
ADC0DRaw = {
|
ADC0DRaw = {
|
||||||
DataSource = "DDB1"
|
DataSource = "DDB1"
|
||||||
Type = "int32"
|
Type = "int32"
|
||||||
@@ -1005,11 +1021,19 @@ $IsttokApp = {
|
|||||||
+GAMCAOutput = {
|
+GAMCAOutput = {
|
||||||
Class = "IOGAM"
|
Class = "IOGAM"
|
||||||
InputSignals = {
|
InputSignals = {
|
||||||
|
Counter = {
|
||||||
|
DataSource = "DDB1"
|
||||||
|
Type = "uint32"
|
||||||
|
}
|
||||||
Time = {
|
Time = {
|
||||||
DataSource = "DDB1"
|
DataSource = "DDB1"
|
||||||
Type = "uint32"
|
Type = "uint32"
|
||||||
}
|
}
|
||||||
Counter = {
|
TimeoutCount = {
|
||||||
|
DataSource = "DDB1"
|
||||||
|
Type = "uint32"
|
||||||
|
}
|
||||||
|
TimeoutMax = {
|
||||||
DataSource = "DDB1"
|
DataSource = "DDB1"
|
||||||
Type = "uint32"
|
Type = "uint32"
|
||||||
}
|
}
|
||||||
@@ -1023,11 +1047,19 @@ $IsttokApp = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
OutputSignals = {
|
OutputSignals = {
|
||||||
Time = {
|
CounterLi = {
|
||||||
DataSource = "EPICSCAOutput"
|
DataSource = "EPICSCAOutput"
|
||||||
Type = "uint32"
|
Type = "uint32"
|
||||||
}
|
}
|
||||||
Counter = {
|
TimeLi = {
|
||||||
|
DataSource = "EPICSCAOutput"
|
||||||
|
Type = "uint32"
|
||||||
|
}
|
||||||
|
TimeoutCountLi = {
|
||||||
|
DataSource = "EPICSCAOutput"
|
||||||
|
Type = "uint32"
|
||||||
|
}
|
||||||
|
TimeoutMaxLi = {
|
||||||
DataSource = "EPICSCAOutput"
|
DataSource = "EPICSCAOutput"
|
||||||
Type = "uint32"
|
Type = "uint32"
|
||||||
}
|
}
|
||||||
@@ -1351,6 +1383,12 @@ $IsttokApp = {
|
|||||||
Time = {
|
Time = {
|
||||||
Type = "uint32"
|
Type = "uint32"
|
||||||
}
|
}
|
||||||
|
TimeoutCount = {
|
||||||
|
Type = "uint32"
|
||||||
|
}
|
||||||
|
TimeoutMax = {
|
||||||
|
Type = "uint32"
|
||||||
|
}
|
||||||
ADC0Decim = {
|
ADC0Decim = {
|
||||||
Type = "int32"
|
Type = "int32"
|
||||||
}
|
}
|
||||||
@@ -1726,12 +1764,20 @@ $IsttokApp = {
|
|||||||
IgnoreBufferOverrun = "1"
|
IgnoreBufferOverrun = "1"
|
||||||
NumberOfBuffers = "10"
|
NumberOfBuffers = "10"
|
||||||
Signals = {
|
Signals = {
|
||||||
Time = {
|
CounterLi = {
|
||||||
|
PVName = "ISTTOK:marte2:COUNTER"
|
||||||
|
Type = "uint32"
|
||||||
|
}
|
||||||
|
TimeLi = {
|
||||||
PVName = "ISTTOK:marte2:TIME"
|
PVName = "ISTTOK:marte2:TIME"
|
||||||
Type = "uint32"
|
Type = "uint32"
|
||||||
}
|
}
|
||||||
Counter = {
|
TimeoutCountLi = {
|
||||||
PVName = "ISTTOK:marte2:COUNTER"
|
PVName = "ISTTOK:marte2:AtcaIop-Timeout-Count"
|
||||||
|
Type = "uint32"
|
||||||
|
}
|
||||||
|
TimeoutMaxLi = {
|
||||||
|
PVName = "ISTTOK:marte2:AtcaIop-Timeout-Max"
|
||||||
Type = "uint32"
|
Type = "uint32"
|
||||||
}
|
}
|
||||||
ADC0DecimAi = {
|
ADC0DecimAi = {
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
namespace MARTe {
|
namespace MARTe {
|
||||||
|
|
||||||
|
const uint32 POLL_EXTRA_WAIT = 10000u;
|
||||||
//const float64 ADC_SIMULATOR_PI = 3.14159265359;
|
//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_OFFSET = 2u; // in DMA Data packet in 32b. First 2 are counter.
|
||||||
const uint32 IOP_ADC_INTEG_OFFSET = 16u; // in 64 bit words
|
const uint32 IOP_ADC_INTEG_OFFSET = 16u; // in 64 bit words
|
||||||
@@ -107,18 +108,20 @@ AtcaIopADC::AtcaIopADC() :
|
|||||||
timerPeriodUsecTime = 0u;
|
timerPeriodUsecTime = 0u;
|
||||||
counterAndTimer[0] = 0u;
|
counterAndTimer[0] = 0u;
|
||||||
counterAndTimer[1] = 0u;
|
counterAndTimer[1] = 0u;
|
||||||
|
timeoutCount = 0u;
|
||||||
|
timeoutMax = 0u;
|
||||||
sleepNature = Busy;
|
sleepNature = Busy;
|
||||||
sleepPercentage = 0u;
|
sleepPercentage = 0u;
|
||||||
execCounter = 0u;
|
//execCounter = 0u;
|
||||||
pollTimout = 0u;
|
//pollTimout = 0u;
|
||||||
adcPeriod = 0.;
|
adcPeriod = 0.;
|
||||||
uint32 k;
|
uint32 k;
|
||||||
for (k=0u; k<ATCA_IOP_N_ADCs; k++) {
|
for (k=0u; k < ATCA_IOP_N_ADCs; k++) {
|
||||||
adcValues[k] = 0u;
|
adcValues[k] = 0u;
|
||||||
electricalOffsets[k] = 0u;
|
electricalOffsets[k] = 0u;
|
||||||
wiringOffsets[k] = 0.0;
|
wiringOffsets[k] = 0.0;
|
||||||
}
|
}
|
||||||
for (k=0u; k<ATCA_IOP_N_INTEGRALS; k++) {
|
for (k=0u; k < ATCA_IOP_N_INTEGRALS; k++) {
|
||||||
adcIntegralValues[k] = 0u;
|
adcIntegralValues[k] = 0u;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -503,9 +506,7 @@ bool AtcaIopADC::SetConfiguredDatabase(StructuredDataI& data) {
|
|||||||
if (ok) {
|
if (ok) {
|
||||||
isCounter = (signalIdx == 0u);
|
isCounter = (signalIdx == 0u);
|
||||||
isTime = (signalIdx == 1u);
|
isTime = (signalIdx == 1u);
|
||||||
//isAdcDecim = (signalIdx == 2u);
|
isAdc = (signalIdx < ATCA_IOP_N_TIMCNT + ATCA_IOP_N_ADCs + ATCA_IOP_N_INTEGRALS);
|
||||||
isAdc= (signalIdx < ATCA_IOP_N_TIMCNT + ATCA_IOP_N_ADCs + ATCA_IOP_N_INTEGRALS);
|
|
||||||
//isAdcSim = (signalIdx < ATCA_IOP_N_SIGNALS);
|
|
||||||
if (isCounter) {
|
if (isCounter) {
|
||||||
if (nSamples > 1u) {
|
if (nSamples > 1u) {
|
||||||
ok = false;
|
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");
|
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 {}
|
else {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -599,6 +585,12 @@ bool AtcaIopADC::GetSignalMemoryBuffer(const uint32 signalIdx, const uint32 buff
|
|||||||
else if (signalIdx == 1u) {
|
else if (signalIdx == 1u) {
|
||||||
signalAddress = &counterAndTimer[1];
|
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 ) {
|
else if (signalIdx < ATCA_IOP_N_TIMCNT + ATCA_IOP_N_ADCs ) {
|
||||||
signalAddress = &adcValues[signalIdx - ATCA_IOP_N_TIMCNT];
|
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
|
//Sleep until the next period. Cannot be < 0 due to while(lastTimeTicks < startTicks) above
|
||||||
uint64 sleepTicksCorrection = (startTicks - lastTimeTicks);
|
uint64 sleepTicksCorrection = (startTicks - lastTimeTicks);
|
||||||
|
//uint64 deltaTicks = sleepTimeTicks - (startTicks - lastTimeTicks);
|
||||||
uint64 deltaTicks = sleepTimeTicks - sleepTicksCorrection;
|
uint64 deltaTicks = sleepTimeTicks - sleepTicksCorrection;
|
||||||
|
|
||||||
|
timeoutMax = deltaTicks; // debug
|
||||||
//volatile int32 currentDMA = 0u;
|
//volatile int32 currentDMA = 0u;
|
||||||
oldestBufferIdx = GetOldestBufferIdx();
|
oldestBufferIdx = GetOldestBufferIdx();
|
||||||
float32 totalSleepTime = static_cast<float32>(static_cast<float64>(deltaTicks) * HighResolutionTimer::Period());
|
float32 totalSleepTime = static_cast<float32>(static_cast<float64>(deltaTicks) * HighResolutionTimer::Period());
|
||||||
|
/*
|
||||||
#ifdef DEBUG_POLL
|
#ifdef DEBUG_POLL
|
||||||
if((execCounter++)%DEBUG_POLL == 0) {
|
if((execCounter++)%DEBUG_POLL == 0) {
|
||||||
REPORT_ERROR(ErrorManagement::Information, "Executor sleepTime: %f pollTimout: %d", totalSleepTime, pollTimout);
|
REPORT_ERROR(ErrorManagement::Information, "Executor sleepTime: %f pollTimout: %d", totalSleepTime, pollTimout);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
if (sleepNature == Busy) {
|
if (sleepNature == Busy) {
|
||||||
if (sleepPercentage > 0u) {
|
if (sleepPercentage > 0u) {
|
||||||
//float32 sleepTime = totalSleepTime * 0.5;
|
//float32 sleepTime = totalSleepTime * 0.5;
|
||||||
float32 sleepTime = totalSleepTime * (static_cast<float32>(sleepPercentage) / 100.F);
|
float32 sleepTime = totalSleepTime * (static_cast<float32>(sleepPercentage) / 100.F);
|
||||||
Sleep::NoMore(sleepTime);
|
Sleep::NoMore(sleepTime);
|
||||||
//currentDMA =
|
|
||||||
//if(PollDma(startTicks + deltaTicks + 100000u) < 0)
|
//if(PollDma(startTicks + deltaTicks + 100000u) < 0)
|
||||||
//while ((HighResolutionTimer::Counter() - startTicks) < deltaTicks) {
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
if(PollDma(startTicks + deltaTicks + sleepTimeTicks + 10000u) < 0)
|
if(PollDma(startTicks + deltaTicks + sleepTimeTicks + POLL_EXTRA_WAIT) < 0){
|
||||||
pollTimout++; // TODO check max wait
|
//pollTimout++; // TODO check max wait
|
||||||
|
timeoutCount++; //
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
else {
|
else {
|
||||||
float32 totalSleepTime = static_cast<float32>(static_cast<float64>(deltaTicks) * HighResolutionTimer::Period());
|
float32 totalSleepTime = static_cast<float32>(static_cast<float64>(deltaTicks) * HighResolutionTimer::Period());
|
||||||
@@ -747,7 +743,7 @@ uint32 AtcaIopADC::GetSleepPercentage() const {
|
|||||||
* */
|
* */
|
||||||
|
|
||||||
int32 AtcaIopADC::PollDma(uint64 waitLimitTicks) const {
|
int32 AtcaIopADC::PollDma(uint64 waitLimitTicks) const {
|
||||||
//uint32 oldBufferFooter = mappedDmaBase[buffIdx * RT_PCKT_SIZE + 62];
|
|
||||||
DMA_CH1_PCKT *pdma = (DMA_CH1_PCKT *) mappedDmaBase;
|
DMA_CH1_PCKT *pdma = (DMA_CH1_PCKT *) mappedDmaBase;
|
||||||
uint32 oldBufferFooter = pdma[oldestBufferIdx].foot_time_cnt;
|
uint32 oldBufferFooter = pdma[oldestBufferIdx].foot_time_cnt;
|
||||||
volatile uint32 freshBufferFooter = oldBufferFooter;
|
volatile uint32 freshBufferFooter = oldBufferFooter;
|
||||||
@@ -758,7 +754,6 @@ int32 AtcaIopADC::PollDma(uint64 waitLimitTicks) const {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
actualTime = HighResolutionTimer::Counter();
|
actualTime = HighResolutionTimer::Counter();
|
||||||
//freshBufferFooter = mappedDmaBase[buffIdx * RT_PCKT_SIZE + 62];
|
|
||||||
freshBufferFooter = pdma[oldestBufferIdx].foot_time_cnt;
|
freshBufferFooter = pdma[oldestBufferIdx].foot_time_cnt;
|
||||||
}
|
}
|
||||||
//uint32 headTimeMark = mappedDmaBase[buffIdx * RT_PCKT_SIZE];
|
//uint32 headTimeMark = mappedDmaBase[buffIdx * RT_PCKT_SIZE];
|
||||||
|
|||||||
@@ -52,10 +52,9 @@ namespace MARTe {
|
|||||||
*/
|
*/
|
||||||
const uint32 ATCA_IOP_MAX_CHANNELS = 32u;
|
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_ADCs = 16u;
|
||||||
const uint32 ATCA_IOP_N_INTEGRALS = ATCA_IOP_N_ADCs;
|
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 +
|
const uint32 ATCA_IOP_N_SIGNALS = (ATCA_IOP_N_TIMCNT + ATCA_IOP_N_ADCs +
|
||||||
ATCA_IOP_N_INTEGRALS);
|
ATCA_IOP_N_INTEGRALS);
|
||||||
/**
|
/**
|
||||||
@@ -77,12 +76,18 @@ namespace MARTe {
|
|||||||
* ADCFrequency = 2000000
|
* ADCFrequency = 2000000
|
||||||
* Signals = {
|
* Signals = {
|
||||||
* Counter = {
|
* Counter = {
|
||||||
* Type = uint32 //int32 also supported
|
* Type = uint32
|
||||||
* }
|
* }
|
||||||
* Time = {
|
* Time = {
|
||||||
* Type = uint32 //int32 also supported
|
* Type = uint32
|
||||||
* Frequency = 1000
|
* Frequency = 1000
|
||||||
* }
|
* }
|
||||||
|
* TimeoutCount = {
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* TimeoutMax = {
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
* ADC0 = {
|
* ADC0 = {
|
||||||
* Type = uint32
|
* Type = uint32
|
||||||
* }
|
* }
|
||||||
@@ -297,14 +302,24 @@ namespace MARTe {
|
|||||||
/**
|
/**
|
||||||
* Debugging
|
* Debugging
|
||||||
*/
|
*/
|
||||||
uint32 execCounter;
|
//uint32 execCounter;
|
||||||
uint32 pollTimout;
|
//uint32 pollTimout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current counter and timer
|
* Current counter and timer
|
||||||
*/
|
*/
|
||||||
uint32 counterAndTimer[2];
|
uint32 counterAndTimer[2];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout counter
|
||||||
|
*/
|
||||||
|
uint32 timeoutCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout counter
|
||||||
|
*/
|
||||||
|
uint32 timeoutMax;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ADC values
|
* ADC values
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user