fix bug
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
from devlib.util import print_instruction
|
||||
from sti.util import *
|
||||
|
||||
STI_PARAMETER = {
|
||||
'CURRENT': 10, # uA
|
||||
'CHANNEL': CHANNEL_STI_0,
|
||||
'STI_MODE': STI_WAVEFORM_POS,
|
||||
'PRECISION': STI_PRECISION_10,
|
||||
'STI_FREQ': 1000, # Hz
|
||||
'STI_PW': 200, # us
|
||||
'STI_PW_IPI': 0, # us
|
||||
'STI_NUM': STI_NUM_INFINITE,
|
||||
}
|
||||
|
||||
if not validate_frequency_parameter(STI_PARAMETER):
|
||||
print('invalidate parameter')
|
||||
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')
|
||||
@@ -1,4 +1,4 @@
|
||||
from devlib.util import print_instruction
|
||||
from typing import Dict, Any
|
||||
|
||||
CHANNEL_STI_0 = 0
|
||||
CHANNEL_STI_1 = 1
|
||||
@@ -18,16 +18,21 @@ STI_INSTRUCTION = {
|
||||
'LOCAL': '3b010#header;1b0;4b>CHANNEL;3b>STI_MODE;1b>PRECISION;12b>STI_FREQ;10b>STI_PW;10b>STI_PW_IPI;10b>STI_NUM'
|
||||
}
|
||||
|
||||
STI_PARAMETER = {
|
||||
DEFAULT_PARAMETER = {
|
||||
'CURRENT': 10, # uA
|
||||
'CHANNEL': CHANNEL_STI_0,
|
||||
'STI_MODE': STI_WAVEFORM_POS,
|
||||
'PRECISION': STI_PRECISION_10,
|
||||
'STI_FREQ': 100, # Hz
|
||||
'STI_PW': 900, # us
|
||||
'STI_PW_IPI': 0, # us
|
||||
'STI_FREQ': 1000, # Hz
|
||||
'STI_PW': 100, # us
|
||||
'STI_PW_IPI': 50, # us
|
||||
'STI_NUM': STI_NUM_INFINITE,
|
||||
}
|
||||
|
||||
# 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')
|
||||
|
||||
def validate_frequency_parameter(parameter: Dict[str, Any]) -> bool:
|
||||
p = int(parameter['PRECISION'])
|
||||
f = int(parameter['STI_FREQ'])
|
||||
w = int(parameter['STI_PW'])
|
||||
i = int(parameter['STI_PW_IPI'])
|
||||
return 1e6 * (1 if p == 0 else 10) / f >= 2 * w + i
|
||||
Reference in New Issue
Block a user