Skip to content

Commit c305669

Browse files
author
neil.hamilton
committed
Create usbDrDaq.py with API functions and enums
1 parent 776fac8 commit c305669

File tree

1 file changed

+304
-0
lines changed

1 file changed

+304
-0
lines changed

picosdk/usbDrDaq.py

Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
#
2+
# Copyright (C) 2014-2020 Pico Technology Ltd. See LICENSE file for terms.
3+
#
4+
"""
5+
This is a Python module defining the functions from the usbDrDaqApi.h C header
6+
file for DrDaq Data Logger using the usbDrDaq driver API
7+
functions.
8+
"""
9+
10+
from ctypes import *
11+
from picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY
12+
from picosdk.library import Library
13+
from picosdk.constants import make_enum
14+
15+
class UsbDrDaqlib(Library):
16+
def __init__(self):
17+
super(UsbDrDaqlib, self).__init__("usbDrDaq")
18+
19+
20+
usbDrDaq = UsbDrDaqlib()
21+
22+
usbDrDaq.USB_DRDAQ_INPUTS = make_enum([
23+
"USB_DRDAQ_CHANNEL_EXT1",
24+
"USB_DRDAQ_CHANNEL_EXT2",
25+
"USB_DRDAQ_CHANNEL_EXT3",
26+
"USB_DRDAQ_CHANNEL_SCOPE",
27+
"USB_DRDAQ_CHANNEL_PH",
28+
"USB_DRDAQ_CHANNEL_RES",
29+
"USB_DRDAQ_CHANNEL_LIGHT",
30+
"USB_DRDAQ_CHANNEL_TEMP",
31+
"USB_DRDAQ_CHANNEL_MIC_WAVE",
32+
("USB_DRDAQ_CHANNEL_MIC_LEVEL", "USB_DRDAQ_MAX_CHANNELS")
33+
])
34+
35+
usbDrDaq.USB_DRDAQ_GPIO = make_enum([
36+
"USB_DRDAQ_GPIO_1",
37+
"USB_DRDAQ_GPIO_2",
38+
"USB_DRDAQ_GPIO_3",
39+
"USB_DRDAQ_GPIO_4"
40+
])
41+
42+
doc = """ PICO_STATUS UsbDrDaqCloseUnit
43+
(
44+
int16_t handle
45+
); """
46+
usbDrDaq.make_symbol("_CloseUnit", "UsbDrDaqCloseUnit", c_uint32, [c_int16], doc)
47+
48+
doc = """ PICO_STATUS UsbDrDaqEnabledRGBLED
49+
(
50+
int16_t handle,
51+
int16_t enabled
52+
); """
53+
usbDrDaq.make_symbol("_EnableRGBLED", "UsbDrDaqEnableRGBLED", c_uint32, [c_int16, c_int16], doc)
54+
55+
doc = """ PICO_STATUS UsbDrDaqGetChannelInfo
56+
(
57+
int16_t handle,
58+
float *min,
59+
float *max,
60+
int16_t *places,
61+
int16_t *divider,
62+
USB_DRDAQ_INPUTS channel
63+
); """
64+
usbDrDaq.make_symbol("_GetChannelInfo", "UsbDrDaqGetChannelInfo", c_uint32, [c_int16, c_void_p, c_void_p, c_void_p, c_void_p, c_uint32], doc)
65+
66+
doc = """ PICO_STATUS UsbDrDaqGetInput
67+
(
68+
int16_t handle,
69+
USB_DRDAQ_GPIO IOChannel,
70+
int16_t pullUp,
71+
int16_t *value
72+
); """
73+
usbDrDaq.make_symbol("_GetInput", "UsbDrDaqGetInput", c_uint32, [c_int16, c_uint32, c_int16, c_void_p], doc)
74+
75+
doc = """ PICO_STATUS UsbDrDaqGetPulseCount
76+
(
77+
int16_t handle,
78+
USB_DRDAQ_GPIO IOChannel,
79+
int16_t *count
80+
); """
81+
usbDrDaq.make_symbol("_GetPulseCount", "UsbDrDaqGetPulseCount", c_uint32, [c_int16, c_uint32, c_void_p], doc)
82+
83+
doc = """ PICO_STATUS UsbDrDaqGetScalings
84+
(
85+
int16_t handle,
86+
USB_DRDAQ_INPUTS channel,
87+
int16_t *nScales
88+
int16_t *currentScale,
89+
int8_t *names
90+
int16_t namesSize
91+
); """
92+
usbDrDaq.make_symbol("_GetScalings", "UsbDrDaqGetScalings", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p, c_void_p, c_int16], doc)
93+
94+
doc = """ PICO_STATUS UsbDrDaqGetSingle
95+
(
96+
int16_t handle,
97+
USB_DRDAQ_INPUTS channel,
98+
int16_t *value,
99+
uint16_t *overflow
100+
); """
101+
usbDrDaq.make_symbol("_GetSingle", "UsbDrDaqGetSingle", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p], doc)
102+
103+
doc = """ PICO_STATUS UsbDrDaqGetSingleF
104+
(
105+
int16_t handle,
106+
USB_DRDAQ_INPUTS channel,
107+
float *value,
108+
uint16_t *overflow
109+
); """
110+
usbDrDaq.make_symbol("_getSingleF", "UsbDrDaqGetSingleF", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p], doc)
111+
112+
doc = """ PICO_STATUS UsbDrDaqGetTriggerTimeOffestNs
113+
(
114+
int16_t handle,
115+
int64_t *time
116+
); """
117+
usbDrDaq.make_symbol("_GetTriggerTimeOffsetNs", "UsbDrDaqGetTriggerTimeOffestNs", c_uint32, [c_int16, c_void_p], doc)
118+
119+
doc = """ PICO_STATUS UsbDrDaqGetUnitInfo
120+
(
121+
int16_t handle,
122+
int8_t *string,
123+
int16_t stringLength,
124+
int16_t *requiredSize,
125+
PICO_INFO info
126+
); """
127+
usbDrDaq.make_symbol("_GetUnitInfo", "UsbDrDaqGetUnitInfo", c_uint32, [c_int16, c_void_p, c_int16, c_void_p, c_uint32], doc)
128+
129+
doc = """ PICO_STATUS UsbDrDaqGetValues
130+
(
131+
int16_t handle,
132+
int16_t *values,
133+
uint32_t *noOfValues,
134+
uint16_t *overflow,
135+
uint32_t *triggerIndex
136+
); """
137+
usbDrDaq.make_symbol("_GetValues", "UsbDrDaqGetValues", c_uint32, [c_int16, c_void_p, c_void_p, c_void_p, c_void_p], doc)
138+
139+
doc = """ PICO_STATUS UsbDrDaqGetValuesF
140+
(
141+
int16_t handle,
142+
float *values,
143+
uint32_t *noOfValues,
144+
uint16_t *overflow,
145+
uint32_t *triggerIndex
146+
); """
147+
usbDrDaq.make_symbol("_GetValuesF", "UsbDrDaqGetValuesF", c_uint32, [c_int16, c_void_p, c_void_p, c_void_p, c_void_p], doc)
148+
149+
doc = """ PICO_STATUS UsbDrDaqOpenUnit
150+
(
151+
int16_t *handle
152+
); """
153+
usbDrDaq.make_symbol("_OpenUnit", "UsbDrDaqOpenUnit", c_uint32, [c_void_p], doc)
154+
155+
doc = """ PICO_STATUS UsbDrDaqOpenUnitAsync
156+
(
157+
int16_t *handle
158+
); """
159+
usbDrDaq.make_symbol("_OpenUnitAsync", "UsbDrDaqOpenUnitAsync", c_uint32, [c_void_p], doc)
160+
161+
doc = """ PICO_STATUS UsbDrDaqOpenUnitProgress
162+
(
163+
int16_t *handle,
164+
int16_t *progress,
165+
int16_t *complete
166+
); """
167+
usbDrDaq.make_symbol("_OpenUnitProgress", "UsbDrDaqOpenUnitProgress", c_uint32, [c_void_p, c_void_p, c_void_p], doc)
168+
169+
doc = """ PICO_STATUS UsbDrDaqPhTemperatureCompensation
170+
(
171+
int16_t handle,
172+
uint16_t enabled
173+
); """
174+
usbDrDaq.make_symbol("_PhTemperatureCompensation", "UsbDrDaqPhTemperatureCompensation", c_uint32, [c_int16, c_uint16], doc)
175+
176+
doc = """ PICO_STATUS UsbDrDaqPingUnit
177+
(
178+
int16_t *handle
179+
); """
180+
usbDrDaq.make_symbol("_PingUnit", "UsbDrDaqPingUnit", c_uint32, [c_void_p], doc)
181+
182+
doc = """ PICO_STATUS UsbDrDaqReady
183+
(
184+
int16_t handle,
185+
int16_t *ready
186+
); """
187+
usbDrDaq.make_symbol("_Ready", "UsbDrDaqReady", c_uint32, [c_int16, c_void_p], doc)
188+
189+
doc = """ PICO_STATUS UsbDrDaqRun
190+
(
191+
int16_t handle,
192+
uint32_t no_of_values,
193+
BLOCK_METHOD method
194+
); """
195+
usbDrDaq.make_symbol("_Run", "UsbDrDaqRun", c_uint32, [c_int16, c_uint32, c_uint32], doc)
196+
197+
doc = """ PICO_STATUS UsbDrDaqSetDO
198+
(
199+
int16_t handle,
200+
USB_DRDAQ_GPIO IOChannel,
201+
int16_t value
202+
); """
203+
usbDrDaq.make_symbol("_SetDO", "UsbDrDaqSetDO", c_uint32, [c_int16, c_uint32, c_int16], doc)
204+
205+
doc = """ PICO_STATUS UsbDrDaqSetInterval
206+
(
207+
int16_t handle,
208+
uint32_t *us_for_block,
209+
uint32_t ideal_no_of_samples,
210+
USB_DRDAQ_INPUTS *channels,
211+
int16_t no_of_channels
212+
); """
213+
usbDrDaq.make_symbol("_SetInterval", "UsbDrDaqSetInterval", c_uint32, [c_int16, c_void_p, c_uint32, c_void_p, c_int16], doc)
214+
215+
doc = """ PICO_STATUS UsbDrDaqSetIntervalF
216+
(
217+
int16_t handle,
218+
float *us_for_block,
219+
uint32_t ideal_no_of_samples,
220+
USB_DRDAQ_INPUTS *channels,
221+
int16_t no_of_channels
222+
); """
223+
usbDrDaq.make_symbol("_SetIntervalF", "UsbDrDaqSetIntervalF", c_uint32, [c_int16, c_void_p, c_uint32, c_void_p, c_int16], doc)
224+
225+
doc = """ PICO_STATUS UsbDrDaqSetPWM
226+
(
227+
int16_t handle,
228+
USB_DRDAQ_GPIO IOChannel,
229+
uint16_t period,
230+
uint8_t cycle
231+
); """
232+
usbDrDaq.make_symbol("_SetPWM", "UsbDrDaqSetPWM", c_uint32, [c_int16, c_uint32, c_uint16, c_uint8], doc)
233+
234+
doc = """ PICO_STATUS UsbDrDaqSetRGBLED
235+
(
236+
int16_t handle,
237+
uint16_t red,
238+
uint16_t green,
239+
uint16_t blue
240+
); """
241+
usbDrDaq.make_symbol("_SetRGBLED", "UsbDrDaqSetRGBLED", c_uint32, [c_int16, c_uint16, c_uint16, c_uint16], doc)
242+
243+
doc = """ PICO_STATUS UsbDrDaqSetScalings
244+
(
245+
int16_t handle,
246+
USB_DRDAQ_INPUTS channel,
247+
int16_t scalingNumber
248+
); """
249+
usbDrDaq.make_symbol("_SetScalings", "UsbDrDaqSetScalings", c_uint32, [c_int16, c_uint32, c_int16], doc)
250+
251+
doc = """ PICO_STATUS UsbDrDaqSetSigGenArbitary
252+
(
253+
int16_t handle,
254+
int32_t offsetVoltage,
255+
uint32_t pkToPk,
256+
int16_t *arbitaryWaveform,
257+
int16_t arbitaryWaveformSize,
258+
int32_t updateRate
259+
); """
260+
usbDrDaq.make_symbol("_SetSigGenArbitary", "UsbDrDaqSetSigGenArbitary", c_uint32, [c_int16, c_int32, c_uint32, c_void_p, c_int16, c_int32], doc)
261+
262+
doc = """ PICO_STATUS UsbDrDaqSetSigGenBuiltIn
263+
(
264+
int16_t handle,
265+
int32_t offsetVoltage,
266+
uint32_t pkToPk,
267+
int16_t frequency,
268+
USB_DRDAQ_WAVE waveType
269+
); """
270+
usbDrDaq.make_symbol("_SetSigGenBuiltIn", "UsbDrDaqSetSigGenBuiltIn", c_uint32, [c_int16, c_int32, c_uint32, c_int16, c_uint32], doc)
271+
272+
doc = """ PICO_STATUS UsbDrDaqSetTrigger
273+
(
274+
int16_t handle,
275+
uint16_t enabled,
276+
uint16_t auto_trigger,
277+
uint16_t auto_ms,
278+
uint16_t channel,
279+
uint16_t dir,
280+
int16_t threshold,
281+
uint16_t hysteresis,
282+
float delay
283+
); """
284+
usbDrDaq.make_symbol("_SetTrigger", "UsbDrDaqSetTrigger", c_uint32, [c_int16, c_uint16, c_uint16, c_uint16, c_uint16, c_uint16,c_int16, c_uint16, c_float], doc)
285+
286+
doc = """ PICO_STATUS UsbDrDaqStartPulseCount
287+
(
288+
int16_t handle,
289+
USB_DRDAQ_GPIO IOChannel,
290+
int16_t direction
291+
); """
292+
usbDrDaq.make_symbol("_StartPulseCount", "UsbDrDaqStartPulseCount", c_uint32, [c_int16, c_uint32, c_int16], doc)
293+
294+
doc = """ PICO_STATUS UsbDrDaqStop
295+
(
296+
int16_t handle
297+
); """
298+
usbDrDaq.make_symbol("_Stop", "UsbDrDaqStop", c_uint32, [c_int16], doc)
299+
300+
doc = """ PICO_STATUS UsbDrDaqStopSigGen
301+
(
302+
int16_t handle
303+
); """
304+
usbDrDaq.make_symbol("_StopSigGen", "UsbDrDaqStopSigGen", c_uint32, [c_int16], doc)

0 commit comments

Comments
 (0)