-
Notifications
You must be signed in to change notification settings - Fork 103
/
tddn.py
204 lines (155 loc) · 6.85 KB
/
tddn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# Copyright (C) 2024 Analog Devices, Inc.
#
# SPDX short identifier: ADIBSD
from typing import List
from adi.attribute import attribute
from adi.context_manager import context_manager
class tddn(context_manager, attribute):
"""TDDN Controller"""
channel = [] # type: ignore
_device_name: str = ""
def __init__(self, uri=""):
"""TDDN Controller"""
context_manager.__init__(self, uri, self._device_name)
self._ctrl = self._ctx.find_device("iio-axi-tdd-0")
for ch in self._ctrl.channels:
name = ch._id
self.channel.append(self._channel(self._ctrl, name))
@property
def frame_length_ms(self) -> float:
"""frame_length_ms: TDD frame length (ms)"""
return self._get_iio_dev_attr("frame_length_ms")
@frame_length_ms.setter
def frame_length_ms(self, value: float):
self._set_iio_dev_attr("frame_length_ms", value)
@property
def frame_length_raw(self) -> float:
"""frame_length_raw: TDD frame length (clock cycles)"""
return self._get_iio_dev_attr("frame_length_raw")
@frame_length_raw.setter
def frame_length_raw(self, value: float):
self._set_iio_dev_attr("frame_length_raw", value)
@property
def startup_delay_ms(self) -> float:
"""startup_delay_ms: Initial delay before the first frame (ms)"""
return self._get_iio_dev_attr("startup_delay_ms")
@startup_delay_ms.setter
def startup_delay_ms(self, value: float):
self._set_iio_dev_attr("startup_delay_ms", value)
@property
def startup_delay_raw(self) -> float:
"""startup_delay_raw: Initial delay before the first frame (clock cycles)"""
return self._get_iio_dev_attr("startup_delay_raw")
@startup_delay_raw.setter
def startup_delay_raw(self, value: float):
self._set_iio_dev_attr("startup_delay_raw", value)
@property
def internal_sync_period_ms(self) -> float:
"""internal_sync_period_ms: Period of the internal sync generator (ms)"""
return self._get_iio_dev_attr("internal_sync_period_ms")
@internal_sync_period_ms.setter
def internal_sync_period_ms(self, value: float):
self._set_iio_dev_attr("internal_sync_period_ms", value)
@property
def internal_sync_period_raw(self) -> float:
"""internal_sync_period_raw: Period of the internal sync generator (clock cycles)"""
return self._get_iio_dev_attr("internal_sync_period_raw")
@internal_sync_period_raw.setter
def internal_sync_period_raw(self, value: float):
self._set_iio_dev_attr("internal_sync_period_raw", value)
@property
def burst_count(self) -> int:
"""burst_count: Amount of frames to produce, where 0 means repeat indefinitely"""
return self._get_iio_dev_attr("burst_count")
@burst_count.setter
def burst_count(self, value: int):
self._set_iio_dev_attr("burst_count", value)
@property
def sync_soft(self) -> bool:
"""sync_soft: Trigger one software sync pulse"""
return bool(int(self._get_iio_dev_attr("sync_soft")))
@sync_soft.setter
def sync_soft(self, value: bool):
self._set_iio_dev_attr("sync_soft", int(value))
@property
def sync_external(self) -> bool:
"""sync_external: Enable the external sync trigger"""
return bool(int(self._get_iio_dev_attr("sync_external")))
@sync_external.setter
def sync_external(self, value: bool):
self._set_iio_dev_attr("sync_external", int(value))
@property
def sync_internal(self) -> bool:
"""sync_internal: Enable the internal sync trigger"""
return bool(int(self._get_iio_dev_attr("sync_internal")))
@sync_internal.setter
def sync_internal(self, value: bool):
self._set_iio_dev_attr("sync_internal", int(value))
@property
def sync_reset(self) -> bool:
"""sync_reset: Reset the internal counter when receiving a sync event"""
return bool(int(self._get_iio_dev_attr("sync_reset")))
@sync_reset.setter
def sync_reset(self, value: bool):
self._set_iio_dev_attr("sync_reset", int(value))
@property
def enable(self) -> bool:
"""enable: Enable or disable the TDD engine"""
return bool(int(self._get_iio_dev_attr("enable")))
@enable.setter
def enable(self, value: bool):
self._set_iio_dev_attr("enable", int(value))
@property
def state(self) -> int:
"""state: The current state of the internal FSM"""
return self._get_iio_dev_attr("state")
@state.setter
def state(self, value: int):
self._set_iio_dev_attr("state", value)
class _channel(attribute):
"""TDDN channel"""
def __init__(self, ctrl, channel_name):
self.name = channel_name
self._ctrl = ctrl
@property
def enable(self) -> bool:
"""channel_enable: Selected channel output enable"""
return bool(int(self._get_iio_attr(self.name, "enable", True)))
@enable.setter
def enable(self, value: bool):
self._set_iio_attr(self.name, "enable", True, int(value))
@property
def polarity(self) -> bool:
"""channel_polarity: Selected channel output polarity"""
return bool(int(self._get_iio_attr(self.name, "polarity", True)))
@polarity.setter
def polarity(self, value: bool):
self._set_iio_attr(self.name, "polarity", True, int(value))
@property
def on_ms(self) -> float:
"""channel_on_ms: The offset from the beginning of a new frame when the selected channel is set (ms)"""
return self._get_iio_attr(self.name, "on_ms", True)
@on_ms.setter
def on_ms(self, value: float):
self._set_iio_attr(self.name, "on_ms", True, value)
@property
def on_raw(self) -> float:
"""channel_on_raw: The offset from the beginning of a new frame when the selected channel is set (clock cycles)"""
return self._get_iio_attr(self.name, "on_raw", True)
@on_raw.setter
def on_raw(self, value: float):
self._set_iio_attr(self.name, "on_raw", True, value)
@property
def off_ms(self) -> float:
"""channel_off_ms: The offset from the beginning of a new frame when the selected channel is reset (ms)"""
return self._get_iio_attr(self.name, "off_ms", True)
@off_ms.setter
def off_ms(self, value: float):
self._set_iio_attr(self.name, "off_ms", True, value)
@property
def off_raw(self) -> float:
"""channel_off_raw: The offset from the beginning of a new frame when the selected channel is reset (clock cycles)"""
return self._get_iio_attr(self.name, "off_raw", True)
@off_raw.setter
def off_raw(self, value: float):
self._set_iio_attr(self.name, "off_raw", True, value)