Changed RT DMA buffs

Signed-off-by: Bernardo Carvalho <bernardo.carvalho@tecnico.ulisboa.pt>
This commit is contained in:
2024-05-02 16:28:50 +01:00
parent d62dc8a082
commit 06f9a6d851
3 changed files with 168 additions and 137 deletions

View File

@@ -12,16 +12,25 @@ import argparse
ADC_CHANNELS = 14 # channels stored in ISTTOK ADC_CHANNELS = 14 # channels stored in ISTTOK
DECIM_RATE = 200 DECIM_RATE = 200
MDSTREENAME = 'rtappisttok'
def main(args): def main(args):
mdsPulseNumber = args.shot mdsPulseNumber = args.shot
mdsTreeName = 'rtappisttok'
try: try:
tree = Tree(mdsTreeName, mdsPulseNumber) if(mdsPulseNumber > 0):
tree = Tree(MDSTREENAME, mdsPulseNumber)
else:
tree = Tree(MDSTREENAME)
mdsPulseNumber = tree.getCurrent()
tree.close()
tree = Tree(MDSTREENAME, mdsPulseNumber)
except: except:
print(f'Failed opening {mdsTreeName} for pulse number {mdsPulseNumber:d}') print(f'Failed opening {MDSTREENAME} for pulse number {mdsPulseNumber:d}')
exit() exit()
print(f'Openpening {MDSTREENAME} for pulse number {mdsPulseNumber:d}')
# add plt.addLegend() BEFORE you create the curves. # add plt.addLegend() BEFORE you create the curves.
#mdsNode = tree.getNode("ATCAIOP1.ADC0RAW") #mdsNode = tree.getNode("ATCAIOP1.ADC0RAW")
#dataAdc = mdsNode.getData().data() #dataAdc = mdsNode.getData().data()
@@ -59,7 +68,7 @@ if __name__ == '__main__':
#parser.add_argument('-l','--list', nargs='+') #parser.add_argument('-l','--list', nargs='+')
parser.add_argument('-c', '--crange', nargs='+',type=int, help='Channel plots (1 12)',default=[1, 12]) parser.add_argument('-c', '--crange', nargs='+',type=int, help='Channel plots (1 12)',default=[1, 12])
parser.add_argument('-i', '--irange', nargs='+',type=int,default=[1, 12]) parser.add_argument('-i', '--irange', nargs='+',type=int,default=[1, 12])
parser.add_argument('-s', '--shot', type=int, help='Mds+ pulse Number ([1, ...])', default=100) parser.add_argument('-s', '--shot', type=int, help='Mds+ pulse Number ([1, ...])', default=0)
#parser.add_argument('-e', '--averages', action='store_true', help='Calc averages') #parser.add_argument('-e', '--averages', action='store_true', help='Calc averages')
#parser.add_argument('-w', '--drift', action='store_true', help='Calc drifts') #parser.add_argument('-w', '--drift', action='store_true', help='Calc drifts')
#, default='') #, default='')

View File

