Skip to content

Commit a99ec8f

Browse files
committed
add sig_gen_arbitrary_min_max_values
1 parent b4d501c commit a99ec8f

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

common/src/sig_gen.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#[derive(Debug, Clone)]
2+
pub struct SigGenArbitraryMinMaxValues {
3+
pub min_value: i16,
4+
pub max_value: i16,
5+
pub min_size: u32,
6+
pub max_size: u32,
7+
}

driver/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use parking_lot::RwLock;
4747
use pico_common::{
4848
ChannelConfig, Driver, FromPicoStr, PicoChannel, PicoError, PicoInfo, PicoRange, PicoResult, SampleConfig,
4949
PicoSweepType, PicoExtraOperations, PicoIndexMode, PicoSigGenTrigType, PicoSigGenTrigSource, PicoWaveType,
50-
SweepShotCount,
50+
SweepShotCount, SigGenArbitraryMinMaxValues,
5151
};
5252
pub use resolution::Resolution;
5353
use std::{fmt, pin::Pin, sync::Arc};
@@ -228,6 +228,13 @@ pub trait PicoDriver: fmt::Debug + Send + Sync {
228228
) -> PicoResult<()> {
229229
unimplemented!()
230230
}
231+
232+
fn sig_gen_arbitrary_min_max_values(
233+
&self,
234+
_handle: i16,
235+
) -> PicoResult<SigGenArbitraryMinMaxValues> {
236+
unimplemented!();
237+
}
231238
}
232239

233240
pub type ArcDriver = Arc<dyn PicoDriver>;

driver/src/ps2000a.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use pico_common::{
99
ChannelConfig, DownsampleMode, Driver, FromPicoStr, PicoChannel, PicoError, PicoInfo, PicoRange,
1010
PicoResult, PicoStatus, SampleConfig, ToPicoStr, PicoSweepType,
1111
PicoExtraOperations, PicoIndexMode, PicoSigGenTrigType, PicoSigGenTrigSource, PicoWaveType,
12-
SweepShotCount,
12+
SweepShotCount, SigGenArbitraryMinMaxValues,
1313
};
1414
use pico_sys_dynamic::ps2000a::{PS2000A_EXTRA_OPERATIONS, PS2000A_INDEX_MODE, PS2000A_SIGGEN_TRIG_SOURCE, PS2000A_SIGGEN_TRIG_TYPE, PS2000A_SWEEP_TYPE, PS2000ALoader};
1515
use std::{pin::Pin, sync::Arc};
@@ -384,7 +384,7 @@ impl PicoDriver for PS2000ADriver {
384384
trigger_type: PicoSigGenTrigType,
385385
trigger_source: PicoSigGenTrigSource,
386386
ext_in_threshold: i16,
387-
) -> PicoResult<()> {
387+
) -> PicoResult<()> {
388388
// TODO: no idea how to do this better
389389
// to avoid the data being taken away, store a copy here?
390390
// go read the SDK to see if the memory is caller responsibility or
@@ -410,5 +410,28 @@ impl PicoDriver for PS2000ADriver {
410410
trigger_source as PS2000A_SIGGEN_TRIG_SOURCE,
411411
ext_in_threshold)
412412
}).to_result((), "set_sig_gen_arbitrary")
413-
}
413+
}
414+
415+
fn sig_gen_arbitrary_min_max_values(
416+
&self,
417+
handle: i16,
418+
) -> PicoResult<SigGenArbitraryMinMaxValues> {
419+
let mut min_value: i16 = 0;
420+
let mut max_value: i16 = 0;
421+
let mut min_size: u32 = 0;
422+
let mut max_size: u32 = 0;
423+
PicoStatus::from(unsafe {
424+
self.bindings.ps2000aSigGenArbitraryMinMaxValues(
425+
handle,
426+
&mut min_value,
427+
&mut max_value,
428+
&mut min_size,
429+
&mut max_size,
430+
)}).to_result(SigGenArbitraryMinMaxValues {
431+
min_value,
432+
max_value,
433+
min_size,
434+
max_size,
435+
}, "sig_gen_arbitrary_min_max_values")
436+
}
414437
}

0 commit comments

Comments
 (0)