IMPLEMENT bool Uart::startup(Address _port, int __irq) { port = _port; _irq = __irq; Proc::Status o = Proc::cli_save(); if (!valid()) { Proc::sti_restore(o); fail(); return false; } ier(Base_ier_bits);/* disable all rs-232 interrupts */ mcr(0x0b); /* out2, rts, and dtr enabled */ fcr(1); /* enable fifo */ fcr(0x07); /* clear rcv xmit fifo */ fcr(1); /* enable fifo */ lcr(0); /* clear line control register */ /* clearall interrupts */ /*read*/ msr(); /* IRQID 0*/ /*read*/ iir(); /* IRQID 1*/ /*read*/ trb(); /* IRQID 2*/ /*read*/ lsr(); /* IRQID 3*/ while(lsr() & 1/*DATA READY*/) /*read*/ trb(); Proc::sti_restore(o); return true; }
IMPLEMENT void Uart::shutdown() { Proc::Status o = Proc::cli_save(); mcr(0x06); fcr(0); lcr(0); ier(0); Proc::sti_restore(o); }
int main(int argc, char *argv[]) { // Signal settings. double rate = 1e6; double freq = 10e3; double fc = 150e3; // Modulation settings double gain = 1; double rel_fc = fc / rate; double rel_fs = freq / rate; boost::shared_ptr<SharedType<double> > fcr(new SharedType<double>(rel_fc)); // Specific Modulation Settings. AmDemod::SideBand sideBand = AmDemod::SideBand::DOUBLE; unsigned int constSize = 16; int supp_carrier = 1; double mod_index = 0.5; // Frame size and FFT size. size_t N = 2048; size_t frameSize = 384; /*************************************************************************************************** * Create stream object * **************************************************************************************************/ // AM Stream function. StreamFunction * _streamFunction = new AmFunction(new cosFunction(freq), mod_index, rel_fc, sideBand, supp_carrier); //StreamFunction * _streamFunction = new eFunction(freq); StreamFunction * _noisyStreamFunction = new AwgnFunction(_streamFunction, 0, 1e6, 1e6); // FM Stream Function //StreamFunction * _streamFunction = new FmFunction(new cosFunction(freq), mod_index, rel_fc); // MPSK Stream Function //StreamFunction * _streamFunction = new DigitalFunction(new MPskFunction(constSize), rel_fs, rel_fc); // ------------ Create Streamer Object ------------ // // UhdMock Object boost::scoped_ptr < Streamer > _dataStream(new UhdMock(_noisyStreamFunction, rate, gain, frameSize)); // UhdRead Object // boost::scoped_ptr < Streamer > _dataStream(new UhdRead(rate, freq, gain, frameSize)); /*************************************************************************************************** * Initialize utilities * **************************************************************************************************/ // Get shared buffer boost::shared_ptr < SharedBuffer<std::complex<double> > > _buffer(_dataStream->getBuffer()); // Create fft generator function. FFTGenerator _fftGen(_buffer, rate, N); AmcClassifier<double, AMC::ModType> * classifier = new AmcZnDecisionTree(); //classifier->load("test0"); std::string dir = "/home/jcq/git/Automatic-Modulation-Classification-ELEN4012/train-data/2015-10-12-3"; ClassifierTrainer ct(classifier,dir); ct.train(); ct.save("test0"); //AMC::FeatureExtractor _featureExtractor(_buffer, classifier, N, rate); AMC::FeatureExtractor _featureExtractor(_buffer, classifier, rate, fcr, N); AMC::FeatureExtractor _featureExtractor(_buffer, rate, fcr, bwr,N,1); /*************************************************************************************************** * Initialize GUI Objects * **************************************************************************************************/ // Initialize interface. QApplication _app(argc, argv); MainWindow _mainWindow(rate, N); _mainWindow.show(); _mainWindow.setData(_fftGen.getFreqVec(), _fftGen.getFftVec()); _mainWindow.setBuffer(_buffer); _mainWindow.setSharedModType(_featureExtractor.getSharedModType()); /*************************************************************************************************** * Start threads. * **************************************************************************************************/ _dataStream->startStream(); // _amcRecv.startDemod(); _fftGen.startFft(); _featureExtractor.start(AMC::FeatureExtractor::ExtractionMode::CLASSIFY); return _app.exec(); }