@@ -46,71 +46,86 @@
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
namespace MARTe { namespace MARTe {
//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
const uint32 RT_PCKT_SIZE = 1024u; const uint32 RT_PCKT_SIZE = 1024u;
const uint32 RT_PCKT64_SIZE = 512u; // In 64 bit words const uint32 RT_PCKT64_SIZE = 512u; // In 64 bit words
/* 256 + 3840 = 4096 B (PAGE_SIZE) data packet*/ /* 256 + 3840 = 4096 B (PAGE_SIZE) data packet
typedef struct _DMA_CH1_PCKT { typedef struct _DMA_CH1_PCKT {
uint32 head_time_cnt; uint32 head_time_cnt;
uint32 header; // h5431BACD uint32 header; // h5431BACD
int32 channel[60]; // 24 56 int32 channel[60]; // 24 56
uint32 foot_time_cnt; uint32 foot_time_cnt;
uint32 footer; // h9876ABDC uint32 footer; // h9876ABDC
uint8 page_fill[3840]; uint8 page_fill[3840];
} DMA_CH1_PCKT; } DMA_CH1_PCKT;
*/
#define DMA_RT_PCKT_SIZE 256
/* 256 Bytes RT data packet */
typedef struct _DMA_CH1_PCKT {
volatile uint32_t head_time_cnt;
volatile uint32_t header; // h5431BACD
volatile int32_t adc_decim_data[ADC_CHANNELS];
volatile uint64_t _fill64_0; // 00
volatile int64_t adc_integ_data[ADC_CHANNELS];
volatile int64_t _fill64_1[4]; // 00
volatile uint32_t sample_cnt;
volatile uint32_t _fill32; // hAAAABBBB
volatile uint32_t foot_time_cnt;
volatile uint32_t footer; // h9876ABDC
} DMA_CH1_PCKT;
struct atca_eo_config { struct atca_eo_config {
int32_t offset[ATCA_IOP_MAX_CHANNELS]; int32_t offset[ATCA_IOP_MAX_CHANNELS];
}; };
struct atca_wo_config { struct atca_wo_config {
int32_t offset[ATCA_IOP_MAX_CHANNELS]; int32_t offset[ATCA_IOP_MAX_CHANNELS];
}; };
//} //}
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Method definitions */ /* Method definitions */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
AtcaIopADC::AtcaIopADC() : AtcaIopADC::AtcaIopADC() :
DataSourceI(), MessageI(), EmbeddedServiceMethodBinderI(), executor(*this) { DataSourceI(), MessageI(), EmbeddedServiceMethodBinderI(), executor(*this) {
deviceName = ""; deviceName = "";
boardId = 2u; boardId = 2u;
//deviceDmaName = ""; //deviceDmaName = "";
boardFileDescriptor = -1; boardFileDescriptor = -1;
boardDmaDescriptor = -1; boardDmaDescriptor = -1;
mappedDmaBase = NULL; mappedDmaBase = NULL;
mappedDmaSize = 0u; mappedDmaSize = 0u;
isMaster = 0u; isMaster = 0u;
oldestBufferIdx = 0u; oldestBufferIdx = 0u;
lastTimeTicks = 0u; lastTimeTicks = 0u;
sleepTimeTicks = 0u; sleepTimeTicks = 0u;
timerPeriodUsecTime = 0u; timerPeriodUsecTime = 0u;
counterAndTimer[0] = 0u; counterAndTimer[0] = 0u;
counterAndTimer[1] = 0u; counterAndTimer[1] = 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;
} }
if (!synchSem.Create()) { if (!synchSem.Create()) {
REPORT_ERROR(ErrorManagement::FatalError, "Could not create EventSem."); REPORT_ERROR(ErrorManagement::FatalError, "Could not create EventSem.");
}
} }
}
/*lint -e{1551} the destructor must guarantee that the Timer SingleThreadService is stopped.*/ /*lint -e{1551} the destructor must guarantee that the Timer SingleThreadService is stopped.*/
AtcaIopADC::~AtcaIopADC() { AtcaIopADC::~AtcaIopADC() {
@@ -121,7 +136,7 @@ AtcaIopADC::~AtcaIopADC() {
ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_STREAM_DISABLE); ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_STREAM_DISABLE);
ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_DMA_DISABLE); ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_DMA_DISABLE);
uint32 statusReg = 0; uint32 statusReg = 0;
ioctl(boardFileDescriptor, ATCA_PCIE_IOPG_STATUS, &statusReg); ioctl(boardFileDescriptor, ATCA_PCIE_IOPG_STATUS, &statusReg);
//rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_DMA_RESET); //rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_DMA_RESET);
close(boardFileDescriptor); close(boardFileDescriptor);
REPORT_ERROR(ErrorManagement::Information, "Close device %d OK. Status Reg 0x%x,", boardFileDescriptor, statusReg); REPORT_ERROR(ErrorManagement::Information, "Close device %d OK. Status Reg 0x%x,", boardFileDescriptor, statusReg);
@@ -163,13 +178,13 @@ bool AtcaIopADC::Initialise(StructuredDataI& data) {
} }
} }
/* /*
if (ok) { if (ok) {
ok = data.Read("DeviceDmaName", deviceDmaName); ok = data.Read("DeviceDmaName", deviceDmaName);
if (!ok) { if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "The DeviceDmaName shall be specified"); REPORT_ERROR(ErrorManagement::ParametersError, "The DeviceDmaName shall be specified");
} }
} }
*/ */
if (ok) { if (ok) {
ok = data.Read("NumberOfChannels", numberOfChannels); ok = data.Read("NumberOfChannels", numberOfChannels);
if (!ok) { if (!ok) {
@@ -388,13 +403,13 @@ bool AtcaIopADC::SetConfiguredDatabase(StructuredDataI& data) {
} }
//mappedDmaBase = (int32 *) mmap(0, getpagesize() * NUMBER_OF_BUFFERS, //mappedDmaBase = (int32 *) mmap(0, getpagesize() * NUMBER_OF_BUFFERS,
mappedDmaBase = (int32 *) mmap(0, 4096u * NUMBER_OF_BUFFERS, mappedDmaSize = getpagesize();
mappedDmaBase = mmap(0, mappedDmaSize, //4096u, // * NUMBER_OF_BUFFERS,
PROT_READ, MAP_SHARED, boardDmaDescriptor, 0); PROT_READ, MAP_SHARED, boardDmaDescriptor, 0);
if (mappedDmaBase == MAP_FAILED){ if (mappedDmaBase == MAP_FAILED){
ok = false; ok = false;
REPORT_ERROR(ErrorManagement::FatalError, "Error Mapping DMA Memory Device %s", fullDeviceName); REPORT_ERROR(ErrorManagement::FatalError, "Error Mapping DMA Memory Device %s", fullDeviceName);
} }
mappedDmaSize = getpagesize();
uint32 statusReg = 0; uint32 statusReg = 0;
int rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_DMA_RESET); int rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_DMA_RESET);
@@ -433,7 +448,7 @@ bool AtcaIopADC::SetConfiguredDatabase(StructuredDataI& data) {
ok = false; ok = false;
REPORT_ERROR(ErrorManagement::FatalError, "Device Status Reg %d, 0x%x", rc, statusReg); REPORT_ERROR(ErrorManagement::FatalError, "Device Status Reg %d, 0x%x", rc, statusReg);
} }
// rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_ACQ_ENABLE); // rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_ACQ_ENABLE);
//rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_DMA_DISABLE); //rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_DMA_DISABLE);
//Sleep::Busy(0.001); // in Sec //Sleep::Busy(0.001); // in Sec
//rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_ACQ_DISABLE); //rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_ACQ_DISABLE);
@@ -469,7 +484,7 @@ bool AtcaIopADC::SetConfiguredDatabase(StructuredDataI& data) {
bool isCounter = false; bool isCounter = false;
bool isTime = false; bool isTime = false;
bool isAdc = false; bool isAdc = false;
// bool isAdcDecim = false; // bool isAdcDecim = false;
//bool isAdcSim = false; //bool isAdcSim = false;
uint32 signalIdx = 0u; uint32 signalIdx = 0u;
uint32 nSamples = 0u; uint32 nSamples = 0u;
@@ -504,13 +519,13 @@ bool AtcaIopADC::SetConfiguredDatabase(StructuredDataI& data) {
} }
} }
/* /*
else if (isAdcDecim) { else if (isAdcDecim) {
ok = GetSignalNumberOfElements(signalIdx, nElements); ok = GetSignalNumberOfElements(signalIdx, nElements);
REPORT_ERROR(ErrorManagement::Information, "The ADC decim Signal Elements %d", nElements); REPORT_ERROR(ErrorManagement::Information, "The ADC decim Signal Elements %d", nElements);
// if (nSamples > 1u) { // if (nSamples > 1u) {
// ok = false; // ok = false;
// REPORT_ERROR(ErrorManagement::ParametersError, "The second signal (time) shall have one and only one sample"); // REPORT_ERROR(ErrorManagement::ParametersError, "The second signal (time) shall have one and only one sample");
//} //}
} }
*/ */
else if (isAdc) { else if (isAdc) {
@@ -520,17 +535,17 @@ bool AtcaIopADC::SetConfiguredDatabase(StructuredDataI& data) {
} }
} }
/* /*
else if (isAdcSim) { else if (isAdcSim) {
//How many samples to read for each cycle? //How many samples to read for each cycle?
if (adcSamplesPerCycle == 0u) { if (adcSamplesPerCycle == 0u) {
adcSamplesPerCycle = nSamples; adcSamplesPerCycle = nSamples;
} }
else { else {
if (adcSamplesPerCycle != nSamples) { if (adcSamplesPerCycle != nSamples) {
ok = false; ok = false;
REPORT_ERROR(ErrorManagement::ParametersError, "All the ADC signals shall have the same number of samples"); REPORT_ERROR(ErrorManagement::ParametersError, "All the ADC signals shall have the same number of samples");
} }
} }
} }
*/ */
@@ -551,10 +566,10 @@ bool AtcaIopADC::SetConfiguredDatabase(StructuredDataI& data) {
timerPeriodUsecTime = static_cast<uint32>(periodUsec); timerPeriodUsecTime = static_cast<uint32>(periodUsec);
float64 sleepTimeT = (static_cast<float64>(HighResolutionTimer::Frequency()) / cycleFrequency); float64 sleepTimeT = (static_cast<float64>(HighResolutionTimer::Frequency()) / cycleFrequency);
sleepTimeTicks = static_cast<uint64>(sleepTimeT); sleepTimeTicks = static_cast<uint64>(sleepTimeT);
/* /*
* [Information - AtcaIopADC.cpp:548]: The timer will be set using a cycle frequency of 10000.000000 Hz * [Information - AtcaIopADC.cpp:548]: The timer will be set using a cycle frequency of 10000.000000 Hz
* [Information - AtcaIopADC.cpp:554]: The timer will be set using a sleepTimeTicks of 100000 (ns) * [Information - AtcaIopADC.cpp:554]: The timer will be set using a sleepTimeTicks of 100000 (ns)
*/ */
REPORT_ERROR(ErrorManagement::Information, REPORT_ERROR(ErrorManagement::Information,
"The timer will be set using a sleepTimeTicks of %d (ns)", sleepTimeTicks); "The timer will be set using a sleepTimeTicks of %d (ns)", sleepTimeTicks);
} }
@@ -564,8 +579,8 @@ bool AtcaIopADC::SetConfiguredDatabase(StructuredDataI& data) {
ok = (adcFrequency == static_cast<uint32>(totalNumberOfSamplesPerSecond)); ok = (adcFrequency == static_cast<uint32>(totalNumberOfSamplesPerSecond));
if (!ok) { if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, REPORT_ERROR(ErrorManagement::ParametersError,
"The adcSamplesPerCycle * cycleFrequency (%u) shall be equal to the ADCs acquisition frequency (%u)", "The adcSamplesPerCycle * cycleFrequency (%u) shall be equal to the ADCs acquisition frequency (%u)",
totalNumberOfSamplesPerSecond, adcFrequency); totalNumberOfSamplesPerSecond, adcFrequency);
} }
} }
return ok; return ok;
@@ -640,6 +655,7 @@ bool AtcaIopADC::PrepareNextState(const char8* const currentStateName, const cha
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: the method sleeps for the given period irrespectively of the input info.*/ /*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: the method sleeps for the given period irrespectively of the input info.*/
ErrorManagement::ErrorType AtcaIopADC::Execute(ExecutionInfo& info) { ErrorManagement::ErrorType AtcaIopADC::Execute(ExecutionInfo& info) {
DMA_CH1_PCKT *pdma = (DMA_CH1_PCKT *) mappedDmaBase;
if (lastTimeTicks == 0u) { if (lastTimeTicks == 0u) {
lastTimeTicks = HighResolutionTimer::Counter(); lastTimeTicks = HighResolutionTimer::Counter();
} }
@@ -661,7 +677,7 @@ ErrorManagement::ErrorType AtcaIopADC::Execute(ExecutionInfo& info) {
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) {
@@ -677,13 +693,13 @@ ErrorManagement::ErrorType AtcaIopADC::Execute(ExecutionInfo& info) {
if(PollDma(startTicks + deltaTicks + sleepTimeTicks + 10000u) < 0) if(PollDma(startTicks + deltaTicks + sleepTimeTicks + 10000u) < 0)
pollTimout++; // TODO check max wait pollTimout++; // TODO check max wait
/* /*
else { else {
float32 totalSleepTime = static_cast<float32>(static_cast<float64>(deltaTicks) * HighResolutionTimer::Period()); float32 totalSleepTime = static_cast<float32>(static_cast<float64>(deltaTicks) * HighResolutionTimer::Period());
uint32 busyPercentage = (100u - sleepPercentage); uint32 busyPercentage = (100u - sleepPercentage);
float32 busyTime = totalSleepTime * (static_cast<float32>(busyPercentage) / 100.F); float32 busyTime = totalSleepTime * (static_cast<float32>(busyPercentage) / 100.F);
Sleep::SemiBusy(totalSleepTime, busyTime); Sleep::SemiBusy(totalSleepTime, busyTime);
} }
*/ */
} }
else { else {
float32 sleepTime = static_cast<float32>(static_cast<float64>(deltaTicks) * HighResolutionTimer::Period()); float32 sleepTime = static_cast<float32>(static_cast<float64>(deltaTicks) * HighResolutionTimer::Period());
@@ -693,20 +709,22 @@ ErrorManagement::ErrorType AtcaIopADC::Execute(ExecutionInfo& info) {
ErrorManagement::ErrorType err = synchSem.Post(); ErrorManagement::ErrorType err = synchSem.Post();
counterAndTimer[0] += nCycles; counterAndTimer[0] += nCycles;
//counterAndTimer[1] = counterAndTimer[0] * timerPeriodUsecTime; //counterAndTimer[1] = mappedDmaBase[oldestBufferIdx * RT_PCKT_SIZE] * timerPeriodUsecTime;
counterAndTimer[1] = mappedDmaBase[oldestBufferIdx * RT_PCKT_SIZE] * timerPeriodUsecTime; counterAndTimer[1] = pdma[oldestBufferIdx].head_time_cnt * timerPeriodUsecTime;
// Get adc data from DMA packet // Get adc data from DMA packet
uint32 k; uint32 k;
uint32 s; uint32 s;
for (k=0u; k < ATCA_IOP_N_ADCs ; k++) { for (k=0u; k < ATCA_IOP_N_ADCs ; k++) {
adcValues[k] = (mappedDmaBase[oldestBufferIdx * RT_PCKT_SIZE + //adcValues[k] = (mappedDmaBase[oldestBufferIdx * RT_PCKT_SIZE +
IOP_ADC_OFFSET + k] ) / (1<<14); // IOP_ADC_OFFSET + k] ) / (1<<14);
adcValues[k] = pdma[oldestBufferIdx].adc_decim_data[k] / (1<<14);
} }
int64 * mappedDmaBase64 = (int64 *) mappedDmaBase; //int64 * mappedDmaBase64 = (int64 *) mappedDmaBase;
for (k=0u; k < ATCA_IOP_N_INTEGRALS ; k++) { for (k=0u; k < ATCA_IOP_N_INTEGRALS ; k++) {
adcIntegralValues[k] = mappedDmaBase64[oldestBufferIdx * RT_PCKT64_SIZE + IOP_ADC_INTEG_OFFSET + k]; adcIntegralValues[k] = pdma[oldestBufferIdx].adc_integ_data[k];
//mappedDmaBase64[oldestBufferIdx * RT_PCKT64_SIZE + IOP_ADC_INTEG_OFFSET + k];
} }
float64 t = counterAndTimer[1]; float64 t = counterAndTimer[1];
t /= 1e6; t /= 1e6;
// Compute simulated Sinus Signals // Compute simulated Sinus Signals
@@ -729,39 +747,42 @@ uint32 AtcaIopADC::GetSleepPercentage() const {
* */ * */
int32 AtcaIopADC::PollDma(uint64 waitLimitTicks) const { int32 AtcaIopADC::PollDma(uint64 waitLimitTicks) const {
uint32 buffIdx = oldestBufferIdx; //uint32 oldBufferFooter = mappedDmaBase[buffIdx * RT_PCKT_SIZE + 62];
uint32 oldBufferFooter = mappedDmaBase[buffIdx * RT_PCKT_SIZE + 62]; DMA_CH1_PCKT *pdma = (DMA_CH1_PCKT *) mappedDmaBase;
uint32 freshBufferFooter = oldBufferFooter; uint32 oldBufferFooter = pdma[oldestBufferIdx].foot_time_cnt;
uint64 actualTime = HighResolutionTimer::Counter(); volatile uint32 freshBufferFooter = oldBufferFooter;
while (freshBufferFooter == oldBufferFooter) { //uint32 buffIdx = oldestBufferIdx;
if(actualTime > waitLimitTicks) { uint64 actualTime = HighResolutionTimer::Counter();
return -1; while (freshBufferFooter == oldBufferFooter) {
} if(actualTime > waitLimitTicks) {
actualTime = HighResolutionTimer::Counter(); return -1;
freshBufferFooter = mappedDmaBase[buffIdx * RT_PCKT_SIZE + 62];
} }
uint32 headTimeMark = mappedDmaBase[buffIdx * RT_PCKT_SIZE]; actualTime = HighResolutionTimer::Counter();
if(headTimeMark != freshBufferFooter) //freshBufferFooter = mappedDmaBase[buffIdx * RT_PCKT_SIZE + 62];
{ freshBufferFooter = pdma[oldestBufferIdx].foot_time_cnt;
//currentBufferIdx = buffIdx; }
//currentMasterHeader = pdma[currentBufferIdx].head_time_cnt; //uint32 headTimeMark = mappedDmaBase[buffIdx * RT_PCKT_SIZE];
return -2; uint32 headTimeMark = pdma[oldestBufferIdx].head_time_cnt ;
} if(headTimeMark != freshBufferFooter)
return buffIdx; {
return -2;
}
return oldestBufferIdx;
} }
uint32 AtcaIopADC::GetOldestBufferIdx() const { uint32 AtcaIopADC::GetOldestBufferIdx() const {
volatile uint32 oldestBufferHeader = mappedDmaBase[0]; DMA_CH1_PCKT *pdma = (DMA_CH1_PCKT *) mappedDmaBase;
uint32 buffIdx = 0u; uint32 buffIdx = 0u;
volatile uint32 header = mappedDmaBase[0]; volatile uint32 header = pdma[buffIdx].head_time_cnt;
for (uint32 dmaIndex = 1u; dmaIndex < NUMBER_OF_BUFFERS; dmaIndex++) { volatile uint32 oldestBufferHeader = header;
header = mappedDmaBase[dmaIndex * RT_PCKT_SIZE]; for (uint32 dmaIndex = 1u; dmaIndex < NUMBER_OF_BUFFERS; dmaIndex++) {
if (header < oldestBufferHeader) { header = pdma[dmaIndex].head_time_cnt;
oldestBufferHeader = header; if (header < oldestBufferHeader) {
buffIdx = dmaIndex; oldestBufferHeader = header;
} buffIdx = dmaIndex;
} }
return buffIdx; }
return buffIdx;
} }
CLASS_REGISTER(AtcaIopADC, "1.0") CLASS_REGISTER(AtcaIopADC, "1.0")

View File

@@ -401,7 +401,8 @@ namespace MARTe {
/** /**
* Pointer to mapped memory * Pointer to mapped memory
*/ */
int32 * mappedDmaBase; //int32 * mappedDmaBase;
void * mappedDmaBase;
uint32 mappedDmaSize; uint32 mappedDmaSize;
/** /**
* The last written buffer * The last written buffer