Skip to content

Commit afd3d1d

Browse files
author
neil.hamilton
committed
Creates picosynth.py and populate with enums and functions
1 parent c19c1db commit afd3d1d

File tree

1 file changed

+171
-0
lines changed

1 file changed

+171
-0
lines changed

picosdk/picosynth.py

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
#
2+
# Copyright (C) 2022 Pico Technology Ltd. See LICENSE file for terms.
3+
#
4+
"""
5+
This is a Python module defining the functions from the picosynth.h C header file
6+
for the PicoSource AS108 Agile Synthesizer using the picosynth driver API functions.
7+
"""
8+
9+
from ctypes import *
10+
from picosdk.library import Library
11+
from picosdk.errors import ArgumentOutOfRangeError
12+
from picosdk.constants import make_enum
13+
14+
class Picosynthlib(library):
15+
def __init__(self):
16+
super(Picosynthlib, self).__init__("picosynth")
17+
18+
picosynth = Picosynthlib()
19+
20+
picosynth.PICO_SOURCE_MODEL = make_enum([
21+
"PICO_NONE_SPECIFIED",
22+
"PICO_SYNTH",
23+
])
24+
25+
doc = """ PICO_STATUS picosynthOpenUnit
26+
(
27+
PICO_SOURCE_MODEL model,
28+
uint32_t *handle,
29+
unit8_t *serialNumber
30+
);"""
31+
picosynth.make_symbol("_OpenUnit","picosynthOpenUnit",c_uint32,[c_uint32, c_void_p, c_void_p],doc)
32+
33+
doc = """ PICO_STATUS picosynthEnumerateUnits
34+
(
35+
PICO_SOURCE_MODEL model,
36+
uint8_t *serials,
37+
unit16_t *serialLth
38+
);"""
39+
picosynth.make_symbol("_EnumerateUnits","picosynthEnumerateUnits",c_uint32,[c_uint32, c_void_p, c_void_p],doc)
40+
41+
doc = """ PICO_STATUS picosynthGetUnitInfo
42+
(
43+
int8_t *string,
44+
unit16_t stringLength,
45+
uint16_t *requiredSize,
46+
PICO_INFO deviceInfo
47+
);"""
48+
picosynth.make_symbol("_GetUnitInfo","picosynthGetUnitInfo",c_uint32,[c_uint32, c_void_p, c_uint16, c_void_p, c_uint32],doc)
49+
50+
doc = """ PICO_STATUS picosynthPingUnit
51+
(
52+
uint32_t *handle,
53+
);"""
54+
picosynth.make_symbol("_PingUnit","picosynthPingUnit",c_uint32,[c_uint32],doc)
55+
56+
doc = """ PICO_STATUS picosynthCloseUnit
57+
(
58+
uint32_t *handle,
59+
);"""
60+
picosynth.make_symbol("_CloseUnit","picosynthCloseUnit",c_uint32,[c_uint32],doc)
61+
62+
doc = """ PICO_STATUS picosynthSetOutputOff
63+
(
64+
uint32_t *handle,
65+
);"""
66+
picosynth.make_symbol("_SetOutputOff","picosynthSetOutputOff",c_uint32,[c_uint32],doc)
67+
68+
doc = """ PICO_STATUS picosynthSetFrequency
69+
(
70+
uint32_t *handle,
71+
double frequencyHz,
72+
double powerLeveldBm
73+
);"""
74+
picosynth.make_symbol("_SetFrequency","picosynthSetFrequency",c_uint32,[c_uint32, c_double, c_double],doc)
75+
76+
doc = """ PICO_STATUS picosynthSetPhase
77+
(
78+
uint32_t handle,
79+
double phaseDeg
80+
);"""
81+
picosynth.make_symbol("_SetPhase", "picosynthSetPhase", c_uint32,[c_uint32, c_double], doc)
82+
83+
doc = """ PICO_STATUS picosynthSetAmplitudeModulation
84+
(
85+
uint32_t handle,
86+
double frequencyHz,
87+
double powerLeveldBm,
88+
double modulationDepthPercent,
89+
double modulationRateHz,
90+
MODULATION_SOURCE modulationSource,
91+
int16_t enabled
92+
);"""
93+
picosynth.make_symbol("_SetAmplitudeModulation","picosynthSetAmplitudeModulation", c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_uint32,c_int16],doc)
94+
95+
doc = """ PICO_STATUS picosynthSetFrequencyModulation
96+
(
97+
uint32_t handle,
98+
double frequencyHz,
99+
double powerLeveldBm,
100+
double modulationDeviationHz,
101+
double modulationRateHz,
102+
MODULATION_SOURCE modulationSource,
103+
int16_t enabled
104+
);"""
105+
picosynth.make_symbol("_SetFrequencyModulation","picosynthSetFrequencyModulation",c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_uint32,c_int16],doc)
106+
107+
doc = """ PICO_STATUS picosynthSetPhaseModulation
108+
(
109+
uint32_t handle,
110+
double frequencyHz,
111+
double powerLeveldBm,
112+
double modulationDeviationHz,
113+
double modulationRateHz,
114+
MODULATION_SOURCE modulationSource,
115+
int16_t enabled
116+
);"""
117+
picosynth.make_symbol("_SetPhaseModulation","picosynthSetPhaseModulation",c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_uint32,c_int16],doc)
118+
119+
doc = """ PICO_STATUS picosynthSetFrequencyAndLevelSweep
120+
(
121+
uint32_t handle,
122+
double startFrequencyHz,
123+
double stopFrequencyHz,
124+
double startLevel,
125+
double stopLevel,
126+
LEVEL_UNIT levelUnit,
127+
double dwellTimeUs,
128+
int32_t pointsInSweep,
129+
SWEEP_HOP_MODE mode,
130+
TRIGGER_MODE triggerMode
131+
);"""
132+
picosynth.make_symbol("_SetFrequencyAndLevelSweep","picosynthSetFrequencyAndLevelSweep", c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_uint32,c_double,c_int32,c_uint32,c_uint32],doc)
133+
134+
doc = """ PICO_STATUS picosynthSetPhaseAndLevelSweep
135+
(
136+
uint32_t handle,
137+
double frequencyHz,
138+
double startPhaseDeg,
139+
double stopPhaseDeg,
140+
double startLevel,
141+
double stopLevel,
142+
LEVEL_UNIT levelUnit,
143+
double dwellTimeUs,
144+
int32_t pointsInSweep,
145+
SWEEP_HOP_MODE mode,
146+
TRIGGER_MODE triggerMode
147+
);"""
148+
picosynth.make_symbol("_SetPhaseAndLevelSweep","picosynthSetPhaseAndLevelSweep", c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_double,c_uint32,c_double,c_int32,c_uint32,c_uint32],doc)
149+
150+
doc = """ PICO_STATUS picosynthSetArbitraryPhaseAndLevel
151+
(
152+
uint32_t handle,
153+
double frequencyHz,
154+
double *arbitraryPhaseDeg,
155+
double *arbitraryPowerLeveldBm,
156+
int32_t numberOfPoints,
157+
double dwellTimeUs,
158+
TRIGGER_MODE triggerMode
159+
);"""
160+
picosynth.make_symbol("_SetArbitraryPhaseAndLevel","picosynthSetArbitraryPhaseAndLevel",c_uint32,[c_uint32,c_double,c_double,c_double,c_int32,c_double,c_uint32],doc)
161+
162+
doc = """ PICO_STATUS picosynthSetArbitraryFrequencyAndLevel
163+
(
164+
uint32_t handle,
165+
double *arbitraryFrequencyHz,
166+
double *arbitraryPowerLeveldBm,
167+
int32_t numberOfPoints,
168+
double dwellTimeUs,
169+
TRIGGER_MODE triggerMode
170+
);"""
171+
picosynth.make_symbol("_SetArbitraryFrequencyAndLevel","picosynthSetArbitraryFrequencyAndLevel",c_uint32,[c_uint32,c_double,c_double,c_int32,c_double,c_uint32],doc)

0 commit comments

Comments
 (0)