#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; iaddWidget(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(); }