|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | + |
| 3 | +#include "modelRP2040.h" |
| 4 | +#include "hantekdsocontrol.h" |
| 5 | +#include "hantekprotocol/controlStructs.h" |
| 6 | +#include "usb/scopedevice.h" |
| 7 | +#include <QDebug> |
| 8 | +#include <QDir> |
| 9 | +#include <QSettings> |
| 10 | + |
| 11 | + |
| 12 | +#define VERBOSE 0 |
| 13 | + |
| 14 | +using namespace Hantek; |
| 15 | + |
| 16 | +static ModelRP2040 modelInstance_rp2040; |
| 17 | + |
| 18 | +static void initSpecifications( Dso::ControlSpecification &specification ) { |
| 19 | + // we drop 2K + 480 sample values due to unreliable start of stream |
| 20 | + // 20000 samples at 100kS/s = 200 ms gives enough to fill |
| 21 | + // the screen two times (for pre/post trigger) at 10ms/div = 100ms/screen |
| 22 | + // SAMPLESIZE defined in hantekdsocontrol.h |
| 23 | + // adapt accordingly in HantekDsoControl::convertRawDataToSamples() |
| 24 | + |
| 25 | + // HW gain, voltage steps in V/div (ranges 20,50,100,200,500,1000,2000,5000 mV) |
| 26 | + specification.gain = { { 10, 20e-3 }, { 10, 50e-3 }, { 10, 100e-3 }, { 5, 200e-3 }, |
| 27 | + { 2, 500e-3 }, { 1, 1.00 }, { 1, 2.00 }, { 1, 5.00 } }; |
| 28 | + |
| 29 | + // Define the scaling between ADC sample values and real input voltage |
| 30 | + // Everything is scaled on the full screen height (8 divs) |
| 31 | + // The voltage/div setting: 20m 50m 100m 200m 500m 1V 2V 5V |
| 32 | + // Equivalent input voltage: 0.16V 0.4V 0.8V 1.6V 4V 8V 16V 40V |
| 33 | + // Theoretical gain setting: x10 x10 x10 x5 x2 x1 x1 x1 |
| 34 | + // mV / digit: 4 4 4 8 20 40 40 40 |
| 35 | + // specification.voltageScale[ 0 ] = { 255, 255, 255, 127.5, 51, 25.5, 25.5, 25.5 }; |
| 36 | + // specification.voltageScale[ 1 ] = { 255, 255, 255, 127.5, 51, 25.5, 25.5, 25.5 }; |
| 37 | + specification.voltageScale[ 0 ] = { 250, 250, 250, 125, 50, 25, 25, 25 }; |
| 38 | + specification.voltageScale[ 1 ] = { 250, 250, 250, 125, 50, 25, 25, 25 }; |
| 39 | + // Gain and offset can be corrected by individual config values from EEPROM or file |
| 40 | + // Lower effective sample rates < 10 kS/s use oversampling to increase the SNR |
| 41 | + |
| 42 | + specification.samplerate.single.base = 100e3; |
| 43 | + specification.samplerate.single.max = 1e6; |
| 44 | + specification.samplerate.single.recordLengths = { UINT_MAX }; |
| 45 | + specification.samplerate.multi.base = 100e3; |
| 46 | + specification.samplerate.multi.max = 1e6; |
| 47 | + specification.samplerate.multi.recordLengths = { UINT_MAX }; |
| 48 | + |
| 49 | + specification.fixedSampleRates = { |
| 50 | + // samplerate, sampleId, downsampling |
| 51 | + { 1e3, 101, 10 }, |
| 52 | + { 2e3, 102, 10 }, |
| 53 | + { 5e3, 105, 10 }, |
| 54 | + { 10e3, 101, 1 }, |
| 55 | + { 20e3, 102, 1 }, |
| 56 | + { 50e3, 105, 1 }, |
| 57 | + { 100e3, 110, 1 }, |
| 58 | + { 200e3, 120, 1 }, |
| 59 | + { 500e3, 150, 1 }, |
| 60 | + { 1e6, 1, 1 } |
| 61 | + }; |
| 62 | + |
| 63 | + specification.couplings = { Dso::Coupling::DC, Dso::Coupling::AC }; |
| 64 | + specification.triggerModes = { |
| 65 | + Dso::TriggerMode::AUTO, |
| 66 | + Dso::TriggerMode::NORMAL, |
| 67 | + Dso::TriggerMode::SINGLE, |
| 68 | + Dso::TriggerMode::ROLL, |
| 69 | + }; |
| 70 | + |
| 71 | + specification.fixedUSBinLength = 0; |
| 72 | + |
| 73 | + specification.calfreqSteps = { 30, 40, 50, 60, 80, 100, 120, 160, 200, 250, 300, 400, 440, |
| 74 | + 500, 600, 660, 800, 1000, 1200, 1600, 2000, 2500, 3300, 4000, 5000, 6000, |
| 75 | + 8000, 10e3, 12e3, 16e3, 20e3, 25e3, 30e3, 40e3, 50e3, 60e3, 80e3, 100e3 }; |
| 76 | + specification.hasCalibrationEEPROM = false; |
| 77 | +} |
| 78 | + |
| 79 | +static void applyRequirements_( HantekDsoControl *dsoControl ) { |
| 80 | + dsoControl->addCommand( new ControlSetGain_CH1() ); // 0xE0 |
| 81 | + dsoControl->addCommand( new ControlSetGain_CH2() ); // 0xE1 |
| 82 | + dsoControl->addCommand( new ControlSetSamplerate() ); // 0xE2 |
| 83 | + dsoControl->addCommand( new ControlStartSampling() ); // 0xE3 |
| 84 | + dsoControl->addCommand( new ControlSetNumChannels() ); // 0xE4 |
| 85 | + dsoControl->addCommand( new ControlSetCoupling() ); // 0xE5 (no effect w/o AC/DC HW mod) |
| 86 | + dsoControl->addCommand( new ControlSetCalFreq() ); // 0xE6 |
| 87 | +} |
| 88 | + |
| 89 | +/// VID/PID active VID/PID no FW Scope name |
| 90 | +// |------------| |------------| |------| |
| 91 | +ModelRP2040::ModelRP2040() |
| 92 | + : DSOModel( ID, 0x04b5, 0x2040, 0x04b5, 0x2040, 0, "", "RP2040", Dso::ControlSpecification( 2 ) ) { |
| 93 | + initSpecifications( specification ); |
| 94 | +} |
| 95 | + |
| 96 | +void ModelRP2040::applyRequirements( HantekDsoControl *dsoControl ) const { applyRequirements_( dsoControl ); } |
| 97 | + |
| 98 | + |
0 commit comments