##// END OF EJS Templates
waveform display added for the normal mode...
waveform display added for the normal mode packet statistics added for all modes

File last commit:

r0:081a6eb3cced default
r19:7f565009af54 default
Show More
spectralmatricesdmasimulator.cpp
133 lines | 5.9 KiB | text/x-c | CppLexer
/ rmapplugin / spectralmatricesdmasimulator.cpp
#include "spectralmatricesdmasimulator.h"
SpectralMatricesDMASimulator::SpectralMatricesDMASimulator(QWidget *parent) :
QWidget(parent)
{
timer = new QTimer;
QString message;
count = SPECTRAL_MATRIX_SIZE;
unsigned int i = 0;
Value = (unsigned int*) malloc(count*sizeof(int));
for (i=0; i<count; i++){
Value[i] = i;
}
spectralMatrixCTRL = 0x00;
spectralMatrixAddress1 = 0x40000000;
spectralMatrixAddress2 = 0x40000004;
irqctrlForce = 0x00001000; // force irq 12
flagSendMatrix1 = true;
sendOneSpectralMatrix1Button = new QPushButton(tr("Send 1 Spectral Matrix at address 1"));
sendOneSpectralMatrix2Button = new QPushButton(tr("Send 1 Spectral Matrix at address 2"));
readMatrixAddress1Button = new QPushButton(tr("Read Spectral Matrix Address (1)"));
readMatrixAddress2Button = new QPushButton(tr("Read Spectral Matrix Address (2)"));
startSendingMatricesButton = new QPushButton(tr("Start sending matrices periodically"));
stopSendingMatricesButton = new QPushButton(tr("Stop sending matrices periodically"));
mainLayout = new QVBoxLayout;
mainLayout->addWidget(sendOneSpectralMatrix1Button);
mainLayout->addWidget(sendOneSpectralMatrix2Button);
mainLayout->addWidget(readMatrixAddress1Button);
mainLayout->addWidget(readMatrixAddress2Button);
mainLayout->addWidget(startSendingMatricesButton);
mainLayout->addWidget(stopSendingMatricesButton);
this->setLayout(mainLayout);
message.append("Address of the Spectral Matrix N°1: " + QString::number(spectralMatrixAddress1));
emit sendMessage(message);
message.append("Address of the Spectral Matrix N°2: " + QString::number(spectralMatrixAddress2));
emit sendMessage(message);
connect(this->sendOneSpectralMatrix1Button, SIGNAL(clicked()), this, SLOT(sendOneSpectralMatrix1SLOT()));
connect(this->sendOneSpectralMatrix2Button, SIGNAL(clicked()), this, SLOT(sendOneSpectralMatrix2SLOT()));
connect(this->readMatrixAddress1Button, SIGNAL(clicked()), this, SLOT(readMatrixAddress1SLOT()));
connect(this->readMatrixAddress2Button, SIGNAL(clicked()), this, SLOT(readMatrixAddress2SLOT()));
connect(this->timer, SIGNAL(timeout()), this, SLOT(sendOneSpectralMatrixSLOT()));
connect(this->startSendingMatricesButton, SIGNAL(clicked()), this, SLOT(startSendingMatricesSLOT()));
connect(this->stopSendingMatricesButton, SIGNAL(clicked()), this, SLOT(stopSendingMatricesSLOT()));
}
void SpectralMatricesDMASimulator::sendOneSpectralMatrix1SLOT()
{
emit(rmapplugginRead(&spectralMatrixAddress1, 1, APB_SPECTRAL_MATRICES_DMA1));
emit(rmapplugginWrite(Value, count, spectralMatrixAddress1));
emit(rmapplugginRead(&spectralMatrixCTRL, 1, APB_SPECTRAL_MATRICES_CTRL));
spectralMatrixCTRL = spectralMatrixCTRL | 0x00000001;
emit(rmapplugginWrite(&spectralMatrixCTRL, 1, APB_SPECTRAL_MATRICES_CTRL));
emit(rmapplugginWrite(&irqctrlForce, 1, APB_ADDRESS_IRQCTRL));
}
void SpectralMatricesDMASimulator::sendOneSpectralMatrix2SLOT()
{
emit(rmapplugginRead(&spectralMatrixAddress2, 1, APB_SPECTRAL_MATRICES_DMA2));
emit(rmapplugginWrite(Value, count, spectralMatrixAddress2));
emit(rmapplugginRead(&spectralMatrixCTRL, 1, APB_SPECTRAL_MATRICES_CTRL));
spectralMatrixCTRL = spectralMatrixCTRL | 0x00000002;
emit(rmapplugginWrite(&spectralMatrixCTRL, 1, APB_SPECTRAL_MATRICES_CTRL));
emit(rmapplugginWrite(&irqctrlForce, 1, APB_ADDRESS_IRQCTRL));
}
void SpectralMatricesDMASimulator::sendOneSpectralMatrixSLOT()
{
if (flagSendMatrix1 == true)
{
emit(rmapplugginRead(&spectralMatrixCTRL, 1, APB_SPECTRAL_MATRICES_CTRL));
if ( (spectralMatrixCTRL & 1) == 1) emit(sendMessage("ERROR matrix 1 not processed"));
//emit(rmapplugginWrite(Value, count, spectralMatrixAddress1));
spectralMatrixCTRL = spectralMatrixCTRL | 0x00000001; // sets the bit 0 of the ctrl register to 1
emit(rmapplugginWrite(&spectralMatrixCTRL, 1, APB_SPECTRAL_MATRICES_CTRL));
emit(rmapplugginWrite(&irqctrlForce, 1, APB_ADDRESS_IRQCTRL));
flagSendMatrix1 = false;
nbMatricesSent++;
if (nbMatricesSent==400) {
emit(sendMessage("400 matrices successfully sent"));
nbMatricesSent = 0;
}
}
else if (flagSendMatrix1 == false)
{
emit(rmapplugginRead(&spectralMatrixCTRL, 1, APB_SPECTRAL_MATRICES_CTRL));
if ( ( (spectralMatrixCTRL>>1) & 1 ) == 1 ) emit(sendMessage("ERROR matrix 2 not processed"));
//emit(rmapplugginWrite(Value, count, spectralMatrixAddress2));
spectralMatrixCTRL = spectralMatrixCTRL | 0x00000002; // sets the bit 1 of the ctrl register to 1
emit(rmapplugginWrite(&spectralMatrixCTRL, 1, APB_SPECTRAL_MATRICES_CTRL));
emit(rmapplugginWrite(&irqctrlForce, 1, APB_ADDRESS_IRQCTRL));
flagSendMatrix1 = true;
nbMatricesSent++;
if (nbMatricesSent==400) {
emit(sendMessage("400 matrices successfully sent"));
nbMatricesSent = 0;
}
}
}
void SpectralMatricesDMASimulator::readMatrixAddress1SLOT()
{
QString message;
emit(rmapplugginRead(&spectralMatrixAddress1, 1, APB_SPECTRAL_MATRICES_DMA1));
message.append("Address of the Spectral Matrix (1): "
+ QString::number(spectralMatrixAddress1, 16));
emit sendMessage(message);
}
void SpectralMatricesDMASimulator::readMatrixAddress2SLOT()
{
QString message;
emit(rmapplugginRead(&spectralMatrixAddress2, 1, APB_SPECTRAL_MATRICES_DMA2));
message.append("Address of the Spectral Matrix (2): "
+ QString::number(spectralMatrixAddress2, 16));
emit sendMessage(message);
}
void SpectralMatricesDMASimulator::startSendingMatricesSLOT()
{
nbMatricesSent = 0;
readMatrixAddress1SLOT();
readMatrixAddress2SLOT();
timer->start(40);
}
void SpectralMatricesDMASimulator::stopSendingMatricesSLOT()
{
timer->stop();
}