diff --git a/.gitignore b/.gitignore index 8b60424..3e659c5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ Tests/DCX81/spi_read_fifo.cmm Tests/DCX81/spi2_slave.cmm *.xlsx Tests/apx500_functionality_test/THD_test.approjx -Tests/apx500_functionality_test/SNR_test.approjx \ No newline at end of file +Tests/apx500_functionality_test/SNR_test.approjx +Tests/DBMA7/script1.py \ No newline at end of file diff --git a/Chip_Validation_Python_Manual.docx b/Chip_Validation_Python_Manual.docx index 9d2e36d..2314ee4 100644 Binary files a/Chip_Validation_Python_Manual.docx and b/Chip_Validation_Python_Manual.docx differ diff --git a/Tests/DBMA7/DBMA7_test_template.py b/Tests/DBMA7/DBMA7_test_template.py new file mode 100644 index 0000000..8e85be9 --- /dev/null +++ b/Tests/DBMA7/DBMA7_test_template.py @@ -0,0 +1,41 @@ +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\DBMA7." +TEST_NAME = "test_template" + +## Defines +rpi_address = "172.19.66.17" +rpi_username = "pi" +rpi_password = "pi" +apx_project_path = r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\apx500_functionality_test\SNR_test2.approjx" +apx_results_path = r"C:\Users\bar.kristal\Documents\GitHub\Python\apx500_functionality_test\full_sequence" + +#call the init.py module: +import paramiko +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\apx525_functions.py") + +################################################################################################## +## test start: + +#initial RPI connection +RPI = RaspberryPi(rpi_address, rpi_username, rpi_password) +#reset both D2 and A7 +RPI.reset_A7() +RPI.reset_D2() +RPI.init_D2() + +#call FW functions (configuration and set-ups that written in the RPI's python code): +print RPI.send("sudo python host_valab.py det_internal") + +#read and write to registers +print RPI.read_register_A7('0x0') +RPI.write_register_A7('0x0', '0x0004') +print RPI.read_register_A7('0x0') + +#run measurements with AudioPrecision, result saved at apx_results_path +SequenceMode_full_sequence_from_project(apx_project_path, apx_results_path) + +#close connection with RPI: +RPI.close() + diff --git a/Tests/DBMA7/dbma7_bringup.py b/Tests/DBMA7/dbma7_bringup.py new file mode 100644 index 0000000..34d8d90 --- /dev/null +++ b/Tests/DBMA7/dbma7_bringup.py @@ -0,0 +1,23 @@ +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\\Users\bar.kristal\Documents\GitHub\Python\Tests\DBMA7." +TEST_NAME = "dbmA7_bringup" + +## Defines +#boot file path for the initialization of UartDeviceTC(): +TC55B01_BOOT_FILE = r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\classd_boot_166.bin" +dbma7_boot_file = r"t:\art\TCIII\script\ram_boot.bin" + +#call the init.py module: +import math +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC55b_regs.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC55b_defs.py") +################################################################################################## + +A7 = UartDeviceTC(name="A7", com="COM22", baudrate=921600, parity='E', stopbits=2, boot_file=dbma7_boot_file) +# A7.change_baudrate(3000000) + +# A7.write_register('3000000', 'ffffaaaa') +chk = A7.read_register('3000000') +print chk diff --git a/Tests/DBMA7/dbma7_ssh.py b/Tests/DBMA7/dbma7_ssh.py new file mode 100644 index 0000000..6964d3a --- /dev/null +++ b/Tests/DBMA7/dbma7_ssh.py @@ -0,0 +1,33 @@ +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\DBMA7." +TEST_NAME = "dbmA7_ssh" + +## Defines +#boot file path for the initialization of UartDeviceTC(): +TC55B01_BOOT_FILE = r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\classd_boot_166.bin" +dbma7_boot_file = r"t:\art\TCIII\script\ram_boot.bin" + +#call the init.py module: +import paramiko +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") + + +################################################################################################## +rpi_address = "172.19.66.17" +rpi_username = "pi" +rpi_password = "Validation23" + + +RPI = RaspberryPi(rpi_address, rpi_username, rpi_password) + + +print RPI.read_register_A7('0x0') +RPI.write_register_A7('0x0', '0x0004') +print RPI.read_register_A7('0x0') + +print RPI.send("sudo python host_valab.py det_internal") +print RPI.send("sudo python host_valab.py atc3 reset") +print RPI.send("sudo python host_valab.py det_internal") + +RPI.close() \ No newline at end of file diff --git a/Tests/DBMA7/dbma7_tests.py b/Tests/DBMA7/dbma7_tests.py new file mode 100644 index 0000000..d4ba8e6 --- /dev/null +++ b/Tests/DBMA7/dbma7_tests.py @@ -0,0 +1,89 @@ +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\\Users\bar.kristal\Documents\GitHub\Python\Tests\DBMA7." +TEST_NAME = "dbmA7._use_cases" + +## Defines +#boot file path for the initialization of UartDeviceTC(): +TC55B01_BOOT_FILE = r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\classd_boot_166.bin" +dbma7_boot_file = r"t:\art\TCIII\ram_boot.bin" + +#call the init.py module: +import math +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC55b_regs.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC55b_defs.py") +################################################################################################## + +# defines: +CMU_BASE = 0x0000 +AFE_BASE = 0x0100 + + +SCU_CLK_PMOD = CMU_BASE + 0x20 +AFE_BGREF_CFG = AFE_BASE + 0x24 +AFE_OUTAMP_CFG0 = AFE_BASE + 0x0c + +def tx_noise_floor_config(A7): + ''' + 1. Open the band-gap, charge-pump block and LDO, + and enable CLK_CP. + 2. Enable the output amplifier. + 3. Enable the digital path with no specific order + 4. Enable the DAC.''' + + # # pll_configurations: + A7.write_register('4', '1002f00') + A7.write_register('0', '1017') + + # # enable bad-gap: + A7.tc_setbits(AFE_BGREF_CFG, 0x1) + + # # enable CLK_CP: + A7.tc_setbits(SCU_CLK_PMOD, 0x40000) + + # #enable LDO + #TBD + + # # enable OUTAMP0_EN: + A7.tc_setbits(AFE_OUTAMP_CFG0, 0x1) + + # # enable GDAC0_CLK, GDAC1_CLK, GDAC_CLK_MOD: + A7.tc_setbits(SCU_CLK_PMOD, 0xe0000000) + + # # enable I2S: + A7.tc_setbits(SCU_CLK_PMOD, 0x1000) + + +process = 'TYP' #'FF' / 'SS' +oven = VotschVT4002(OVEN_ADDRESS) + +procese_col = 1 +temp_col = 2 +gear_col = 3 +qual_col = 4 +result_col = 5 + +temp_list = ['-40', '25', '90'] +gear_list = [1, 2, 3, 4] +qual_list = ['LP', 'HQ', 'BTL'] +output_load_list = ['32k', '16k'] + +#inital Excel file: +wb1, full_path = create_excel_file(DIR_NAME, LOG_NAME_EXCEL) +ws1 = wb1.create_sheet("Noise_floor_test_{}".format(prosess)) + +ws1.cell(row=1, column=procese_col).value = process +ws1.cell(row=1, column=temp_col).value = temp +ws1.cell(row=1, column=gear_col).value = 'gear_number' +ws1.cell(row=1, column=qual_col).value = 'quality' +ws1.cell(row=1, column=result_col).value = 'result' + + +for temp in temp_list: + oven.wait_for_temp(temp) + + for + tx_noise_floor_config(A7, gear_num, quality) + + diff --git a/Tests/DBMA7/dbma7_tx_gain_n_frequency.py b/Tests/DBMA7/dbma7_tx_gain_n_frequency.py new file mode 100644 index 0000000..67d4843 --- /dev/null +++ b/Tests/DBMA7/dbma7_tx_gain_n_frequency.py @@ -0,0 +1,91 @@ +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\\Users\bar.kristal\Documents\GitHub\Python\Tests\DBMA7." +TEST_NAME = "dbmA7_tx_gain_n_frequency_test + +## Defines +#boot file path for the initialization of UartDeviceTC(): +TC55B01_BOOT_FILE = r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\classd_boot_166.bin" + +#call the init.py module: +import math +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC55b_regs.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC55b_defs.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\apx525_functions.py") +################################################################################################## + +# defines: + + +def tx_gain_config(A7): + '''configure TX path for the test''' + + + + +process = 'TYP' #'FF' / 'SS' +oven = VotschVT4002(OVEN_ADDRESS) +A7 = UartDeviceTC(name="TC", com="COM6", baudrate=115200, parity='E', stopbits=1, boot_file=TC55B01_BOOT_FILE) + + +temp_list = ['-40', '25', '90'] +noise_gating_list = ['off'] +output_load_list = ['32000', '16000'] +vcca_list = ['1.7, 1.8', '2'] +input_amplitude_list= ['-20', '-1', '0'] #in dBFS + +#inital Excel file: +wb1, full_path = create_excel_file(DIR_NAME, LOG_NAME_EXCEL) +ws1 = wb1.create_sheet("gain_n_frequency_test_{}".format(prosess)) + + + +#define the values for this test: +colomns_dict = {} +colomns_list = ['process', + 'temp[C]', + 'VCCA[V]', + 'input amplitude[V]', + 'result', + 'units'] + +#define a colomn number for every value: +for col, value in enumerate(colomns_list): + colomns_dict[value] = col + # insert healines into Excel: + ws1.cell(row=1, column=col).value = value + +wb1.save(full_path) + + +#initial the row number +current_row = 1 + + +for temp in temp_list: + oven.wait_for_temp(temp) + + for load in output_load_list: + electronic_load = KikusuiPLZ70UA(ELECTRONIC_LOAD_ADDRESS) + electronic_load.set_resistance(load) + + for vcca in vcca_list: + for input_amplitude in input_amplitude_list: + current_row += 1 + + #config TX PATH + tx_gain_config(A7) + + #measure gain with APX525; + # THD_resutls, thd_units = SequenceMode_THD_from_project(THD_project) + # THDN_resutls, thdn_units = SequenceMode_THDN_Ratio_from_project(THDN_project) + + #insert values into Excel + ws1.cell(row=current_row, column=colomns_dict['process']).value = process + ws1.cell(row=current_row, column=colomns_dict['temp[C]']).value = temp + ws1.cell(row=current_row, column=colomns_dict['VCCA[V]']).value = vcca + ws1.cell(row=current_row, column=colomns_dict['result']).value = gain_resutls + ws1.cell(row=current_row, column=colomns_dict['units']).value = gain_units + + wb1.save(full_path) \ No newline at end of file diff --git a/Tests/DBMA7/dbma7_tx_noise_floor_test.py b/Tests/DBMA7/dbma7_tx_noise_floor_test.py new file mode 100644 index 0000000..44636fb --- /dev/null +++ b/Tests/DBMA7/dbma7_tx_noise_floor_test.py @@ -0,0 +1,118 @@ +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\\Users\bar.kristal\Documents\GitHub\Python\Tests\DBMA7." +TEST_NAME = "dbmA7_tx_noise_floor" + +## Defines +#boot file path for the initialization of UartDeviceTC(): +TC55B01_BOOT_FILE = r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\classd_boot_166.bin" + +#call the init.py module: +import math +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC55b_regs.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC55b_defs.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\apx525_functions.py") + +################################################################################################## + +# defines: + +def tx_noise_floor_config(A7): + ''' + 1. Open the band-gap, charge-pump block and LDO, + and enable CLK_CP. + 2. Enable the output amplifier. + 3. Enable the digital path with no specific order + 4. Enable the DAC.''' + + # # pll_configurations: + A7.write_register('4', '1002f00') + A7.write_register('0', '1017') + # # enable bad-gap: + A7.tc_setbits(AFE_BGREF_CFG, 0x1) + # # enable CLK_CP: + A7.tc_setbits(SCU_CLK_PMOD, 0x40000) + # #enable LDO + #TBD + # # enable OUTAMP0_EN: + A7.tc_setbits(AFE_OUTAMP_CFG0, 0x1) + # # enable GDAC0_CLK, GDAC1_CLK, GDAC_CLK_MOD: + A7.tc_setbits(SCU_CLK_PMOD, 0xe0000000) + # # enable I2S: + A7.tc_setbits(SCU_CLK_PMOD, 0x1000) + + +process = 'TYP' #'FF' / 'SS' +# oven = VotschVT4002(OVEN_ADDRESS) +# A7 = UartDeviceTC(name="TC", com="COM6", baudrate=115200, parity='E', stopbits=1, boot_file=TC55B01_BOOT_FILE) + +#inital Excel file: +wb1, full_path = create_excel_file(DIR_NAME, LOG_NAME_EXCEL) +ws1 = wb1.create_sheet("Noise_floor_test_{}".format(process)) + +#define the values for this test: +colomns_dict = {} +colomns_list = ['process', + 'temp[C]', + 'VCCA[V]', + 'gear_number', + 'quality', + 'Noise level result', + 'result_units'] +#define a colomn number for every value: +for col, value in enumerate(colomns_list): + colomns_dict[value] = col + # insert healines into Excel: + ws1.cell(row=1, column=col).value = value +wb1.save(full_path) + + +temp_list = ['-40', '25', '90'] +gear_list = [1, 2, 3, 4] +qual_list = ['LP', 'HQ', 'BTL'] +output_load_list = ['32000', '16000'] #ohm +vcca_list = ['1.8'] + + + +#initial the row number +current_row = 1 + + +for temp in temp_list: + # oven.wait_for_temp(temp) + + for load in output_load_list: + electronic_load = KikusuiPLZ70UA(ELECTRONIC_LOAD_ADDRESS) + electronic_load.set_resistance(load) + + for vcca in vcca_list: + + for gear in gear_list: + for qual in qual_list: + + if gear == 4 and qual == 'HQ': + break + elif qual == 'BTL' and gear != 4: + break + + else: + current_row += 1 + + #config TX PATH + # tx_noise_floor_config(A7, gear, qual) + + #measure noise level with APX525; + # Noise_RMS_resutls, units = SequenceMode_NoiseLevel_from_project(Noise_Level_project) + + #insert values into Excel + ws1.cell(row=current_row, column=colomns_dict['process']).value = process + ws1.cell(row=current_row, column=colomns_dict['temp[C]']).value = temp + ws1.cell(row=current_row, column=colomns_dict['VCCA[V]']).value = vcca + ws1.cell(row=current_row, column=colomns_dict['gear_number']).value = gear + ws1.cell(row=current_row, column=colomns_dict['quality']).value = qual + # ws1.cell(row=current_row, column=colomns_dict['Noise level result']).value = Noise_RMS_resutls + # ws1.cell(row=current_row, column=colomns_dict['result_units']).value = units + + wb1.save(full_path) \ No newline at end of file diff --git a/Tests/DBMA7/dbma7_tx_snr_test.py b/Tests/DBMA7/dbma7_tx_snr_test.py new file mode 100644 index 0000000..c1479b6 --- /dev/null +++ b/Tests/DBMA7/dbma7_tx_snr_test.py @@ -0,0 +1,94 @@ +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\\Users\bar.kristal\Documents\GitHub\Python\Tests\DBMA7." +TEST_NAME = "dbmA7_tx_snr_test" + +## Defines +#boot file path for the initialization of UartDeviceTC(): +TC55B01_BOOT_FILE = r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\classd_boot_166.bin" + +#call the init.py module: +import math +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC55b_regs.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC55b_defs.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\apx525_functions.py") +################################################################################################## + +# defines: + +def tx_snr_config(A7): + '''configure TX path for the test''' + + + + +process = 'TYP' #'FF' / 'SS' +oven = VotschVT4002(OVEN_ADDRESS) +A7 = UartDeviceTC(name="TC", com="COM6", baudrate=115200, parity='E', stopbits=1, boot_file=TC55B01_BOOT_FILE) + + +temp_list = ['-40', '25', '90'] +gear_list = ['auto'] +qual_list = ['auto'] +noise_gating_list = ['on', 'off'] +output_load_list = ['32000', '16000'] +vcca_list = ['1.8'] + +#inital Excel file: +wb1, full_path = create_excel_file(DIR_NAME, LOG_NAME_EXCEL) +ws1 = wb1.create_sheet("SNR_test_{}".format(prosess)) + +#define the values for this test: +colomns_dict = {} +colomns_list = ['process', + 'temp[C]', + 'VCCA[V]', + 'gear_number', + 'quality', + 'noise gating', + 'SNR result', + 'result_units'] + +#define a colomn number for every value: +for col, value in enumerate(colomns_list): + colomns_dict[value] = col + # insert healines into Excel: + ws1.cell(row=1, column=col).value = value +wb1.save(full_path) + + +#initial the row number +current_row = 1 + + +for temp in temp_list: + oven.wait_for_temp(temp) + + for load in output_load_list: + electronic_load = KikusuiPLZ70UA(ELECTRONIC_LOAD_ADDRESS) + electronic_load.set_resistance(load) + + for vcca in vcca_list: + for gear in gear_list: + for qual in qual_list: + for noise_gating in noise_gating_list: + current_row += 1 + + #config TX PATH + tx_snr_config(A7, noise_gating) + + #measure noise level with APX525; + # SNR_resutls, units = SequenceMode_SNR_from_project(SNR_project) + + #insert values into Excel + ws1.cell(row=current_row, column=colomns_dict['process']).value = process + ws1.cell(row=current_row, column=colomns_dict['temp[C]']).value = temp + ws1.cell(row=current_row, column=colomns_dict['VCCA[V]']).value = vcca + ws1.cell(row=current_row, column=colomns_dict['gear_number']).value = gear + ws1.cell(row=current_row, column=colomns_dict['quality']).value = qual + ws1.cell(row=current_row, column=colomns_dict['noise_gating']).value = noise_gating + ws1.cell(row=current_row, column=colomns_dict['SNR_resutls']).value = SNR_resutls + ws1.cell(row=current_row, column=colomns_dict['result_units']).value = units + + wb1.save(full_path) \ No newline at end of file diff --git a/Tests/DBMA7/dbma7_tx_thdn_test.py b/Tests/DBMA7/dbma7_tx_thdn_test.py new file mode 100644 index 0000000..d2857ee --- /dev/null +++ b/Tests/DBMA7/dbma7_tx_thdn_test.py @@ -0,0 +1,101 @@ +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\\Users\bar.kristal\Documents\GitHub\Python\Tests\DBMA7." +TEST_NAME = "dbmA7_tx_thdn_test + +## Defines +#boot file path for the initialization of UartDeviceTC(): +TC55B01_BOOT_FILE = r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\classd_boot_166.bin" + +#call the init.py module: +import math +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC55b_regs.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC55b_defs.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\apx525_functions.py") +################################################################################################## + +# defines: + + +def tx_thdn_config(A7): + '''configure TX path for the test''' + + + + +process = 'TYP' #'FF' / 'SS' +oven = VotschVT4002(OVEN_ADDRESS) +A7 = UartDeviceTC(name="TC", com="COM6", baudrate=115200, parity='E', stopbits=1, boot_file=TC55B01_BOOT_FILE) + + +temp_list = ['-40', '25', '90'] +gear_list = ['auto'] +qual_list = ['auto'] +noise_gating_list = ['off'] +output_load_list = ['32000', '16000'] +vcca_list = ['1.7, 1.8', '2'] + +#inital Excel file: +wb1, full_path = create_excel_file(DIR_NAME, LOG_NAME_EXCEL) +ws1 = wb1.create_sheet("thd+n_test_{}".format(prosess)) + + +#define the values for this test: +colomns_dict = {} +colomns_list = ['process', + 'temp[C]', + 'VCCA[V]', + 'gear_number', + 'quality', + 'noise gating', + 'THD result', + 'THD result_units', + 'THD+N result', + 'THD+N result_units'] + +#define a colomn number for every value: +for col, value in enumerate(colomns_list): + colomns_dict[value] = col + # insert healines into Excel: + ws1.cell(row=1, column=col).value = value +wb1.save(full_path) + +#initial the row number +current_row = 1 + + +for temp in temp_list: + oven.wait_for_temp(temp) + + for load in output_load_list: + electronic_load = KikusuiPLZ70UA(ELECTRONIC_LOAD_ADDRESS) + electronic_load.set_resistance(load) + + for vcca in vcca_list: + for gear in gear_list: + for qual in qual_list: + for noise_gating in noise_gating_list: + current_row += 1 + + #config TX PATH + tx_thdn_config(A7) + + #measure noise level with APX525; + # THD_resutls, thd_units = SequenceMode_THD_from_project(THD_project) + # THDN_resutls, thdn_units = SequenceMode_THDN_Ratio_from_project(THDN_project) + + #insert values into Excel + ws1.cell(row=current_row, column=colomns_dict['process']).value = process + ws1.cell(row=current_row, column=colomns_dict['temp[C]']).value = temp + ws1.cell(row=current_row, column=colomns_dict['VCCA[V]']).value = vcca + ws1.cell(row=current_row, column=colomns_dict['gear_number']).value = gear + ws1.cell(row=current_row, column=colomns_dict['quality']).value = qual + ws1.cell(row=current_row, column=colomns_dict['noise_gating']).value = noise_gating + ws1.cell(row=current_row, column=colomns_dict['THD result']).value = THD_resutls + ws1.cell(row=current_row, column=colomns_dict['THD result_units']).value = thd_units + ws1.cell(row=current_row, column=colomns_dict['THD+N result']).value = THDN_resutls + ws1.cell(row=current_row, column=colomns_dict['THD+N result_units']).value = thdn_units + + + wb1.save(full_path) \ No newline at end of file diff --git a/Tests/DBMD4/dbma4_leakage_test.py b/Tests/DBMD4/dbma4_leakage_test.py new file mode 100644 index 0000000..3e38661 --- /dev/null +++ b/Tests/DBMD4/dbma4_leakage_test.py @@ -0,0 +1,87 @@ +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\\Users\bar.kristal\Documents\GitHub\Python\Tests\DBMD4" +TEST_NAME = "dbmd4_leakage_test" + +## Defines +#boot file path for the initialization of UartDeviceTC(): +TC55B01_BOOT_FILE = r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\classd_boot_166.bin" + +#call the init.py module: +import math +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC55b_regs.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC55b_defs.py") +################################################################################################## + +# defines: +num_of_repeat = 4 + +process_col = 1 +temp_col = 2 +core_voltage_col = 3 + + +process = 'TYP' #'TYP' / 'FF' / 'SS' + +oven = VotschVT4002(OVEN_ADDRESS) +power_supply = QL355TPPwrSply(POWER_SUPLLY_ADDRESS) +dmm = Agillent34401A(DMM_ADDRESS) + +power_supply.channel_off(2) +power_supply.set_volt(2, 0) +power_supply.sense(2, 0) + + +temp_list = ['80'] +core_voltage_list = ['1.2'] + +#inital Excel file: +wb1, full_path = create_excel_file(DIR_NAME, LOG_NAME_EXCEL) +ws1 = wb1.create_sheet("DBMD4_leakage_test {}".format(process)) + +#define the values for this test: +colomns_dict = {} +colomns_list = ['process', + 'temp[C]', + 'core_voltage[V]', + 'leakage current w/o core power', + 'leakage current with core power'] + +#define a colomn number for every value: +for col, value in enumerate(colomns_list, 1): + colomns_dict[value] = col + # insert healines into Excel: + ws1.cell(row=1, column=col).value = value +wb1.save(full_path) + +current_row = 1 #initialize the row counter + +for temp in temp_list: + # oven.wait_for_temp(temp) + oven.set_temp(temp) + for voltage in core_voltage_list: + + for i in range(num_of_repeat): + power_supply.set_volt(2, 0) + power_supply.channel_on(2) + time.sleep(0.1) + result1 = dmm.meas('DCV') + + time.sleep(0.1) + power_supply.set_volt(2, voltage) + time.sleep(0.1) + result2 = dmm.meas('DCV') + + current_row += 1 + + # insert values into Excel + ws1.cell(row=current_row, column=colomns_dict['process']).value = process + ws1.cell(row=current_row, column=colomns_dict['temp[C]']).value = temp + ws1.cell(row=current_row, column=colomns_dict['core_voltage[V]']).value = voltage + ws1.cell(row=current_row, column=colomns_dict['leakage current w/o core power']).value = result1 + ws1.cell(row=current_row, column=colomns_dict['leakage current with core power']).value = result2 + + wb1.save(full_path) + + diff --git a/Tests/DBMD7-FPGA/check.py b/Tests/DBMD7-FPGA/check.py new file mode 100644 index 0000000..09e3df6 --- /dev/null +++ b/Tests/DBMD7-FPGA/check.py @@ -0,0 +1,31 @@ + +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\\Users\bar.kristal\Documents\GitHub\Python\Tests\DBMD7-FPGA\check" +TEST_NAME = "check" + +#defines: +T32_APP_CMM_PATH = r"T:\\barkristal\DVF101\SPI\scripts\dvf101_app.cmm" + +#call the init.py module: +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") +####################################################################################### + + + +## Uart_Device: + +# D6 = UartDevice('DBMD6', 'COM13', baudrate=912600, bytesize=8, parity='N', stopbits=1,timeout=1) +# D6.change_baudrate(115200) +# print D6.ser.baudrate +# D6.sync(10) +# D6.load_boot_file(r'T:\Barkristal\VT_D6_ver_293_Sen333.bin') +# print D6.read_IO_port('3000000') + +D7 = UartDeviceD7FPGA('DBMD4', 'COM9', baudrate=912600, bytesize=8, parity='N', stopbits=1,timeout=1) +# D4.sync(10) +# D6.load_boot_file(r'T:\Barkristal\VT_D6_ver_293_Sen333.bin') +print D7.read_register('3000000') +print D7.read_register('3000008') +print D7.read_register('3000040') +print D7.read_register('3000024') \ No newline at end of file diff --git a/Tests/DBMD7-FPGA/timers_auto_restart.py b/Tests/DBMD7-FPGA/timers_auto_restart.py new file mode 100644 index 0000000..ecb1009 --- /dev/null +++ b/Tests/DBMD7-FPGA/timers_auto_restart.py @@ -0,0 +1,103 @@ + +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\\Users\bar.kristal\Documents\GitHub\Python\Tests\DBMD7-FPGA\timers" +TEST_NAME = "timers_auto_restart" + + +#call the init.py module: +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") +####################################################################################### + + + +###### defines: ###### + +TIMER0_BASE = '50' +TIMER1_BASE = '58' +TIMER2_BASE = '90' +TIMER3_BASE = '98' + +timer = 1 #set the TIMER to be tested +ITERATIONS = 3 + +if timer == 0: + BASE = TIMER0_BASE + MASK = 0x10 +else: + if timer == 1: + BASE = TIMER1_BASE + MASK = 0x8 + else: + if timer == 2: + BASE = TIMER2_BASE + MASK = 0x400 + else: + BASE = TIMER3_BASE + MASK = 0x800 + +D7 = UartDeviceD7FPGA('DBMD4', 'COM5', baudrate=912600, bytesize=8, parity='N', stopbits=1,timeout=1) + + + + + +#enable TIMERS_LP_EN and TIMERS23_EN: +D7.setbits('3000024', '110') + + + + +## auto restart count mode : +write_to_log("####auto-restart mode test on TIMER%d:####"%timer) + +#TIMER_OUT_R cleared by setting CT, auto_restart mode: +D7.write_register(BASE +'00000', '4') +D7.setbits(BASE +'00004', '8') + +#set timer value: +D7.write_register(BASE +'0000c', "8000000") +time.sleep(1) +write_to_log( D7.read_register(BASE +'00010') ) +#start counting down +D7.setbits(BASE +'00004', '1') +time.sleep(1) + +#clear TC: +D7.setbits(BASE + '00004', '4') +#clear TIMER0 interrupt at EICR +D7.write_register('200000c', 'ffff') +time.sleep(0.01) +interrupt0 = int(D7.read_register('2000004'),16) + +timer_cc = D7.read_register(BASE +'00010') +timer_cc_prev = timer_cc +itr = 0 +while (itr < ITERATIONS): + time.sleep(1) + write_to_log(timer_cc) + timer_cc = D7.read_register(BASE +'00010') + if (int(timer_cc, 16) > int(timer_cc_prev, 16)): + itr += 1 + interrupt1 = int(D7.read_register('2000004'), 16) + write_to_log("interrupt0: %x" % (interrupt0)) + write_to_log("interrupt1: %x" % (interrupt1)) + + if (interrupt0 & MASK == 0 and interrupt1 & MASK == MASK): + + write_to_log("timer0 on single count mode PASSED") + else: + write_to_log("timer0 on single count mode FAILED") + + #clear TIMER0 interrupt at EICR + D7.setbits(BASE + '00004', '4') + D7.write_register('200000c', 'ffff') + + else: + interrupt0 = int(D7.read_register('2000004'), 16) + + timer_cc_prev = timer_cc + + + + diff --git a/Tests/DBMD7-FPGA/timers_event_count.py b/Tests/DBMD7-FPGA/timers_event_count.py new file mode 100644 index 0000000..7200af1 --- /dev/null +++ b/Tests/DBMD7-FPGA/timers_event_count.py @@ -0,0 +1,93 @@ + +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\\Users\bar.kristal\Documents\GitHub\Python\Tests\DBMD7-FPGA\timers" +TEST_NAME = "timers_single_count" + + +#call the init.py module: +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") +####################################################################################### + + + +###### defines: ###### + +TIMER0_BASE = '50' +TIMER1_BASE = '58' +TIMER2_BASE = '90' +TIMER3_BASE = '98' + +timer = 1 #set the TIMER to be tested +if timer == 0: + BASE = TIMER0_BASE + MASK = 0x10 +else: + if timer == 1: + BASE = TIMER1_BASE + MASK = 0x8 + else: + if timer == 2: + BASE = TIMER2_BASE + MASK = 0x400 + else: + BASE = TIMER3_BASE + MASK = 0x800 + +D7 = UartDeviceD7FPGA('DBMD4', 'COM5', baudrate=912600, bytesize=8, parity='N', stopbits=1,timeout=1) + + + + + +#enable TIMERS_LP_EN and TIMERS23_EN: +D7.setbits('3000024', '110') + + + + + +## event count mode : +write_to_log("####event count mode test on TIMER%d:####"%timer) + +#TIMER_OUT_R cleared by setting CT: +D7.write_register(BASE +'00000', '0c') +time.sleep(0.01) +D7.setbits(BASE + '00004', '4') + +#clear TIMER0 interrupt at EICR +D7.write_register('200000c', 'ffff') +time.sleep(0.1) +#read interrupt status: +interrupt0 = int(D7.read_register('2000004'),16) + + +#COUNTER regiser is reflected at TIMER_CC: +D7.setbits(BASE + '00004', '8') +#set timer value: +D7.write_register(BASE + '0000c', "f") +time.sleep(1) +write_to_log( D7.read_register(BASE + '00010') ) +#start counting down +D7.setbits(BASE + '00004', '1') +time.sleep(1) +timer_cc = D7.read_register(BASE + '00010') +while( timer_cc != '0'): + # write 1 to EW: (click the event counter) + D7.write_register(BASE + '00008', '1') + write_to_log(timer_cc) + timer_cc = D7.read_register(BASE + '00010') +time.sleep(0.01) + +interrupt1 = int(D7.read_register('2000004'), 16) +write_to_log("interrupt0: %x"%(interrupt0)) +write_to_log("interrupt1: %x"%(interrupt1)) + +if (interrupt0&MASK == 0 and interrupt1&MASK == MASK): + + write_to_log("timer0 on event count mode PASSED") +else: + write_to_log("timer0 on event count mode FAILED") + + + diff --git a/Tests/DBMD7-FPGA/timers_free_running.py b/Tests/DBMD7-FPGA/timers_free_running.py new file mode 100644 index 0000000..ec033f2 --- /dev/null +++ b/Tests/DBMD7-FPGA/timers_free_running.py @@ -0,0 +1,106 @@ + +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\\Users\bar.kristal\Documents\GitHub\Python\Tests\DBMD7-FPGA\timers" +TEST_NAME = "timers_free_running" + + +#call the init.py module: +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") +####################################################################################### + + + +###### defines: ###### + +TIMER0_BASE = '50' +TIMER1_BASE = '58' +TIMER2_BASE = '90' +TIMER3_BASE = '98' + +timer = 0 #set the TIMER to be tested +ITERATIONS = 2 + +if timer == 0: + BASE = TIMER0_BASE + MASK = 0x10 +else: + if timer == 1: + BASE = TIMER1_BASE + MASK = 0x8 + else: + if timer == 2: + BASE = TIMER2_BASE + MASK = 0x400 + else: + BASE = TIMER3_BASE + MASK = 0x800 + +D7 = UartDeviceD7FPGA('DBMD4', 'COM5', baudrate=912600, bytesize=8, parity='N', stopbits=1,timeout=1) + + + + + +#enable TIMERS_LP_EN and TIMERS23_EN: +D7.setbits('3000024', '110') + +### free running mode : +write_to_log("####free running test on TIMER%d:####"%timer) + + +#pause the counter: +D7.setbits(BASE + '00004', '2') + +#clear TC: +D7.setbits(BASE + '00004', '4') +#clear TIMER0 interrupt at EICR +D7.write_register('200000c', 'ffff') +time.sleep(0.01) +interrupt0 = int(D7.read_register('2000004'),16) + +#TIMER_OUT_R cleared by setting CT, free-running mode, TS(time scale)= /16 : +D7.write_register(BASE +'00000', 'b') + +#un-pause the counter: +D7.clrbits(BASE + '00004', '2') + + +#pause the counter: +D7.setbits(BASE + '00004', '2') +if (int(D7.read_register(BASE +'00010'), 16) == int(D7.read_register(BASE +'00010'), 16)): + write_to_log("Pause Count PASSED") +#un-pause the counter: +D7.clrbits(BASE + '00004', '2') + + +timer_cc = D7.read_register(BASE +'00010') +timer_cc_prev = timer_cc +itr = 0 +while (itr < ITERATIONS): + time.sleep(1) + write_to_log(timer_cc) + timer_cc = D7.read_register(BASE +'00010') + if (int(timer_cc, 16) > int(timer_cc_prev, 16)): + itr += 1 + interrupt1 = int(D7.read_register('2000004'), 16) + write_to_log("interrupt0: %x" % (interrupt0)) + write_to_log("interrupt1: %x" % (interrupt1)) + + if (interrupt0 & MASK == 0 and interrupt1 & MASK == MASK): + + write_to_log("timer0 on single count mode PASSED") + else: + write_to_log("timer0 on single count mode FAILED") + + #clear TIMER0 interrupt at EICR + D7.setbits(BASE + '00004', '4') + D7.write_register('200000c', 'ffff') + + else: + interrupt0 = int(D7.read_register('2000004'), 16) + + timer_cc_prev = timer_cc + + + diff --git a/Tests/DBMD7-FPGA/timers_single_count.py b/Tests/DBMD7-FPGA/timers_single_count.py new file mode 100644 index 0000000..dcd8597 --- /dev/null +++ b/Tests/DBMD7-FPGA/timers_single_count.py @@ -0,0 +1,92 @@ + +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\\Users\bar.kristal\Documents\GitHub\Python\Tests\DBMD7-FPGA\timers" +TEST_NAME = "timers_single_count" + + +#call the init.py module: +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") +####################################################################################### + + + +###### defines: ###### + +TIMER0_BASE = '50' +TIMER1_BASE = '58' +TIMER2_BASE = '90' +TIMER3_BASE = '98' + +timer = 1 #set the TIMER to be tested +if timer == 0: + BASE = TIMER0_BASE + MASK = 0x10 +else: + if timer == 1: + BASE = TIMER1_BASE + MASK = 0x8 + else: + if timer == 2: + BASE = TIMER2_BASE + MASK = 0x400 + else: + BASE = TIMER3_BASE + MASK = 0x800 + +D7 = UartDeviceD7FPGA('DBMD4', 'COM5', baudrate=912600, bytesize=8, parity='N', stopbits=1,timeout=1) + + + + + +#enable TIMERS_LP_EN and TIMERS23_EN: +D7.setbits('3000024', '110') + + + + + +## single count mode : +write_to_log("####single count mode test on TIMER%d:####"%timer) + +#TIMER_OUT_R cleared by setting CT: +D7.write_register(BASE +'00000', '0') +time.sleep(0.01) +D7.setbits(BASE + '00004', '4') + +#clear TIMER0 interrupt at EICR +D7.write_register('200000c', 'ffff') +time.sleep(0.1) +#read interrupt status: +interrupt0 = int(D7.read_register('2000004'),16) + + +#COUNTER regiser is reflected at TIMER_CC: +D7.setbits(BASE + '00004', '8') +#set timer value: +D7.write_register(BASE + '0000c', "8000000") +time.sleep(1) +write_to_log( D7.read_register(BASE + '00010') ) +#start counting down +D7.setbits(BASE + '00004', '1') +time.sleep(1) +timer_cc = D7.read_register(BASE + '00010') +while( timer_cc != '0'): + time.sleep(1) + write_to_log(timer_cc) + timer_cc = D7.read_register(BASE + '00010') +time.sleep(0.01) + +interrupt1 = int(D7.read_register('2000004'), 16) +write_to_log("interrupt0: %x"%(interrupt0)) +write_to_log("interrupt1: %x"%(interrupt1)) + +if (interrupt0&MASK == 0 and interrupt1&MASK == MASK): + + write_to_log("timer0 on single count mode PASSED") +else: + write_to_log("timer0 on single count mode FAILED") + + + diff --git a/Tests/DBMD7-FPGA/timers_watchdog.py b/Tests/DBMD7-FPGA/timers_watchdog.py new file mode 100644 index 0000000..092c8e2 --- /dev/null +++ b/Tests/DBMD7-FPGA/timers_watchdog.py @@ -0,0 +1,88 @@ + +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\\Users\bar.kristal\Documents\GitHub\Python\Tests\DBMD7-FPGA\timers" +TEST_NAME = "timers_watchdog" + + +#call the init.py module: +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") +####################################################################################### + + + +###### defines: ###### + +TIMER0_BASE = '50' + + +timer = 0 #set the TIMER to be tested +ITERATIONS = 3 + +BASE = TIMER0_BASE +MASK = 0x10 + + +D7 = UartDeviceD7FPGA('DBMD4', 'COM9', baudrate=912600, bytesize=8, parity='N', stopbits=1,timeout=1) + + + + + +#enable TIMERS_LP_EN and TIMERS23_EN: +D7.setbits('3000024', '110') + + + + +## watchdog mode : +write_to_log("####watchdog test on TIMER%d:####"%timer) + + +#set timer value: +D7.write_register(BASE +'0000c', "8000000") +time.sleep(1) +write_to_log( D7.read_register(BASE +'00010') ) + + +#TIMER_OUT_R cleared by setting CT,watchdog mode: +D7.setbits(BASE +'00004', '8') +D7.write_register(BASE +'00000', '14') #sub-mode 2 (NMI) + + +#clear TC: +# D7.setbits(BASE + '00004', '4') +#clear TIMER0 interrupt at EICR +D7.write_register('200000c', 'ffff') +time.sleep(0.01) +interrupt0 = int(D7.read_register('2000004'),16) + + +#start counting down +D7.setbits(BASE +'00008', '1') +time.sleep(0.1) + + +timer_cc = D7.read_register(BASE +'00010') +timer_cc_prev = timer_cc +while( timer_cc != '0'): + time.sleep(1) + write_to_log(timer_cc) + timer_cc = D7.read_register(BASE + '00010') +time.sleep(0.01) + +interrupt1 = int(D7.read_register('2000004'), 16) +write_to_log("interrupt0: %x"%(interrupt0)) +write_to_log("interrupt1: %x"%(interrupt1)) + +if (interrupt0&MASK == 0 and interrupt1&MASK == MASK): + + write_to_log("timer0 on single count mode PASSED") +else: + write_to_log("timer0 on single count mode FAILED") + + + + + + diff --git a/Tests/TC55B01/TC55b_defs.py b/Tests/TC55B01/TC55b_defs.py new file mode 100644 index 0000000..7c45b48 --- /dev/null +++ b/Tests/TC55B01/TC55b_defs.py @@ -0,0 +1,610 @@ +# =============================================== +# ===== TC55B01 (a.k.a TC2) register defs ===== +# ===== Based on tc55b_defs.dbt ===== +# ===== File Creator: Avihay Shemesh ===== +# ===== Date: 14/03/2017 ===== +# ===== Last modified: 14/03/2017 ===== +# =============================================== + + +NO_MASK = 0x00000000 +FULL_MASK = 0xFFFFFFFF +MASK_LOW = 0x0000FFFF +MASK_HIGH = 0xFFFF0000 + +# ===== REGS DEFAULTS +AFE_INAMP_CFG_DEFAULT = 0x14341434 +AFE_ADC_VREF_DLY_DEFAULT = 0x00ffffff +AFE_ADC_CFG_DEFAULT = 0x0cc90008 +AFE_OUTAMP_CFG_DEFAULT = 0x02203000 +AFE_DAC_CFG_DEFAULT = 0x00000300 +AFE_CHARGE_PUMP_0_CFG_DEFAULT = 0x00408fcc +AFE_CHARGE_PUMP_1_CFG_DEFAULT = 0x00408fcc +AFE_CHARGE_PUMP_0_CTL_DEFAULT = 0x00102010 +AFE_CHARGE_PUMP_1_CTL_DEFAULT = 0x00102010 +AFE_DNS_TO_CP_CTL_DEFAULT = 0x00000000 +AFE_BGREF_CFG_DEFAULT = 0x0000f0f0 +AFE_ANALOG_TEST_MUX_CFG_DEFAULT = 0x0000a0f7 +AFE_SPARE_CFG1_DEFAULT = 0x00000000 +AFE_SPARE_CFG2_DEFAULT = 0x00000000 + +# ===== FIELDS + +AFE_INAMP_CFG_INAMP0_GAIN = 0x0000001F +AFE_INAMP_CFG_INAMP0_ICTRL = 0x00000020 +AFE_INAMP_CFG_INAMP0_INC_CURR = 0x00000040 +AFE_INAMP_CFG_INAMP0_EN = 0x00000080 +AFE_INAMP_CFG_INAMP1_GAIN = 0x00001F00 +AFE_INAMP_CFG_INAMP1_EN = 0x00008000 +AFE_INAMP_CFG_INAMP2_GAIN = 0x001F0000 +AFE_INAMP_CFG_INAMP2_ICTRL = 0x00200000 +AFE_INAMP_CFG_INAMP2_INC_CURR = 0x00400000 +AFE_INAMP_CFG_INAMP2_EN = 0x00800000 +AFE_INAMP_CFG_INAMP3_GAIN = 0x1F000000 +AFE_INAMP_CFG_INAMP3_EN = 0x80000000 + + +AFE_ADC_CFG_ADC0_EN = 0x00000001 +AFE_ADC_CFG_ADC1_EN = 0x00000002 +AFE_ADC_CFG_EN_DR2Z = 0x00000004 +AFE_ADC_CFG_VREFAMP_ICTRL = 0x00000008 +AFE_ADC_CFG_DITHER_PWR = 0x00000700 +AFE_ADC_CFG_DITHER_EN = 0x00000800 +AFE_ADC_CFG_DIS_OPAMPS = 0x00001000 +AFE_ADC_CFG_FLASH_TEST_EN = 0x00002000 +AFE_ADC_CFG_VREF_FAST_CHARGE = 0x00004000 +AFE_ADC_CFG_PLUS_6DB = 0x00008000 +AFE_ADC_CFG_VERF_AMP_FLWR_LVL = 0x00070000 +AFE_ADC_CFG_VREF_FLASH_LVL = 0x00F80000 +AFE_ADC_CFG_VREF_AMP_LVL = 0x07000000 +AFE_ADC_CFG_ICTRL = 0x08000000 +AFE_ADC_CFG_VTEST_OUT_SEL = 0x70000000 +AFE_ADC_CFG_ADC_COM_VREF_EN = 0x80000000 + +AFE_OUTAMP_CFG_OUTAMP0_EN = 0x00000001 +AFE_OUTAMP_CFG_OUTAMP0_EN_BIAS = 0x00000002 +AFE_OUTAMP_CFG_OUTAMP1_EN = 0x00000004 +AFE_OUTAMP_CFG_OUTAMP1_EN_BIAS = 0x00000008 +AFE_OUTAMP_CFG_OUTAMP2_EN = 0x00000010 +AFE_OUTAMP_CFG_OUTAMP2_EN_BIAS = 0x00000020 +AFE_OUTAMP_CFG_OUTAMP3_EN = 0x00000040 +AFE_OUTAMP_CFG_OUTAMP3_EN_BIAS = 0x00000080 +AFE_OUTAMP_CFG_OUTAMP4_EN = 0x00000100 +AFE_OUTAMP_CFG_OUTAMP4_EN_BIAS = 0x00000200 +AFE_OUTAMP_CFG_OUTAMP5_EN = 0x00000400 +AFE_OUTAMP_CFG_OUTAMP5_EN_BIAS = 0x00000800 +AFE_OUTAMP_CFG_ICTRL = 0x00003000 +AFE_OUTAMP_CFG_RES_CONFIG = 0x0000C000 +AFE_OUTAMP_CFG_OUTAMP01_VCCAQ_EN = 0x00010000 +AFE_OUTAMP_CFG_OUTAMP23_VCCAQ_EN = 0x00020000 +AFE_OUTAMP_CFG_OUTAMP45_VCCAQ_EN = 0x00040000 +AFE_OUTAMP_CFG_VCCAQ_BIAS_TRIM = 0x00300000 +AFE_OUTAMP_CFG_VCCAQ_OUTPUT_TRIM = 0x07000000 + +AFE_DAC_CFG_DAC0_EN = 0x1 +AFE_DAC_CFG_DAC1_EN = 0x2 +AFE_DAC_CFG_DAC2_EN = 0x4 +AFE_DAC_CFG_DAC3_EN = 0x8 +AFE_DAC_CFG_DAC4_EN = 0x10 +AFE_DAC_CFG_DAC5_EN = 0x20 +# ===== reserved +AFE_DAC_CFG_DAC_ICTRL_loc = 8 +AFE_DAC_CFG_DAC_ICTRL = 0x700 +# ===== skip +AFE_DAC_CFG_DAC0_FORCE_EN = 0x10000 +AFE_DAC_CFG_DAC1_FORCE_EN = 0x20000 +AFE_DAC_CFG_DAC2_FORCE_EN = 0x40000 +AFE_DAC_CFG_DAC3_FORCE_EN = 0x80000 +AFE_DAC_CFG_DAC4_FORCE_EN = 0x100000 +AFE_DAC_CFG_DAC5_FORCE_EN = 0x200000 + + +AFE_CHARGE_PUMP_x_CFG_CP_EN_REG = 0x1 + +AFE_DNS_TO_CP_CTL_CP0_HI_SIG0_EN = 0x1 +AFE_DNS_TO_CP_CTL_CP0_HI_SIG1_EN = 0x2 +AFE_DNS_TO_CP_CTL_CP0_HI_SIG2_EN = 0x4 +AFE_DNS_TO_CP_CTL_CP0_HI_SIG3_EN = 0x8 +AFE_DNS_TO_CP_CTL_CP1_HI_SIG0_EN = 0x10 +AFE_DNS_TO_CP_CTL_CP1_HI_SIG1_EN = 0x20 +AFE_DNS_TO_CP_CTL_CP1_HI_SIG2_EN = 0x40 +AFE_DNS_TO_CP_CTL_CP1_HI_SIG3_EN = 0x80 + +AFE_BGREF_CFG_BGREF_EN = 0x1 + +# ============================================ +# =================== DDF ==================== +# ============================================ + +# ===== REGS DEFAULTS +DDF_CFG1_DEFAULT = 0x00401F08 +DDF_CFG2_DEFAULT = 0x0A100100 +DDF_CFG3_DEFAULT = 0x00640301 +DDF_DC_OFFST_DEFAULT = 0x00000000 +DDF_EVENT_CFG_DEFAULT = 0x00000000 +DDF_STAT_DEFAULT = 0x00000000 +DDF_TEST_IN_DATA_DEFAULT = 0x00000000 +DDF_OFIFO_DATA_DEFAULT = 0x00000000 +DDF_BQ_B_DEFAULT = 0x00000000 +DDF_BQ_AN_DEFAULT = 0x00000000 + +# ===== FIELDS +DDF_CFG1_FIFO_WM = 0x0000001F +DDF_CFG1_OUT_16_24 = 0x00000020 +DDF_CFG1_ROUND_MODE = 0x00000040 +DDF_CFG1_CDF = 0x0001FF00 +DDF_CFG1_CIC_ORDER = 0x00700000 +DDF_CFG1_CICD_BP = 0x01000000 +DDF_CFG1_CICI_BP = 0x02000000 +DDF_CFG1_INPUT_TEST = 0x04000000 +DDF_CFG1_DDF_ENABLE = 0x08000000 + +DDF_CFG2_POST_IIR_G2 = 0x000001FF +DDF_CFG2_POST_IIR_SHIFT = 0x00000E00 +DDF_CFG2_PRE_IIR_G1 = 0x001FF000 +DDF_CFG2_PRE_IIR_SHIFT = 0x1F000000 + +DDF_CFG3_IDF2 = 0x0000001F +DDF_CFG3_IDF1 = 0x00001F00 +DDF_CFG3_SIIR2 = 0x000F0000 +DDF_CFG3_SIIR1 = 0x00F00000 + +DDF_DC_OFFST_DC_OFFST = 0x00FFFFFF + +DDF_EVENT_CFG_POST_IIR_SAT_IE = 0x00000001 +DDF_EVENT_CFG_PRE_IIR_OVF_IE = 0x00000002 +DDF_EVENT_CFG_IIR_OVF_IE = 0x00000004 +DDF_EVENT_CFG_DATA_OVRN_IE = 0x00000008 +DDF_EVENT_CFG_FIFO_ERR_IE = 0x00000010 +DDF_EVENT_CFG_IE_ALL = 0x1F + +DDF_STAT_OFIFO_STAT = 0x0000001F +DDF_STAT_POST_IIR_ST = 0x00000100 +DDF_STAT_PRE_IIR_ST = 0x00000200 +DDF_STAT_IIR_OVF_ST = 0x00000400 +DDF_STAT_DATA_OVRN_ST = 0x00000800 +DDF_STAT_FIFO_OVRN_ST = 0x00001000 +DDF_STAT_FIFO_UDRN_ST = 0x00002000 +DDF_STAT_WM_ST = 0x00004000 +DDF_STAT_BQ_OVF_INDEX = 0x000F0000 + +DDF_TEST_IN_DATA_TEST_I_DATA = 0x0000001F +DDF_OFIFO_DATA_OFIFO_DATA = 0xFFFFFFFF +DDF_BQ_B_BQi_Bj = 0x0003FFFF +DDF_BQ_AN_BQi_AjN = 0x0003FFFF + +# ============================================ +# ================= SCU ====================== +# ============================================ + +# ===== REGS DEFAULTS +TC55_SCU_PLL_CFG1_DEFAULT = 0x00001018 +TC55_SCU_PLL_CFG2_DEFAULT = 0x11002F00 +TC55_SCU_PLL_LCK_DEFAULT = 0x0007B1FF +TC55_SCU_CLK_DIV1_DEFAULT = 0x00000000 +TC55_SCU_CLK_DIV2_DEFAULT = 0x23470E00 +TC55_SCU_CLK_DIV3_DEFAULT = 0x00001000 +TC55_SCU_CLK_DIV4_DEFAULT = 0x007B3800 +TC55_SCU_CLK_DIV5_DEFAULT = 0x00bf00bf +TC55_SCU_CLK_PMOD_DEFAULT = 0x00000000 +TC55_SCU_BLK_RST_DEFAULT = 0x00000000 +TC55_SCU_I2S_CFG_DEFAULT = 0x00001717 +TC55_SCU_CP_CFG_DEFAULT = 0x0000006C +TC55_SCU_IODS_DEFAULT = 0x00000000 +TC55_SCU_IOKE_DEFAULT = 0xFFFFFFFD +TC55_SCU_IOPE_DEFAULT = 0xF0000002 +TC55_SCU_IOPV_DEFAULT = 0x00000002 +TC55_SCU_IOIE_DEFAULT = 0xFFFFFFFF +TC55_SCU_TEST_CTL1_DEFAULT = 0x3210F000 +TC55_SCU_TEST_CTL2_DEFAULT = 0x00000000 + +# ===== FEILDS +# ===== TC55_SCU_PLL_CFG1 +TC55_BYPASS = 0x00008000 +TC55_TEST = 0x00004000 +TC55_FASTEN = 0x00002000 +TC55_ENSAT = 0x00001000 +TC55_BWADJ = 0x00000FFF + +# ===== TC55_SCU_PLL_CFG2 +TC55_POWER_DOWN = 0x10000000 +TC55_CLKOD = 0x07000000 +TC55_CLKF = 0x001FFF00 +TC55_CLKR = 0x0000003F + +# ===== TC55_SCU_PLL_LCK +TC55_PLL_LCK = 0x01000000 +TC55_PLL_RST_COUNT = 0x003FF000 +TC55_PLL_LOCK_COUNT = 0x00000FFF + +# ===== TC55_SCU_CLK_DIV1 +TC55_SYS_CLK_DIV = 0x0000FF00 +TC55_PLL_POSTDIV = 0x000000FC +TC55_PLL_PREDIV = 0x00000003 + +# ===== TC55_SCU_CLK_DIV2 +TC55_ADC_DAC_CLK_DIV_loc = 24 +TC55_ADC_DAC_CLK_DIV = 0xFF000000 +TC55_ADC_CLK_DIV_loc = 16 +TC55_ADC_CLK_DIV = 0x00FF0000 +TC55_DEM_CLK_DIV_loc = 8 +TC55_DEM_CLK_DIV = 0x0000FF00 +TC55_DDF_CLK_DIV_loc = 0 +TC55_DDF_CLK_DIV = 0x000000FF + +# ===== TC55_SCU_CLK_DIV3 +TC55_DAC2DNS_STRB_DLY_loc = 24 +TC55_DAC2DNS_STRB_DLY = 0xFF000000 +TC55_ADC2DDF_STRB_DLY = 0x00FF0000 +TC55_ADC2ADCDAC_DLY = 0x0000FF00 +TC55_ADC2DEM_DLY = 0x000000FF + +# ===== TC55_SCU_CLK_DIV4 +TC55_CP_CLK_DIV = 0x0FFF0000 +TC55_DAC_CLK_DIV_loc = 8 +TC55_DAC_CLK_DIV = 0x0000FF00 +TC55_DNS_CLK_DIV_loc = 0 +TC55_DNS_CLK_DIV = 0x000000FF + +# ===== TC55_SCU_CLK_DIV5 +TC55_I2S0_CLK_DIV_loc = 0 +TC55_I2S1_CLK_DIV_loc = 16 +TC55_I2S0_CLK_DIV = 0x0000FFFF +TC55_I2S1_CLK_DIV = 0xFFFF0000 + +# ===== TC55_SCU_CLK_PMOD +TC55_CP_CLK_EN = 0x00040000 +TC55_DAC_CLK_EN = 0x00020000 +TC55_ADC_CLK_EN = 0x00010000 +# ===== bits 15-14 reserved +TC55_I2S1_CLK_EN = 0x00002000 +TC55_I2S0_CLK_EN = 0x00001000 +TC55_CLSSG_DNS3_CLK_EN = 0x00000800 +TC55_CLSSG_DNS2_CLK_EN = 0x00000400 +TC55_CLSSG_DNS1_CLK_EN = 0x00000200 +TC55_CLSSG_DNS0_CLK_EN = 0x00000100 +TC55_DNS3_CLK_EN = 0x00000080 +TC55_DNS2_CLK_EN = 0x00000040 +TC55_DNS1_CLK_EN = 0x00000020 +TC55_DNS0_CLK_EN = 0x00000010 +TC55_DEM1_CLK_EN = 0x00000008 +TC55_DEM0_CLK_EN = 0x00000004 +TC55_DDF1_CLK_EN = 0x00000002 +TC55_DDF0_CLK_EN = 0x00000001 + +# ===== TC55_SCU_BLK_RST +TC55_I2S1_RST = 0x00080000 +TC55_I2S0_RST = 0x00040000 +TC55_CLSSG_DNS3_RST = 0x00020000 +TC55_CLSSG_DNS2_RST = 0x00010000 +TC55_CLSSG_DNS1_RST = 0x00008000 +TC55_CLSSG_DNS0_RST = 0x00004000 +TC55_DNS3_CORE_RST = 0x00002000 +TC55_DNS2_CORE_RST = 0x00001000 +TC55_DNS1_CORE_RST = 0x00000800 +TC55_DNS0_CORE_RST = 0x00000400 +TC55_DNS3_RST = 0x00000200 +TC55_DNS2_RST = 0x00000100 +TC55_DNS1_RST = 0x00000080 +TC55_DNS0_RST = 0x00000040 +TC55_DEM1_RST = 0x00000020 +TC55_DEM0_RST = 0x00000010 +TC55_DDF1_CORE_RST = 0x00000008 +TC55_DDF0_CORE_RST = 0x00000004 +TC55_DDF1_RST = 0x00000002 +TC55_DDF0_RST = 0x00000001 + +# ===== TC55_SCU_I2S_CFG +TC55_I2S1_LRC_TYPE = 0x00008000 +TC55_I2S1_SCLK_TYPE = 0x00004000 +TC55_I2S1_WIDTH_CTRL = 0x00001F00 +TC55_I2S0_LRC_TYPE = 0x00000080 +TC55_I2S0_SCLK_TYPE = 0x00000040 +TC55_I2S0_WIDTH_CTRL = 0x0000001F + +TC55_I2S1_WIDTH_32 = 0x00001F00 +TC55_I2S1_WIDTH_24 = 0x00001700 +TC55_I2S1_WIDTH_16 = 0x00000F00 +TC55_I2S0_WIDTH_32 = 0x0000001F +TC55_I2S0_WIDTH_24 = 0x00000017 +TC55_I2S0_WIDTH_16 = 0x0000000F + +# ===== TC55_SCU_IODS +TC55_IODS_TST_MUX_CLK_3 = 0x80000000 +TC55_IODS_TST_MUX_CLK_2 = 0x40000000 +TC55_IODS_TST_MUX_CLK_1 = 0x20000000 +TC55_IODS_TST_MUX_CLK_0 = 0x10000000 +TC55_IODS_TST_MUX_DATA_15 = 0x08000000 +TC55_IODS_TST_MUX_DATA_14 = 0x04000000 +TC55_IODS_TST_MUX_DATA_13 = 0x02000000 +TC55_IODS_TST_MUX_DATA_12 = 0x01000000 +TC55_IODS_TST_MUX_DATA_11 = 0x00800000 +TC55_IODS_TST_MUX_DATA_10 = 0x00400000 +TC55_IODS_TST_MUX_DATA_9 = 0x00200000 +TC55_IODS_TST_MUX_DATA_8 = 0x00100000 +TC55_IODS_TST_MUX_DATA_7 = 0x00080000 + +#define CLSSG_DNS_CLK_MASK 0x0f00 +TC55_IODS_TST_MUX_DATA_6 = 0x00040000 +TC55_IODS_TST_MUX_DATA_5 = 0x00020000 +TC55_IODS_TST_MUX_DATA_4 = 0x00010000 +TC55_IODS_TST_MUX_DATA_3 = 0x00008000 +TC55_IODS_TST_MUX_DATA_2 = 0x00004000 +TC55_IODS_TST_MUX_DATA_1 = 0x00002000 +TC55_IODS_TST_MUX_DATA_0 = 0x00001000 +TC55_IODS_I2S1_TXD = 0x00000800 +TC55_IODS_I2S1_RXD = 0x00000400 +TC55_IODS_I2S1_FSYNC = 0x00000200 +TC55_IODS_I2S1_SCLK = 0x00000100 +TC55_IODS_I2S0_TXD = 0x00000080 +TC55_IODS_I2S0_RXD = 0x00000040 +TC55_IODS_I2S0_FSYNC = 0x00000020 +TC55_IODS_I2S0_SCLK = 0x00000010 +TC55_IODS_SPI_SDO = 0x00000008 +TC55_IODS_SPI_SDI = 0x00000004 +TC55_IODS_SPI_SCS = 0x00000002 +TC55_IODS_SPI_SCK = 0x00000001 + +# ===== TC55_SCU_IOKE +TC55_IOKE_TST_MUX_CLK_3 = 0x80000000 +TC55_IOKE_TST_MUX_CLK_2 = 0x40000000 +TC55_IOKE_TST_MUX_CLK_1 = 0x20000000 +TC55_IOKE_TST_MUX_CLK_0 = 0x10000000 +TC55_IOKE_TST_MUX_DATA_15 = 0x08000000 +TC55_IOKE_TST_MUX_DATA_14 = 0x04000000 +TC55_IOKE_TST_MUX_DATA_13 = 0x02000000 +TC55_IOKE_TST_MUX_DATA_12 = 0x01000000 +TC55_IOKE_TST_MUX_DATA_11 = 0x00800000 +TC55_IOKE_TST_MUX_DATA_10 = 0x00400000 +TC55_IOKE_TST_MUX_DATA_9 = 0x00200000 +TC55_IOKE_TST_MUX_DATA_8 = 0x00100000 +TC55_IOKE_TST_MUX_DATA_7 = 0x00080000 +TC55_IOKE_TST_MUX_DATA_6 = 0x00040000 +TC55_IOKE_TST_MUX_DATA_5 = 0x00020000 +TC55_IOKE_TST_MUX_DATA_4 = 0x00010000 +TC55_IOKE_TST_MUX_DATA_3 = 0x00008000 +TC55_IOKE_TST_MUX_DATA_2 = 0x00004000 +TC55_IOKE_TST_MUX_DATA_1 = 0x00002000 +TC55_IOKE_TST_MUX_DATA_0 = 0x00001000 +TC55_IOKE_I2S1_TXD = 0x00000800 +TC55_IOKE_I2S1_RXD = 0x00000400 +TC55_IOKE_I2S1_FSYNC = 0x00000200 +TC55_IOKE_I2S1_SCLK = 0x00000100 +TC55_IOKE_I2S0_TXD = 0x00000080 +TC55_IOKE_I2S0_RXD = 0x00000040 +TC55_IOKE_I2S0_FSYNC = 0x00000020 +TC55_IOKE_I2S0_SCLK = 0x00000010 +TC55_IOKE_SPI_SDO = 0x00000008 +TC55_IOKE_SPI_SDI = 0x00000004 +TC55_IOKE_SPI_SCS = 0x00000002 +TC55_IOKE_SPI_SCK = 0x00000001 + +# ===== TC55_SCU_IOPE +TC55_IOPE_TST_MUX_CLK_3 = 0x80000000 +TC55_IOPE_TST_MUX_CLK_2 = 0x40000000 +TC55_IOPE_TST_MUX_CLK_1 = 0x20000000 +TC55_IOPE_TST_MUX_CLK_0 = 0x10000000 +TC55_IOPE_TST_MUX_DATA_15 = 0x08000000 +TC55_IOPE_TST_MUX_DATA_14 = 0x04000000 +TC55_IOPE_TST_MUX_DATA_13 = 0x02000000 +TC55_IOPE_TST_MUX_DATA_12 = 0x01000000 +TC55_IOPE_TST_MUX_DATA_11 = 0x00800000 +TC55_IOPE_TST_MUX_DATA_10 = 0x00400000 +TC55_IOPE_TST_MUX_DATA_9 = 0x00200000 +TC55_IOPE_TST_MUX_DATA_8 = 0x00100000 +TC55_IOPE_TST_MUX_DATA_7 = 0x00080000 +TC55_IOPE_TST_MUX_DATA_6 = 0x00040000 +TC55_IOPE_TST_MUX_DATA_5 = 0x00020000 +TC55_IOPE_TST_MUX_DATA_4 = 0x00010000 +TC55_IOPE_TST_MUX_DATA_3 = 0x00008000 +TC55_IOPE_TST_MUX_DATA_2 = 0x00004000 +TC55_IOPE_TST_MUX_DATA_1 = 0x00002000 +TC55_IOPE_TST_MUX_DATA_0 = 0x00001000 +TC55_IOPE_I2S1_TXD = 0x00000800 +TC55_IOPE_I2S1_RXD = 0x00000400 +TC55_IOPE_I2S1_FSYNC = 0x00000200 +TC55_IOPE_I2S1_SCLK = 0x00000100 +TC55_IOPE_I2S0_TXD = 0x00000080 +TC55_IOPE_I2S0_RXD = 0x00000040 +TC55_IOPE_I2S0_FSYNC = 0x00000020 +TC55_IOPE_I2S0_SCLK = 0x00000010 +TC55_IOPE_SPI_SDO = 0x00000008 +TC55_IOPE_SPI_SDI = 0x00000004 +TC55_IOPE_SPI_SCS = 0x00000002 +TC55_IOPE_SPI_SCK = 0x00000001 + +# ===== TC55_SCU_IOPV +TC55_IOPV_TST_MUX_CLK_3 = 0x80000000 +TC55_IOPV_TST_MUX_CLK_2 = 0x40000000 +TC55_IOPV_TST_MUX_CLK_1 = 0x20000000 +TC55_IOPV_TST_MUX_CLK_0 = 0x10000000 +TC55_IOPV_TST_MUX_DATA_15 = 0x08000000 +TC55_IOPV_TST_MUX_DATA_14 = 0x04000000 +TC55_IOPV_TST_MUX_DATA_13 = 0x02000000 +TC55_IOPV_TST_MUX_DATA_12 = 0x01000000 +TC55_IOPV_TST_MUX_DATA_11 = 0x00800000 +TC55_IOPV_TST_MUX_DATA_10 = 0x00400000 +TC55_IOPV_TST_MUX_DATA_9 = 0x00200000 +TC55_IOPV_TST_MUX_DATA_8 = 0x00100000 +TC55_IOPV_TST_MUX_DATA_7 = 0x00080000 +TC55_IOPV_TST_MUX_DATA_6 = 0x00040000 +TC55_IOPV_TST_MUX_DATA_5 = 0x00020000 +TC55_IOPV_TST_MUX_DATA_4 = 0x00010000 +TC55_IOPV_TST_MUX_DATA_3 = 0x00008000 +TC55_IOPV_TST_MUX_DATA_2 = 0x00004000 +TC55_IOPV_TST_MUX_DATA_1 = 0x00002000 +TC55_IOPV_TST_MUX_DATA_0 = 0x00001000 +TC55_IOPV_I2S1_TXD = 0x00000800 +TC55_IOPV_I2S1_RXD = 0x00000400 +TC55_IOPV_I2S1_FSYNC = 0x00000200 +TC55_IOPV_I2S1_SCLK = 0x00000100 +TC55_IOPV_I2S0_TXD = 0x00000080 +TC55_IOPV_I2S0_RXD = 0x00000040 +TC55_IOPV_I2S0_FSYNC = 0x00000020 +TC55_IOPV_I2S0_SCLK = 0x00000010 +TC55_IOPV_SPI_SDO = 0x00000008 +TC55_IOPV_SPI_SDI = 0x00000004 +TC55_IOPV_SPI_SCS = 0x00000002 +TC55_IOPV_SPI_SCK = 0x00000001 + +# ===== TC55_SCU_IOIE +TC55_IOIE_TST_MUX_CLK_3 = 0x80000000 +TC55_IOIE_TST_MUX_CLK_2 = 0x40000000 +TC55_IOIE_TST_MUX_CLK_1 = 0x20000000 +TC55_IOIE_TST_MUX_CLK_0 = 0x10000000 +TC55_IOIE_TST_MUX_DATA_15 = 0x08000000 +TC55_IOIE_TST_MUX_DATA_14 = 0x04000000 +TC55_IOIE_TST_MUX_DATA_13 = 0x02000000 +TC55_IOIE_TST_MUX_DATA_12 = 0x01000000 +TC55_IOIE_TST_MUX_DATA_11 = 0x00800000 +TC55_IOIE_TST_MUX_DATA_10 = 0x00400000 +TC55_IOIE_TST_MUX_DATA_9 = 0x00200000 +TC55_TIOIE_ST_MUX_DATA_8 = 0x00100000 +TC55_IOIE_TST_MUX_DATA_7 = 0x00080000 +TC55_IOIE_TST_MUX_DATA_6 = 0x00040000 +TC55_IOIE_TST_MUX_DATA_5 = 0x00020000 +TC55_IOIE_TST_MUX_DATA_4 = 0x00010000 +TC55_IOIE_TST_MUX_DATA_3 = 0x00008000 +TC55_IOIE_TST_MUX_DATA_2 = 0x00004000 +TC55_IOIE_TST_MUX_DATA_1 = 0x00002000 +TC55_IOIE_TST_MUX_DATA_0 = 0x00001000 +TC55_IOIE_I2S1_TXD = 0x00000800 +TC55_IOIE_I2S1_RXD = 0x00000400 +TC55_IOIE_I2S1_FSYNC = 0x00000200 +TC55_IOIE_I2S1_SCLK = 0x00000100 +TC55_IOIE_I2S0_TXD = 0x00000080 +TC55_IOIE_I2S0_RXD = 0x00000040 +TC55_IOIE_I2S0_FSYNC = 0x00000020 +TC55_IOIE_I2S0_SCLK = 0x00000010 +# ===== bit 3 reserved +TC55_IOIE_SPI_SDI = 0x00000004 +TC55_IOIE_SPI_SCS = 0x00000002 +TC55_IOIE_SPI_SCK = 0x00000001 + +# ===== TC55_SCU_TEST_CTL1 +TC55_DAC3_IN_SEL = 0xF0000000 +TC55_DAC2_IN_SEL = 0x0F000000 +TC55_DAC1_IN_SEL = 0x00F00000 +TC55_DAC0_IN_SEL = 0x000F0000 +TC55_DIFF_CLK_DIV = 0x0000F000 +TC55_DIFF_CLK_EN = 0x00000800 +TC55_SE_CLK0_MUX = 0x00000780 +TC55_SE_CLK1_MUX = 0x00000078 +TC55_DIG_TST_MUX = 0x00000007 + +# ===== TC55_SCU_TEST_CTL2 +# ============================================ +# ===== DNS +# ============================================ +# ===== REGS DEFAULTS +DNS_CFG1_DEFAULT = 0x00000000 +DNS_CFG2_DEFAULT = 0x00007551 +DNS_CFG3_DEFAULT = 0x00000000 +DNS_CFG4_DEFAULT = 0x00000000 +DNS_CFG5_DEFAULT = 0x00100000 +DNS_CFG6_DEFAULT = 0x00000000 +DNS_STAT_DEFAULT = 0x00000000 +DNS_DAT_DEFAULT = 0x00000000 +DNS_BQ_B_DEFAULT = 0x00000000 +DNS_BQ_AN_DEFAULT = 0x00000000 +# ===== FIELDS +DNS_CFG1_ENABLE = 0x00000001 +DNS_CFG1_MUTE = 0x00000002 + +DNS_CFG2_ZIS1 = 0x0000000F +DNS_CFG2_IIR1_B = 0x000000F0 +DNS_CFG2_IIR2_B = 0x00000F00 +DNS_CFG2_ZIS_ZOH2 = 0x0000F000 +DNS_CFG2_ZIS2_ZOH2_MD = 0x00010000 + +DNS_CFG3_GAIN = 0x000001FF +DNS_CFG3_SHIFT = 0x0000F000 + +DNS_CFG4_OFFSET = 0x00FFFFFF + +DNS_CFG5_DITHER_GAIN = 0x0000FFFF +DNS_CFG5_ZOH = 0x001F0000 +DNS_CFG5_DITH_EN = 0x01000000 +DNS_CFG5_SD_MODE = 0x30000000 + +DNS_CFG6_FIFO_WMT = 0x0000001F +DNS_CFG6_WM_IE = 0x00000020 +DNS_CFG6_FIFO_ERR_IE = 0x00000040 +DNS_CFG6_LM_IE = 0x00000080 +DNS_CFG6_BI_TRN_SAT_INT_EN = 0x00000100 + +DNS_STAT_FIFO_STAT = 0x0000001F +DNS_STAT_WM_INT_STAT = 0x00000020 +DNS_STAT_FIFO_OVRN = 0x00000040 +DNS_STAT_FIFO_UDRN = 0x00000080 +DNS_STAT_SCL_L = 0x00000100 +DNS_STAT_SD_L1 = 0x00000200 +DNS_STAT_SD_L2 = 0x00000400 +DNS_STAT_SD_L3 = 0x00000800 +DNS_STAT_SD_L4 = 0x00001000 +DNS_STAT_TRN_SAT = 0x00008000 +DNS_STAT_Bi_TRN_SAT = 0x000F0000 + +DNS_DAT_DATA = 0x00FFFFFF + +DNS_BQ_B_BQi_Bj = 0x0003FFFF +DNS_BQ_AN_BQi_AjN = 0x0003FFFF + +# ============================================ +# ===== DEM +# ============================================ + +# ===== REGS DEFAULTS + +DEM_CTL_DEFAULT = 0x00000004 +DEM_TST_DEFAULT = 0x00000000 +DEM_TEST_INPUT_DEFAULT = 0x00000000 +DEM_TEST_OUTPUT_DEFAULT = 0x00000000 + +# ===== FIELDS + +#DEM_CTL +DEM_EN = 0x00000001 +DEM_BYPASS = 0x00000002 +DITHER_EN = 0x00000004 + +#DEM_TST +I2_SAT_COUNT = 0x0000003F +I2_SAT_RAW = 0x00000040 +I2_SAT_IND_EN = 0x00000080 +MOD4_LOW_BYP = 0x00000100 +DITHER_LOW_BP = 0x00000400 +DITHER_SINGLE_STRB = 0x00000800 +INV_THERM_CNT = 0x0001F000 +DEM_TST_BSY = 0x40000000 +DEM_TST = 0x80000000 + +#DEM_TEST_INPUT +TEST_INPUT = 0x0000FFFF + +#DEM_TEST_OUTPUT +TEST_OUTPUT = 0x0000FFFF + +# ============================================ +# ===== CLASSG_DNS +# ============================================ + +# ===== REGS DEFAULTS + +CLASSG_DNS_CLSG_DET_DEFAULT = 0x0003E884 +CLASSG_DNS_IIR_CFG_DEFAULT = 0x00000248 +CLASSG_DNS_IIR_STAT_DEFAULT = 0x00000000 +CLASSG_DNS_THRS_DET_DEFAULT = 0x0002223E +CLASSG_DNS_BQ_B_DEFAULT = 0x00000000 +CLASSG_DNS_BQ_AN_DEFAULT = 0x00000000 + +# ===== FIELDS +CLASSGX_DET_ENABLE = 0x00000001 + +CLASSG_DNS_CLSG_DET_DLY_LNGT = 0x1E +CLASSG_DNS_IIR_STAT_TRN_SAT = 0x00000001 +CLASSG_DNS_IIR_STAT_Bi_TRN_SAT = 0x0000001E + + + + diff --git a/Tests/TC55B01/TC55b_regs.py b/Tests/TC55B01/TC55b_regs.py new file mode 100644 index 0000000..51b138f --- /dev/null +++ b/Tests/TC55B01/TC55b_regs.py @@ -0,0 +1,1188 @@ +# ==================================================== +# ===== TC55B01 (a.k.a TC2) register list ===== +# ===== Based on tc55b_regs.dbt ===== +# ===== File Creator: Avihay Shemesh ===== +# ===== Date: 14/03/2017 ===== +# ===== Last modified: 14/03/2017 ===== +# ==================================================== + +# ===== Define Base Adressess ===== +SCU_BASE = 0x0000 +AFE_BASE = 0x0100 +DNS0_BASE = 0x0200 +DNS1_BASE = 0x0400 +DNS2_BASE = 0x0600 +DNS3_BASE = 0x0800 +DDF0_BASE = 0x0A00 +DDF1_BASE = 0x0C00 +DEM0_BASE = 0x0E00 +DEM1_BASE = 0x0E40 +VT_BASE = 0x0E80 +TEMP_SENSE_BASE = 0x0EC0 +CLASSG_DNS0_BASE = 0x0F00 +CLASSG_DNS1_BASE = 0x0F80 +CLASSG_DNS2_BASE = 0x1000 +CLASSG_DNS3_BASE = 0x1080 +DCLS0_BASE = 0x1100 +DCLS1_BASE = 0x1200 +SP_IDDF_BASE = 0x1400 +SP_VDDF_BASE = 0x1600 +GDAC0_DNS_BASE = 0x1800 +GDAC0_CTRL_BASE = 0x1980 +GDAC1_DNS_BASE = 0x1A00 +GDAC1_CTRL_BASE = 0x1B80 + +# ===== SCU ===== +#TC55_SCU_PLL_CFG1 = 0x0000 +#TC55_SCU_PLL_CFG2 = 0x0004 +#TC55_SCU_PLL_LCK = 0x0008 +#TC55_SCU_CLK_DIV1 = 0x000c +#TC55_SCU_CLK_DIV2 = 0x0010 +#TC55_SCU_CLK_DIV3 = 0x0014 +#TC55_SCU_CLK_DIV4 = 0x0018 +#TC55_SCU_CLK_DIV5 = 0x001C +#TC55_SCU_CLK_PMOD = 0x0020 +#TC55_SCU_BLK_RST = 0x0024 +#TC55_SCU_I2S_CFG = 0x0028 +#TC55_SCU_IODS = 0x0034 +#TC55_SCU_IOKE = 0x0038 +#TC55_SCU_IOPE = 0x003c +#TC55_SCU_IOIE = 0x0044 +#TC55_SCU_TEST_CTL1 = 0x0050 +#TC55_SCU_TEST_CTL2 = 0x0054 +#TC55_SCU_CLK_DIV6 = 0x0058 +#TC55_SCU_CLK_DIV7 = 0x005C +#TC55_SCU_CLK_DIV8 = 0x0060 +#TC55_SCU_CLK_DIV9 = 0x0064 +#TC55_SCU_BLK_RST1 = 0x0068 +SCU_PLL_CFG1 = 0x0000 +SCU_PLL_CFG2 = 0x0004 +SCU_PLL_LCK = 0x0008 +SCU_CLK_DIV1 = 0x000c +SCU_CLK_DIV2 = 0x0010 +SCU_CLK_DIV3 = 0x0014 +SCU_CLK_DIV4 = 0x0018 +SCU_CLK_DIV5 = 0x001C +SCU_CLK_PMOD = 0x0020 +SCU_BLK_RST = 0x0024 +SCU_I2S_CFG = 0x0028 +SCU_IODS = 0x0034 +SCU_IOKE = 0x0038 +SCU_IOPE = 0x003c +SCU_IOIE = 0x0044 +SCU_TEST_CTL1 = 0x0050 +SCU_TEST_CTL2 = 0x0054 +SCU_CLK_DIV6 = 0x0058 +SCU_CLK_DIV7 = 0x005C +SCU_CLK_DIV8 = 0x0060 +SCU_CLK_DIV9 = 0x0064 +SCU_BLK_RST1 = 0x0068 +# =============== +# ===== AFE +# =============== +AFE_INAMP_CFG = 0x0100 +AFE_ADC_VREF_DLY = 0x0104 +AFE_ADC_CFG = 0x0108 +AFE_OUTAMP_CFG = 0x010C +AFE_DAC_CFG = 0x0110 +AFE_CHARGE_PUMP_0_CFG = 0x0114 +AFE_CHARGE_PUMP_1_CFG = 0x0118 +AFE_CHARGE_PUMP_0_CTL = 0x011C +AFE_CHARGE_PUMP_1_CTL = 0x0120 +AFE_DNS_TO_CP_CTL = 0x0124 +AFE_BGREF_CFG = 0x0128 +AFE_ANALOG_TEST_MUX_CFG = 0x012C +AFE_SPARE_CFG1 = 0x0130 +AFE_SPARE_CFG2 = 0x0134 +AFE_CLASSD_0_CFG1 = 0x013c +AFE_CLASSD_0_CFG2 = 0x0140 +AFE_CLASSD_0_PRTCT_CFG1 = 0x0144 +AFE_CLASSD_0_PRTCT_CFG2 = 0x0148 +AFE_CLASSD_1_CFG1 = 0x014c +AFE_CLASSD_1_CFG2 = 0x0150 +AFE_CLASSD_1_PRTCT_CFG1 = 0x0154 +AFE_CLASSD_1_PRTCT_CFG2 = 0x0158 +AFE_STATUS = 0x015c +# =============== +# ===== DNS0 +# =============== +DNS0_CFG1 = 0x0200 +DNS0_CFG2 = 0x0204 +DNS0_CFG3 = 0x0208 +DNS0_CFG4 = 0x020C +DNS0_CFG5 = 0x0210 +DNS0_CFG6 = 0x0214 +DNS0_STAT = 0x0218 +DNS0_DAT = 0x021C +DNS0_BQ1_B0 = 0x0240 +DNS0_BQ1_B1 = 0x0244 +DNS0_BQ1_B2 = 0x0248 +DNS0_BQ1_A1N = 0x024C +DNS0_BQ1_A2N = 0x0250 +DNS0_BQ2_B0 = 0x0254 +DNS0_BQ2_B1 = 0x0258 +DNS0_BQ2_B2 = 0x025C +DNS0_BQ2_A1N = 0x0260 +DNS0_BQ2_A2N = 0x0264 +DNS0_BQ3_B0 = 0x0268 +DNS0_BQ3_B1 = 0x026C +DNS0_BQ3_B2 = 0x0270 +DNS0_BQ3_A1N = 0x0274 +DNS0_BQ3_A2N = 0x0278 +DNS0_BQ4_B0 = 0x027C +DNS0_BQ4_B1 = 0x0280 +DNS0_BQ4_B2 = 0x0284 +DNS0_BQ4_A1N = 0x0288 +DNS0_BQ4_A2N = 0x028C +DNS0_BQ5_B0 = 0x0290 +DNS0_BQ5_B1 = 0x0294 +DNS0_BQ5_B2 = 0x0298 +DNS0_BQ5_A1N = 0x029C +DNS0_BQ5_A2N = 0x02A0 +DNS0_BQ6_B0 = 0x02A4 +DNS0_BQ6_B1 = 0x02A8 +DNS0_BQ6_B2 = 0x02AC +DNS0_BQ6_A1N = 0x02B0 +DNS0_BQ6_A2N = 0x02B4 +DNS0_BQ7_B0 = 0x02B8 +DNS0_BQ7_B1 = 0x02BC +DNS0_BQ7_B2 = 0x02C0 +DNS0_BQ7_A1N = 0x02C4 +DNS0_BQ7_A2N = 0x02C8 +DNS0_BQ8_B0 = 0x02CC +DNS0_BQ8_B1 = 0x02D0 +DNS0_BQ8_B2 = 0x02D4 +DNS0_BQ8_A1N = 0x02D8 +DNS0_BQ8_A2N = 0x02DC +DNS0_BQ9_B0 = 0x02E0 +DNS0_BQ9_B1 = 0x02E4 +DNS0_BQ9_B2 = 0x02E8 +DNS0_BQ9_A1N = 0x02EC +DNS0_BQ9_A2N = 0x02F0 +DNS0_BQ10_B0 = 0x02F4 +DNS0_BQ10_B1 = 0x02F8 +DNS0_BQ10_B2 = 0x02FC +DNS0_BQ10_A1N = 0x0300 +DNS0_BQ10_A2N = 0x0304 +# =============== +# ===== DNS1 +# =============== +DNS1_CFG1 = 0x0400 +DNS1_CFG2 = 0x0404 +DNS1_CFG3 = 0x0408 +DNS1_CFG4 = 0x040C +DNS1_CFG5 = 0x0410 +DNS1_CFG6 = 0x0414 +DNS1_STAT = 0x0418 +DNS1_DAT = 0x041C +DNS1_BQ1_B0 = 0x0440 +DNS1_BQ1_B1 = 0x0444 +DNS1_BQ1_B2 = 0x0448 +DNS1_BQ1_A1N = 0x044C +DNS1_BQ1_A2N = 0x0450 +DNS1_BQ2_B0 = 0x0454 +DNS1_BQ2_B1 = 0x0458 +DNS1_BQ2_B2 = 0x045C +DNS1_BQ2_A1N = 0x0460 +DNS1_BQ2_A2N = 0x0464 +DNS1_BQ3_B0 = 0x0468 +DNS1_BQ3_B1 = 0x046C +DNS1_BQ3_B2 = 0x0470 +DNS1_BQ3_A1N = 0x0474 +DNS1_BQ3_A2N = 0x0478 +DNS1_BQ4_B0 = 0x047C +DNS1_BQ4_B1 = 0x0480 +DNS1_BQ4_B2 = 0x0484 +DNS1_BQ4_A1N = 0x0488 +DNS1_BQ4_A2N = 0x048C +DNS1_BQ5_B0 = 0x0490 +DNS1_BQ5_B1 = 0x0494 +DNS1_BQ5_B2 = 0x0498 +DNS1_BQ5_A1N = 0x049C +DNS1_BQ5_A2N = 0x04A0 +DNS1_BQ6_B0 = 0x04A4 +DNS1_BQ6_B1 = 0x04A8 +DNS1_BQ6_B2 = 0x04AC +DNS1_BQ6_A1N = 0x04B0 +DNS1_BQ6_A2N = 0x04B4 +DNS1_BQ7_B0 = 0x04B8 +DNS1_BQ7_B1 = 0x04BC +DNS1_BQ7_B2 = 0x04C0 +DNS1_BQ7_A1N = 0x04C4 +DNS1_BQ7_A2N = 0x04C8 +DNS1_BQ8_B0 = 0x04CC +DNS1_BQ8_B1 = 0x04D0 +DNS1_BQ8_B2 = 0x04D4 +DNS1_BQ8_A1N = 0x04D8 +DNS1_BQ8_A2N = 0x04DC +DNS1_BQ9_B0 = 0x04E0 +DNS1_BQ9_B1 = 0x04E4 +DNS1_BQ9_B2 = 0x04E8 +DNS1_BQ9_A1N = 0x04EC +DNS1_BQ9_A2N = 0x04F0 +DNS1_BQ10_B0 = 0x04F4 +DNS1_BQ10_B1 = 0x04F8 +DNS1_BQ10_B2 = 0x04FC +DNS1_BQ10_A1N = 0x0500 +DNS1_BQ10_A2N = 0x0504 +# =============== +# ===== DNS2 +# =============== +DNS2_CFG1 = 0x0600 +DNS2_CFG2 = 0x0604 +DNS2_CFG3 = 0x0608 +DNS2_CFG4 = 0x060C +DNS2_CFG5 = 0x0610 +DNS2_CFG6 = 0x0614 +DNS2_STAT = 0x0618 +DNS2_DAT = 0x061C +DNS2_BQ1_B0 = 0x0640 +DNS2_BQ1_B1 = 0x0644 +DNS2_BQ1_B2 = 0x0648 +DNS2_BQ1_A1N = 0x064C +DNS2_BQ1_A2N = 0x0650 +DNS2_BQ2_B0 = 0x0654 +DNS2_BQ2_B1 = 0x0658 +DNS2_BQ2_B2 = 0x065C +DNS2_BQ2_A1N = 0x0660 +DNS2_BQ2_A2N = 0x0664 +DNS2_BQ3_B0 = 0x0668 +DNS2_BQ3_B1 = 0x066C +DNS2_BQ3_B2 = 0x0670 +DNS2_BQ3_A1N = 0x0674 +DNS2_BQ3_A2N = 0x0678 +DNS2_BQ4_B0 = 0x067C +DNS2_BQ4_B1 = 0x0680 +DNS2_BQ4_B2 = 0x0684 +DNS2_BQ4_A1N = 0x0688 +DNS2_BQ4_A2N = 0x068C +DNS2_BQ5_B0 = 0x0690 +DNS2_BQ5_B1 = 0x0694 +DNS2_BQ5_B2 = 0x0698 +DNS2_BQ5_A1N = 0x069C +DNS2_BQ5_A2N = 0x06A0 +DNS2_BQ6_B0 = 0x06A4 +DNS2_BQ6_B1 = 0x06A8 +DNS2_BQ6_B2 = 0x06AC +DNS2_BQ6_A1N = 0x06B0 +DNS2_BQ6_A2N = 0x06B4 +DNS2_BQ7_B0 = 0x06B8 +DNS2_BQ7_B1 = 0x06BC +DNS2_BQ7_B2 = 0x06C0 +DNS2_BQ7_A1N = 0x06C4 +DNS2_BQ7_A2N = 0x06C8 +DNS2_BQ8_B0 = 0x06CC +DNS2_BQ8_B1 = 0x06D0 +DNS2_BQ8_B2 = 0x06D4 +DNS2_BQ8_A1N = 0x06D8 +DNS2_BQ8_A2N = 0x06DC +DNS2_BQ9_B0 = 0x06E0 +DNS2_BQ9_B1 = 0x06E4 +DNS2_BQ9_B2 = 0x06E8 +DNS2_BQ9_A1N = 0x06EC +DNS2_BQ9_A2N = 0x06F0 +DNS2_BQ10_B0 = 0x06F4 +DNS2_BQ10_B1 = 0x06F8 +DNS2_BQ10_B2 = 0x06FC +DNS2_BQ10_A1N = 0x0700 +DNS2_BQ10_A2N = 0x0704 +# =============== +# ===== DNS3 +# =============== +DNS3_CFG1 = 0x0800 +DNS3_CFG2 = 0x0804 +DNS3_CFG3 = 0x0808 +DNS3_CFG4 = 0x080C +DNS3_CFG5 = 0x0810 +DNS3_CFG6 = 0x0814 +DNS3_STAT = 0x0818 +DNS3_DAT = 0x081C +DNS3_BQ1_B0 = 0x0840 +DNS3_BQ1_B1 = 0x0844 +DNS3_BQ1_B2 = 0x0848 +DNS3_BQ1_A1N = 0x084C +DNS3_BQ1_A2N = 0x0850 +DNS3_BQ2_B0 = 0x0854 +DNS3_BQ2_B1 = 0x0858 +DNS3_BQ2_B2 = 0x085C +DNS3_BQ2_A1N = 0x0860 +DNS3_BQ2_A2N = 0x0864 +DNS3_BQ3_B0 = 0x0868 +DNS3_BQ3_B1 = 0x086C +DNS3_BQ3_B2 = 0x0870 +DNS3_BQ3_A1N = 0x0874 +DNS3_BQ3_A2N = 0x0878 +DNS3_BQ4_B0 = 0x087C +DNS3_BQ4_B1 = 0x0880 +DNS3_BQ4_B2 = 0x0884 +DNS3_BQ4_A1N = 0x0888 +DNS3_BQ4_A2N = 0x088C +DNS3_BQ5_B0 = 0x0890 +DNS3_BQ5_B1 = 0x0894 +DNS3_BQ5_B2 = 0x0898 +DNS3_BQ5_A1N = 0x089C +DNS3_BQ5_A2N = 0x08A0 +DNS3_BQ6_B0 = 0x08A4 +DNS3_BQ6_B1 = 0x08A8 +DNS3_BQ6_B2 = 0x08AC +DNS3_BQ6_A1N = 0x08B0 +DNS3_BQ6_A2N = 0x08B4 +DNS3_BQ7_B0 = 0x08B8 +DNS3_BQ7_B1 = 0x08BC +DNS3_BQ7_B2 = 0x08C0 +DNS3_BQ7_A1N = 0x08C4 +DNS3_BQ7_A2N = 0x08C8 +DNS3_BQ8_B0 = 0x08CC +DNS3_BQ8_B1 = 0x08D0 +DNS3_BQ8_B2 = 0x08D4 +DNS3_BQ8_A1N = 0x08D8 +DNS3_BQ8_A2N = 0x08DC +DNS3_BQ9_B0 = 0x08E0 +DNS3_BQ9_B1 = 0x08E4 +DNS3_BQ9_B2 = 0x08E8 +DNS3_BQ9_A1N = 0x08EC +DNS3_BQ9_A2N = 0x08F0 +DNS3_BQ10_B0 = 0x08F4 +DNS3_BQ10_B1 = 0x08F8 +DNS3_BQ10_B2 = 0x08FC +DNS3_BQ10_A1N = 0x0900 +DNS3_BQ10_A2N = 0x0904 +# =============== +# ===== DDFx +# =============== +DDF_CFG1 = 0x0000 +DDF_CFG2 = 0x0004 +DDF_CFG3 = 0x0008 +DDF_DC_OFFST = 0x000C +DDF_EVENT_CFG = 0x0010 +DDF_STAT = 0x0014 +DDF_TEST_IN_DATA = 0x0018 +DDF_OFIFO_DATA = 0x001C +DDF_BQ1_B0 = 0x0020 +DDF_BQ1_B1 = 0x0024 +DDF_BQ1_B2 = 0x0028 +DDF_BQ1_A1N = 0x002C +DDF_BQ1_A2N = 0x0030 +DDF_BQ2_B0 = 0x0034 +DDF_BQ2_B1 = 0x0038 +DDF_BQ2_B2 = 0x003C +DDF_BQ2_A1N = 0x0040 +DDF_BQ2_A2N = 0x0044 +DDF_BQ3_B0 = 0x0048 +DDF_BQ3_B1 = 0x004C +DDF_BQ3_B2 = 0x0050 +DDF_BQ3_A1N = 0x0054 +DDF_BQ3_A2N = 0x0058 +DDF_BQ4_B0 = 0x005C +DDF_BQ4_B1 = 0x0060 +DDF_BQ4_B2 = 0x0064 +DDF_BQ4_A1N = 0x0068 +DDF_BQ4_A2N = 0x006C +DDF_BQ5_B0 = 0x0070 +DDF_BQ5_B1 = 0x0074 +DDF_BQ5_B2 = 0x0078 +DDF_BQ5_A1N = 0x007C +DDF_BQ5_A2N = 0x0080 +DDF_BQ6_B0 = 0x0084 +DDF_BQ6_B1 = 0x0088 +DDF_BQ6_B2 = 0x008C +DDF_BQ6_A1N = 0x0090 +DDF_BQ6_A2N = 0x0094 +DDF_BQ7_B0 = 0x0098 +DDF_BQ7_B1 = 0x009C +DDF_BQ7_B2 = 0x00A0 +DDF_BQ7_A1N = 0x00A4 +DDF_BQ7_A2N = 0x00A8 +DDF_BQ8_B0 = 0x00AC +DDF_BQ8_B1 = 0x00B0 +DDF_BQ8_B2 = 0x00B4 +DDF_BQ8_A1N = 0x00B8 +DDF_BQ8_A2N = 0x00BC +DDF_BQ9_B0 = 0x00C0 +DDF_BQ9_B1 = 0x00C4 +DDF_BQ9_B2 = 0x00C8 +DDF_BQ9_A1N = 0x00CC +DDF_BQ9_A2N = 0x00D0 +DDF_BQ10_B0 = 0x00D4 +DDF_BQ10_B1 = 0x00D8 +DDF_BQ10_B2 = 0x00DC +DDF_BQ10_A1N = 0x00E0 +DDF_BQ10_A2N = 0x00E4 +# =============== +# ===== DDF0 +# =============== +DDF0_CFG1 = 0x0a00 +DDF0_CFG2 = 0x0a04 +DDF0_CFG3 = 0x0a08 +DDF0_DC_OFFST = 0x0a0C +DDF0_EVENT_CFG = 0x0a10 +DDF0_STAT = 0x0a14 +DDF0_TEST_IN_DATA = 0x0a18 +DDF0_OFIFO_DATA = 0x0a1C +DDF0_BQ1_B0 = 0x0a20 +DDF0_BQ1_B1 = 0x0a24 +DDF0_BQ1_B2 = 0x0a28 +DDF0_BQ1_A1N = 0x0a2C +DDF0_BQ1_A2N = 0x0a30 +DDF0_BQ2_B0 = 0x0a34 +DDF0_BQ2_B1 = 0x0a38 +DDF0_BQ2_B2 = 0x0a3C +DDF0_BQ2_A1N = 0x0a40 +DDF0_BQ2_A2N = 0x0a44 +DDF0_BQ3_B0 = 0x0a48 +DDF0_BQ3_B1 = 0x0a4C +DDF0_BQ3_B2 = 0x0a50 +DDF0_BQ3_A1N = 0x0a54 +DDF0_BQ3_A2N = 0x0a58 +DDF0_BQ4_B0 = 0x0a5C +DDF0_BQ4_B1 = 0x0a60 +DDF0_BQ4_B2 = 0x0a64 +DDF0_BQ4_A1N = 0x0a68 +DDF0_BQ4_A2N = 0x0a6C +DDF0_BQ5_B0 = 0x0a70 +DDF0_BQ5_B1 = 0x0a74 +DDF0_BQ5_B2 = 0x0a78 +DDF0_BQ5_A1N = 0x0a7C +DDF0_BQ5_A2N = 0x0a80 +DDF0_BQ6_B0 = 0x0a84 +DDF0_BQ6_B1 = 0x0a88 +DDF0_BQ6_B2 = 0x0a8C +DDF0_BQ6_A1N = 0x0a90 +DDF0_BQ6_A2N = 0x0a94 +DDF0_BQ7_B0 = 0x0a98 +DDF0_BQ7_B1 = 0x0a9C +DDF0_BQ7_B2 = 0x0aA0 +DDF0_BQ7_A1N = 0x0aA4 +DDF0_BQ7_A2N = 0x0aA8 +DDF0_BQ8_B0 = 0x0aAC +DDF0_BQ8_B1 = 0x0aB0 +DDF0_BQ8_B2 = 0x0aB4 +DDF0_BQ8_A1N = 0x0aB8 +DDF0_BQ8_A2N = 0x0aBC +DDF0_BQ9_B0 = 0x0aC0 +DDF0_BQ9_B1 = 0x0aC4 +DDF0_BQ9_B2 = 0x0aC8 +DDF0_BQ9_A1N = 0x0aCC +DDF0_BQ9_A2N = 0x0aD0 +DDF0_BQ10_B0 = 0x0aD4 +DDF0_BQ10_B1 = 0x0aD8 +DDF0_BQ10_B2 = 0x0aDC +DDF0_BQ10_A1N = 0x0aE0 +DDF0_BQ10_A2N = 0x0aE4 +# =============== +# ===== DDF1 +# =============== +DDF1_CFG1 = 0x0c00 +DDF1_CFG2 = 0x0c04 +DDF1_CFG3 = 0x0c08 +DDF1_DC_OFFST = 0x0c0C +DDF1_EVENT_CFG = 0x0c10 +DDF1_STAT = 0x0c14 +DDF1_TEST_IN_DATA = 0x0c18 +DDF1_OFIFO_DATA = 0x0c1C +DDF1_BQ1_B0 = 0x0c20 +DDF1_BQ1_B1 = 0x0c24 +DDF1_BQ1_B2 = 0x0c28 +DDF1_BQ1_A1N = 0x0c2C +DDF1_BQ1_A2N = 0x0c30 +DDF1_BQ2_B0 = 0x0c34 +DDF1_BQ2_B1 = 0x0c38 +DDF1_BQ2_B2 = 0x0c3C +DDF1_BQ2_A1N = 0x0c40 +DDF1_BQ2_A2N = 0x0c44 +DDF1_BQ3_B0 = 0x0c48 +DDF1_BQ3_B1 = 0x0c4C +DDF1_BQ3_B2 = 0x0c50 +DDF1_BQ3_A1N = 0x0c54 +DDF1_BQ3_A2N = 0x0c58 +DDF1_BQ4_B0 = 0x0c5C +DDF1_BQ4_B1 = 0x0c60 +DDF1_BQ4_B2 = 0x0c64 +DDF1_BQ4_A1N = 0x0c68 +DDF1_BQ4_A2N = 0x0c6C +DDF1_BQ5_B0 = 0x0c70 +DDF1_BQ5_B1 = 0x0c74 +DDF1_BQ5_B2 = 0x0c78 +DDF1_BQ5_A1N = 0x0c7C +DDF1_BQ5_A2N = 0x0c80 +DDF1_BQ6_B0 = 0x0c84 +DDF1_BQ6_B1 = 0x0c88 +DDF1_BQ6_B2 = 0x0c8C +DDF1_BQ6_A1N = 0x0c90 +DDF1_BQ6_A2N = 0x0c94 +DDF1_BQ7_B0 = 0x0c98 +DDF1_BQ7_B1 = 0x0c9C +DDF1_BQ7_B2 = 0x0cA0 +DDF1_BQ7_A1N = 0x0cA4 +DDF1_BQ7_A2N = 0x0cA8 +DDF1_BQ8_B0 = 0x0cAC +DDF1_BQ8_B1 = 0x0cB0 +DDF1_BQ8_B2 = 0x0cB4 +DDF1_BQ8_A1N = 0x0cB8 +DDF1_BQ8_A2N = 0x0cBC +DDF1_BQ9_B0 = 0x0cC0 +DDF1_BQ9_B1 = 0x0cC4 +DDF1_BQ9_B2 = 0x0cC8 +DDF1_BQ9_A1N = 0x0cCC +DDF1_BQ9_A2N = 0x0cD0 +DDF1_BQ10_B0 = 0x0cD4 +DDF1_BQ10_B1 = 0x0cD8 +DDF1_BQ10_B2 = 0x0cDC +DDF1_BQ10_A1N = 0x0cE0 +DDF1_BQ10_A2N = 0x0cE4 +# =============== +# ===== DEM0 +# =============== +DEM0_CTL = 0x0e00 +DEM0_TST = 0x0e04 +DEM0_TEST_INPUT = 0x0e08 +DEM0_TEST_OUTPUT = 0x0e0C +# =============== +# ===== DEM1 +# =============== +DEM1_CTL = 0x0e40 +DEM1_TST = 0x0e44 +DEM1_TEST_INPUT = 0x0e48 +DEM1_TEST_OUTPUT = 0x0e4C +# =============== +# ===== VT_ADC_CTRL VOICE_TRIG SAR ADC +# =============== +VT_CTL_CFG1 = 0x0E80 +VT_CTL_CFG2 = 0x0E84 +VT_CTL_CFG3 = 0x0E88 +VT_CTL_CFG4 = 0x0E8C +VT_CTL_CFG5 = 0x0E90 +VT_CTL_CFG6 = 0x0E94 +VT_CTL_CFG7 = 0x0E98 +VT_CTL_STAT = 0x0E9C +# =============== +# ===== TEMP_SENSE +# =============== +TEMP_SENSE_CFG1 = 0x0EC0 +TEMP_SENSE_STAT = 0x0EC4 +# =============== +# ===== CLASSG_DNS0 +# =============== +CLASSG_DNS0_CLSG_DET = 0x0f00 +CLASSG_DNS0_IIR_CFG = 0x0f04 +CLASSG_DNS0_IIR_STAT = 0x0f08 +CLASSG_DNS0_THRS_DET = 0x0f0C +CLASSG_DNS0_BQ1_B0 = 0x0f10 +CLASSG_DNS0_BQ1_B1 = 0x0f14 +CLASSG_DNS0_BQ1_B2 = 0x0f18 +CLASSG_DNS0_BQ1_A1N = 0x0f1C +CLASSG_DNS0_BQ1_A2N = 0x0f20 +CLASSG_DNS0_BQ2_B0 = 0x0f24 +CLASSG_DNS0_BQ2_B1 = 0x0f28 +CLASSG_DNS0_BQ2_B2 = 0x0f2C +CLASSG_DNS0_BQ2_A1N = 0x0f30 +CLASSG_DNS0_BQ2_A2N = 0x0f34 +CLASSG_DNS0_BQ3_B0 = 0x0f38 +CLASSG_DNS0_BQ3_B1 = 0x0f3C +CLASSG_DNS0_BQ3_B2 = 0x0f40 +CLASSG_DNS0_BQ3_A1N = 0x0f44 +CLASSG_DNS0_BQ3_A2N = 0x0f48 +CLASSG_DNS0_BQ4_B0 = 0x0f4C +CLASSG_DNS0_BQ4_B1 = 0x0f50 +CLASSG_DNS0_BQ4_B2 = 0x0f54 +CLASSG_DNS0_BQ4_A1N = 0x0f58 +CLASSG_DNS0_BQ4_A2N = 0x0f5C +# =============== +# ===== CLASSG_DNS1 +# =============== +CLASSG_DNS1_CLSG_DET = 0x0f80 +CLASSG_DNS1_IIR_CFG = 0x0f84 +CLASSG_DNS1_IIR_STAT = 0x0f88 +CLASSG_DNS1_THRS_DET = 0x0f8C +CLASSG_DNS1_BQ1_B0 = 0x0f90 +CLASSG_DNS1_BQ1_B1 = 0x0f94 +CLASSG_DNS1_BQ1_B2 = 0x0f98 +CLASSG_DNS1_BQ1_A1N = 0x0f9C +CLASSG_DNS1_BQ1_A2N = 0x0fa0 +CLASSG_DNS1_BQ2_B0 = 0x0fa4 +CLASSG_DNS1_BQ2_B1 = 0x0fa8 +CLASSG_DNS1_BQ2_B2 = 0x0faC +CLASSG_DNS1_BQ2_A1N = 0x0fb0 +CLASSG_DNS1_BQ2_A2N = 0x0fb4 +CLASSG_DNS1_BQ3_B0 = 0x0fb8 +CLASSG_DNS1_BQ3_B1 = 0x0fbC +CLASSG_DNS1_BQ3_B2 = 0x0fc0 +CLASSG_DNS1_BQ3_A1N = 0x0fc4 +CLASSG_DNS1_BQ3_A2N = 0x0fc8 +CLASSG_DNS1_BQ4_B0 = 0x0fcC +CLASSG_DNS1_BQ4_B1 = 0x0fd0 +CLASSG_DNS1_BQ4_B2 = 0x0fd4 +CLASSG_DNS1_BQ4_A1N = 0x0fd8 +CLASSG_DNS1_BQ4_A2N = 0x0fdC +# =============== +# ===== CLASSG_DNS2 +# =============== +CLASSG_DNS2_CLSG_DET = 0x1000 +CLASSG_DNS2_IIR_CFG = 0x1004 +CLASSG_DNS2_IIR_STAT = 0x1008 +CLASSG_DNS2_THRS_DET = 0x100C +CLASSG_DNS2_BQ1_B0 = 0x1010 +CLASSG_DNS2_BQ1_B1 = 0x1014 +CLASSG_DNS2_BQ1_B2 = 0x1018 +CLASSG_DNS2_BQ1_A1N = 0x101C +CLASSG_DNS2_BQ1_A2N = 0x1020 +CLASSG_DNS2_BQ2_B0 = 0x1024 +CLASSG_DNS2_BQ2_B1 = 0x1028 +CLASSG_DNS2_BQ2_B2 = 0x102C +CLASSG_DNS2_BQ2_A1N = 0x1030 +CLASSG_DNS2_BQ2_A2N = 0x1034 +CLASSG_DNS2_BQ3_B0 = 0x1038 +CLASSG_DNS2_BQ3_B1 = 0x103C +CLASSG_DNS2_BQ3_B2 = 0x1040 +CLASSG_DNS2_BQ3_A1N = 0x1044 +CLASSG_DNS2_BQ3_A2N = 0x1048 +CLASSG_DNS2_BQ4_B0 = 0x104C +CLASSG_DNS2_BQ4_B1 = 0x1050 +CLASSG_DNS2_BQ4_B2 = 0x1054 +CLASSG_DNS2_BQ4_A1N = 0x1058 +CLASSG_DNS2_BQ4_A2N = 0x105C +# =============== +# ===== CLASSG_DNS3 +# =============== +CLASSG_DNS3_CLSG_DET = 0x1080 +CLASSG_DNS3_IIR_CFG = 0x1084 +CLASSG_DNS3_IIR_STAT = 0x1088 +CLASSG_DNS3_THRS_DET = 0x108C +CLASSG_DNS3_BQ1_B0 = 0x1090 +CLASSG_DNS3_BQ1_B1 = 0x1094 +CLASSG_DNS3_BQ1_B2 = 0x1098 +CLASSG_DNS3_BQ1_A1N = 0x109C +CLASSG_DNS3_BQ1_A2N = 0x10a0 +CLASSG_DNS3_BQ2_B0 = 0x10a4 +CLASSG_DNS3_BQ2_B1 = 0x10a8 +CLASSG_DNS3_BQ2_B2 = 0x10aC +CLASSG_DNS3_BQ2_A1N = 0x10b0 +CLASSG_DNS3_BQ2_A2N = 0x10b4 +CLASSG_DNS3_BQ3_B0 = 0x10b8 +CLASSG_DNS3_BQ3_B1 = 0x10bC +CLASSG_DNS3_BQ3_B2 = 0x10c0 +CLASSG_DNS3_BQ3_A1N = 0x10c4 +CLASSG_DNS3_BQ3_A2N = 0x10c8 +CLASSG_DNS3_BQ4_B0 = 0x10cC +CLASSG_DNS3_BQ4_B1 = 0x10d0 +CLASSG_DNS3_BQ4_B2 = 0x10d4 +CLASSG_DNS3_BQ4_A1N = 0x10d8 +CLASSG_DNS3_BQ4_A2N = 0x10dC +# =============== +# ===== classD modulator - dcls_pwm_tc55b01 - DCLS0 +# =============== +CLSD0_SD_CTRL = 0x1100 +CLSD0_GAIN_CTRL1 = 0x1104 +CLSD0_GAIN_CTRL2 = 0x1108 +CLSD0_DC = 0x110C +CLSD0_IIR_CTRL = 0x1110 +CLSD0_RAMP_CFG = 0x1114 +CLSD0_MOD_INT = 0x1118 +CLSD0_BQ1_B0 = 0x111C +CLSD0_BQ1_B1 = 0x1120 +CLSD0_BQ1_B2 = 0x1124 +CLSD0_BQ1_A0N = 0x1128 +CLSD0_BQ1_A1N = 0x112C +CLSD0_BQ2_B0 = 0x1130 +CLSD0_BQ2_B1 = 0x1134 +CLSD0_BQ2_B2 = 0x1138 +CLSD0_BQ2_A0N = 0x113C +CLSD0_BQ2_A1N = 0x1140 +CLSD0_BQ3_B0 = 0x1144 +CLSD0_BQ3_B1 = 0x1148 +CLSD0_BQ3_B2 = 0x114C +CLSD0_BQ3_A0N = 0x1150 +CLSD0_BQ3_A1N = 0x1154 +CLSD0_BQ4_B0 = 0x1158 +CLSD0_BQ4_B1 = 0x115C +CLSD0_BQ4_B2 = 0x1160 +CLSD0_BQ4_A0N = 0x1164 +CLSD0_BQ4_A1N = 0x1168 +CLSD0_BQ5_B0 = 0x116C +CLSD0_BQ5_B1 = 0x1170 +CLSD0_BQ5_B2 = 0x1174 +CLSD0_BQ5_A0N = 0x1178 +CLSD0_BQ5_A1N = 0x117C +CLSD0_BQ6_B0 = 0x1180 +CLSD0_BQ6_B1 = 0x1184 +CLSD0_BQ6_B2 = 0x1188 +CLSD0_BQ6_A0N = 0x118C +CLSD0_BQ6_A1N = 0x1190 +CLSD0_BQ7_B0 = 0x1194 +CLSD0_BQ7_B1 = 0x1198 +CLSD0_BQ7_B2 = 0x119C +CLSD0_BQ7_A0N = 0x11A0 +CLSD0_BQ7_A1N = 0x11A4 +CLSD0_BQ8_B0 = 0x11A8 +CLSD0_BQ8_B1 = 0x11AC +CLSD0_BQ8_B2 = 0x11B0 +CLSD0_BQ8_A0N = 0x11B4 +CLSD0_BQ8_A1N = 0x11B8 +CLSD0_BQ9_B0 = 0x11BC +CLSD0_BQ9_B1 = 0x11C0 +CLSD0_BQ9_B2 = 0x11C4 +CLSD0_BQ9_A0N = 0x11C8 +CLSD0_BQ9_A1N = 0x11CC +CLSD0_BQ10_B0 = 0x11D0 +CLSD0_BQ10_B1 = 0x11D4 +CLSD0_BQ10_B2 = 0x11D8 +CLSD0_BQ10_A0N = 0x11DC +CLSD0_BQ10_A1N = 0x11E0 +# =============== +# ===== classD modulator - dcls_pwm_tc55b01 - DCLS1 +# =============== +CLSD1_SD_CTRL = 0x1200 +CLSD1_GAIN_CTRL1 = 0x1204 +CLSD1_GAIN_CTRL2 = 0x1208 +CLSD1_DC = 0x120C +CLSD1_IIR_CTRL = 0x1210 +CLSD1_RAMP_CFG = 0x1214 +CLSD1_MOD_INT = 0x1218 +CLSD1_BQ1_B0 = 0x121C +CLSD1_BQ1_B1 = 0x1220 +CLSD1_BQ1_B2 = 0x1224 +CLSD1_BQ1_A0N = 0x1228 +CLSD1_BQ1_A1N = 0x122C +CLSD1_BQ2_B0 = 0x1230 +CLSD1_BQ2_B1 = 0x1234 +CLSD1_BQ2_B2 = 0x1238 +CLSD1_BQ2_A0N = 0x123C +CLSD1_BQ2_A1N = 0x1240 +CLSD1_BQ3_B0 = 0x1244 +CLSD1_BQ3_B1 = 0x1248 +CLSD1_BQ3_B2 = 0x124C +CLSD1_BQ3_A0N = 0x1250 +CLSD1_BQ3_A1N = 0x1254 +CLSD1_BQ4_B0 = 0x1258 +CLSD1_BQ4_B1 = 0x125C +CLSD1_BQ4_B2 = 0x1260 +CLSD1_BQ4_A0N = 0x1264 +CLSD1_BQ4_A1N = 0x1268 +CLSD1_BQ5_B0 = 0x126C +CLSD1_BQ5_B1 = 0x1270 +CLSD1_BQ5_B2 = 0x1274 +CLSD1_BQ5_A0N = 0x1278 +CLSD1_BQ5_A1N = 0x127C +CLSD1_BQ6_B0 = 0x1280 +CLSD1_BQ6_B1 = 0x1284 +CLSD1_BQ6_B2 = 0x1288 +CLSD1_BQ6_A0N = 0x128C +CLSD1_BQ6_A1N = 0x1290 +CLSD1_BQ7_B0 = 0x1294 +CLSD1_BQ7_B1 = 0x1298 +CLSD1_BQ7_B2 = 0x129C +CLSD1_BQ7_A0N = 0x12A0 +CLSD1_BQ7_A1N = 0x12A4 +CLSD1_BQ8_B0 = 0x12A8 +CLSD1_BQ8_B1 = 0x12AC +CLSD1_BQ8_B2 = 0x12B0 +CLSD1_BQ8_A0N = 0x12B4 +CLSD1_BQ8_A1N = 0x12B8 +CLSD1_BQ9_B0 = 0x12BC +CLSD1_BQ9_B1 = 0x12C0 +CLSD1_BQ9_B2 = 0x12C4 +CLSD1_BQ9_A0N = 0x12C8 +CLSD1_BQ9_A1N = 0x12CC +CLSD1_BQ10_B0 = 0x12D0 +CLSD1_BQ10_B1 = 0x12D4 +CLSD1_BQ10_B2 = 0x12D8 +CLSD1_BQ10_A0N = 0x12DC +CLSD1_BQ10_A1N = 0x12E0 +# =============== +# ===== SP_IDDF +# =============== +SP_IDDF_CFG1 = 0x1400 +SP_IDDF_CFG2 = 0x1404 +SP_IDDF_STAT = 0x1408 +SP_IDDF_FIR_DC_OFST = 0x140c +SP_IDDF_FIFO_DATA = 0x1410 +# Bi-Quad Coef +SP_IDDF_BQ1_B0 = 0x1414 +SP_IDDF_BQ1_B1 = 0x1418 +SP_IDDF_BQ1_B2 = 0x141c +SP_IDDF_BQ1_A1N = 0x1420 +SP_IDDF_BQ1_A2N = 0x1424 +SP_IDDF_BQ2_B0 = 0x1428 +SP_IDDF_BQ2_B1 = 0x142c +SP_IDDF_BQ2_B2 = 0x1430 +SP_IDDF_BQ2_A1N = 0x1434 +SP_IDDF_BQ2_A2N = 0x1438 +SP_IDDF_BQ3_B0 = 0x143c +SP_IDDF_BQ3_B1 = 0x1440 +SP_IDDF_BQ3_B2 = 0x1444 +SP_IDDF_BQ3_A1N = 0x1448 +SP_IDDF_BQ3_A2N = 0x144c +SP_IDDF_BQ4_B0 = 0x1450 +SP_IDDF_BQ4_B1 = 0x1454 +SP_IDDF_BQ4_B2 = 0x1458 +SP_IDDF_BQ4_A1N = 0x145c +SP_IDDF_BQ4_A2N = 0x1460 +# FIR coeff +SP_IDDF_FIR_COEF_0 = 0x1480 +SP_IDDF_FIR_COEF_1 = 0x1484 +SP_IDDF_FIR_COEF_2 = 0x1488 +SP_IDDF_FIR_COEF_3 = 0x148c +SP_IDDF_FIR_COEF_4 = 0x1490 +SP_IDDF_FIR_COEF_5 = 0x1494 +SP_IDDF_FIR_COEF_6 = 0x1498 +SP_IDDF_FIR_COEF_7 = 0x149c +SP_IDDF_FIR_COEF_8 = 0x14a0 +SP_IDDF_FIR_COEF_9 = 0x14a4 +SP_IDDF_FIR_COEF_10 = 0x14a8 +SP_IDDF_FIR_COEF_11 = 0x14ac +SP_IDDF_FIR_COEF_12 = 0x14b0 +SP_IDDF_FIR_COEF_13 = 0x14b4 +SP_IDDF_FIR_COEF_14 = 0x14b8 +SP_IDDF_FIR_COEF_15 = 0x14bc +SP_IDDF_FIR_COEF_16 = 0x14c0 +SP_IDDF_FIR_COEF_17 = 0x14c4 +SP_IDDF_FIR_COEF_18 = 0x14c8 +SP_IDDF_FIR_COEF_19 = 0x14cc +SP_IDDF_FIR_COEF_20 = 0x14d0 +SP_IDDF_FIR_COEF_21 = 0x14d4 +SP_IDDF_FIR_COEF_22 = 0x14d8 +SP_IDDF_FIR_COEF_23 = 0x14dc +SP_IDDF_FIR_COEF_24 = 0x14e0 +SP_IDDF_FIR_COEF_25 = 0x14e4 +SP_IDDF_FIR_COEF_26 = 0x14e8 +SP_IDDF_FIR_COEF_27 = 0x14ec +SP_IDDF_FIR_COEF_28 = 0x14f0 +SP_IDDF_FIR_COEF_29 = 0x14f4 +SP_IDDF_FIR_COEF_30 = 0x14f8 +SP_IDDF_FIR_COEF_31 = 0x14fc +SP_IDDF_FIR_COEF_32 = 0x1500 +SP_IDDF_FIR_COEF_33 = 0x1504 +SP_IDDF_FIR_COEF_34 = 0x1508 +SP_IDDF_FIR_COEF_35 = 0x150c +SP_IDDF_FIR_COEF_36 = 0x1510 +SP_IDDF_FIR_COEF_37 = 0x1514 +SP_IDDF_FIR_COEF_38 = 0x1518 +SP_IDDF_FIR_COEF_39 = 0x151c +SP_IDDF_FIR_COEF_40 = 0x1520 +SP_IDDF_FIR_COEF_41 = 0x1524 +SP_IDDF_FIR_COEF_42 = 0x1528 +SP_IDDF_FIR_COEF_43 = 0x152c +SP_IDDF_FIR_COEF_44 = 0x1530 +SP_IDDF_FIR_COEF_45 = 0x1534 +SP_IDDF_FIR_COEF_46 = 0x1538 +SP_IDDF_FIR_COEF_47 = 0x153c +SP_IDDF_FIR_COEF_48 = 0x1540 +SP_IDDF_FIR_COEF_49 = 0x1544 +SP_IDDF_FIR_COEF_50 = 0x1548 +SP_IDDF_FIR_COEF_51 = 0x154c +SP_IDDF_FIR_COEF_52 = 0x1550 +SP_IDDF_FIR_COEF_53 = 0x1554 +SP_IDDF_FIR_COEF_54 = 0x1558 +SP_IDDF_FIR_COEF_55 = 0x155c +SP_IDDF_FIR_COEF_56 = 0x1560 +SP_IDDF_FIR_COEF_57 = 0x1564 +SP_IDDF_FIR_COEF_58 = 0x1568 +SP_IDDF_FIR_COEF_59 = 0x156c +SP_IDDF_FIR_COEF_60 = 0x1570 +SP_IDDF_FIR_COEF_61 = 0x1574 +SP_IDDF_FIR_COEF_62 = 0x1578 +SP_IDDF_FIR_COEF_63 = 0x157c +SP_IDDF_FIR_COEF_64 = 0x1580 +SP_IDDF_FIR_1ST_COEF = SP_IDDF_FIR_COEF_0 +SP_IDDF_FIR_LST_COEF = SP_IDDF_FIR_COEF_64 + +# =============== +# ===== SP_VDDF +# =============== +SP_VDDF_CFG1 = 0x1600 +SP_VDDF_CFG2 = 0x1604 +SP_VDDF_STAT = 0x1608 +SP_VDDF_FIR_DC_OFST = 0x160c +SP_VDDF_FIFO_DATA = 0x1610 +# Bi-Quad Coef +SP_VDDF_BQ1_B0 = 0x1614 +SP_VDDF_BQ1_B1 = 0x1618 +SP_VDDF_BQ1_B2 = 0x161c +SP_VDDF_BQ1_A1N = 0x1620 +SP_VDDF_BQ1_A2N = 0x1624 +SP_VDDF_BQ2_B0 = 0x1628 +SP_VDDF_BQ2_B1 = 0x162c +SP_VDDF_BQ2_B2 = 0x1630 +SP_VDDF_BQ2_A1N = 0x1634 +SP_VDDF_BQ2_A2N = 0x1638 +SP_VDDF_BQ3_B0 = 0x163c +SP_VDDF_BQ3_B1 = 0x1640 +SP_VDDF_BQ3_B2 = 0x1644 +SP_VDDF_BQ3_A1N = 0x1648 +SP_VDDF_BQ3_A2N = 0x164c +SP_VDDF_BQ4_B0 = 0x1650 +SP_VDDF_BQ4_B1 = 0x1654 +SP_VDDF_BQ4_B2 = 0x1658 +SP_VDDF_BQ4_A1N = 0x165c +SP_VDDF_BQ4_A2N = 0x1660 +#FIR coeff +SP_VDDF_FIR_COEF_0 = 0x1680 +SP_VDDF_FIR_COEF_1 = 0x1684 +SP_VDDF_FIR_COEF_2 = 0x1688 +SP_VDDF_FIR_COEF_3 = 0x168c +SP_VDDF_FIR_COEF_4 = 0x1690 +SP_VDDF_FIR_COEF_5 = 0x1694 +SP_VDDF_FIR_COEF_6 = 0x1698 +SP_VDDF_FIR_COEF_7 = 0x169c +SP_VDDF_FIR_COEF_8 = 0x16a0 +SP_VDDF_FIR_COEF_9 = 0x16a4 +SP_VDDF_FIR_COEF_10 = 0x16a8 +SP_VDDF_FIR_COEF_11 = 0x16ac +SP_VDDF_FIR_COEF_12 = 0x16b0 +SP_VDDF_FIR_COEF_13 = 0x16b4 +SP_VDDF_FIR_COEF_14 = 0x16b8 +SP_VDDF_FIR_COEF_15 = 0x16bc +SP_VDDF_FIR_COEF_16 = 0x16c0 +SP_VDDF_FIR_COEF_17 = 0x16c4 +SP_VDDF_FIR_COEF_18 = 0x16c8 +SP_VDDF_FIR_COEF_19 = 0x16cc +SP_VDDF_FIR_COEF_20 = 0x16d0 +SP_VDDF_FIR_COEF_21 = 0x16d4 +SP_VDDF_FIR_COEF_22 = 0x16d8 +SP_VDDF_FIR_COEF_23 = 0x16dc +SP_VDDF_FIR_COEF_24 = 0x16e0 +SP_VDDF_FIR_COEF_25 = 0x16e4 +SP_VDDF_FIR_COEF_26 = 0x16e8 +SP_VDDF_FIR_COEF_27 = 0x16ec +SP_VDDF_FIR_COEF_28 = 0x16f0 +SP_VDDF_FIR_COEF_29 = 0x16f4 +SP_VDDF_FIR_COEF_30 = 0x16f8 +SP_VDDF_FIR_COEF_31 = 0x16fc +SP_VDDF_FIR_COEF_32 = 0x1700 +SP_VDDF_FIR_COEF_33 = 0x1704 +SP_VDDF_FIR_COEF_34 = 0x1708 +SP_VDDF_FIR_COEF_35 = 0x170c +SP_VDDF_FIR_COEF_36 = 0x1710 +SP_VDDF_FIR_COEF_37 = 0x1714 +SP_VDDF_FIR_COEF_38 = 0x1718 +SP_VDDF_FIR_COEF_39 = 0x171c +SP_VDDF_FIR_COEF_40 = 0x1720 +SP_VDDF_FIR_COEF_41 = 0x1724 +SP_VDDF_FIR_COEF_42 = 0x1728 +SP_VDDF_FIR_COEF_43 = 0x172c +SP_VDDF_FIR_COEF_44 = 0x1730 +SP_VDDF_FIR_COEF_45 = 0x1734 +SP_VDDF_FIR_COEF_46 = 0x1738 +SP_VDDF_FIR_COEF_47 = 0x173c +SP_VDDF_FIR_COEF_48 = 0x1740 +SP_VDDF_FIR_COEF_49 = 0x1744 +SP_VDDF_FIR_COEF_50 = 0x1748 +SP_VDDF_FIR_COEF_51 = 0x174c +SP_VDDF_FIR_COEF_52 = 0x1750 +SP_VDDF_FIR_COEF_53 = 0x1754 +SP_VDDF_FIR_COEF_54 = 0x1758 +SP_VDDF_FIR_COEF_55 = 0x175c +SP_VDDF_FIR_COEF_56 = 0x1760 +SP_VDDF_FIR_COEF_57 = 0x1764 +SP_VDDF_FIR_COEF_58 = 0x1768 +SP_VDDF_FIR_COEF_59 = 0x176c +SP_VDDF_FIR_COEF_60 = 0x1770 +SP_VDDF_FIR_COEF_61 = 0x1774 +SP_VDDF_FIR_COEF_62 = 0x1778 +SP_VDDF_FIR_COEF_63 = 0x177c +SP_VDDF_FIR_COEF_64 = 0x1780 +SP_VDDF_FIR_1ST_COEF = SP_VDDF_FIR_COEF_0 +SP_VDDF_FIR_LST_COEF = SP_VDDF_FIR_COEF_64 + +# =============== +# ===== GDAC0_DNS +# =============== +GDAC0_DNS_CFG1 = 0x1800 +GDAC0_DNS_CFG2 = 0x1804 +GDAC0_DNS_CFG5 = 0x1810 +GDAC0_DNS_CFG6 = 0x1814 +GDAC0_DNS_STAT = 0x1818 +GDAC0_DNS_DAT = 0x181C +GDAC0_DNS_BQ1_B0 = 0x1840 +GDAC0_DNS_BQ1_B1 = 0x1844 +GDAC0_DNS_BQ1_B2 = 0x1848 +GDAC0_DNS_BQ1_A1N = 0x184C +GDAC0_DNS_BQ1_A2N = 0x1850 +GDAC0_DNS_BQ2_B0 = 0x1854 +GDAC0_DNS_BQ2_B1 = 0x1858 +GDAC0_DNS_BQ2_B2 = 0x185C +GDAC0_DNS_BQ2_A1N = 0x1860 +GDAC0_DNS_BQ2_A2N = 0x1864 +GDAC0_DNS_BQ3_B0 = 0x1868 +GDAC0_DNS_BQ3_B1 = 0x186C +GDAC0_DNS_BQ3_B2 = 0x1870 +GDAC0_DNS_BQ3_A1N = 0x1874 +GDAC0_DNS_BQ3_A2N = 0x1878 +GDAC0_DNS_BQ4_B0 = 0x187C +GDAC0_DNS_BQ4_B1 = 0x1880 +GDAC0_DNS_BQ4_B2 = 0x1884 +GDAC0_DNS_BQ4_A1N = 0x1888 +GDAC0_DNS_BQ4_A2N = 0x188C +GDAC0_DNS_BQ5_B0 = 0x1890 +GDAC0_DNS_BQ5_B1 = 0x1894 +GDAC0_DNS_BQ5_B2 = 0x1898 +GDAC0_DNS_BQ5_A1N = 0x189C +GDAC0_DNS_BQ5_A2N = 0x18A0 +GDAC0_DNS_BQ6_B0 = 0x18A4 +GDAC0_DNS_BQ6_B1 = 0x18A8 +GDAC0_DNS_BQ6_B2 = 0x18AC +GDAC0_DNS_BQ6_A1N = 0x18B0 +GDAC0_DNS_BQ6_A2N = 0x18B4 +GDAC0_DNS_BQ7_B0 = 0x18B8 +GDAC0_DNS_BQ7_B1 = 0x18BC +GDAC0_DNS_BQ7_B2 = 0x18C0 +GDAC0_DNS_BQ7_A1N = 0x18C4 +GDAC0_DNS_BQ7_A2N = 0x18C8 +GDAC0_DNS_BQ8_B0 = 0x18CC +GDAC0_DNS_BQ8_B1 = 0x18D0 +GDAC0_DNS_BQ8_B2 = 0x18D4 +GDAC0_DNS_BQ8_A1N = 0x18D8 +GDAC0_DNS_BQ8_A2N = 0x18DC +GDAC0_DNS_BQ9_B0 = 0x18E0 +GDAC0_DNS_BQ9_B1 = 0x18E4 +GDAC0_DNS_BQ9_B2 = 0x18E8 +GDAC0_DNS_BQ9_A1N = 0x18EC +GDAC0_DNS_BQ9_A2N = 0x18F0 +GDAC0_DNS_BQ10_B0 = 0x18F4 +GDAC0_DNS_BQ10_B1 = 0x18F8 +GDAC0_DNS_BQ10_B2 = 0x18FC +GDAC0_DNS_BQ10_A1N = 0x1900 +GDAC0_DNS_BQ10_A2N = 0x1904 +GDAC0_DNS_GAIN1 = 0x1908 +GDAC0_DNS_OFFSET1 = 0x190C +GDAC0_DNS_GAIN2 = 0x1910 +GDAC0_DNS_OFFSET2 = 0x1914 +GDAC0_DNS_GAIN3 = 0x1918 +GDAC0_DNS_OFFSET3 = 0x191C +GDAC0_DNS_GAIN_CTRL1 = 0x1920 +GDAC0_DNS_GAIN_CTRL2 = 0x1924 +GDAC0_DNS_GAIN_CTRL_OFFST = 0x1928 +# =============== +# ===== GDAC0_CTRL +# =============== +GDAC0_CTRL_GS_CFG1 = 0x1980 +GDAC0_CTRL_GS_CFG2 = 0x1984 +GDAC0_CTRL_IIR_STAT = 0x1988 +GDAC0_CTRL_THRS_DET_CFG1 = 0x198C +GDAC0_CTRL_BQ1_B0 = 0x1990 +GDAC0_CTRL_BQ1_B1 = 0x1994 +GDAC0_CTRL_BQ1_B2 = 0x1998 +GDAC0_CTRL_BQ1_A1N = 0x199C +GDAC0_CTRL_BQ1_A2N = 0x19A0 +GDAC0_CTRL_BQ2_B0 = 0x19A4 +GDAC0_CTRL_BQ2_B1 = 0x19A8 +GDAC0_CTRL_BQ2_B2 = 0x19AC +GDAC0_CTRL_BQ2_A1N = 0x19B0 +GDAC0_CTRL_BQ2_A2N = 0x19B4 +GDAC0_CTRL_BQ3_B0 = 0x19B8 +GDAC0_CTRL_BQ3_B1 = 0x19BC +GDAC0_CTRL_BQ3_B2 = 0x19C0 +GDAC0_CTRL_BQ3_A1N = 0x19C4 +GDAC0_CTRL_BQ3_A2N = 0x19C8 +GDAC0_CTRL_BQ4_B0 = 0x19CC +GDAC0_CTRL_BQ4_B1 = 0x19D0 +GDAC0_CTRL_BQ4_B2 = 0x19D4 +GDAC0_CTRL_BQ4_A1N = 0x19D8 +GDAC0_CTRL_BQ4_A2N = 0x19DC +GDAC0_CTRL_BQ5_B0 = 0x19E0 +GDAC0_CTRL_BQ5_B1 = 0x19E4 +GDAC0_CTRL_BQ5_B2 = 0x19E8 +GDAC0_CTRL_BQ5_A1N = 0x19Ec +GDAC0_CTRL_BQ5_A2N = 0x19F0 +GDAC0_CTRL_THRS_DET_CFG2 = 0x19F4 +# =============== +# ===== GDAC1_DNS +# =============== +GDAC1_DNS_CFG1 = 0x1A00 +GDAC1_DNS_CFG2 = 0x1A04 +GDAC1_DNS_CFG5 = 0x1A10 +GDAC1_DNS_CFG6 = 0x1A14 +GDAC1_DNS_STAT = 0x1A18 +GDAC1_DNS_DAT = 0x1A1C +GDAC1_DNS_BQ1_B0 = 0x1A40 +GDAC1_DNS_BQ1_B1 = 0x1A44 +GDAC1_DNS_BQ1_B2 = 0x1A48 +GDAC1_DNS_BQ1_A1N = 0x1A4C +GDAC1_DNS_BQ1_A2N = 0x1A50 +GDAC1_DNS_BQ2_B0 = 0x1A54 +GDAC1_DNS_BQ2_B1 = 0x1A58 +GDAC1_DNS_BQ2_B2 = 0x1A5C +GDAC1_DNS_BQ2_A1N = 0x1A60 +GDAC1_DNS_BQ2_A2N = 0x1A64 +GDAC1_DNS_BQ3_B0 = 0x1A68 +GDAC1_DNS_BQ3_B1 = 0x1A6C +GDAC1_DNS_BQ3_B2 = 0x1A70 +GDAC1_DNS_BQ3_A1N = 0x1A74 +GDAC1_DNS_BQ3_A2N = 0x1A78 +GDAC1_DNS_BQ4_B0 = 0x1A7C +GDAC1_DNS_BQ4_B1 = 0x1A80 +GDAC1_DNS_BQ4_B2 = 0x1A84 +GDAC1_DNS_BQ4_A1N = 0x1A88 +GDAC1_DNS_BQ4_A2N = 0x1A8C +GDAC1_DNS_BQ5_B0 = 0x1A90 +GDAC1_DNS_BQ5_B1 = 0x1A94 +GDAC1_DNS_BQ5_B2 = 0x1A98 +GDAC1_DNS_BQ5_A1N = 0x1A9C +GDAC1_DNS_BQ5_A2N = 0x1AA0 +GDAC1_DNS_BQ6_B0 = 0x1AA4 +GDAC1_DNS_BQ6_B1 = 0x1AA8 +GDAC1_DNS_BQ6_B2 = 0x1AAC +GDAC1_DNS_BQ6_A1N = 0x1AB0 +GDAC1_DNS_BQ6_A2N = 0x1AB4 +GDAC1_DNS_BQ7_B0 = 0x1AB8 +GDAC1_DNS_BQ7_B1 = 0x1ABC +GDAC1_DNS_BQ7_B2 = 0x1AC0 +GDAC1_DNS_BQ7_A1N = 0x1AC4 +GDAC1_DNS_BQ7_A2N = 0x1AC8 +GDAC1_DNS_BQ8_B0 = 0x1ACC +GDAC1_DNS_BQ8_B1 = 0x1AD0 +GDAC1_DNS_BQ8_B2 = 0x1AD4 +GDAC1_DNS_BQ8_A1N = 0x1AD8 +GDAC1_DNS_BQ8_A2N = 0x1ADC +GDAC1_DNS_BQ9_B0 = 0x1AE0 +GDAC1_DNS_BQ9_B1 = 0x1AE4 +GDAC1_DNS_BQ9_B2 = 0x1AE8 +GDAC1_DNS_BQ9_A1N = 0x1AEC +GDAC1_DNS_BQ9_A2N = 0x1AF0 +GDAC1_DNS_BQ10_B0 = 0x1AF4 +GDAC1_DNS_BQ10_B1 = 0x1AF8 +GDAC1_DNS_BQ10_B2 = 0x1AFC +GDAC1_DNS_BQ10_A1N = 0x1B00 +GDAC1_DNS_BQ10_A2N = 0x1B04 +GDAC1_DNS_GAIN1 = 0x1B08 +GDAC1_DNS_OFFSET1 = 0x1B0C +GDAC1_DNS_GAIN2 = 0x1B10 +GDAC1_DNS_OFFSET2 = 0x1B14 +GDAC1_DNS_GAIN3 = 0x1B18 +GDAC1_DNS_OFFSET3 = 0x1B1C +GDAC1_DNS_GAIN_CTRL1 = 0x1B20 +GDAC1_DNS_GAIN_CTRL2 = 0x1B24 +GDAC1_DNS_GAIN_CTRL_OFFST = 0x1B28 +# =============== +# ===== GDAC1_CTRL +# =============== +GDAC1_CTRL_GS_CFG1 = 0x1B80 +GDAC1_CTRL_GS_CFG2 = 0x1B84 +GDAC1_CTRL_IIR_STAT = 0x1B88 +GDAC1_CTRL_THRS_DET_CFG1 = 0x1B8C +GDAC1_CTRL_BQ1_B0 = 0x1B90 +GDAC1_CTRL_BQ1_B1 = 0x1B94 +GDAC1_CTRL_BQ1_B2 = 0x1B98 +GDAC1_CTRL_BQ1_A1N = 0x1B9C +GDAC1_CTRL_BQ1_A2N = 0x1BA0 +GDAC1_CTRL_BQ2_B0 = 0x1BA4 +GDAC1_CTRL_BQ2_B1 = 0x1BA8 +GDAC1_CTRL_BQ2_B2 = 0x1BAC +GDAC1_CTRL_BQ2_A1N = 0x1BB0 +GDAC1_CTRL_BQ2_A2N = 0x1BB4 +GDAC1_CTRL_BQ3_B0 = 0x1BB8 +GDAC1_CTRL_BQ3_B1 = 0x1BBC +GDAC1_CTRL_BQ3_B2 = 0x1BC0 +GDAC1_CTRL_BQ3_A1N = 0x1BC4 +GDAC1_CTRL_BQ3_A2N = 0x1BC8 +GDAC1_CTRL_BQ4_B0 = 0x1BCC +GDAC1_CTRL_BQ4_B1 = 0x1BD0 +GDAC1_CTRL_BQ4_B2 = 0x1BD4 +GDAC1_CTRL_BQ4_A1N = 0x1BD8 +GDAC1_CTRL_BQ4_A2N = 0x1BDC +GDAC1_CTRL_BQ5_B0 = 0x1BD0 +GDAC1_CTRL_BQ5_B1 = 0x1BE4 +GDAC1_CTRL_BQ5_B2 = 0x1BE8 +GDAC1_CTRL_BQ5_A1N = 0x1BEc +GDAC1_CTRL_BQ5_A2N = 0x1BE0 +GDAC1_CTRL_THRS_DET_CFG2 = 0x1BF4 diff --git a/Tests/TC55B01/TC_test.py b/Tests/TC55B01/TC_test.py new file mode 100644 index 0000000..ac78eb3 --- /dev/null +++ b/Tests/TC55B01/TC_test.py @@ -0,0 +1,120 @@ +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC_functionality_test" +TEST_NAME = "TC_test" + +## Defines +#boot file path for the initialization of UartDeviceTC(): +TC55B01_BOOT_FILE = r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\classd_boot_166.bin" + +#call the init.py module: +import math +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC55b_regs.py") +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\TC55B01\TC55b_defs.py") +################################################################################################## + + + + + +def Temp_Sense(tc): + # Driver.WriteRegister(atc3, 0x128, 0x13131) + # tc.write_register('128', '13131') + tc.write_register('128', '0f0f1') + # Driver.WriteRegister(atc3, 0x13C, 0x40488841) + tc.write_register('13c', '40488841') + # Driver.WriteRegister(atc3, 0x144, 0x5A10800) + tc.write_register('144', '5a10800') + + # Driver.WriteRegister(atc3, 0x4, 0x1002F00) + tc.write_register('0004', '1002f00') + # Driver.WriteRegister(atc3, 0x0, 0x1018) + tc.write_register('0000', '1018') + # ModifyRegister(SCU_CLK_DIV1, 0x100, 0x100) + tc.tc_setbits('000c', '100') + # ModifyRegister(SCU_CLK_DIV6, 0x12500000, 0xFFF00000) + tc.tc_setbits('0058', '12500000') + tc.tc_clrbits('0058', 'eda00000') + # ModifyRegister(SCU_CLK_PMOD, 0x08000000, 0x08000000) + tc.tc_setbits('20', '08000000') + # Driver.WriteRegister(atc3, TEMP_SENSE_CFG1, 0x00000000) + tc.write_register('0ec0', '0') + # Driver.WriteRegister(atc3, TEMP_SENSE_CFG1, 0x37) + tc.write_register('0ec0', '37') + + time.sleep(4) + + # Driver.WriteRegister(atc3, 0x0EC4, 0xFFF) + tc.write_register('0ec4', 'fff') + # Driver.WriteRegister(atc3, 0x0EC4, 0x0) + tc.write_register('0ec4', '0') + # Driver.WriteRegister(atc3, 0x0EC4, 0x80000000) + tc.write_register('0ec4', '80000000') + time.sleep(4) + RegVal1 = tc.read_register('ec4') + print "regVal1: %s" %RegVal1 + + # Driver.WriteRegister(atc3, 0x144, 0x5A90800) + tc.write_register('144', '5a90800') + time.sleep(4) + # Driver.WriteRegister(atc3, 0x0EC4, 0xFFF) + tc.write_register('0ec4', 'fff') + # Driver.WriteRegister(atc3, 0x0EC4, 0x0) + tc.write_register('0ec4', '0') + # Driver.WriteRegister(atc3, 0x0EC4, 0x80000000) + tc.write_register('0ec4', '80000000') + time.sleep(4) + RegVal2 = tc.read_register('ec4') + + print "regVal2: %s" % RegVal2 + + vbe1 = 1.8 * int(RegVal1, 16) / 32764 + vbe2 = 1.8 * int(RegVal2, 16) / 32764 + print "\n vbe1 " + str(vbe1) + print "\n vbe2 " + str(vbe2) + q = 1.6E-19 + k = 1.38E-23 + N = 4000 + offset = 0.0038 + temp = (vbe2 - vbe1 - offset) * q / (k * math.log(N)) - 273 + print "\n Measured Temperature:" + str(temp) + + + +def vt_adc(tc): + ## config PLL: + tc.write_register('4', '1002f00') + tc.write_register('0', '1017') + tc.tc_modify_register(SCU_CLK_DIV1, '100', '100') + + ## config i2s0 to master, 16bit word: + tc.write_register(SCU_I2S_CFG, '17cf') + + tc.tc_modify_register(SCU_IOIE, '00', '80') + tc.write_register('015c', 'ff00010c') + tc.write_register(AFE_INAMP_CFG,0x00103434) + tc.write_register(VT_CTL_CFG2,0x80000000) + tc.write_register(VT_CTL_CFG3,0xc0000000) + tc.write_register(VT_CTL_CFG4,0xc0000000) + tc.write_register(VT_CTL_CFG5,0x0024007c) + tc.write_register(VT_CTL_CFG1,0x800000bf) + tc.write_register(SCU_CLK_DIV5,0x00470047) + tc.tc_modify_register(SCU_CLK_DIV7,0x0b00300,0xfff00000) + tc.tc_modify_register(SCU_TEST_CTL1,0x02010000,0x02010000) + tc.write_register(AFE_BGREF_CFG,0x000f0f1) + + #enable GDAC_MOD_CLK: + tc.tc_modify_register(SCU_CLK_PMOD,0x10000000,0x10000000) + + tc.write_register(AFE_INAMP_CFG,0x010b434) + tc.write_register(AFE_ADC_CFG,0x8cc9080e) + + #enable I2S0_CLK, VT_CLK, ADC_CLK: + tc.tc_modify_register(SCU_CLK_PMOD,0x10011000,0x10011000) + + tc.write_register(0x12c,0x8) + +tc = Uar\tDeviceTC(name="TC", com="COM4", baudrate=115200, parity='E', stopbits=1, boot_file=TC55B01_BOOT_FILE) +# Temp_Sense(tc) +vt_adc(tc) diff --git a/Tests/TC55B01/classd_boot_166.bin b/Tests/TC55B01/classd_boot_166.bin new file mode 100644 index 0000000..c7858a4 Binary files /dev/null and b/Tests/TC55B01/classd_boot_166.bin differ diff --git a/Tests/TC55B01/classd_boot_166_no_last_4_bytes.bin b/Tests/TC55B01/classd_boot_166_no_last_4_bytes.bin new file mode 100644 index 0000000..7b8b6ee Binary files /dev/null and b/Tests/TC55B01/classd_boot_166_no_last_4_bytes.bin differ diff --git a/Tests/functionality_test/excel_test.py b/Tests/functionality_test/excel_test.py new file mode 100644 index 0000000..6c787f9 --- /dev/null +++ b/Tests/functionality_test/excel_test.py @@ -0,0 +1,70 @@ + +## Test ID: +USER_NAME = 'Bar' +FOLDER_PATH = r"C:\\Users\bar.kristal\Documents\GitHub\Python\Tests\functionality_test" +TEST_NAME = "excel_test" + +#call the init.py module: +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") + +# defines: +headlines = ["Block", "Temp", "Voltage", "Result"] +temps = ["-40C", "25C", "80C"] +voltages = ["0.9", "1.1", "1.2"] +blocks = ["PTCM", "RAM", "DTCM"] + +block_col = 1 +temp_col = 2 +volt_col = 3 +result_col = 4 + +####################################################################################### + +wb1, full_path = create_excel_file(DIR_NAME, LOG_NAME_EXCEL) +ws1 = wb1.create_sheet("BIST results") + +thermotron = Termotron3800(TERMOTRON_TCP_IP) +pwr_sply = QL355TPPwrSply(POWER_SUPLLY_ADDRESS) +dmm = Agillent34401A(DMM_ADDRESS) + + + +#write headlines to excel +for i in range(len(headlines)): + ws1.cell(row=1, column=i+1).value = headlines[i] +wb1.save(full_path) + +current_row = 2 + +#start test and write results to excel +for temp in temps: + # thermotron.set_temp(temp) + time.sleep(3) + + for volt in voltages: + # pwr_sply.set_volt(volt) + + for block in blocks: + + '''run test on the block''' + + #result: + if len(block) % 2 == 0: + result = "Pass" + else: + result = "Fail" + + #write results: + ws1.cell(row=current_row, column=block_col).value = block + ws1.cell(row=current_row, column=temp_col).value = temp + ws1.cell(row=current_row, column=volt_col).value = volt + ws1.cell(row=current_row, column=result_col).value = result + + #upgarde row number + current_row += 1 + + #save excel file + wb1.save(full_path) + + + diff --git a/apx525_functions.py b/apx525_functions.py new file mode 100644 index 0000000..d0d068d --- /dev/null +++ b/apx525_functions.py @@ -0,0 +1,326 @@ +execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\apx525_module.py") + +import matplotlib.pyplot as plt +import threading + + + +################################################################ +### some examples: +## initialize APx500 +# APx = APx500_Application(APxOperatingMode.BenchMode, True) +# APx.Visible = True + + +### running an APx project: +# filename = 'Electrical_Test_Setup_APX_100mV_0dB.approjx' +# directory = "T:\Barkristal\DBMD6\DBMD6_electrical_functionality_tests\Tools" +# fullpath = os.path.join(directory, filename) +# APx.OpenProject(fullpath) + + +### BenchMode, FFT: +'''Connect the Digital Serial output to the Digital Serial input. + The test generates a sine wave from the digital serial, and show it's FFT''' +# APx.BenchMode.Setup.OutputConnector.Type = OutputConnectorType.DigitalSerial +# APx.BenchMode.Setup.InputConnector.Type = InputConnectorType.DigitalSerial +# APx.SignalPathSetup.SerialDigitalTransmitter.EnableOutputs = True +# #APx.BenchMode.Generator.Levels.SetValue(OutputChannelIndex.Ch1, 0.02) +# APx.BenchMode.Generator.Frequency.Value = 2000 +# APx.BenchMode.Generator.On = True +# fft = APx.BenchMode.Measurements.Fft +# fft.Show() +# fft.Start() +# time.sleep(2) +# xValues = fft.FFTSpectrum.GetXValues(InputChannelIndex.Ch1, VerticalAxis.Left) +# yValues = fft.FFTSpectrum.GetYValues(InputChannelIndex.Ch1, VerticalAxis.Left) +# yval = [] +# xval = [] +# for i in yValues: +# yval.append(i) +# for j in xValues: +# xval.append(j) +# plt.semilogx(xval, yval) +# plt.show() + +### BenchMode, THD: +'''Connect the Digital Serial output to the Digital Serial input. + The test generates a sine wave from the digital serial, and measure it's THD''' +# APx.BenchMode.Setup.OutputConnector.Type = OutputConnectorType.DigitalSerial +# APx.BenchMode.Setup.InputConnector.Type = InputConnectorType.DigitalSerial +# APx.SignalPathSetup.SerialDigitalTransmitter.EnableOutputs = True +# APx.BenchMode.Generator.Frequency.Value = 2000 +# APx.BenchMode.Generator.On = True +# AcousticResponse = APx.BenchMode.Measurements.AcousticResponse +# AcousticResponse.Start() #start measurements +# THD = AcousticResponse.ThdLevel +# time.sleep(2) +# xValues = THD.GetXValues(InputChannelIndex.Ch1, VerticalAxis.Left) +# yValues = THD.GetYValues(InputChannelIndex.Ch1, VerticalAxis.Left) +# yval = [] +# xval = [] +# for i in yValues: +# yval.append(i) +# for j in xValues: +# xval.append(j) +# plt.semilogx(xval,yval) +# plt.show() + + + +### BenchMode, THD, load project: +'''Connect the Digital Serial output to the Digital Serial input. + The test generates a sine wave from the digital serial, and measure it's THD''' +# APx.OpenProject(r"C:\Users\bar.kristal\Documents\GitHub\Python\Tests\apx500_functionality_test\THD_test.approjx") +# AcousticResponse = APx.BenchMode.Measurements.AcousticResponse +# AcousticResponse.Start() #start measurements +# THD = AcousticResponse.ThdLevel +# time.sleep(2) +# xValues = THD.GetXValues(InputChannelIndex.Ch1, VerticalAxis.Left) +# yValues = THD.GetYValues(InputChannelIndex.Ch1, VerticalAxis.Left) +# yval = [] +# xval = [] +# for i in yValues: +# yval.append(i) +# for j in xValues: +# xval.append(j) +# plt.semilogx(xval,yval) +# plt.show() + + + +### SequenceMode, SNR, load project: +def SequenceMode_SNR_from_project(project_path): + '''This function loads a specified project, and returns the SNR results. + Results are in the following form: list results, str units. The length of the results list + is dependent on the number of channels that turned on in the project. + The project need to be in Sequence mode''' + APx = APx500_Application() + APx.Visible = True + APx.OpenProject(project_path) + SNR = APx.Sequence.GetMeasurement("Signal Path1", "Signal to Noise Ratio") + SNR.Checked = True + SNR.Run() + show_fft(APx) # save a figure of the FFT + if SNR.HasSequenceResults: + readingValues = SNR.SequenceResults[MeasurementResultType.SignalToNoiseRatioMeter].GetMeterValues() + units = SNR.SequenceResults[MeasurementResultType.SignalToNoiseRatioMeter].MeterUnit + + results = [] + for i in range(len(readingValues)): + results.append(readingValues[i]) + return results, units + + + +def SequenceMode_THDN_Ratio_from_project(project_path): + '''This function loads a specified project, and returns the THD+N results. + Results are in the following form: list results, str units. The length of the results list + is dependent on the number of channels that turned on in the project. + The project need to be in Sequence mode''' + APx = APx500_Application() + APx.Visible = True + APx.OpenProject(project_path) + THD_N = APx.Sequence.GetMeasurement("Signal Path1", "THD+N") + THD_N.Checked = True + THD_N.Run() #run the measurement + show_fft(APx) # save a figure of the FFT + if THD_N.HasSequenceResults: + readingValues = THD_N.SequenceResults[MeasurementResultType.ThdNRatioMeter].GetMeterValues() + units = THD_N.SequenceResults[MeasurementResultType.ThdNRatioMeter].MeterUnit + results = [] + for i in range(len(readingValues)): + results.append(readingValues[i]) + + return results, units + + + +def SequenceMode_THD_from_project(project_path): + '''This function loads a specified project, and returns the THD results. + Results are in the following form: list results, str units. The length of the results list + is dependent on the number of channels that turned on in the project. + The project need to be in Sequence mode''' + APx = APx500_Application() + APx.Visible = True + APx.OpenProject(project_path) + THD = APx.Sequence.GetMeasurement("Signal Path1", "THD+N") + THD.Checked = True + THD.Run() #run the measurement + show_fft(APx) # save a figure of the FFT + if THD.HasSequenceResults: + readingValues = THD.SequenceResults[MeasurementResultType.ThdRatioMeter].GetMeterValues() + units = THD.SequenceResults[MeasurementResultType.ThdRatioMeter].MeterUnit + results = [] + for i in range(len(readingValues)): + results.append(readingValues[i]) + + return results, units + + +def SequenceMode_SINAD_from_project(project_path): + '''This function loads a specified project, and returns the SINAD results. + Results are in the following form: list results, str units. The length of the results list + is dependent on the number of channels that turned on in the project. + The project need to be in Sequence mode''' + APx = APx500_Application() + APx.Visible = True + APx.OpenProject(project_path) + SINAD = APx.Sequence.GetMeasurement("Signal Path1", "SINAD") + SINAD.Checked = True + SINAD.Run() #run the measurement + time.sleep(4) + show_fft(APx) #save a figure of the FFT + if SINAD.HasSequenceResults: + readingValues = SINAD.SequenceResults[MeasurementResultType.SinadRatioMeter].GetMeterValues() + units = SINAD.SequenceResults[MeasurementResultType.SinadRatioMeter].MeterUnit + results = [] + for i in range(len(readingValues)): + results.append(readingValues[i]) + + return results, units + + +def SequenceMode_NoiseLevel_from_project(project_path): + '''This function loads a specified project, and returns the Noise level results. + Results are in the following form: list results, str units. The length of the results list + is dependent on the number of channels that turned on in the project. + The project need to be in Sequence mode''' + APx = APx500_Application() + APx.Visible = True + APx.OpenProject(project_path) + Noise = APx.Sequence.GetMeasurement("Signal Path1", "Noise (RMS)") + Noise.Checked = True + Noise.Run() #run the measurement + show_fft(APx) # save a figure of the FFT + if Noise.HasSequenceResults: + readingValues = Noise.SequenceResults[MeasurementResultType.NoiseRmsLevelMeter].GetMeterValues() + units = Noise.SequenceResults[MeasurementResultType.NoiseRmsLevelMeter].MeterUnit + results = [] + for i in range(len(readingValues)): + results.append(readingValues[i]) + + return results, units + +def SequenceMode_CMRR_from_project(project_path): + '''This function loads a specified project, and returns the CMRR results. + Results are in the following form: list results, str units. The length of the results list + is dependent on the number of channels that turned on in the project. + The project need to be in Sequence mode''' + APx = APx500_Application() + APx.Visible = True + APx.OpenProject(project_path) + CMRR = APx.Sequence.GetMeasurement("Signal Path1", "CMRR") + CMRR.Checked = True + CMRR.Run() #run the measurement + show_fft(APx) # save a figure of the FFT + if CMRR.HasSequenceResults: + readingValues = CMRR.SequenceResults[MeasurementResultType.CmrrMeter].GetMeterValues() + units = CMRR.SequenceResults[MeasurementResultType.CmrrMeter].MeterUnit + results = [] + for i in range(len(readingValues)): + results.append(readingValues[i]) + + return results, units + + + +def SequenceMode_frequency_response_from_project(project_path): + '''This function loads a specified project, and returns the frequency response results. + Results are in the following form: list results, str units. The length of the results list + is dependent on the number of channels that turned on in the project. + The project need to be in Sequence mode''' + APx = APx500_Application() + APx.Visible = True + APx.OpenProject(project_path) + APx.FrequencyResponse.Start() + level = APx.FrequencyResponse.Level + data = level.GetValues(0, APx.FrequencyResponse.Level.AcquisitionCount - 1) + xval = [] + yval = [] + for i in range(len(data)): + # print "point %s: (%s %s,%s %s)"%(i, data[i].X, level.XAxis.Unit, data[i].Y, level.YAxis.Unit) + xval.append(data[i].X) + yval.append(data[i].Y) + + graph_path = DIR_NAME + r"\\" + TEST_NAME + r"_" + "frequency_response" + TEST_DATE + r"_" + TEST_TIME + r".png" + plt.plot(xval, yval) + # plt.show() + plt.savefig(graph_path) + return graph_path + + +def SequenceMode_full_sequence_from_project(project_path, results_path): + '''This function loads a project that runs a sequence of measurments, + sets the path and name for the results_file to be saved, + and runs the sequence.''' + + APx = APx500_Application() + APx.Visible = True + APx.OpenProject(project_path) + SequenceMode_change_log_path(APx, results_path) + APx.Sequence.Run() + + + + +def SequenceMode_change_log_path(APx, log_path): + ''' + :param APx: instance ot the APx_Application() class + log_path: path for the results csv file to be saved + for example: log_path = "c:\DBMA7\SNR", than the results_file will be saved at: "c:\DBMA7\SNR\date&time.csv" + :return: none + ''' + path = log_path+"$(Date)$(Time).csv" + try: + APx.Sequence.DataOutput.MeterReadingsFileName = path + except: + raise "path is not valid" + + +def show_scope(APx): + scope_path = DIR_NAME + r"\\" + TEST_NAME + r"_" + "scope_figure" + TEST_DATE + r"_" + TEST_TIME + r".png" + + scope = APx.ScopeSignalMonitor.Scope + yValues = scope.GetYValues(InputChannelIndex.Ch1, VerticalAxis.Left) + xValues = scope.GetXValues(InputChannelIndex.Ch1, VerticalAxis.Left) + + yval = [] + xval = [] + for i in yValues: + yval.append(i) + for j in xValues: + xval.append(j) + plt.plot(xval, yval) + #plt.show() + plt.savefig(scope_path) + + +def show_fft(APx): + fft_path = DIR_NAME + r"\\" + TEST_NAME + r"_" + "fft_figure" + TEST_DATE + r"_" + TEST_TIME + r".png" + + fft = APx.FftSpectrumSignalMonitor + fft.FFTLength = FFTLength.FFT_48000 + xValues = fft.FFTSpectrum.GetXValues(InputChannelIndex.Ch1, VerticalAxis.Left) + yValues = fft.FFTSpectrum.GetYValues(InputChannelIndex.Ch1, VerticalAxis.Left) + yval = [] + xval = [] + for i in yValues: + yval.append(i) + for j in xValues: + xval.append(j) + plt.semilogx(xval, yval) + #plt.show() + plt.savefig(fft_path) + + +def show_scope_new_thread(APx): + thread = threading.Thread(target=show_scope, args=(APx,)) + thread.start() + + +def show_fft_new_thread(APx): + thread = threading.Thread(target=show_fft, args=(APx,)) + thread.start() + + diff --git a/apx500_module.py b/apx525_module.py similarity index 87% rename from apx500_module.py rename to apx525_module.py index 1d68921..b5b7a7b 100644 --- a/apx500_module.py +++ b/apx525_module.py @@ -1,13 +1,13 @@ import sys sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib') # Set the path to import pure Python Libs -sys.path.append(r"C:\Program Files (x86)\Audio Precision\APx500 4.3\API") # Set the path to import the Apx API -sys.path.append(r"C:\Program Files (x86)\Audio Precision\APx500 4.3\API\Python") # Set the path to import the Apx python sampleProject +sys.path.append(r"C:\Program Files (x86)\Audio Precision\APx500 4.4\API") # Set the path to import the Apx API +sys.path.append(r"C:\Program Files (x86)\Audio Precision\APx500 4.4\API\Python") # Set the path to import the Apx python sampleProject import clr # Import the Common Language Runtime clr.AddReference("System.Drawing") # Needed for Dialog Boxes clr.AddReference("System.Windows.Forms") # Needed for Dialog Boxes -clr.AddReference("C:\Program Files (x86)\Audio Precision\APx500 4.3\API\AudioPrecision.API2.dll") -clr.AddReference("C:\Program Files (x86)\Audio Precision\APx500 4.3\API\AudioPrecision.API.dll") +clr.AddReference("C:\Program Files (x86)\Audio Precision\APx500 4.4\API\AudioPrecision.API2.dll") #the path changed from APx500 4.3 to APx500 4.4 +clr.AddReference("C:\Program Files (x86)\Audio Precision\APx500 4.4\API\AudioPrecision.API.dll") from AudioPrecision.API import * # Import the APx API diff --git a/devices.py b/devices.py index 5547e9c..3a93c39 100644 --- a/devices.py +++ b/devices.py @@ -16,315 +16,781 @@ class UartDevice(): - def __init__(self, name, com, baudrate=115200, bytesize=8, parity='N', stopbits=1,timeout=1): - self.name=name - self.ser=serial.Serial() - self.ser.close() - self.ser.port = com - self.ser.baudrate = baudrate - self.ser.bytesize = bytesize - self.ser.parity = parity - self.ser.stopbits = stopbits - self.ser.timeout = timeout - self.ser.open() - - #Close the serial connection with the device - def close(self): - self.ser.close() - - #Changing the serial connection's parameters: - def change_port(self, com): - self.ser.port = com - write_to_log("{} port changed to {}".format(self.name, com)) - def change_baudrate(self, baudrate): - self.ser.baudrate = baudrate - write_to_log("{} baudrate changed to {}".format(self.name, baudrate)) - def change_bytesize(self, bytesize): - self.ser.bytesize= bytesize - write_to_log("{} bytesize changed to {}".format(self.name, bytesize)) - def change_parity(self, parity): - self.ser.parity= parity - write_to_log("{} parity changed to {}".format(self.name, parity)) - def change_stopbits(self, stopbits): - self.ser.stopbits= stopbits - write_to_log("{} stopbits changed to {}".format(self.name, stopbits)) - def change_timeout(self, timeout): - self.ser.timeout= timeout - write_to_log("{} timeout changed to {}".format(self.name, timeout)) - - - - #Sync with the device, up to n attempts. - def sync (self, n): - data_in = '' - i=0 - if (self.name == 'DBMD2'): - sync_seq = 'AcAcAcAcAcAcAcAcAcAc' - elif (self.name in ['DBMD4','DBMD6','DBMD7']): - sync_seq = chr(0x0)*20 - else: - write_to_log('No sync method for this type of chip. Please make sure that you enterd the right name') - write_to_log("Sync failed") - return - while (i < n): - self.ser.write(sync_seq) - time.sleep(0.3) - data_in = self.ser.read(2) - if data_in == "OK": - time.sleep(0.1) - write_to_log("Synced!") - break - - else: - write_to_log("Sync failed") - write_to_log("Startover Sync function, loop number: "+str(i)) - write_to_log("Please restart %s" % self.name) - i=i+1 - - def read_apb_reg(self, address): - # fill with zero for 8 bit word - address = address.zfill(8) - # convert hexa value to ascii and divide to little indian - addr6 = binascii.unhexlify(address[6]+address[7]) - addr4 = binascii.unhexlify(address[4]+address[5]) - addr2 = binascii.unhexlify(address[2]+address[3]) - addr0 = binascii.unhexlify(address[0]+address[1]) - - self.ser.write(chr(0x5A)+chr(0x07)+addr6+addr4+addr2+addr0) - time.sleep(0.1) - reg = self.ser.read(20) - reg = reg.zfill(8) - # convert ascii to hex value - apb_reg = binascii.hexlify(reg[5])+binascii.hexlify(reg[4])+binascii.hexlify(reg[3])+binascii.hexlify(reg[2]) - return apb_reg - - def write_apb_reg(self, address, value): - # fill with zero for 8 bit word - value = value.zfill(8) - address = address.zfill(8) - # convert hexa value to ascii and divide to little indian - val6 = binascii.unhexlify(value[6]+value[7]) - val4 = binascii.unhexlify(value[4]+value[5]) - val2 = binascii.unhexlify(value[2]+value[3]) - val0 = binascii.unhexlify(value[0]+value[1]) - - # convert hexa value to ascii and divide to little indian - addr6 = binascii.unhexlify(address[6]+address[7]) - addr4 = binascii.unhexlify(address[4]+address[5]) - addr2 = binascii.unhexlify(address[2]+address[3]) - addr0 = binascii.unhexlify(address[0]+address[1]) - - # write apb register- command to D4 - self.ser.write(chr(0x5A)+chr(0x04) - +addr6+addr4 - +addr2+addr0 - +val6+val4 - +val2+val0) - - def clear_bits(self, address, bits_to_clr): - bits_to_clr = int(bits_to_clr, 16) # convert to number - current_value = self.read_apb_reg(address) - current_value = int(current_value, 16) # convert to number - new_value = current_value & (~bits_to_clr) # zero the bits wanted - new_value = hex(new_value)[2:] # convert to hex (string) and cut the 0x-prefix - self.write_apb_reg(address, new_value) - - def set_bits(self, address, bits_to_set): - bits_to_set = int(bits_to_set,16) # convert to number - current_value = self.read_apb_reg(address) - current_value = int(current_value,16) # convert to number - new_value = current_value | bits_to_set # set the bits wanted - new_value = hex(new_value)[2:] # convert to hex (string) and cut the 0x-prefix - self.write_apb_reg(address, new_value) - - def load_boot_file(self, file_name): - self.load_file(file_name, 0) - self.exeBootFile() - - def load_file(self, file_name, unsent_bytes): - infile = open(file_name, "rb") - bytes_to_send = infile.read() - #wakeup() - if (unsent_bytes == 0): - self.ser.write(str(bytes_to_send)) - else: - self.ser.write((str(bytes_to_send))[:-unsent_bytes]) - time.sleep(1) - self.ser.flushInput() - - def exeBootFile(self): - self.ser.write(chr(0x5A)) - self.ser.write(chr(0x0B)) - time.sleep(0.5) - self.ser.write("19r") - time.sleep(0.5) - version = self.ser.read(5) - write_to_log("Chip type check return: " + str(version)[:4]) - time.sleep(0.1) - if (version[:3] == 'dbd'): - write_to_log("Boot Succeeded") - else: - write_to_log("Boot Failed") - - # Write to a FW register. The function doesn't read the register after the writing. - def write_register(self, register_num, value): - self.ser.flushInput() - time.sleep(0.01) - #wakeup - value = (str(value)).zfill(4) - register_num = (str(register_num)).zfill(3) - self.ser.write(register_num + "w" + value) - - #Read a FW register - def read_register(self, register_num): - self.ser.flushInput() - time.sleep(0.01) - #wakeup() - register_num = (str(register_num)).zfill(3) - self.ser.write(register_num + "r") - time.sleep(0.01) - value = self.ser.read(5)[:4] - write_to_log("reg: 0x" + register_num + " ; value: 0x" + str(value)) - return str(value) - - # Write to an APB register - def write_IO_port (self, address, value): - self.ser.flushInput() - address = (str(address)).zfill(8) - address_msb = address [:4] - address_lsb = address [4:8] - value = (str(value)).zfill(8) - value_msb = reg_value [:4] - value_lsb = reg_value [4:8] - #wakeup() - self.ser.write("006w" + address_msb) - time.sleep (0.001) - self.ser.write("005w" + address_lsb) - time.sleep (0.001) - self.ser.write("007w" + value_lsb) - time.sleep (0.001) - self.ser.write("008w" + value_msb) - - # Read an APB register - def read_IO_port (self, address): - self.ser.flushInput() - time.sleep (0.001) - address = (str(address)).zfill(8) - address_msb = address [:4] - address_lsb = address [4:8] - #wakeup() - self.ser.write("006w" + address_msb) - time.sleep (0.001) - self.ser.write("005w" + address_lsb) - time.sleep (0.001) - self.ser.write("007r") - value_lsb = self.ser.read(5)[:4] - self.ser.write("008r") - value_msb = self.ser.read(5)[:4] - return str(value_msb)+str(value_lsb) - - -T32_OK = 0 -T32_DEV = 1 + def __init__(self, name, com, baudrate=115200, bytesize=8, parity='N', stopbits=1,timeout=1): + self.name=name + self.ser=serial.Serial() + self.ser.close() + self.ser.port = com + self.ser.baudrate = baudrate + self.ser.bytesize = bytesize + self.ser.parity = parity + self.ser.stopbits = stopbits + self.ser.timeout = timeout + self.ser.open() + + #Close the serial connection with the device + def close(self): + self.ser.close() + + #Changing the serial connection's parameters: + def change_port(self, com): + self.ser.port = com + write_to_log("{} port changed to {}".format(self.name, com)) + def change_baudrate(self, baudrate): + self.ser.baudrate = baudrate + write_to_log("{} baudrate changed to {}".format(self.name, baudrate)) + def change_bytesize(self, bytesize): + self.ser.bytesize= bytesize + write_to_log("{} bytesize changed to {}".format(self.name, bytesize)) + def change_parity(self, parity): + self.ser.parity= parity + write_to_log("{} parity changed to {}".format(self.name, parity)) + def change_stopbits(self, stopbits): + self.ser.stopbits= stopbits + write_to_log("{} stopbits changed to {}".format(self.name, stopbits)) + def change_timeout(self, timeout): + self.ser.timeout= timeout + write_to_log("{} timeout changed to {}".format(self.name, timeout)) + + + #Write data to the serial port + def write_data(self, data): + self.ser.write(data) + + #Read data from serial port + def read_data(self): + data = "" + c = self.ser.read(1) + while c != "\r" and c != "\n": + print c + data += c + c = self.ser.read(1) + return data + + + + #Sync with the device, up to n attempts. + def sync (self, n): + data_in = '' + i=0 + if (self.name in ['DBMD2','TC', 'A7']): + sync_seq = ('AcAcA'+chr(255))*30 + elif (self.name in ['DBMD4','DBMD6','DBMD7']): + sync_seq = chr(0x0)*20 + else: + write_to_log('No sync method for this type of chip. Please make sure that you enterd the right name') + write_to_log("Sync failed") + return + while (i < n): + self.ser.write(sync_seq) + time.sleep(0.3) + data_in = self.ser.read(2) + if data_in == "OK": + time.sleep(0.1) + write_to_log("Synced!") + break + + else: + write_to_log("Sync failed") + write_to_log("Startover Sync function, loop number: "+str(i)) + write_to_log("Please restart %s" % self.name) + i=i+1 + + + def load_boot_file(self, file_name): + if self.name in ['TC']: + self.load_file(file_name, 4) + self.exeBootFile() + else: + self.load_file(file_name, 0) + self.exeBootFile() + + def load_file(self, file_name, unsent_bytes): + infile = open(file_name, "rb") + bytes_to_send = infile.read() + # wakeup() + if (unsent_bytes == 0): + self.ser.write(str(bytes_to_send)) + else: + self.ser.write((str(bytes_to_send))[:-unsent_bytes]) + time.sleep(1) + self.ser.flushInput() + + def exeBootFile(self): + self.ser.write(chr(0x5A)) + self.ser.write(chr(0x0B)) + time.sleep(0.5) + if (self.name == 'TC'): + self.change_baudrate(1843200) + self.change_parity('N') + time.sleep(0.1) + version = self.read_version() + write_to_log("Version check returned: %s" % version) + time.sleep(0.1) + if (version == '15'): + write_to_log("Boot Succeeded") + else: + write_to_log("Boot Failed") + + elif (self.name == 'A7'): + self.change_baudrate(3000000) + self.change_parity('N') + self.change_stopbits(1) + # version = self.read_version() + # write_to_log("Version check returned: %s" % version) + # time.sleep(0.1) + # if (version == '0'): + # write_to_log("Boot Succeeded") + # else: + # write_to_log("Boot Failed") + else: + self.ser.write("19r") + time.sleep(0.5) + version = self.ser.read(5) + print version + write_to_log("Chip type check return: " + str(version)[:4]) + time.sleep(0.1) + if (version[:3] == 'dbd'): + write_to_log("Boot Succeeded") + else: + write_to_log("Boot Failed") + + + + ########## BEFORE BOOT FILE HAS BEEN LODED: ############ + + #Read from apb registers after boot file loaded: + def read_apb_reg(self, address): + # fill with zero for 8 bit word + address = address.zfill(8) + # convert hexa value to ascii and divide to little indian + addr6 = binascii.unhexlify(address[6]+address[7]) + addr4 = binascii.unhexlify(address[4]+address[5]) + addr2 = binascii.unhexlify(address[2]+address[3]) + addr0 = binascii.unhexlify(address[0]+address[1]) + + self.ser.write(chr(0x5A)+chr(0x07)+addr6+addr4+addr2+addr0) + time.sleep(0.1) + reg = self.ser.read(20) + reg = reg.zfill(8) + # convert ascii to hex value + # apb_reg = binascii.hexlify(reg[5])+binascii.hexlify(reg[4])+binascii.hexlify(reg[3])+binascii.hexlify(reg[2]) + apb_reg = binascii.hexlify(reg[7]) + binascii.hexlify(reg[6]) + binascii.hexlify(reg[5]) + binascii.hexlify( + reg[4]) #change by Bar, 18.4.17 + return apb_reg + + #Write to apb registers after boot file loaded: + def write_apb_reg(self, address, value): + # fill with zero for 8 bit word + value = value.zfill(8) + address = address.zfill(8) + # convert hexa value to ascii and divide to little indian + val6 = binascii.unhexlify(value[6]+value[7]) + val4 = binascii.unhexlify(value[4]+value[5]) + val2 = binascii.unhexlify(value[2]+value[3]) + val0 = binascii.unhexlify(value[0]+value[1]) + + # convert hexa value to ascii and divide to little indian + addr6 = binascii.unhexlify(address[6]+address[7]) + addr4 = binascii.unhexlify(address[4]+address[5]) + addr2 = binascii.unhexlify(address[2]+address[3]) + addr0 = binascii.unhexlify(address[0]+address[1]) + + # write apb register- command to D4 + self.ser.write(chr(0x5A)+chr(0x04) + +addr6+addr4 + +addr2+addr0 + +val6+val4 + +val2+val0) + + #Clear bits from apb register's value. This function can be used after loading boot file. + def apb_clear_bits(self, address, bits_to_clr): + bits_to_clr = int(bits_to_clr, 16) # convert to number + current_value = self.read_apb_reg(address) + current_value = int(current_value, 16) # convert to number + new_value = current_value & (~bits_to_clr) # zero the bits wanted + new_value = hex(new_value)[2:] # convert to hex (string) and cut the 0x-prefix + self.write_apb_reg(address, new_value) + + #Set bits is apb register's value. This function can be used after loading boot file. + def apb_set_bits(self, address, bits_to_set): + bits_to_set = int(bits_to_set,16) # convert to number + current_value = self.read_apb_reg(address) + current_value = int(current_value,16) # convert to number + new_value = current_value | bits_to_set # set the bits wanted + new_value = hex(new_value)[2:] # convert to hex (string) and cut the 0x-prefix + self.write_apb_reg(address, new_value) + + + ######## AFTER LOADING BOOT FILE: ############# + #Write to a FW register. The function doesn't read the register after the writing. + def write_register(self, register_num, value): + self.ser.flushInput() + time.sleep(0.01) + #wakeup + value = (str(value)).zfill(4) + register_num = (str(register_num)).zfill(3) + self.ser.write(register_num + "w" + value) + #Read a FW register + def read_register(self, register_num): + self.ser.flushInput() + time.sleep(0.01) + #wakeup() + register_num = (str(register_num)).zfill(3) + self.ser.write(register_num + "r") + time.sleep(0.01) + value = self.ser.read(5)[:4] + write_to_log("reg: 0x" + register_num + " ; value: 0x" + str(value)) + return str(value) + + # Write to an APB register + def write_IO_port (self, address, value): + self.ser.flushInput() + address = (str(address)).zfill(8) + address_msb = address [:4] + address_lsb = address [4:8] + value = (str(value)).zfill(8) + value_msb = value [:4] + value_lsb = value [4:8] + #wakeup() + self.ser.write("006w" + address_msb) + time.sleep (0.001) + self.ser.write("005w" + address_lsb) + time.sleep (0.001) + self.ser.write("007w" + value_lsb) + time.sleep (0.001) + self.ser.write("008w" + value_msb) + + # Read an APB register + def read_IO_port (self, address): + self.ser.flushInput() + time.sleep (0.001) + address = (str(address)).zfill(8) + address_msb = address [:4] + address_lsb = address [4:8] + #wakeup() + self.ser.write("006w" + address_msb) + time.sleep (0.001) + self.ser.write("005w" + address_lsb) + time.sleep (0.001) + self.ser.write("007r") + self.ser.reset_input_buffer() + time.sleep(0.5) + value_lsb = self.ser.read(5)[:4] + self.ser.write("008r") + value_msb = self.ser.read(5)[:4] + return str(value_msb)+str(value_lsb) + + def IO_port_set_bits(self, address, bits_to_set): + current_val = self.read_IO_port(address) + new_val = hex(int(current_val, 16) | int(bits_to_set, 16)).lstrip('0x') + self.write_IO_port(address, new_val) + + def IO_port_clear_bits(self, address, bits_to_clear): + current_val = self.read_IO_port(address) + new_val = hex(int(current_val, 16) & ~int(bits_to_clear, 16)).lstrip('0x') + self.write_IO_port(address, new_val) + + + +########################################################################################################## + +T32_OK = 0 +T32_DEV = 1 # NOTE: every script that using the LAUTERBACH should close the connection # with the device at the end by calling the function ".close()" class Lauterbach(): - def __init__(self, name): - self.name = name - # Start TRACE32 instance - exception_1_raised=1 - exception_2_raised=1 - num_of_attempts=2 #attempts to connect to LAUTERBACH - count=0 - T32_is_open=0 - while (exception_2_raised and count < num_of_attempts): - exception_2_raised=0 - count += 1 - while (exception_1_raised): - exception_1_raised=0 - try: - for i in psutil.pids(): - if (psutil.Process(i).name()== "t32marm.exe"): - T32_is_open=1 - except: - write_to_log("error raised while initializing LAUTERBACH") - exception_1_raised=1 - if (not T32_is_open): - t32_exe = os.path.join('C:\\','T32','t32marm.exe') - config_file = os.path.join('C:\\' ,'T32', 'config.t32') - start_up = os.path.join('C:\\','T32','demo', 'arm', 'compiler', 'arm', 'cortexm.cmm') - command = [t32_exe, '-c', config_file, '-s', start_up] - process = subprocess.Popen(command) - # Wait until the TRACE32 instance is started - time.sleep(5) - - # Load TRACE32 Remote API - if platform.architecture()[0] == '32bit': # check the system's architecture - self.t32api = ctypes.cdll.LoadLibrary(r'C:\T32\t32api.dll') #32bit - elif platform.architecture()[0] == '64bit': - self.t32api = ctypes.cdll.LoadLibrary(r'C:\T32\t32api64.dll') #64bit - else: - write_to_log(r"Error- can't determine the system's architecture") - # Configure communication channel: - self.t32api.T32_Config(b"NODE=",b"localhost") - self.t32api.T32_Config(b"PORT=",b"20000") - self.t32api.T32_Config(b"PACKLEN=",b"1024") - # Establish communication channel: - rc1 = self.t32api.T32_Init() - rc2 = self.t32api.T32_Attach(T32_DEV) - rc3 = self.t32api.T32_Ping() - if (rc2 != T32_OK or rc3 != T32_OK): - exception_2_raised=1 - self.close() - if count == num_of_attempts: - write_to_log("Error- failed to connect to Lautebach after {} attempts".format(count+1)) - # Start PRACTICE script - run dvf101_app.cmm - self.t32api.T32_Cmd(b"CD.DO {}".format(T32_APP_CMM_PATH)) - time.sleep(2) - - - def close(self): - self.t32api.T32_Exit() - - def write_register(self, address, value, length="LONG"): - command= "DATA.SET 0x{} %LE %{} 0x{}".format(address, length, value) - if (self.t32api.T32_Cmd(command) != T32_OK): - write_to_log("error while writing to 0x{}".format(address)) - - def read_register(self, address, length="LONG"): - self.t32api.T32_Cmd("PRINT") - command = "print data.{}(A:0x{})".format(length ,address) - if (self.t32api.T32_Cmd(command) != T32_OK): - write_to_log("Error while reading from 0x{}".format(address)) - return "" - else: - status = ctypes.c_uint16(-1) - message = ctypes.create_string_buffer(256) - mrc = self.t32api.T32_GetMessage(ctypes.byref(message), ctypes.byref(status)) - return message.value.decode("utf-8") - - #set only the specified bits_to_set with value_to_set - def set_bits(self, address, bits_to_set, value_to_set, length="LONG"): - command = "PER.Set.Field A:{} %{} 0x{} {}".format(address, length ,str(bits_to_set), str(value_to_set)) - if (self.t32api.T32_Cmd(command) != T32_OK): - write_to_log("error while writing to 0x{}".format(address)) - - - #set to 0 only the specified bits - def clear_bits(self, address, bits_to_clear, length="LONG"): - command = "PER.Set.Field A:{} %{} 0x{} {}".format(address, length ,str(bits_to_set), '0') - if (self.t32api.T32_Cmd(command) != T32_OK): - write_to_log("error while writing to 0x{}".format(address)) - - - #Execute a cmm file. the function should get the full path of the .cmm file - def execute_cmm_file(self, cmm_file): - command = "CD.DO {}".format(cmm_file) - if (self.t32api.T32_Cmd(command) != T32_OK): - write_to_log("Error while executing {}".format(cmm_file)) - else: - write_to_log("{} executed successfully".format(cmm_file)) + def __init__(self, name): + self.name = name + # Start TRACE32 instance + exception_1_raised=1 + exception_2_raised=1 + num_of_attempts=2 #attempts to connect to LAUTERBACH + count=0 + T32_is_open=0 + while (exception_2_raised and count < num_of_attempts): + exception_2_raised=0 + count += 1 + while (exception_1_raised): + exception_1_raised=0 + try: + for i in psutil.pids(): + if (psutil.Process(i).name()== "t32marm.exe"): + T32_is_open=1 + except: + write_to_log("error raised while initializing LAUTERBACH") + exception_1_raised=1 + if (not T32_is_open): + t32_exe = os.path.join('C:\\','T32','t32marm.exe') + config_file = os.path.join('C:\\' ,'T32', 'config.t32') + start_up = os.path.join('C:\\','T32','demo', 'arm', 'compiler', 'arm', 'cortexm.cmm') + command = [t32_exe, '-c', config_file, '-s', start_up] + process = subprocess.Popen(command) + # Wait until the TRACE32 instance is started + time.sleep(5) + + # Load TRACE32 Remote API + if platform.architecture()[0] == '32bit': # check the system's architecture + self.t32api = ctypes.cdll.LoadLibrary(r'C:\T32\t32api.dll') #32bit + elif platform.architecture()[0] == '64bit': + self.t32api = ctypes.cdll.LoadLibrary(r'C:\T32\t32api64.dll') #64bit + else: + write_to_log(r"Error- can't determine the system's architecture") + # Configure communication channel: + self.t32api.T32_Config(b"NODE=",b"localhost") + self.t32api.T32_Config(b"PORT=",b"20000") + self.t32api.T32_Config(b"PACKLEN=",b"1024") + # Establish communication channel: + rc1 = self.t32api.T32_Init() + rc2 = self.t32api.T32_Attach(T32_DEV) + rc3 = self.t32api.T32_Ping() + if (rc2 != T32_OK or rc3 != T32_OK): + exception_2_raised=1 + self.close() + if count == num_of_attempts: + write_to_log("Error- failed to connect to Lautebach after {} attempts".format(count+1)) + # Start PRACTICE script - run dvf101_app.cmm + self.t32api.T32_Cmd(b"CD.DO {}".format(T32_APP_CMM_PATH)) + time.sleep(2) + + + def close(self): + self.t32api.T32_Exit() + + def write_register(self, address, value, length="LONG"): + command= "DATA.SET 0x{} %LE %{} 0x{}".format(address, length, value) + if (self.t32api.T32_Cmd(command) != T32_OK): + write_to_log("error while writing to 0x{}".format(address)) + + def read_register(self, address, length="LONG"): + self.t32api.T32_Cmd("PRINT") + command = "print data.{}(A:0x{})".format(length ,address) + if (self.t32api.T32_Cmd(command) != T32_OK): + write_to_log("Error while reading from 0x{}".format(address)) + return "" + else: + status = ctypes.c_uint16(-1) + message = ctypes.create_string_buffer(256) + mrc = self.t32api.T32_GetMessage(ctypes.byref(message), ctypes.byref(status)) + return message.value.decode("utf-8") + + #set only the specified bits_to_set with value_to_set + def set_bits(self, address, bits_to_set, value_to_set, length="LONG"): + command = "PER.Set.Field A:{} %{} 0x{} {}".format(address, length ,str(bits_to_set), str(value_to_set)) + if (self.t32api.T32_Cmd(command) != T32_OK): + write_to_log("error while writing to 0x{}".format(address)) + + + #set to 0 only the specified bits + def clear_bits(self, address, bits_to_clear, length="LONG"): + command = "PER.Set.Field A:{} %{} 0x{} {}".format(address, length ,str(bits_to_set), '0') + if (self.t32api.T32_Cmd(command) != T32_OK): + write_to_log("error while writing to 0x{}".format(address)) + + + #Execute a cmm file. the function should get the full path of the .cmm file + def execute_cmm_file(self, cmm_file): + command = "CD.DO {}".format(cmm_file) + if (self.t32api.T32_Cmd(command) != T32_OK): + write_to_log("Error while executing {}".format(cmm_file)) + else: + write_to_log("{} executed successfully".format(cmm_file)) - \ No newline at end of file + +############################################################################################################### + +#This class is used for communicating with the analog Test Chip of DBM series. +#The communication is set through DBMD2 chip, that is connected to the Test Chip through SPI, and is using the FW_boot_file +#of nir michael, and the ART commands. +class UartDeviceTC(UartDevice): + def __init__(self, name, com, baudrate=115200, bytesize=8, parity='N', stopbits=1,timeout=1, boot_file=r"t:\art\classc\script\classd_boot_166.bin"): + UartDevice.__init__(self, name, com, baudrate, bytesize, parity, stopbits, timeout) + self.name=name + self.sync(10) + self.load_boot_file(boot_file) + time.sleep(1) + + + + #Write to register of the Test Chip: + def write_register(self, address, value): + if type(address) == str: + address = address.lower().lstrip('0x') + if type(address) in [int, long]: + address = hex(address).rstrip('L').lower().lstrip('0x') + + + if type(value) == str: + value = value.lower().lstrip('0x') + if type(value) in [int, long]: + value = hex(value).rstrip('L').lower().lstrip('0x') + + time.sleep(0.05) + self.write_data("\r\ntc_write 0x{} 0x{}\r\n".format(address, value)) + self.ser.reset_input_buffer() + self.ser.reset_output_buffer() + print self.read_register(address) + + #Read a register of the Test Chip: + def read_register(self, address): + if type(address) == str: + address = address.lower().lstrip('0x') + if type(address) in [int, long]: + address = hex(address).rstrip('L').lower().lstrip('0x') + + unknown = 0 + while not unknown: + self.ser.reset_input_buffer() + command = "tc_read 0x{}\r\n".format(address) + self.write_data(command) + time.sleep(0.05) + input = '' + c = self.ser.read(1) + while c != '\n': + c = self.ser.read(1) + c = self.ser.read(1) + while c != '\n': + input += c + c = self.ser.read(1) + input = input.replace(chr(0), '').replace(' ','').rstrip('\r') + if input != 'Unknowncommand': + unknown = 1 + return input + + #Set bits in a register of the Test Chip: + def tc_setbits(self, address, bits_to_set): + if type(address) == str: + address = address.lower().replace('0x', '') + elif type(address) in [int, long]: + address = hex(address).rstrip('L').lower().replace('0x', '') + + if type(bits_to_set) == str: + bits_to_set = bits_to_set.lower().replace('0x', '') + elif type(bits_to_set) in [int, long]: + bits_to_set = hex(bits_to_set).rstrip('L').lower().replace('0x', '') + + self.write_data("\r\ntc_setbits 0x{} 0x{}\r\n".format(address, bits_to_set)) + self.ser.reset_input_buffer() + self.ser.reset_output_buffer() + + #Clear bits in a register of the Test Chip: + def tc_clrbits(self, address, bits_to_clr): + if type(address) == str: + address = address.lower().replace('0x', '') + elif type(address) in [int, long]: + address = hex(address).rstrip('L').lower().replace('0x', '') + + if type(bits_to_clr) == str: + bits_to_clr = bits_to_clr.lower().replace('0x', '') + elif type(bits_to_clr) in [int, long]: + bits_to_clr = hex(bits_to_clr).rstrip('L').lower().replace('0x', '') + + self.write_data("\r\ntc_clrbits 0x{} 0x{}\r\n".format(address, bits_to_clr)) + self.ser.reset_input_buffer() + self.ser.reset_output_buffer() + + + def tc_modify_register(self, address, bits_to_modify, mask): + if type(address) == str: + address = address.lower().replace('0x', '') + elif type(address) in [int, long]: + address = hex(address).rstrip('L').lower().replace('0x', '') + + if type(bits_to_modify) == str: + bits_to_modify = bits_to_modify.lower().replace('0x', '') + elif type(bits_to_modify) in [int, long]: + bits_to_modify = hex(bits_to_modify).rstrip('L').lower().replace('0x', '') + + if type(mask) == str: + mask = mask.lower().replace('0x', '') + elif type(mask) in [int, long]: + mask = hex(mask).rstrip('L').lower().replace('0x', '') + + bits_to_set = hex(int(bits_to_modify, 16) & int(mask, 16))[2:].rstrip('L') + self.tc_setbits(address, bits_to_set) + bits_to_clr = hex((int(bits_to_modify,16) ^ 0xffffffff) & int(mask, 16))[2:].rstrip('L') + self.tc_clrbits(address, bits_to_clr) + print self.read_register(address) + + def read_version(self): + flag = 0 + while not flag: + self.ser.reset_input_buffer() + self.write_data("\r\nversion\r\n") + time.sleep(0.001) + input = '' + c = self.ser.read(1) + while c != '\n': + c = self.ser.read(1) + c = self.ser.read(1) + while c != '\n': + input += c + c = self.ser.read(1) + input = input.replace(chr(0), '').replace(' ','').rstrip('\r') + if input != 'Unknowncommand': + flag = 1 + return input + + + + + +class UartDeviceD7FPGA(UartDevice): + def __init__(self, name, com, baudrate=115200, bytesize=8, parity='N', stopbits=1,timeout=1): + UartDevice.__init__(self, name, com, baudrate, bytesize, parity, stopbits, timeout) + self.name=name + + + #Write to register of the Test Chip: + def write_register(self, address, value): + if type(address) == str: + address = address.lower().lstrip('0x') + if type(address) in [int, long]: + address = hex(address).rstrip('L').lower().lstrip('0x') + + + if type(value) == str: + value = value.lower().lstrip('0x') + if type(value) in [int, long]: + value = hex(value).rstrip('L').lower().lstrip('0x') + + time.sleep(0.05) + self.write_data("\r\naw 0x{} 0x{}\r\n".format(address, value)) + self.ser.reset_input_buffer() + self.ser.reset_output_buffer() + # print self.read_register(address) + + #Read a register of the Test Chip: + # def read_register_old(self, address): + # if type(address) == str: + # address = address.lower().lstrip('0x') + # if type(address) in [int, long]: + # address = hex(address).rstrip('L').lower().lstrip('0x') + # + # unknown = 0 + # while not unknown: + # time.sleep(0.1) + # self.ser.reset_input_buffer() + # command = "ad 0x{}\r\n".format(address) + # self.write_data(command) + # # time.sleep(0.05) + # input = '' + # c = self.ser.read(1) + # while c != '\n': + # c = self.ser.read(1) + # c = self.ser.read(3) + # while c != ' ': + # c = self.ser.read(1) + # + # c = self.ser.read(1) + # while c != '\n': + # input += c + # c = self.ser.read(1) + # + # if input != 'Unknowncommand': + # unknown = 1 + # + # input = input.replace(chr(0), '').split(' ') + # for p in input: + # if p != '': + # input = p + # break + # # input = input.replace(chr(0), '').replace(' ','').rstrip('\r') + # return input + + # Read a register of the Test Chip: + def read_register(self, address): + if type(address) == str: + address = address.lower().lstrip('0x') + if type(address) in [int, long]: + address = hex(address).rstrip('L').lower().lstrip('0x') + + unknown = 0 + while not unknown: + self.ser.reset_input_buffer() + command = "ar 0x{}\r\n".format(address) + self.write_data(command) + # time.sleep(0.05) + input = '' + c = self.ser.read(1) + while c != '\n': + c = self.ser.read(1) + c = self.ser.read(1) + while c != '\n': + input += c + c = self.ser.read(1) + input = input.replace(chr(0), '').replace(' ', '').rstrip('\r').replace('0x', '') + if input != 'Unknowncommand': + unknown = 1 + return input + + #Set bits in a register of the Test Chip: + def setbits(self, address, bits_to_set): + if type(address) == str: + address = address.lower().replace('0x', '') + elif type(address) in [int, long]: + address = hex(address).rstrip('L').lower().replace('0x', '') + + if type(bits_to_set) == str: + bits_to_set = bits_to_set.lower().replace('0x', '') + elif type(bits_to_set) in [int, long]: + bits_to_set = hex(bits_to_set).rstrip('L').lower().replace('0x', '') + + self.write_data("\r\napb_setbits 0x{} 0x{}\r\n".format(address, bits_to_set)) + self.ser.reset_input_buffer() + self.ser.reset_output_buffer() + + #Clear bits in a register of the Test Chip: + def clrbits(self, address, bits_to_clr): + if type(address) == str: + address = address.lower().replace('0x', '') + elif type(address) in [int, long]: + address = hex(address).rstrip('L').lower().replace('0x', '') + + if type(bits_to_clr) == str: + bits_to_clr = bits_to_clr.lower().replace('0x', '') + elif type(bits_to_clr) in [int, long]: + bits_to_clr = hex(bits_to_clr).rstrip('L').lower().replace('0x', '') + + self.write_data("\r\napb_clrbits 0x{} 0x{}\r\n".format(address, bits_to_clr)) + self.ser.reset_input_buffer() + self.ser.reset_output_buffer() + + + def modify_register(self, address, bits_to_modify, mask): + if type(address) == str: + address = address.lower().replace('0x', '') + elif type(address) in [int, long]: + address = hex(address).rstrip('L').lower().replace('0x', '') + + if type(bits_to_modify) == str: + bits_to_modify = bits_to_modify.lower().replace('0x', '') + elif type(bits_to_modify) in [int, long]: + bits_to_modify = hex(bits_to_modify).rstrip('L').lower().replace('0x', '') + + if type(mask) == str: + mask = mask.lower().replace('0x', '') + elif type(mask) in [int, long]: + mask = hex(mask).rstrip('L').lower().replace('0x', '') + + bits_to_set = hex(int(bits_to_modify, 16) & int(mask, 16))[2:].rstrip('L') + self.apb_setbits(address, bits_to_set) + bits_to_clr = hex((int(bits_to_modify,16) ^ 0xffffffff) & int(mask, 16))[2:].rstrip('L') + self.apb_clrbits(address, bits_to_clr) + print self.read_register(address) + + def read_version(self): + flag = 0 + while not flag: + self.ser.reset_input_buffer() + self.write_data("version\r\n") + time.sleep(0.001) + input = '' + c = self.ser.read(1) + while c != '\n': + c = self.ser.read(1) + c = self.ser.read(1) + while c != '\n': + input += c + c = self.ser.read(1) + input = input.replace(chr(0), '').replace(' ','').rstrip('\r') + if input != 'Unknowncommand': + flag = 1 + return input + + +class RaspberryPi(): + def __init__(self, ip_address, user_name, user_password ): + self.ip_address = ip_address + self.user_name = user_name + self.user_password = user_password + # open an ssh connection: + self.ssh = paramiko.SSHClient() + self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + self.ssh.connect(self.ip_address, username=self.user_name, password=self.user_password, allow_agent=False) + # open a channel: + self.channel = self.ssh.invoke_shell() + self.channel.settimeout(3) + # check connection: + time.sleep(0.5) + self.read() + check = self.send("echo check") + if check != "check\r\n": + write_to_log("Error: failed to open an ssh conncetion with the RaspberryPi") + self.close + # go to DBMA7_valab directory + self.send("cd ../DBMA7_valab") + + + def send(self, command): + '''send command to the RaspberryPi's terminal, and returns the answer''' + # while (self.channel.recv_ready()): + # self.channel.recv(8192) + while (not self.channel.send_ready()): + pass + self.channel.sendall(command + '\n') + time.sleep(0.1) + while (not self.channel.recv_ready()): + pass + self.channel.recv(len(command+'\n')+1) #ignore the echo of the command itself + return self.read() + + def read_old(self): + '''reads the answer from the RaspberryPi's terminal''' + if (not self.channel.recv_ready()): + time.sleep(1) + if (not self.channel.recv_ready()): + return + answer = self.channel.recv(8192) + while (self.channel.recv_ready()): + answer += self.channel.recv(8192) + # answer = answer.rsplit("{}@raspberry".format(self.user_name))[0] + return answer + + def read(self): + '''reads the answer from the RaspberryPi's terminal''' + if (not self.channel.recv_ready()): + time.sleep(1) + if (not self.channel.recv_ready()): + return + answer = self.channel.recv(8192) + while (not "{}@raspberry".format(self.user_name) in answer): + answer += self.channel.recv(8192) + answer = answer.rsplit("{}@raspberry".format(self.user_name))[0] + return answer + + def reset_A7(self): + self.send("sudo python host_valab.py atc3 reset") + + def reset_D2(self): + self.send("sudo python host_valab.py d2 reset") + + def init_D2(self): + self.send("sudo python host_valab.py init_d2") + time.sleep(1) + + def read_register_D2(self, address): + answer = RPI.send("sudo python host_valab.py d2 r {}".format(address)) + answer = answer.split("value: ")[1].lstrip("0x").rstrip('\r\n') + return answer + + def write_register_D2(self, address, value): + RPI.send("sudo python host_valab.py d2 w {} {}".format(address, value)) + + def read_register_A7(self, address): + answer = RPI.send("sudo python host_valab.py atc3 r {}".format(address)) + answer = answer.split("value: ")[1].lstrip("0x").rstrip('\r\n') + return answer + + def write_register_A7(self, address, value): + RPI.send("sudo python host_valab.py atc3 w {} {}".format(address, value)) + + + def close(self): + '''close connection with the RaspberryPi''' + self.channel.close() + self.ssh.close() + + diff --git a/init.py b/init.py index 2f0b1aa..2dade73 100644 --- a/init.py +++ b/init.py @@ -28,9 +28,9 @@ import visa # for controlling GPIB devices. (this module takes long time to load, so load it only if necessary) import openpyxl # Excel library. (this module takes long time to load, so load it only if necessary) import decimal -import platform #for the Laurebach initialization -import PyTektronixScope - +import platform # for the Laurebach initialization +# import PyTektronixScope +# import saleae @@ -45,6 +45,7 @@ execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\devices.py") execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\utilities.py") execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\lab_equipment.py") + # execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\apx525_module.py") POWER_SUPLLY_ADDRESS = "GPIB0::29::INSTR" DMM_ADDRESS = "GPIB0::22::INSTR" @@ -52,7 +53,7 @@ WAVE_GENERATOR_ADDRESS = "GPIB0::1::INSTR" ELECTRONIC_LOAD_ADDRESS = "GPIB0::3::INSTR" SCOPE_ADDRESS = "GPIB0::9::INSTR" - + OVEN_ADDRESS = 'COM17' elif USER_NAME == "Sas": execfile(r"C:\GitHub\Python\devices.py") @@ -82,7 +83,18 @@ SCOPE_ADDRESS = "GPIB0::9::INSTR" TERMOTRON_TCP_IP = ("172.19.5.239", 8080) # (ip, port) , (Bisset) - +elif USER_NAME == "Ronny": + execfile(r"C:\Users\ronnyi\Documents\GitHub\Python\devices.py") + execfile(r"C:\Users\ronnyi\Documents\GitHub\Python\utilities.py") + execfile(r"C:\Users\ronnyi\Documents\GitHub\Python\lab_equipment.py") + + # POWER_SUPLLY_ADDRESS = "GPIB1::29::INSTR" + # DMM_ADDRESS = "GPIB0::22::INSTR" + # FREQUENCY_COUNTER_ADDRESS = "GPIB0::27::INSTR" + # WAVE_GENERATOR_ADDRESS = "GPIB0::1::INSTR" + # ELECTRONIC_LOAD_ADDRESS = "GPIB0::3::INSTR" + # SCOPE_ADDRESS = "GPIB0::9::INSTR" + TERMOTRON_TCP_IP = ("172.19.5.240", 8080) # (ip, port) , (Ronny) diff --git a/lab_equipment.py b/lab_equipment.py index e397bb1..27b5f7d 100644 --- a/lab_equipment.py +++ b/lab_equipment.py @@ -9,543 +9,547 @@ #Errors: class Error_connecting_device(): - def __init__(self): - write_to_log("Error: failed connecting to device" %(self.type)) + def __init__(self): + write_to_log("Error: failed connecting to device" %(self.type)) #Lab equipment classes: class Agillent34401A(): - def __init__(self,address): - resource_manager = visa.ResourceManager() - self.dev=resource_manager.open_resource(address) - self.name=self.dev.query('*IDN?')[:-1] - self.dev.timeout = 5000 - - def close(self): - self.dev.close() - #write_to_log ('The connection with: %s is now closed' %(self.name)) - - def send_command(self, command): - #Send a visa command to the device. - #This function and the next one can be used in order to send a command that doesn't covered by this module. - self.dev.write(command) - - def read_response(self, command): - #read from the device. can be used after sending a query command to the device. - return self.dev.read()[-1] - - def meas(self,meas): - if meas == 'DCV': - self.dev.write('MEAS:VOLT:DC?') - result = self.dev.read()[:-1] - write_to_log ("DC Measurement: %s" %(result)) - elif meas == 'ACV': - self.dev.write('MEAS:VOLT:AC?') - result = self.dev.read()[:-1] - write_to_log ("AC Measurement: %s" %(result)) - elif meas == 'frequency': - self.dev.write('MEAS:FREQ?') - result = self.dev.read()[:-1] - write_to_log ("Frequency Measurement: %s" %(result)) - elif meas == 'resistance': - self.dev.write('MEAS:REAS?') - result = self.dev.read()[:-1] - write_to_log ("Resistance Measurement: %s" %(result)) - elif meas == 'DCI': - self.dev.write('MEAS:CURR:DC?') - result = self.dev.read()[:-1] - write_to_log ("DC Current Measurement: %s" %(result)) - elif meas == 'ACI': - self.dev.write('MEAS:CURR:AC?') - result = self.dev.read()[:-1] - write_to_log ("AC Current Measurement: %s" %(result)) - return result + def __init__(self,address): + resource_manager = visa.ResourceManager() + self.dev=resource_manager.open_resource(address) + self.name=self.dev.query('*IDN?')[:-1] + self.dev.timeout = 5000 + + def close(self): + self.dev.close() + #write_to_log ('The connection with: %s is now closed' %(self.name)) + + def send_command(self, command): + #Send a visa command to the device. + #This function and the next one can be used in order to send a command that doesn't covered by this module. + self.dev.write(command) + + def read_response(self, command): + #read from the device. can be used after sending a query command to the device. + return self.dev.read()[-1] + + def meas(self,meas): + if meas == 'DCV': + self.dev.write('MEAS:VOLT:DC?') + result = self.dev.read()[:-1] + write_to_log ("DC Measurement: %s" %(result)) + elif meas == 'ACV': + self.dev.write('MEAS:VOLT:AC?') + result = self.dev.read()[:-1] + write_to_log ("AC Measurement: %s" %(result)) + elif meas == 'frequency': + self.dev.write('MEAS:FREQ?') + result = self.dev.read()[:-1] + write_to_log ("Frequency Measurement: %s" %(result)) + elif meas == 'resistance': + self.dev.write('MEAS:REAS?') + result = self.dev.read()[:-1] + write_to_log ("Resistance Measurement: %s" %(result)) + elif meas == 'DCI': + self.dev.write('MEAS:CURR:DC?') + result = self.dev.read()[:-1] + write_to_log ("DC Current Measurement: %s" %(result)) + elif meas == 'ACI': + self.dev.write('MEAS:CURR:AC?') + result = self.dev.read()[:-1] + write_to_log ("AC Current Measurement: %s" %(result)) + return result class QL355TPPwrSply(): - def __init__(self,address): - resource_manager = visa.ResourceManager() - self.dev=resource_manager.open_resource(address) - self.dev.clear() - self.name=self.dev.query('*IDN?')[:-1] - self.dev.timeout = 5000 - - - def close(self): - self.dev.close() - write_to_log ('The connection with: %s is now closed' %(self.name)) - - def set_timeout(self, time): - time = int(time) - self.dev.timeout = time - - def send_command(self, command): - #Send a visa command to the device. - #This function and the next one can be used in order to send a command that doesn't covered by this module. - self.dev.write(command) - - def read_response(self, command): - #read from the device. can be used after sending a query command to the device. - return self.dev.read()[-1] - - def set_volt(self, channel, volt): - #set the voltage output of the specified channel - channel = str(channel) - self.dev.write("V%s %s" %(channel , volt)) - time.sleep(0.5) - res = self.dev.query("V%s?" %(channel))[:-1] - return res - - def set_current_lim(self, channel, current): - #set the current limit of the specified channel - channel = str(channel) - self.dev.write("I%s %s" %(channel ,current)) - time.sleep(0.1) - res = self.dev.query("I%s?" %(channel))[:-1] - return res - - def channel_on(self, channel): - #set ON the specified channel - channel = str(channel) - self.dev.write('OP%s 1' %(channel)) - write_to_log('Channel %s is on' %(channel)) - - def channel_off(self, channel): - #set OFF the specified channel - channel = str(channel) - self.dev.write('OP%s 0' %(channel)) - write_to_log('Channel %s is off' %(channel)) - - def increment_voltage(self, channel, step_size): - #increment the channel's output voltage in a step_size voltage - channel = str(channel) - self.dev.write('DELTAV%s %s' %(channel ,step_size)) - self.dev.write('INCV%s' %(channel)) - #write_to_log("Channel %s was incremented by %sV" %(channel ,step_size)) - res = self.dev.write('V%s?' %(channel)) - #write_to_log("Channel %s volatge is now %sV" %(channel ,self.dev.read()[3:])) - return res - - def all_off(self): - #set ALL channels OFF - self.dev.write('OPALL 0') - #write_to_log("All channels set OFF") - - def all_on(self): - #set ALL channels ON - self.dev.write('OPALL 1') - #write_to_log("All channels set ON") - - def read_current(self, channel): - #reads the current flows right now through the channel - self.dev.write('I%sO?' %(str(channel))) - cur = self.dev.read()[:-1] - #write_to_log("The current at channel %s is: %s" %(channel, cur)) - return cur - - def sense(self, channel, mode): - #mode=0: local, mode=1: remote - self.dev.write('SENSE%s %s' %(channel, mode)) - mod="local" if mode == '0' else "remote" - #write_to_log("Activated %s sense on channel %s" %(mod, str(channel))) - - + def __init__(self,address): + resource_manager = visa.ResourceManager() + self.dev=resource_manager.open_resource(address) + self.dev.clear() + self.name=self.dev.query('*IDN?')[:-1] + self.dev.timeout = 5000 + + + def close(self): + self.dev.close() + write_to_log ('The connection with: %s is now closed' %(self.name)) + + def set_timeout(self, time): + time = int(time) + self.dev.timeout = time + + def send_command(self, command): + #Send a visa command to the device. + #This function and the next one can be used in order to send a command that doesn't covered by this module. + self.dev.write(command) + + def read_response(self, command): + #read from the device. can be used after sending a query command to the device. + return self.dev.read()[-1] + + def set_volt(self, channel, volt): + #set the voltage output of the specified channel + channel = str(channel) + self.dev.write("V%s %s" %(channel , volt)) + time.sleep(0.5) + res = self.dev.query("V%s?" %(channel))[:-1] + return res + + def set_current_lim(self, channel, current): + #set the current limit of the specified channel + channel = str(channel) + self.dev.write("I%s %s" %(channel ,current)) + time.sleep(0.1) + res = self.dev.query("I%s?" %(channel))[:-1] + return res + + def channel_on(self, channel): + #set ON the specified channel + channel = str(channel) + self.dev.write('OP%s 1' %(channel)) + write_to_log('Channel %s is on' %(channel)) + + def channel_off(self, channel): + #set OFF the specified channel + channel = str(channel) + self.dev.write('OP%s 0' %(channel)) + write_to_log('Channel %s is off' %(channel)) + + def increment_voltage(self, channel, step_size): + #increment the channel's output voltage in a step_size voltage + channel = str(channel) + self.dev.write('DELTAV%s %s' %(channel ,step_size)) + self.dev.write('INCV%s' %(channel)) + #write_to_log("Channel %s was incremented by %sV" %(channel ,step_size)) + res = self.dev.write('V%s?' %(channel)) + #write_to_log("Channel %s volatge is now %sV" %(channel ,self.dev.read()[3:])) + return res + + def all_off(self): + #set ALL channels OFF + self.dev.write('OPALL 0') + #write_to_log("All channels set OFF") + + def all_on(self): + #set ALL channels ON + self.dev.write('OPALL 1') + #write_to_log("All channels set ON") + + def read_current(self, channel): + #reads the current flows right now through the channel + self.dev.write('I%sO?' %(str(channel))) + cur = self.dev.read()[:-1] + #write_to_log("The current at channel %s is: %s" %(channel, cur)) + return cur + + def sense(self, channel, mode): + #mode=0: local, mode=1: remote + self.dev.write('SENSE%s %s' %(channel, mode)) + mod="local" if mode == '0' else "remote" + #write_to_log("Activated %s sense on channel %s" %(mod, str(channel))) + + class HP53131aFreqCounter(): - def __init__(self,address): - resource_manager = visa.ResourceManager() - self.dev=resource_manager.open_resource(address) - self.name=self.dev.query('*IDN?')[:-1] - self.dev.timeout = 5000 - - def close(self): - self.dev.close() - write_to_log ('The connection with: %s is now closed' %(self.name)) - - def send_command(self, command): - #Send a visa command to the device. - #This function and the next one can be used in order to send a command that doesn't covered by this module. - self.dev.write(command) - - def read_response(self, command): - #read from the device. can be used after sending a query command to the device. - return self.dev.read()[-1] - - #Take one of the following measurement options. - #Notice that the 'channel' argument is an option, only for 'frequency' mesurement, when the default is "1" - def meas(self, meas, channel="1"): - channel = str(channel) - if ((meas != "frequency" and meas != "volt_max_peak" and meas != "volt_min_peak") and (channel != "1")): - write_to_log("Error: %s measurement can be taken only from channel 1" %(meas)) - return "" - else: - if (meas == "frequency"): - self.dev.write('MEAS%s:FREQ?' %(channel)) - result = self.dev.read()[:-1] - write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) - elif (meas == "rise_time"): - self.dev.write('MEAS:RTIME?') - result = self.dev.read()[:-1] - write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) - elif (meas == "fall_time"): - self.dev.write('MEAS:FTIME?') - result = self.dev.read()[:-1] - write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) - elif (meas == "period"): - self.dev.write('MEAS:PER?') - result = self.dev.read()[:-1] - write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) - elif (meas == "pos_width"): - self.dev.write('MEAS:PWID?') - result = self.dev.read()[:-1] - write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) - elif (meas == "neg_width"): - self.dev.write('MEAS:NWID?') - result = self.dev.read()[:-1] - write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) - elif (meas == "duty_cycle"): - self.dev.write('MEAS:DCYC?') - result = self.dev.read()[:-1] - write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) - elif (meas == "volt_max_peak"): - self.dev.write('MEAS%s:MAX?' %(channel)) - result = self.dev.read()[:-1] - write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) - elif (meas == "volt_min_peak"): - self.dev.write('MEAS%s:MIN?' %(channel)) - result = self.dev.read()[:-1] - write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) - elif (meas == "ratio"): - self.dev.write('MEAS:FREQ:RAT?') - result = self.dev.read()[:-1] - write_to_log ("Ratio %s to %s: %s" %("1", "2", result)) - elif (meas == "phase"): - self.dev.write('MEAS:PHAS?') - result = self.dev.read()[:-1] - write_to_log ("Phase %s to %s: %s" %("1", "2", result)) - return result - - + def __init__(self,address): + resource_manager = visa.ResourceManager() + self.dev=resource_manager.open_resource(address) + self.name=self.dev.query('*IDN?')[:-1] + self.dev.timeout = 5000 + + def close(self): + self.dev.close() + write_to_log ('The connection with: %s is now closed' %(self.name)) + + def send_command(self, command): + #Send a visa command to the device. + #This function and the next one can be used in order to send a command that doesn't covered by this module. + self.dev.write(command) + + def read_response(self, command): + #read from the device. can be used after sending a query command to the device. + return self.dev.read()[-1] + + #Take one of the following measurement options. + #Notice that the 'channel' argument is an option, only for 'frequency' mesurement, when the default is "1" + def meas(self, meas, channel="1"): + channel = str(channel) + if ((meas != "frequency" and meas != "volt_max_peak" and meas != "volt_min_peak") and (channel != "1")): + write_to_log("Error: %s measurement can be taken only from channel 1" %(meas)) + return "" + else: + if (meas == "frequency"): + self.dev.write('MEAS%s:FREQ?' %(channel)) + result = self.dev.read()[:-1] + write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) + elif (meas == "rise_time"): + self.dev.write('MEAS:RTIME?') + result = self.dev.read()[:-1] + write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) + elif (meas == "fall_time"): + self.dev.write('MEAS:FTIME?') + result = self.dev.read()[:-1] + write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) + elif (meas == "period"): + self.dev.write('MEAS:PER?') + result = self.dev.read()[:-1] + write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) + elif (meas == "pos_width"): + self.dev.write('MEAS:PWID?') + result = self.dev.read()[:-1] + write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) + elif (meas == "neg_width"): + self.dev.write('MEAS:NWID?') + result = self.dev.read()[:-1] + write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) + elif (meas == "duty_cycle"): + self.dev.write('MEAS:DCYC?') + result = self.dev.read()[:-1] + write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) + elif (meas == "volt_max_peak"): + self.dev.write('MEAS%s:MAX?' %(channel)) + result = self.dev.read()[:-1] + write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) + elif (meas == "volt_min_peak"): + self.dev.write('MEAS%s:MIN?' %(channel)) + result = self.dev.read()[:-1] + write_to_log ("%s measurement on channel %s: %s" %(meas, channel, result)) + elif (meas == "ratio"): + self.dev.write('MEAS:FREQ:RAT?') + result = self.dev.read()[:-1] + write_to_log ("Ratio %s to %s: %s" %("1", "2", result)) + elif (meas == "phase"): + self.dev.write('MEAS:PHAS?') + result = self.dev.read()[:-1] + write_to_log ("Phase %s to %s: %s" %("1", "2", result)) + return result + + class HP33120aWaveGen(): - '''Compatible also for Agilent33250A device''' - def __init__(self, address): - resource_manager = visa.ResourceManager() - self.dev=resource_manager.open_resource(address) - self.name=self.dev.query('*IDN?')[:-1] - self.dev.timeout = 5000 - - def close(self): - self.dev.close() - write_to_log ('The connection with: %s is now closed' %(self.name)) - - def send_command(self, command): - #Send a visa command to the device. - #This function and the next one can be used in order to send a command that doesn't covered by this module. - self.dev.write(command) - - def read_response(self, command): - #read from the device. can be used after sending a query command to the device. - return self.dev.read()[-1] - - #Generate a waveform in single command. - #Example: self.generate("SIN", 3000, 1.5, -1) generates a sine wave, 3KHz, 1.5Vpp, -1V offset. - def generate(self, wave, frequency, amplitude, offset): - self.dev.write("APPL:%s %s, %s, %s" %(wave, frequency, amplitude, offset)) - - #Set specifiied shape : SINusoid|SQUare|TRIangle|RAMP|NOISe|DC|USER - def set_shape(self, shape): - self.dev.write("FUNC:SHAP %s" %(shape)) - - #Set frequency - def set_frequency(self, frequency): - self.dev.write("FREQ: %s" %(frequency)) - - def set_amplitude(self, amplitude): - self.dev.write("VOLT: %s" %(amplitude)) - - #Set the units of the amplitude: VPP|VRMS|DBM|DEFault - #Do not affect the offset units, which stays V. - def set_amplitude_units(self, units): - self.dev.write("VOLT:UNIT %s" %(amplitude)) - - def set_offset(self, offset): - self.dev.write("VOLT:OFFS %s" %(offset)) - - def get_shape(self): - result = self.dev.query("FUNC:SHAP?")[:-1] - write_to_log("Signal's shape is: %s" %(result)) - return result - - def get_frequency(self): - result = self.dev.query("FREQ?")[:-1] - write_to_log("Frequency is: %s" %(result)) - return result - - def get_amplitude(self): - result = self.dev.query("VOLT?")[:-1] - write_to_log("Amplitude is: %s" %(result)) - return result - - def get_amplitude_unit(self): - result = self.dev.query("VOLT:UNIT?")[:-1] - write_to_log("Amplitude units are: %s" %(result)) - return result - - - def get_offset(self): - result = self.dev.query("VOLT:OFFS?")[:-1] - write_to_log("Offset is: %s" %(result)) - return result - - #Turn on the output channel. Doesn't necessary when using the generate() command, - #because output channel is being turn on automatically. - def output_on(self): - self.dev.write("OUTPUT ON") - - def output_off(self): - self.dev.write("OUTPUT OFF") + '''Compatible also for Agilent33250A device''' + def __init__(self, address): + resource_manager = visa.ResourceManager() + self.dev=resource_manager.open_resource(address) + self.name=self.dev.query('*IDN?')[:-1] + self.dev.timeout = 5000 + + def close(self): + self.dev.close() + write_to_log ('The connection with: %s is now closed' %(self.name)) + + def send_command(self, command): + #Send a visa command to the device. + #This function and the next one can be used in order to send a command that doesn't covered by this module. + self.dev.write(command) + + def read_response(self, command): + #read from the device. can be used after sending a query command to the device. + return self.dev.read()[-1] + + #Generate a waveform in single command. + #Example: self.generate("SIN", 3000, 1.5, -1) generates a sine wave, 3KHz, 1.5Vpp, -1V offset. + def generate(self, wave, frequency, amplitude, offset): + self.dev.write("APPL:%s %s, %s, %s" %(wave, frequency, amplitude, offset)) + + #Set specifiied shape : SINusoid|SQUare|TRIangle|RAMP|NOISe|DC|USER + def set_shape(self, shape): + self.dev.write("FUNC:SHAP %s" %(shape)) + + #Set frequency + def set_frequency(self, frequency): + self.dev.write("FREQ: %s" %(frequency)) + + def set_amplitude(self, amplitude): + self.dev.write("VOLT: %s" %(amplitude)) + + #Set the units of the amplitude: VPP|VRMS|DBM|DEFault + #Do not affect the offset units, which stays V. + def set_amplitude_units(self, units): + self.dev.write("VOLT:UNIT %s" %(amplitude)) + + def set_offset(self, offset): + self.dev.write("VOLT:OFFS %s" %(offset)) + + def get_shape(self): + result = self.dev.query("FUNC:SHAP?")[:-1] + write_to_log("Signal's shape is: %s" %(result)) + return result + + def get_frequency(self): + result = self.dev.query("FREQ?")[:-1] + write_to_log("Frequency is: %s" %(result)) + return result + + def get_amplitude(self): + result = self.dev.query("VOLT?")[:-1] + write_to_log("Amplitude is: %s" %(result)) + return result + + def get_amplitude_unit(self): + result = self.dev.query("VOLT:UNIT?")[:-1] + write_to_log("Amplitude units are: %s" %(result)) + return result + + + def get_offset(self): + result = self.dev.query("VOLT:OFFS?")[:-1] + write_to_log("Offset is: %s" %(result)) + return result + + #Turn on the output channel. Doesn't necessary when using the generate() command, + #because output channel is being turn on automatically. + def output_on(self): + self.dev.write("OUTPUT ON") + + def output_off(self): + self.dev.write("OUTPUT OFF") class KikusuiPLZ70UA(): - def __init__(self, address): - resource_manager = visa.ResourceManager() - self.dev=resource_manager.open_resource(address) - self.name=self.dev.query('*IDN?')[:-1] - self.dev.timeout = 5000 - - #Close the connection with the device - def close(self): - self.dev.close() - write_to_log ('The connection with: %s is now closed' %(self.name)) - - def send_command(self, command): - #Send a visa command to the device. - #This function and the next one can be used in order to send a command that doesn't covered by this module. - self.dev.write(command) - - def read_response(self, command): - #read from the device. can be used after sending a query command to the device. - return self.dev.read()[-1] - - #Reset the device to factory default settings. - def reset(self): - self.dev.write("*RST") - write_to_log ('%s configured to factory default settings' %(self.name[:-1])) - - def load_on(self): - self.dev.write("INP ON") - if (self.dev.query("INP?") != '0'): - write_to_log("Load in on") - - def load_off(self): - self.dev.write("INP OFF") - if (self.dev.query("INP?") != '1'): - write_to_log("Load in off") - - #mode=CC/CR/CV/CCCV/CRCV, when CC='constant current' CR='constant resistance' CV='constant voltage' - def set_constant_mode(self, channel, mode): - self.dev.write("INST CH%s" %channel) - self.dev.write("FUNC %s" %mode) - - - #Set the conductance (in units of [S]). This funciton sets both of the channels together - def set_conductance(self, conductance): - self.dev.write("COND %s" %conductance) - - #Set the resistance (in unit of [ohm]) by first changing to conductance units. This funciton sets both of the channels together - def set_resistance(self, resistance): - if (float(resistance) != 0): - conductance = str(1/float(resistance)) - self.dev.write("COND %s" %conductance) - - #Set current. This funciton sets both of the channels together - def set_current(self, current): - self.dev.write("CURR %s" %current) - - #Set voltage. This funciton sets both of the channels together - def set_voltage(self, channel, voltage): - self.dev.write("INST CH%s" %channel) - self.dev.write("VOLT %s" %voltage) - - #Read the conductance on the specified channel - def read_conductance(self, channel): - self.dev.write("INST CH%s" %channel) - res = self.dev.query("MEAS:COND?")[:-1] - write_to_log("The conductance on channel %s is: %sS" %(channel, res)) - return res - - #Read the conductance on the specified channel - def read_current(self, channel): - self.dev.write("INST CH%s" %channel) - res = self.dev.query("MEAS:CURR?")[:-1] - write_to_log("The current on channel %s is: %sA" %(channel, res)) - return res - - #Read the conductance on the specified channel - def read_voltage(self, channel): - self.dev.write("INST CH%s" %channel) - res = self.dev.query("MEAS:VOLT?")[:-1] - write_to_log("The voltage on channel %s is: %sV" %(channel, res)) - return res - + def __init__(self, address): + resource_manager = visa.ResourceManager() + self.dev=resource_manager.open_resource(address) + self.name=self.dev.query('*IDN?')[:-1] + self.dev.timeout = 5000 + + #Close the connection with the device + def close(self): + self.dev.close() + write_to_log ('The connection with: %s is now closed' %(self.name)) + + def send_command(self, command): + #Send a visa command to the device. + #This function and the next one can be used in order to send a command that doesn't covered by this module. + self.dev.write(command) + + def read_response(self, command): + #read from the device. can be used after sending a query command to the device. + return self.dev.read()[-1] + + #Reset the device to factory default settings. + def reset(self): + self.dev.write("*RST") + write_to_log ('%s configured to factory default settings' %(self.name[:-1])) + + def load_on(self): + self.dev.write("INP ON") + if (self.dev.query("INP?") != '0'): + write_to_log("Load is on") + + def load_off(self): + self.dev.write("INP OFF") + if (self.dev.query("INP?") != '1'): + write_to_log("Load is off") + + #mode=CC/CR/CV/CCCV/CRCV, when CC='constant current' CR='constant resistance' CV='constant voltage' + def set_constant_mode(self, channel, mode): + self.dev.write("INST CH%s" %channel) + self.dev.write("FUNC %s" %mode) + + + #Set the conductance (in units of [S]). This funciton sets both of the channels together + def set_conductance(self, conductance): + self.dev.write("COND %s" %conductance) + + #Set the resistance (in unit of [ohm]) by first changing to conductance units. This funciton sets both of the channels together + def set_resistance(self, resistance): + if (float(resistance) != 0): + conductance = str(1/float(resistance)) + self.dev.write("COND %s" %conductance) + + #Set current. This funciton sets both of the channels together + def set_current(self, current): + self.dev.write("CURR %s" %current) + + #Set voltage. This funciton sets both of the channels together + def set_voltage(self, channel, voltage): + self.dev.write("INST CH%s" %channel) + self.dev.write("VOLT %s" %voltage) + + #Read the conductance on the specified channel + def read_conductance(self, channel): + self.dev.write("INST CH%s" %channel) + res = self.dev.query("MEAS:COND?")[:-1] + write_to_log("The conductance on channel %s is: %sS" %(channel, res)) + return res + + #Read the conductance on the specified channel + def read_current(self, channel): + self.dev.write("INST CH%s" %channel) + res = self.dev.query("MEAS:CURR?")[:-1] + write_to_log("The current on channel %s is: %sA" %(channel, res)) + return res + + #Read the conductance on the specified channel + def read_voltage(self, channel): + self.dev.write("INST CH%s" %channel) + res = self.dev.query("MEAS:VOLT?")[:-1] + write_to_log("The voltage on channel %s is: %sV" %(channel, res)) + return res + # The connection with this oven is a serial connection - rs232 - which is done using a usb-to-RS232 connector. # This connector appears as a virtual port with a specified 'COM'- this is the COM we need to enter when initializing the connection. class VotschVT4002(): - def __init__(self, com): - self.name="VotschVT4002" - self.ser=serial.Serial() - self.ser.close() - self.ser.port = com - self.ser.baudrate = 9600 - self.ser.bytesize = 8 - self.ser.parity = 'N' - self.ser.stopbits = 1 - self.ser.timeout = 1 - self.ser.open() - - - #Close the serial connection with the device - def close(self): - self.ser.close() - - #Changing the serial connection's parameters: - def change_port(self, com): - self.ser.port = com - write_to_log("{} port changed to {}".format(self.name, com)) - - #Sets the temperature and STARTS the chamber. temp can be from type int, float of str - def set_temp(self, temp): - neg = '0' - typ = type(temp) - if (typ == str): - temp = float(temp) - if (abs(temp) < 10): - temp = neg + '00' + str(round(temp,1)) - elif (temp <= 100 and temp >= -50): - temp = neg + '0' +str(round(temp,1)) - else: - write_to_log("Error: temperature should be between -50C to 100C") - self.ser.write("$00E %s 0000.0 0000.0 0000.0 0000.0 010100000000111013" %temp) - self.ser.write("$00I\r\n") - - #Return the temperature - def read_temp(self): - self.ser.write("$00I\r\n") - res = self.ser.readline() - res = res.split(" ")[1] - if (res[0] == '1'): #negative - res = '-' + res[2:] - else: - res = res[2:] - #write_to_log("Temperature is: %sC" %res) - return res - - #Stops the function of the chamber - def stop_champer(self): - self.ser.write("$00E 0000.0 0000.0 0000.0 0000.0 0000.0 000100000000111013") - - #Sets a temperature, and waits until it gets to the desirable temp. - def wait_for_temp(self,temp): - self.set_temp(temp) - time.sleep(0.5) - current_temp = float(self.read_temp()) - write_to_log("wait for the temperature to reach %sC" %temp) - temp = float(temp) - while (abs(current_temp) <= abs(temp*0.98) or abs(current_temp) >= abs(temp*1.02)): - time.sleep(1) - current_temp = float(self.read_temp()) - write_to_log("Temperature has reached the desirable value") - - def read_error(self): - self.ser.write("$00F\r\n") - time.sleep(1) - return self.ser.readline() + def __init__(self, com): + self.name="VotschVT4002" + self.ser=serial.Serial() + self.ser.close() + self.ser.port = com + self.ser.baudrate = 9600 + self.ser.bytesize = 8 + self.ser.parity = 'N' + self.ser.stopbits = 1 + self.ser.timeout = 1 + self.ser.open() + + + #Close the serial connection with the device + def close(self): + self.ser.close() + + #Changing the serial connection's parameters: + def change_port(self, com): + self.ser.port = com + write_to_log("{} port changed to {}".format(self.name, com)) + + #Sets the temperature and STARTS the chamber. temp can be from type int, float of str + def set_temp(self, temp): + typ = type(temp) + if (typ == str): + temp = float(temp) + neg = '0' if int(temp) >= 0 else '-' + if (abs(temp) < 10): + temp = neg + '00' + str(round(abs(temp), 1)) + elif (temp <= 100 and temp >= -50): + temp = neg + '0' +str(round(abs(temp), 1)) + else: + write_to_log("Error: temperature should be between -50C to 100C") + return + self.ser.write("$00E %s 0000.0 0000.0 0000.0 0000.0 010100000000111013" %temp) + self.ser.write("$00I\r\n") + + #Return the temperature + def read_temp(self): + self.ser.write("$00I\r\n") + res = self.ser.readline() + res = res.split(" ")[1] + if (res[0] == '1'): #negative + res = '-' + res[2:] + else: + res = res[2:] + #write_to_log("Temperature is: %sC" %res) + return res + + #Stops the function of the chamber + def stop_champer(self): + self.ser.write("$00E 0000.0 0000.0 0000.0 0000.0 0000.0 000100000000111013") + + #Sets a temperature, and waits until it gets to the desirable temp. + def wait_for_temp(self,temp): + self.set_temp(temp) + time.sleep(0.5) + current_temp = float(self.read_temp()) + write_to_log("wait for the temperature to reach %sC" %temp) + temp = float(temp) + while (current_temp <= temp-1 or current_temp >= temp+1): + time.sleep(1) + current_temp = float(self.read_temp()) + write_to_log("Temperature has reached the desirable value") + + def read_error(self): + self.ser.write("$00F\r\n") + time.sleep(1) + return self.ser.readline() class Termotron3800(): - def __init__(self,address): - self.tcp_ip = address[0] - self.port = address[1] - self.buffer_size = 1024 - self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.sock.connect((self.tcp_ip, self.port)) - self.sock.send("IDEN?\r\n") #ask for device identity - self.name = self.read_line() - self.sock.send("VRSN?\r\n") #ask for software version - self.version = self.read_line() - - - #close connection with device - def close(self): - self.sock.close() - - #read line from socket - def read_line(self): - line = "" - while True: - c = self.sock.recv(64) - if c == "": - break - elif "\r" in c: - line += c.split("\r")[0] - break - else: - line += c - return line - - #before reading the device's answer: - def clear_buffer(self): - c = self.sock.recv(1) - while (c != ""): - c = self.sock.recv(16) - time.sleep(0.1) - - #stop chamber from working - def stop_chamber(self): - err = "0" - k = 0 - while (err != "5" and k<3): #5 means that Termotron received the stop command - self.sock.send("STOP\r\n") #send the STOP command - self.sock.send("SCOD?\r\n") #check if the command had been received - err = self.read_line() - k += 1 - - if (k == 10): #5 means that Termotron received the stop command - write_to_log("Error while sending STOP command to %s" %self.name) - - def run_chamber(self): - self.sock.send("RUNM\r\n") - - - def set_temp(self, temp): - if type(temp != str): - temp = str(temp) - self.sock.send("SETP1,%s\r\n" %temp) - time.sleep(0.1) - self.run_chamber() - - #read the current temperature of the chamber. - def read_temp(self): - self.sock.send("PVAR1?\r\n") #read the deviation from the configured value - time.sleep(0.1) - current_temp = self.read_line() - count = 0 - while current_temp == '0' and count<3: - self.sock.send("PVAR1?\r\n") - current_temp = self.read_line() - count += 1 - return float(current_temp) - - - def wait_for_temp(self, temp): - self.set_temp(temp) - time.sleep(0.1) - current_temp = self.read_temp() - while (abs(current_temp) <= abs(temp*0.98) or abs(current_temp) >= abs(temp*1.02)): - time.sleep(1) - current_temp = self.read_temp() - write_to_log("Temperature has reached the desirable value") + def __init__(self,address): + self.tcp_ip = address[0] + self.port = address[1] + self.buffer_size = 1024 + self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.sock.connect((self.tcp_ip, self.port)) + self.sock.send("IDEN?\r\n") #ask for device identity + self.name = self.read_line() + self.sock.send("VRSN?\r\n") #ask for software version + self.version = self.read_line() + + + #close connection with device + def close(self): + self.sock.close() + + #read line from socket + def read_line(self): + line = "" + while True: + c = self.sock.recv(64) + if c == "": + break + elif "\r" in c: + line += c.split("\r")[0] + break + else: + line += c + return line + + #before reading the device's answer: + def clear_buffer(self): + c = self.sock.recv(1) + while (c != ""): + c = self.sock.recv(16) + time.sleep(0.1) + + #stop chamber from working + def stop_chamber(self): + err = "0" + k = 0 + while (err != "5" and k<3): #5 means that Termotron received the stop command + self.sock.send("STOP\r\n") #send the STOP command + self.sock.send("SCOD?\r\n") #check if the command had been received + err = self.read_line() + k += 1 + + if (k == 10): #5 means that Termotron received the stop command + write_to_log("Error while sending STOP command to %s" %self.name) + + def run_chamber(self): + self.sock.send("RUNM\r\n") + + + def set_temp(self, temp): + if type(temp != str): + temp = str(temp) + self.sock.send("SETP1,%s\r\n" %temp) + time.sleep(0.1) + self.run_chamber() + + #read the current temperature of the chamber. + def read_temp(self): + self.sock.send("PVAR1?\r\n") #read the deviation from the configured value + time.sleep(0.1) + current_temp = self.read_line() + count = 0 + while current_temp == '0' and count<3: + self.sock.send("PVAR1?\r\n") + current_temp = self.read_line() + count += 1 + return float(current_temp) + + + def wait_for_temp(self, temp): + self.set_temp(temp) + time.sleep(0.1) + current_temp = self.read_temp() + while (abs(current_temp) <= abs(temp*0.98) or abs(current_temp) >= abs(temp*1.02)): + time.sleep(1) + current_temp = self.read_temp() + write_to_log("Temperature has reached the desirable value") + + + diff --git a/test1.py b/test1.py index e5fb247..5e99953 100644 --- a/test1.py +++ b/test1.py @@ -9,9 +9,9 @@ # TEST_NAME - the test's name. # # # # #defines: # -# T32_APP_CMM_PATH of every define that is specific to this test. # +# T32_APP_CMM_PATH or every define that is specific to this test. # # # -# #call the init.py module: # +# #import modules: # # execfile(r"C:\Users\bar.kristal\Documents\GitHub\Python\init.py") # #################################################################################################### @@ -38,6 +38,13 @@ # D6.load_boot_file(r'T:\Barkristal\VT_D6_ver_293_Sen333.bin') # print D6.read_IO_port('3000000') +D4 = UartDevice('DBMD4', 'COM9', baudrate=912600, bytesize=8, parity='N', stopbits=1,timeout=1) +D4.change_baudrate(115200) +print D4.ser.baudrate +D4.sync(10) +# D6.load_boot_file(r'T:\Barkristal\VT_D6_ver_293_Sen333.bin') +print D4.read_apb_reg('3000000') +print D4.read_apb_reg('3000008') ######################## @@ -136,6 +143,11 @@ ######################## ## Wave generator -wave_gen = HP33120aWaveGen("GPIB0::12::INSTR") -wave_gen.generate("SIN", '1000', "1", "0") +# wave_gen = HP33120aWaveGen("GPIB0::12::INSTR") +# wave_gen.generate("SIN", '1000', "1", "0") + +######################## +## saleae +# logic = saleae.Saleae() +# logic.capture_to_file(r'c:\saleae_capture') \ No newline at end of file