This commit is contained in:
yichin
2019-05-27 17:26:58 +08:00
parent 3249e7e1e2
commit 28e8a66221
3 changed files with 137 additions and 29 deletions
+2 -1
View File
@@ -7,7 +7,7 @@ STI_PARAMETER = {
'STI_MODE': STI_WAVEFORM_POS,
'PRECISION': STI_PRECISION_10,
'STI_FREQ': 1000, # Hz
'STI_PW': 100, # us
'STI_PW': 150, # us
'STI_PW_IPI': 0, # us
'STI_NUM': STI_NUM_INFINITE,
}
@@ -18,3 +18,4 @@ else:
print_instruction(STI_INSTRUCTION['GLOBAL'], STI_PARAMETER, append_ris_type=False, c_style_uint8_array='ins')
print_instruction(STI_INSTRUCTION['LOCAL'], STI_PARAMETER, append_ris_type=False, c_style_uint8_array='ins')
print(STI_PARAMETER['STI_PW'], get_spin_timeout_value(STI_PARAMETER['STI_PW']))
+44
View File
@@ -36,3 +36,47 @@ def validate_frequency_parameter(parameter: Dict[str, Any]) -> bool:
w = int(parameter['STI_PW'])
i = int(parameter['STI_PW_IPI'])
return 1e6 * (1 if p == 0 else 10) / f >= 2 * w + i
SPIN_TIMEOUT = [
(10, 53),
(20, 106),
(30, 160),
(40, 214),
(50, 265),
(60, 319),
(70, 374),
(80, 427),
(100, 533),
(200, 1066),
(500, 2060),
(1000, 4120),
]
def get_spin_timeout_value(timeout_us: int) -> int:
if timeout_us == 0:
return 0
elif timeout_us <= SPIN_TIMEOUT[0][0]:
return SPIN_TIMEOUT[0][1]
elif timeout_us >= SPIN_TIMEOUT[-1][0]:
return SPIN_TIMEOUT[-1][1]
else:
for i in range(len(SPIN_TIMEOUT)):
t0 = SPIN_TIMEOUT[i][0]
v0 = SPIN_TIMEOUT[i][1]
if timeout_us == t0:
return v0
t1 = SPIN_TIMEOUT[i + 1][0]
v1 = SPIN_TIMEOUT[i + 1][1]
if t0 < timeout_us < t1:
dt = t1 - t0
return int((t1 - timeout_us) * v0 / dt + (timeout_us - t0) * v1 / dt)
raise RuntimeError()