Compare commits
180 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c24db94db2 | |||
| ecfd6b23ec | |||
| ced7a357e5 | |||
| cf21efb331 | |||
| 08a758b77e | |||
| 50d0398d5a | |||
| 37c556bcd3 | |||
| ac14aa1e1e | |||
| 49f99fb9f6 | |||
| 3553e2c5e3 | |||
| d155fab875 | |||
| 464e80310e | |||
| 8b1ee78b63 | |||
| 30deffd0a3 | |||
| c9683added | |||
| 37f56b3acd | |||
| c30c735c9a | |||
| f1e1593a9a | |||
| 6f952b0600 | |||
| 427a1f8ee8 | |||
| 0a8c570027 | |||
| 6b32b71bfa | |||
| 98daa4a268 | |||
| 25b3caa8b5 | |||
| 7abe679d8a | |||
| ed0e856542 | |||
| cd630d4125 | |||
| 39f2847485 | |||
| 13418b6663 | |||
| 78b6fc9de2 | |||
| a27bc9523e | |||
| 65679c5974 | |||
| 8db68f9794 | |||
| 8c0d8255a7 | |||
| 010c89e862 | |||
| 0e27334394 | |||
| 8bb4484570 | |||
| eeefd47b44 | |||
| 04270b85b3 | |||
| f6c8e06776 | |||
| 9cb791976d | |||
| dba6cde440 | |||
| 312a961f94 | |||
| 97a344c349 | |||
| f84a4dab27 | |||
| 0afe5f764a | |||
| 2d40295688 | |||
| aeee554ac2 | |||
| ed8900c38d | |||
| 9cb1c1d1e7 | |||
| b843e05c39 | |||
| 4d7f3054b1 | |||
| f57397cb38 | |||
| 6159d35cb3 | |||
| 98a14c7ef8 | |||
| 89d7a7b012 | |||
| c7a5ead820 | |||
| 15fc8d8e42 | |||
| be19d969ad | |||
| bf38d2f4ea | |||
| 76de153299 | |||
| 1e919a7211 | |||
| c91d1ccf21 | |||
| a5dad54034 | |||
| c9783e48a1 | |||
| 1051ffd8fc | |||
| 162048a009 | |||
| 3f3107e7e0 | |||
| 839647c2a6 | |||
| 563ed5f724 | |||
| ef4eaa6b2d | |||
| f4df61ec6d | |||
| d760414837 | |||
| 21dfcc8c03 | |||
| db7c35c294 | |||
| 47c8303c9d | |||
| a9cd19727b | |||
| 3e067bc1c4 | |||
| d7fc95b90b | |||
| 883c7759b0 | |||
| be0fba2947 | |||
| f1c03ea972 | |||
| 837741d3e3 | |||
| 5157a83bbe | |||
| 2b2fc8f3ec | |||
| f552bdacab | |||
| 2679cdead2 | |||
| cfa25627bd | |||
| 88fd446fef | |||
| c5f084a93c | |||
| 0eb46585d8 | |||
| 8ff9884301 | |||
| 2054421b78 | |||
| 45131f3e8d | |||
| 61da4e107d | |||
| daff7d5929 | |||
| 4eaade4d8a | |||
| 54bcb0efe2 | |||
| e8d10e9e87 | |||
| ce3462b2b3 | |||
| 0c3af8b70e | |||
| 15cc5a4b82 | |||
| 7e2e7467bd | |||
| 339282d568 | |||
| 780d0afa6a | |||
| 02089810f2 | |||
| 18c35e27d0 | |||
| ce3b4f50a7 | |||
| 31c897c9dc | |||
| 8443648d48 | |||
| 2d877ea62d | |||
| 37df7d21e3 | |||
| 0e8707bbd1 | |||
| 479a4d6de1 | |||
| dffe29f80d | |||
| 31dff11f6e | |||
| 8f075f477b | |||
| c133fa74c3 | |||
| 7edcb7517a | |||
| 6cb1e18b7a | |||
| 980aba0010 | |||
| c6800f8f4f | |||
| 3ee0945114 | |||
| 09c47df3bb | |||
| 5b68f374e7 | |||
| 8d6e639c99 | |||
| 5616203743 | |||
| cbd103794c | |||
| a6c980cb0b | |||
| d812b3eea2 | |||
| 50a9034b38 | |||
| b799ef44cc | |||
| 5fc157e66d | |||
| 7234964ba1 | |||
| 5a472c1e5b | |||
| 9fc5858073 | |||
| f7570eda95 | |||
| 8e5369389f | |||
| 71c00ac6b3 | |||
| fa0d47c241 | |||
| 96d94f79b7 | |||
| bd96102ec2 | |||
| 79239bd4a7 | |||
| 02e72276aa | |||
| df3b074539 | |||
| 4bf451b64c | |||
| d06895e074 | |||
| e2672cf2b2 | |||
| 495fca7e90 | |||
| 3ef9f32df6 | |||
| 9ebe9c902f | |||
| 9ea1f6e40d | |||
| 2bc7184d4d | |||
| 27ffda9adf | |||
| 1f8b280b2c | |||
| a6950c2b74 | |||
| 5f3e5bbd6b | |||
| d379f0b5f7 | |||
| 9130c9edc2 | |||
| fb8fdd5d5b | |||
| 53305aaec5 | |||
| 51e8f8f4fa | |||
| 8c31d345fc | |||
| 3d00ed87c7 | |||
| aa8023d3a1 | |||
| 331fb14342 | |||
| 540a53e917 | |||
| c9d1efa1f7 | |||
| 5093fb354f | |||
| 209fd3239e | |||
| 2bf8a1781b | |||
| 520e0939f6 | |||
| 03cef16fd6 | |||
| e59a0b76bf | |||
| 247e5e50b7 | |||
| 495f1e3834 | |||
| d0061e7d5c | |||
| 8af6af1849 | |||
| 6f4d8818b5 | |||
| 75cd2faf91 |
+4
@@ -2,16 +2,20 @@
|
||||
<launchConfiguration type="com.ti.ccstudio.debug.launchType.device.debugging">
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <PropertyValues> <property id="ConnectOnStartup"> <curValue>1</curValue> </property> <property id="EnableInstalledBreakpoint"> <curValue>1</curValue> </property> <property id="IgnoreSoftLaunchFailures"> <curValue>0</curValue> </property> </PropertyValues> "/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <PropertyValues> <property id="ConnectOnStartup"> <curValue>1</curValue> </property> <property id="EnableInstalledBreakpoint"> <curValue>1</curValue> </property> <property id="IgnoreSoftLaunchFailures"> <curValue>0</curValue> </property> </PropertyValues> "/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <PropertyValues> <property id="ConnectOnStartup"> <curValue>1</curValue> </property> <property id="EnableInstalledBreakpoint"> <curValue>1</curValue> </property> <property id="IgnoreSoftLaunchFailures"> <curValue>0</curValue> </property> </PropertyValues> "/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <PropertyValues> <property id="ConnectOnStartup"> <curValue>1</curValue> </property> <property id="EnableInstalledBreakpoint"> <curValue>1</curValue> </property> <property id="IgnoreSoftLaunchFailures"> <curValue>0</curValue> </property> </PropertyValues> "/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_app}"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_app}"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_app}"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_app}"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="simple_peripheral_cc2650em_app"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="simple_peripheral_cc2650em_app"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="simple_peripheral_cc2650em_app"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="simple_peripheral_cc2650em_app"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_TARGET_CONFIG" value="${target_config_active_default:simple_peripheral_cc2650em_app}"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/simple_peripheral_cc2650em_app"/>
|
||||
|
||||
BIN
Binary file not shown.
+4
@@ -3,16 +3,20 @@
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\stack\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <PropertyValues> <property id="ConnectOnStartup"> <curValue>1</curValue> </property> <property id="EnableInstalledBreakpoint"> <curValue>1</curValue> </property> <property id="IgnoreSoftLaunchFailures"> <curValue>0</curValue> </property> </PropertyValues> "/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\stack\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <PropertyValues> <property id="ConnectOnStartup"> <curValue>1</curValue> </property> <property id="EnableInstalledBreakpoint"> <curValue>1</curValue> </property> <property id="IgnoreSoftLaunchFailures"> <curValue>0</curValue> </property> </PropertyValues> "/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\stack\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <PropertyValues> <property id="ConnectOnStartup"> <curValue>1</curValue> </property> <property id="EnableInstalledBreakpoint"> <curValue>1</curValue> </property> <property id="IgnoreSoftLaunchFailures"> <curValue>0</curValue> </property> </PropertyValues> "/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <PropertyValues> <property id="ConnectOnStartup"> <curValue>1</curValue> </property> <property id="EnableInstalledBreakpoint"> <curValue>1</curValue> </property> <property id="IgnoreSoftLaunchFailures"> <curValue>0</curValue> </property> </PropertyValues> "/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\stack\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_stack}"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\stack\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_stack}"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\stack\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_stack}"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_stack}"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\stack\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="simple_peripheral_cc2650em_stack"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\stack\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="simple_peripheral_cc2650em_stack"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\stack\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="simple_peripheral_cc2650em_stack"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="simple_peripheral_cc2650em_stack"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_TARGET_CONFIG" value="${target_config_active_default:simple_peripheral_cc2650em_stack}"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\stack\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\stack\FlashROM\simple_peripheral_cc2650em_stack.out"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\stack\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\stack\FlashROM\simple_peripheral_cc2650em_stack.out"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\stack\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\stack\FlashROM\simple_peripheral_cc2650em_stack.out"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\stack\FlashROM\simple_peripheral_cc2650em_stack.out"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/simple_peripheral_cc2650em_stack"/>
|
||||
</listAttribute>
|
||||
|
||||
+247
@@ -0,0 +1,247 @@
|
||||
|
||||
#ifndef AD5940
|
||||
#define AD5940
|
||||
|
||||
static void AD5940_init(){
|
||||
select_REG(0x0908);//initiation
|
||||
w16_REG(0x02C9);
|
||||
select_REG(0x0C08);
|
||||
w16_REG(0x206C);
|
||||
select_REG(0x21F0);
|
||||
w16_REG(0x0010);
|
||||
select_REG(0x0410);
|
||||
w16_REG(0x02C9);
|
||||
select_REG(0x0A28);
|
||||
w16_REG(0x0009);
|
||||
select_REG(0x238C);
|
||||
w16_REG(0x0104);
|
||||
select_REG(0x0A04);
|
||||
w16_REG(0x4859);
|
||||
select_REG(0x0A04);
|
||||
w16_REG(0xF27B);
|
||||
select_REG(0x0A00);
|
||||
w16_REG(0x8009);
|
||||
select_REG(0x0A04);
|
||||
w16_REG(0x4859);
|
||||
select_REG(0x22F0);
|
||||
w16_REG(0x0000);
|
||||
}
|
||||
|
||||
static void AD5940_sftreset(){
|
||||
select_REG(0x0424);
|
||||
w16_REG(0xA158);
|
||||
CPUdelay(200);
|
||||
}
|
||||
|
||||
static void AD5940_HWReset(){
|
||||
PIN_setOutputValue(pin_handle, AD_reset, 0);
|
||||
CPUdelay(2000); // 200us
|
||||
PIN_setOutputValue(pin_handle, AD_reset, 1);
|
||||
CPUdelay(5000); // 500us
|
||||
}
|
||||
|
||||
static void setEIS_EIS (void)
|
||||
{
|
||||
select_REG(LPDACCON0); //2128 //DC on
|
||||
w32_REG(0x00000001); //LPDAC enabled
|
||||
select_REG(LPDACSW0); //2124 //operation
|
||||
w32_REG(0b111111); //0b101011
|
||||
|
||||
select_REG(HSRTIACON);
|
||||
w32_REG(0x00000000); //200R //1pF
|
||||
|
||||
select_REG(ADCCON); //21A8
|
||||
w32_REG(0x00000101);
|
||||
select_REG(DFTCON);
|
||||
w32_REG(0x00000091);
|
||||
select_REG(SWCON); //200C
|
||||
w32_REG(0x00026355); //D5 | P5 | N3 | T6 | T9 0b010 0110 0011 0101 0101
|
||||
|
||||
if (instru.ADCGainLv != HSRTIA_GAIN_AUTO) {
|
||||
instru.AutoGainEnable = 0;
|
||||
HSTIAGainCtrl(instru.ADCGainLv);
|
||||
} else {
|
||||
instru.AutoGainEnable = 1;
|
||||
instru.ADCGainLv = HSRTIA_200R;
|
||||
HSTIAGainCtrl(instru.ADCGainLv);
|
||||
}
|
||||
|
||||
DAC_outputV(instru.dcbias + CaliTable.DAC_offset * 200);
|
||||
SetWGAmp(instru.acamp);
|
||||
|
||||
select_REG(0x2000); //2000
|
||||
w32_REG(0x0031CFC0);
|
||||
|
||||
//HIGH POWER MODE
|
||||
select_REG(0x22F0); //PWMB
|
||||
w32_REG(0x0000000D); //switch to active high power mode
|
||||
select_REG(0x0414);
|
||||
w16_REG(0x0000);
|
||||
select_REG(0x0420);
|
||||
w16_REG(0xA815);
|
||||
select_REG(0x0408); //16bit system clock divider
|
||||
w16_REG(0x0442); //set divider = 2
|
||||
select_REG(0x20BC); //HSOSCCON
|
||||
w32_REG(0x00000000); //switch to 32MHz output
|
||||
select_REG(0x2044);
|
||||
w32_REG(0x00000311);
|
||||
select_REG(0x2010); //HSDACCON
|
||||
w32_REG(0x0000000E); //DAC gain = 2, > 80 kHz
|
||||
select_REG(0x238C); //ADCBUFCON
|
||||
w32_REG(0x005F3D0F); //recommended
|
||||
SetEISHIGHZ(0);
|
||||
}
|
||||
|
||||
static void setEIS_CV (void)
|
||||
{
|
||||
//Clock and Ref
|
||||
select_REG(0x0414); //CLKSEL
|
||||
w16_REG(0x0);
|
||||
select_REG(0x20BC); //HSOSCCON
|
||||
w32_REG(0x00000004); //16 MHz output
|
||||
select_REG(0x2180); //BUFSENCON
|
||||
w32_REG(0x00000037); //0b110110
|
||||
|
||||
//Configure LPDAC LPTIA
|
||||
select_REG(0x2050); //LPREFBUFCON
|
||||
w32_REG(0x0); //enable lpref and lp 2.5V buffer
|
||||
select_REG(0x2124); //LPDACSW0
|
||||
w32_REG(0x0000003E);
|
||||
select_REG(0x20E4); //LPTIASW0
|
||||
w32_REG(0x00008034); // SW2 | SW4 | SW5
|
||||
select_REG(0x20EC); //LPTIACON0
|
||||
w32_REG(0x00000038); //RF 0 | RTIA 200R | Rload 0 | High Current Mode
|
||||
select_REG(0x2128); //LPDACCON0
|
||||
w32_REG(0x00000001);
|
||||
|
||||
//Configure ADC | ADCDAT (0x2074)
|
||||
select_REG(0x21A8); //ADCCON
|
||||
w32_REG(0x00001021); //PGA = 1 | VZERO | LPTIA_OUT
|
||||
select_REG(0x2044); //ADCFILTERCON
|
||||
w32_REG(0x00002011); // Sinc3 En | SINC3OSR2 | SINC2OSR22
|
||||
select_REG(0x20D0); //DFTCON
|
||||
w32_REG(0x00000001); // Sinc2 to DFT | DFTNUM4
|
||||
|
||||
//AFE and PWMB
|
||||
select_REG(0x2000); //AFECON
|
||||
w32_REG(0x00098780); //ADC on //0b10011000011110000000
|
||||
select_REG(0x22F0); //PWMB
|
||||
w32_REG(0x00000005);//fc 50kHz, low power mode
|
||||
|
||||
|
||||
// //Clock and Ref
|
||||
// select_REG(CLKSEL); //CLKSEL
|
||||
// w16_REG(0x0);
|
||||
// select_REG(HSOSCCON); //HSOSCCON
|
||||
// w32_REG(0x00000004); //16 MHz output
|
||||
// select_REG(0x2180); //BUFSENCON
|
||||
// w32_REG(0x00000037); //0b110110
|
||||
//
|
||||
// //Configure LPDAC LPTIA
|
||||
// select_REG(LPREFBUFCON); //LPREFBUFCON
|
||||
// w32_REG(0x0); //enable lpref and lp 2.5V buffer
|
||||
// select_REG(LPDACSW0); //LPDACSW0
|
||||
// w32_REG(0x0000003E);
|
||||
// select_REG(LPTIASW0); //LPTIASW0
|
||||
// w32_REG(0x00008034); // SW2 | SW4 | SW5
|
||||
// select_REG(LPTIACON0); //LPTIACON0
|
||||
// w32_REG(0x00000038); //RF 0 | RTIA 200R | Rload 0 | High Current Mode
|
||||
// select_REG(LPDACCON0); //LPDACCON0
|
||||
// w32_REG(0x00000001);
|
||||
//
|
||||
// //Configure ADC | ADCDAT (0x2074)
|
||||
// select_REG(ADCCON); //ADCCON
|
||||
// w32_REG(0x00001021); //PGA = 1 | VZERO | LPTIA_OUT
|
||||
// select_REG(ADCFILTERCON); //ADCFILTERCON
|
||||
// w32_REG(0x00014091); //AVR 4 | Sinc3 En | OSR 5
|
||||
//// w32_REG(0x00012011); //Disable avr | sinc3 enable | osr 2
|
||||
// select_REG(DFTCON); //DFTCON
|
||||
// w32_REG(0x00100031); //sinc3 + average input for DFT | DFTNUM 32
|
||||
//
|
||||
// //AFE and PMWB
|
||||
// select_REG(AFECON); //AFECON
|
||||
// w32_REG(0x00098780); //ADC on //0b10011000011110000000
|
||||
// select_REG(PMBW); //PMWB
|
||||
// w32_REG(0x00000005);//fc 50kHz, low power mode
|
||||
}
|
||||
|
||||
static void HS_cali_config (void)
|
||||
{
|
||||
select_REG(LPDACCON0); //2128 //DC on
|
||||
w32_REG(0x00000001); //LPDAC enabled
|
||||
select_REG(LPDACSW0); //2124 //operation
|
||||
w32_REG(0b111111); //0b101011
|
||||
|
||||
select_REG(DE0RESCON); //20F8 //DE0's gain
|
||||
w32_REG(0x000000FF);
|
||||
// select_REG(HSRTIACON);
|
||||
// w32_REG(0x00000200); //4pF + 200R
|
||||
|
||||
select_REG(ADCCON); //21A8
|
||||
w32_REG(0x00000101);
|
||||
select_REG(DFTCON); //20D0
|
||||
w32_REG(0x00000091);
|
||||
select_REG(SWCON); //200C
|
||||
w32_REG(0x00026355); //D5 | P5 | N3 | T6 | T9 0b010 0110 0011 0101 0101
|
||||
// w32_REG(0x00026905); //0b010 0110 1001 0000 0101
|
||||
|
||||
select_REG(AFECON); //2000
|
||||
w32_REG(0x0030CFC0);
|
||||
|
||||
//HIGH POWER MODE
|
||||
select_REG(PMBW); //PMWB
|
||||
w32_REG(0x0000000D); //switch to active high power mode
|
||||
select_REG(CLKSEL);
|
||||
w16_REG(0x0000);
|
||||
select_REG(CLKCON0KEY);
|
||||
w16_REG(0xA815);
|
||||
select_REG(CLKCON0); //16bit system clock divider
|
||||
w16_REG(0x0442); //set divider = 2
|
||||
select_REG(HSOSCCON); //HSOSCCON
|
||||
w32_REG(0x00000000); //switch to 32MHz output
|
||||
select_REG(ADCFILTERCON); //ADCFILTERCON
|
||||
w32_REG(0x000000D0); //ADC data rate = 1.6MHz // 2 samples to average
|
||||
select_REG(HSDACCON); //HSDACCON
|
||||
w32_REG(0x0000000E); //DAC gain = 2, > 80 kHz
|
||||
select_REG(ADCBUFCON); //ADCBUFCON
|
||||
w32_REG(0x005F3D0F); //recommended
|
||||
}
|
||||
static void LP_cali_config (void)
|
||||
{
|
||||
//Clock and Ref
|
||||
select_REG(0x0414); //CLKSEL
|
||||
w16_REG(0x0);
|
||||
select_REG(0x20BC); //HSOSCCON
|
||||
w32_REG(0x00000004); //16 MHz output
|
||||
select_REG(0x2180); //BUFSENCON
|
||||
w32_REG(0x00000037); //0b110110
|
||||
|
||||
//Configure LPDAC LPTIA
|
||||
select_REG(0x2050); //LPREFBUFCON
|
||||
w32_REG(0x0); //enable lpref and lp 2.5V buffer
|
||||
select_REG(0x2124); //LPDACSW0
|
||||
w32_REG(0x0000003E);
|
||||
select_REG(0x20E4); //LPTIASW0
|
||||
w32_REG(0x00008034); // SW2 | SW4 | SW5
|
||||
select_REG(0x20EC); //LPTIACON0
|
||||
w32_REG(0x00000038); //RF 0 | RTIA 200R | Rload 0 | High Current Mode
|
||||
select_REG(0x2128); //LPDACCON0
|
||||
w32_REG(0x00000001);
|
||||
|
||||
//Configure ADC | ADCDAT (0x2074)
|
||||
select_REG(0x21A8); //ADCCON
|
||||
w32_REG(0x00001021); //PGA = 1 | VZERO | LPTIA_OUT
|
||||
select_REG(0x2044); //ADCFILTERCON
|
||||
w32_REG(0x00006091); //AVR 4 | Sinc3 En | OSR 2
|
||||
// w32_REG(0x00012011); //Disable avr | sinc3 enable | osr 2
|
||||
select_REG(0x20D0); //DFTCON
|
||||
w32_REG(0x001000C1); //sinc3 + average input for DFT | dftnum max
|
||||
|
||||
//AFE and PWMB
|
||||
select_REG(0x2000); //AFECON
|
||||
w32_REG(0x00098780); //ADC on //0b10011000011110000000
|
||||
select_REG(0x22F0); //PWMB
|
||||
w32_REG(0x00000005);//fc 50kHz, low power mode
|
||||
}
|
||||
|
||||
#endif
|
||||
+229
-229
@@ -1,229 +1,192 @@
|
||||
|
||||
#ifndef Elite15_PIN
|
||||
#define Elite_15PIN
|
||||
|
||||
#include "Elite_PIN.h"
|
||||
|
||||
static void update_latch_status (uint32_t latch_num, uint32_t elite_pin, bool highlow) {
|
||||
switch (latch_num) {
|
||||
case LOAD0: {
|
||||
switch (elite_pin) {
|
||||
case D0: {
|
||||
LH.LATCH0[0] = highlow;
|
||||
break;
|
||||
}
|
||||
case D1: {
|
||||
LH.LATCH0[1] = highlow;
|
||||
break;
|
||||
}
|
||||
case D2: {
|
||||
LH.LATCH0[2] = highlow;
|
||||
break;
|
||||
}
|
||||
case D3: {
|
||||
LH.LATCH0[3] = highlow;
|
||||
break;
|
||||
}
|
||||
case D4: {
|
||||
LH.LATCH0[4] = highlow;
|
||||
break;
|
||||
}
|
||||
case D5: {
|
||||
LH.LATCH0[5] = highlow;
|
||||
break;
|
||||
}
|
||||
case D6: {
|
||||
LH.LATCH0[6] = highlow;
|
||||
break;
|
||||
}
|
||||
case D7: {
|
||||
LH.LATCH0[7] = highlow;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LOAD1: {
|
||||
switch (elite_pin) {
|
||||
case D0: {
|
||||
LH.LATCH1[0] = highlow;
|
||||
break;
|
||||
}
|
||||
case D1: {
|
||||
LH.LATCH1[1] = highlow;
|
||||
break;
|
||||
}
|
||||
case D2: {
|
||||
LH.LATCH1[2] = highlow;
|
||||
break;
|
||||
}
|
||||
case D3: {
|
||||
LH.LATCH1[3] = highlow;
|
||||
break;
|
||||
}
|
||||
case D4: {
|
||||
LH.LATCH1[4] = highlow;
|
||||
break;
|
||||
}
|
||||
case D5: {
|
||||
LH.LATCH1[5] = highlow;
|
||||
break;
|
||||
}
|
||||
case D6: {
|
||||
LH.LATCH1[6] = highlow;
|
||||
break;
|
||||
}
|
||||
case D7: {
|
||||
LH.LATCH1[7] = highlow;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LOAD2: {
|
||||
switch (elite_pin) {
|
||||
case D0: {
|
||||
LH.LATCH2[0] = highlow;
|
||||
break;
|
||||
}
|
||||
case D1: {
|
||||
LH.LATCH2[1] = highlow;
|
||||
break;
|
||||
}
|
||||
case D2: {
|
||||
LH.LATCH2[2] = highlow;
|
||||
break;
|
||||
}
|
||||
case D3: {
|
||||
LH.LATCH2[3] = highlow;
|
||||
break;
|
||||
}
|
||||
case D4: {
|
||||
LH.LATCH2[4] = highlow;
|
||||
break;
|
||||
}
|
||||
case D5: {
|
||||
LH.LATCH2[5] = highlow;
|
||||
break;
|
||||
}
|
||||
case D6: {
|
||||
LH.LATCH2[6] = highlow;
|
||||
break;
|
||||
}
|
||||
case D7: {
|
||||
LH.LATCH2[7] = highlow;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool highlow) {
|
||||
ELITE15_SPI_CLOSE();
|
||||
add_elite_pin();
|
||||
update_latch_status (latch_num, pin_num, highlow);
|
||||
//
|
||||
//#ifndef Elite15_PIN
|
||||
//#define Elite_15PIN
|
||||
//
|
||||
//#include "Elite_PIN.h"
|
||||
//
|
||||
//static void update_latch_status (uint32_t latch_num, uint32_t elite_pin, bool highlow) {
|
||||
// switch (latch_num) {
|
||||
// case LOAD0: {
|
||||
// switch (elite_pin) {
|
||||
// case D0: {
|
||||
// LH.LATCH0[0] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D1: {
|
||||
// LH.LATCH0[1] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D2: {
|
||||
// LH.LATCH0[2] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D3: {
|
||||
// LH.LATCH0[3] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D4: {
|
||||
// LH.LATCH0[4] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D5: {
|
||||
// LH.LATCH0[5] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D6: {
|
||||
// LH.LATCH0[6] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D7: {
|
||||
// LH.LATCH0[7] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// default: {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// case LOAD1: {
|
||||
// switch (elite_pin) {
|
||||
// case D0: {
|
||||
// LH.LATCH1[0] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D1: {
|
||||
// LH.LATCH1[1] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D2: {
|
||||
// LH.LATCH1[2] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D3: {
|
||||
// LH.LATCH1[3] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D4: {
|
||||
// LH.LATCH1[4] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D5: {
|
||||
// LH.LATCH1[5] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D6: {
|
||||
// LH.LATCH1[6] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D7: {
|
||||
// LH.LATCH1[7] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// default: {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// case LOAD2: {
|
||||
// switch (elite_pin) {
|
||||
// case D0: {
|
||||
// LH.LATCH2[0] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D1: {
|
||||
// LH.LATCH2[1] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D2: {
|
||||
// LH.LATCH2[2] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D3: {
|
||||
// LH.LATCH2[3] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D4: {
|
||||
// LH.LATCH2[4] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D5: {
|
||||
// LH.LATCH2[5] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D6: {
|
||||
// LH.LATCH2[6] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// case D7: {
|
||||
// LH.LATCH2[7] = highlow;
|
||||
// break;
|
||||
// }
|
||||
// default: {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// default: {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool highlow) {
|
||||
// ELITE15_SPI_CLOSE();
|
||||
// add_elite_pin();
|
||||
// update_latch_status (latch_num, pin_num, highlow);
|
||||
//// PIN_setOutputValue(&ZM_rst, latch_num, 1); // Turn on latch
|
||||
//
|
||||
// switch (latch_num) {
|
||||
// case LOAD0: {
|
||||
//// PIN_setOutputValue(&ZM_rst, D0, LH.LATCH0[0]);
|
||||
//// PIN_setOutputValue(&ZM_rst, D1, LH.LATCH0[1]);
|
||||
//// PIN_setOutputValue(&ZM_rst, D2, LH.LATCH0[2]);
|
||||
//// PIN_setOutputValue(&ZM_rst, D3, LH.LATCH0[3]);
|
||||
// PIN_setOutputValue(pin_handle, D4, LH.LATCH0[4]);
|
||||
// PIN_setOutputValue(pin_handle, D5, LH.LATCH0[5]);
|
||||
// PIN_setOutputValue(pin_handle, D6, LH.LATCH0[6]);
|
||||
// PIN_setOutputValue(pin_handle, D7, LH.LATCH0[7]);
|
||||
// break;
|
||||
// }
|
||||
// case LOAD1: {
|
||||
// PIN_setOutputValue(pin_handle, D0, LH.LATCH1[0]);
|
||||
// PIN_setOutputValue(pin_handle, D1, LH.LATCH1[1]);
|
||||
// PIN_setOutputValue(pin_handle, D2, LH.LATCH1[2]);
|
||||
// PIN_setOutputValue(pin_handle, D3, LH.LATCH1[3]);
|
||||
// PIN_setOutputValue(pin_handle, D4, LH.LATCH1[4]);
|
||||
// PIN_setOutputValue(pin_handle, D5, LH.LATCH1[5]);
|
||||
// PIN_setOutputValue(pin_handle, D6, LH.LATCH1[6]);
|
||||
// PIN_setOutputValue(pin_handle, D7, LH.LATCH1[7]);
|
||||
// break;
|
||||
// }
|
||||
// case LOAD2: {
|
||||
// PIN_setOutputValue(pin_handle, D0, LH.LATCH2[0]);
|
||||
// PIN_setOutputValue(pin_handle, D1, LH.LATCH2[1]);
|
||||
// PIN_setOutputValue(pin_handle, D2, LH.LATCH2[2]);
|
||||
// PIN_setOutputValue(pin_handle, D3, LH.LATCH2[3]);
|
||||
// PIN_setOutputValue(pin_handle, D4, LH.LATCH2[4]);
|
||||
// PIN_setOutputValue(pin_handle, D5, LH.LATCH2[5]);
|
||||
// PIN_setOutputValue(pin_handle, D6, LH.LATCH2[6]);
|
||||
// PIN_setOutputValue(pin_handle, D7, LH.LATCH2[7]);
|
||||
// break;
|
||||
// }
|
||||
// default: {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// PIN_setOutputValue(&ZM_rst, latch_num, 1); // Turn on latch
|
||||
|
||||
switch (latch_num) {
|
||||
case LOAD0: {
|
||||
// PIN_setOutputValue(&ZM_rst, D0, LH.LATCH0[0]);
|
||||
// PIN_setOutputValue(&ZM_rst, D1, LH.LATCH0[1]);
|
||||
// PIN_setOutputValue(&ZM_rst, D2, LH.LATCH0[2]);
|
||||
// PIN_setOutputValue(&ZM_rst, D3, LH.LATCH0[3]);
|
||||
PIN_setOutputValue(pin_handle, D4, LH.LATCH0[4]);
|
||||
PIN_setOutputValue(pin_handle, D5, LH.LATCH0[5]);
|
||||
PIN_setOutputValue(pin_handle, D6, LH.LATCH0[6]);
|
||||
PIN_setOutputValue(pin_handle, D7, LH.LATCH0[7]);
|
||||
break;
|
||||
}
|
||||
case LOAD1: {
|
||||
PIN_setOutputValue(pin_handle, D0, LH.LATCH1[0]);
|
||||
PIN_setOutputValue(pin_handle, D1, LH.LATCH1[1]);
|
||||
PIN_setOutputValue(pin_handle, D2, LH.LATCH1[2]);
|
||||
PIN_setOutputValue(pin_handle, D3, LH.LATCH1[3]);
|
||||
PIN_setOutputValue(pin_handle, D4, LH.LATCH1[4]);
|
||||
PIN_setOutputValue(pin_handle, D5, LH.LATCH1[5]);
|
||||
PIN_setOutputValue(pin_handle, D6, LH.LATCH1[6]);
|
||||
PIN_setOutputValue(pin_handle, D7, LH.LATCH1[7]);
|
||||
break;
|
||||
}
|
||||
case LOAD2: {
|
||||
PIN_setOutputValue(pin_handle, D0, LH.LATCH2[0]);
|
||||
PIN_setOutputValue(pin_handle, D1, LH.LATCH2[1]);
|
||||
PIN_setOutputValue(pin_handle, D2, LH.LATCH2[2]);
|
||||
PIN_setOutputValue(pin_handle, D3, LH.LATCH2[3]);
|
||||
PIN_setOutputValue(pin_handle, D4, LH.LATCH2[4]);
|
||||
PIN_setOutputValue(pin_handle, D5, LH.LATCH2[5]);
|
||||
PIN_setOutputValue(pin_handle, D6, LH.LATCH2[6]);
|
||||
PIN_setOutputValue(pin_handle, D7, LH.LATCH2[7]);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
PIN_setOutputValue(&ZM_rst, latch_num, 1); // Turn on latch
|
||||
// CPUdelay(10);
|
||||
PIN_setOutputValue(&ZM_rst, latch_num, 0); // Turn off latch
|
||||
remove_elite_pin();
|
||||
ELITE15_SPI_HOLD();
|
||||
}
|
||||
|
||||
static void Init_Elite15_PIN () {
|
||||
InitLH();
|
||||
add_elite_pin();
|
||||
|
||||
PIN_setOutputValue(pin_handle, D0, 0);
|
||||
PIN_setOutputValue(pin_handle, D1, 0);
|
||||
PIN_setOutputValue(pin_handle, D2, 0);
|
||||
PIN_setOutputValue(pin_handle, D3, 0);
|
||||
PIN_setOutputValue(pin_handle, D4, 0);
|
||||
PIN_setOutputValue(pin_handle, D5, 0);
|
||||
PIN_setOutputValue(pin_handle, D6, 0);
|
||||
PIN_setOutputValue(pin_handle, D7, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD1, 1);
|
||||
PIN_setOutputValue(pin_handle, LOAD2, 1);
|
||||
CPUdelay(10);
|
||||
PIN_setOutputValue(pin_handle, LOAD1, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD2, 0);
|
||||
|
||||
|
||||
PIN_setOutputValue(pin_handle, D0, 0);
|
||||
PIN_setOutputValue(pin_handle, D1, 0);
|
||||
PIN_setOutputValue(pin_handle, D2, 0);
|
||||
PIN_setOutputValue(pin_handle, D3, 0);
|
||||
PIN_setOutputValue(pin_handle, D4, 1);
|
||||
PIN_setOutputValue(pin_handle, D5, 1);
|
||||
PIN_setOutputValue(pin_handle, D6, 1);
|
||||
PIN_setOutputValue(pin_handle, D7, 1);
|
||||
CPUdelay(10);
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 0);
|
||||
|
||||
remove_elite_pin();
|
||||
|
||||
//// CPUdelay(10);
|
||||
// PIN_setOutputValue(&ZM_rst, latch_num, 0); // Turn off latch
|
||||
// remove_elite_pin();
|
||||
// ELITE15_SPI_HOLD();
|
||||
//}
|
||||
//
|
||||
//static void Init_Elite15_PIN () {
|
||||
// InitLH();
|
||||
// add_elite_pin();
|
||||
//
|
||||
// PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
// PIN_setOutputValue(pin_handle, LOAD1, 1);
|
||||
// PIN_setOutputValue(pin_handle, LOAD2, 1);
|
||||
// CPUdelay(10);
|
||||
// PIN_setOutputValue(pin_handle, D0, 0);
|
||||
// PIN_setOutputValue(pin_handle, D1, 0);
|
||||
// PIN_setOutputValue(pin_handle, D2, 0);
|
||||
@@ -232,15 +195,52 @@ static void Init_Elite15_PIN () {
|
||||
// PIN_setOutputValue(pin_handle, D5, 0);
|
||||
// PIN_setOutputValue(pin_handle, D6, 0);
|
||||
// PIN_setOutputValue(pin_handle, D7, 0);
|
||||
// CPUdelay(10);
|
||||
// PIN_setOutputValue(pin_handle, LOAD0, 0);
|
||||
// PIN_setOutputValue(pin_handle, LOAD1, 1);
|
||||
// PIN_setOutputValue(pin_handle, LOAD2, 1);
|
||||
// CPUdelay(10);
|
||||
// PIN_setOutputValue(pin_handle, LOAD1, 0);
|
||||
// PIN_setOutputValue(pin_handle, LOAD2, 0);
|
||||
//
|
||||
//
|
||||
// PIN_setOutputValue(pin_handle, D0, 0);
|
||||
// PIN_setOutputValue(pin_handle, D1, 0);
|
||||
// PIN_setOutputValue(pin_handle, D2, 0);
|
||||
// PIN_setOutputValue(pin_handle, D3, 0);
|
||||
// PIN_setOutputValue(pin_handle, D4, 1);
|
||||
// PIN_setOutputValue(pin_handle, D5, 1);
|
||||
// PIN_setOutputValue(pin_handle, D6, 1);
|
||||
// PIN_setOutputValue(pin_handle, D7, 1);
|
||||
// CPUdelay(10);
|
||||
// PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
// PIN_setOutputValue(pin_handle, LOAD0, 0);
|
||||
//
|
||||
// remove_elite_pin();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
//
|
||||
//// InitLH();
|
||||
//// add_elite_pin();
|
||||
////
|
||||
//// PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
//// PIN_setOutputValue(pin_handle, LOAD1, 1);
|
||||
//// PIN_setOutputValue(pin_handle, LOAD2, 1);
|
||||
//// CPUdelay(10);
|
||||
//// PIN_setOutputValue(pin_handle, D0, 0);
|
||||
//// PIN_setOutputValue(pin_handle, D1, 0);
|
||||
//// PIN_setOutputValue(pin_handle, D2, 0);
|
||||
//// PIN_setOutputValue(pin_handle, D3, 0);
|
||||
//// PIN_setOutputValue(pin_handle, D4, 0);
|
||||
//// PIN_setOutputValue(pin_handle, D5, 0);
|
||||
//// PIN_setOutputValue(pin_handle, D6, 0);
|
||||
//// PIN_setOutputValue(pin_handle, D7, 0);
|
||||
//// CPUdelay(10);
|
||||
//// PIN_setOutputValue(pin_handle, LOAD0, 0);
|
||||
//// PIN_setOutputValue(pin_handle, LOAD1, 0);
|
||||
//// PIN_setOutputValue(pin_handle, LOAD2, 0);
|
||||
////
|
||||
//// remove_elite_pin();
|
||||
//}
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//#endif
|
||||
|
||||
+713
-33
@@ -1,3 +1,4 @@
|
||||
#include <math.h>
|
||||
|
||||
#ifndef EliteADC
|
||||
#define EliteADC
|
||||
@@ -5,13 +6,14 @@
|
||||
#include "Elite_PIN.h"
|
||||
#include "EliteSPI.h"
|
||||
#include "EliteNotify.h"
|
||||
#include "eis_cali_table.h"
|
||||
|
||||
// Elite ADC macro
|
||||
// ADC command, Elite will use these cmd to control ADC
|
||||
#define CMD_CURRENT_MEASURE 0xC5
|
||||
#define CMD_VOLT_MEASURE 0xD5
|
||||
#define CMD_DAC_MEASURE 0xE5
|
||||
#define CMD_BATTERY_MEASURE 0xF1
|
||||
#define CMD_CURRENT_MEASURE 0xC5 //0b11000101
|
||||
#define CMD_VOLT_MEASURE 0xD5 //0b11010101
|
||||
#define CMD_DAC_MEASURE 0xE5 //0b11100101
|
||||
#define CMD_BATTERY_MEASURE 0xF1 //0b11110001
|
||||
|
||||
// controller command, these are command from control box
|
||||
#define ADC_CH_CURRENT 0x00
|
||||
@@ -84,39 +86,39 @@ static void CAL_ADC_write(uint8_t ADCin) {
|
||||
static void IinADCGainControl(uint8_t IinADCLevel){
|
||||
if(IinADCLevel == 0){
|
||||
// ADC gain level = 0, using 3M resister
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 0);
|
||||
PIN15_setOutputValue(Turnon_I_MID, 0);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_LARGE, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_MID, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_SMALL, 0);
|
||||
}
|
||||
else if(IinADCLevel == 1){
|
||||
// ADC gain level = 1, using 100K resister
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 0);
|
||||
PIN15_setOutputValue(Turnon_I_MID, 0);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 1);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_LARGE, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_MID, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_SMALL, 1);
|
||||
}
|
||||
else if(IinADCLevel == 2){
|
||||
// ADC gain level = 2, using 3K resister
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 0);
|
||||
PIN15_setOutputValue(Turnon_I_MID, 1);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_LARGE, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_MID, 1);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_SMALL, 0);
|
||||
}
|
||||
else if(IinADCLevel == 3){
|
||||
// ADC gain level = 3, using 100R resistor
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 1);
|
||||
PIN15_setOutputValue(Turnon_I_MID, 0);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_LARGE, 1);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_MID, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_SMALL, 0);
|
||||
}
|
||||
else if(IinADCLevel == 4){
|
||||
// ADC gain level = 3, auto gain (using 100R resister)
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 1);
|
||||
PIN15_setOutputValue(Turnon_I_MID, 0);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_LARGE, 1);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_MID, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_SMALL, 0);
|
||||
}
|
||||
else{
|
||||
// default using 100R resister
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 1);
|
||||
PIN15_setOutputValue(Turnon_I_MID, 0);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_LARGE, 1);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_MID, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_I_SMALL, 0);
|
||||
}
|
||||
|
||||
if(IinADCLevel == 0 || IinADCLevel == 1 || IinADCLevel == 2 || IinADCLevel == 3){
|
||||
@@ -130,28 +132,28 @@ static void IinADCGainControl(uint8_t IinADCLevel){
|
||||
static void VinADCGainCtrl(uint8_t VinADCLevel){
|
||||
if(VinADCLevel == 0){
|
||||
// Vin ADC gain level = 0, using 1M resister
|
||||
PIN15_setOutputValue(Turnon_V_SMALL, 0);
|
||||
PIN15_setOutputValue(Turnon_V_MID, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_V_SMALL, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_V_MID, 0);
|
||||
}
|
||||
else if(VinADCLevel == 1){
|
||||
// Vin ADC gain level = 1, using 30K resister
|
||||
PIN15_setOutputValue(Turnon_V_SMALL, 0);
|
||||
PIN15_setOutputValue(Turnon_V_MID, 1);
|
||||
PIN_setOutputValue(pin_handle, Turnon_V_SMALL, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_V_MID, 1);
|
||||
}
|
||||
else if(VinADCLevel == 2){
|
||||
// Vin ADC gain level = 2, using 1K resister
|
||||
PIN15_setOutputValue(Turnon_V_SMALL, 1);
|
||||
PIN15_setOutputValue(Turnon_V_MID, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_V_SMALL, 1);
|
||||
PIN_setOutputValue(pin_handle, Turnon_V_MID, 0);
|
||||
}
|
||||
else if(VinADCLevel == 3){
|
||||
// Vin ADC gain level = 3, auto gain (using 1K resister)
|
||||
PIN15_setOutputValue(Turnon_V_SMALL, 1);
|
||||
PIN15_setOutputValue(Turnon_V_MID, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_V_SMALL, 1);
|
||||
PIN_setOutputValue(pin_handle, Turnon_V_MID, 0);
|
||||
}
|
||||
else{
|
||||
// default using 1K resister
|
||||
PIN15_setOutputValue(Turnon_V_SMALL, 1);
|
||||
PIN15_setOutputValue(Turnon_V_MID, 0);
|
||||
PIN_setOutputValue(pin_handle, Turnon_V_SMALL, 1);
|
||||
PIN_setOutputValue(pin_handle, Turnon_V_MID, 0);
|
||||
}
|
||||
|
||||
if(VinADCLevel == 0 || VinADCLevel == 1 || VinADCLevel == 2){
|
||||
@@ -162,6 +164,114 @@ static void VinADCGainCtrl(uint8_t VinADCLevel){
|
||||
record_flag = false;
|
||||
}
|
||||
|
||||
static void HSTIAGainCtrl(uint8_t HSTIALevel) {
|
||||
/* HSRTIACON[12:5] = CTIACON, disconnect;
|
||||
HSRTIACON[4] = TIASW6CON, diode not in parallel with RTIA;
|
||||
HSRTIACON[3:0] = RTIA */
|
||||
uint32_t reg;
|
||||
uint8_t data;
|
||||
|
||||
reg = 0x00001000;
|
||||
|
||||
if (HSTIALevel == HSRTIA_160K) {
|
||||
// ADC gain level = 0, using 160k resister
|
||||
data = RTIA160k;
|
||||
}
|
||||
else if (HSTIALevel == HSRTIA_20K) {
|
||||
// ADC gain level = 1, using 20k resister
|
||||
data = RTIA20k;
|
||||
}
|
||||
else if (HSTIALevel == HSRTIA_5K) {
|
||||
// ADC gain level = 2, using 5k resister
|
||||
data = RTIA5k;
|
||||
}
|
||||
else if (HSTIALevel == HSRTIA_200R) {
|
||||
// ADC gain level = 3, using 200R resister
|
||||
data = RTIA200R;
|
||||
}
|
||||
else if (HSTIALevel == HSRTIA_GAIN_AUTO) {
|
||||
data = RTIA200R;
|
||||
}
|
||||
|
||||
|
||||
reg = (reg) | ((uint32_t)(data));
|
||||
select_REG(HSRTIACON);
|
||||
w32_REG(reg);
|
||||
}
|
||||
|
||||
static void HSTIAGainCtrl2(uint8_t ret) {
|
||||
uint32_t code;
|
||||
|
||||
select_REG(HSRTIACON);
|
||||
w32_REG(0x00000200);
|
||||
code = r32_REG();
|
||||
|
||||
code = (code & (~15)) | (ret);
|
||||
w32_REG(code);
|
||||
|
||||
record_flag = false;
|
||||
}
|
||||
|
||||
static void LPTIAGainCtrl(uint8_t LPTIALevel){
|
||||
/* LPTIACON0[15:13] = RLPF, disconnect low pass filter;
|
||||
LPTIACON0[12:10] = RLOAD, set at 0R;
|
||||
LPTIACON0[9:5] = RTIA;
|
||||
LPTIACON0[4:3] = IBOOST, High current mode; */
|
||||
// uint32_t code;
|
||||
// uint8_t data;
|
||||
//
|
||||
// code = 0x00000038;
|
||||
//
|
||||
// if (LPTIALevel == LPRTIA_512K) {
|
||||
// data = 26; //512k
|
||||
// }
|
||||
// else if (LPTIALevel == LPRTIA_12K) {
|
||||
// data = 9; //12K
|
||||
// }
|
||||
// else if (LPTIALevel == LPRTIA_4K) {
|
||||
// data = 5; //4K
|
||||
// }
|
||||
// else if (LPTIALevel == LPRTIA_200R) {
|
||||
// data = 1; //200R
|
||||
// }
|
||||
// else if (LPTIALevel == LPRTIA_GAIN_AUTO) {
|
||||
// data = 1;
|
||||
// }
|
||||
//
|
||||
// code = (code) | ((((uint32_t)(data)) << 5) & 0x000003E0);
|
||||
// select_REG(LPTIACON0); //20EC
|
||||
// w32_REG(code);
|
||||
|
||||
uint32_t code;
|
||||
uint16_t data;
|
||||
|
||||
|
||||
select_REG(0x20EC); //LPTIACON0
|
||||
code = r32_REG();
|
||||
|
||||
if (LPTIALevel == LPRTIA_200R) {
|
||||
data = 1; //200R
|
||||
}
|
||||
else if (LPTIALevel == LPRTIA_4K) {
|
||||
data = 5; //4K
|
||||
}
|
||||
else if (LPTIALevel == LPRTIA_12K) {
|
||||
data = 9; //12K
|
||||
}
|
||||
else if (LPTIALevel == LPRTIA_512K) {
|
||||
data = 26; //512K
|
||||
}
|
||||
else if (LPTIALevel == LPRTIA_200R) {
|
||||
data = 1;
|
||||
}
|
||||
|
||||
code = (code & (~(31 << 5))) | (data << 5);
|
||||
select_REG(0x20EC); //LPTIACON0
|
||||
w32_REG(code);
|
||||
|
||||
record_flag = false;
|
||||
}
|
||||
|
||||
static void ADCChannelSelect(uint8_t ADCChannel){
|
||||
// set ADC parameter
|
||||
// 0xC1~F1 = reading AIN0~AIN3. Using FSR+-6V, resolution = 187.5uV
|
||||
@@ -210,7 +320,7 @@ static void ReadADCIin(uint8_t *buf){
|
||||
|
||||
static void ReadADCVin(uint8_t *buf){
|
||||
// Read data twice since the first data we get is previous data
|
||||
|
||||
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
ADCChannelSelect(ADC_CH_VOLT);
|
||||
ADC_read(buf);
|
||||
|
||||
@@ -236,6 +346,42 @@ static void ReadADCBat(uint8_t *buf){
|
||||
ADC_read(buf);
|
||||
}
|
||||
|
||||
static int32_t ReadRawADC() {
|
||||
select_REG(ADCDAT);
|
||||
return r32_REG();
|
||||
}
|
||||
|
||||
static int32_t ReadRealZ() {
|
||||
select_REG(DFTREAL);
|
||||
return r32_REG();
|
||||
}
|
||||
|
||||
static int32_t ReadImagZ() {
|
||||
select_REG(DFTIMAG);
|
||||
return r32_REG();
|
||||
}
|
||||
|
||||
static uint32_t ReadSINC2() {
|
||||
select_REG(0x2080);
|
||||
return r32_REG();
|
||||
}
|
||||
|
||||
static uint32_t ReadFreq() {
|
||||
static uint64_t freqDAC;
|
||||
static uint32_t ret;
|
||||
select_REG(WGFCW);
|
||||
freqDAC = r32_REG();
|
||||
ret = User2Freq(freqDAC); //freeDAC * 16M / 2^30
|
||||
|
||||
return ret; //this gives the freq in mHz
|
||||
}
|
||||
|
||||
static int32_t ADCCode2Volt(uint32_t code) {
|
||||
int32_t volt;
|
||||
volt = (1811 * 1008 * (int32_t)(code - 32768)) / 32768;
|
||||
return volt; //uV
|
||||
}
|
||||
|
||||
/* for Elite1.5-re */
|
||||
// Iin theoretical boundary <2.67, 1.89~80, 63~2600, >1900 (uA)
|
||||
/* Old boundary
|
||||
@@ -259,6 +405,21 @@ static void ReadADCBat(uint8_t *buf){
|
||||
#define VIN_GAIN_MID1_BOUNDARY2 300000 // 300 mV = 300,000,000 nV
|
||||
#define VIN_GAIN_LARGE_BOUNDARY 250000 // 250 mV = 250,000,000 nV
|
||||
|
||||
#define LPTIA_GAIN_SMALL_BOUNDARY 1500 // 1.5 uA = 1,500,000 pA
|
||||
#define LPTIA_GAIN_MID1_BOUNDARY1 1000 // 1 uA = 1,000,000 pA
|
||||
#define LPTIA_GAIN_MID1_BOUNDARY2 60000 // 60 uA = 60,000,000 pA
|
||||
#define LPTIA_GAIN_MID2_BOUNDARY1 40000 // 40 uA = 40,000,000 pA
|
||||
#define LPTIA_GAIN_MID2_BOUNDARY2 175000 // 175 uA = 175,000 nA
|
||||
#define LPTIA_GAIN_LARGE_BOUNDARY 120000 // 120 uA = 120,000 nA
|
||||
|
||||
// Current Squared
|
||||
#define HSTIA_GAIN_SMALL_BOUNDARY 4500 // 4.5 uA = 4,500,000 pA
|
||||
#define HSTIA_GAIN_MID1_BOUNDARY1 3600 // 3 uA = 3,000,000 pA
|
||||
#define HSTIA_GAIN_MID1_BOUNDARY2 40000 // 36 uA = 36,000,000 pA
|
||||
#define HSTIA_GAIN_MID2_BOUNDARY1 30000 // 25 uA = 25,000,000 pA
|
||||
#define HSTIA_GAIN_MID2_BOUNDARY2 166000 // 166 uA = 166,000 nA
|
||||
#define HSTIA_GAIN_LARGE_BOUNDARY 133000 // 133 uA = 133,000 nA
|
||||
|
||||
static int32_t read_cali_Iin(uint8_t *buf){
|
||||
int32_t RealCurrent = 0;
|
||||
|
||||
@@ -549,4 +710,523 @@ static void AutoGainChangeVin(int32_t RealVin){
|
||||
}
|
||||
}
|
||||
|
||||
//EIS Function//
|
||||
static int32_t read_LPTIA_Iin(){
|
||||
static int32_t dftdat, Iin;
|
||||
dftdat = neg_18bit(ReadRealZ()) + 3929;
|
||||
|
||||
if (instru.ADCGainLv == 0) {
|
||||
Iin = -(0.867 * dftdat * 1000 + 256) / 512.1 / 0.033;
|
||||
// res = rawIin / 0.033;
|
||||
}
|
||||
else if (instru.ADCGainLv == 1) {
|
||||
Iin = - ((dftdat + dftdat * 0.086) * 1000 + 6)/ 12.1 / 2.63;
|
||||
}
|
||||
else if (instru.ADCGainLv == 2) {
|
||||
Iin = - ((dftdat + dftdat * 0.04) * 1000 + 2) / 4.1 / 6.99;
|
||||
// res = rawIin / 5.43;
|
||||
}
|
||||
else if (instru.ADCGainLv == 3 || instru.ADCGainLv == 4) {
|
||||
Iin = - (dftdat * 1000 + 105) / 210 * 9.23;
|
||||
// Iin = rawIin / 0.102;
|
||||
}
|
||||
// InputNotify(NOTIFY_VOLT, dftdat);
|
||||
InputNotify(NOTIFY_CURRENT, Iin);
|
||||
InputNotify(NOTIFY_IMPEDANCE, instru.ADCGainLv);
|
||||
return Iin;
|
||||
}
|
||||
|
||||
static uint64_t read_HSTIA_Iin(){
|
||||
uint32_t originalDFT, RealCurrent;
|
||||
uint64_t correctedDFT;
|
||||
|
||||
instru.real = neg_18bit(ReadRealZ());
|
||||
instru.imag = neg_18bit(ReadImagZ());
|
||||
|
||||
originalDFT = sqrt(instru.imag * instru.imag + instru.real * instru.real);
|
||||
correctedDFT = (uint64_t)originalDFT * (10000 + ((uint64_t)User2Freq(instru.fset) * (uint64_t)User2Freq(instru.fset)) / ((uint64_t)CaliTable.CutoffFreq * (uint64_t)CaliTable.CutoffFreq)) / 10000;
|
||||
|
||||
if (instru.ADCGainLv == 3) {
|
||||
RealCurrent = (uint64_t)CaliTable.Lv[instru.ADCGainLv].HSRTIA_a * exp((uint64_t)CaliTable.Lv[instru.ADCGainLv].HSRTIA_b * correctedDFT / 1e6) + (uint64_t)CaliTable.Lv[instru.ADCGainLv].HSRTIA_c * exp((uint64_t)CaliTable.Lv[instru.ADCGainLv].HSRTIA_d * correctedDFT / 1e6) / 1e5;
|
||||
} else {
|
||||
RealCurrent = ((int64_t)correctedDFT * (int64_t)correctedDFT * CaliTable.Lv[instru.ADCGainLv].HSRTIA_a + (int64_t)correctedDFT * CaliTable.Lv[instru.ADCGainLv].HSRTIA_b + (int64_t)CaliTable.Lv[instru.ADCGainLv].HSRTIA_c * 1e4) / 1e8;
|
||||
}
|
||||
return RealCurrent;
|
||||
}
|
||||
|
||||
static void AutoChangeLPTIAGain(int32_t RealCurrent){
|
||||
if(instru.ADCGainLv == LPRTIA_200R){
|
||||
if(RealCurrent < LPTIA_GAIN_LARGE_BOUNDARY && RealCurrent > -1*LPTIA_GAIN_LARGE_BOUNDARY){
|
||||
// switch to 1 level current(small)
|
||||
if (RealCurrent < LPTIA_GAIN_MID1_BOUNDARY1 && RealCurrent > -1*LPTIA_GAIN_MID1_BOUNDARY1){
|
||||
I_GAIN_3M_counter++;
|
||||
if(I_GAIN_3M_counter > 2){
|
||||
instru.ADCGainLv = LPRTIA_512K;
|
||||
LPTIAGainCtrl(instru.ADCGainLv);
|
||||
I_GAIN_3M_counter = 0;
|
||||
}
|
||||
}
|
||||
// switch to 2 level current
|
||||
else if (RealCurrent < LPTIA_GAIN_MID2_BOUNDARY1 && RealCurrent > -1*LPTIA_GAIN_MID2_BOUNDARY1){
|
||||
I_GAIN_100K_counter++;
|
||||
if(I_GAIN_100K_counter > 2){
|
||||
instru.ADCGainLv = LPRTIA_12K;
|
||||
LPTIAGainCtrl(instru.ADCGainLv);
|
||||
I_GAIN_100K_counter = 0;
|
||||
}
|
||||
}
|
||||
// switch to 3 level current
|
||||
else{
|
||||
I_GAIN_3K_counter++;
|
||||
if(I_GAIN_3K_counter > 2){
|
||||
instru.ADCGainLv = LPRTIA_4K;
|
||||
LPTIAGainCtrl(instru.ADCGainLv);
|
||||
I_GAIN_3K_counter = 0;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(I_GAIN_3K_counter > 0){
|
||||
I_GAIN_3K_counter--;
|
||||
}
|
||||
if(I_GAIN_100K_counter > 0){
|
||||
I_GAIN_100K_counter--;
|
||||
}
|
||||
if(I_GAIN_3M_counter > 0){
|
||||
I_GAIN_3M_counter--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(instru.ADCGainLv == LPRTIA_4K){
|
||||
// switch to 4 level current(large)
|
||||
if(RealCurrent > LPTIA_GAIN_MID2_BOUNDARY2 || RealCurrent < -1*LPTIA_GAIN_MID2_BOUNDARY2){
|
||||
I_GAIN_100R_counter++;
|
||||
if(I_GAIN_100R_counter > 2){
|
||||
instru.ADCGainLv = LPRTIA_200R;
|
||||
LPTIAGainCtrl(instru.ADCGainLv);
|
||||
I_GAIN_100R_counter = 0;
|
||||
}
|
||||
}
|
||||
else if (RealCurrent < LPTIA_GAIN_MID2_BOUNDARY1 && RealCurrent > -1*LPTIA_GAIN_MID2_BOUNDARY1){
|
||||
// switch to 1 level current(small)
|
||||
if(RealCurrent < LPTIA_GAIN_MID1_BOUNDARY1 && RealCurrent > -1*LPTIA_GAIN_MID1_BOUNDARY1){
|
||||
I_GAIN_3M_counter++;
|
||||
if(I_GAIN_3M_counter > 2){
|
||||
instru.ADCGainLv = LPRTIA_512K;
|
||||
LPTIAGainCtrl(instru.ADCGainLv);
|
||||
I_GAIN_3M_counter = 0;
|
||||
}
|
||||
}
|
||||
// switch to 2 level current
|
||||
else{
|
||||
I_GAIN_100K_counter++;
|
||||
if(I_GAIN_100K_counter > 2){
|
||||
instru.ADCGainLv = LPRTIA_12K;
|
||||
LPTIAGainCtrl(instru.ADCGainLv);
|
||||
I_GAIN_100K_counter = 0;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(I_GAIN_100R_counter > 0){
|
||||
I_GAIN_100R_counter--;
|
||||
}
|
||||
if(I_GAIN_100K_counter > 0){
|
||||
I_GAIN_100K_counter--;
|
||||
}
|
||||
if(I_GAIN_3M_counter > 0){
|
||||
I_GAIN_3M_counter--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(instru.ADCGainLv == LPRTIA_12K){
|
||||
// switch to 1 level current(small)
|
||||
if(RealCurrent < LPTIA_GAIN_MID1_BOUNDARY1 && RealCurrent > -1*LPTIA_GAIN_MID1_BOUNDARY1){
|
||||
I_GAIN_3M_counter++;
|
||||
if(I_GAIN_3M_counter > 2){
|
||||
instru.ADCGainLv = LPRTIA_512K;
|
||||
LPTIAGainCtrl(instru.ADCGainLv);
|
||||
I_GAIN_3M_counter = 0;
|
||||
}
|
||||
}
|
||||
else if (RealCurrent > LPTIA_GAIN_MID1_BOUNDARY2 || RealCurrent < -1*LPTIA_GAIN_MID1_BOUNDARY2){
|
||||
// switch to 4 level current(large)
|
||||
if(RealCurrent > LPTIA_GAIN_MID2_BOUNDARY2 || RealCurrent < -1*LPTIA_GAIN_MID2_BOUNDARY2){
|
||||
I_GAIN_100R_counter++;
|
||||
if(I_GAIN_100R_counter > 2){
|
||||
instru.ADCGainLv = LPRTIA_200R;
|
||||
LPTIAGainCtrl(instru.ADCGainLv);
|
||||
I_GAIN_100R_counter = 0;
|
||||
}
|
||||
}
|
||||
// switch to 3 level current
|
||||
else{
|
||||
I_GAIN_3K_counter++;
|
||||
if(I_GAIN_3K_counter > 2){
|
||||
instru.ADCGainLv = LPRTIA_4K;
|
||||
LPTIAGainCtrl(instru.ADCGainLv);
|
||||
I_GAIN_3K_counter = 0;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(I_GAIN_100R_counter > 0){
|
||||
I_GAIN_100R_counter--;
|
||||
}
|
||||
if(I_GAIN_3K_counter > 0){
|
||||
I_GAIN_3K_counter--;
|
||||
}
|
||||
if(I_GAIN_3M_counter > 0){
|
||||
I_GAIN_3M_counter--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(instru.ADCGainLv == LPRTIA_512K){
|
||||
if(RealCurrent > LPTIA_GAIN_SMALL_BOUNDARY || RealCurrent < -1*LPTIA_GAIN_SMALL_BOUNDARY){
|
||||
// switch to 4 level current(large)
|
||||
if(RealCurrent > LPTIA_GAIN_MID2_BOUNDARY2 || RealCurrent < -1*LPTIA_GAIN_MID2_BOUNDARY2){
|
||||
I_GAIN_100R_counter++;
|
||||
if(I_GAIN_100R_counter > 2){
|
||||
instru.ADCGainLv = LPRTIA_200R;
|
||||
LPTIAGainCtrl(instru.ADCGainLv);
|
||||
I_GAIN_100R_counter = 0;
|
||||
}
|
||||
}
|
||||
// switch to 3 level current
|
||||
else if(RealCurrent > LPTIA_GAIN_MID1_BOUNDARY2 || RealCurrent < -1*LPTIA_GAIN_MID1_BOUNDARY2){
|
||||
I_GAIN_3K_counter++;
|
||||
if(I_GAIN_3K_counter > 2){
|
||||
instru.ADCGainLv = LPRTIA_4K;
|
||||
LPTIAGainCtrl(instru.ADCGainLv);
|
||||
I_GAIN_3K_counter = 0;
|
||||
}
|
||||
}
|
||||
// switch to 2 level current
|
||||
else{
|
||||
I_GAIN_100K_counter++;
|
||||
if(I_GAIN_100K_counter > 2){
|
||||
instru.ADCGainLv = LPRTIA_12K;
|
||||
LPTIAGainCtrl(instru.ADCGainLv);
|
||||
I_GAIN_100K_counter = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
if(I_GAIN_100R_counter > 0){
|
||||
I_GAIN_100R_counter--;
|
||||
}
|
||||
if(I_GAIN_3K_counter > 0){
|
||||
I_GAIN_3K_counter--;
|
||||
}
|
||||
if(I_GAIN_100K_counter > 0){
|
||||
I_GAIN_100K_counter--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void AutoChangeHSTIAGain(uint64_t RealCurrent){
|
||||
if(instru.ADCGainLv == HSRTIA_200R){
|
||||
if(RealCurrent < HSTIA_GAIN_LARGE_BOUNDARY){
|
||||
// switch to 1 level current(small)
|
||||
if (RealCurrent < HSTIA_GAIN_MID1_BOUNDARY1){
|
||||
instru.ADCGainLv = HSRTIA_160K;
|
||||
HSTIAGainCtrl(instru.ADCGainLv);
|
||||
gainChange_flag = true;
|
||||
}
|
||||
// switch to 2 level current
|
||||
else if (RealCurrent < HSTIA_GAIN_MID2_BOUNDARY1){
|
||||
instru.ADCGainLv = HSRTIA_20K;
|
||||
HSTIAGainCtrl(instru.ADCGainLv);
|
||||
gainChange_flag = true;
|
||||
}
|
||||
// switch to 3 level current
|
||||
else{
|
||||
instru.ADCGainLv = HSRTIA_5K;
|
||||
HSTIAGainCtrl(instru.ADCGainLv);
|
||||
gainChange_flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(instru.ADCGainLv == HSRTIA_5K){
|
||||
// switch to 4 level current(large)
|
||||
if(RealCurrent > HSTIA_GAIN_MID2_BOUNDARY2){
|
||||
instru.ADCGainLv = HSRTIA_200R;
|
||||
HSTIAGainCtrl(instru.ADCGainLv);
|
||||
gainChange_flag = true;
|
||||
}
|
||||
else if (RealCurrent < HSTIA_GAIN_MID2_BOUNDARY1){
|
||||
// switch to 1 level current(small)
|
||||
if(RealCurrent < HSTIA_GAIN_MID1_BOUNDARY1){
|
||||
instru.ADCGainLv = HSRTIA_160K;
|
||||
HSTIAGainCtrl(instru.ADCGainLv);
|
||||
gainChange_flag = true;
|
||||
}
|
||||
// switch to 2 level current
|
||||
else{
|
||||
instru.ADCGainLv = HSRTIA_20K;
|
||||
HSTIAGainCtrl(instru.ADCGainLv);
|
||||
gainChange_flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(instru.ADCGainLv == HSRTIA_20K){
|
||||
// switch to 1 level current(small)
|
||||
if(RealCurrent < HSTIA_GAIN_MID1_BOUNDARY1){
|
||||
instru.ADCGainLv = HSRTIA_160K;
|
||||
HSTIAGainCtrl(instru.ADCGainLv);
|
||||
gainChange_flag = true;
|
||||
}
|
||||
else if (RealCurrent > HSTIA_GAIN_MID1_BOUNDARY2){
|
||||
// switch to 4 level current(large)
|
||||
if(RealCurrent > HSTIA_GAIN_MID2_BOUNDARY2){
|
||||
instru.ADCGainLv = HSRTIA_200R;
|
||||
HSTIAGainCtrl(instru.ADCGainLv);
|
||||
gainChange_flag = true;
|
||||
}
|
||||
// switch to 3 level current
|
||||
else{
|
||||
instru.ADCGainLv = HSRTIA_5K;
|
||||
HSTIAGainCtrl(instru.ADCGainLv);
|
||||
gainChange_flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(instru.ADCGainLv == HSRTIA_160K){
|
||||
if(RealCurrent > HSTIA_GAIN_SMALL_BOUNDARY){
|
||||
// switch to 4 level current(large)
|
||||
if(RealCurrent > HSTIA_GAIN_MID2_BOUNDARY2){
|
||||
instru.ADCGainLv = HSRTIA_200R;
|
||||
HSTIAGainCtrl(instru.ADCGainLv);
|
||||
gainChange_flag = true;
|
||||
}
|
||||
// switch to 3 level current
|
||||
else if(RealCurrent > HSTIA_GAIN_MID1_BOUNDARY2){
|
||||
instru.ADCGainLv = HSRTIA_5K;
|
||||
HSTIAGainCtrl(instru.ADCGainLv);
|
||||
gainChange_flag = true;
|
||||
}
|
||||
// switch to 2 level current
|
||||
else{
|
||||
instru.ADCGainLv = HSRTIA_20K;
|
||||
HSTIAGainCtrl(instru.ADCGainLv);
|
||||
gainChange_flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void SetAVG(uint8_t avg_num){
|
||||
uint32_t code;
|
||||
select_REG(0x2044); //ADCFILTERCON
|
||||
code = r32_REG();
|
||||
code = (code & (~(3 << 14))) | (avg_num << 14);
|
||||
w32_REG(code);
|
||||
}
|
||||
|
||||
static void EnAVG(uint8_t ret){
|
||||
uint32_t code;
|
||||
select_REG(0x2044);
|
||||
code = r32_REG();
|
||||
code = (code & (~(1 << 7))) | (ret << 7);
|
||||
w32_REG(code);
|
||||
}
|
||||
|
||||
static int32_t r_sinc2dat(){
|
||||
select_REG(0x2080);
|
||||
return r32_REG();
|
||||
}
|
||||
|
||||
static void SetCTIA(uint8_t ret){
|
||||
uint64_t code;
|
||||
select_REG(HSRTIACON);
|
||||
code = r32_REG();
|
||||
code = (code & (~(0x7F << 5))) | (ret << 5);
|
||||
w32_REG(code);
|
||||
}
|
||||
|
||||
static void EnDFTnADC(uint8_t ret){
|
||||
uint32_t code;
|
||||
select_REG(0x2000);
|
||||
code = r32_REG();
|
||||
code = (code & (~0x00008100)) | (ret << 15) | (ret << 8);
|
||||
w32_REG(code);
|
||||
}
|
||||
|
||||
static void SetADCDataRate(uint8_t dataRate){ //1: 800k | 0: 1.6M
|
||||
uint32_t code;
|
||||
select_REG(0x2044); //0x2044
|
||||
code = r32_REG();
|
||||
code = (code & (~1)) | (dataRate);
|
||||
w32_REG(code);
|
||||
}
|
||||
|
||||
static void SelDFTin(uint8_t ret){ // 1: SINC3 | 2: raw | 3: SINC2
|
||||
uint32_t code;
|
||||
select_REG(0x20D0);
|
||||
code = r32_REG();
|
||||
code = (code & (~(3 << 20))) | (ret << 20);
|
||||
w32_REG(code);
|
||||
}
|
||||
|
||||
static void BpNotch(uint8_t ret){ // 1: bypass notch
|
||||
uint32_t code;
|
||||
select_REG(0x2044);
|
||||
code = r32_REG();
|
||||
code = (code & (~(1 << 4))) | (!ret << 4);
|
||||
w32_REG(code);
|
||||
}
|
||||
|
||||
static void BpSINC3(uint8_t ret){ // 1: bypass sinc3
|
||||
uint32_t code;
|
||||
select_REG(0x2044);
|
||||
code = r32_REG();
|
||||
code = (code & (~(1 << 6))) | (ret << 6);
|
||||
w32_REG(code);
|
||||
}
|
||||
|
||||
static void EnNotch(uint8_t ret){
|
||||
uint32_t code;
|
||||
select_REG(0x2000);
|
||||
code = r32_REG();
|
||||
code = (code & (~(1 << 16))) | (ret << 16);
|
||||
w32_REG(code);
|
||||
}
|
||||
|
||||
static void SetSinc3OSR(uint8_t osr){ //0, 1, 2, 3
|
||||
uint32_t code;
|
||||
select_REG(0x2044); //0x2044
|
||||
code = r32_REG();
|
||||
code = (code & (~(3 << 12))) | (osr << 12);
|
||||
w32_REG(code);
|
||||
}
|
||||
|
||||
static void SetSinc2OSR(uint8_t osr){ //0~11 2^i
|
||||
uint32_t code;
|
||||
select_REG(0x2044); //0x2044
|
||||
code = r32_REG();
|
||||
code = (code & (~(15 << 8))) | (osr << 8);
|
||||
w32_REG(code);
|
||||
}
|
||||
|
||||
static void SetDFTNUM(uint8_t dft_num){
|
||||
uint32_t code;
|
||||
select_REG(0x20D0); //20D0
|
||||
code = r32_REG();
|
||||
code = (code & (~(15 << 4))) | (dft_num << 4);
|
||||
w32_REG(code);
|
||||
}
|
||||
|
||||
static void SetSamplingTime(uint32_t freq){
|
||||
// 10000 Hz
|
||||
if (freq >= 1000000 && instru.settingIndex != 1) {
|
||||
SelDFTin(1);
|
||||
BpSINC3(1);
|
||||
SetADCDataRate(ADC1M6sps);
|
||||
SetDFTNUM(DFTNUM16384);
|
||||
instru.settingIndex = 1;
|
||||
}
|
||||
|
||||
// 9999.99 ~ 1000Hz
|
||||
else if (freq >= 100000 && freq < 1000000 && instru.settingIndex != 2) {
|
||||
SelDFTin(1);
|
||||
BpSINC3(0);
|
||||
SetADCDataRate(ADC1M6sps);
|
||||
SetSinc3OSR(Sinc3OSR4);
|
||||
SetDFTNUM(DFTNUM8192);
|
||||
|
||||
// select_REG(0x2044); //0x2044
|
||||
// w32_REG(0x00001010); //ADC data rate = 1.6MHz | SINC3 4
|
||||
// select_REG(0x20D0); //20D0
|
||||
// w32_REG(0x001000B1); //takes SINC3 | DFTNUM = 8192
|
||||
instru.settingIndex = 2;
|
||||
}
|
||||
|
||||
// 999.99 ~ 100Hz
|
||||
else if (freq >= 10000 && freq < 100000 && instru.settingIndex != 3) {
|
||||
SelDFTin(1);
|
||||
BpSINC3(0);
|
||||
SetADCDataRate(ADC800Ksps);
|
||||
SetSinc3OSR(Sinc3OSR5);
|
||||
SetDFTNUM(DFTNUM16384);
|
||||
// SetCTIA(0); //1pF
|
||||
|
||||
// select_REG(0x2044); //0x2044
|
||||
// w32_REG(0x00000011); //ADC data rate = 800KHz | SINC3 5
|
||||
// select_REG(0x20D0); //20D0
|
||||
// w32_REG(0x001000C1); //takes SINC3 | DFTNUM = 16384
|
||||
instru.settingIndex = 3;
|
||||
}
|
||||
|
||||
// 99.99 ~ 10Hz
|
||||
else if (freq >= 1000 && freq < 10000 && instru.settingIndex != 4) {
|
||||
SelDFTin(0);
|
||||
BpSINC3(0);
|
||||
SetADCDataRate(ADC800Ksps);
|
||||
SetSinc2OSR(Sinc2OSR178);
|
||||
SetSinc3OSR(Sinc3OSR5);
|
||||
SetDFTNUM(DFTNUM1024);
|
||||
// SetCTIA(0); //1pF
|
||||
|
||||
// select_REG(0x2044); //0x2044
|
||||
// w32_REG(0x00000311); //ADC data rate = 800KHz | SINC2 89 | SINC3 5
|
||||
// select_REG(0x20D0); //20D0
|
||||
// w32_REG(0x00000091); //takes sinc2 | DFTNUM = 2048
|
||||
instru.settingIndex = 4;
|
||||
}
|
||||
|
||||
// 9.99 ~ 1Hz
|
||||
else if (freq >= 100 && freq < 1000 && instru.settingIndex != 5) {
|
||||
SelDFTin(0);
|
||||
BpSINC3(0);
|
||||
SetADCDataRate(ADC800Ksps);
|
||||
SetSinc2OSR(Sinc2OSR889);
|
||||
SetSinc3OSR(Sinc3OSR5);
|
||||
SetDFTNUM(DFTNUM1024);
|
||||
// SetCTIA(0); //1pF
|
||||
|
||||
// select_REG(0x2044); //0x2044
|
||||
// w32_REG(0x00000911); //ADC data rate = 800KHz | SINC2 889 | SINC3 5
|
||||
// select_REG(0x20D0); //20D0
|
||||
// w32_REG(0x00000081); //takes sinc2 | DFTNUM = 1024
|
||||
instru.settingIndex = 5;
|
||||
}
|
||||
|
||||
// 0.99 ~ 0.1Hz
|
||||
else if (freq >= 10 && freq < 100 && instru.settingIndex != 6) {
|
||||
// select_REG(0x2044);
|
||||
// w32_REG(0x00000511); //ADC data rate = 800KHz | SINC2 533 | SINC3 5
|
||||
// select_REG(0x20D0);
|
||||
// w32_REG(0x000000C1); //takes sinc2 | DFTNUM = 16384
|
||||
|
||||
SelDFTin(0);
|
||||
BpSINC3(0);
|
||||
SetADCDataRate(ADC800Ksps);
|
||||
SetSinc2OSR(Sinc2OSR1333);
|
||||
SetSinc3OSR(Sinc3OSR2);
|
||||
SetDFTNUM(DFTNUM16384);
|
||||
// SetCTIA(0); //1pF
|
||||
instru.settingIndex = 6;
|
||||
}
|
||||
|
||||
// 0.015Hz | 136s
|
||||
else if (freq >= 1 && freq < 10 && instru.settingIndex != 7) {
|
||||
// select_REG(0x2044);
|
||||
// w32_REG(0x00000B11); //ADC data rate = 800KHz | SINC2 1333 | SINC3 5
|
||||
// select_REG(0x20D0);
|
||||
// w32_REG(0x000000C1); //takes sinc2 | DFTNUM = 16384
|
||||
|
||||
SelDFTin(0);
|
||||
BpSINC3(0);
|
||||
SetADCDataRate(ADC800Ksps);
|
||||
SetSinc2OSR(Sinc2OSR1333);
|
||||
SetSinc3OSR(Sinc3OSR5);
|
||||
SetDFTNUM(DFTNUM16384);
|
||||
SetCTIA(0); //1pF
|
||||
instru.settingIndex = 7;
|
||||
}
|
||||
}
|
||||
|
||||
//EIS function//
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
|
||||
#ifndef ELITECCMODE
|
||||
#define ELITECCMODE
|
||||
|
||||
#define Vset instru.Vset
|
||||
#define DELTAVOLTMAX 2000000 //2000000 = 10mV
|
||||
|
||||
/* Transform setting CC into IUC
|
||||
*
|
||||
* User code in CC mode : 0 ~ 3000000
|
||||
* Real current value : -15.00000 ~ 15.00000 mA
|
||||
* => user code = 1500000 mapping to 0.00000 mA
|
||||
*/
|
||||
static void cc_vscan(void)
|
||||
{
|
||||
struct wm_cc_ctx_t *cc = (struct wm_cc_ctx_t *)wm_get();
|
||||
struct wm_meas_t *m = &cc->measure;
|
||||
uint16_t divisionRate;
|
||||
int32_t deltaI;
|
||||
int32_t deltaV;
|
||||
int32_t Iin;
|
||||
int32_t Vin;
|
||||
|
||||
if (vscanReset) {
|
||||
Vset = 0;
|
||||
|
||||
if (cc->_charge == 0) {
|
||||
cc->_Iset = instru.constantCurrent * 200 * (-1);
|
||||
//[50pA] //controller UI 15000uA => Elite 1500000 => 1500000 * 10 * 1000 / 50 [50pA];
|
||||
}
|
||||
|
||||
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
|
||||
Vin = m->_measureVin * 200; //[5nV]
|
||||
|
||||
Vset = Vin + cc->_Iset / 20 ; //[5nV]
|
||||
|
||||
if (Vset >= 1100000000) { // 5.5V
|
||||
Vset = 1100000000;
|
||||
} else if (Vset <= -1000000000) { //-5V
|
||||
Vset = -1000000000;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vscanReset) {
|
||||
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
|
||||
deltaI = Iin - cc->_Iset;
|
||||
|
||||
if (deltaI > 2000000 || deltaI < -2000000) { //100uA
|
||||
divisionRate = 1;
|
||||
} else {
|
||||
divisionRate = 20;
|
||||
}
|
||||
|
||||
deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
|
||||
|
||||
if (deltaV > DELTAVOLTMAX) { //2000000 = 10mV
|
||||
deltaV = DELTAVOLTMAX;
|
||||
} else if (deltaV < (-DELTAVOLTMAX)) {
|
||||
deltaV = (-DELTAVOLTMAX);
|
||||
}
|
||||
|
||||
Vset = Vset + deltaV; //[5nV]
|
||||
|
||||
if (Vset >= 1100000000) { // 5.5V
|
||||
Vset = 1100000000;
|
||||
} else if (Vset <= -1000000000) { //-5V
|
||||
Vset = -1000000000;
|
||||
}
|
||||
|
||||
if (Vset <= cc->_Vmin) {
|
||||
Vset = cc->_Vmin;
|
||||
} else if (Vset >= cc->_Vmax) {
|
||||
Vset = cc->_Vmax;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+7
-5
@@ -23,13 +23,14 @@ static void cv_vscan(void)
|
||||
cv->_current_direction_up = false;
|
||||
}
|
||||
|
||||
//Vsetp = x * 20 * N, x=xmV ; N=VscanRate
|
||||
// Vstep = x * 20 * N, x=xmV ; N=VscanRate Vstep unit [5nV]/[0.1ms]
|
||||
if (instru.step <= 10) {
|
||||
cv->_Vstep = instru.step * instru.VsetRate / 5;
|
||||
} else {
|
||||
cv->_Vstep = instru.step / 5 * instru.VsetRate;
|
||||
}
|
||||
|
||||
|
||||
if (cv->_Vmin == cv->_Vinit) {
|
||||
VminCounter = true;
|
||||
}
|
||||
@@ -41,13 +42,14 @@ static void cv_vscan(void)
|
||||
}
|
||||
|
||||
if (!vscanReset) {
|
||||
cv->bFirst = false;
|
||||
if ((instru.Vinit < instru.Ve1 && instru.Vinit < instru.Ve2) ||
|
||||
(instru.Vinit > instru.Ve1 && instru.Vinit > instru.Ve2)
|
||||
) {
|
||||
if (cv->_current_direction_up) {
|
||||
Vset = Vset + cv->_Vstep * GPT.GptimerMultiple;
|
||||
Vset = Vset + cv->_Vstep; //* GPT.GptimerMultiple;
|
||||
} else {
|
||||
Vset = Vset - cv->_Vstep * GPT.GptimerMultiple;
|
||||
Vset = Vset - cv->_Vstep; //* GPT.GptimerMultiple;
|
||||
}
|
||||
|
||||
if (instru.Vinit < instru.Ve1 && instru.Vinit < instru.Ve2) {
|
||||
@@ -71,9 +73,9 @@ static void cv_vscan(void)
|
||||
}
|
||||
|
||||
if (cv->_current_direction_up) {
|
||||
Vset = Vset + cv->_Vstep * GPT.GptimerMultiple;
|
||||
Vset = Vset + cv->_Vstep;// * GPT.GptimerMultiple;
|
||||
} else {
|
||||
Vset = Vset - cv->_Vstep * GPT.GptimerMultiple;
|
||||
Vset = Vset - cv->_Vstep;// * GPT.GptimerMultiple;
|
||||
}
|
||||
|
||||
if (VmaxCounter && VminCounter) {
|
||||
|
||||
-84
@@ -1,84 +0,0 @@
|
||||
|
||||
#ifndef ELITECV
|
||||
#define ELITECV
|
||||
|
||||
static void iv_cy_vscan(void)
|
||||
{
|
||||
struct wm_iv_cy_ctx_t *iv_cy = (struct wm_iv_cy_ctx_t *)wm_get();
|
||||
static bool VminCounter;
|
||||
static bool VmaxCounter;
|
||||
|
||||
NotifyCycleNumber = (instru.cycleNumber - iv_cy->_cycleNumber + 1);
|
||||
|
||||
if(vscanReset){
|
||||
VmaxCounter = false;
|
||||
VminCounter = false;
|
||||
|
||||
if(instru.directionInit == 1){
|
||||
iv_cy->_direction_up = true;
|
||||
iv_cy->_current_direction_up = true;
|
||||
}else if(instru.directionInit == 0){
|
||||
iv_cy->_direction_up = false;
|
||||
iv_cy->_current_direction_up = false;
|
||||
}
|
||||
|
||||
//Vsetp = x * 20 * N, x=xmV ; N=VscanRate
|
||||
if(instru.step <= 10){
|
||||
iv_cy->_Vstep = instru.step * instru.VsetRate / 5;
|
||||
}else{
|
||||
iv_cy->_Vstep = instru.step / 5 * instru.VsetRate;
|
||||
}
|
||||
|
||||
if(iv_cy->_Vmin == iv_cy->_Vinit){
|
||||
VminCounter = true;
|
||||
}
|
||||
if(iv_cy->_Vmax == iv_cy->_Vinit){
|
||||
VmaxCounter = true;
|
||||
}
|
||||
|
||||
Vset = iv_cy->_Vinit;
|
||||
}
|
||||
|
||||
if(!vscanReset){
|
||||
if (Vset >= iv_cy->_Vmax){
|
||||
VmaxCounter = true;
|
||||
}else if (Vset <= iv_cy->_Vmin){
|
||||
VminCounter = true;
|
||||
}
|
||||
|
||||
if (iv_cy->_current_direction_up){
|
||||
Vset = Vset + iv_cy->_Vstep * GPT.GptimerMultiple;
|
||||
}else{
|
||||
Vset = Vset - iv_cy->_Vstep * GPT.GptimerMultiple;
|
||||
}
|
||||
|
||||
if(VmaxCounter && VminCounter){
|
||||
if(iv_cy->_direction_up && iv_cy->_current_direction_up){
|
||||
if(Vset >= iv_cy->_Vinit){
|
||||
iv_cy->_cycleNumber--;
|
||||
VminCounter = false;
|
||||
VmaxCounter = false;
|
||||
}
|
||||
}
|
||||
if(!iv_cy->_direction_up && !iv_cy->_current_direction_up){
|
||||
if(Vset <= iv_cy->_Vinit){
|
||||
iv_cy->_cycleNumber--;
|
||||
VminCounter = false;
|
||||
VmaxCounter = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Vset >= iv_cy->_Vmax){
|
||||
iv_cy->_current_direction_up = false;
|
||||
}else if (Vset <= iv_cy->_Vmin){
|
||||
iv_cy->_current_direction_up = true;
|
||||
}
|
||||
|
||||
/*stop condition*/
|
||||
if(iv_cy->_cycleNumber == 0){
|
||||
PeriodicEvent = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
#ifndef ELITECVSCAN
|
||||
#define ELITECVSCAN
|
||||
|
||||
#define Vset instru.Vset
|
||||
|
||||
static void ca_vscan(void)
|
||||
{
|
||||
struct wm_ca_ctx_t *ca = (struct wm_ca_ctx_t *)wm_get();
|
||||
|
||||
if(vscanReset){
|
||||
Vset = ca->_Vinit;
|
||||
}
|
||||
|
||||
if(!vscanReset){
|
||||
Vset = ca->_Vinit;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+273
-27
@@ -29,60 +29,161 @@ static bool DACReset;
|
||||
//}
|
||||
//#endif
|
||||
|
||||
#ifdef ELITE_VERSION_1_4
|
||||
#define DACCLS 0x02
|
||||
#define DACOUT 0x31
|
||||
//#ifdef ELITE_VERSION_1_4
|
||||
//#define DACCLS 0x02
|
||||
//#define DACOUT 0x31
|
||||
//
|
||||
//static uint16_t DAC_outputV(uint16_t voltLV) {
|
||||
// // C = command, X = don't care, D = data
|
||||
// // CCCC CCCC = command
|
||||
// // DDDD DDDD = v1
|
||||
// // DDDD DDDD = v2
|
||||
//
|
||||
// // command
|
||||
// // 0x02 = clear
|
||||
// // 0x31 = output voltage
|
||||
//
|
||||
// uint8_t v1, v2 = 0;
|
||||
// v1 = (uint8_t) ((voltLV & 0xFF00) >> 8);
|
||||
// v2 = (uint8_t) (voltLV & 0x00FF);
|
||||
//
|
||||
// spi_DACtxbuf[0] = DACOUT;
|
||||
// spi_DACtxbuf[1] = v1;
|
||||
// spi_DACtxbuf[2] = v2;
|
||||
//
|
||||
// DAC_SPI(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
|
||||
//
|
||||
// return voltLV;
|
||||
//}
|
||||
//#endif
|
||||
|
||||
static uint16_t DAC_outputV(uint16_t voltLV) {
|
||||
// C = command, X = don't care, D = data
|
||||
// CCCC CCCC = command
|
||||
// DDDD DDDD = v1
|
||||
// DDDD DDDD = v2
|
||||
|
||||
// command
|
||||
// 0x02 = clear
|
||||
// 0x31 = output voltage
|
||||
#define VBIAS_LSB 107422 // 2200/4096 [mV] = 107422 [5nV]
|
||||
#define VZERO_LSB 6875008 // VBIAS_LSB * 64
|
||||
#define DAC12BIT_LSB 107422
|
||||
|
||||
uint8_t v1, v2 = 0;
|
||||
v1 = (uint8_t) ((voltLV & 0xFF00) >> 8);
|
||||
v2 = (uint8_t) (voltLV & 0x00FF);
|
||||
static int32_t DAC_outputV(int32_t voltLV) { // LPDAC output, voltLV = Vbias-Vzero
|
||||
static int32_t vztemp, vscan;
|
||||
static uint32_t vb, vz, vbcode, vzcode, DACOutCode = 0;
|
||||
|
||||
spi_DACtxbuf[0] = DACOUT;
|
||||
spi_DACtxbuf[1] = v1;
|
||||
spi_DACtxbuf[2] = v2;
|
||||
vztemp = (-0.45 * voltLV) + 249000000;
|
||||
if (voltLV < 0) {
|
||||
vztemp -= DAC12BIT_LSB;
|
||||
}
|
||||
vzcode = (vztemp - 40000000 + VZERO_LSB / 2) / VZERO_LSB;
|
||||
vz = vzcode * VZERO_LSB + 40000000;
|
||||
|
||||
DAC_SPI(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
|
||||
vb = voltLV + vz;
|
||||
vbcode = ((vb - 40000000 + VBIAS_LSB / 2) / VBIAS_LSB);
|
||||
DACOutCode = (0x0003FFFF & ((vzcode << 12) + vbcode));
|
||||
|
||||
return voltLV;
|
||||
DACOutCode = Cali_LPDAC(DACOutCode);
|
||||
|
||||
select_REG(LPDACDAT0);
|
||||
w32_REG(DACOutCode);
|
||||
|
||||
vscan = (int32_t)(vb - vz) / 200;
|
||||
return vscan;
|
||||
}
|
||||
|
||||
static uint32_t DAC_outputF(uint32_t freq) {
|
||||
select_REG(WGFCW);
|
||||
w32_REG(freq);
|
||||
return freq;
|
||||
}
|
||||
|
||||
static void VoutGainControl(uint8_t VOUTLevel){
|
||||
if(VOUTLevel == 0){
|
||||
// VOUT gain level = 0, using 240K resister
|
||||
PIN15_setOutputValue(Turon_VOUT_SMALL, 0);
|
||||
PIN_setOutputValue(pin_handle, Turon_VOUT_SMALL, 0);
|
||||
}
|
||||
else if(VOUTLevel == 1){
|
||||
// VOUT gain level = 1, using 15K resister
|
||||
PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
|
||||
PIN_setOutputValue(pin_handle, Turon_VOUT_SMALL, 1);
|
||||
}
|
||||
else if(VOUTLevel == 2){
|
||||
// VOUT gain level = 2, using 15K resister
|
||||
PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
|
||||
PIN_setOutputValue(pin_handle, Turon_VOUT_SMALL, 1);
|
||||
}
|
||||
else{
|
||||
// default using 15K resister
|
||||
PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
|
||||
PIN_setOutputValue(pin_handle, Turon_VOUT_SMALL, 1);
|
||||
}
|
||||
record_flag = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
static uint32_t CalcPeriod(uint32_t freq){ //One Second = 10000
|
||||
|
||||
static int32_t User2Real(uint16_t UserCode){
|
||||
/* transfer usercode to real voltage value (mV) */
|
||||
return (int32_t)((UserCode - 25000) / 5);
|
||||
uint32_t period;
|
||||
|
||||
if (freq == 1) {
|
||||
period = 666667;
|
||||
} else {
|
||||
period = (1000000 + freq / 2) / freq; // [sec]
|
||||
}
|
||||
|
||||
if (period < 20){
|
||||
period = 20;
|
||||
}
|
||||
|
||||
return period;
|
||||
}
|
||||
|
||||
static uint32_t CalcDelayTime(uint32_t freq){
|
||||
uint32_t delayTime, decadeSamplingTime;
|
||||
delayTime = CalcPeriod(freq) * instru.delay; //get delay time
|
||||
if (delayTime < 20) {
|
||||
delayTime = 20;
|
||||
} else {
|
||||
delayTime = (delayTime + 5) / 10;
|
||||
}
|
||||
|
||||
// 1000Hz
|
||||
if (freq >= 100000) {
|
||||
decadeSamplingTime = 1025;
|
||||
}
|
||||
|
||||
// 100Hz
|
||||
else if (freq >= 10000) {
|
||||
decadeSamplingTime = 1025;
|
||||
}
|
||||
|
||||
// 10Hz
|
||||
else if (freq >= 1000) {
|
||||
decadeSamplingTime = 11393;
|
||||
}
|
||||
|
||||
// 1Hz
|
||||
else if (freq >= 100) {
|
||||
decadeSamplingTime = 91034;
|
||||
}
|
||||
|
||||
//0.1Hz
|
||||
else if (freq >= 10) {
|
||||
decadeSamplingTime = 550000;
|
||||
}
|
||||
|
||||
// 0.015Hz | 136s
|
||||
else if (freq >= 1) {
|
||||
decadeSamplingTime = 1360000;
|
||||
}
|
||||
|
||||
delayTime += decadeSamplingTime; //delay+reading time
|
||||
|
||||
return delayTime;
|
||||
}
|
||||
|
||||
static uint32_t User2Freq(uint32_t UserCode){
|
||||
uint32_t freq;
|
||||
freq = (UserCode * 149 + 50)/ 100;
|
||||
return freq; //[100mHz]
|
||||
}
|
||||
|
||||
static uint32_t Freq2DAC(uint32_t freq){
|
||||
uint32_t code;
|
||||
code = (freq * 100 + 75) / 149;
|
||||
return code; //return code
|
||||
}
|
||||
|
||||
// DAC Vout theoretical boundary <300, 100~ (mV)
|
||||
#define DAC_VOUT_GAIN_SMALL_BOUNDARY 100000 // 25500(usercode) = 100 mV
|
||||
@@ -116,4 +217,149 @@ static void AutoGainChangeVout(int32_t userCode){
|
||||
}
|
||||
}
|
||||
|
||||
static void SetWGAmp(uint16_t ampcode){
|
||||
// uint32_t amplitude = Cali_HSAMP(ampcode);
|
||||
|
||||
// static uint64_t amp_cutoff = 40000000;
|
||||
// uint32_t corrected_amp;
|
||||
//
|
||||
// corrected_amp = ((uint64_t)ampcode * 800 * 1000 / 2047) * (1 + ((uint64_t)instru.fset * (uint64_t)instru.fset) / (amp_cutoff * amp_cutoff)); //[uV]
|
||||
//
|
||||
// ampcode = corrected_amp * 2047 / 800000;
|
||||
|
||||
select_REG(WGCON);
|
||||
w32_REG(0x0); // 0x0: DC disable ac first
|
||||
select_REG(WGAMPLITUDE);
|
||||
w32_REG(ampcode);
|
||||
select_REG(WGCON);
|
||||
w32_REG(0x00000004); //0x4: Sinusoid
|
||||
}
|
||||
|
||||
static void SetEISHIGHZ(uint8_t ret){
|
||||
uint32_t code;
|
||||
|
||||
select_REG(LPTIASW0); //LPTIASW0
|
||||
code = r32_REG();
|
||||
code = (code & (~(1 << 2))) | (ret << 2); //ret = 0 HighZ on | ret = 1 HighZ off
|
||||
w32_REG(code);
|
||||
}
|
||||
|
||||
static void HSDAC_GainControl(uint8_t G_EXA_PGA) {
|
||||
/* Set the Gain value of PGA and Excitation amp */
|
||||
uint32_t reg = 0;
|
||||
uint8_t DACUpdateRate = 0x07;
|
||||
|
||||
switch (G_EXA_PGA) {
|
||||
case 0x00:{
|
||||
reg = 0x00000000;
|
||||
break;
|
||||
}
|
||||
case 0x01:{
|
||||
reg = 0x00000001;
|
||||
break;
|
||||
}
|
||||
case 0x10:{
|
||||
reg = 0x00001000;
|
||||
break;
|
||||
}
|
||||
case 0x11:{
|
||||
reg = 0x00001001;
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
reg = 0x0000000E; // Default update rate = 7
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reg = reg | ((uint32_t)(DACUpdateRate) << 1);
|
||||
select_REG(HSDACCON); // HSDACCON address
|
||||
w32_REG(reg);
|
||||
}
|
||||
|
||||
static void HSDAC_output(uint16_t amp) {
|
||||
/* Set and write the amplitude of HSDAC. Full scale: 0x0200 ~ 0x0E00, 0x0800 = 0V */
|
||||
/* Set and write the amplitude of HSDAC. Full scale: 512 ~ 3584, 2048 = 0V */
|
||||
uint32_t amplitude = 0;
|
||||
|
||||
if (amp > 0x0E00) {
|
||||
amplitude = 0x00000E00;
|
||||
} else if (amp < 0x0200) {
|
||||
amplitude = 0x00000200;
|
||||
} else {
|
||||
amplitude = (uint32_t) (amp & 0x0FFF);
|
||||
}
|
||||
|
||||
select_REG(HSDACDAT); // HSDACDAT address
|
||||
w32_REG(amplitude);
|
||||
}
|
||||
|
||||
static void PowerMode_CutoffFrequencyControl (uint8_t bandwidth, uint8_t PowerMode) {
|
||||
uint32_t reg = 0;
|
||||
|
||||
switch (bandwidth) {
|
||||
case cutoff_auto :{
|
||||
reg = (((uint32_t)(cutoff_auto)) & 0x0000000F) << 2;
|
||||
break;
|
||||
}
|
||||
case cutoff_50k :{
|
||||
reg = (((uint32_t)(cutoff_50k)) & 0x0000000F) << 2;
|
||||
break;
|
||||
}
|
||||
case cutoff_100k :{
|
||||
reg = (((uint32_t)(cutoff_100k)) & 0x0000000F) << 2;
|
||||
break;
|
||||
}
|
||||
case cutoff_250k :{
|
||||
reg = (((uint32_t)(cutoff_250k)) & 0x0000000F) << 2;
|
||||
break;
|
||||
}
|
||||
default :{
|
||||
reg = (((uint32_t)(cutoff_auto)) & 0x0000000F) << 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (PowerMode) {
|
||||
case LOW_PW_MODE :{
|
||||
reg = reg | ((uint32_t)(LOW_PW_MODE) & 0x00000000F);
|
||||
break;
|
||||
}
|
||||
case HIGH_PW_MODE :{
|
||||
reg = reg | ((uint32_t)(HIGH_PW_MODE) & 0x00000000F);
|
||||
break;
|
||||
}
|
||||
default :{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
select_REG(PMBW);
|
||||
w32_REG(reg);
|
||||
}
|
||||
|
||||
static int32_t cali_DAC_outputV(int32_t voltLV) { // LPDAC output, voltLV = Vbias-Vzero
|
||||
static int32_t vztemp, vscan;
|
||||
static uint32_t vb, vz, vbcode, vzcode, DACOutCode = 0;
|
||||
|
||||
vztemp = (-0.45 * voltLV) + 249000000;
|
||||
if (voltLV < 0) {
|
||||
vztemp -= DAC12BIT_LSB;
|
||||
}
|
||||
vzcode = (vztemp - 40000000 + VZERO_LSB / 2) / VZERO_LSB;
|
||||
vz = vzcode * VZERO_LSB + 40000000;
|
||||
|
||||
vb = voltLV + vz;
|
||||
vbcode = ((vb - 40000000 + VBIAS_LSB / 2) / VBIAS_LSB);
|
||||
DACOutCode = (0x0003FFFF & ((vzcode << 12) + vbcode));
|
||||
|
||||
select_REG(LPDACDAT0);
|
||||
w32_REG(DACOutCode);
|
||||
|
||||
vscan = (int32_t)(vb - vz) / 200;
|
||||
// InputNotify(NOTIFY_VOLT, voltLV);
|
||||
// InputNotify(NOTIFY_CURRENT, vztemp);
|
||||
return vscan;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+43
-40
@@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#define BOARD_EEEF
|
||||
#define BOARD_EIS
|
||||
|
||||
typedef struct _formula{
|
||||
|
||||
@@ -39,16 +39,42 @@ typedef struct _formula{
|
||||
}Formula;
|
||||
|
||||
struct _correction{
|
||||
|
||||
Formula ADC_volt[3];
|
||||
Formula ADC_current[4];
|
||||
Formula Usercode2DAC[2];
|
||||
uint16_t Gain0Boundary[2];
|
||||
uint16_t Gain1Boundary[4];
|
||||
uint16_t Gain2Boundary[2];
|
||||
|
||||
} Correction =
|
||||
|
||||
#ifdef BOARD_EIS // EIS
|
||||
{
|
||||
.ADC_volt[0].coeff = (6268),
|
||||
.ADC_volt[0].offset = -101548925,
|
||||
|
||||
.ADC_volt[1].coeff = (215286),
|
||||
.ADC_volt[1].offset = -3498610755,
|
||||
|
||||
.ADC_volt[2].coeff = (6248966),
|
||||
.ADC_volt[2].offset = -101525581798,
|
||||
|
||||
.ADC_current[0].coeff = 3140113,
|
||||
.ADC_current[0].offset = (-51096616915),
|
||||
|
||||
.ADC_current[1].coeff = 71991480,
|
||||
.ADC_current[1].offset = (-1171591233910),
|
||||
|
||||
.ADC_current[2].coeff = 1463918055,
|
||||
.ADC_current[2].offset = (-23822237948708),
|
||||
|
||||
.ADC_current[3].coeff = 30759517333,
|
||||
.ADC_current[3].offset = (-500591140209163),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10508844),
|
||||
.Usercode2DAC[0].offset = 581826013531,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178229067),
|
||||
.Usercode2DAC[1].offset = 4775935828877,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_C7A1 //megafly
|
||||
{
|
||||
.ADC_volt[0].coeff = (6256),
|
||||
@@ -1002,43 +1028,10 @@ static int32_t DecodeADCValue(uint8_t ADCGain, uint8_t ADCChannel, uint8_t *ADC_
|
||||
return ret;
|
||||
}
|
||||
|
||||
// #0 board, (0x5f75 <= rawdata) && (rawdata <= 0x5fb2)
|
||||
// ((0x5f97 < rawdata) && (rawdata < 0x6589)) || ((0x5999 < rawdata) && (rawdata < 0x5f93))
|
||||
|
||||
static void ADC_overflow(uint8_t gain, uint8_t *rawdata){
|
||||
|
||||
// Gain boundary defines different ADC gain level working area
|
||||
// Gain0Boundary = {lowerbound, upperbound}, is the lower and upper bound of gain level 0 working area.
|
||||
|
||||
uint16_t U16Rawdata = 0;
|
||||
U16Rawdata = (((uint16_t) (rawdata[0]))<<8) | ((uint16_t) (rawdata[1]));
|
||||
|
||||
if(gain == I_GAIN_3M){
|
||||
if( U16Rawdata <= Correction.Gain0Boundary[0]){
|
||||
rawdata[0] = Correction.Gain0Boundary[0] >> 4;
|
||||
rawdata[1] = (uint8_t) (Correction.Gain0Boundary[0] & 0x00FF);
|
||||
}
|
||||
else if(U16Rawdata >= Correction.Gain0Boundary[1]){
|
||||
rawdata[0] = (uint8_t) (Correction.Gain0Boundary[1] >> 4);
|
||||
rawdata[1] = (uint8_t) (Correction.Gain0Boundary[1] & 0x00FF);
|
||||
}
|
||||
}
|
||||
else if(gain == I_GAIN_100K){
|
||||
if( U16Rawdata <= Correction.Gain1Boundary[0]){
|
||||
rawdata[0] = Correction.Gain1Boundary[0] >> 4;
|
||||
rawdata[1] = (uint8_t) (Correction.Gain1Boundary[0] & 0x00FF);
|
||||
}
|
||||
else if(U16Rawdata >= Correction.Gain1Boundary[1]){
|
||||
rawdata[0] = (uint8_t) (Correction.Gain1Boundary[1] >> 4);
|
||||
rawdata[1] = (uint8_t) (Correction.Gain1Boundary[1] & 0x00FF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// User will enter -5V~+5V in UI.
|
||||
// websever and controler use 0~50000 represent -5~+5V
|
||||
// this function should turn 0~50000 into DACcode which output the exactly voltage user want
|
||||
static uint16_t Usercode_Correction_to_DAC(uint8_t DACGain, uint16_t usercode)
|
||||
static uint32_t Usercode_Correction_to_DAC(uint8_t DACGain, uint16_t usercode)
|
||||
{
|
||||
long long usercode_32;
|
||||
uint16_t DACcode = 0;
|
||||
@@ -1047,9 +1040,19 @@ static uint16_t Usercode_Correction_to_DAC(uint8_t DACGain, uint16_t usercode)
|
||||
|
||||
DACcode = (uint16_t) ((Correction.Usercode2DAC[DACGain].coeff * usercode_32 + Correction.Usercode2DAC[DACGain].offset)/1e7);
|
||||
|
||||
|
||||
|
||||
|
||||
return DACcode;
|
||||
}
|
||||
|
||||
static uint32_t Usercode_Correction_to_Freq(uint16_t usercode)
|
||||
{
|
||||
uint32_t freqCode;
|
||||
freqCode = ((uint32_t)(usercode) * 240) + 67109;
|
||||
return freqCode;
|
||||
}
|
||||
|
||||
|
||||
static int32_t DAC_to_realV(uint8_t DACGain, uint16_t DACcode)
|
||||
{
|
||||
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
|
||||
#ifndef ELITEEIS
|
||||
#define ELITEEIS
|
||||
|
||||
static void eis_fscan(void)
|
||||
{
|
||||
struct wm_eis_ctx_t *eis = (struct wm_eis_ctx_t *)wm_get();
|
||||
|
||||
if (vscanReset) {
|
||||
eis->_in_reset_flag = true;
|
||||
|
||||
eis->_f1 = User2Freq(eis->_f1);
|
||||
eis->_f2 = User2Freq(eis->_f2);
|
||||
eis->_fmax = User2Freq(eis->_fmax);
|
||||
eis->_fmin = User2Freq(eis->_fmin);
|
||||
|
||||
if (instru.directionInit == 1) {
|
||||
eis->_direction_up = true;
|
||||
} else if (instru.directionInit == 0) {
|
||||
eis->_direction_up = false;
|
||||
}
|
||||
|
||||
eis->_decades = CalcDecade(instru.fmin, instru.fmax);
|
||||
|
||||
instru.fset = eis->_f1;
|
||||
|
||||
vscanReset = false;
|
||||
}
|
||||
|
||||
if (!vscanReset) {
|
||||
if(eis->_direction_up) {
|
||||
if(eis->_sweepIndex == 0){
|
||||
if(eis->_decadeIndex < eis->_decades) {
|
||||
eis->_fd1 = eis->_f1 * TenPowerTable[eis->_decadeIndex];
|
||||
eis->_fd2 = eis->_f1 * TenPowerTable[eis->_decadeIndex + 1];
|
||||
} else if (eis->_decadeIndex == eis->_decades) {
|
||||
eis->_fd1 = eis->_fd2;//eis->_f1 * TenPowerTable[decadeIndex];
|
||||
eis->_fd2 = eis->_fmax;
|
||||
}
|
||||
}
|
||||
|
||||
if(eis->_decadeIndex != 0 && eis->_sweepIndex == 0){
|
||||
eis->_sweepIndex++;
|
||||
}
|
||||
|
||||
if(instru.scale == 0) { // logarithm
|
||||
if (eis->_ppd == 10) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable10[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
else if (eis->_ppd == 9){
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable9[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
else if (eis->_ppd == 8) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable8[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
else if (eis->_ppd == 7) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable7[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
else if (eis->_ppd == 6) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable6[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
else if (eis->_ppd == 5) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable5[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
else if (eis->_ppd == 4) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable4[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
else if (eis->_ppd == 3) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable3[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
else if (eis->_ppd == 2) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable2[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
}
|
||||
else if (instru.scale == 1) { // linear
|
||||
instru.fset = eis->_fd1 + eis->_sweepIndex * ((eis->_fd2 - eis->_fd1) / (eis->_ppd - 1));
|
||||
}
|
||||
|
||||
if(instru.fset > eis->_fmax){
|
||||
instru.fset = eis->_fmax;
|
||||
}
|
||||
|
||||
} else { //reverse
|
||||
if(eis->_sweepIndex == 0){
|
||||
if(eis->_decadeIndex < eis->_decades){
|
||||
eis->_fd1 = eis->_f1 / TenPowerTable[eis->_decadeIndex];
|
||||
eis->_fd2 = eis->_f1 / TenPowerTable[eis->_decadeIndex + 1];
|
||||
} else if (eis->_decadeIndex == eis->_decades){
|
||||
eis->_fd1 = eis->_fd2; //eis->_f1 / TenPowerTable[eis->_decadeIndex];
|
||||
eis->_fd2 = eis->_fmin;
|
||||
}
|
||||
}
|
||||
|
||||
if(eis->_decadeIndex != 0 && eis->_sweepIndex == 0){
|
||||
eis->_sweepIndex++;
|
||||
}
|
||||
|
||||
if(instru.scale == 0) { // logarithm
|
||||
if (eis->_ppd == 10) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable10[9 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
else if (eis->_ppd == 9) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable9[8 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
else if (eis->_ppd == 8) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable8[7 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
else if (eis->_ppd == 7) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable7[6 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
else if (eis->_ppd == 6) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable6[5 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
else if (eis->_ppd == 5) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable5[4 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
else if (eis->_ppd == 4) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable4[3 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
else if (eis->_ppd == 3) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable3[2 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
else if (eis->_ppd == 2) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable2[1 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
}
|
||||
else if(instru.scale == 1) { // linear
|
||||
instru.fset = eis->_fd1 - eis->_sweepIndex * ((eis->_fd1 - eis->_fd2) / (eis->_ppd - 1));
|
||||
}
|
||||
|
||||
if(instru.fset < eis->_fmin){
|
||||
instru.fset = eis->_fmin;
|
||||
}
|
||||
}
|
||||
if (!gainChange_flag) {
|
||||
if (++eis->_sweepIndex == eis->_ppd) {
|
||||
eis->_sweepIndex = 0;
|
||||
eis->_decadeIndex ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SetSamplingTime(instru.fset);
|
||||
|
||||
instru.sampleRate = 2000;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+2
@@ -18,6 +18,7 @@ struct _GPT{
|
||||
uint32_t NotifyCounter;
|
||||
uint32_t VscanRateCounter;
|
||||
uint32_t LeadTimeCounter;
|
||||
uint32_t DelayTimeCounter;
|
||||
uint32_t BatteryADCCounter;
|
||||
uint32_t BatteryCheckCounter;
|
||||
uint32_t GptimerMultiple;
|
||||
@@ -32,6 +33,7 @@ static void InitGPT(){
|
||||
GPT.NotifyCounter = 0;
|
||||
GPT.VscanRateCounter = 0;
|
||||
GPT.LeadTimeCounter = 0;
|
||||
GPT.DelayTimeCounter = 0;
|
||||
GPT.BatteryADCCounter = 0;
|
||||
GPT.BatteryCheckCounter = 0;
|
||||
GPT.StiCounter = 0;
|
||||
|
||||
-42
@@ -4,48 +4,6 @@
|
||||
|
||||
#define Vset instru.Vset
|
||||
|
||||
static void iv_vscan(void)
|
||||
{
|
||||
struct wm_iv_ctx_t *iv = (struct wm_iv_ctx_t *)wm_get();
|
||||
|
||||
if (vscanReset) {
|
||||
if (instru.directionInit == 1) {
|
||||
iv->_direction_up = true;
|
||||
iv->_current_direction_up = true;
|
||||
} else if (instru.directionInit == 0) {
|
||||
iv->_direction_up = false;
|
||||
iv->_current_direction_up = false;
|
||||
}
|
||||
|
||||
//Vsetp = x * 20 * N, x=xmV ; N=VscanRate
|
||||
if (instru.step <= 10) {
|
||||
iv->_Vstep = instru.step * instru.VsetRate / 5;
|
||||
} else {
|
||||
iv->_Vstep = instru.step / 5 * instru.VsetRate;
|
||||
}
|
||||
|
||||
Vset = iv->_Vinit;
|
||||
}
|
||||
|
||||
if (!vscanReset) {
|
||||
if (iv->_current_direction_up) {
|
||||
if (Vset >= iv->_Vmax) {
|
||||
PeriodicEvent = false;
|
||||
}
|
||||
} else {
|
||||
if (Vset <= iv->_Vmin) {
|
||||
PeriodicEvent = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (iv->_current_direction_up) {
|
||||
Vset = Vset + iv->_Vstep * GPT.GptimerMultiple;
|
||||
} else {
|
||||
Vset = Vset - iv->_Vstep * GPT.GptimerMultiple;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void vo_vscan(void)
|
||||
{
|
||||
struct wm_vo_ctx_t *vo = (struct wm_vo_ctx_t *)wm_get();
|
||||
|
||||
+187
-50
@@ -25,6 +25,26 @@ struct HEADSTAGE_INSTRUCTION {
|
||||
int32_t Vmax;
|
||||
int32_t Vmin;
|
||||
|
||||
/** EIS **/
|
||||
uint32_t f1;
|
||||
uint32_t f2;
|
||||
uint32_t fmax;
|
||||
uint32_t fmin;
|
||||
uint32_t fset;
|
||||
uint16_t dcbias;
|
||||
uint16_t delay;
|
||||
uint16_t acamp;
|
||||
uint8_t avgnum;
|
||||
uint8_t rtia;
|
||||
uint16_t ppd;
|
||||
uint8_t scale;
|
||||
int32_t real;
|
||||
int32_t imag;
|
||||
uint8_t periodIndex;
|
||||
uint32_t delayTime;
|
||||
uint8_t settingIndex;
|
||||
|
||||
|
||||
/** ADC parameter **/
|
||||
uint8_t notifyRateIndex;
|
||||
uint32_t sampleRate;
|
||||
@@ -33,6 +53,7 @@ struct HEADSTAGE_INSTRUCTION {
|
||||
uint8_t VinAutoGainEnable;
|
||||
uint8_t VoutAutoGainEnable;
|
||||
uint8_t ADCGainLv;
|
||||
|
||||
// voltage output gain
|
||||
uint16_t VoutGainLevel;
|
||||
uint8_t VinADCGainLv;
|
||||
@@ -66,41 +87,129 @@ struct HEADSTAGE_INSTRUCTION {
|
||||
|
||||
uint8_t AdcChannel;
|
||||
|
||||
/* EIS DAC parameter */
|
||||
uint8_t DAC_type;
|
||||
uint16_t VAmpSet; // DAC Voltage Amplitude
|
||||
|
||||
/* EIS ADC parameter */
|
||||
uint8_t HSTIAGainLv;
|
||||
uint8_t HSTIAAutoGainEnable;
|
||||
uint8_t LPTIAGainLv;
|
||||
uint8_t LPTIAAutoGainEnable;
|
||||
} instru = {0};
|
||||
|
||||
/** Iin, Vin, Vout **/
|
||||
#define IIN_ADC 0x00
|
||||
#define VIN_ADC 0x01
|
||||
#define VOUT_DAC 0x02
|
||||
#define HIGH_Z 0x03
|
||||
#define VOUT_VIN_ADC 0x04
|
||||
#define EIS_HSTIA 0x00
|
||||
#define EIS_LPTIA 0x01
|
||||
#define EIS_HSDAC 0x02
|
||||
#define EIS_LPDAC 0x03
|
||||
#define VOUT_DAC 0x04
|
||||
#define IIN_ADC 0x05
|
||||
#define VIN_ADC 0x06
|
||||
#define HIGH_Z 0x07
|
||||
|
||||
/** ADC Iin gain level **/
|
||||
#define I_GAIN_3M 0x00 // largest gain
|
||||
#define I_GAIN_100K 0x01
|
||||
#define I_GAIN_3K 0x02
|
||||
#define I_GAIN_100R 0x03 // the least gain
|
||||
#define I_GAIN_AUTO 0x04
|
||||
#define I_GAIN_3M 0x07 // largest gain
|
||||
#define I_GAIN_100K 0x08
|
||||
#define I_GAIN_3K 0x09
|
||||
#define I_GAIN_100R 0x0A // the least gain
|
||||
#define I_GAIN_AUTO 0x04
|
||||
|
||||
// EIS LPTIA Iin Gain Level //
|
||||
#define LPRTIA_512K 0x00
|
||||
#define LPRTIA_12K 0x01
|
||||
#define LPRTIA_4K 0x02
|
||||
#define LPRTIA_200R 0x03
|
||||
#define LPRTIA_GAIN_AUTO 0x04
|
||||
|
||||
// EIS HSTIA Iin Gain Level
|
||||
#define HSRTIA_160K 0x00
|
||||
#define HSRTIA_20K 0x01
|
||||
#define HSRTIA_5K 0x02
|
||||
#define HSRTIA_200R 0x03
|
||||
#define HSRTIA_GAIN_AUTO 0x04
|
||||
|
||||
/** ADC Vin gain level **/
|
||||
#define VIN_GAIN_1M 0x00
|
||||
#define VIN_GAIN_30K 0x01
|
||||
#define VIN_GAIN_1K 0x02
|
||||
#define VIN_GAIN_AUTO 0x03
|
||||
#define VIN_GAIN_1M 0x00
|
||||
#define VIN_GAIN_30K 0x01
|
||||
#define VIN_GAIN_1K 0x02
|
||||
#define VIN_GAIN_AUTO 0x03
|
||||
|
||||
/** Vout gain level **/
|
||||
#define VOUT_GAIN_240K 0x00
|
||||
#define VOUT_GAIN_15K 0x01
|
||||
#define VOUT_GAIN_AUTO 0x02
|
||||
#define VOUT_GAIN_240K 0x00
|
||||
#define VOUT_GAIN_15K 0x01
|
||||
#define VOUT_GAIN_AUTO 0x02
|
||||
|
||||
/* DAC reset parameter */
|
||||
#define DAC_ZERO 25000
|
||||
#define DAC_ZERO 25000
|
||||
#define EIS_HSDAC_ZERO 0x0800
|
||||
|
||||
// Step time macro
|
||||
#define STEPTIME_HALF_SEC 5000
|
||||
#define STEPTIME_ONE_SEC 10000
|
||||
#define STEPTIME_TWO_SEC 20000
|
||||
#define STEPTIME_HALF_SEC 5000
|
||||
#define STEPTIME_ONE_SEC 10000
|
||||
#define STEPTIME_TWO_SEC 20000
|
||||
|
||||
/* AVG Number */
|
||||
#define AVG2 0
|
||||
#define AVG4 1
|
||||
#define AVG8 2
|
||||
#define AVG16 3
|
||||
|
||||
#define ADC1M6sps 0
|
||||
#define ADC800Ksps 1
|
||||
|
||||
#define Sinc3OSR5 0
|
||||
#define Sinc3OSR4 1
|
||||
#define Sinc3OSR2 2
|
||||
|
||||
#define Sinc2OSR22 0
|
||||
#define Sinc2OSR44 1
|
||||
#define Sinc2OSR89 2
|
||||
#define Sinc2OSR178 3
|
||||
#define Sinc2OSR267 4
|
||||
#define Sinc2OSR533 5
|
||||
#define Sinc2OSR640 6
|
||||
#define Sinc2OSR667 7
|
||||
#define Sinc2OSR800 8
|
||||
#define Sinc2OSR889 9
|
||||
#define Sinc2OSR1067 10
|
||||
#define Sinc2OSR1333 11
|
||||
|
||||
#define DFTNUM4 0
|
||||
#define DFTNUM8 1
|
||||
#define DFTNUM16 2
|
||||
#define DFTNUM32 3
|
||||
#define DFTNUM64 4
|
||||
#define DFTNUM128 5
|
||||
#define DFTNUM256 6
|
||||
#define DFTNUM512 7
|
||||
#define DFTNUM1024 8
|
||||
#define DFTNUM2048 9
|
||||
#define DFTNUM4096 10
|
||||
#define DFTNUM8192 11
|
||||
#define DFTNUM16384 12
|
||||
|
||||
#define AD5940_SYS_CLOCK 16000000
|
||||
#define Cutoff_Freq 37000000 // 210kHz
|
||||
|
||||
///* LPTIA gain Level */
|
||||
//#define LPRTIA200R 1 //Max 3mA
|
||||
//#define LPRTIA4K 5 //Max 220uA
|
||||
//#define LPRTIA12K 9 //Max 74uA
|
||||
//#define LPRTIA512K 26 //Max 1.76uA
|
||||
|
||||
static uint32_t HSRTIATable[4] = {160000, 20000, 5000, 200};
|
||||
|
||||
/* HSTIA gain level (feedback R value) */
|
||||
#define RTIA200R 0x00 // 200R
|
||||
#define RTIA1k 0x01 // 1k
|
||||
#define RTIA5k 0x02 // 5k
|
||||
#define RTIA10k 0x03 // 10k
|
||||
#define RTIA20k 0x04 // 20k
|
||||
#define RTIA40k 0x05 // 40k
|
||||
#define RTIA80k 0x06 // 80k
|
||||
#define RTIA160k 0x07 // 160k
|
||||
#define RTIAopen 0x08 // RTIA is open
|
||||
/*********************************************************************
|
||||
* @fn InitEliteInstruction
|
||||
*
|
||||
@@ -111,35 +220,53 @@ struct HEADSTAGE_INSTRUCTION {
|
||||
* @return None.
|
||||
*/
|
||||
static void InitEliteInstruction(){
|
||||
instru.chip_id = 0;
|
||||
instru.eliteFxn = 0; //default is a null event
|
||||
instru.VsetRateIndex = 0;
|
||||
instru.VsetRate = 2;
|
||||
instru.Vset = 0;
|
||||
instru.VoltConstant = DAC_ZERO; //DAC_ZERO is about 0V
|
||||
instru.directionInit = 1; //0:reverse 1:forward
|
||||
instru.step = 0;
|
||||
instru.Ve1 = DAC_ZERO;
|
||||
instru.Ve2 = DAC_ZERO;
|
||||
instru.Vinit = 0;
|
||||
instru.Vmax = 0;
|
||||
instru.Vmin = 0;
|
||||
instru.notifyRateIndex = 100;
|
||||
instru.sampleRate = 15;
|
||||
instru.VoViSwitch = 0x01; //0:user see Vo 1: user see Vi
|
||||
instru.AutoGainEnable = 1;
|
||||
instru.VinAutoGainEnable = 1;
|
||||
instru.VoutAutoGainEnable = 1;
|
||||
instru.ADCGainLv = I_GAIN_AUTO;
|
||||
instru.VoutGainLevel = VOUT_GAIN_AUTO;
|
||||
instru.VinADCGainLv = VIN_GAIN_AUTO;
|
||||
instru.notifyRate = STEPTIME_ONE_SEC;
|
||||
instru.cycleNumber = 1;
|
||||
instru.charge = 1; //0:discharge 1:charge
|
||||
instru.constantCurrent = 0;
|
||||
instru.Currentmax = 0;
|
||||
instru.StepTime = STEPTIME_ONE_SEC;
|
||||
instru.AdcChannel = 0;
|
||||
instru.chip_id = 0;
|
||||
instru.eliteFxn = 0; //default is a null event
|
||||
instru.VsetRateIndex = 0;
|
||||
instru.VsetRate = 2;
|
||||
instru.Vset = 0;
|
||||
instru.VoltConstant = DAC_ZERO; //DAC_ZERO is about 0V
|
||||
instru.directionInit = 1; //0:reverse 1:forward
|
||||
instru.step = 0;
|
||||
instru.Ve1 = DAC_ZERO;
|
||||
instru.Ve2 = DAC_ZERO;
|
||||
instru.Vinit = 0;
|
||||
instru.Vmax = 0;
|
||||
instru.Vmin = 0;
|
||||
instru.notifyRateIndex = 100;
|
||||
instru.sampleRate = 15;
|
||||
instru.VoViSwitch = 0x01; //0:user see Vo 1: user see Vi
|
||||
instru.AutoGainEnable = 1;
|
||||
instru.VinAutoGainEnable = 1;
|
||||
instru.VoutAutoGainEnable = 1;
|
||||
instru.ADCGainLv = I_GAIN_AUTO;
|
||||
instru.VoutGainLevel = VOUT_GAIN_AUTO;
|
||||
instru.VinADCGainLv = VIN_GAIN_AUTO;
|
||||
instru.notifyRate = STEPTIME_ONE_SEC;
|
||||
instru.cycleNumber = 1;
|
||||
instru.charge = 1; //0:discharge 1:charge
|
||||
instru.constantCurrent = 0;
|
||||
instru.Currentmax = 0;
|
||||
instru.StepTime = STEPTIME_ONE_SEC;
|
||||
instru.AdcChannel = 0;
|
||||
|
||||
//EIS
|
||||
instru.f1 = 0;
|
||||
instru.f2 = 0;
|
||||
instru.fset = 0;
|
||||
instru.fmax = 0;
|
||||
instru.fmin = 0;
|
||||
instru.delay = 0;
|
||||
instru.scale = 0;
|
||||
instru.avgnum = 0;
|
||||
instru.dcbias = 0;
|
||||
instru.acamp = 0;
|
||||
instru.rtia = 0;
|
||||
instru.ppd = 1;
|
||||
instru.periodIndex = 0;
|
||||
instru.delayTime = 0;
|
||||
instru.settingIndex = 0;
|
||||
|
||||
|
||||
//pulse mode
|
||||
instru.sti_t1 = 0;
|
||||
@@ -158,6 +285,16 @@ static void InitEliteInstruction(){
|
||||
instru.sti_v7 = DAC_ZERO;
|
||||
instru.sti_loop = 1;
|
||||
instru.sti_cy = 0;
|
||||
|
||||
// EIS DAC
|
||||
instru.VAmpSet = EIS_HSDAC_ZERO;
|
||||
instru.DAC_type = EIS_HSDAC;
|
||||
|
||||
// EIS ADC
|
||||
instru.HSTIAGainLv = 0;
|
||||
instru.HSTIAAutoGainEnable = 1;
|
||||
instru.LPTIAGainLv = 0;
|
||||
instru.LPTIAAutoGainEnable = 1;
|
||||
}
|
||||
|
||||
#ifdef __cpulsplus
|
||||
|
||||
+15
-13
@@ -8,25 +8,27 @@ static bool TurnOnElite(uint8_t key) {
|
||||
if (key == 0) {
|
||||
// press 1 sec, power on LED, read bat power
|
||||
if (TurnOnCounter >= CLOCK_ONE_SECOND) {
|
||||
headstage_battery_volt();
|
||||
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) |
|
||||
((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
|
||||
if( bat < 768 && bat > 20){
|
||||
PIN15_setOutputValue(enable_5v, 0);
|
||||
return false;
|
||||
}else{
|
||||
PIN15_setOutputValue(enable_5v, 1); // enable 5V
|
||||
TurnOn10V();
|
||||
// headstage_battery_volt();
|
||||
// uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) |
|
||||
// ((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
|
||||
// if( bat < 768 && bat > 20){
|
||||
// PIN_setOutputValue(pin_handle, enable_5v, 0);
|
||||
// return false;
|
||||
// }else{
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 1); // enable 5V
|
||||
Elite_SPI_init();
|
||||
// TurnOn10V();
|
||||
ModeLED(BT_WAIT);
|
||||
AD5940_init();
|
||||
return true;
|
||||
}
|
||||
// }
|
||||
} else {
|
||||
TurnOnCounter++;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
TurnOnCounter = 0;
|
||||
PIN15_setOutputValue(enable_5v, 0); // disable 5V
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -46,7 +48,7 @@ static void EliteKeyPress(uint8_t key) {
|
||||
// press 3~4 sec, shutdown 2650
|
||||
else if (ShutDownCounter > (CLOCK_ONE_SECOND*3) ) {
|
||||
LED_color(DARKLED, 0xFF, 0xFF, 0x00);
|
||||
PIN15_setOutputValue(enable_5v, 0); // disable 5V
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V
|
||||
}
|
||||
ShutDownCounter ++;
|
||||
} else {
|
||||
@@ -68,7 +70,7 @@ static void EliteKeyPress(uint8_t key) {
|
||||
|
||||
static void TurnOn10V() {
|
||||
If10Von = true;
|
||||
PIN15_setOutputValue(enable_10v, 1);
|
||||
PIN_setOutputValue(pin_handle, enable_10v, 1);
|
||||
CPUdelay(8000);
|
||||
}
|
||||
|
||||
|
||||
+10
-12
@@ -156,18 +156,8 @@ static void checkFlafLED()
|
||||
static void WorkModeLED()
|
||||
{
|
||||
switch (instru.eliteFxn) {
|
||||
case CURVE_IV:
|
||||
case CURVE_VO:
|
||||
case CURVE_RT:
|
||||
case CURVE_VT:
|
||||
case CURVE_IT:
|
||||
case CURVE_CV:
|
||||
case CURVE_CA:
|
||||
case CURVE_CC:
|
||||
case CURVE_OCP:
|
||||
case CURVE_LSV:
|
||||
case CURVE_IV_CY:
|
||||
case CURVE_PULSE:
|
||||
case CURVE_EIS:
|
||||
case CURVE_EIS_CV:
|
||||
WORKLED();
|
||||
break;
|
||||
|
||||
@@ -178,6 +168,14 @@ static void WorkModeLED()
|
||||
Elite_led_color(COLOR_ORANGE);
|
||||
} else if (instru.AdcChannel == VOUT_DAC) {
|
||||
Elite_led_color(COLOR_BLUE);
|
||||
}else if (instru.AdcChannel == EIS_HSDAC) {
|
||||
Elite_led_color(COLOR_PURPLE_DARK);
|
||||
} else if (instru.AdcChannel == EIS_HSTIA) {
|
||||
Elite_led_color(COLOR_WHITE);
|
||||
} else if (instru.AdcChannel == EIS_LPTIA) {
|
||||
Elite_led_color(COLOR_RED);
|
||||
} else if (instru.AdcChannel == EIS_LPDAC) {
|
||||
Elite_led_color(COLOR_BLUE);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
#ifndef ELITELSV
|
||||
#define ELITELSV
|
||||
|
||||
#define Vset instru.Vset
|
||||
|
||||
static void lsv_vscan(void)
|
||||
{
|
||||
struct wm_lsv_ctx_t *lsv = (struct wm_lsv_ctx_t *)wm_get();
|
||||
|
||||
NotifyCycleNumber = (instru.cycleNumber - lsv->_cycleNumber + 1);
|
||||
|
||||
if (vscanReset) {
|
||||
if (instru.directionInit == 1) {
|
||||
lsv->_direction_up = true;
|
||||
lsv->_current_direction_up = true;
|
||||
} else {
|
||||
lsv->_direction_up = false;
|
||||
lsv->_current_direction_up = false;
|
||||
}
|
||||
|
||||
//Vsetp = x * 20 * N, x=xmV ; N=VscanRate
|
||||
if (instru.step <= 10) {
|
||||
lsv->_Vstep = instru.step * instru.VsetRate / 5;
|
||||
} else {
|
||||
lsv->_Vstep = instru.step / 5 * instru.VsetRate;
|
||||
}
|
||||
|
||||
Vset = lsv->_Vinit;
|
||||
}
|
||||
|
||||
if (!vscanReset) {
|
||||
|
||||
if (lsv->_current_direction_up) {
|
||||
Vset = Vset + lsv->_Vstep * GPT.GptimerMultiple;
|
||||
} else {
|
||||
Vset = Vset - lsv->_Vstep * GPT.GptimerMultiple;
|
||||
}
|
||||
|
||||
/*stop condition*/
|
||||
if (Vset >= lsv->_Vmax) {
|
||||
PeriodicEvent = false;
|
||||
} else if (Vset <= lsv->_Vmin) {
|
||||
PeriodicEvent = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+4
-4
@@ -93,9 +93,9 @@ static void SendNotify() {
|
||||
not_buf[0] = instru.chip_id;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
not_buf[i + 1] = NotifyCurrent[i];
|
||||
not_buf[i + 5] = NotifyVolt[i];
|
||||
not_buf[i + 9] = NotifyImpedance[i];
|
||||
not_buf[i + 1] = NotifyCurrent[i]; // 1 2 3 4
|
||||
not_buf[i + 5] = NotifyVolt[i]; // 5 6 7 8
|
||||
not_buf[i + 9] = NotifyImpedance[i]; //9 10 11 12
|
||||
}
|
||||
|
||||
// 1 Timestamp = 32 usec; 31 Timestamp ~= 1 msec
|
||||
@@ -109,7 +109,7 @@ static void SendNotify() {
|
||||
not_buf[17] = (NotifyCycleNumber >> 8) & 0xff;
|
||||
not_buf[18] = NotifyCycleNumber & 0xff;
|
||||
|
||||
not_buf[19] = (finishMode << 7) & 0x80;
|
||||
not_buf[19] = (finishMode << 7) & 0x80 | instru.ADCGainLv & 0x0F;
|
||||
|
||||
for (int i = 20; i < BLE_DAT_BUFF_SIZE; i++){
|
||||
not_buf[i] = 0;
|
||||
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
#ifndef ELITEPULSE
|
||||
#define ELITEPULSE
|
||||
|
||||
#define Vset instru.Vset
|
||||
|
||||
static void pulse_vscan(void)
|
||||
{
|
||||
struct wm_pulse_ctx_t *pulse = (struct wm_pulse_ctx_t *)wm_get();
|
||||
static uint16_t lastVolt;
|
||||
|
||||
if (stiFirstTime) {
|
||||
stiFirstTime = false;
|
||||
lastVolt = 25000;
|
||||
pulse->_sti_t_flag = 1;
|
||||
pulse->_sti_v = pulse->_sti_v1;
|
||||
pulse->_sti_t = pulse->_sti_t1;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else if(!stiFirstTime) {
|
||||
if (GPT.StiCounter >= pulse->_sti_t) {
|
||||
GPT.StiCounter -= pulse->_sti_t; //to get right time
|
||||
|
||||
if (pulse->_sti_lp > 0) {
|
||||
if (pulse->_sti_cy > 0) {
|
||||
if (pulse->_sti_t_flag == 1) {
|
||||
pulse->_sti_t_flag = 2;
|
||||
pulse->_sti_v = pulse->_sti_v2;
|
||||
pulse->_sti_t = pulse->_sti_t2;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else if (pulse->_sti_t_flag == 2) {
|
||||
pulse->_sti_t_flag = 3;
|
||||
pulse->_sti_v = pulse->_sti_v3;
|
||||
pulse->_sti_t = pulse->_sti_t3;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else if (pulse->_sti_t_flag == 3) {
|
||||
pulse->_sti_cy -- ;
|
||||
if (pulse->_sti_cy == 0) {
|
||||
pulse->_sti_t_flag = 4;
|
||||
pulse->_sti_v = pulse->_sti_v4;
|
||||
pulse->_sti_t = pulse->_sti_t4;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else {
|
||||
pulse->_sti_t_flag = 2;
|
||||
pulse->_sti_v = pulse->_sti_v2;
|
||||
pulse->_sti_t = pulse->_sti_t2;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (pulse->_sti_cy <= 0){
|
||||
if (pulse->_sti_t_flag == 4) {
|
||||
pulse->_sti_lp -- ;
|
||||
if (pulse->_sti_lp > 0) {
|
||||
pulse->_sti_cy = instru.sti_cy;
|
||||
pulse->_sti_t_flag = 2;
|
||||
pulse->_sti_v = pulse->_sti_v2;
|
||||
pulse->_sti_t = pulse->_sti_t2;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else {
|
||||
pulse->_sti_t_flag = 5;
|
||||
pulse->_sti_v = pulse->_sti_v5;
|
||||
pulse->_sti_t = pulse->_sti_t5;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (pulse->_sti_lp <= 0) {
|
||||
if (pulse->_sti_t_flag == 5) {
|
||||
pulse->_sti_t_flag = 6;
|
||||
pulse->_sti_v = pulse->_sti_v6;
|
||||
pulse->_sti_t = pulse->_sti_t6;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else if (pulse->_sti_t_flag == 6) {
|
||||
pulse->_sti_t_flag = 7;
|
||||
pulse->_sti_v = pulse->_sti_v7;
|
||||
pulse->_sti_t = pulse->_sti_t7;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else if (pulse->_sti_t_flag == 7) {
|
||||
pulse->_sti_v = 25000;
|
||||
PeriodicEvent = false;
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0: open highz;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastVolt != pulse->_sti_v) {
|
||||
lastVolt = pulse->_sti_v;
|
||||
//if (pulse->_sti_v == 25000) {
|
||||
// PIN15_setOutputValue(HIGH_Z_MODE, 0); // 1 => close high_z mode
|
||||
//} else {
|
||||
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
//}
|
||||
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, pulse->_sti_v));
|
||||
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, pulse->_sti_v));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+16
-11
@@ -13,14 +13,16 @@ static void reset() {
|
||||
initINSBuf();
|
||||
initDATBuf();
|
||||
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // HIGH Z MODE // 1: close; 0: open;
|
||||
AD5940_HWReset();
|
||||
AD5940_init();
|
||||
// AD5940_sftreset();
|
||||
|
||||
VinADCGainCtrl(VIN_GAIN_AUTO);
|
||||
IinADCGainControl(I_GAIN_AUTO);
|
||||
// PIN_setOutputValue(pin_handle, HIGH_Z_MODE, 0); // HIGH Z MODE // 1: close; 0: open;
|
||||
|
||||
instru.VoutGainLevel = VOUT_GAIN_15K;
|
||||
VoutGainControl(instru.VoutGainLevel);
|
||||
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLevel, 25000));
|
||||
HSTIAGainCtrl(HSRTIA_200R);
|
||||
LPTIAGainCtrl(LPRTIA_200R);
|
||||
HSDAC_GainControl(0x00);
|
||||
HSDAC_output(0x0800);
|
||||
|
||||
for (int i = 0; i < SPI_LED_SIZE; i++) {
|
||||
spi_LEDtxbuf[i] = 0;
|
||||
@@ -37,6 +39,7 @@ static void reset() {
|
||||
spi_ADC_rxbuf[i] = 0;
|
||||
}
|
||||
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1); // AD_CS HIGH
|
||||
ModeLED(NO_EVENT);
|
||||
CPUdelay(1600);
|
||||
}
|
||||
@@ -51,12 +54,13 @@ static void Eliteinterrupt() {
|
||||
InitGPT();
|
||||
initINSBuf();
|
||||
initDATBuf();
|
||||
AD5940_HWReset();
|
||||
AD5940_init();
|
||||
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // HIGH Z MODE // 1: close; 0: open;
|
||||
|
||||
instru.VoutGainLevel = VOUT_GAIN_15K;
|
||||
VoutGainControl(instru.VoutGainLevel);
|
||||
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLevel, 25000));
|
||||
// HSTIAGainCtrl(HSRTIA_200R);
|
||||
// LPTIAGainCtrl(LPRTIA_200R);
|
||||
// HSDAC_GainControl(0x00);
|
||||
// HSDAC_output(0x0800);
|
||||
|
||||
for (int i = 0; i < SPI_LED_SIZE; i++) {
|
||||
spi_LEDtxbuf[i] = 0;
|
||||
@@ -73,6 +77,7 @@ static void Eliteinterrupt() {
|
||||
spi_ADC_rxbuf[i] = 0;
|
||||
}
|
||||
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1); // AD_CS HIGH
|
||||
ModeLED(NO_EVENT);
|
||||
CPUdelay(8000);
|
||||
}
|
||||
|
||||
+171
-36
@@ -16,7 +16,7 @@
|
||||
|
||||
/* application use SPI parameters and buffers */
|
||||
#define SPI_LED_SIZE 28
|
||||
#define SPI_DAC_SIZE 3
|
||||
#define SPI_DAC_SIZE 6
|
||||
#define SPI_ADC_SIZE 4
|
||||
|
||||
static uint16_t spi_LEDtxbuf[SPI_LED_SIZE] = {0};
|
||||
@@ -27,6 +27,8 @@ static uint8_t spi_rxbuf[SPI_DAC_SIZE] = {0};
|
||||
|
||||
static uint8_t spi_ADC_txbuf[SPI_ADC_SIZE] = {0};
|
||||
static uint8_t spi_ADC_rxbuf[SPI_ADC_SIZE] = {0};
|
||||
//
|
||||
//static uint32_t SeqCmdBuff;
|
||||
|
||||
/* system use SPI parameters */
|
||||
static SPI_Handle spiHandle0 = NULL; // SPI0 = LED
|
||||
@@ -42,7 +44,7 @@ static void ELITE15_SPI_CLOSE();
|
||||
static void Elite_SPI_init(){
|
||||
SPI_init();
|
||||
SPI_Params_init(&spiParams0);
|
||||
spiParams0.bitRate = 2000; // 12k
|
||||
spiParams0.bitRate = 2000; // 2k
|
||||
spiParams0.mode = SPI_MASTER;
|
||||
spiParams0.dataSize = 16;
|
||||
spiParams0.frameFormat = SPI_POL0_PHA1;
|
||||
@@ -52,7 +54,8 @@ static void Elite_SPI_init(){
|
||||
spiParams1.bitRate = 1000000; // 1M
|
||||
spiParams1.mode = SPI_MASTER;
|
||||
spiParams1.dataSize = 8;
|
||||
spiParams1.frameFormat = SPI_POL0_PHA1;
|
||||
spiParams1.frameFormat = SPI_POL0_PHA0;
|
||||
|
||||
spiHandle1 = SPI_open(Board_SPI1, &spiParams1); // ADC DAC SPI
|
||||
}
|
||||
|
||||
@@ -65,9 +68,7 @@ static void LED_SPI(uint8_t length, uint16_t *spi_txbuf, uint16_t *spi_rxbuf) {
|
||||
}
|
||||
|
||||
static void ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
// PIN15_setOutputValue(ADC_CS, 0); // ADC_CS LOW
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
PIN_setOutputValue(pin_handle, D6, 0); // ADC_CS LOW
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 0); // CS_ADC
|
||||
|
||||
ADC_DAC_transaction.count = length;
|
||||
ADC_DAC_transaction.txBuf = spi_txbuf;
|
||||
@@ -75,43 +76,33 @@ static void ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, D6, 1); // ADC_CS HIGH
|
||||
update_latch_status (ADC_CS, 1);
|
||||
// PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1); // CS_ADC
|
||||
}
|
||||
|
||||
static void DAC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
// PIN15_setOutputValue(DAC_CS, 0); // DAC_CS LOW
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
PIN_setOutputValue(pin_handle, D7, 0); // DAC_CS LOW
|
||||
|
||||
ADC_DAC_transaction.count = length;
|
||||
ADC_DAC_transaction.txBuf = spi_txbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, D7, 1); // DAC_CS HIGH
|
||||
update_latch_status (DAC_CS, 1);
|
||||
// PIN15_setOutputValue(DAC_CS, 1); // DAC_CS HIGH
|
||||
}
|
||||
|
||||
static void ELITE15_SPI_HOLD() {
|
||||
Elite_SPI_init();
|
||||
#ifdef ELITE_PIN_1_5_RE
|
||||
PIN_setOutputValue(pin_handle, D6, LH.LATCH0[6]); // ADC_CS
|
||||
PIN_setOutputValue(pin_handle, D7, LH.LATCH0[7]); // DAC_CS
|
||||
PIN_setOutputValue(pin_handle, D4, LH.LATCH0[4]); // update HIGH_Z_MODE
|
||||
#endif
|
||||
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
PIN_setOutputValue(pin_handle, LOAD1, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD2, 0);
|
||||
// #ifdef ELITE_PIN_1_5_RE
|
||||
// PIN_setOutputValue(pin_handle, D6, LH.LATCH0[6]); // ADC_CS
|
||||
// PIN_setOutputValue(pin_handle, D7, LH.LATCH0[7]); // DAC_CS
|
||||
// PIN_setOutputValue(pin_handle, D4, LH.LATCH0[4]); // update HIGH_Z_MODE
|
||||
// #endif
|
||||
//
|
||||
// PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
// PIN_setOutputValue(pin_handle, LOAD1, 0);
|
||||
// PIN_setOutputValue(pin_handle, LOAD2, 0);
|
||||
}
|
||||
static void ELITE15_SPI_CLOSE() {
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD1, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD2, 0);
|
||||
// PIN_setOutputValue(pin_handle, LOAD0, 0);
|
||||
// PIN_setOutputValue(pin_handle, LOAD1, 0);
|
||||
// PIN_setOutputValue(pin_handle, LOAD2, 0);
|
||||
|
||||
SPI_close(spiHandle0);
|
||||
SPI_close(spiHandle1);
|
||||
@@ -119,19 +110,163 @@ static void ELITE15_SPI_CLOSE() {
|
||||
|
||||
/* Elite1.5 Calibration SPI */
|
||||
static void CAL_ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
// PIN15_setOutputValue(ADC_CS, 0); // ADC_CS LOW
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
PIN_setOutputValue(pin_handle, D6, 0); // ADC_CS LOW
|
||||
|
||||
ADC_DAC_transaction.count = length;
|
||||
ADC_DAC_transaction.txBuf = spi_txbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, D6, 1); // ADC_CS HOGH
|
||||
update_latch_status (ADC_CS, 1);
|
||||
// PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1); // CS_ADC
|
||||
}
|
||||
|
||||
static void CAL_LED_SPI(uint8_t length, uint16_t *spi_txbuf, uint16_t *spi_rxbuf) {
|
||||
LED_transaction.count = length;
|
||||
LED_transaction.txBuf = spi_txbuf;
|
||||
LED_transaction.rxBuf = spi_rxbuf;
|
||||
|
||||
SPI_transfer(spiHandle0, &LED_transaction);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef ELITE_VERSION_EIS
|
||||
/* define SPI command */
|
||||
// datasheet page 98
|
||||
#define SPICMD_SETADDR 0x20
|
||||
#define SPICMD_WRITEREG 0x2D
|
||||
#define SPICMD_READREG 0x6D
|
||||
|
||||
//define REG
|
||||
#define LPDACCON0 0x2128
|
||||
#define LPDACSW0 0x2124
|
||||
#define LPDACDAT0 0x2120
|
||||
#define LPREFBUFCON 0x2050
|
||||
#define SWMUX 0x235C
|
||||
#define LPTIASW0 0x20E4
|
||||
#define SWCON 0x200C
|
||||
#define HSDACCON 0x2010
|
||||
#define HSDACDAT 0x2048
|
||||
#define LPTIACON0 0x20EC
|
||||
#define HSTIACON 0x20FC
|
||||
#define AFECON 0x2000
|
||||
#define DSWFULLCON 0x2150
|
||||
#define NSWFULLCON 0x2154
|
||||
#define PSWFULLCON 0x2158
|
||||
#define TSWFULLCON 0x215C
|
||||
#define WGFCW 0x2030
|
||||
#define WGPHASE 0x2034
|
||||
#define WGOFFSET 0x2038
|
||||
#define WGAMPLITUDE 0x203C
|
||||
#define WGCON 0x2014
|
||||
#define DE0RESCON 0x20F8
|
||||
#define ADCCON 0x21A8
|
||||
#define DFTCON 0x20D0
|
||||
#define ADCFILTERCON 0x2044
|
||||
#define PMBW 0x22F0
|
||||
#define CLKSEL 0x0414
|
||||
#define CLKCON0 0x0408
|
||||
#define CLKCON0KEY 0x0420
|
||||
#define HSOSCCON 0x20BC
|
||||
#define ADCBUFCON 0x238C
|
||||
#define HSRTIACON 0x20F0
|
||||
#define ADCDAT 0x2074
|
||||
#define DFTREAL 0x2078
|
||||
#define DFTIMAG 0x207C
|
||||
|
||||
static void select_REG(uint16_t addr){
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 0);
|
||||
// CPUdelay(16000);
|
||||
|
||||
spi_DACtxbuf[0] = SPICMD_SETADDR;
|
||||
spi_DACtxbuf[1] = (uint8_t)((addr & 0xFF00) >> 8);
|
||||
spi_DACtxbuf[2] = (uint8_t)(addr & 0x00FF);
|
||||
|
||||
ADC_DAC_transaction.count = 3;
|
||||
ADC_DAC_transaction.txBuf = spi_DACtxbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
// CPUdelay(16000);
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1);
|
||||
}
|
||||
|
||||
static void w16_REG(uint16_t data){
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 0);
|
||||
spi_DACtxbuf[0] = SPICMD_WRITEREG;
|
||||
spi_DACtxbuf[1] = (uint8_t)((data & 0xFF00) >> 8);
|
||||
spi_DACtxbuf[2] = (uint8_t)(data & 0x00FF);
|
||||
|
||||
ADC_DAC_transaction.count = 3;
|
||||
ADC_DAC_transaction.txBuf = spi_DACtxbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1);
|
||||
}
|
||||
|
||||
static int16_t r16_REG(){
|
||||
int16_t ret;
|
||||
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 0);
|
||||
spi_DACtxbuf[0] = SPICMD_READREG;
|
||||
spi_DACtxbuf[1] = 0x00;
|
||||
spi_DACtxbuf[2] = 0x00;
|
||||
spi_DACtxbuf[3] = 0x00;
|
||||
|
||||
ADC_DAC_transaction.count = 4;
|
||||
ADC_DAC_transaction.txBuf = spi_DACtxbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
ret = (int16_t)spi_rxbuf[2] << 8 | \
|
||||
(int16_t)spi_rxbuf[3];
|
||||
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void w32_REG(uint32_t data){
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 0);
|
||||
spi_DACtxbuf[0] = SPICMD_WRITEREG;
|
||||
spi_DACtxbuf[1] = (uint8_t)((data & 0xFF000000) >> 24);
|
||||
spi_DACtxbuf[2] = (uint8_t)((data & 0x00FF0000) >> 16);
|
||||
spi_DACtxbuf[3] = (uint8_t)((data & 0x0000FF00) >> 8);
|
||||
spi_DACtxbuf[4] = (uint8_t)(data & 0x000000FF);
|
||||
|
||||
ADC_DAC_transaction.count = 5;
|
||||
ADC_DAC_transaction.txBuf = spi_DACtxbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1);
|
||||
}
|
||||
|
||||
static int32_t r32_REG(){
|
||||
int32_t ret;
|
||||
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 0);
|
||||
spi_DACtxbuf[0] = SPICMD_READREG;
|
||||
spi_DACtxbuf[1] = 0x00;
|
||||
spi_DACtxbuf[2] = 0x00;
|
||||
spi_DACtxbuf[3] = 0x00;
|
||||
spi_DACtxbuf[4] = 0x00;
|
||||
spi_DACtxbuf[5] = 0x00;
|
||||
|
||||
ADC_DAC_transaction.count = 6;
|
||||
ADC_DAC_transaction.txBuf = spi_DACtxbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
ret = (int32_t)spi_rxbuf[2] << 24 | \
|
||||
(int32_t)spi_rxbuf[3] << 16 | \
|
||||
(int32_t)spi_rxbuf[4] << 8 | \
|
||||
(int32_t)spi_rxbuf[5];
|
||||
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif // ELITE_EIS
|
||||
|
||||
#endif // ELITE_SPI
|
||||
|
||||
+98
-51
@@ -4,7 +4,7 @@
|
||||
#ifndef ELITE_WORK_DATA
|
||||
#define ELITE_WORK_DATA
|
||||
|
||||
#define CLOCK_ONE_SECOND 10000
|
||||
#define CLOCK_ONE_SECOND 10000 // 1s
|
||||
|
||||
#include "EliteInstruction.h"
|
||||
|
||||
@@ -19,6 +19,20 @@
|
||||
bool _current_direction_up; \
|
||||
uint16_t _cycleNumber
|
||||
|
||||
//#define FOUT_PARA \
|
||||
// uint32_t _f1; \
|
||||
// uint32_t _f2; \
|
||||
// uint32_t _fd1; \
|
||||
// uint32_t _fd2; \
|
||||
// uint32_t _fmax; \
|
||||
// uint32_t _fmin; \
|
||||
// uint32_t _fset; \
|
||||
// uint8_t _decades; \ //num of decades in whole
|
||||
// uint16_t _ppd; \
|
||||
// uint8_t _decadeIndex; \ //index of decade max is 8
|
||||
// uint16_t _sweepIndex; \ //index of smaller decade max is 10
|
||||
// bool _direction_up
|
||||
|
||||
#define MEAS_CURR(_m) (((struct wm_meas_t *)(_m))->_measureCurrent)
|
||||
#define MEAS_VIN(_m) (((struct wm_meas_t *)(_m))->_measureVin)
|
||||
#define MEAS_VOUT(_m) (((struct wm_meas_t *)(_m))->_measureVout)
|
||||
@@ -34,6 +48,31 @@ struct wm_meas_t {
|
||||
};
|
||||
|
||||
/* member of mode */
|
||||
struct wm_eis_ctx_t {
|
||||
struct wm_meas_t measure;
|
||||
int16_t _phase;
|
||||
int32_t _mag;
|
||||
int32_t _real;
|
||||
int32_t _imag;
|
||||
uint32_t _f1;
|
||||
uint32_t _f2;
|
||||
uint32_t _fd1;
|
||||
uint32_t _fd2;
|
||||
uint32_t _fmax;
|
||||
uint32_t _fmin;
|
||||
uint32_t _fset;
|
||||
uint8_t _decades; //num of decades in whole
|
||||
uint16_t _ppd;
|
||||
uint8_t _cnt;
|
||||
int8_t _decadeIndex; //index of decade max is 8
|
||||
int16_t _sweepIndex; //index of smaller decade max is 10
|
||||
bool _direction_up;
|
||||
bool _switchNeg;
|
||||
bool _switchPos;
|
||||
bool _firstSwitch;
|
||||
bool _in_reset_flag;
|
||||
};
|
||||
|
||||
struct wm_vo_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
@@ -84,6 +123,8 @@ struct wm_cv_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
VOUT_PARA;
|
||||
int32_t _LPRtia;
|
||||
bool bFirst;
|
||||
};
|
||||
|
||||
struct wm_lsv_ctx_t {
|
||||
@@ -141,6 +182,49 @@ static void *workMode_p = NULL;
|
||||
static bool Free_Work_Mode = false;
|
||||
|
||||
/* init mode func */
|
||||
static int __eis_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_eis_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_eis_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_phase = 0;
|
||||
p->_mag = 0;
|
||||
p->_real = 0;
|
||||
p->_imag = 0;
|
||||
p->_f1 = instru.f1;
|
||||
p->_f2 = instru.f2;
|
||||
p->_fmax = instru.fmax;
|
||||
p->_fmin = instru.fmin;
|
||||
p->_fd1 = 0; //decade freq 1
|
||||
p->_fd2 = 0; //decade freq 2
|
||||
p->_fset = 0;
|
||||
p->_cnt = 0;
|
||||
p->_ppd = instru.ppd; //points per decade
|
||||
p->_decades = 0;
|
||||
p->_sweepIndex = 0;
|
||||
p->_decadeIndex = 0;
|
||||
p->_direction_up = true;
|
||||
p->_switchPos = false;
|
||||
p->_switchNeg = false;
|
||||
p->_firstSwitch = true;
|
||||
p->_in_reset_flag = false;
|
||||
|
||||
*wm = p;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __vo_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
@@ -247,9 +331,9 @@ static int __iv_create(void)
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_Vinit = (instru.Vinit - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmax = (instru.Vmax - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmin = (instru.Vmin - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vinit = instru.Vinit; //(instru.Vinit - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmax = instru.Vmax; //(instru.Vmax - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmin = instru.Vmin; //(instru.Vmin - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vset = 0;
|
||||
p->_Vstep = 0;
|
||||
p->_direction_up = true;
|
||||
@@ -335,11 +419,15 @@ static int __cv_create(void)
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_Vinit = (instru.Vinit - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmax = (instru.Vmax - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmin = (instru.Vmin - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vinit = (instru.Vinit - 25000) * 4 * 4000; //[5nV]
|
||||
p->_Vmax = (instru.Vmax - 25000) * 4 * 4000; //[5nV]
|
||||
p->_Vmin = (instru.Vmin - 25000) * 4 * 4000; //[5nV]
|
||||
// p->_Vinit = (instru.Vinit - 25000) * 4 * 10000; //[5nV]
|
||||
// p->_Vmax = (instru.Vmax - 25000) * 4 * 10000; //[5nV]
|
||||
// p->_Vmin = (instru.Vmin - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vset = 0;
|
||||
p->_Vstep = 0;
|
||||
p->bFirst = true;
|
||||
p->_direction_up = true;
|
||||
p->_current_direction_up = true;
|
||||
p->_cycleNumber = instru.cycleNumber;
|
||||
@@ -474,55 +562,14 @@ int wm_init(void)
|
||||
if (*wm) return -1;
|
||||
|
||||
switch (mode) {
|
||||
case CURVE_VO:
|
||||
case CURVE_CALI_DAC:
|
||||
if (__vo_create()) return -2;
|
||||
case CURVE_EIS:
|
||||
if (__eis_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_IT:
|
||||
if (__it_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_VT:
|
||||
if (__vt_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_RT:
|
||||
if (__rt_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_IV:
|
||||
if (__iv_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_IV_CY:
|
||||
if (__iv_cy_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_CC:
|
||||
if (__cc_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_CV:
|
||||
case CURVE_EIS_CV:
|
||||
if (__cv_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_LSV:
|
||||
if (__lsv_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_CA:
|
||||
if (__ca_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_PULSE:
|
||||
if (__pulse_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_OCP:
|
||||
if (__ocp_create()) return -2;
|
||||
break;
|
||||
|
||||
default:
|
||||
// printf("DO NOT support!!");
|
||||
return -3;
|
||||
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
|
||||
#ifndef ELITEZT
|
||||
#define ELITEZT
|
||||
|
||||
// output a certain voltage e.g. 2v
|
||||
// and measure the input voltage
|
||||
// => calculate the resister
|
||||
// change the output voltage step
|
||||
// => get a R-T curve (with resolution = 1 sample/volt step )
|
||||
|
||||
static void rt_vscan(void)
|
||||
{
|
||||
struct wm_rt_ctx_t *rt = (struct wm_rt_ctx_t *)wm_get();
|
||||
|
||||
if (vscanReset) {
|
||||
Vset = rt->_Vinit;
|
||||
}
|
||||
|
||||
if(!vscanReset) {
|
||||
Vset = rt->_Vinit;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+58
-1
@@ -7,8 +7,64 @@
|
||||
#include <ti/drivers/PIN.h>
|
||||
|
||||
//#define ELITE_PIN_1_5
|
||||
#define ELITE_PIN_1_5_RE
|
||||
//#define ELITE_PIN_1_5_RE
|
||||
#define ELITE_PIN_EIS
|
||||
|
||||
#ifdef ELITE_PIN_EIS
|
||||
/* SPI Board */
|
||||
#define Board_SPI0_MISO PIN_UNASSIGNED
|
||||
#define Board_SPI0_MOSI IOID_4
|
||||
#define Board_SPI0_CLK IOID_3
|
||||
#define Board_SPI0_CS PIN_UNASSIGNED
|
||||
|
||||
#define Board_SPI1_MISO IOID_1
|
||||
#define Board_SPI1_MOSI IOID_6
|
||||
#define Board_SPI1_CLK IOID_5
|
||||
#define Board_SPI1_CS PIN_UNASSIGNED
|
||||
|
||||
#define AD_CS IOID_10
|
||||
|
||||
//#define SD_MISO IOID_11
|
||||
//#define SD_CS IOID_8
|
||||
//#define SD_CLK IOID_7
|
||||
//#define SD_MOSI IOID_13
|
||||
|
||||
#define switch_on IOID_14
|
||||
#define enable_5v IOID_9
|
||||
#define AD_reset IOID_13
|
||||
#define enable_10v PIN_UNASSIGNED
|
||||
#define HIGH_Z_MODE PIN_UNASSIGNED
|
||||
#define shutdown_6994 PIN_UNASSIGNED
|
||||
|
||||
#define Turnon_I_LARGE PIN_UNASSIGNED
|
||||
#define Turnon_I_MID PIN_UNASSIGNED
|
||||
#define Turnon_I_SMALL PIN_UNASSIGNED
|
||||
|
||||
#define Turnon_V_MID PIN_UNASSIGNED
|
||||
#define Turnon_V_SMALL PIN_UNASSIGNED
|
||||
|
||||
#define Turon_VOUT_SMALL PIN_UNASSIGNED
|
||||
|
||||
|
||||
PIN_Handle pin_handle;
|
||||
static PIN_State ZM_rst;
|
||||
|
||||
const PIN_Config BLE_IO[] = {
|
||||
enable_5v | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,// 5V_enable
|
||||
AD_reset | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
|
||||
switch_on | PIN_INPUT_EN | PIN_PULLDOWN,
|
||||
AD_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
|
||||
PIN_TERMINATE
|
||||
};
|
||||
|
||||
static void remove_elite_pin() {
|
||||
PIN_close(pin_handle);
|
||||
pin_handle = PIN_open(&ZM_rst, BLE_IO);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ELITE_PIN_1_5_RE
|
||||
/* SPI Board */
|
||||
#define Board_SPI0_MISO PIN_UNASSIGNED
|
||||
#define Board_SPI0_MOSI D1
|
||||
@@ -113,6 +169,7 @@ static void remove_elite_pin() {
|
||||
PIN_close(pin_handle);
|
||||
pin_handle = PIN_open(&ZM_rst, BLE_IO);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @def BOOSTXL_CC2650MA_SPIName
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ static void measureBat(){
|
||||
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) |
|
||||
((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
|
||||
if( bat < 768 && bat > 20){
|
||||
PIN15_setOutputValue(enable_5v, 0);
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+33
-18
@@ -12,41 +12,45 @@
|
||||
#define VIS_STI 0xC0
|
||||
#define VIS_FUH 0x90
|
||||
#define VIS_INT 0x60
|
||||
#define VIS_SHIFT_200K 0xA0
|
||||
#define VIS_SHIFT_10K 0xE0
|
||||
#define VIS_SHIFT_200R 0x80
|
||||
#define VIS_DEVICE_SHINY 0x10
|
||||
#define VIS_SHINY_DIS 0x20
|
||||
#define VIS_CC_ZERO 0x40
|
||||
|
||||
// RIS (real instruction)
|
||||
enum all_mode_e {
|
||||
CURVE_IV = 0x01, // I-V Curve //0x10,
|
||||
CURVE_IV_CY = 0x02, // Cycle I-V //0x20,
|
||||
CURVE_VO = 0x03, // Function Generator //0x30,
|
||||
CURVE_RT = 0x04, // R-T Graph //0x40,
|
||||
CURVE_VT = 0x05, // V-T Graph //0x50,
|
||||
CURVE_IT = 0x06, // I-T Graph //0x60,
|
||||
CURVE_CC = 0x07, // Constant Current (CC) //0xD0,
|
||||
CURVE_OCP = 0x08, // Open Circuit Potential (OCP)
|
||||
CURVE_CV = 0x09, // Cyclic Voltammetry (CV) //0xC0,
|
||||
CURVE_LSV = 0x0A, // Linear Sweep Voltammetry (LSV) //0x02,
|
||||
CURVE_CA = 0x0B, // Chronoamperometric Graph (CA) //0x03,
|
||||
CURVE_PULSE = 0x0C, //0x94,
|
||||
|
||||
CURVE_EIS = 0xD1, //Should Change to 0xD1
|
||||
CURVE_EIS_CV = 0xD2,
|
||||
|
||||
CURVE_CALI_DAC = 0xF0, //0x93,
|
||||
CURVE_CALI_ADC = 0xF1, // Cali ADC - test //0x92,
|
||||
|
||||
// CURVE_CALI_ADC = 0x92, // Cali ADC - test //0x92,
|
||||
|
||||
SET_SAMPLE_RATE = 0xE0, //0x70,
|
||||
// SET_SAMPLE_RATE = 0x70, //0x70,
|
||||
SET_ADC_DAC_GAIN = 0xE1, //0x80,
|
||||
// SET_ADC_DAC_GAIN = 0x80, //0x80,
|
||||
};
|
||||
|
||||
// CIS (control instruction)
|
||||
#define CIS_VERSION 0x40
|
||||
#define CIS_VOLT 0x10
|
||||
#define CIS_LED_TEST 0x70
|
||||
#define CIS_CALI 0x30
|
||||
#define CIS_CALI2 0x90
|
||||
|
||||
#define CTL_WRT 0x20
|
||||
#define CTL_RD 0x21
|
||||
#define CTL_RD_DFTR 0x78
|
||||
#define CTL_RD_DFTI 0x7C
|
||||
#define CTL_WRT_WGAMPL 0x3C
|
||||
#define CTL_WRT_TRAP 0x2c
|
||||
#define CTL_RESET 0x11
|
||||
#define CTL_IMPEDANCE 0x12
|
||||
#define CTL_CV3 0x13
|
||||
#define cali_LPTIA_setGain 0x29
|
||||
#define cali_LPDAC_voltout 0x39
|
||||
#define cali_HSDAC_amp 0x49
|
||||
#define cali_HSTIA_setGain 0x59
|
||||
#define cali_HSDAC_DC 0x69
|
||||
|
||||
// mode parameter
|
||||
#define STEP_TO_VSETRATE(step) step2VsetRate(step)
|
||||
@@ -103,5 +107,16 @@ enum all_mode_e {
|
||||
#define WORKING 0x04
|
||||
#define POST_WORK 0x05
|
||||
|
||||
/* EIS define */
|
||||
// cutoff frequency of the filter in AD5940
|
||||
#define cutoff_auto 0x00
|
||||
#define cutoff_50k 0x01
|
||||
#define cutoff_100k 0x02
|
||||
#define cutoff_250k 0x03
|
||||
|
||||
#define LOW_PW_MODE 0x00
|
||||
#define HIGH_PW_MODE 0x01
|
||||
|
||||
|
||||
#define VALUE_ZERO_TO_ONE(_v) (_v == 0) ? 1 : _v
|
||||
#endif
|
||||
|
||||
+259
-204
@@ -1,10 +1,13 @@
|
||||
#include <math.h>
|
||||
|
||||
#ifndef ELITE_MODE_ADC_DAC
|
||||
#define ELITE_MODE_ADC_DAC
|
||||
|
||||
#define Vset instru.Vset
|
||||
|
||||
static void volt_out() {
|
||||
static uint16_t DACOutCode;
|
||||
static void volt_out()
|
||||
{
|
||||
static int32_t DACOutCode;
|
||||
static int32_t DeltaVout;
|
||||
static int32_t Vout;
|
||||
|
||||
@@ -22,6 +25,7 @@ static void volt_out() {
|
||||
Vout = -1000000000;
|
||||
}
|
||||
|
||||
|
||||
instru.VoltConstant = Vout / 40000 + 25000; //5nV=>usercode
|
||||
DACOutCode = Usercode_Correction_to_DAC(instru.VoutGainLevel, instru.VoltConstant);
|
||||
DAC_outputV(DACOutCode);
|
||||
@@ -29,26 +33,27 @@ static void volt_out() {
|
||||
return;
|
||||
}
|
||||
|
||||
static void freq_out()
|
||||
{
|
||||
DAC_outputF(instru.fset);
|
||||
return;
|
||||
}
|
||||
|
||||
static void vscan_volt_out(void)
|
||||
{
|
||||
struct wm_cv_ctx_t *cv = (struct wm_cv_ctx_t *)wm_get();
|
||||
void *wm = wm_get();
|
||||
uint16_t DACOutCode;
|
||||
int32_t DeltaVout;
|
||||
int32_t Vout;
|
||||
int32_t Vin;
|
||||
|
||||
Vin = MEAS_VIN(wm) * 200;//[5nV]
|
||||
/* in [5nV] ver */
|
||||
MEAS_VOUT(wm) = DAC_outputV(Vset);
|
||||
|
||||
if (DACReset) {
|
||||
Vout = Vset + Vin;
|
||||
} else {
|
||||
DeltaVout = Vset - (Vout - Vin);
|
||||
Vout = Vout + DeltaVout;
|
||||
if (Vset == cv->_Vinit && cv->bFirst){
|
||||
Elite_led_color(COLOR_ORANGE);
|
||||
CPUdelay(30000);
|
||||
Elite_led_color(COLOR_CYAN);
|
||||
}
|
||||
|
||||
instru.VoltConstant = Vout / 40000 + 25000;//5nV=>usercode
|
||||
DACOutCode = Usercode_Correction_to_DAC(instru.VoutGainLevel, instru.VoltConstant);
|
||||
DAC_outputV(DACOutCode);
|
||||
// InputNotify(NOTIFY_VOLT, vscan);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -70,41 +75,57 @@ static void CalcuResistance()
|
||||
|
||||
resist = volt * 1000000 / current; //R = V / Iin; [mOhm]
|
||||
InputNotify(NOTIFY_IMPEDANCE, resist);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void DACenable(uint8_t afterRead){
|
||||
|
||||
//////EIS PLOT RELATED FUNCTION START//////
|
||||
static uint8_t CalcDecade(uint32_t f1, uint32_t f2)
|
||||
{
|
||||
uint8_t decades; //max is 7
|
||||
decades = log10(f2/f1);
|
||||
return decades;
|
||||
}
|
||||
|
||||
static int32_t neg_18bit(int32_t ret)
|
||||
{
|
||||
// if (ret > 131072) {
|
||||
// ret = ret - 262144;
|
||||
// }
|
||||
ret &= 0x3FFFF;
|
||||
if (ret & (1 << 17)) {
|
||||
ret |= 0xFFFC0000;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//////EIS PLOT RELATED FUNCTION END//////
|
||||
|
||||
|
||||
static void DACenable(uint8_t afterRead)
|
||||
{
|
||||
void *wm = wm_get();
|
||||
|
||||
if (afterRead == AFTER_READ_I) {
|
||||
switch (instru.eliteFxn) {
|
||||
case CURVE_CC:
|
||||
cc_vscan();
|
||||
volt_out();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (afterRead == AFTER_READ_V) {
|
||||
switch (instru.eliteFxn) {
|
||||
case CURVE_IV_CY:
|
||||
case CURVE_IV:
|
||||
volt_out();
|
||||
case CURVE_EIS:
|
||||
freq_out();
|
||||
break;
|
||||
|
||||
case CURVE_VO:
|
||||
case CURVE_RT:
|
||||
volt_out();
|
||||
CalcuResistance();
|
||||
break;
|
||||
|
||||
case CURVE_CV:
|
||||
case CURVE_CA:
|
||||
case CURVE_LSV:
|
||||
case CURVE_EIS_CV:
|
||||
vscan_volt_out();
|
||||
break;
|
||||
|
||||
default:{
|
||||
Elite_led_color(COLOR_PURPLE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -123,9 +144,11 @@ static void read_Iin_change_gain(void)
|
||||
MEAS_CURR(wm) = read_cali_Iin(spi_ADC_rxbuf);
|
||||
if (instru.AutoGainEnable) {
|
||||
AutoGainChangeIin(MEAS_CURR(wm));
|
||||
// AutoChangeLPTIAGain(MEAS_CURR(wm));
|
||||
} else {
|
||||
if (lastIinADCGainLevel != instru.ADCGainLv) {
|
||||
IinADCGainControl(instru.ADCGainLv);
|
||||
// LPTIAGainCtrl(instru.ADCGainLv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +164,66 @@ static void read_Iin_change_gain(void)
|
||||
return;
|
||||
}
|
||||
|
||||
static void LPTIA_change_gain(void)
|
||||
{
|
||||
static uint8_t rec_cnt = 0;
|
||||
void *wm = wm_get();
|
||||
|
||||
if (instru.AutoGainEnable > 1)
|
||||
return;
|
||||
|
||||
/* read Iin and do NOT record the Iin after changing gain twice */
|
||||
MEAS_CURR(wm) = read_LPTIA_Iin();
|
||||
if (instru.AutoGainEnable) {
|
||||
AutoChangeLPTIAGain(MEAS_CURR(wm));
|
||||
} else {
|
||||
if (lastIinADCGainLevel != instru.ADCGainLv) {
|
||||
LPTIAGainCtrl(instru.ADCGainLv);
|
||||
}
|
||||
}
|
||||
|
||||
if (record_flag == false) {
|
||||
rec_cnt++;
|
||||
}
|
||||
|
||||
if (rec_cnt == 2) {
|
||||
record_flag = true;
|
||||
rec_cnt = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void HSTIA_change_gain(void)
|
||||
{
|
||||
// static uint8_t rec_cnt = 0;
|
||||
void *wm = wm_get();
|
||||
|
||||
if (instru.AutoGainEnable > 1)
|
||||
return;
|
||||
|
||||
/* read Iin and do NOT record the Iin after changing gain twice */
|
||||
MEAS_CURR(wm) = read_HSTIA_Iin();
|
||||
if (instru.AutoGainEnable) {
|
||||
AutoChangeHSTIAGain(MEAS_CURR(wm));
|
||||
} else {
|
||||
if (lastIinADCGainLevel != instru.ADCGainLv) {
|
||||
HSTIAGainCtrl(instru.ADCGainLv);
|
||||
}
|
||||
}
|
||||
|
||||
// if (record_flag == false) {
|
||||
// rec_cnt++;
|
||||
// }
|
||||
//
|
||||
// if (rec_cnt == 2) {
|
||||
// record_flag = true;
|
||||
// rec_cnt = 0;
|
||||
// }
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void read_Vin_change_gain(void)
|
||||
{
|
||||
static uint8_t rec_cnt = 0;
|
||||
@@ -237,7 +320,7 @@ static void Iin_Vin_Vout_Plot(void)
|
||||
|
||||
} else if (ADC_cnt == 4) {
|
||||
read_Vout_change_gain();
|
||||
DACenable(AFTER_READ_V);
|
||||
DACenable(AFTER_READ_V); // to volt_out -> DACOutput(DACoutCode)
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ADC_cnt++;
|
||||
|
||||
@@ -249,168 +332,119 @@ static void Iin_Vin_Vout_Plot(void)
|
||||
return;
|
||||
}
|
||||
|
||||
static void CC_Plot(void)
|
||||
static void CV_Plot(void)
|
||||
{
|
||||
struct wm_cv_ctx_t *cv = (struct wm_cv_ctx_t *)wm_get();
|
||||
static uint8_t ADC_cnt = 0;
|
||||
void *wm = wm_get();
|
||||
|
||||
/* the time for measuring battery */
|
||||
if (batteryCheck_flag) {
|
||||
EliteADCBattery();
|
||||
if (!batteryCheck_flag) {
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ADC_cnt = 3;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* the time for Not measuring battery */
|
||||
/* ADC_cnt: 0 - read Iin and do NOT buffer the Iin after changing gain twice,
|
||||
* and output DAC, and read Vin, and increase ADC_cnt
|
||||
* 1 - read Vin and increase ADC_cnt
|
||||
* 2 - read Vin and do NOT buffer the Vin after changing gain twice,
|
||||
* and output DAC, and read Iin, and increase ADC_cnt
|
||||
* 3 - read Iin and reset ADC_cnt
|
||||
*/
|
||||
if (ADC_cnt == 0) {
|
||||
read_Iin_change_gain();
|
||||
DACenable(AFTER_READ_I);
|
||||
ReadADCVin(spi_ADC_rxbuf);
|
||||
DACenable(AFTER_READ_V);
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 1) {
|
||||
ReadADCVin(spi_ADC_rxbuf);
|
||||
LPTIA_change_gain();
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 2) {
|
||||
read_Vin_change_gain();
|
||||
DACenable(AFTER_READ_V);
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 3) {
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
read_LPTIA_Iin();
|
||||
ADC_cnt = 0;
|
||||
}
|
||||
|
||||
InputNotify(NOTIFY_VOLT, MEAS_VOUT(wm));
|
||||
// InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
// InputNotify(NOTIFY_IMPEDANCE, instru.ADCGainLv);
|
||||
return;
|
||||
}
|
||||
|
||||
static void IT_Plot(void)
|
||||
static void EIS_Plot(void) //real and imag impedance plot
|
||||
{
|
||||
struct wm_eis_ctx_t *eis = (struct wm_eis_ctx_t *)wm_get();
|
||||
static uint8_t ADC_cnt = 0;
|
||||
static int32_t realSum, imagSum = 0;
|
||||
int32_t avg_real, avg_imag = 0;
|
||||
static uint8_t avg_count, high_freq_cnt = 0;
|
||||
void *wm = wm_get();
|
||||
|
||||
/* measure battery if needs */
|
||||
if (batteryCheck_flag) {
|
||||
EliteADCBattery();
|
||||
if (!batteryCheck_flag) {
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ADC_cnt = 1;
|
||||
if (fout_flag){
|
||||
DAC_outputF(Freq2DAC(instru.fset));
|
||||
EnDFTnADC(1);
|
||||
instru.sampleRate = CalcDelayTime(instru.fset);
|
||||
fout_flag = false;
|
||||
if (eis->_in_reset_flag) {
|
||||
avg_count = 0;
|
||||
high_freq_cnt = 0;
|
||||
realSum = 0;
|
||||
imagSum = 0;
|
||||
ADC_cnt = 0;
|
||||
eis->_in_reset_flag = false;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* ADC_cnt: 0 - read Iin and do NOT buffer the Iin after changing gain twice
|
||||
* 1 - read Iin and increase ADC_cnt
|
||||
* 2 - read Iin and reset ADC_cnt
|
||||
*/
|
||||
if (ADC_cnt == 0) {
|
||||
read_Iin_change_gain();
|
||||
DACenable(AFTER_READ_I);
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ADC_cnt++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ADC_cnt == 1) {
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ADC_cnt = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
static void VT_Plot(void)
|
||||
{
|
||||
static uint8_t ADC_cnt = 0;
|
||||
void *wm = wm_get();
|
||||
|
||||
/* measure battery if needs */
|
||||
if (batteryCheck_flag) {
|
||||
EliteADCBattery();
|
||||
if (!batteryCheck_flag) {
|
||||
ReadADCVin(spi_ADC_rxbuf);
|
||||
ADC_cnt = 1;
|
||||
} else {
|
||||
if (ADC_cnt == 0){
|
||||
HSTIA_change_gain();
|
||||
if (gainChange_flag) {
|
||||
gainChange_flag = false;
|
||||
instru.sampleRate = CalcDelayTime(instru.fset);
|
||||
instru.real = 0;
|
||||
instru.imag = 0;
|
||||
ADC_cnt = 0;
|
||||
} else {
|
||||
instru.sampleRate = 15;
|
||||
ADC_cnt ++;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* ADC_cnt: 0 - read Vin and do NOT buffer the Vin after changing gain twice
|
||||
* 1 - read Vin and increase ADC_cnt
|
||||
* 2 - read Vin and reset ADC_cnt
|
||||
*/
|
||||
if (ADC_cnt == 0) {
|
||||
read_Vin_change_gain();
|
||||
DACenable(AFTER_READ_V);
|
||||
ReadADCVin(spi_ADC_rxbuf);
|
||||
ADC_cnt++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ADC_cnt == 1) {
|
||||
ReadADCVin(spi_ADC_rxbuf);
|
||||
ADC_cnt = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void Vout_Plot(void)
|
||||
{
|
||||
static uint8_t ADC_cnt = 0;
|
||||
void *wm = wm_get();
|
||||
|
||||
/* measure battery if needs */
|
||||
if (batteryCheck_flag) {
|
||||
EliteADCBattery();
|
||||
if (!batteryCheck_flag) {
|
||||
ReadADCVout(spi_ADC_rxbuf);
|
||||
ADC_cnt = 1;
|
||||
else if (ADC_cnt == 1) {
|
||||
HSTIA_change_gain();
|
||||
if (firstFreq_flag) {
|
||||
if (instru.fset >= 10000000) {
|
||||
if (high_freq_cnt == 3) {
|
||||
firstFreq_flag = false;
|
||||
}
|
||||
high_freq_cnt ++;
|
||||
} else {
|
||||
firstFreq_flag = false;
|
||||
}
|
||||
instru.sampleRate = CalcDelayTime(instru.fset);
|
||||
instru.real = 0;
|
||||
instru.imag = 0;
|
||||
ADC_cnt = 0;
|
||||
} else {
|
||||
instru.sampleRate = 15;
|
||||
ADC_cnt ++;
|
||||
}
|
||||
}
|
||||
else if (ADC_cnt == 2) {
|
||||
realSum += instru.real;
|
||||
imagSum += instru.imag;
|
||||
avg_count++;
|
||||
instru.sampleRate = CalcDelayTime(instru.fset);
|
||||
if (avg_count == avgNumTable[instru.avgnum]){
|
||||
avg_real = (realSum + avg_count / 2) / avg_count;
|
||||
avg_imag = (imagSum + avg_count / 2) / avg_count;
|
||||
avg_count = 0;
|
||||
realSum = 0;
|
||||
imagSum = 0;
|
||||
EnDFTnADC(0);
|
||||
if(eis->_direction_up){
|
||||
if (instru.fset >= eis->_fmax) {
|
||||
PeriodicEvent = false;
|
||||
finishMode = 1;
|
||||
}
|
||||
} else {
|
||||
if (instru.fset <= eis->_fmin) {
|
||||
PeriodicEvent = false;
|
||||
finishMode = 1;
|
||||
}
|
||||
}
|
||||
notify_flag = true;
|
||||
high_freq_cnt = 0;
|
||||
}
|
||||
ADC_cnt = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* ADC_cnt: 0 - read Vout and do NOT buffer the Vout after changing gain twice
|
||||
* 1 - read Vout and increase ADC_cnt
|
||||
* 2 - read Vout and reset ADC_cnt
|
||||
*/
|
||||
if (ADC_cnt == 0) {
|
||||
read_Vout_change_gain();
|
||||
DACenable(AFTER_READ_V);
|
||||
ReadADCVout(spi_ADC_rxbuf);
|
||||
ADC_cnt++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ADC_cnt == 1) {
|
||||
ReadADCVout(spi_ADC_rxbuf);
|
||||
ADC_cnt = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
InputNotify(NOTIFY_CURRENT, avg_imag);
|
||||
InputNotify(NOTIFY_VOLT, avg_real);
|
||||
InputNotify(NOTIFY_IMPEDANCE, instru.fset);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -422,29 +456,45 @@ static void cali_IT_plot(void) {
|
||||
static uint16_t cali_count = 0;
|
||||
static uint8_t ADC_cnt = 0;
|
||||
static uint8_t rec_cnt = 0;
|
||||
static uint16_t cali_count_max = 1000;
|
||||
static uint16_t cali_count_max = 5000;
|
||||
int32_t ADCValueAVG = 0;
|
||||
int32_t temp = 0;
|
||||
|
||||
/* ADC_cnt: 0 - read Iin and do NOT buffer the Iin after changing gain twice
|
||||
* 1 - read Iin and increase ADC_cnt
|
||||
* 2 - read Iin and reset ADC_cnt
|
||||
*/
|
||||
if (ADC_cnt == 0) {
|
||||
if (instru.AutoGainEnable) {
|
||||
MEAS_CURR(wm) = 0xFFFF;
|
||||
if (instru.HSTIAAutoGainEnable) {
|
||||
temp = 0xFFFF;
|
||||
} else {
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
MEAS_CURR(wm) = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
|
||||
if (lastIinADCGainLevel != instru.ADCGainLv) {
|
||||
IinADCGainControl(instru.ADCGainLv);
|
||||
}
|
||||
// MEAS_CURR(wm) = (ReadRawADC() & 0x0000FFFF);
|
||||
temp = (ReadRealZ() & 0x0003FFFF);
|
||||
}
|
||||
|
||||
if (instru.ADCGainLv == 0) {
|
||||
cali_count_max = 5000;
|
||||
} else {
|
||||
cali_count_max = 1000;
|
||||
}
|
||||
// switch (instru.AdcChannel) {
|
||||
// case EIS_HSTIA: {
|
||||
// if (instru.HSTIAGainLv == 0) {
|
||||
// cali_count_max = 5000;
|
||||
// } else {
|
||||
// cali_count_max = 1000;
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// case EIS_LPTIA: {
|
||||
// if (instru.LPTIAGainLv == 0) {
|
||||
// cali_count_max = 5000;
|
||||
// } else {
|
||||
// cali_count_max = 1000;
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// default:{
|
||||
// cali_count_max = 1000;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
cali_count_max = 3000;
|
||||
|
||||
if (record_flag == false) {
|
||||
rec_cnt++;
|
||||
@@ -453,6 +503,7 @@ static void cali_IT_plot(void) {
|
||||
ADCValueAVG = ADCValueSUM / cali_count;
|
||||
|
||||
InputNotify(NOTIFY_CURRENT, ADCValueAVG);
|
||||
// InputNotify(NOTIFY_VOLT, ADCValueAVG);
|
||||
SendNotify();
|
||||
|
||||
uint8_t CIS_buf[9] = {0};
|
||||
@@ -460,7 +511,7 @@ static void cali_IT_plot(void) {
|
||||
CIS_buf[1] = (uint8_t) ((ADCValueAVG & 0xFF00) >> 8);
|
||||
CIS_buf[2] = (uint8_t) (ADCValueAVG & 0x00FF);
|
||||
CIS_buf[3] = 0x00;
|
||||
CIS_buf[4] = instru.ADCGainLv;
|
||||
CIS_buf[4] = instru.HSTIAGainLv;
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 9, CIS_buf);
|
||||
|
||||
PeriodicEvent = false;
|
||||
@@ -469,10 +520,10 @@ static void cali_IT_plot(void) {
|
||||
ModeLED(NO_EVENT);
|
||||
} else {
|
||||
cali_count++;
|
||||
ADCValueSUM = ADCValueSUM + MEAS_CURR(wm);
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_VOLT, ADCValueSUM);
|
||||
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
|
||||
ADCValueSUM = ADCValueSUM + temp;
|
||||
InputNotify(NOTIFY_CURRENT, temp);
|
||||
InputNotify(NOTIFY_VOLT, temp);
|
||||
// InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -486,14 +537,14 @@ static void cali_IT_plot(void) {
|
||||
}
|
||||
|
||||
if (ADC_cnt == 1) {
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ReadRealZ();
|
||||
ADC_cnt++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ADC_cnt == 2) {
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ReadRealZ();
|
||||
ADC_cnt = 0;
|
||||
|
||||
return;
|
||||
@@ -511,25 +562,28 @@ static void cali_VT_plot(void) {
|
||||
static uint8_t rec_cnt = 0;
|
||||
uint16_t cali_count_max = 0;
|
||||
int32_t ADCValueAVG = 0;
|
||||
int32_t temp = 0;
|
||||
|
||||
/* ADC_cnt: 0 - read Vin and do NOT buffer the Vin after changing gain twice
|
||||
* 1 - read Vin and increase ADC_cnt
|
||||
* 2 - read Vin and reset ADC_cnt
|
||||
*/
|
||||
if (ADC_cnt == 0) {
|
||||
if (instru.VinAutoGainEnable) {
|
||||
MEAS_VIN(wm) = 0xFFFF;
|
||||
if (instru.LPTIAAutoGainEnable) {
|
||||
// MEAS_VIN(wm) = 0xFFFF;
|
||||
temp = 0xFFFF;
|
||||
} else {
|
||||
ReadADCVin(spi_ADC_rxbuf);
|
||||
MEAS_VIN(wm) = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
|
||||
if (lastVinADCGainLv != instru.VinADCGainLv) VinADCGainCtrl(instru.VinADCGainLv);
|
||||
// ReadADCVin(spi_ADC_rxbuf);
|
||||
// MEAS_VIN(wm) = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
|
||||
temp = (ReadRealZ() & 0x0003FFFF);
|
||||
// if (lastVinADCGainLv != instru.VinADCGainLv) VinADCGainCtrl(instru.VinADCGainLv);
|
||||
}
|
||||
|
||||
if (instru.VinADCGainLv == 0) {
|
||||
cali_count_max = 5000;
|
||||
} else {
|
||||
cali_count_max = 1000;
|
||||
}
|
||||
// if (instru.VinADCGainLv == 0) {
|
||||
cali_count_max = 3000;
|
||||
// } else {
|
||||
// cali_count_max = 1000;
|
||||
// }
|
||||
|
||||
if (record_flag == false) {
|
||||
rec_cnt++;
|
||||
@@ -554,8 +608,8 @@ static void cali_VT_plot(void) {
|
||||
ModeLED(NO_EVENT);
|
||||
} else {
|
||||
cali_count++;
|
||||
ADCValueSUM = ADCValueSUM + MEAS_VIN(wm);
|
||||
InputNotify(NOTIFY_VOLT, MEAS_VIN(wm));
|
||||
ADCValueSUM = ADCValueSUM + temp;
|
||||
InputNotify(NOTIFY_VOLT, temp);
|
||||
InputNotify(NOTIFY_CURRENT, ADCValueSUM);
|
||||
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
|
||||
}
|
||||
@@ -571,14 +625,14 @@ static void cali_VT_plot(void) {
|
||||
}
|
||||
|
||||
if (ADC_cnt == 1) {
|
||||
ReadADCVin(spi_ADC_rxbuf);
|
||||
// ReadRealZ();
|
||||
ADC_cnt++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ADC_cnt == 2) {
|
||||
ReadADCVin(spi_ADC_rxbuf);
|
||||
// ReadRealZ();
|
||||
ADC_cnt = 0;
|
||||
|
||||
return;
|
||||
@@ -588,3 +642,4 @@ static void cali_VT_plot(void) {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+4
-4
@@ -3,10 +3,10 @@
|
||||
#define VERSION_DATE
|
||||
|
||||
#define VERSION_DATE_YEAR 21
|
||||
#define VERSION_DATE_MONTH 6
|
||||
#define VERSION_DATE_DAY 17
|
||||
#define VERSION_DATE_HOUR 12
|
||||
#define VERSION_DATE_MINUTE 18
|
||||
#define VERSION_DATE_MONTH 8
|
||||
#define VERSION_DATE_DAY 30
|
||||
#define VERSION_DATE_HOUR 15
|
||||
#define VERSION_DATE_MINUTE 47
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
#include "eis_cali_table.h"
|
||||
|
||||
/* SendCaliValue
|
||||
* 2~ : cutoff frequency
|
||||
* 4~5 : voltage amplitude
|
||||
* 2 : phase parameter a
|
||||
* 3 : phase parameter b
|
||||
* 4 : HSRTIA200R
|
||||
* 5 : HSRTIA5K
|
||||
* 6 : HSRTIA20K
|
||||
* 7 : HSRTIA160K
|
||||
*/
|
||||
|
||||
static void SendCaliValue0(void) {
|
||||
uint8_t cali_buf[BLE_CIS_BUFF_SIZE];
|
||||
|
||||
uint8_t index = 2;
|
||||
|
||||
cali_buf[1] = instru.chip_id;
|
||||
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.CutoffFreq >> 24) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.CutoffFreq >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.CutoffFreq >> 8) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.CutoffFreq & 0xFF;
|
||||
|
||||
// cali_buf[index++] = (uint8_t) CaliTable.Temp & 0xFF;
|
||||
|
||||
// cali_buf[index++] = (uint8_t) CaliTable.HSRTIA200R & 0xFF;
|
||||
//
|
||||
// cali_buf[index++] = (uint8_t) (CaliTable.HSRTIA5K >> 8) & 0xFF;
|
||||
// cali_buf[index++] = (uint8_t) CaliTable.HSRTIA5K & 0xFF;
|
||||
|
||||
// cali_buf[index++] = (uint8_t) (CaliTable.HSRTIA20K >> 8) & 0xFF;
|
||||
// cali_buf[index++] = (uint8_t) CaliTable.HSRTIA20K & 0xFF;
|
||||
//
|
||||
// cali_buf[index++] = (uint8_t) (CaliTable.HSRTIA160K >> 24) & 0xFF;
|
||||
// cali_buf[index++] = (uint8_t) (CaliTable.HSRTIA160K >> 16) & 0xFF;
|
||||
// cali_buf[index++] = (uint8_t) (CaliTable.HSRTIA160K >> 8) & 0xFF;
|
||||
// cali_buf[index++] = (uint8_t) CaliTable.HSRTIA160K & 0xFF;
|
||||
|
||||
cali_buf[0] = index - 1;
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 20, cali_buf);
|
||||
}
|
||||
|
||||
static void SendCaliValue1(void) {
|
||||
uint8_t cali_buf[BLE_CIS_BUFF_SIZE];
|
||||
|
||||
uint8_t filter_number1 = 2, index = 2;
|
||||
|
||||
cali_buf[1] = instru.chip_id;
|
||||
|
||||
for (int i = 0; i < filter_number1 ; i++) {
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Ft[i].PhaseParaA >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Ft[i].PhaseParaA >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Ft[i].PhaseParaA >> 8)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Ft[i].PhaseParaA & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Ft[i].PhaseParaB >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Ft[i].PhaseParaB >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Ft[i].PhaseParaB >> 8) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Ft[i].PhaseParaB & 0xFF;
|
||||
}
|
||||
|
||||
cali_buf[0] = index - 1;
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 20, cali_buf);
|
||||
}
|
||||
|
||||
static void SendCaliValue2(void) {
|
||||
uint8_t cali_buf[BLE_CIS_BUFF_SIZE];
|
||||
|
||||
uint8_t filter_number1 = 2, filter_number2 = 4, index = 2;
|
||||
|
||||
cali_buf[1] = instru.chip_id;
|
||||
|
||||
for (int i = filter_number1; i < filter_number2 ; i++) {
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Ft[i].PhaseParaA >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Ft[i].PhaseParaA >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Ft[i].PhaseParaA >> 8)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Ft[i].PhaseParaA & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Ft[i].PhaseParaB >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Ft[i].PhaseParaB >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Ft[i].PhaseParaB >> 8) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Ft[i].PhaseParaB & 0xFF;
|
||||
}
|
||||
|
||||
cali_buf[0] = index - 1;
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, index, cali_buf);
|
||||
}
|
||||
|
||||
static void SendCaliValue3(void) {
|
||||
uint8_t cali_buf[BLE_CIS_BUFF_SIZE];
|
||||
|
||||
uint8_t index = 2;
|
||||
|
||||
cali_buf[1] = instru.chip_id;
|
||||
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[0].HSRTIA_a >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[0].HSRTIA_a >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[0].HSRTIA_a >> 8)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Lv[0].HSRTIA_a & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[0].HSRTIA_b >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[0].HSRTIA_b >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[0].HSRTIA_b >> 8) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Lv[0].HSRTIA_b & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[0].HSRTIA_c >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[0].HSRTIA_c >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[0].HSRTIA_c >> 8) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Lv[0].HSRTIA_c & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Lv[0].HSRTIA_d & 0xFF;
|
||||
|
||||
cali_buf[0] = index - 1;
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, index, cali_buf);
|
||||
}
|
||||
|
||||
static void SendCaliValue4(void) {
|
||||
uint8_t cali_buf[BLE_CIS_BUFF_SIZE];
|
||||
|
||||
uint8_t index = 2;
|
||||
|
||||
cali_buf[1] = instru.chip_id;
|
||||
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[1].HSRTIA_a >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[1].HSRTIA_a >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[1].HSRTIA_a >> 8)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Lv[1].HSRTIA_a & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[1].HSRTIA_b >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[1].HSRTIA_b >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[1].HSRTIA_b >> 8) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Lv[1].HSRTIA_b & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[1].HSRTIA_c >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[1].HSRTIA_c >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[1].HSRTIA_c >> 8) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Lv[1].HSRTIA_c & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Lv[1].HSRTIA_d & 0xFF;
|
||||
|
||||
cali_buf[0] = index - 1;
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, index, cali_buf);
|
||||
}
|
||||
|
||||
static void SendCaliValue5(void) {
|
||||
uint8_t cali_buf[BLE_CIS_BUFF_SIZE];
|
||||
|
||||
uint8_t index = 2;
|
||||
|
||||
cali_buf[1] = instru.chip_id;
|
||||
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[2].HSRTIA_a >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[2].HSRTIA_a >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[2].HSRTIA_a >> 8)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Lv[2].HSRTIA_a & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[2].HSRTIA_b >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[2].HSRTIA_b >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[2].HSRTIA_b >> 8) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Lv[2].HSRTIA_b & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[2].HSRTIA_c >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[2].HSRTIA_c >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[2].HSRTIA_c >> 8) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Lv[2].HSRTIA_c & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Lv[2].HSRTIA_d & 0xFF;
|
||||
|
||||
cali_buf[0] = index - 1;
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, index, cali_buf);
|
||||
}
|
||||
|
||||
static void SendCaliValue6(void) {
|
||||
uint8_t cali_buf[BLE_CIS_BUFF_SIZE];
|
||||
|
||||
uint8_t index = 2;
|
||||
|
||||
cali_buf[1] = instru.chip_id;
|
||||
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[3].HSRTIA_a >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[3].HSRTIA_a >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[3].HSRTIA_a >> 8)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Lv[3].HSRTIA_a & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[3].HSRTIA_b >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[3].HSRTIA_b >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[3].HSRTIA_b >> 8) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Lv[3].HSRTIA_b & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[3].HSRTIA_c >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[3].HSRTIA_c >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[3].HSRTIA_c >> 8) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Lv[3].HSRTIA_c & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[3].HSRTIA_d >> 24)& 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[3].HSRTIA_d >> 16) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) (CaliTable.Lv[3].HSRTIA_d >> 8) & 0xFF;
|
||||
cali_buf[index++] = (uint8_t) CaliTable.Lv[3].HSRTIA_d & 0xFF;
|
||||
|
||||
cali_buf[0] = index - 1;
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, index, cali_buf);
|
||||
}
|
||||
+448
@@ -0,0 +1,448 @@
|
||||
#ifndef EIS_CALI_TABLE
|
||||
#define EIS_CALI_TABLE
|
||||
|
||||
#define BOARD_TEST
|
||||
|
||||
typedef struct _SingleFilterCali{
|
||||
uint32_t PhaseParaA;
|
||||
int32_t PhaseParaB;
|
||||
}SingleFilterCali;
|
||||
|
||||
typedef struct _SingleGainLvCali{
|
||||
long long HSTIA_coeff;
|
||||
long long HSTIA_offset;
|
||||
long long LPTIA_coeff;
|
||||
long long LPTIA_offset;
|
||||
uint32_t HSRTIA_a;
|
||||
int32_t HSRTIA_b;
|
||||
int32_t HSRTIA_c;
|
||||
uint32_t HSRTIA_d;
|
||||
uint16_t HSRTIA_root;
|
||||
}SingleGainLvCali;
|
||||
|
||||
struct _CaliTable{
|
||||
//CIS to Controller
|
||||
char DeviceName[25];
|
||||
uint32_t CutoffFreq;
|
||||
int32_t DAC_offset;
|
||||
SingleFilterCali Ft[7];
|
||||
|
||||
//EIS
|
||||
long long HSDAC_coeff;
|
||||
long long HSDAC_offset;
|
||||
long long LPDAC_coeff;
|
||||
long long LPDAC_offset;
|
||||
long long HSAMP_coeff;
|
||||
long long HSAMP_offset;
|
||||
SingleGainLvCali Lv[4];
|
||||
|
||||
}CaliTable =
|
||||
|
||||
#ifdef BOARD_TEST
|
||||
{
|
||||
//CIS to Controller
|
||||
.DeviceName = "BOARD_TEST",
|
||||
.CutoffFreq = 250000,
|
||||
.DAC_offset = 0, // * 200 [5n]
|
||||
|
||||
// hsrtia160k
|
||||
.Lv[0].HSRTIA_a = 0, // 1e8
|
||||
.Lv[0].HSRTIA_b = 1, // 1e8
|
||||
.Lv[0].HSRTIA_c = 0, // 1e4
|
||||
.Lv[0].HSRTIA_d = 0,
|
||||
|
||||
// hsrtia20k
|
||||
.Lv[1].HSRTIA_a = 0, // 1e8
|
||||
.Lv[1].HSRTIA_b = 1, // 1e8
|
||||
.Lv[1].HSRTIA_c = 0, // 1e4
|
||||
.Lv[1].HSRTIA_d = 0,
|
||||
|
||||
// hsrtia5k
|
||||
.Lv[2].HSRTIA_a = 0, //1e8
|
||||
.Lv[2].HSRTIA_b = 1, // 1e8
|
||||
.Lv[2].HSRTIA_c = 0, // 1e4
|
||||
.Lv[2].HSRTIA_d = 0,
|
||||
|
||||
// hsrtia200r a*exp(bx) + c*exp(dx)
|
||||
.Lv[3].HSRTIA_a = 1,
|
||||
.Lv[3].HSRTIA_b = 0, // 1e6
|
||||
.Lv[3].HSRTIA_c = 1, // 1e5
|
||||
.Lv[3].HSRTIA_d = 0, // 1e6
|
||||
|
||||
.Ft[0].PhaseParaA = 15,
|
||||
.Ft[0].PhaseParaB = -9000,
|
||||
.Ft[1].PhaseParaA = 15,
|
||||
.Ft[1].PhaseParaB = -9000,
|
||||
.Ft[2].PhaseParaA = 15,
|
||||
.Ft[2].PhaseParaB = -9000,
|
||||
.Ft[3].PhaseParaA = 15,
|
||||
.Ft[3].PhaseParaB = -9000,
|
||||
|
||||
//only for EIS 1e10
|
||||
.HSAMP_coeff = 9703610267,
|
||||
.HSAMP_offset = -12815281473,
|
||||
|
||||
.LPDAC_coeff = 10000464997,
|
||||
.LPDAC_offset = -75871559054,
|
||||
|
||||
.HSDAC_coeff = 25196655311242,
|
||||
.HSDAC_offset = 19932276246516,
|
||||
|
||||
.Lv[0].HSTIA_coeff = 1,
|
||||
.Lv[0].HSTIA_offset = 0,
|
||||
.Lv[1].HSTIA_coeff = 1,
|
||||
.Lv[1].HSTIA_offset = 0,
|
||||
.Lv[2].HSTIA_coeff = 1,
|
||||
.Lv[2].HSTIA_offset = 0,
|
||||
.Lv[3].HSTIA_coeff = 1,
|
||||
.Lv[3].HSTIA_offset = 0,
|
||||
|
||||
.Lv[0].LPTIA_coeff = 1,
|
||||
.Lv[0].LPTIA_offset = 0,
|
||||
.Lv[1].LPTIA_coeff = 1,
|
||||
.Lv[1].LPTIA_offset = 0,
|
||||
.Lv[2].LPTIA_coeff = 1,
|
||||
.Lv[2].LPTIA_offset = 0,
|
||||
.Lv[3].LPTIA_coeff = 1,
|
||||
.Lv[3].LPTIA_offset = 0
|
||||
};
|
||||
|
||||
#elif defined(BOARD_A4_DA_32_D4_EF_CF)
|
||||
{
|
||||
.DeviceName = "BOARD_A4_DA_32_D4_EF_CF",
|
||||
.CutoffFreq = 271000,
|
||||
.DAC_offset = -19250, // * 200 [5n]
|
||||
|
||||
// hsrtia160k
|
||||
.Lv[0].HSRTIA_a = 0, // 1e8
|
||||
.Lv[0].HSRTIA_b = 8005810, // 1e8
|
||||
.Lv[0].HSRTIA_c = -171109, // 1e4
|
||||
.Lv[0].HSRTIA_d = 0,
|
||||
|
||||
// hsrtia20k
|
||||
.Lv[1].HSRTIA_a = 357, // 1e8
|
||||
.Lv[1].HSRTIA_b = 57813915, // 1e8
|
||||
.Lv[1].HSRTIA_c = 1543941, // 1e4
|
||||
.Lv[1].HSRTIA_d = 0,
|
||||
|
||||
// hsrtia5k
|
||||
.Lv[2].HSRTIA_a = 15417, //1e8
|
||||
.Lv[2].HSRTIA_b = -62720427, // 1e8
|
||||
.Lv[2].HSRTIA_c = 225612029, // 1e4
|
||||
.Lv[2].HSRTIA_d = 0,
|
||||
|
||||
// hsrtia200r a*exp(bx) + c*exp(dx)
|
||||
.Lv[3].HSRTIA_a = 20450,
|
||||
.Lv[3].HSRTIA_b = 1611, // 1e6
|
||||
.Lv[3].HSRTIA_c = 4069, // 1e5
|
||||
.Lv[3].HSRTIA_d = 7499, // 1e6
|
||||
|
||||
.Ft[0].PhaseParaA = 141808, //1e10
|
||||
.Ft[0].PhaseParaB = -88304901, // 10000 Hz //1e6
|
||||
.Ft[1].PhaseParaA = 338333,
|
||||
.Ft[1].PhaseParaB = -89912194, // 100 Hz
|
||||
.Ft[2].PhaseParaA = 20541858,
|
||||
.Ft[2].PhaseParaB = -90000573, // 10 Hz
|
||||
.Ft[3].PhaseParaA = 100923290,
|
||||
.Ft[3].PhaseParaB = -90023337, // 0.01 Hz
|
||||
|
||||
//only for EIS 1e10
|
||||
.HSAMP_coeff = 9703610267,
|
||||
.HSAMP_offset = -12815281473,
|
||||
|
||||
.LPDAC_coeff = 10000464997,
|
||||
.LPDAC_offset = -75871559054,
|
||||
|
||||
.HSDAC_coeff = 25196655311242,
|
||||
.HSDAC_offset = 19932276246516,
|
||||
|
||||
.Lv[0].HSTIA_coeff = -1062,
|
||||
.Lv[0].HSTIA_offset = 67755568664846,
|
||||
.Lv[1].HSTIA_coeff = 23,
|
||||
.Lv[1].HSTIA_offset = 101767408723,
|
||||
.Lv[2].HSTIA_coeff = -31,
|
||||
.Lv[2].HSTIA_offset = 2037756,
|
||||
.Lv[3].HSTIA_coeff = -66623,
|
||||
.Lv[3].HSTIA_offset = 44299692,
|
||||
|
||||
.Lv[0].LPTIA_coeff = 1,
|
||||
.Lv[0].LPTIA_offset = 0,
|
||||
.Lv[1].LPTIA_coeff = 1,
|
||||
.Lv[1].LPTIA_offset = 0,
|
||||
.Lv[2].LPTIA_coeff = 1,
|
||||
.Lv[2].LPTIA_offset = 0,
|
||||
.Lv[3].LPTIA_coeff = 1,
|
||||
.Lv[3].LPTIA_offset = 0
|
||||
};
|
||||
|
||||
#elif defined(BOARD_A4_DA_32_D4_ED_BF)
|
||||
{
|
||||
.DeviceName = "BOARD_A4_DA_32_D4_ED_BF",
|
||||
.CutoffFreq = 262000,
|
||||
.DAC_offset = -19250, // * 200 [5n]
|
||||
|
||||
// hsrtia160k
|
||||
.Lv[0].HSRTIA_a = 0, // 1e8
|
||||
.Lv[0].HSRTIA_b = 8053030, // 1e8
|
||||
.Lv[0].HSRTIA_c = -217364, // 1e4
|
||||
.Lv[0].HSRTIA_d = 0,
|
||||
|
||||
// hsrtia20k
|
||||
.Lv[1].HSRTIA_a = 350, // 1e8
|
||||
.Lv[1].HSRTIA_b = 58929847, // 1e8
|
||||
.Lv[1].HSRTIA_c = 1111691, // 1e4
|
||||
.Lv[1].HSRTIA_d = 0,
|
||||
|
||||
// hsrtia5k
|
||||
.Lv[2].HSRTIA_a = 14842, //1e8
|
||||
.Lv[2].HSRTIA_b = -38831335, // 1e8
|
||||
.Lv[2].HSRTIA_c = 207680613, // 1e4
|
||||
.Lv[2].HSRTIA_d = 0,
|
||||
|
||||
// hsrtia200r a*exp(bx) + c*exp(dx)
|
||||
.Lv[3].HSRTIA_a = 20160,
|
||||
.Lv[3].HSRTIA_b = 1609, // 1e6
|
||||
.Lv[3].HSRTIA_c = 1085, // 1e5
|
||||
.Lv[3].HSRTIA_d = 7883, // 1e6
|
||||
|
||||
.Ft[0].PhaseParaA = 144194, //1e10
|
||||
.Ft[0].PhaseParaB = -88614855, // 10000 Hz //1e6
|
||||
.Ft[1].PhaseParaA = 342333,
|
||||
.Ft[1].PhaseParaB = -89906917, // 100 Hz
|
||||
.Ft[2].PhaseParaA = 20561112,
|
||||
.Ft[2].PhaseParaB = -90006375, // 10 Hz
|
||||
.Ft[3].PhaseParaA = 100878445,
|
||||
.Ft[3].PhaseParaB = -90013670, // 0.01 Hz
|
||||
|
||||
//only for EIS 1e10
|
||||
.HSAMP_coeff = 9703610267,
|
||||
.HSAMP_offset = -12815281473,
|
||||
|
||||
.LPDAC_coeff = 10000464997,
|
||||
.LPDAC_offset = -75871559054,
|
||||
|
||||
.HSDAC_coeff = 25196655311242,
|
||||
.HSDAC_offset = 19932276246516,
|
||||
|
||||
.Lv[0].HSTIA_coeff = -1062,
|
||||
.Lv[0].HSTIA_offset = 67755568664846,
|
||||
.Lv[1].HSTIA_coeff = 23,
|
||||
.Lv[1].HSTIA_offset = 101767408723,
|
||||
.Lv[2].HSTIA_coeff = -31,
|
||||
.Lv[2].HSTIA_offset = 2037756,
|
||||
.Lv[3].HSTIA_coeff = -66623,
|
||||
.Lv[3].HSTIA_offset = 44299692,
|
||||
|
||||
.Lv[0].LPTIA_coeff = 1,
|
||||
.Lv[0].LPTIA_offset = 0,
|
||||
.Lv[1].LPTIA_coeff = 1,
|
||||
.Lv[1].LPTIA_offset = 0,
|
||||
.Lv[2].LPTIA_coeff = 1,
|
||||
.Lv[2].LPTIA_offset = 0,
|
||||
.Lv[3].LPTIA_coeff = 1,
|
||||
.Lv[3].LPTIA_offset = 0
|
||||
};
|
||||
|
||||
#elif defined(BOARD_A4_DA_32_D4_F0_59)
|
||||
{
|
||||
.DeviceName = "BOARD_A4_DA_32_D4_F0_59",
|
||||
.CutoffFreq = 265000,
|
||||
.DAC_offset = -19250, // * 200 [5n]
|
||||
|
||||
// hsrtia160k
|
||||
.Lv[0].HSRTIA_a = 0, // 1e8
|
||||
.Lv[0].HSRTIA_b = 7982677, // 1e8
|
||||
.Lv[0].HSRTIA_c = -220834, // 1e4
|
||||
.Lv[0].HSRTIA_d = 0,
|
||||
|
||||
// hsrtia20k
|
||||
.Lv[1].HSRTIA_a = 386, // 1e8
|
||||
.Lv[1].HSRTIA_b = 56887373, // 1e8
|
||||
.Lv[1].HSRTIA_c = 2369927, // 1e4
|
||||
.Lv[1].HSRTIA_d = 0,
|
||||
|
||||
// hsrtia5k
|
||||
.Lv[2].HSRTIA_a = 14859, //1e8
|
||||
.Lv[2].HSRTIA_b = -43698725, // 1e8
|
||||
.Lv[2].HSRTIA_c = 210542432, // 1e4
|
||||
.Lv[2].HSRTIA_d = 0,
|
||||
|
||||
// hsrtia200r a*exp(bx) + c*exp(dx)
|
||||
.Lv[3].HSRTIA_a = 19600,
|
||||
.Lv[3].HSRTIA_b = 1637, // 1e6
|
||||
.Lv[3].HSRTIA_c = 659, // 1e5
|
||||
.Lv[3].HSRTIA_d = 8167, // 1e6
|
||||
|
||||
.Ft[0].PhaseParaA = 146177, //1e10
|
||||
.Ft[0].PhaseParaB = -88604805, // 10000 Hz //1e6
|
||||
.Ft[1].PhaseParaA = 342195,
|
||||
.Ft[1].PhaseParaB = -89912214, // 100 Hz
|
||||
.Ft[2].PhaseParaA = 20559398,
|
||||
.Ft[2].PhaseParaB = -90006634, // 10 Hz
|
||||
.Ft[3].PhaseParaA = 100415851,
|
||||
.Ft[3].PhaseParaB = -89982615, // 0.01 Hz
|
||||
|
||||
//only for EIS 1e10
|
||||
.HSAMP_coeff = 9703610267,
|
||||
.HSAMP_offset = -12815281473,
|
||||
|
||||
.LPDAC_coeff = 10000464997,
|
||||
.LPDAC_offset = -75871559054,
|
||||
|
||||
.HSDAC_coeff = 25196655311242,
|
||||
.HSDAC_offset = 19932276246516,
|
||||
|
||||
.Lv[0].HSTIA_coeff = -1062,
|
||||
.Lv[0].HSTIA_offset = 67755568664846,
|
||||
.Lv[1].HSTIA_coeff = 23,
|
||||
.Lv[1].HSTIA_offset = 101767408723,
|
||||
.Lv[2].HSTIA_coeff = -31,
|
||||
.Lv[2].HSTIA_offset = 2037756,
|
||||
.Lv[3].HSTIA_coeff = -66623,
|
||||
.Lv[3].HSTIA_offset = 44299692,
|
||||
|
||||
.Lv[0].LPTIA_coeff = 1,
|
||||
.Lv[0].LPTIA_offset = 0,
|
||||
.Lv[1].LPTIA_coeff = 1,
|
||||
.Lv[1].LPTIA_offset = 0,
|
||||
.Lv[2].LPTIA_coeff = 1,
|
||||
.Lv[2].LPTIA_offset = 0,
|
||||
.Lv[3].LPTIA_coeff = 1,
|
||||
.Lv[3].LPTIA_offset = 0
|
||||
};
|
||||
|
||||
#elif defined(BOARD_A4_DA_32_D4_ED_91)
|
||||
{
|
||||
.DeviceName = "BOARD_A4_DA_32_D4_ED_91",
|
||||
.CutoffFreq = 265550,
|
||||
.DAC_offset = -19250,
|
||||
|
||||
// hsrtia160k
|
||||
.Lv[0].HSRTIA_a = 0, // 1e8
|
||||
.Lv[0].HSRTIA_b = 7983901, // 1e8
|
||||
.Lv[0].HSRTIA_c = -217990, // 1e4
|
||||
.Lv[0].HSRTIA_d = 0,
|
||||
|
||||
// hsrtia20k
|
||||
.Lv[1].HSRTIA_a = 338, // 1e8
|
||||
.Lv[1].HSRTIA_b = 58576686, // 1e8
|
||||
.Lv[1].HSRTIA_c = 1238326, // 1e4
|
||||
.Lv[1].HSRTIA_d = 0,
|
||||
|
||||
// hsrtia5k
|
||||
.Lv[2].HSRTIA_a = 14554, //1e8
|
||||
.Lv[2].HSRTIA_b = -36919197, // 1e8
|
||||
.Lv[2].HSRTIA_c = 205602111, // 1e4
|
||||
.Lv[2].HSRTIA_d = 0,
|
||||
|
||||
// hsrtia200r a*exp(bx) + c*exp(dx)
|
||||
.Lv[3].HSRTIA_a = 19890,
|
||||
.Lv[3].HSRTIA_b = 1620, // 1e6
|
||||
.Lv[3].HSRTIA_c = 893, // 1e5
|
||||
.Lv[3].HSRTIA_d = 7970, // 1e6
|
||||
|
||||
.Ft[0].PhaseParaA = 146478, //1e10
|
||||
.Ft[0].PhaseParaB = -88583908, // 10000 Hz //1e6
|
||||
.Ft[1].PhaseParaA = 342341,
|
||||
.Ft[1].PhaseParaB = -89891632, // 100 Hz
|
||||
.Ft[2].PhaseParaA = 20576527,
|
||||
.Ft[2].PhaseParaB = -90009194, // 10 Hz
|
||||
.Ft[3].PhaseParaA = 100884331,
|
||||
.Ft[3].PhaseParaB = -90024204, // 0.01 Hz
|
||||
|
||||
//only for EIS 1e10
|
||||
.HSAMP_coeff = 9703610267,
|
||||
.HSAMP_offset = -12815281473,
|
||||
|
||||
.LPDAC_coeff = 10000464997,
|
||||
.LPDAC_offset = -75871559054,
|
||||
|
||||
.HSDAC_coeff = 25196655311242,
|
||||
.HSDAC_offset = 19932276246516,
|
||||
|
||||
.Lv[0].HSTIA_coeff = -1062,
|
||||
.Lv[0].HSTIA_offset = 67755568664846,
|
||||
.Lv[1].HSTIA_coeff = 23,
|
||||
.Lv[1].HSTIA_offset = 101767408723,
|
||||
.Lv[2].HSTIA_coeff = -31,
|
||||
.Lv[2].HSTIA_offset = 2037756,
|
||||
.Lv[3].HSTIA_coeff = -66623,
|
||||
.Lv[3].HSTIA_offset = 44299692,
|
||||
|
||||
.Lv[0].LPTIA_coeff = 1,
|
||||
.Lv[0].LPTIA_offset = 0,
|
||||
.Lv[1].LPTIA_coeff = 1,
|
||||
.Lv[1].LPTIA_offset = 0,
|
||||
.Lv[2].LPTIA_coeff = 1,
|
||||
.Lv[2].LPTIA_offset = 0,
|
||||
.Lv[3].LPTIA_coeff = 1,
|
||||
.Lv[3].LPTIA_offset = 0
|
||||
};
|
||||
|
||||
#elif defined(BOARD_A4_DA_32_D4_E7_D2)
|
||||
{
|
||||
.DeviceName = "BOARD_A4_DA_32_D4_E7_D2",
|
||||
.CutoffFreq = 275000,
|
||||
|
||||
.Ft[0].PhaseParaA = 155530, //1e10
|
||||
.Ft[0].PhaseParaB = -87720229, // 1e6
|
||||
.Ft[1].PhaseParaA = 341776,
|
||||
.Ft[1].PhaseParaB = -89919625,
|
||||
.Ft[2].PhaseParaA = 20542303,
|
||||
.Ft[2].PhaseParaB = -89997668,
|
||||
.Ft[3].PhaseParaA = 100310791,
|
||||
.Ft[3].PhaseParaB = -89988818,
|
||||
|
||||
|
||||
//only for EIS 1e8
|
||||
.HSAMP_coeff = 9745467306673,
|
||||
.HSAMP_offset = -11243183077,
|
||||
|
||||
.LPDAC_coeff = 1001472547,
|
||||
.LPDAC_offset = -395332002445,
|
||||
|
||||
.HSDAC_coeff = 2532582201433,
|
||||
.HSDAC_offset = 19873740865949,
|
||||
|
||||
.Lv[0].HSTIA_coeff = -4032141,
|
||||
.Lv[0].HSTIA_offset = 1040297509317,
|
||||
.Lv[1].HSTIA_coeff = -3181894,
|
||||
.Lv[1].HSTIA_offset = 820944361270,
|
||||
.Lv[2].HSTIA_coeff = -13482,
|
||||
.Lv[2].HSTIA_offset = 3480817953,
|
||||
.Lv[3].HSTIA_coeff = -333074,
|
||||
.Lv[3].HSTIA_offset = 85901359807,
|
||||
|
||||
.Lv[0].LPTIA_coeff = 1,
|
||||
.Lv[0].LPTIA_offset = 0,
|
||||
.Lv[1].LPTIA_coeff = 1,
|
||||
.Lv[1].LPTIA_offset = 0,
|
||||
.Lv[2].LPTIA_coeff = 1,
|
||||
.Lv[2].LPTIA_offset = 0,
|
||||
.Lv[3].LPTIA_coeff = 1,
|
||||
.Lv[3].LPTIA_offset = 0
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
static uint32_t Cali_LPDAC (uint32_t value) {
|
||||
uint32_t res;
|
||||
res = (uint32_t)(((int64_t)CaliTable.LPDAC_coeff * value + (int64_t)CaliTable.LPDAC_offset + 5e9) / 1e10);
|
||||
return res;
|
||||
}
|
||||
|
||||
static uint32_t Cali_HSAMP (uint16_t value) {
|
||||
uint32_t res;
|
||||
res = (uint32_t)(((int64_t)CaliTable.HSAMP_coeff * value + (int64_t)CaliTable.HSAMP_offset + 5e9) / 1e10);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static uint32_t Cali_HSTIA (uint32_t value, uint8_t gain_level) {
|
||||
uint32_t res;
|
||||
res = (uint32_t)(((int64_t)CaliTable.Lv[gain_level].HSTIA_coeff * value + (int64_t)CaliTable.Lv[gain_level].HSTIA_offset + 5e9) / 1e10);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
+427
-309
@@ -16,7 +16,7 @@ Stimulation pulse width 40 us .. 490 us (50 us/step)
|
||||
Stimulation pulse shape POS, NEG, P2N, N2P, AWF
|
||||
Stimulation pulse times 1 .. 253 (4 times/step)
|
||||
Stimulation pulse freq 30 .. 10K Hz
|
||||
======================= =============================
|
||||
======================= ========================F=====
|
||||
|
||||
=========================
|
||||
Instruction Specification
|
||||
@@ -435,14 +435,16 @@ characteristic change event
|
||||
EliteZM02 0,2,1,5
|
||||
EliteZM15 0,2,1,6
|
||||
EliteZM_pulsefly 0,2,1,7
|
||||
ELITEEIS 0,4,1,0
|
||||
**************************/
|
||||
// product information
|
||||
#define DEVICE_NAME "Elite"
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0 //0:Elite ,1:Neulive
|
||||
#define MINOR_PRODUCT_NUMBER 2 //1:Elite_legacy(Ori_Neulive) 2:Elite_zm 3:Elite_bat
|
||||
#define MINOR_PRODUCT_NUMBER 4 //1:Elite_legacy(Ori_Neulive) 2:Elite_zm 3:Elite_bat 4:Elite_EIS
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 6
|
||||
#define ELITE_VERSION_1_4
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#define ELITE_VERSION_EIS
|
||||
//#define ELITE_VERSION_1_4
|
||||
//#define ELITE_VERSION_1_3
|
||||
|
||||
// buffer size
|
||||
@@ -475,6 +477,7 @@ static uint8 channel_table[CHANNEL_COUNT] = {0};
|
||||
static uint8_t ins_buf[BLE_INS_BUFF_SIZE] = {0};
|
||||
static uint8_t not_buf[BLE_DAT_BUFF_SIZE] = {0};
|
||||
static uint8_t cis_buf[BLE_CIS_BUFF_SIZE] = {0};
|
||||
//static uint8_t cali_buf[BLE_CIS_BUFF_SIZE] = {0}
|
||||
|
||||
/**
|
||||
* Latch initialize
|
||||
@@ -553,18 +556,42 @@ static uint32_t notifyRateTable[6] = {100, 1000, 2000, 10000, 100000, 1000000};
|
||||
1 Hz: 10000 ,
|
||||
0.1 Hz: 100000 ,
|
||||
0.01 Hz: 1000000 }*/
|
||||
static uint32_t VsetRateTable[5] = {2, 10, 100, 1000, 10000};
|
||||
static uint32_t VsetRateTable[5] = {2, 10, 100, 1000, 10000}; //0.2ms
|
||||
static uint8_t avgNumTable[4] = {2, 4, 6, 8};
|
||||
static uint16_t LogSpacingTable10[10] = {1000, 1292, 1668, 2154, 2783, 3594, 4642, 5995, 7743, 10000};
|
||||
static uint16_t LogSpacingTable9[9] = {1000, 1334, 1778, 2371, 3162, 4217, 5623, 7499, 10000};
|
||||
static uint16_t LogSpacingTable8[8] = {1000, 1389, 1931, 2683, 3728, 5179, 7197, 10000};
|
||||
static uint16_t LogSpacingTable7[7] = {1000, 1468, 2154, 3162, 4642, 6813, 10000};
|
||||
static uint16_t LogSpacingTable6[6] = {1000, 1585, 2512, 3981, 6310, 10000};
|
||||
static uint16_t LogSpacingTable5[5] = {1000, 1778, 3162, 5623, 10000};
|
||||
static uint16_t LogSpacingTable4[4] = {1000, 2154, 4642, 10000};
|
||||
static uint16_t LogSpacingTable3[3] = {1000, 3162, 10000};
|
||||
static uint16_t LogSpacingTable2[2] = {1000, 10000};
|
||||
static uint32_t TenPowerTable[9] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000};
|
||||
static bool batteryCheck_flag;
|
||||
static bool batteryADC_flag;
|
||||
static bool ADC_flag;
|
||||
static bool vscan_flag;
|
||||
static bool notify_flag;
|
||||
static bool notifyFirst_flag;
|
||||
static bool impedanceRead_flag;
|
||||
static bool record_flag;
|
||||
static bool vscanReset;
|
||||
static bool mode_init;
|
||||
static bool leadTimeReset;
|
||||
static bool firstTimeReset;
|
||||
static bool fset_flag;
|
||||
static bool fout_flag;
|
||||
static bool gainChange_flag;
|
||||
static bool firstFreq_flag;
|
||||
static uint32_t time0 = 0;
|
||||
static uint32_t time1 = 0;
|
||||
static uint32_t delta_time = 0;
|
||||
static uint32_t time10 = 0;
|
||||
static uint32_t time11 = 0;
|
||||
static uint32_t delta_time1 = 0;
|
||||
static uint32_t test_cnt = 0;
|
||||
|
||||
//pulse mode variable
|
||||
static bool stiFirstTime;
|
||||
static int16_t I_GAIN_100R_counter;
|
||||
@@ -584,45 +611,48 @@ static bool preWorkLedFlag = 0;
|
||||
static bool workingLedFlag = 0;
|
||||
static bool postWorkLedFlag = 0;
|
||||
|
||||
static void update_latch_status (uint32_t latch_num, uint32_t elite_pin, bool highlow);
|
||||
//EIS
|
||||
static uint32_t RtiaTable[5] = {30000, 12100, 4100, 210, 210};
|
||||
static void update_latch_status (uint32_t latch_num, uint32_t elite_pin, bool highlow);
|
||||
|
||||
// ADC function
|
||||
static int32_t DecodeADCValue(uint8_t ADCGain, uint8_t ADCChannel, uint8_t *ADC_raw);
|
||||
static void headstage_battery_volt();
|
||||
static void EliteADCBattery();
|
||||
static void VinADCGainCtrl(uint8_t VinADCLevel);
|
||||
static void VoutGainControl(uint8_t VOUTLevel);
|
||||
static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool highlow);
|
||||
static int32_t DecodeADCValue(uint8_t ADCGain, uint8_t ADCChannel, uint8_t *ADC_raw);
|
||||
static void headstage_battery_volt();
|
||||
static void EliteADCBattery();
|
||||
static void VinADCGainCtrl(uint8_t VinADCLevel);
|
||||
static void VoutGainControl(uint8_t VOUTLevel);
|
||||
static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool highlow);
|
||||
|
||||
// Elite key detection & turn on/ shutdown function (peripheral hardware control)
|
||||
static void Elite_led_color(uint16_t color);
|
||||
static void ModeLED(uint16_t modeStatus);
|
||||
static void Elite_led_color(uint16_t color);
|
||||
static void ModeLED(uint16_t modeStatus);
|
||||
//static void LED_color(uint8_t bright, uint8_t red, uint8_t green, uint8_t blue);
|
||||
static bool If10Von = false;
|
||||
static void TurnOn10V();
|
||||
static bool If10Von = false;
|
||||
static void TurnOn10V();
|
||||
|
||||
// periodic event control
|
||||
static void EliteADCControl(void);
|
||||
static void vscan_ctrl(void);
|
||||
static void mode_done(void);
|
||||
|
||||
//mode (Vset)
|
||||
static void lsv_vscan(void);
|
||||
static void ca_vscan(void);
|
||||
static void cv_vscan(void);
|
||||
static void cc_vscan(void);
|
||||
static void EliteADCControl(void);
|
||||
static void vscan_ctrl(void);
|
||||
static void cv_vscan(void);
|
||||
static void mode_done(void);
|
||||
|
||||
//mode (DAC)
|
||||
static void DACenable(uint8_t afterRead);
|
||||
static void volt_out();
|
||||
static void freq_out();
|
||||
static void vscan_volt_out(void);
|
||||
static void pulse_vscan(void);
|
||||
static void PowerMode_CutoffFrequencyControl (uint8_t bandwidth, uint8_t PowerMode);
|
||||
static uint32_t User2Freq(uint32_t UserCode);
|
||||
static int32_t neg_18bit(int32_t ret);
|
||||
|
||||
//mode (notify)
|
||||
static void initDATBuf();
|
||||
static void initDATBuf();
|
||||
|
||||
//init parameter
|
||||
static void InitEliteFlag();
|
||||
static void InitEliteFlag();
|
||||
|
||||
//EIS crap
|
||||
static void AD5940_HWReset();
|
||||
|
||||
#include "EliteInstruction.h"
|
||||
#include "EliteADC.h"
|
||||
@@ -639,198 +669,65 @@ static void InitEliteFlag();
|
||||
#include "EliteNotify.h"
|
||||
#include "EliteFlagCTInit.h"
|
||||
#include "EliteLatchInit.h"
|
||||
#include "AD5940.h"
|
||||
#include "EliteReset.h"
|
||||
#include "EliteLED.h"
|
||||
#include "EliteKeyDetect.h"
|
||||
#include "Elite_mode_ADC_DAC.h"
|
||||
#include "EliteCCMode.h"
|
||||
#include "EliteIVCurve.h"
|
||||
#include "EliteCVCurve.h"
|
||||
#include "EliteZTCurve.h"
|
||||
#include "EliteEISMode.h"
|
||||
#include "impedance_meter.h"
|
||||
#include "Elite_version.h"
|
||||
#include "EliteCV3Mode.h"
|
||||
#include "EliteLSVMode.h"
|
||||
#include "EliteCVSCANMode.h"
|
||||
#include "ElitePulseMode.h"
|
||||
#include "Elite_batt.h"
|
||||
#include "Elite_power.h"
|
||||
#include "eis_cali_cis.h"
|
||||
|
||||
// update instruction for Z meter
|
||||
static void update_ZM_instruction(uint8 *ins) {
|
||||
uint8_t ins_type = ins[0] & 0b11110000;
|
||||
uint8_t chip_ID = ins[0] & 0b00001111;
|
||||
uint8_t oper = ins[1] & 0xF0; // this is don't care in RIS
|
||||
instru.chip_id = chip_ID;
|
||||
uint8_t oper = ins[1] & 0xF0; // this is don't care in RISASD;//
|
||||
instru.chip_id = chip_ID;
|
||||
|
||||
switch (ins_type) {
|
||||
|
||||
case INS_TYPE_RIS: {
|
||||
switch (ins[2]) {
|
||||
case CURVE_IV: {
|
||||
instru.eliteFxn = CURVE_IV;
|
||||
instru.sampleRate = 15;
|
||||
instru.Ve1 = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
|
||||
instru.Ve2 = ((uint16_t)(ins[5]) << 8) | (uint16_t)(ins[6]);
|
||||
instru.Vinit = (int32_t)instru.Ve1;
|
||||
instru.Vmax = (int32_t)VMAX(instru.Ve1,instru.Ve2);
|
||||
instru.Vmin = (int32_t)VMIN(instru.Ve1,instru.Ve2);
|
||||
instru.directionInit = VDIRECTION(instru.Ve1,instru.Ve2);
|
||||
instru.notifyRate = (uint32_t)(ins[9]);
|
||||
instru.notifyRate = OldStep2NewStepTime(instru.notifyRate); //5000;10000;20000;
|
||||
instru.step = ((uint32_t)(ins[7]) << 8) | (uint32_t)(ins[8]);//1~1000 = 0.1mv ~ 100mv
|
||||
instru.step = instru.step * 100000 / instru.notifyRate;
|
||||
STEP_TO_VSETRATE(instru.step);
|
||||
instru.VsetRate = VsetRateTable[instru.VsetRateIndex];//N
|
||||
instru.cycleNumber = 1;
|
||||
case CURVE_EIS: { //0xD1
|
||||
if (ins[3] == PARA_1) { //3000D1 01
|
||||
instru.f1 = ((uint32_t)(ins[4]) << 24) | ((uint32_t)(ins[5]) << 16) | ((uint32_t)(ins[6]) << 8) | (uint32_t)(ins[7]); //FREQ_START
|
||||
instru.f2 = ((uint32_t)(ins[8]) << 24) | ((uint32_t)(ins[9]) << 16) | ((uint32_t)(ins[10]) << 8) | (uint32_t)(ins[11]); //FREQ_STOP
|
||||
instru.sampleRate = 15;//CalcDelayTime(User2Freq(instru.f1), true); //ms //read
|
||||
instru.fmax = (uint32_t)VMAX(instru.f1, instru.f2);
|
||||
instru.fmin = (uint32_t)VMIN(instru.f1, instru.f2);
|
||||
instru.delay = ((uint16_t)(ins[12]) << 8) | (uint16_t)(ins[13]); //DELAY/10 how many periods
|
||||
if (instru.f1 > instru.f2){
|
||||
instru.directionInit = 0; //0:reverse 1:forward
|
||||
} else if (instru.f1 <= instru.f2){
|
||||
instru.directionInit = 1;
|
||||
}
|
||||
} else if (ins[3] == PARA_2) { //3000D1 02
|
||||
instru.eliteFxn = CURVE_EIS;
|
||||
instru.dcbias = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
|
||||
instru.acamp = ((uint16_t)(ins[6]) << 8) | (uint16_t)(ins[7]);
|
||||
instru.avgnum = (uint8_t)(ins[8]);
|
||||
instru.rtia = (uint8_t)(ins[9]);
|
||||
instru.ppd = ((uint16_t)(ins[10]) << 8) | (uint16_t)(ins[11]);
|
||||
instru.scale = (uint8_t)(ins[12]);
|
||||
|
||||
if((instru.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && instru.Ve1 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE)
|
||||
&& (instru.Ve2 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && instru.Ve2 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE)){
|
||||
instru.VoutGainLevel = VOUT_GAIN_15K;
|
||||
} else {
|
||||
instru.VoutGainLevel = VOUT_GAIN_240K;
|
||||
instru.ADCGainLv = instru.rtia;
|
||||
|
||||
setEIS_EIS();
|
||||
|
||||
ModeLED(WORKING);
|
||||
}
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_IV_CY: {
|
||||
instru.eliteFxn = CURVE_IV_CY;
|
||||
instru.sampleRate = 15;
|
||||
instru.Ve1 = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
|
||||
instru.Ve2 = ((uint16_t)(ins[5]) << 8) | (uint16_t)(ins[6]);
|
||||
instru.Vinit = (int32_t)instru.Ve1;
|
||||
instru.Vmax = (int32_t)VMAX(instru.Ve1,instru.Ve2);
|
||||
instru.Vmin = (int32_t)VMIN(instru.Ve1,instru.Ve2);
|
||||
instru.directionInit = VDIRECTION(instru.Ve1,instru.Ve2);
|
||||
instru.notifyRate = (uint32_t)(ins[9]);
|
||||
instru.notifyRate = OldStep2NewStepTime(instru.notifyRate); //5000;10000;20000;
|
||||
instru.step = ((uint32_t)(ins[7]) << 8) | (uint32_t)(ins[8]);//1~1000 = 0.1mv ~ 100mv
|
||||
instru.step = instru.step * 100000 / instru.notifyRate;
|
||||
STEP_TO_VSETRATE(instru.step);
|
||||
instru.VsetRate = VsetRateTable[instru.VsetRateIndex];//N
|
||||
instru.cycleNumber = ((uint16_t)(ins[10]) << 8) | (uint16_t)(ins[11]);
|
||||
|
||||
if((instru.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && instru.Ve1 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE)
|
||||
&& (instru.Ve2 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && instru.Ve2 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE)){
|
||||
instru.VoutGainLevel = VOUT_GAIN_15K;
|
||||
}else{
|
||||
instru.VoutGainLevel = VOUT_GAIN_240K;
|
||||
}
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_VO: {
|
||||
instru.eliteFxn = CURVE_VO;
|
||||
instru.Ve1 = ((uint16_t)ins[3] << 8) | (uint16_t)ins[4];
|
||||
instru.Vinit = (int32_t)instru.Ve1;
|
||||
|
||||
if(instru.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && instru.Ve1 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE){
|
||||
instru.VoutGainLevel = VOUT_GAIN_15K;
|
||||
} else {
|
||||
instru.VoutGainLevel = VOUT_GAIN_240K;
|
||||
}
|
||||
|
||||
instru.notifyRate = ((uint32_t)ins[5] << 8) | (uint32_t)ins[6];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.sampleRate = 15;
|
||||
|
||||
// TODO: input to json
|
||||
instru.AutoGainEnable = 1;
|
||||
instru.ADCGainLv = I_GAIN_100R;
|
||||
IinADCGainControl(instru.ADCGainLv);
|
||||
instru.VinAutoGainEnable = 1;
|
||||
instru.VinADCGainLv = VIN_GAIN_1K;
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
// end
|
||||
ModeLED(WORKING);
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_RT: {
|
||||
instru.eliteFxn = CURVE_RT;
|
||||
instru.notifyRate = ((uint32_t)ins[3] << 8) | (uint32_t)ins[4];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.sampleRate = 15;
|
||||
instru.VsetRate = 2;
|
||||
instru.Ve1 = 25000 + 5000;
|
||||
instru.Vinit = (int32_t)instru.Ve1;
|
||||
|
||||
// TODO: input to json
|
||||
instru.AutoGainEnable = 1;
|
||||
instru.ADCGainLv = I_GAIN_100R;
|
||||
IinADCGainControl(instru.ADCGainLv);
|
||||
instru.VinAutoGainEnable = 1;
|
||||
instru.VinADCGainLv = VIN_GAIN_1K;
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
// end
|
||||
|
||||
|
||||
if(instru.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && instru.Ve1 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE){
|
||||
instru.VoutGainLevel = VOUT_GAIN_15K;
|
||||
} else {
|
||||
instru.VoutGainLevel = VOUT_GAIN_240K;
|
||||
}
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_VT: {
|
||||
instru.eliteFxn = CURVE_VT;
|
||||
instru.notifyRate = ((uint32_t)ins[3] << 8) | (uint32_t)ins[4];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.sampleRate = 15;
|
||||
ModeLED(WORKING);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_OCP: {
|
||||
instru.eliteFxn = CURVE_OCP;
|
||||
instru.notifyRate = ((uint32_t)ins[3] << 8) | (uint32_t)ins[4];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.sampleRate = 15;
|
||||
ModeLED(WORKING);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_IT: {
|
||||
instru.eliteFxn = CURVE_IT;
|
||||
instru.notifyRate = ((uint32_t)ins[3] << 8) | (uint32_t)ins[4];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.sampleRate = 15;
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_CC: {
|
||||
instru.eliteFxn = CURVE_CC;
|
||||
instru.notifyRate = ((uint32_t)ins[12] << 8) | (uint32_t)ins[13];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.sampleRate = 15;
|
||||
instru.charge = ins[3]; //0:discharge 1:charge
|
||||
instru.constantCurrent = (uint32_t)(ins[4]) << 24 | (uint32_t)(ins[5]) << 16 | (uint32_t)(ins[6]) << 8 | (uint32_t)(ins[7]);
|
||||
instru.Vmax = (uint32_t)(ins[8]) << 8 | (uint32_t)(ins[9]);
|
||||
instru.Vmin = (uint32_t)(ins[10]) << 8 | (uint32_t)(ins[11]);
|
||||
|
||||
instru.VoutGainLevel = VOUT_GAIN_240K;
|
||||
ModeLED(WORKING);
|
||||
/*******************************************************
|
||||
controller instruction
|
||||
ins[3] -> Charge, 0:discharge 1:charge
|
||||
ins[6:9] -> ConstantCurrent, 0 ~ 15000uA : 0 ~ 1500000
|
||||
********************************************************/
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_CV: {
|
||||
case CURVE_EIS_CV: {
|
||||
if (ins[3] == PARA_1) {
|
||||
instru.sampleRate = 15;
|
||||
instru.Vinit = ((int32_t)(ins[4]) << 8) | (int32_t)(ins[5]);
|
||||
instru.Vinit = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
|
||||
instru.Ve1 = ((uint16_t)(ins[6]) << 8) | (uint16_t)(ins[7]);
|
||||
instru.Ve2 = ((uint16_t)(ins[8]) << 8) | (uint16_t)(ins[9]);
|
||||
instru.Vmax = (int32_t)VMAX(instru.Ve1,instru.Ve2);
|
||||
@@ -841,55 +738,19 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.directionInit = 1;
|
||||
}
|
||||
} else if (ins[3] == PARA_2) {
|
||||
instru.eliteFxn = CURVE_CV;
|
||||
instru.Currentmax = (int32_t)(ins[10]) << 24 | (int32_t)(ins[11]) << 16 | (int32_t)(ins[12]) << 8 | (int32_t)(ins[13]);
|
||||
instru.eliteFxn = CURVE_EIS_CV;
|
||||
instru.notifyRate = (uint32_t)(ins[8]) << 8 | (uint32_t)(ins[9]);
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
//controller UI 0.01~1000mv send to Elite 1~100000
|
||||
instru.step = (uint32_t)(ins[4]) << 24 | (uint32_t)(ins[5]) << 16 | (uint32_t)(ins[6]) << 8 | (uint32_t)(ins[7]);
|
||||
STEP_TO_VSETRATE(instru.step);
|
||||
STEP_TO_VSETRATE(instru.step); //step2VsetRate
|
||||
instru.VsetRate = VsetRateTable[instru.VsetRateIndex];//N
|
||||
instru.cycleNumber = ((uint16_t)(ins[14]) << 8) | (uint16_t)(ins[15]);
|
||||
instru.cycleNumber = (uint16_t)(ins[10]) << 8 | (uint16_t)(ins[11]);
|
||||
|
||||
instru.VoutGainLevel = VOUT_GAIN_240K;
|
||||
setEIS_CV();
|
||||
ModeLED(WORKING);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_LSV: {
|
||||
instru.eliteFxn = CURVE_LSV;
|
||||
instru.sampleRate = 15;
|
||||
instru.Ve1 = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
|
||||
instru.Ve2 = ((uint16_t)(ins[5]) << 8) | (uint16_t)(ins[6]);
|
||||
instru.Vinit = (int32_t)instru.Ve1;
|
||||
instru.Vmax = (int32_t)VMAX(instru.Ve1,instru.Ve2);
|
||||
instru.Vmin = (int32_t)VMIN(instru.Ve1,instru.Ve2);
|
||||
instru.directionInit = VDIRECTION(instru.Ve1,instru.Ve2);
|
||||
instru.Currentmax = (int32_t)(ins[13]) << 24 | (int32_t)(ins[14]) << 16 | (int32_t)(ins[15]) << 8 | (int32_t)(ins[16]);
|
||||
instru.notifyRate = (uint32_t)(ins[11]) << 8 | (uint32_t)(ins[12]);
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
//controller UI 0.01~1000mv send to Elite 1~100000
|
||||
instru.step = (uint32_t)(ins[7]) << 24 | (uint32_t)(ins[8]) << 16 | (uint32_t)(ins[9]) << 8 | (uint32_t)(ins[10]);
|
||||
STEP_TO_VSETRATE(instru.step);
|
||||
instru.VsetRate = VsetRateTable[instru.VsetRateIndex];//N
|
||||
instru.cycleNumber = 1;//ins[17];
|
||||
|
||||
instru.VoutGainLevel = VOUT_GAIN_240K;
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_CA: {
|
||||
instru.eliteFxn = CURVE_CA;
|
||||
instru.sampleRate = 15;
|
||||
instru.Vinit = ((int32_t)(ins[3]) << 8) | (int32_t)(ins[4]);
|
||||
instru.notifyRate = (uint32_t)(ins[5]) << 8 | (uint32_t)(ins[6]);
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.VsetRate = VsetRateTable[0];
|
||||
|
||||
instru.VoutGainLevel = VOUT_GAIN_240K;
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -907,8 +768,8 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.AutoGainEnable = 0;
|
||||
} else {
|
||||
instru.AutoGainEnable = 1;
|
||||
instru.ADCGainLv = I_GAIN_100R;
|
||||
IinADCGainControl(instru.ADCGainLv);
|
||||
instru.ADCGainLv = LPRTIA_200R;
|
||||
LPTIAGainCtrl(instru.ADCGainLv);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -935,11 +796,11 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
case HIGH_Z : {
|
||||
switch(ins[4]) {
|
||||
case 0x00 : {
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0 => open high_z mode
|
||||
SetEISHIGHZ(0); //open CE0
|
||||
break;
|
||||
}
|
||||
case 0x01 : {
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
SetEISHIGHZ(1); //close CE0
|
||||
break;
|
||||
}
|
||||
default : {
|
||||
@@ -948,6 +809,39 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EIS_HSDAC : {
|
||||
if(ins[4] == 0x00) {
|
||||
instru.DAC_type = EIS_HSDAC;
|
||||
} else if (ins[4] == 0x01) {
|
||||
instru.DAC_type = EIS_LPDAC;
|
||||
}
|
||||
HSDAC_GainControl(0x00); // fix HSDAC gain at default
|
||||
break;
|
||||
}
|
||||
case EIS_HSTIA : {
|
||||
instru.HSTIAGainLv = ins[4];
|
||||
if (instru.HSTIAGainLv != HSRTIA_GAIN_AUTO) {
|
||||
instru.HSTIAAutoGainEnable = 0;
|
||||
} else {
|
||||
instru.HSTIAAutoGainEnable = 1;
|
||||
instru.HSTIAGainLv = RTIA200R;
|
||||
HSTIAGainCtrl(instru.HSTIAGainLv);
|
||||
}
|
||||
HSTIAGainCtrl(instru.HSTIAGainLv);
|
||||
break;
|
||||
}
|
||||
case EIS_LPTIA : {
|
||||
instru.LPTIAGainLv = ins[4];
|
||||
if (instru.LPTIAGainLv != LPRTIA_GAIN_AUTO) {
|
||||
instru.LPTIAAutoGainEnable = 0;
|
||||
} else {
|
||||
instru.LPTIAAutoGainEnable = 1;
|
||||
instru.LPTIAGainLv = LPRTIA_200R;
|
||||
LPTIAGainCtrl(instru.LPTIAGainLv);
|
||||
}
|
||||
LPTIAGainCtrl(instru.LPTIAGainLv);
|
||||
break;
|
||||
}
|
||||
default :{
|
||||
break;
|
||||
}
|
||||
@@ -955,18 +849,9 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_CALI_DAC: {
|
||||
instru.eliteFxn = CURVE_CALI_DAC;
|
||||
ModeLED(WORKING);
|
||||
instru.sampleRate = 15;
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
instru.VoltConstant = ( ((uint16_t)(ins[3])) << 8) | (uint16_t)(ins[4]);
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_CALI_ADC: {
|
||||
switch(ins[3]) {
|
||||
case IIN_ADC : { // 0x00
|
||||
case IIN_ADC : { // 0x05
|
||||
instru.eliteFxn = CURVE_CALI_ADC;
|
||||
instru.AdcChannel = IIN_ADC;
|
||||
instru.notifyRate = 1000;
|
||||
@@ -975,7 +860,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
case VIN_ADC : { // 0x01
|
||||
case VIN_ADC : { // 0x06
|
||||
instru.eliteFxn = CURVE_CALI_ADC;
|
||||
instru.AdcChannel = VIN_ADC;
|
||||
instru.notifyRate = 1000;
|
||||
@@ -984,18 +869,59 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
case VOUT_DAC : { // 0x02
|
||||
case VOUT_DAC : { // 0x04
|
||||
instru.eliteFxn = CURVE_CALI_ADC;
|
||||
instru.AdcChannel = VOUT_DAC;
|
||||
instru.notifyRate = 1000;
|
||||
instru.sampleRate = 15;
|
||||
instru.VoViSwitch = 0x00; // 0: read Vout voltage
|
||||
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
// PIN_setOutputValue(pin_handle, HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
instru.VoltConstant = ( ((uint16_t)(ins[4])) << 8) | (uint16_t)(ins[5]); // output voltage
|
||||
DAC_outputV(instru.VoltConstant); //UserCode -> DAC code -> DAC out
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
case EIS_HSDAC :{ // 0x02
|
||||
instru.eliteFxn = CURVE_CALI_ADC;
|
||||
instru.notifyRate = 1000;
|
||||
instru.sampleRate = 15;
|
||||
static int32_t LPvolt = 0;
|
||||
instru.VAmpSet = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
|
||||
|
||||
if (instru.DAC_type == EIS_HSDAC) {
|
||||
instru.AdcChannel = EIS_HSDAC;
|
||||
HS_cali_config();
|
||||
HSDAC_output(instru.VAmpSet);
|
||||
// SetWGAmp(instru.VAmpSet); // sine wave generation usage
|
||||
} else if (instru.DAC_type == EIS_LPDAC) {
|
||||
instru.AdcChannel = EIS_LPDAC;
|
||||
LP_cali_config();
|
||||
LPvolt = ((int32_t)(ins[4]) << 8) | (int32_t)(ins[5]);
|
||||
LPvolt = (LPvolt - 25000) * 4 * 4000;
|
||||
DAC_outputV(LPvolt);
|
||||
}
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
case EIS_HSTIA :{ // 0x00
|
||||
instru.eliteFxn = CURVE_CALI_ADC;
|
||||
instru.AdcChannel = EIS_HSTIA;
|
||||
instru.notifyRate = 1000;
|
||||
instru.sampleRate = 15;
|
||||
HS_cali_config();
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
case EIS_LPTIA :{ // 0x01
|
||||
instru.eliteFxn = CURVE_CALI_ADC;
|
||||
instru.AdcChannel = EIS_LPTIA;
|
||||
instru.notifyRate = 1000;
|
||||
instru.sampleRate = 15;
|
||||
LP_cali_config();
|
||||
LPTIAGainCtrl(ins[4]);
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
default : {
|
||||
break;
|
||||
}
|
||||
@@ -1003,46 +929,8 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_PULSE: {
|
||||
instru.VoutGainLevel = VOUT_GAIN_240K;
|
||||
instru.sampleRate = 15;
|
||||
instru.notifyRate = 100;
|
||||
if (ins[3] == PARA_1) {
|
||||
instru.sti_t1 = (int32_t)(ins[4]) << 24 | (int32_t)(ins[5]) << 16 | (int32_t)(ins[6]) << 8 | (int32_t)(ins[7]);
|
||||
instru.sti_t2 = (int32_t)(ins[8]) << 24 | (int32_t)(ins[9]) << 16 | (int32_t)(ins[10]) << 8 | (int32_t)(ins[11]);
|
||||
instru.sti_t3 = (int32_t)(ins[12]) << 24 | (int32_t)(ins[13]) << 16 | (int32_t)(ins[14]) << 8 | (int32_t)(ins[15]);
|
||||
instru.sti_t4 = (int32_t)(ins[16]) << 24 | (int32_t)(ins[17]) << 16 | (int32_t)(ins[18]) << 8 | (int32_t)(ins[19]);
|
||||
} else if (ins[3] == PARA_2) {
|
||||
instru.sti_t5 = (int32_t)(ins[4]) << 24 | (int32_t)(ins[5]) << 16 | (int32_t)(ins[6]) << 8 | (int32_t)(ins[7]);
|
||||
instru.sti_v1 = 25000; //8~11
|
||||
instru.sti_v2 = 50000; //12~15 //41406.43161.
|
||||
instru.sti_v3 = 25000; //16~19
|
||||
} else if (ins[3] == PARA_3) {
|
||||
instru.sti_v4 = 25000; //4~7
|
||||
instru.sti_v5 = 25000; //8~11
|
||||
instru.sti_cy = (uint16_t)(ins[12]); //12
|
||||
instru.sti_loop = (uint16_t)(ins[13]); //13
|
||||
} else if (ins[3] == PARA_4) {
|
||||
instru.sti_t6 = (int32_t)(ins[4]) << 24 | (int32_t)(ins[5]) << 16 | (int32_t)(ins[6]) << 8 | (int32_t)(ins[7]); //4~7
|
||||
instru.sti_t7 = (int32_t)(ins[8]) << 24 | (int32_t)(ins[9]) << 16 | (int32_t)(ins[10]) << 8 | (int32_t)(ins[11]); //8~11
|
||||
instru.sti_v6 = 25000; //12~15
|
||||
instru.sti_v7 = 25000;; //16~19
|
||||
instru.sti_t1 = VALUE_ZERO_TO_ONE(instru.sti_t1);
|
||||
instru.sti_t2 = VALUE_ZERO_TO_ONE(instru.sti_t2);
|
||||
instru.sti_t3 = VALUE_ZERO_TO_ONE(instru.sti_t3);
|
||||
instru.sti_t4 = VALUE_ZERO_TO_ONE(instru.sti_t4);
|
||||
instru.sti_t5 = VALUE_ZERO_TO_ONE(instru.sti_t5);
|
||||
instru.sti_t6 = VALUE_ZERO_TO_ONE(instru.sti_t6);
|
||||
instru.sti_t7 = VALUE_ZERO_TO_ONE(instru.sti_t7);
|
||||
megaStiEnable = true;
|
||||
} else if (ins[3] == PARA_17) {
|
||||
instru.eliteFxn = CURVE_PULSE;
|
||||
ModeLED(WORKING);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xFF: { // 0x3000FF
|
||||
case 0xFF: { // 0x3000FF DEV_MODE
|
||||
switch (ins[3]) {
|
||||
case 0x01: {
|
||||
headstage_battery_volt();
|
||||
@@ -1071,8 +959,219 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
break;
|
||||
}
|
||||
|
||||
case CTL_WRT: { // ble write: 0x3000FF 20FFFFFFFFFFFF
|
||||
uint32_t address = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
|
||||
uint32_t data = ((uint16_t)(ins[6]) << 24) | (uint16_t)(ins[7]) << 16 |
|
||||
(uint16_t)(ins[8]) << 8 | (uint16_t)(ins[9]);
|
||||
|
||||
select_REG(address);
|
||||
w32_REG(data);
|
||||
|
||||
initCISBuf();
|
||||
cis_buf[0] = (uint8_t)((address & 0x0000FF00) >> 8);
|
||||
cis_buf[1] = (uint8_t)(address & 0x000000FF);
|
||||
cis_buf[2] = (uint8_t)((data & 0xFF000000) >> 24);
|
||||
cis_buf[3] = (uint8_t)((data & 0x00FF0000) >> 16);
|
||||
cis_buf[4] = (uint8_t)((data & 0x0000FF00) >> 8);
|
||||
cis_buf[5] = (uint8_t)(data & 0x000000FF);
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
case CTL_RD: { // ble write: 0x3000FF 21FFFF
|
||||
uint32_t address = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
|
||||
select_REG(address);
|
||||
r32_REG();
|
||||
|
||||
initCISBuf();
|
||||
cis_buf[0] = 20;
|
||||
cis_buf[1] = (uint8_t)((address & 0x0000FF00) >> 8);
|
||||
cis_buf[2] = (uint8_t)(address & 0x000000FF);
|
||||
cis_buf[3] = spi_rxbuf[2];
|
||||
cis_buf[4] = spi_rxbuf[3];
|
||||
cis_buf[5] = spi_rxbuf[4];
|
||||
cis_buf[6] = spi_rxbuf[5];
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
case CTL_RD_DFTR: { // ble write: 0x3000FF 78FFFFFFFF
|
||||
select_REG(0x2078);
|
||||
r32_REG();
|
||||
|
||||
initCISBuf();
|
||||
cis_buf[0] = 20;
|
||||
cis_buf[1] = (uint8_t)(0x20);
|
||||
cis_buf[2] = (uint8_t)(0x78);
|
||||
cis_buf[3] = spi_rxbuf[2];
|
||||
cis_buf[4] = spi_rxbuf[3];
|
||||
cis_buf[5] = spi_rxbuf[4];
|
||||
cis_buf[6] = spi_rxbuf[5];
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
case CTL_RD_DFTI: { // ble write: 0x3000FF 7CFFFFFFFF
|
||||
select_REG(0x207C);
|
||||
r32_REG();
|
||||
|
||||
initCISBuf();
|
||||
cis_buf[0] = (uint8_t)(0x20);
|
||||
cis_buf[1] = (uint8_t)(0x7C);
|
||||
cis_buf[2] = spi_rxbuf[2];
|
||||
cis_buf[3] = spi_rxbuf[3];
|
||||
cis_buf[4] = spi_rxbuf[4];
|
||||
cis_buf[5] = spi_rxbuf[5];
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
case CTL_WRT_WGAMPL: { // ble write: 0x3000FF 3CFFFFFFFF | write waveform generator amplitude
|
||||
uint32_t data = ((uint16_t)(ins[4]) << 24) | (uint16_t)(ins[5]) << 16 | (uint16_t)(ins[6]) << 8 | (uint16_t)(ins[7]);
|
||||
|
||||
select_REG(0x2014);
|
||||
w32_REG(0x0); // 0x0: DC disable ac first
|
||||
|
||||
select_REG(0x203C);
|
||||
w32_REG(data);
|
||||
|
||||
initCISBuf();
|
||||
cis_buf[0] = (uint8_t)(0x20);
|
||||
cis_buf[1] = (uint8_t)(0x3C);
|
||||
cis_buf[2] = (uint8_t)((data & 0xFF000000) >> 24);
|
||||
cis_buf[3] = (uint8_t)((data & 0x00FF0000) >> 16);
|
||||
cis_buf[4] = (uint8_t)((data & 0x0000FF00) >> 8);
|
||||
cis_buf[5] = (uint8_t)(data & 0x000000FF);
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
|
||||
select_REG(0x2014);
|
||||
w32_REG(0x00000004); //0x4: Sinusoid
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x10: {
|
||||
uint32_t data = (uint8_t)(ins[4]);
|
||||
HSTIAGainCtrl2(data);
|
||||
break;
|
||||
}
|
||||
|
||||
case CTL_RESET: { //UI write: 11
|
||||
AD5940_HWReset();
|
||||
AD5940_init();
|
||||
// AD5940_sftreset();
|
||||
break;
|
||||
}
|
||||
|
||||
case CTL_IMPEDANCE: { //ble write:0x3000FF 12 | UI write: 12
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CTL_CV3: { //UI write: 13 with lpdac/lptia/dac
|
||||
//Clock and Ref
|
||||
select_REG(0x0414); //CLKSEL
|
||||
w16_REG(0x0);
|
||||
select_REG(0x20BC); //HSOSCCON
|
||||
w32_REG(0x00000004); //16 MHz output
|
||||
select_REG(0x2180); //BUFSENCON
|
||||
w32_REG(0x00000037); //0b110110
|
||||
|
||||
//Configure LPDAC LPTIA
|
||||
select_REG(0x2050); //LPREFBUFCON
|
||||
w32_REG(0x0); //enable lpref and lp 2.5V buffer
|
||||
select_REG(0x2124); //LPDACSW0
|
||||
w32_REG(0x0000003E);
|
||||
select_REG(0x20E4); //LPTIASW0
|
||||
w32_REG(0x00008034); // SW2 | SW4 | SW5
|
||||
select_REG(0x20EC); //LPTIACON0
|
||||
w32_REG(0x00000038); //RF 0 | RTIA 200R | Rload 0 | High Current Mode //default 200R
|
||||
select_REG(0x2128); //LPDACCON0
|
||||
w32_REG(0x00000001);
|
||||
|
||||
//Configure ADC | ADCDAT (0x2074)
|
||||
select_REG(0x21A8); //ADCCON
|
||||
w32_REG(0x00001021); //PGA = 1 | VZERO | LPTIA_OUT
|
||||
select_REG(0x2044); //ADCFILTERCON
|
||||
w32_REG(0x00014091); //Disable avr | sinc3 enable | osr 2
|
||||
select_REG(0x20D0); //DFTCON
|
||||
w32_REG(0x00100031); //sinc3 + average input for DFT | dftnum max
|
||||
|
||||
//AFE and PWMB
|
||||
select_REG(0x2000); //AFECON
|
||||
w32_REG(0x00098780); //ADC on //0b10011000011110000000
|
||||
select_REG(0x22F0); //PWMB
|
||||
w32_REG(0x00000005);//fc 50kHz, low power mode
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x31: {
|
||||
uint32_t data = ((uint16_t)(ins[4]) << 24) | (uint16_t)(ins[5]) << 16 |
|
||||
(uint16_t)(ins[6]) << 8 | (uint16_t)(ins[7]);
|
||||
data *= 200;
|
||||
DAC_outputV(data);
|
||||
}
|
||||
|
||||
case 0x32: {
|
||||
uint8_t data = (uint8_t)(ins[4]);
|
||||
LPTIAGainCtrl(data);
|
||||
}
|
||||
|
||||
case 0x03: { // ble write: 0x3000FF 03
|
||||
if (ins[4] == 1) {
|
||||
Elite_led_color(COLOR_RED); //0301
|
||||
} else if (ins[4] == 2){
|
||||
Elite_led_color(COLOR_ORANGE); //0302
|
||||
} else if (ins[4] == 3){
|
||||
Elite_led_color(COLOR_YELLOW);
|
||||
} else if (ins[4] == 4){
|
||||
Elite_led_color(COLOR_GREEN);
|
||||
} else if (ins[4] == 5){
|
||||
Elite_led_color(COLOR_BLUE);
|
||||
} else if (ins[4] == 6){
|
||||
Elite_led_color(COLOR_MAGENTA);
|
||||
} else if (ins[4] == 7){
|
||||
Elite_led_color(COLOR_RED);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case cali_LPDAC_voltout: { // 0x39
|
||||
int32_t voltin = 0;
|
||||
LP_cali_config();
|
||||
voltin = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
|
||||
voltin = (voltin - 25000) * 4 * 4000;
|
||||
cali_DAC_outputV(voltin);
|
||||
LED_color(DARKLED, 0x00, 0x00, 0x80);
|
||||
break;
|
||||
}
|
||||
case cali_LPTIA_setGain: { // 0x29
|
||||
// setEIS_CV();
|
||||
LPTIAGainCtrl(ins[4]);
|
||||
// LED_color(DARKLED, 0x80, 0x00, 0x00);
|
||||
break;
|
||||
}
|
||||
case cali_HSDAC_amp: { // 0x49
|
||||
HS_cali_config();
|
||||
instru.VAmpSet = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
|
||||
// HSDAC_output(instru.VAmpSet);
|
||||
DAC_outputF(0x00000800);
|
||||
SetWGAmp(instru.VAmpSet); // sine wave generation usage
|
||||
LED_color(DARKLED, 0x80, 0x00, 0x80);
|
||||
break;
|
||||
}
|
||||
case cali_HSTIA_setGain: { // 0x59
|
||||
// setEIS_CV();
|
||||
HS_cali_config();
|
||||
HSTIAGainCtrl(ins[4]);
|
||||
// LED_color(DARKLED, 0x80, 0x00, 0x00);
|
||||
break;
|
||||
}
|
||||
case cali_HSDAC_DC: { // 0x69
|
||||
HS_cali_config();
|
||||
instru.VAmpSet = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
|
||||
HSDAC_output(instru.VAmpSet);
|
||||
LED_color(DARKLED, 0x80, 0x00, 0x80);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1103,6 +1202,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
}
|
||||
|
||||
case VIS_STI: {
|
||||
time0 = (Timestamp_get32()) / 31;
|
||||
for(int i = 0; i < 12; i++) {
|
||||
FlushNotify();
|
||||
}
|
||||
@@ -1125,7 +1225,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
break;
|
||||
}
|
||||
|
||||
case VIS_DEVICE_SHINY: {
|
||||
case VIS_DEVICE_SHINY: { //detect
|
||||
Elite_led_color(COLOR_PURPLE);
|
||||
// uint8_t deviceShinySwitch = (ins[2] & 0b11110000) >> 4;//1:open 0:close
|
||||
// if(deviceShinySwitch == 1){
|
||||
@@ -1149,14 +1249,6 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
break;
|
||||
}
|
||||
|
||||
case VIS_CC_ZERO: {
|
||||
instru.eliteFxn = CURVE_OCP;
|
||||
instru.notifyRate = 500;
|
||||
instru.sampleRate = 15;
|
||||
ModeLED(PRE_WORK);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
@@ -1167,26 +1259,29 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
case INS_TYPE_CIS: {
|
||||
switch (oper) {
|
||||
case 0x00: {
|
||||
I2CWrite(0x01, 0xAB);
|
||||
//I2CWrite(0x01, 0xAB);
|
||||
break;
|
||||
}
|
||||
|
||||
case CIS_VERSION: {
|
||||
initCISBuf();
|
||||
cis_buf[0] = VERSION_DATE_YEAR;
|
||||
cis_buf[1] = VERSION_DATE_MONTH;
|
||||
cis_buf[2] = VERSION_DATE_DAY;
|
||||
cis_buf[3] = VERSION_DATE_HOUR;
|
||||
cis_buf[4] = VERSION_DATE_MINUTE;
|
||||
cis_buf[0] = 6;
|
||||
cis_buf[1] = CIS_VERSION;
|
||||
cis_buf[2] = VERSION_DATE_YEAR;
|
||||
cis_buf[3] = VERSION_DATE_MONTH;
|
||||
cis_buf[4] = VERSION_DATE_DAY;
|
||||
cis_buf[5] = VERSION_DATE_HOUR;
|
||||
cis_buf[6] = VERSION_DATE_MINUTE;
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
case CIS_VOLT: {
|
||||
initCISBuf();
|
||||
cis_buf[0] = CIS_VOLT;
|
||||
cis_buf[1] = NotifyVoltBat[3];
|
||||
cis_buf[2] = NotifyVoltBat[2];
|
||||
cis_buf[0] = 3;
|
||||
cis_buf[1] = CIS_VOLT;
|
||||
cis_buf[2] = NotifyVoltBat[3];
|
||||
cis_buf[3] = NotifyVoltBat[2];
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
@@ -1198,6 +1293,29 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
LED_color(LIGHTLED, ins[3], ins[4], ins[5]);
|
||||
} else if (ins[2] == 2) {
|
||||
LED_color(DARKLED, ins[3], ins[4], ins[5]);
|
||||
} else if (ins[2] == 3) {
|
||||
Elite_led_color(COLOR_PURPLE);
|
||||
} else if (ins[2] == 4) {
|
||||
Elite_led_color(COLOR_ORANGE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CIS_CALI: {
|
||||
if (ins[2] == 0) {
|
||||
SendCaliValue0();
|
||||
} else if (ins[2] == 1) {
|
||||
SendCaliValue1();
|
||||
} else if (ins[2] == 2) {
|
||||
SendCaliValue2();
|
||||
} else if (ins[2] == 3) {
|
||||
SendCaliValue3();
|
||||
} else if (ins[2] == 4) {
|
||||
SendCaliValue4();
|
||||
} else if (ins[2] == 5) {
|
||||
SendCaliValue5();
|
||||
} else if (ins[2] == 6) {
|
||||
SendCaliValue6();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+183
-345
@@ -46,23 +46,27 @@ static void ZM_init() {
|
||||
|
||||
// initialize
|
||||
pin_handle = PIN_open(&ZM_rst, BLE_IO);
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1); // AD_CS HIGH
|
||||
/*
|
||||
Init_Elite15_PIN();
|
||||
ELITE15_SPI_HOLD();
|
||||
|
||||
PIN15_setOutputValue(shutdown_6994, 1); // OFF = 1 => turn off 6994
|
||||
PIN15_setOutputValue(enable_10v, 0); // enable 10V
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // HIGH Z MODE // 1: close; 0: open;
|
||||
|
||||
PIN_setOutputValue(pin_handle, shutdown_6994, 1); // OFF = 1 => turn off 6994
|
||||
PIN_setOutputValue(pin_handle, enable_10v, 0); // enable 10V
|
||||
PIN_setOutputValue(pin_handle, HIGH_Z_MODE, 0); // HIGH Z MODE // 1: close; 0: open;
|
||||
*/
|
||||
|
||||
InitEliteInstruction();
|
||||
|
||||
// init DAC, set output ~= 0 V
|
||||
instru.VoutGainLevel = VOUT_GAIN_15K;
|
||||
VoutGainControl(instru.VoutGainLevel);
|
||||
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLevel, 25000));
|
||||
// instru.VoutGainLevel = VOUT_GAIN_15K;
|
||||
// VoutGainControl(instru.VoutGainLevel);
|
||||
// DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLevel, 25000));
|
||||
|
||||
/* when elite open, must change vin level,
|
||||
measure battery value will be right */
|
||||
VinADCGainCtrl(VIN_GAIN_AUTO);
|
||||
// VinADCGainControl(VIN_GAIN_AUTO);
|
||||
|
||||
elite_gptimer_open();
|
||||
elite_gptimer_start();
|
||||
@@ -85,25 +89,14 @@ static void DACCode2Real2Notify(uint16_t DACcode) {
|
||||
}
|
||||
|
||||
#define IsPeriodicMode() ( \
|
||||
(instru.eliteFxn == CURVE_IV) || \
|
||||
(instru.eliteFxn == CURVE_IV_CY) || \
|
||||
(instru.eliteFxn == CURVE_IT) || \
|
||||
(instru.eliteFxn == CURVE_VT) || \
|
||||
(instru.eliteFxn == CURVE_RT) || \
|
||||
(instru.eliteFxn == CURVE_CC) || \
|
||||
(instru.eliteFxn == CURVE_CV) || \
|
||||
(instru.eliteFxn == CURVE_LSV) || \
|
||||
(instru.eliteFxn == CURVE_CA) || \
|
||||
(instru.eliteFxn == CURVE_VO) || \
|
||||
(instru.eliteFxn == CURVE_OCP) || \
|
||||
(instru.eliteFxn == CURVE_EIS) || \
|
||||
(instru.eliteFxn == CURVE_EIS_CV) || \
|
||||
(instru.eliteFxn == CURVE_CALI_ADC) \
|
||||
)
|
||||
|
||||
#define Ve1MatchVe2Mode() ( \
|
||||
(instru.eliteFxn == CURVE_IV) || \
|
||||
(instru.eliteFxn == CURVE_IV_CY) || \
|
||||
(instru.eliteFxn == CURVE_CV) || \
|
||||
(instru.eliteFxn == CURVE_LSV) \
|
||||
(instru.eliteFxn == CURVE_EIS) || \
|
||||
(instru.eliteFxn == CURVE_EIS_CV) \
|
||||
)
|
||||
|
||||
/*********************************************************************
|
||||
@@ -117,333 +110,193 @@ static void DACCode2Real2Notify(uint16_t DACcode) {
|
||||
*/
|
||||
static void SimpleBLEPeripheral_performPeriodicTask(void) {
|
||||
if (IsPeriodicMode()) {
|
||||
/** Periodic Event **/
|
||||
// Default working flow is vscan -> ADC read -> send notify
|
||||
// We will need a flag to control vscan, ADC and notify
|
||||
static bool first_highz_flag = false;
|
||||
if(instru.eliteFxn == CURVE_EIS){
|
||||
|
||||
GPT.DeltaGptimerCounter = GPT.GptimerCounter - GPT.GptimerCounter0;
|
||||
GPT.GptimerCounter0 = GPT.GptimerCounter;
|
||||
GPT.DeltaGptimerCounter = GPT.GptimerCounter - GPT.GptimerCounter0;
|
||||
GPT.GptimerCounter0 = GPT.GptimerCounter;
|
||||
|
||||
if (mode_init) {
|
||||
GPT.SampleRateCounter = instru.sampleRate - 10;
|
||||
GPT.VscanRateCounter = instru.VsetRate - 1;
|
||||
mode_init = false;
|
||||
batteryADC_flag = false;
|
||||
record_flag = true;
|
||||
firstTimeReset = true;
|
||||
notifyFirst_flag = true;
|
||||
first_highz_flag = true;
|
||||
I_GAIN_100R_counter = 0;
|
||||
I_GAIN_3K_counter = 0;
|
||||
I_GAIN_100K_counter = 0;
|
||||
I_GAIN_3M_counter = 0;
|
||||
VIN_GAIN_1M_counter = 0;
|
||||
VIN_GAIN_30K_counter = 0;
|
||||
VIN_GAIN_1K_counter = 0;
|
||||
VOUT_GAIN_240K_counter = 0;
|
||||
VOUT_GAIN_15K_counter = 0;
|
||||
DACReset = true;
|
||||
vscanReset = true;
|
||||
leadTimeReset = true;
|
||||
if (mode_init){
|
||||
GPT.SampleRateCounter = 0;
|
||||
mode_init = false;
|
||||
gainChange_flag = false;
|
||||
firstFreq_flag = true;
|
||||
fset_flag = true;
|
||||
fout_flag = true;
|
||||
firstTimeReset = true;
|
||||
notifyFirst_flag = true;
|
||||
DACReset = true;
|
||||
vscanReset = true;
|
||||
leadTimeReset = true;
|
||||
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
IinADCGainControl(instru.ADCGainLv);
|
||||
VoutGainControl(instru.VoutGainLevel);
|
||||
if (Ve1MatchVe2Mode()) {
|
||||
if (instru.Ve1 == instru.Ve2) {
|
||||
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLevel, instru.Ve1));
|
||||
if (instru.f1 == instru.f2) {
|
||||
DAC_outputF(instru.f1);
|
||||
PeriodicEvent = false;
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0: open highz;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GPT.LeadTimeCounter = GPT.LeadTimeCounter + GPT.DeltaGptimerCounter;
|
||||
if (leadTimeReset && GPT.LeadTimeCounter <= 2000) {
|
||||
vscanReset = true;
|
||||
if (first_highz_flag && GPT.LeadTimeCounter >= 1000) {
|
||||
if (instru.eliteFxn == CURVE_OCP) {
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0);
|
||||
} else {
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // HIGH Z MODE // 1: close; 0: open;
|
||||
SetEISHIGHZ(1);
|
||||
}
|
||||
|
||||
//vscan counter //fset counter
|
||||
if (fset_flag) {
|
||||
vscan_ctrl(); //set
|
||||
fset_flag = false;
|
||||
fout_flag = true;
|
||||
}
|
||||
|
||||
//ADC counter
|
||||
GPT.SampleRateCounter = GPT.SampleRateCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.SampleRateCounter >= instru.sampleRate){
|
||||
GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
|
||||
ADC_flag = true;
|
||||
if(ADC_flag){
|
||||
EliteADCControl(); //read data
|
||||
ADC_flag = false;
|
||||
}
|
||||
first_highz_flag = false;
|
||||
}
|
||||
} else {
|
||||
if (notifyFirst_flag) {
|
||||
GPT.NotifyCounter = instru.notifyRate - 20;
|
||||
notifyFirst_flag = false;
|
||||
}
|
||||
vscanReset = false;
|
||||
leadTimeReset = false;
|
||||
}
|
||||
|
||||
//vscan counter
|
||||
GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
|
||||
if (GPT.VscanRateCounter >= instru.VsetRate) {
|
||||
if (GPT.VscanRateCounter >= instru.VsetRate * 2) {
|
||||
GPT.GptimerMultiple = GPT.VscanRateCounter / instru.VsetRate;
|
||||
} else {
|
||||
GPT.GptimerMultiple = 1;
|
||||
}
|
||||
GPT.VscanRateCounter -= instru.VsetRate * GPT.GptimerMultiple; //To get right time
|
||||
vscan_flag = true;
|
||||
if (vscan_flag) {
|
||||
vscan_ctrl();
|
||||
vscan_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
//battery counter
|
||||
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
|
||||
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.BatteryCheckCounter >= 50000){
|
||||
GPT.BatteryCheckCounter -= 50000; //To get right time
|
||||
batteryCheck_flag = true;
|
||||
}
|
||||
|
||||
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) | ((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
|
||||
if( bat < 768 && bat > 20){
|
||||
// PIN15_setOutputValue(enable_5v, 0);
|
||||
}
|
||||
|
||||
//ADC counter
|
||||
GPT.SampleRateCounter = GPT.SampleRateCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.SampleRateCounter >= instru.sampleRate){
|
||||
GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
|
||||
ADC_flag = true;
|
||||
if(ADC_flag){
|
||||
EliteADCControl();
|
||||
ADC_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Notify counter(Notify control, check if we need to send notify)
|
||||
//please don't put Notify counter before ADC counter, maybe get wrong data
|
||||
GPT.NotifyCounter = GPT.NotifyCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.NotifyCounter >= instru.notifyRate){
|
||||
GPT.NotifyCounter -= instru.notifyRate; //To get right time
|
||||
notify_flag = true;
|
||||
//Notify counter(Notify control, check if we need to send notify)
|
||||
//please don't put Notify counter before ADC counter, maybe get wrong data
|
||||
if(vscanReset){
|
||||
notify_flag = false;
|
||||
}
|
||||
if(notify_flag){
|
||||
SendNotify();
|
||||
SendNotify(); //send
|
||||
notify_flag = false;
|
||||
fset_flag = true;
|
||||
time0 = (Timestamp_get32()) / 31;
|
||||
time1 = 0;
|
||||
delta_time = 0;
|
||||
}
|
||||
}
|
||||
|
||||
mode_done();
|
||||
}
|
||||
else if (instru.eliteFxn == CURVE_PULSE) {
|
||||
/** Periodic Event **/
|
||||
// Default working flow is vscan -> ADC read -> send notify
|
||||
// We will need a flag to control vscan, ADC and notify
|
||||
mode_done(); //finishMode = 1, SendNotify(), Eliteinterrupt()
|
||||
} else {
|
||||
/** Periodic Event **/
|
||||
// Default working flow is vscan -> ADC read -> send notify
|
||||
// We will need a flag to control vscan, ADC and notify
|
||||
|
||||
GPT.DeltaGptimerCounter = GPT.GptimerCounter - GPT.GptimerCounter0;
|
||||
GPT.GptimerCounter0 = GPT.GptimerCounter;
|
||||
static bool first_highz_flag = false;
|
||||
|
||||
if(mode_init){
|
||||
GPT.SampleRateCounter = instru.sampleRate - 10;
|
||||
GPT.VscanRateCounter = instru.VsetRate - 1;
|
||||
mode_init = false;
|
||||
batteryADC_flag = false;
|
||||
record_flag = true;
|
||||
firstTimeReset = true;
|
||||
notifyFirst_flag = true;
|
||||
//pulsemode variable
|
||||
stiFirstTime = true;
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
IinADCGainControl(instru.ADCGainLv);
|
||||
VoutGainControl(instru.VoutGainLevel);
|
||||
if (Ve1MatchVe2Mode()) {
|
||||
if (instru.Ve1 == instru.Ve2) {
|
||||
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLevel, instru.Ve1));
|
||||
PeriodicEvent = false;
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0: open highz;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
} else if (instru.eliteFxn == CURVE_PULSE) {
|
||||
if(!megaStiEnable){
|
||||
PeriodicEvent = false;
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0: open highz;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
GPT.DeltaGptimerCounter = GPT.GptimerCounter - GPT.GptimerCounter0;
|
||||
GPT.GptimerCounter0 = GPT.GptimerCounter;
|
||||
|
||||
if (mode_init) {
|
||||
GPT.SampleRateCounter = instru.sampleRate - 10;
|
||||
GPT.VscanRateCounter = instru.VsetRate - 1;
|
||||
mode_init = false;
|
||||
batteryADC_flag = false;
|
||||
record_flag = true;
|
||||
fset_flag = true;
|
||||
firstTimeReset = true;
|
||||
notifyFirst_flag = true;
|
||||
first_highz_flag = true;
|
||||
I_GAIN_100R_counter = 0;
|
||||
I_GAIN_3K_counter = 0;
|
||||
I_GAIN_100K_counter = 0;
|
||||
I_GAIN_3M_counter = 0;
|
||||
VIN_GAIN_1M_counter = 0;
|
||||
VIN_GAIN_30K_counter = 0;
|
||||
VIN_GAIN_1K_counter = 0;
|
||||
VOUT_GAIN_240K_counter = 0;
|
||||
VOUT_GAIN_15K_counter = 0;
|
||||
DACReset = true;
|
||||
vscanReset = true;
|
||||
leadTimeReset = true;
|
||||
|
||||
GPT.LeadTimeCounter = GPT.LeadTimeCounter + GPT.DeltaGptimerCounter;
|
||||
if(leadTimeReset && GPT.LeadTimeCounter <= 2000){
|
||||
vscanReset = true;
|
||||
}else{
|
||||
if(notifyFirst_flag){
|
||||
GPT.NotifyCounter = instru.notifyRate - 20;
|
||||
notifyFirst_flag = false;
|
||||
}
|
||||
vscanReset = false;
|
||||
leadTimeReset = false;
|
||||
}
|
||||
/*
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
IinADCGainControl(instru.ADCGainLv);
|
||||
VoutGainControl(instru.VoutGainLevel);
|
||||
*/
|
||||
|
||||
//vscan counter
|
||||
GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
|
||||
//pulse mode counter
|
||||
GPT.StiCounter = GPT.StiCounter + GPT.DeltaGptimerCounter;
|
||||
if (vscanReset) {
|
||||
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLevel, 25000));
|
||||
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLevel, 25000));
|
||||
//vscanReset = false;
|
||||
}else{
|
||||
if (megaStiEnable) {
|
||||
pulse_vscan();
|
||||
if (Ve1MatchVe2Mode()) {
|
||||
if (instru.Ve1 == instru.Ve2) {
|
||||
// DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLevel, instru.Ve1));
|
||||
DAC_outputV(instru.Ve1);
|
||||
PeriodicEvent = false;
|
||||
SetEISHIGHZ(1);
|
||||
// PIN_setOutputValue(pin_handle, HIGH_Z_MODE, 0); // 0: open highz;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GPT.LeadTimeCounter = GPT.LeadTimeCounter + GPT.DeltaGptimerCounter;
|
||||
if (leadTimeReset && GPT.LeadTimeCounter <= 2000) {
|
||||
vscanReset = true;
|
||||
if (first_highz_flag && GPT.LeadTimeCounter >= 1000) {
|
||||
SetEISHIGHZ(1); // // High Z | 1 off | 0 on
|
||||
// PIN_setOutputValue(pin_handle, HIGH_Z_MODE, 1); // HIGH Z MODE // 1: close; 0: open;
|
||||
first_highz_flag = false;
|
||||
}
|
||||
} else {
|
||||
if (notifyFirst_flag) {
|
||||
GPT.NotifyCounter = instru.notifyRate - 20;
|
||||
notifyFirst_flag = false;
|
||||
}
|
||||
vscanReset = false;
|
||||
leadTimeReset = false;
|
||||
}
|
||||
|
||||
//vscan counter //fset counter
|
||||
GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
|
||||
if (GPT.VscanRateCounter >= instru.VsetRate) {
|
||||
if (GPT.VscanRateCounter >= instru.VsetRate * 2) {
|
||||
GPT.GptimerMultiple = GPT.VscanRateCounter / instru.VsetRate;
|
||||
} else {
|
||||
GPT.GptimerMultiple = 1;
|
||||
}
|
||||
GPT.VscanRateCounter -= instru.VsetRate * GPT.GptimerMultiple; //To get right time
|
||||
vscan_flag = true;
|
||||
if (vscan_flag) {
|
||||
vscan_ctrl(); //set
|
||||
vscan_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
//ADC counter
|
||||
GPT.SampleRateCounter = GPT.SampleRateCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.SampleRateCounter >= instru.sampleRate){
|
||||
GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
|
||||
ADC_flag = true;
|
||||
if(ADC_flag){
|
||||
EliteADCControl(); //read data
|
||||
ADC_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Notify counter(Notify control, check if we need to send notify)
|
||||
//please don't put Notify counter before ADC counter, maybe get wrong data
|
||||
GPT.NotifyCounter = GPT.NotifyCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.NotifyCounter >= instru.notifyRate){
|
||||
GPT.NotifyCounter -= instru.notifyRate; //To get right time
|
||||
notify_flag = true;
|
||||
if(vscanReset){
|
||||
notify_flag = false;
|
||||
}
|
||||
if(notify_flag){
|
||||
SendNotify(); //send
|
||||
notify_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
mode_done(); //finishMode = 1, SendNotify(), Eliteinterrupt()
|
||||
|
||||
}
|
||||
|
||||
// if(GPT.VscanRateCounter >= instru.VsetRate){
|
||||
// if(GPT.VscanRateCounter >= instru.VsetRate * 2){
|
||||
// GPT.GptimerMultiple = GPT.VscanRateCounter / instru.VsetRate;
|
||||
// }else{
|
||||
// GPT.GptimerMultiple = 1;
|
||||
// }
|
||||
// GPT.VscanRateCounter -= instru.VsetRate * GPT.GptimerMultiple; //To get right time
|
||||
// vscan_flag = true;
|
||||
// if(vscan_flag){
|
||||
// vscan_ctrl();
|
||||
// vscan_flag = false;
|
||||
// }
|
||||
// }
|
||||
|
||||
//battery counter
|
||||
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
|
||||
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.BatteryCheckCounter >= 50000){
|
||||
GPT.BatteryCheckCounter -= 50000; //To get right time
|
||||
batteryCheck_flag = true;
|
||||
}
|
||||
|
||||
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) | ((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
|
||||
if( bat < 768 && bat > 20){
|
||||
PIN15_setOutputValue(enable_5v, 0);
|
||||
}
|
||||
|
||||
//ADC counter
|
||||
GPT.SampleRateCounter = GPT.SampleRateCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.SampleRateCounter >= instru.sampleRate){
|
||||
GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
|
||||
ADC_flag = true;
|
||||
if(ADC_flag){
|
||||
EliteADCControl();
|
||||
ADC_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Notify counter(Notify control, check if we need to send notify)
|
||||
//please don't put Notify counter before ADC counter, maybe get wrong data
|
||||
GPT.NotifyCounter = GPT.NotifyCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.NotifyCounter >= instru.notifyRate){
|
||||
GPT.NotifyCounter -= instru.notifyRate; //To get right time
|
||||
notify_flag = true;
|
||||
if(vscanReset){
|
||||
notify_flag = false;
|
||||
}
|
||||
if(notify_flag){
|
||||
SendNotify();
|
||||
notify_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
mode_done();
|
||||
}
|
||||
else if (instru.eliteFxn == CURVE_CALI_DAC) {
|
||||
DAC_outputV(instru.VoltConstant); //UserCode -> DAC code -> DAC out
|
||||
wm_deinit();
|
||||
PeriodicEvent = false;
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void EliteADCControl(void)
|
||||
static void EliteADCControl(void) //CURVE_IV => CC_Plot() | CURVE_CV => Iin_Vin_Vout_Plot
|
||||
{
|
||||
void *wm = wm_get();
|
||||
|
||||
switch (instru.eliteFxn) {
|
||||
case CURVE_IV:
|
||||
case CURVE_IV_CY:
|
||||
Iin_Vin_Vout_Plot();
|
||||
if (record_flag) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_IMPEDANCE, MEAS_VOUT(wm));
|
||||
}
|
||||
case CURVE_EIS:
|
||||
EIS_Plot();
|
||||
break;
|
||||
|
||||
case CURVE_RT:
|
||||
Iin_Vin_Vout_Plot();
|
||||
if (record_flag) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_VOLT, MEAS_VOUT(wm));
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_CC:
|
||||
Iin_Vin_Vout_Plot();
|
||||
if (record_flag) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_VOLT, MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_IMPEDANCE, MEAS_VOUT(wm));
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_CV:
|
||||
case CURVE_CA:
|
||||
case CURVE_LSV:
|
||||
Iin_Vin_Vout_Plot();
|
||||
if (record_flag) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_VOLT, MEAS_VOUT(wm) - MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_IMPEDANCE, MEAS_VOUT(wm));
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_PULSE:
|
||||
Iin_Vin_Vout_Plot();
|
||||
if (record_flag) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_VOLT, MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_IMPEDANCE, MEAS_VOUT(wm));
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_IT:
|
||||
IT_Plot();
|
||||
if (record_flag) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_VT:
|
||||
VT_Plot();
|
||||
if (record_flag) {
|
||||
InputNotify(NOTIFY_VOLT, MEAS_VIN(wm));
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_VO:
|
||||
Iin_Vin_Vout_Plot();
|
||||
if (record_flag) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_VOLT, MEAS_VOUT(wm));
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_OCP:
|
||||
Iin_Vin_Vout_Plot();
|
||||
if (record_flag) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_VOLT, MEAS_VOUT(wm) - MEAS_VIN(wm));
|
||||
}
|
||||
case CURVE_EIS_CV:
|
||||
CV_Plot();
|
||||
break;
|
||||
|
||||
case CURVE_CALI_ADC:
|
||||
@@ -453,6 +306,10 @@ static void EliteADCControl(void)
|
||||
cali_VT_plot();
|
||||
} else if (instru.AdcChannel == VOUT_DAC) {
|
||||
cali_VT_plot();
|
||||
} else if (instru.AdcChannel == EIS_HSTIA) {
|
||||
cali_IT_plot();
|
||||
} else if (instru.AdcChannel == EIS_LPTIA) {
|
||||
cali_VT_plot();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -461,51 +318,32 @@ static void EliteADCControl(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void mode_done(void)
|
||||
static void mode_done(void) //finishMode = 1, SendNotify(), Eliteinterrupt()
|
||||
{
|
||||
if ((instru.eliteFxn == CURVE_IV) ||
|
||||
(instru.eliteFxn == CURVE_CV) ||
|
||||
(instru.eliteFxn == CURVE_LSV) ||
|
||||
(instru.eliteFxn == CURVE_IV_CY)) {
|
||||
if (instru.eliteFxn == CURVE_EIS_CV) {
|
||||
if (!PeriodicEvent) {
|
||||
finishMode = 1;
|
||||
SendNotify();
|
||||
Eliteinterrupt();
|
||||
}
|
||||
} else if (instru.eliteFxn == CURVE_EIS){
|
||||
if (!PeriodicEvent) {
|
||||
Eliteinterrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void vscan_ctrl(void)
|
||||
static void vscan_ctrl(void)
|
||||
{
|
||||
switch (instru.eliteFxn) {
|
||||
case CURVE_IV:
|
||||
iv_vscan();
|
||||
case CURVE_EIS:
|
||||
eis_fscan();
|
||||
break;
|
||||
|
||||
case CURVE_IV_CY:
|
||||
iv_cy_vscan();
|
||||
break;
|
||||
|
||||
case CURVE_VO:
|
||||
vo_vscan();
|
||||
break;
|
||||
|
||||
case CURVE_RT:
|
||||
rt_vscan();
|
||||
break;
|
||||
|
||||
case CURVE_CV:
|
||||
case CURVE_EIS_CV:
|
||||
cv_vscan();
|
||||
break;
|
||||
|
||||
case CURVE_LSV:
|
||||
lsv_vscan();
|
||||
break;
|
||||
|
||||
case CURVE_CA:
|
||||
ca_vscan();
|
||||
break;
|
||||
|
||||
default:{
|
||||
break;
|
||||
}
|
||||
|
||||
+17
-16
@@ -555,10 +555,10 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
|
||||
// Application main loops
|
||||
GPT.GptimerCounter0 = GPT.GptimerCounter;
|
||||
|
||||
headstage_battery_volt();
|
||||
//headstage_battery_volt();
|
||||
headstage_init_device_info();
|
||||
|
||||
for (;;) {
|
||||
for (;;) { //keeps going until Periodic Event != True
|
||||
// Waits for a signal to the semaphore associated with the calling thread.
|
||||
// Note that the semaphore associated with a thread is signaled when a
|
||||
// message is queued to the message receive queue of the thread or when
|
||||
@@ -614,16 +614,16 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
|
||||
if (counter6994 < CLOCK_ONE_SECOND*5) { // counter6994 enable a IC after 35 counts
|
||||
counter6994++;
|
||||
} else if (counter6994 == CLOCK_ONE_SECOND*5) {
|
||||
PIN15_setOutputValue(shutdown_6994, 0); // OFF = 1 => turn off 6994
|
||||
//PIN_setOutputValue(pin_handle, shutdown_6994, 0); // OFF = 1 => turn off 6994
|
||||
counter6994++;
|
||||
} else if (counter6994 > CLOCK_ONE_SECOND*5) {
|
||||
counter6994 = 0;
|
||||
}
|
||||
EliteKeyPress(key);
|
||||
|
||||
if(key != 0){ //detect Elite battery power when no periodic event
|
||||
measureBat();
|
||||
}
|
||||
// if(key != 0){ //detect Elite battery power when no periodic event
|
||||
// measureBat();
|
||||
// }
|
||||
if(Free_Work_Mode){
|
||||
wm_deinit();
|
||||
InitEliteInstruction();
|
||||
@@ -631,6 +631,7 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
|
||||
}
|
||||
} else {
|
||||
EliteOn = TurnOnElite(key);
|
||||
// AD5940_init();
|
||||
}
|
||||
}
|
||||
else { // if there is periodic event
|
||||
@@ -919,16 +920,16 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
|
||||
|
||||
numActive = linkDB_NumActive();
|
||||
|
||||
uint16_t cxnHandle;
|
||||
|
||||
// requestedPDUSize = LL payload = L2CAP_header + ATT header + BLE_NOT_BUFF_SIZE = 7 + BLE_NOT_BUFF_SIZE //roy
|
||||
uint16_t requestedPDUSize = 251; //251 roy
|
||||
uint16_t requestTxTime = 2120; // (LL payload + 14) * 8 //2120 roy
|
||||
GAPRole_GetParameter(GAPROLE_CONNHANDLE, &cxnHandle);
|
||||
|
||||
if (SUCCESS == HCI_LE_SetDataLenCmd(cxnHandle, requestedPDUSize, requestTxTime)) {
|
||||
// LED_color(DARKLED, 0xFF, 0x00, 0xFF);
|
||||
}
|
||||
// uint16_t cxnHandle;
|
||||
//
|
||||
// // requestedPDUSize = LL payload = L2CAP_header + ATT header + BLE_NOT_BUFF_SIZE = 7 + BLE_NOT_BUFF_SIZE //roy
|
||||
// uint16_t requestedPDUSize = 251; //251 roy
|
||||
// uint16_t requestTxTime = 2120; // (LL payload + 14) * 8 //2120 roy
|
||||
// GAPRole_GetParameter(GAPROLE_CONNHANDLE, &cxnHandle);
|
||||
//
|
||||
// if (SUCCESS == HCI_LE_SetDataLenCmd(cxnHandle, requestedPDUSize, requestTxTime)) {
|
||||
//// LED_color(DARKLED, 0xFF, 0x00, 0xFF);
|
||||
// }
|
||||
|
||||
// Use numActive to determine the connection handle of the last
|
||||
// connection
|
||||
|
||||
@@ -85,7 +85,7 @@ extern "C"
|
||||
|
||||
// Length of Characteristic 5 in bytes
|
||||
#define SIMPLEPROFILE_CHAR5_LEN 5
|
||||
#define SIMPLEPROFILE_CHAR4_LEN 60
|
||||
#define SIMPLEPROFILE_CHAR4_LEN 20
|
||||
#define SIMPLEPROFILE_CHAR3_LEN 20
|
||||
#define SIMPLEPROFILE_CHAR2_LEN 20
|
||||
|
||||
|
||||
Reference in New Issue
Block a user