Skip to content

Commit b4239ea

Browse files
author
neil.hamilton
committed
Merge TSP-514-Create-Examples-for-psospa into master
2 parents c6f59d7 + 05605dc commit b4239ea

File tree

10 files changed

+1141
-14
lines changed

10 files changed

+1141
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
**/*.obj
77
**/*.lib
88
**/*.exp
9+
**/*.bak
910

1011
# All platforms
1112

picosdk/PicoDeviceEnums.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ def _define_threshold_direction():
217217

218218
picoEnum.PICO_ETS_MODE = make_enum([
219219
"PICO_ETS_OFF",
220-
"PICO_WINDOW",
220+
"PICO_ETS_FAST",
221+
"PICO_ETS_SLOW"
221222
])
222223

223224
picoEnum.PICO_INDEX_MODE = make_enum([
@@ -250,6 +251,7 @@ def _define_resolution():
250251
PICO_DR_15BIT = 3
251252
PICO_DR_16BIT = 4
252253
PICO_DR_10BIT = 10
254+
PICO_DR_10BIT_TURBO = 0x1A
253255

254256
return {k.upper(): v for k, v in locals().items() if k.startswith("PICO")}
255257

@@ -312,7 +314,7 @@ def _define_conditions_info():
312314
])
313315

314316
def _define_digital_port():
315-
Pico_DIGITAL_PORT_NONE = 0
317+
PICO_DIGITAL_PORT_NONE = 0
316318
PICO_DIGITAL_PORT_MSO_POD = 1000
317319
PICO_DIGITAL_PORT_UNKNOWN_DEVICE = -2
318320

@@ -326,4 +328,13 @@ def _define_digital_port():
326328
"PICO_FREQUENCY_10MHZ",
327329
"PICO_FREQUENCY_20MHZ",
328330
"PICO_FREQUENCY_25MHZ"
329-
])
331+
])
332+
333+
def _define_power_delivery_device_type():
334+
PICO_USB_POWER_DELIEVRY_DEVICE_TYPE_NOTHING = 0
335+
PICO_USB_POWER_DELIEVRY_DEVICE_TYPE_SOURCE = 2
336+
PICO_USB_POWER_DELIEVRY_DEVICE_TYPE_DEBUG = 3
337+
338+
return {k.upper(): v for k, v in locals().items() if k.startswith("PICO")}
339+
340+
picoEnum.PICO_USB_POWER_DELIEVRY_DEVICE_TYPE = _define_power_delivery_device_type

picosdk/PicoDeviceStructs.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ class PICO_SCALING_FACTORS(Structure):
117117

118118
picoStruct.PICO_SCALING_FACTORS = PICO_SCALING_FACTORS
119119

120+
class PICO_SCALING_FACTORS_FOR_RANGE_TYPES(Structure):
121+
_pack_ = 1
122+
_fields_ = [("channel", c_uint32),
123+
("rangeMin", c_int64),
124+
("rangeMax", c_int64),
125+
("rangeType", c_uint32),
126+
("offset", c_int16),
127+
("scalingFactor", c_double)]
128+
129+
picoStruct.PICO_SCALING_FACTORS_FOR_RANGE_TYPES = PICO_SCALING_FACTORS_FOR_RANGE_TYPES
130+
120131
class PROBE_APP(Structure):
121132
_pack_ = 1
122133
_fields_ = [("id", c_int32),
@@ -141,4 +152,32 @@ class PICO_DIGITAL_PORT_INTERACTIONS(Structure):
141152
("serial", c_int8),
142153
("calibrationDate", c_int8)]
143154

144-
picoStruct.PICO_DIGITAL_PORT_INTERACTIONS = PICO_DIGITAL_PORT_INTERACTIONS
155+
picoStruct.PICO_DIGITAL_PORT_INTERACTIONS = PICO_DIGITAL_PORT_INTERACTIONS
156+
157+
class PICO_CHANNEL_OVERVOLTAGE_TRIPPED(Structure):
158+
_pack_ = 1
159+
_fields_ = [("channel", c_uint32),
160+
("tripped", c_uint8)]
161+
162+
picoStruct.PICO_CHANNEL_OVERVOLTAGE_TRIPPED = PICO_CHANNEL_OVERVOLTAGE_TRIPPED
163+
164+
class PICO_USB_POWER_DELIVERY(Structure):
165+
_pack_ = 1
166+
_fields_ = [("valid", c_uint8),
167+
("busVoltagemV", c_uint32),
168+
("rpCurrentLimitmA", c_uint32),
169+
("partnerConnected", c_uint8),
170+
("ccPolarity", c_uint8),
171+
("attachedDevice", c_uint32),
172+
("contractExists", c_uint8),
173+
("currentPdo", c_uint32),
174+
("currentRdo", c_uint32)]
175+
176+
picoStruct.PICO_USB_POWER_DELIVERY = PICO_USB_POWER_DELIVERY
177+
178+
class PICO_USB_POWER_DETAILS(Structure):
179+
_pack_ = 1
180+
_fields_ = [("dataPort", c_uint32),
181+
("powerPort", c_uint32)]
182+
183+
picoStruct.PICO_USB_POWER_DETAILS = PICO_USB_POWER_DETAILS

picosdk/functions.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.
2+
# Copyright (C) 2018-2024 Pico Technology Ltd. See LICENSE file for terms.
33
#
44
from __future__ import division
55
import numpy as np
@@ -172,3 +172,30 @@ def assert_pico2000_ok(status):
172172
else:
173173
errorCheck = False
174174
raise PicoSDKCtypesError("Unsuccessful API call")
175+
176+
def mV2adcV2(millivolts, rangeMax, maxADC):
177+
"""
178+
mV2adcV2(
179+
float millivolts
180+
int rangeMax
181+
c_int32 maxADC
182+
)
183+
Takes a voltage value and converts it into adc counts for psospa driver scopes
184+
"""
185+
adcValue = round((millivolts * maxADC.value)/(rangeMax/1000000))
186+
187+
return adcValue
188+
189+
def adc2mVV2(bufferADC, rangeMax, maxADC):
190+
"""
191+
adc2mVV2(
192+
c_short_Array bufferADC
193+
int rangeMax
194+
c_int32 maxADC
195+
)
196+
197+
Takes a buffer of raw adc count values and converts it into millivolts for psospa driver scopes
198+
"""
199+
buffermV = [(x * (rangeMax/1000000)) / maxADC.value for x in bufferADC]
200+
201+
return buffermV

picosdk/ps6000a.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def __init__(self):
2020

2121
ps6000a = Ps6000alib()
2222

23+
ps6000a.DEFAULT_RESOLUTION = enums.PICO_DEVICE_RESOLUTION["PICO_DR_8BIT"]
24+
2325
doc = """ void ps6000aExternalReferenceInteractions
2426
(
2527
int16_t handle,
@@ -144,7 +146,7 @@ def __init__(self):
144146
int16_t *requiredSize,
145147
PICO_INFO info
146148
); """
147-
ps6000a.make_symbol("_GetUnitInfo", "ps6000aGetUnitInfo", c_uint32, [c_int16, c_char_p, c_int16, c_void_p, c_int32], doc)
149+
ps6000a.make_symbol("_GetUnitInfo", "ps6000aGetUnitInfo", c_uint32, [c_int16, c_char_p, c_int16, c_void_p, c_uint32], doc)
148150

149151
doc = """ PICO_STATUS ps6000aCloseUnit
150152
(

0 commit comments

Comments
 (0)