Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 123e620f50 | |||
| b5a7720c24 | |||
| 152937ca32 | |||
| 3c85fbef6f | |||
| 4ff8f044c4 | |||
| 22a2095cd7 | |||
| 9c10e4ba53 | |||
| 0529f84511 | |||
| da63ff03d3 | |||
| 141dcb70a3 | |||
| 8625222e36 | |||
| 498652836c | |||
| dbfd4364e3 | |||
| bd049e4fec | |||
| f20b6634ae | |||
| b59472ad2d | |||
| a75b3ba58f | |||
| 8c3d8f46df | |||
| ca29a325f1 | |||
| 61aee1a3e6 | |||
| 162b528385 | |||
| b6e30d25f5 | |||
| db8d7bf0af | |||
| 48d770b271 | |||
| 88d1fc0a5e | |||
| 9769d38897 | |||
| 8be3c30b23 |
-4
@@ -3,20 +3,16 @@
|
||||
<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"/>
|
||||
</listAttribute>
|
||||
|
||||
BIN
Binary file not shown.
-4
@@ -3,20 +3,16 @@
|
||||
<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
@@ -1,247 +0,0 @@
|
||||
|
||||
#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
|
||||
+278
-241
@@ -1,246 +1,283 @@
|
||||
//
|
||||
//#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]);
|
||||
|
||||
#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
|
||||
//// 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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
latch_setOutputValue(latch_num, 1); // Turn on latch
|
||||
// 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();
|
||||
//
|
||||
//// 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
|
||||
// latch_setOutputValue(latch_num, 0); // Turn off latch
|
||||
latch_setOutputValue(LOAD0, 1); // set latch at LOAD0 for SPI transfer
|
||||
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);
|
||||
latch_setOutputValue(LOAD0, 1);
|
||||
latch_setOutputValue(LOAD1, 1);
|
||||
latch_setOutputValue(LOAD2, 1);
|
||||
CPUdelay(10);
|
||||
latch_setOutputValue(LOAD2, 0);
|
||||
|
||||
remove_elite_pin();
|
||||
}
|
||||
|
||||
static void latch_setOutputValue (uint32_t latch_num, bool highlow) {
|
||||
// decode latch value for Elite trigger board
|
||||
if (highlow) {
|
||||
switch (latch_num) {
|
||||
case LOAD0: {
|
||||
PIN_setOutputValue(pin_handle, LOADB, 0);
|
||||
PIN_setOutputValue(pin_handle, LOADA, 0);
|
||||
break;
|
||||
}
|
||||
case LOAD1: {
|
||||
PIN_setOutputValue(pin_handle, LOADB, 0);
|
||||
PIN_setOutputValue(pin_handle, LOADA, 1);
|
||||
break;
|
||||
}
|
||||
case LOAD2: {
|
||||
PIN_setOutputValue(pin_handle, LOADB, 1);
|
||||
PIN_setOutputValue(pin_handle, LOADA, 0);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else { // All latch turn off
|
||||
PIN_setOutputValue(pin_handle, LOADB, 1);
|
||||
PIN_setOutputValue(pin_handle, LOADA, 1);
|
||||
// PIN_setPortOutputValue(pin_handle, ((1<<LOADA)|(1<<LOADB)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void PIN15_setOutputValue_refresh() {
|
||||
ELITE15_SPI_CLOSE();
|
||||
add_elite_pin();
|
||||
|
||||
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]);
|
||||
latch_setOutputValue(LOAD1, 1); // Turn on latch
|
||||
latch_setOutputValue(LOAD0, 1); // set latch at LOAD0 for SPI transfer
|
||||
|
||||
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]);
|
||||
latch_setOutputValue(LOAD2, 1); // Turn on latch
|
||||
latch_setOutputValue(LOAD0, 1); // set latch at LOAD0 for SPI transfer
|
||||
|
||||
remove_elite_pin();
|
||||
ELITE15_SPI_HOLD();
|
||||
}
|
||||
static void disable_trig_output() {
|
||||
update_latch_status(DO_PR_0 , 0);
|
||||
update_latch_status(DO_MOS_0 , 0);
|
||||
update_latch_status(AO_MOS_0 , 0);
|
||||
update_latch_status(AO_MOS_2 , 0);
|
||||
update_latch_status(AO_MOS_3 , 0);
|
||||
update_latch_status(AO_MOS_1 , 0);
|
||||
update_latch_status(DO_MOS_1 , 0);
|
||||
update_latch_status(DO_PR_1 , 0);
|
||||
update_latch_status(OUT_5V_EN_0, 1);
|
||||
update_latch_status(OUT_5V_EN_1, 1);
|
||||
|
||||
PIN15_setOutputValue_refresh();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+270
-791
File diff suppressed because it is too large
Load Diff
+32
@@ -0,0 +1,32 @@
|
||||
|
||||
#ifndef ELITECCC
|
||||
#define ELITECCC
|
||||
|
||||
#include "EliteCCMode.h"
|
||||
|
||||
|
||||
// XXX : should we reset DAC output after STOP?
|
||||
static void CCModeReverseCurrent(CCCMode *CCC){
|
||||
if(CCC->StandBy){
|
||||
if(CT.StandByCounter == CCC->StandByTime){
|
||||
CCC->StandBy = false;
|
||||
CT.StandByCounter = 0;
|
||||
}
|
||||
else{
|
||||
CT.StandByCounter ++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
// reverse charge/discharge
|
||||
if(CCC->BatteryV == CCC->VMax){
|
||||
CCC->StandBy = true;
|
||||
CCC->value = CCC->DischargeCurrent;
|
||||
}
|
||||
else if(CCC->BatteryV == CCC->VMin){
|
||||
CCC->StandBy = true;
|
||||
CCC->value = CCC->ChargeCurrent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
|
||||
#ifndef ELITECCMODE
|
||||
#define ELITECCMODE
|
||||
|
||||
#define Vset INSTRUCTION.Vset
|
||||
#define DELTAVOLTMAX 100000
|
||||
|
||||
/* 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(CCMode *CC){
|
||||
static int32_t Iin = 0;
|
||||
static int32_t deltaI = 0;
|
||||
static int32_t deltaV = 0;
|
||||
uint16_t divisionRate;
|
||||
|
||||
if(vscanReset){
|
||||
Vset = 0;
|
||||
|
||||
if(CC->_charge == 0){
|
||||
CC->_Iset *= -1;
|
||||
}
|
||||
|
||||
Iin = CC->_measureCurrent * 20; //[50pA] nA => 50pA
|
||||
deltaI = Iin - CC->_Iset;
|
||||
|
||||
if(deltaI > 20000000 || deltaI < -20000000){ //1mA
|
||||
divisionRate = 1000;
|
||||
}else{
|
||||
divisionRate = 10;
|
||||
}
|
||||
|
||||
deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
|
||||
|
||||
if(deltaV > DELTAVOLTMAX){ //100000 = 500uV
|
||||
deltaV = DELTAVOLTMAX;
|
||||
}else if(deltaV < (-DELTAVOLTMAX)){
|
||||
deltaV = (-DELTAVOLTMAX);
|
||||
}
|
||||
|
||||
Vset = Vset + deltaV; //[5nV]
|
||||
|
||||
if(Vset <= CC->_Vmin){
|
||||
Vset = CC->_Vmin;
|
||||
}else if(Vset >= CC->_Vmax){
|
||||
Vset = CC->_Vmax;
|
||||
}
|
||||
}
|
||||
|
||||
if(!vscanReset){
|
||||
Iin = CC->_measureCurrent * 20; //[50pA] nA => 50pA
|
||||
deltaI = Iin - CC->_Iset;
|
||||
|
||||
if(deltaI > 20000000 || deltaI < -20000000){ //1mA
|
||||
divisionRate = 1000;
|
||||
}else{
|
||||
divisionRate = 10;
|
||||
}
|
||||
|
||||
deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
|
||||
|
||||
if(deltaV > DELTAVOLTMAX){ //100000 = 500uV
|
||||
deltaV = DELTAVOLTMAX;
|
||||
}else if(deltaV < (-DELTAVOLTMAX)){
|
||||
deltaV = (-DELTAVOLTMAX);
|
||||
}
|
||||
|
||||
Vset = Vset + deltaV; //[5nV]
|
||||
|
||||
if(Vset <= CC->_Vmin){
|
||||
Vset = CC->_Vmin;
|
||||
}else if(Vset >= CC->_Vmax){
|
||||
Vset = CC->_Vmax;
|
||||
}
|
||||
}
|
||||
// int32_t RealV;
|
||||
// RealV = (int32_t)(deltaV);
|
||||
// InputNotify(NOTIFY_IMPEDANCE, RealV);
|
||||
}
|
||||
#endif
|
||||
+90
-49
@@ -1,111 +1,152 @@
|
||||
#ifndef ELITECV3
|
||||
#define ELITECV3
|
||||
|
||||
#define Vset instru.Vset
|
||||
#define Vset INSTRUCTION.Vset
|
||||
|
||||
static void cv_vscan(void)
|
||||
{
|
||||
struct wm_cv_ctx_t *cv = (struct wm_cv_ctx_t *)wm_get();
|
||||
static uint16_t CV3Curve(CV3Mode *CV3){
|
||||
static uint16_t DACOutCode;
|
||||
static int32_t Vin;
|
||||
static int32_t Vout;
|
||||
static int32_t DeltaVout;
|
||||
|
||||
Vin = CV3->_measureVin * 200;//[5nV]
|
||||
if(DACReset){
|
||||
Vout = Vset + Vin;
|
||||
DACReset = false;
|
||||
}else{
|
||||
DeltaVout = Vset - (Vout - Vin);
|
||||
Vout = Vout + DeltaVout;
|
||||
}
|
||||
|
||||
INSTRUCTION.VoltConstant = Vout / 40000 + 25000;//5nV=>usercode
|
||||
DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant);
|
||||
|
||||
int32_t RealV2;
|
||||
RealV2 = (int32_t)((Vout - Vin) / 200);//[1uV]
|
||||
InputNotify(NOTIFY_VOLT, RealV2);
|
||||
|
||||
int32_t RealV;
|
||||
RealV = (int32_t)(Vout / 200);//[1uV]
|
||||
InputNotify(NOTIFY_IMPEDANCE, RealV);
|
||||
|
||||
DAC_outputV(DACOutCode);
|
||||
|
||||
return DACOutCode;
|
||||
}
|
||||
|
||||
|
||||
static void CV3_Vscan(CV3Mode *CV3) {
|
||||
static bool VminCounter;
|
||||
static bool VmaxCounter;
|
||||
|
||||
NotifyCycleNumber = (instru.cycleNumber - cv->_cycleNumber + 1);
|
||||
NotifyCycleNumber = (INSTRUCTION.cycleNumber - CV3->_cycleNumber + 1);
|
||||
|
||||
if (vscanReset) {
|
||||
VmaxCounter = false;
|
||||
VminCounter = false;
|
||||
|
||||
if (instru.directionInit == 1) {
|
||||
cv->_direction_up = true;
|
||||
cv->_current_direction_up = true;
|
||||
if (INSTRUCTION.directionInit == 1) {
|
||||
CV3->_direction_up = true;
|
||||
CV3->_current_direction_up = true;
|
||||
} else {
|
||||
cv->_direction_up = false;
|
||||
cv->_current_direction_up = false;
|
||||
CV3->_direction_up = false;
|
||||
CV3->_current_direction_up = false;
|
||||
}
|
||||
|
||||
// Vstep = x * 20 * N, x=xmV ; N=VscanRate Vstep unit [5nV]/[0.1ms]
|
||||
if (instru.step <= 10) {
|
||||
cv->_Vstep = instru.step * instru.VsetRate / 5;
|
||||
//Vsetp = x * 20 * N, x=xmV ; N=VscanRate
|
||||
if (INSTRUCTION.step <= 10) {
|
||||
CV3->_Vstep = INSTRUCTION.step * INSTRUCTION.VsetRate / 5;
|
||||
} else {
|
||||
cv->_Vstep = instru.step / 5 * instru.VsetRate;
|
||||
CV3->_Vstep = INSTRUCTION.step / 5 * INSTRUCTION.VsetRate;
|
||||
}
|
||||
|
||||
|
||||
if (cv->_Vmin == cv->_Vinit) {
|
||||
if (CV3->_Vmin == CV3->_Vinit) {
|
||||
VminCounter = true;
|
||||
}
|
||||
if (cv->_Vmax == cv->_Vinit) {
|
||||
if (CV3->_Vmax == CV3->_Vinit) {
|
||||
VmaxCounter = true;
|
||||
}
|
||||
|
||||
Vset = cv->_Vinit;
|
||||
Vset = CV3->_Vinit;
|
||||
}
|
||||
|
||||
if (!vscanReset) {
|
||||
cv->bFirst = false;
|
||||
if ((instru.Vinit < instru.Ve1 && instru.Vinit < instru.Ve2) ||
|
||||
(instru.Vinit > instru.Ve1 && instru.Vinit > instru.Ve2)
|
||||
if ((INSTRUCTION.Vinit < INSTRUCTION.Ve1 && INSTRUCTION.Vinit < INSTRUCTION.Ve2) ||
|
||||
(INSTRUCTION.Vinit > INSTRUCTION.Ve1 && INSTRUCTION.Vinit > INSTRUCTION.Ve2)
|
||||
) {
|
||||
if (cv->_current_direction_up) {
|
||||
Vset = Vset + cv->_Vstep; //* GPT.GptimerMultiple;
|
||||
if (CV3->_current_direction_up) {
|
||||
Vset = Vset + CV3->_Vstep * GPT.GptimerMultiple;
|
||||
} else {
|
||||
Vset = Vset - cv->_Vstep; //* GPT.GptimerMultiple;
|
||||
Vset = Vset - CV3->_Vstep * GPT.GptimerMultiple;
|
||||
}
|
||||
|
||||
if (instru.Vinit < instru.Ve1 && instru.Vinit < instru.Ve2) {
|
||||
if (Vset == cv->_Vmin) {
|
||||
if (INSTRUCTION.Vinit < INSTRUCTION.Ve1 && INSTRUCTION.Vinit < INSTRUCTION.Ve2) {
|
||||
if (Vset == CV3->_Vmin) {
|
||||
VminCounter = true;
|
||||
instru.Vinit = instru.Vmin;
|
||||
cv->_Vinit = cv->_Vmin;
|
||||
INSTRUCTION.Vinit = INSTRUCTION.Vmin;
|
||||
CV3->_Vinit = CV3->_Vmin;
|
||||
}
|
||||
} else if (instru.Vinit > instru.Ve1 && instru.Vinit > instru.Ve2) {
|
||||
if (Vset == cv->_Vmax) {
|
||||
} else if (INSTRUCTION.Vinit > INSTRUCTION.Ve1 && INSTRUCTION.Vinit > INSTRUCTION.Ve2) {
|
||||
if (Vset == CV3->_Vmax) {
|
||||
VmaxCounter = true;
|
||||
instru.Vinit = instru.Vmax;
|
||||
cv->_Vinit = cv->_Vmax;
|
||||
INSTRUCTION.Vinit = INSTRUCTION.Vmax;
|
||||
CV3->_Vinit = CV3->_Vmax;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Vset >= cv->_Vmax) {
|
||||
if (Vset >= CV3->_Vmax) {
|
||||
VmaxCounter = true;
|
||||
} else if (Vset <= cv->_Vmin) {
|
||||
} else if (Vset <= CV3->_Vmin) {
|
||||
VminCounter = true;
|
||||
}
|
||||
|
||||
if (cv->_current_direction_up) {
|
||||
Vset = Vset + cv->_Vstep;// * GPT.GptimerMultiple;
|
||||
if (CV3->_current_direction_up) {
|
||||
Vset = Vset + CV3->_Vstep * GPT.GptimerMultiple;
|
||||
} else {
|
||||
Vset = Vset - cv->_Vstep;// * GPT.GptimerMultiple;
|
||||
Vset = Vset - CV3->_Vstep * GPT.GptimerMultiple;
|
||||
}
|
||||
|
||||
if (VmaxCounter && VminCounter) {
|
||||
if (cv->_direction_up && cv->_current_direction_up) {
|
||||
if (Vset >= cv->_Vinit) {
|
||||
cv->_cycleNumber--;
|
||||
if (CV3->_direction_up && CV3->_current_direction_up) {
|
||||
if (Vset >= CV3->_Vinit) {
|
||||
CV3->_cycleNumber--;
|
||||
VminCounter = false;
|
||||
VmaxCounter = false;
|
||||
}
|
||||
}
|
||||
if (!cv->_direction_up && !cv->_current_direction_up) {
|
||||
if (Vset <= cv->_Vinit) {
|
||||
cv->_cycleNumber--;
|
||||
if (!CV3->_direction_up && !CV3->_current_direction_up) {
|
||||
if (Vset <= CV3->_Vinit) {
|
||||
CV3->_cycleNumber--;
|
||||
VminCounter = false;
|
||||
VmaxCounter = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Vset >= cv->_Vmax) {
|
||||
cv->_current_direction_up = false;
|
||||
} else if (Vset <= cv->_Vmin) {
|
||||
cv->_current_direction_up = true;
|
||||
if (Vset >= CV3->_Vmax) {
|
||||
CV3->_current_direction_up = false;
|
||||
} else if (Vset <= CV3->_Vmin) {
|
||||
CV3->_current_direction_up = true;
|
||||
}
|
||||
|
||||
/*stop condition*/
|
||||
if (cv->_cycleNumber == 0) {
|
||||
PeriodicEvent = false;
|
||||
if (CV3->_cycleNumber == 0) {
|
||||
// PeriodicEvent = false;
|
||||
ModeLED(POST_WORK);
|
||||
InitEliteFlag();
|
||||
INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
INSTRUCTION.charge = 0x01;
|
||||
INSTRUCTION.constantCurrent = 0x00;
|
||||
INSTRUCTION.Vmax = 0xC350;
|
||||
INSTRUCTION.Vmin = 0x0000;
|
||||
INSTRUCTION.notifyRate = 500;
|
||||
INSTRUCTION.VoViSwitch = 0x02;//read Vscan = Vout - Vin
|
||||
}
|
||||
}
|
||||
}
|
||||
// int32_t RealV;
|
||||
// RealV = (int32_t)(Vset / 500);//[1uV]
|
||||
// InputNotify(NOTIFY_VOLT, RealV);
|
||||
}
|
||||
#endif
|
||||
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
|
||||
#ifndef ELITECV
|
||||
#define ELITECV
|
||||
|
||||
static uint16_t SWVCurve(WorkMode *WorkModeData) {
|
||||
static uint8_t counter;
|
||||
static uint16_t outputV;
|
||||
static uint16_t Volt;
|
||||
static bool direction_up;
|
||||
|
||||
// reset origin volt at the begin
|
||||
if (DACReset) {
|
||||
Volt = INSTRUCTION.Ve1;
|
||||
outputV = INSTRUCTION.Ve1;
|
||||
if (INSTRUCTION.Ve1 < INSTRUCTION.Ve2)
|
||||
direction_up = true;
|
||||
else
|
||||
direction_up = false;
|
||||
counter = 1;
|
||||
DACReset = false;
|
||||
}
|
||||
|
||||
if (counter == 2 * PulseWidth)
|
||||
counter = 1;
|
||||
else
|
||||
counter++;
|
||||
|
||||
// output a certain volt
|
||||
outputV = Volt;
|
||||
DAC_outputV(outputV);
|
||||
|
||||
// VoltValue = (ramp1*16 + ramp0/16) * 3.05;
|
||||
|
||||
// check if we reach the final volt
|
||||
if ((outputV >= INSTRUCTION.Ve2 && direction_up) || (outputV <= INSTRUCTION.Ve2 && !direction_up)) {
|
||||
PeriodicEvent = false;
|
||||
DACReset = true;
|
||||
}
|
||||
|
||||
// prepare the next output volt
|
||||
if (direction_up) {
|
||||
if (counter == PulseWidth)
|
||||
Volt = Volt + Amplitude;
|
||||
else if (counter == 2 * PulseWidth)
|
||||
Volt = Volt - (Amplitude - INSTRUCTION.step);
|
||||
else
|
||||
Volt = Volt;
|
||||
} else {
|
||||
if (counter == PulseWidth)
|
||||
Volt = Volt - Amplitude;
|
||||
else if (counter == 2 * PulseWidth)
|
||||
Volt = Volt + (Amplitude - INSTRUCTION.step);
|
||||
else
|
||||
Volt = Volt;
|
||||
}
|
||||
|
||||
return outputV;
|
||||
}
|
||||
|
||||
static uint16_t DPVCurve(WorkMode *WorkModeData) {
|
||||
static uint8_t counter;
|
||||
static uint16_t Volt1;
|
||||
static uint16_t Volt2;
|
||||
static uint16_t outputV;
|
||||
static bool direction_up;
|
||||
|
||||
// reset origin volt at the begin
|
||||
if (DACReset) {
|
||||
if (INSTRUCTION.Ve1 < INSTRUCTION.Ve2)
|
||||
direction_up = true;
|
||||
else
|
||||
direction_up = false;
|
||||
|
||||
Volt1 = INSTRUCTION.Ve1;
|
||||
if (direction_up)
|
||||
Volt2 = INSTRUCTION.Ve1 + Amplitude;
|
||||
else
|
||||
Volt2 = INSTRUCTION.Ve1 - Amplitude;
|
||||
|
||||
counter = 1;
|
||||
DACReset = false;
|
||||
}
|
||||
|
||||
if (counter == PulsePeriod)
|
||||
counter = 1;
|
||||
else
|
||||
counter++;
|
||||
|
||||
// output a certain volt
|
||||
if (counter <= (PulsePeriod - PulseWidth)) {
|
||||
outputV = Volt1;
|
||||
DAC_outputV(Volt1);
|
||||
} else {
|
||||
outputV = Volt2;
|
||||
DAC_outputV(Volt2);
|
||||
}
|
||||
|
||||
|
||||
// VoltValue = (ramp1*16 + ramp0/16) * 3.05;
|
||||
|
||||
// check if we reach the final volt
|
||||
if (((outputV >= INSTRUCTION.Ve2) && direction_up) || ((outputV <= INSTRUCTION.Ve2) && !direction_up)) {
|
||||
PeriodicEvent = false;
|
||||
DACReset = true;
|
||||
}
|
||||
|
||||
// check overflow/underflow and prepare for next output
|
||||
if (direction_up) {
|
||||
if (Volt1 + INSTRUCTION.step < Volt1)
|
||||
Volt1 = 0xffff;
|
||||
else
|
||||
Volt1 = Volt1 + INSTRUCTION.step;
|
||||
if (Volt2 + INSTRUCTION.step < Volt2)
|
||||
Volt2 = 0xffff;
|
||||
else
|
||||
Volt2 = Volt2 + INSTRUCTION.step;
|
||||
} else {
|
||||
if (Volt1 - INSTRUCTION.step > Volt1)
|
||||
Volt1 = 0x0000;
|
||||
else
|
||||
Volt1 = Volt1 - INSTRUCTION.step;
|
||||
if (Volt2 - INSTRUCTION.step > Volt2)
|
||||
Volt2 = 0x0000;
|
||||
else
|
||||
Volt2 = Volt2 - INSTRUCTION.step;
|
||||
}
|
||||
|
||||
if (counter + 1 <= (PulsePeriod - PulseWidth)) {
|
||||
return Volt1;
|
||||
} else {
|
||||
return Volt2;
|
||||
}
|
||||
}
|
||||
|
||||
static void CV_Vscan(CVMode *CV){
|
||||
static bool VminCounter;
|
||||
static bool VmaxCounter;
|
||||
|
||||
NotifyCycleNumber = (INSTRUCTION.cycleNumber - CV->_cycleNumber + 1);
|
||||
|
||||
if(vscanReset){
|
||||
VmaxCounter = false;
|
||||
VminCounter = false;
|
||||
|
||||
if(INSTRUCTION.directionInit == 1){
|
||||
CV->_direction_up = true;
|
||||
CV->_current_direction_up = true;
|
||||
}else if(INSTRUCTION.directionInit == 0){
|
||||
CV->_direction_up = false;
|
||||
CV->_current_direction_up = false;
|
||||
}
|
||||
|
||||
//Vsetp = x * 20 * N, x=xmV ; N=VscanRate
|
||||
if(INSTRUCTION.step <= 10){
|
||||
CV->_Vstep = INSTRUCTION.step * INSTRUCTION.VsetRate / 5;
|
||||
}else{
|
||||
CV->_Vstep = INSTRUCTION.step / 5 * INSTRUCTION.VsetRate;
|
||||
}
|
||||
|
||||
if(CV->_Vmin == CV->_Vinit){
|
||||
VminCounter = true;
|
||||
}
|
||||
if(CV->_Vmax == CV->_Vinit){
|
||||
VmaxCounter = true;
|
||||
}
|
||||
|
||||
Vset = CV->_Vinit;
|
||||
}
|
||||
|
||||
if(!vscanReset){
|
||||
if (Vset >= CV->_Vmax){
|
||||
VmaxCounter = true;
|
||||
}else if (Vset <= CV->_Vmin){
|
||||
VminCounter = true;
|
||||
}
|
||||
|
||||
if (CV->_current_direction_up){
|
||||
Vset = Vset + CV->_Vstep * GPT.GptimerMultiple;
|
||||
}else{
|
||||
Vset = Vset - CV->_Vstep * GPT.GptimerMultiple;
|
||||
}
|
||||
|
||||
if(VmaxCounter && VminCounter){
|
||||
if(CV->_direction_up && CV->_current_direction_up){
|
||||
if(Vset >= CV->_Vinit){
|
||||
CV->_cycleNumber--;
|
||||
VminCounter = false;
|
||||
VmaxCounter = false;
|
||||
}
|
||||
}
|
||||
if(!CV->_direction_up && !CV->_current_direction_up){
|
||||
if(Vset <= CV->_Vinit){
|
||||
CV->_cycleNumber--;
|
||||
VminCounter = false;
|
||||
VmaxCounter = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Vset >= CV->_Vmax){
|
||||
CV->_current_direction_up = false;
|
||||
}else if (Vset <= CV->_Vmin){
|
||||
CV->_current_direction_up = true;
|
||||
}
|
||||
|
||||
/*stop condition*/
|
||||
if(CV->_cycleNumber == 0){
|
||||
PeriodicEvent = false;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#ifndef ELITECVSCAN
|
||||
#define ELITECVSCAN
|
||||
|
||||
#define Vset INSTRUCTION.Vset
|
||||
|
||||
static uint16_t CVSCANCurve(CVSCANMode *CVSCAN){
|
||||
static uint16_t DACOutCode;
|
||||
static int32_t Vin;
|
||||
static int32_t Vout;
|
||||
static int32_t DeltaVout;
|
||||
|
||||
Vin = CVSCAN->_measureVin * 200;//[5nV]
|
||||
if(DACReset){
|
||||
Vout = Vset + Vin;
|
||||
DACReset = false;
|
||||
}else{
|
||||
DeltaVout = Vset - (Vout - Vin);
|
||||
Vout = Vout + DeltaVout;
|
||||
}
|
||||
|
||||
INSTRUCTION.VoltConstant = Vout / 40000 + 25000;//5nV=>usercode
|
||||
DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant);
|
||||
|
||||
int32_t RealV2;
|
||||
RealV2 = (int32_t)((Vout - Vin) / 200);//[1uV]
|
||||
InputNotify(NOTIFY_VOLT, RealV2);
|
||||
|
||||
int32_t RealV;
|
||||
RealV = (int32_t)(Vout / 200);//[1uV]
|
||||
InputNotify(NOTIFY_IMPEDANCE, RealV);
|
||||
|
||||
DAC_outputV(DACOutCode);
|
||||
|
||||
return DACOutCode;
|
||||
}
|
||||
|
||||
static void CVSCAN_Vscan(CVSCANMode *CVSCAN){
|
||||
|
||||
if(vscanReset){
|
||||
Vset = CVSCAN->_Vinit;
|
||||
}
|
||||
|
||||
if(!vscanReset){
|
||||
Vset = CVSCAN->_Vinit;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+43
-287
@@ -29,161 +29,59 @@ static bool DACReset;
|
||||
//}
|
||||
//#endif
|
||||
|
||||
//#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;
|
||||
//
|
||||
#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
|
||||
|
||||
|
||||
#define VBIAS_LSB 107422 // 2200/4096 [mV] = 107422 [5nV]
|
||||
#define VZERO_LSB 6875008 // VBIAS_LSB * 64
|
||||
#define DAC12BIT_LSB 107422
|
||||
|
||||
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;
|
||||
|
||||
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));
|
||||
|
||||
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;
|
||||
return voltLV;
|
||||
}
|
||||
|
||||
static void VoutGainControl(uint8_t VOUTLevel){
|
||||
if(VOUTLevel == 0){
|
||||
// VOUT gain level = 0, using 240K resister
|
||||
PIN_setOutputValue(pin_handle, Turon_VOUT_SMALL, 0);
|
||||
// PIN15_setOutputValue(Turon_VOUT_SMALL, 0);
|
||||
}
|
||||
else if(VOUTLevel == 1){
|
||||
// VOUT gain level = 1, using 15K resister
|
||||
PIN_setOutputValue(pin_handle, Turon_VOUT_SMALL, 1);
|
||||
// PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
|
||||
}
|
||||
else if(VOUTLevel == 2){
|
||||
// VOUT gain level = 2, using 15K resister
|
||||
PIN_setOutputValue(pin_handle, Turon_VOUT_SMALL, 1);
|
||||
// PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
|
||||
}
|
||||
else{
|
||||
// default using 15K resister
|
||||
PIN_setOutputValue(pin_handle, Turon_VOUT_SMALL, 1);
|
||||
// PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
|
||||
}
|
||||
record_flag = false;
|
||||
}
|
||||
|
||||
static uint32_t CalcPeriod(uint32_t freq){ //One Second = 10000
|
||||
#endif
|
||||
|
||||
uint32_t period;
|
||||
|
||||
if (freq == 1) {
|
||||
period = 666667;
|
||||
} else {
|
||||
period = (1000000 + freq / 2) / freq; // [sec]
|
||||
}
|
||||
|
||||
if (period < 20){
|
||||
period = 20;
|
||||
}
|
||||
|
||||
return period;
|
||||
static int32_t User2Real(uint16_t UserCode){
|
||||
/* transfer usercode to real voltage value (mV) */
|
||||
return (int32_t)((UserCode - 25000) / 5);
|
||||
}
|
||||
|
||||
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
|
||||
@@ -196,170 +94,28 @@ static void AutoGainChangeVout(int32_t userCode){
|
||||
// switch to 1 level volt(small) 15K
|
||||
// switch to 2 level volt(large) 240K
|
||||
|
||||
if(instru.VoutGainLevel == VOUT_GAIN_AUTO){
|
||||
instru.VoutGainLevel = VOUT_GAIN_15K;
|
||||
VoutGainControl(instru.VoutGainLevel);
|
||||
if(INSTRUCTION.VoutGainLevel == VOUT_GAIN_AUTO){
|
||||
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
|
||||
VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
record_flag = false;
|
||||
}
|
||||
|
||||
if(instru.VoutGainLevel == VOUT_GAIN_15K){
|
||||
if(INSTRUCTION.VoutGainLevel == VOUT_GAIN_15K){
|
||||
if(RealVolt > DAC_VOUT_GAIN_LARGE_BOUNDARY || RealVolt < -1 * DAC_VOUT_GAIN_LARGE_BOUNDARY){
|
||||
// switch to 2 level volt(large)
|
||||
instru.VoutGainLevel = VOUT_GAIN_240K;
|
||||
VoutGainControl(instru.VoutGainLevel);
|
||||
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
|
||||
VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
else if(instru.VoutGainLevel == VOUT_GAIN_240K){
|
||||
else if(INSTRUCTION.VoutGainLevel == VOUT_GAIN_240K){
|
||||
if(RealVolt < DAC_VOUT_GAIN_SMALL_BOUNDARY && RealVolt > -1 * DAC_VOUT_GAIN_SMALL_BOUNDARY ){
|
||||
// switch to 1 level volt(small)
|
||||
instru.VoutGainLevel = VOUT_GAIN_15K;
|
||||
VoutGainControl(instru.VoutGainLevel);
|
||||
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
|
||||
VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
+42
-480
@@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#define BOARD_EIS
|
||||
#define BOARD_C903
|
||||
|
||||
typedef struct _formula{
|
||||
|
||||
@@ -39,42 +39,16 @@ 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),
|
||||
@@ -422,37 +396,6 @@ struct _correction{
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_C5CD
|
||||
{
|
||||
.ADC_volt[0].coeff = (6279),
|
||||
.ADC_volt[0].offset = -100548659,
|
||||
|
||||
.ADC_volt[1].coeff = (216253),
|
||||
.ADC_volt[1].offset = -3471891549,
|
||||
|
||||
.ADC_volt[2].coeff = (6277392),
|
||||
.ADC_volt[2].offset = -100862395596,
|
||||
|
||||
.ADC_current[0].coeff = 3136805,
|
||||
.ADC_current[0].offset = (-50213343000),
|
||||
|
||||
.ADC_current[1].coeff = 72032077,
|
||||
.ADC_current[1].offset = (-1153034516566),
|
||||
|
||||
.ADC_current[2].coeff = 1465628098,
|
||||
.ADC_current[2].offset = (-23459820455868),
|
||||
|
||||
.ADC_current[3].coeff = 30833759075,
|
||||
.ADC_current[3].offset = (-493561287778940),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10522269),
|
||||
.Usercode2DAC[0].offset = 578531626885,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-177684018),
|
||||
.Usercode2DAC[1].offset = 4759051659585,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_C771 //die
|
||||
{
|
||||
.ADC_volt[0].coeff = (6301),
|
||||
@@ -545,410 +488,6 @@ struct _correction{
|
||||
.Usercode2DAC[1].offset = 4789272862069,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_C68B
|
||||
{
|
||||
.ADC_volt[0].coeff = (6268),
|
||||
.ADC_volt[0].offset = -102174553,
|
||||
|
||||
.ADC_volt[1].coeff = (215573),
|
||||
.ADC_volt[1].offset = -3518341586,
|
||||
|
||||
.ADC_volt[2].coeff = (6261878),
|
||||
.ADC_volt[2].offset = -102172685043,
|
||||
|
||||
.ADC_current[0].coeff = 3126866,
|
||||
.ADC_current[0].offset = (-50886322937),
|
||||
|
||||
.ADC_current[1].coeff = 71901602,
|
||||
.ADC_current[1].offset = (-1169888894091),
|
||||
|
||||
.ADC_current[2].coeff = 1460660024,
|
||||
.ADC_current[2].offset = (-23764191484059),
|
||||
|
||||
.ADC_current[3].coeff = 30760667430,
|
||||
.ADC_current[3].offset = (-500493888709662),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10505380),
|
||||
.Usercode2DAC[0].offset = 582175976769,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-179056776),
|
||||
.Usercode2DAC[1].offset = 4796575970947,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_ED5A
|
||||
{
|
||||
.ADC_volt[0].coeff = (6255),
|
||||
.ADC_volt[0].offset = -101981496,
|
||||
|
||||
.ADC_volt[1].coeff = (214609),
|
||||
.ADC_volt[1].offset = -3506688208,
|
||||
|
||||
.ADC_volt[2].coeff = (6287576),
|
||||
.ADC_volt[2].offset = -102718216344,
|
||||
|
||||
.ADC_current[0].coeff = 3135873,
|
||||
.ADC_current[0].offset = (-51079799127),
|
||||
|
||||
.ADC_current[1].coeff = 71803212,
|
||||
.ADC_current[1].offset = (-1169615889960),
|
||||
|
||||
.ADC_current[2].coeff = 1458743323,
|
||||
.ADC_current[2].offset = (-23760656826631),
|
||||
|
||||
.ADC_current[3].coeff = 30800455379,
|
||||
.ADC_current[3].offset = (-501709286949801),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10513739),
|
||||
.Usercode2DAC[0].offset = 582219968611,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178675535),
|
||||
.Usercode2DAC[1].offset = 4787365510181,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_C705
|
||||
{
|
||||
.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_C6EF
|
||||
{
|
||||
.ADC_volt[0].coeff = (6250),
|
||||
.ADC_volt[0].offset = -101736498,
|
||||
|
||||
.ADC_volt[1].coeff = (214630),
|
||||
.ADC_volt[1].offset = -3500639899,
|
||||
|
||||
.ADC_volt[2].coeff = (6273983),
|
||||
.ADC_volt[2].offset = -102312126624,
|
||||
|
||||
.ADC_current[0].coeff = 3118288,
|
||||
.ADC_current[0].offset = (-50838741339),
|
||||
|
||||
.ADC_current[1].coeff = 71681550,
|
||||
.ADC_current[1].offset = (-1168759089937),
|
||||
|
||||
.ADC_current[2].coeff = 1462272089,
|
||||
.ADC_current[2].offset = (-23840506320817),
|
||||
|
||||
.ADC_current[3].coeff = 30686730661,
|
||||
.ADC_current[3].offset = (-500337416473814),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10519033),
|
||||
.Usercode2DAC[0].offset = 583249863408,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178191109),
|
||||
.Usercode2DAC[1].offset = 4776269713117,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_C5AF
|
||||
{
|
||||
.ADC_volt[0].coeff = (6251),
|
||||
.ADC_volt[0].offset = -101338305,
|
||||
|
||||
.ADC_volt[1].coeff = (214878),
|
||||
.ADC_volt[1].offset = -3492068490,
|
||||
|
||||
.ADC_volt[2].coeff = (6268745),
|
||||
.ADC_volt[2].offset = -101859993760,
|
||||
|
||||
.ADC_current[0].coeff = 3137049,
|
||||
.ADC_current[0].offset = (-50892341056),
|
||||
|
||||
.ADC_current[1].coeff = 71900313,
|
||||
.ADC_current[1].offset = (-1166487347464),
|
||||
|
||||
.ADC_current[2].coeff = 1460255142,
|
||||
.ADC_current[2].offset = (-23689442308761),
|
||||
|
||||
.ADC_current[3].coeff = 30735138864,
|
||||
.ADC_current[3].offset = (-498647746053279),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10543618),
|
||||
.Usercode2DAC[0].offset = 583204051611,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-179160298),
|
||||
.Usercode2DAC[1].offset = 4799658904964,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_C6E7
|
||||
{
|
||||
.ADC_volt[0].coeff = (6273),
|
||||
.ADC_volt[0].offset = -101507772,
|
||||
|
||||
.ADC_volt[1].coeff = (215283),
|
||||
.ADC_volt[1].offset = -3492943359,
|
||||
|
||||
.ADC_volt[2].coeff = (6298452),
|
||||
.ADC_volt[2].offset = -102172065832,
|
||||
|
||||
.ADC_current[0].coeff = 3126505,
|
||||
.ADC_current[0].offset = (-50854986702),
|
||||
|
||||
.ADC_current[1].coeff = 71665253,
|
||||
.ADC_current[1].offset = (-1165783058810),
|
||||
|
||||
.ADC_current[2].coeff = 1455913937,
|
||||
.ADC_current[2].offset = (-23682364693928),
|
||||
|
||||
.ADC_current[3].coeff = 30656599965,
|
||||
.ADC_current[3].offset = (-498686538286126),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10548474),
|
||||
.Usercode2DAC[0].offset = 582963458480,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178967404),
|
||||
.Usercode2DAC[1].offset = 4794329226068,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_ED49
|
||||
{
|
||||
.ADC_volt[0].coeff = (6268),
|
||||
.ADC_volt[0].offset = -102013810,
|
||||
|
||||
.ADC_volt[1].coeff = (215623),
|
||||
.ADC_volt[1].offset = -3517703826,
|
||||
|
||||
.ADC_volt[2].coeff = (6273107),
|
||||
.ADC_volt[2].offset = -102313312961,
|
||||
|
||||
.ADC_current[0].coeff = 3131182,
|
||||
.ADC_current[0].offset = (-50878212788),
|
||||
|
||||
.ADC_current[1].coeff = 72031369,
|
||||
.ADC_current[1].offset = (-1170539886748),
|
||||
|
||||
.ADC_current[2].coeff = 1458064484,
|
||||
.ADC_current[2].offset = (-23692701530531),
|
||||
|
||||
.ADC_current[3].coeff = 30723432431,
|
||||
.ADC_current[3].offset = (-499272075689840),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10554205),
|
||||
.Usercode2DAC[0].offset = 583041949770,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178763469),
|
||||
.Usercode2DAC[1].offset = 4789592107725,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_F08F
|
||||
{
|
||||
.ADC_volt[0].coeff = (6264),
|
||||
.ADC_volt[0].offset = -101640847,
|
||||
|
||||
.ADC_volt[1].coeff = (215785),
|
||||
.ADC_volt[1].offset = -3508414799,
|
||||
|
||||
.ADC_volt[2].coeff = (6279952),
|
||||
.ADC_volt[2].offset = -102076620345,
|
||||
|
||||
.ADC_current[0].coeff = 3141963,
|
||||
.ADC_current[0].offset = (-51073231136),
|
||||
|
||||
.ADC_current[1].coeff = 72047691,
|
||||
.ADC_current[1].offset = (-1171229918671),
|
||||
|
||||
.ADC_current[2].coeff = 1461468562,
|
||||
.ADC_current[2].offset = (-23756885490434),
|
||||
|
||||
.ADC_current[3].coeff = 30873625562,
|
||||
.ADC_current[3].offset = (-501896591223166),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10545767),
|
||||
.Usercode2DAC[0].offset = 582980841096,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178801672),
|
||||
.Usercode2DAC[1].offset = 4790333157194,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_E774
|
||||
{
|
||||
.ADC_volt[0].coeff = (6244),
|
||||
.ADC_volt[0].offset = -101801810,
|
||||
|
||||
.ADC_volt[1].coeff = (215275),
|
||||
.ADC_volt[1].offset = -3519927387,
|
||||
|
||||
.ADC_volt[2].coeff = (6279589),
|
||||
.ADC_volt[2].offset = -102655566741,
|
||||
|
||||
.ADC_current[0].coeff = 3123389,
|
||||
.ADC_current[0].offset = (-50776951758),
|
||||
|
||||
.ADC_current[1].coeff = 71847315,
|
||||
.ADC_current[1].offset = (-1168069714834),
|
||||
|
||||
.ADC_current[2].coeff = 1460393971,
|
||||
.ADC_current[2].offset = (-23742664117895),
|
||||
|
||||
.ADC_current[3].coeff = 30737287182,
|
||||
.ADC_current[3].offset = (-499721524793572),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10507966),
|
||||
.Usercode2DAC[0].offset = 581918490604,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178253119),
|
||||
.Usercode2DAC[1].offset = 4776203208556,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_ED21
|
||||
{
|
||||
.ADC_volt[0].coeff = (6237),
|
||||
.ADC_volt[0].offset = -101506434,
|
||||
|
||||
.ADC_volt[1].coeff = (214187),
|
||||
.ADC_volt[1].offset = -3489017250,
|
||||
|
||||
.ADC_volt[2].coeff = (6277851),
|
||||
.ADC_volt[2].offset = -102237808487,
|
||||
|
||||
.ADC_current[0].coeff = 3134799,
|
||||
.ADC_current[0].offset = (-50971095746),
|
||||
|
||||
.ADC_current[1].coeff = 71733616,
|
||||
.ADC_current[1].offset = (-1166459693615),
|
||||
|
||||
.ADC_current[2].coeff = 1462021081,
|
||||
.ADC_current[2].offset = (-23772269392025),
|
||||
|
||||
.ADC_current[3].coeff = 30772308780,
|
||||
.ADC_current[3].offset = (-500364040829566),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10490557),
|
||||
.Usercode2DAC[0].offset = 582220982870,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178506659),
|
||||
.Usercode2DAC[1].offset = 4784370884020,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_EE3A
|
||||
{
|
||||
.ADC_volt[0].coeff = (6258),
|
||||
.ADC_volt[0].offset = -101672777,
|
||||
|
||||
.ADC_volt[1].coeff = (215066),
|
||||
.ADC_volt[1].offset = -3500967589,
|
||||
|
||||
.ADC_volt[2].coeff = (6272676),
|
||||
.ADC_volt[2].offset = -102084032306,
|
||||
|
||||
.ADC_current[0].coeff = 3138624,
|
||||
.ADC_current[0].offset = (-51107815498),
|
||||
|
||||
.ADC_current[1].coeff = 71797400,
|
||||
.ADC_current[1].offset = (-1169199810893),
|
||||
|
||||
.ADC_current[2].coeff = 1462613856,
|
||||
.ADC_current[2].offset = (-23816683013402),
|
||||
|
||||
.ADC_current[3].coeff = 30733477851,
|
||||
.ADC_current[3].offset = (-500459333089804),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10547903),
|
||||
.Usercode2DAC[0].offset = 582785161346,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-179056776),
|
||||
.Usercode2DAC[1].offset = 4797113133841,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_F010
|
||||
{
|
||||
.ADC_volt[0].coeff = (6264),
|
||||
.ADC_volt[0].offset = -101827242,
|
||||
|
||||
.ADC_volt[1].coeff = (215510),
|
||||
.ADC_volt[1].offset = -3511696676,
|
||||
|
||||
.ADC_volt[2].coeff = (6292361),
|
||||
.ADC_volt[2].offset = -102511071793,
|
||||
|
||||
.ADC_current[0].coeff = 3132603,
|
||||
.ADC_current[0].offset = (-50965542108),
|
||||
|
||||
.ADC_current[1].coeff = 71657737,
|
||||
.ADC_current[1].offset = (-1165964825950),
|
||||
|
||||
.ADC_current[2].coeff = 1458242488,
|
||||
.ADC_current[2].offset = (-23726443385639),
|
||||
|
||||
.ADC_current[3].coeff = 30741056126,
|
||||
.ADC_current[3].offset = (-500225222630998),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10586568),
|
||||
.Usercode2DAC[0].offset = 584361939180,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-179021013),
|
||||
.Usercode2DAC[1].offset = 4795545657963,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_EEEF
|
||||
{
|
||||
.ADC_volt[0].coeff = (6263),
|
||||
.ADC_volt[0].offset = -101983153,
|
||||
|
||||
.ADC_volt[1].coeff = (214468),
|
||||
.ADC_volt[1].offset = -3497722617,
|
||||
|
||||
.ADC_volt[2].coeff = (6268586),
|
||||
.ADC_volt[2].offset = -102208366701,
|
||||
|
||||
.ADC_current[0].coeff = 3134472,
|
||||
.ADC_current[0].offset = (-51003312621),
|
||||
|
||||
.ADC_current[1].coeff = 72026797,
|
||||
.ADC_current[1].offset = (-1172092073650),
|
||||
|
||||
.ADC_current[2].coeff = 1463550415,
|
||||
.ADC_current[2].offset = (-23814791825270),
|
||||
|
||||
.ADC_current[3].coeff = 30710210799,
|
||||
.ADC_current[3].offset = (-499732239892393),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10554844),
|
||||
.Usercode2DAC[0].offset = 583784029751,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178890877),
|
||||
.Usercode2DAC[1].offset = 4792844364937,
|
||||
};
|
||||
#endif
|
||||
|
||||
// this function turn ADC measure value (0xXXXX) into real voltage
|
||||
// unit should be uV
|
||||
static int32_t DecodeADCVolt(uint8_t ADCGain, uint16_t ADC_measure){
|
||||
@@ -960,12 +499,12 @@ static int32_t DecodeADCVolt(uint8_t ADCGain, uint16_t ADC_measure){
|
||||
}
|
||||
|
||||
// this function turn ADC measure value (0xXXXX) into Vout voltage
|
||||
// unit should be uV
|
||||
// unit should be mV
|
||||
static int32_t DecodeADCVoutVolt(uint16_t ADC_measure){
|
||||
long long ADCVoutVolt = 0;
|
||||
|
||||
ADCVoutVolt = ((-62658782380) * ADC_measure + 1020118014900000);
|
||||
ADCVoutVolt = ADCVoutVolt / 1e8;
|
||||
ADCVoutVolt = ADCVoutVolt / 1e11;
|
||||
return (int32_t) (ADCVoutVolt);
|
||||
}
|
||||
|
||||
@@ -1028,10 +567,43 @@ 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 uint32_t Usercode_Correction_to_DAC(uint8_t DACGain, uint16_t usercode)
|
||||
static uint16_t Usercode_Correction_to_DAC(uint8_t DACGain, uint16_t usercode)
|
||||
{
|
||||
long long usercode_32;
|
||||
uint16_t DACcode = 0;
|
||||
@@ -1040,19 +612,9 @@ static uint32_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
@@ -1,150 +0,0 @@
|
||||
|
||||
#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
|
||||
|
||||
+8
-2
@@ -7,6 +7,7 @@ struct _CT{
|
||||
uint32_t SampleRate_counter;
|
||||
uint16_t StepTimeCounter;
|
||||
uint16_t NotifyCounter;
|
||||
uint32_t StandByCounter;
|
||||
}CT = {0};
|
||||
|
||||
// GPT counter
|
||||
@@ -18,13 +19,19 @@ struct _GPT{
|
||||
uint32_t NotifyCounter;
|
||||
uint32_t VscanRateCounter;
|
||||
uint32_t LeadTimeCounter;
|
||||
uint32_t DelayTimeCounter;
|
||||
uint32_t BatteryADCCounter;
|
||||
uint32_t BatteryCheckCounter;
|
||||
uint32_t GptimerMultiple;
|
||||
uint32_t StiCounter;
|
||||
}GPT = {0};
|
||||
|
||||
static void InitCT(){
|
||||
CT.SampleRate_counter = 1;
|
||||
CT.StepTimeCounter = 1;
|
||||
CT.NotifyCounter = 1;
|
||||
CT.StandByCounter = 0;
|
||||
}
|
||||
|
||||
static void InitGPT(){
|
||||
GPT.GptimerCounter = 0;
|
||||
GPT.GptimerCounter0 = 0;
|
||||
@@ -33,7 +40,6 @@ static void InitGPT(){
|
||||
GPT.NotifyCounter = 0;
|
||||
GPT.VscanRateCounter = 0;
|
||||
GPT.LeadTimeCounter = 0;
|
||||
GPT.DelayTimeCounter = 0;
|
||||
GPT.BatteryADCCounter = 0;
|
||||
GPT.BatteryCheckCounter = 0;
|
||||
GPT.StiCounter = 0;
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_In
|
||||
#define elite_gptimer_start() GPTimerCC26XX_start(gptimer_handle)
|
||||
#define elite_gptimer_stop() GPTimerCC26XX_stop(gptimer_handle)
|
||||
#define elite_gptimer_close() GPTimerCC26XX_close(gptimer_handle)
|
||||
#define CLOCK_FREQ 4769 // clock freq = 0.1 ms(4800), Measured(4769)
|
||||
#define CLOCK_FREQ 4800 // clock freq = 0.1 ms
|
||||
|
||||
#define elite_gptimer_open() \
|
||||
do { \
|
||||
|
||||
+36
-8
@@ -2,18 +2,46 @@
|
||||
#ifndef ELITEIV
|
||||
#define ELITEIV
|
||||
|
||||
#define Vset instru.Vset
|
||||
#define Vset INSTRUCTION.Vset
|
||||
|
||||
static void vo_vscan(void)
|
||||
{
|
||||
struct wm_vo_ctx_t *vo = (struct wm_vo_ctx_t *)wm_get();
|
||||
static void IV_Vscan(IVMode *IV){
|
||||
if(vscanReset){
|
||||
if(INSTRUCTION.directionInit == 1){
|
||||
IV->_direction_up = true;
|
||||
IV->_current_direction_up = true;
|
||||
}else if(INSTRUCTION.directionInit == 0){
|
||||
IV->_direction_up = false;
|
||||
IV->_current_direction_up = false;
|
||||
}
|
||||
|
||||
if (vscanReset) {
|
||||
Vset = vo->_Vinit;
|
||||
//Vsetp = x * 20 * N, x=xmV ; N=VscanRate
|
||||
if(INSTRUCTION.step <= 10){
|
||||
IV->_Vstep = INSTRUCTION.step * INSTRUCTION.VsetRate / 5;
|
||||
}else{
|
||||
IV->_Vstep = INSTRUCTION.step / 5 * INSTRUCTION.VsetRate;
|
||||
}
|
||||
|
||||
Vset = IV->_Vinit;
|
||||
}
|
||||
|
||||
if(!vscanReset) {
|
||||
Vset = vo->_Vinit;
|
||||
if(!vscanReset){
|
||||
if(IV->_current_direction_up){
|
||||
if(Vset >= IV->_Vmax){
|
||||
PeriodicEvent = false;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}else{
|
||||
if(Vset <= IV->_Vmin){
|
||||
PeriodicEvent = false;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
|
||||
if (IV->_current_direction_up){
|
||||
Vset = Vset + IV->_Vstep * GPT.GptimerMultiple;
|
||||
}else{
|
||||
Vset = Vset - IV->_Vstep * GPT.GptimerMultiple;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+115
-227
@@ -1,14 +1,51 @@
|
||||
#ifndef __INSTR_H__
|
||||
#define __INSTR_H__
|
||||
|
||||
#ifdef __cpulsplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifndef ELITEINSTRUCTION
|
||||
#define ELITEINSTRUCTION
|
||||
|
||||
/** Iin, Vin, Vout **/
|
||||
#define IIN_ADC 0x00
|
||||
#define VIN_ADC 0x01
|
||||
#define VOUT_DAC 0x02
|
||||
#define HIGH_Z 0x03
|
||||
|
||||
/** TRIG01 AOUT, DOUT, PROUT **/
|
||||
#define AOUT_ADC 0x00
|
||||
#define DOUT_ADC 0x01
|
||||
#define PR_DAC 0x02
|
||||
#define LEDtest 0x03
|
||||
#define OUT_5V_EN 0x04
|
||||
|
||||
/** 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
|
||||
|
||||
/** ADC Vin gain level **/
|
||||
#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
|
||||
|
||||
/* DAC reset parameter */
|
||||
#define DAC_ZERO 25000
|
||||
|
||||
// Step time macro
|
||||
#define STEPTIME_HALF_SEC 5000
|
||||
#define STEPTIME_ONE_SEC 10000
|
||||
#define STEPTIME_TWO_SEC 20000
|
||||
|
||||
/*==============================
|
||||
==== headstage instruction ====
|
||||
=============================*/
|
||||
struct HEADSTAGE_INSTRUCTION {
|
||||
|
||||
uint8_t chip_id;
|
||||
uint8_t eliteFxn;
|
||||
|
||||
@@ -25,38 +62,17 @@ 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;
|
||||
uint8_t sampleRateIndex;
|
||||
uint32_t sampleRate;
|
||||
uint8_t VoViSwitch;
|
||||
uint8_t AutoGainEnable;
|
||||
uint8_t VinAutoGainEnable;
|
||||
uint8_t VoutAutoGainEnable;
|
||||
uint8_t ADCGainLv;
|
||||
|
||||
uint8_t ADCGainLevel;
|
||||
// voltage output gain
|
||||
uint16_t VoutGainLevel;
|
||||
uint8_t VinADCGainLv;
|
||||
uint8_t VinADCGainLevel;
|
||||
|
||||
/** Notify parameter **/
|
||||
uint32_t notifyRate;
|
||||
@@ -87,129 +103,24 @@ struct HEADSTAGE_INSTRUCTION {
|
||||
|
||||
uint8_t AdcChannel;
|
||||
|
||||
/* EIS DAC parameter */
|
||||
uint8_t DAC_type;
|
||||
uint16_t VAmpSet; // DAC Voltage Amplitude
|
||||
/** TRIG chan **/
|
||||
bool tri_pr0;
|
||||
bool tri_d0;
|
||||
bool tri_a0;
|
||||
bool tri_a2;
|
||||
bool tri_a3;
|
||||
bool tri_a1;
|
||||
bool tri_d1;
|
||||
bool tri_pr1;
|
||||
bool output_5v_en0;
|
||||
bool output_5v_en1;
|
||||
|
||||
/* EIS ADC parameter */
|
||||
uint8_t HSTIAGainLv;
|
||||
uint8_t HSTIAAutoGainEnable;
|
||||
uint8_t LPTIAGainLv;
|
||||
uint8_t LPTIAAutoGainEnable;
|
||||
} instru = {0};
|
||||
/** trigger mode enable **/
|
||||
bool trig0_en;
|
||||
bool trig1_en;
|
||||
|
||||
/** Iin, Vin, Vout **/
|
||||
#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
|
||||
} INSTRUCTION = {0};
|
||||
|
||||
/** ADC Iin gain level **/
|
||||
#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
|
||||
|
||||
/** Vout gain level **/
|
||||
#define VOUT_GAIN_240K 0x00
|
||||
#define VOUT_GAIN_15K 0x01
|
||||
#define VOUT_GAIN_AUTO 0x02
|
||||
|
||||
/* DAC reset parameter */
|
||||
#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
|
||||
|
||||
/* 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
|
||||
*
|
||||
@@ -220,86 +131,63 @@ static uint32_t HSRTIATable[4] = {160000, 20000, 5000, 200};
|
||||
* @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;
|
||||
|
||||
//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;
|
||||
|
||||
INSTRUCTION.chip_id = 0;
|
||||
INSTRUCTION.eliteFxn = 0; //default is a null event
|
||||
INSTRUCTION.VsetRateIndex = 0;
|
||||
INSTRUCTION.VsetRate = 2;
|
||||
INSTRUCTION.Vset = 0;
|
||||
INSTRUCTION.VoltConstant = DAC_ZERO; //DAC_ZERO is about 0V
|
||||
INSTRUCTION.directionInit = 1; //0:reverse 1:forward
|
||||
INSTRUCTION.step = 0;
|
||||
INSTRUCTION.Ve1 = DAC_ZERO;
|
||||
INSTRUCTION.Ve2 = DAC_ZERO;
|
||||
INSTRUCTION.Vinit = 0;
|
||||
INSTRUCTION.Vmax = 0;
|
||||
INSTRUCTION.Vmin = 0;
|
||||
INSTRUCTION.sampleRateIndex = 1;
|
||||
INSTRUCTION.sampleRate = 100;
|
||||
INSTRUCTION.VoViSwitch = 0x01; //0:user see Vo 1: user see Vi
|
||||
INSTRUCTION.AutoGainEnable = 1;
|
||||
INSTRUCTION.VinAutoGainEnable = 1;
|
||||
INSTRUCTION.VoutAutoGainEnable = 1;
|
||||
INSTRUCTION.ADCGainLevel = I_GAIN_AUTO;
|
||||
INSTRUCTION.VoutGainLevel = VOUT_GAIN_AUTO;
|
||||
INSTRUCTION.VinADCGainLevel = VIN_GAIN_AUTO;
|
||||
INSTRUCTION.notifyRate = STEPTIME_ONE_SEC;
|
||||
INSTRUCTION.cycleNumber = 1;
|
||||
INSTRUCTION.charge = 1; //0:discharge 1:charge
|
||||
INSTRUCTION.constantCurrent = 0;
|
||||
INSTRUCTION.Currentmax = 0;
|
||||
INSTRUCTION.StepTime = STEPTIME_ONE_SEC;
|
||||
INSTRUCTION.AdcChannel = 0;
|
||||
|
||||
//pulse mode
|
||||
instru.sti_t1 = 0;
|
||||
instru.sti_t2 = 0;
|
||||
instru.sti_t3 = 0;
|
||||
instru.sti_t4 = 0;
|
||||
instru.sti_t5 = 0;
|
||||
instru.sti_t6 = 0;
|
||||
instru.sti_t7 = 0;
|
||||
instru.sti_v1 = DAC_ZERO;
|
||||
instru.sti_v2 = DAC_ZERO;
|
||||
instru.sti_v3 = DAC_ZERO;
|
||||
instru.sti_v4 = DAC_ZERO;
|
||||
instru.sti_v5 = DAC_ZERO;
|
||||
instru.sti_v6 = DAC_ZERO;
|
||||
instru.sti_v7 = DAC_ZERO;
|
||||
instru.sti_loop = 1;
|
||||
instru.sti_cy = 0;
|
||||
INSTRUCTION.sti_t1 = 0;
|
||||
INSTRUCTION.sti_t2 = 0;
|
||||
INSTRUCTION.sti_t3 = 0;
|
||||
INSTRUCTION.sti_t4 = 0;
|
||||
INSTRUCTION.sti_t5 = 0;
|
||||
INSTRUCTION.sti_t6 = 0;
|
||||
INSTRUCTION.sti_t7 = 0;
|
||||
INSTRUCTION.sti_v1 = DAC_ZERO;
|
||||
INSTRUCTION.sti_v2 = DAC_ZERO;
|
||||
INSTRUCTION.sti_v3 = DAC_ZERO;
|
||||
INSTRUCTION.sti_v4 = DAC_ZERO;
|
||||
INSTRUCTION.sti_v5 = DAC_ZERO;
|
||||
INSTRUCTION.sti_v6 = DAC_ZERO;
|
||||
INSTRUCTION.sti_v7 = DAC_ZERO;
|
||||
INSTRUCTION.sti_loop = 1;
|
||||
INSTRUCTION.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
|
||||
INSTRUCTION.tri_pr0 = 0;
|
||||
INSTRUCTION.tri_pr1 = 0;
|
||||
INSTRUCTION.tri_a0 = 0;
|
||||
INSTRUCTION.tri_a1 = 0;
|
||||
INSTRUCTION.tri_a2 = 0;
|
||||
INSTRUCTION.tri_a3 = 0;
|
||||
INSTRUCTION.tri_d0 = 0;
|
||||
INSTRUCTION.tri_d1 = 0;
|
||||
INSTRUCTION.output_5v_en0 = 1; // 1 => disable
|
||||
INSTRUCTION.output_5v_en1 = 1; // 1 => disable
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
+15
-17
@@ -8,27 +8,25 @@ 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){
|
||||
// PIN_setOutputValue(pin_handle, enable_5v, 0);
|
||||
// return false;
|
||||
// }else{
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 1); // enable 5V
|
||||
Elite_SPI_init();
|
||||
// TurnOn10V();
|
||||
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();
|
||||
ModeLED(BT_WAIT);
|
||||
AD5940_init();
|
||||
return true;
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
TurnOnCounter++;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
TurnOnCounter = 0;
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V
|
||||
PIN15_setOutputValue(enable_5v, 0); // disable 5V
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -48,18 +46,18 @@ 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);
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V
|
||||
PIN15_setOutputValue(enable_5v, 0); // disable 5V
|
||||
}
|
||||
ShutDownCounter ++;
|
||||
} else {
|
||||
if (OriginEliteFxn == instru.eliteFxn) { // old function == currunt instruction
|
||||
if (OriginEliteFxn == INSTRUCTION.eliteFxn) { // old function == currunt instruction
|
||||
if (ShutDownCounter != 0) {
|
||||
// dark LED
|
||||
checkFlafLED();
|
||||
ShutDownCounter = 0;
|
||||
}
|
||||
} else { // old function != currunt instruction
|
||||
OriginEliteFxn = instru.eliteFxn;
|
||||
OriginEliteFxn = INSTRUCTION.eliteFxn;
|
||||
if (ShutDownCounter != 0) {
|
||||
ShutDownCounter = 0;
|
||||
}
|
||||
@@ -70,7 +68,7 @@ static void EliteKeyPress(uint8_t key) {
|
||||
|
||||
static void TurnOn10V() {
|
||||
If10Von = true;
|
||||
PIN_setOutputValue(pin_handle, enable_10v, 1);
|
||||
// PIN15_setOutputValue(enable_10v, 1);
|
||||
CPUdelay(8000);
|
||||
}
|
||||
|
||||
|
||||
+272
-33
@@ -5,7 +5,20 @@
|
||||
#define DARKLED 0xE1
|
||||
#define LIGHTLED 0xE8
|
||||
|
||||
/* Channels for TRIG01 LED notation */
|
||||
#define LED_PR0 0x00
|
||||
#define LED_D0 0x01
|
||||
#define LED_A0 0x02
|
||||
#define LED_A2 0x03
|
||||
#define LED_A3 0x04
|
||||
#define LED_A1 0x05
|
||||
#define LED_D1 0x06
|
||||
#define LED_PR1 0x07
|
||||
|
||||
static void WorkModeLED();
|
||||
static void update_LED_status (uint8_t chan, uint8_t bright, uint8_t red, uint8_t green, uint8_t blue);
|
||||
static void SET_LED_CHAN(bool *chan_en, uint16_t modeStatus);
|
||||
static void refresh_LED();
|
||||
|
||||
static void LED_color(uint8_t bright, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
spi_LEDtxbuf[0] = 0x0000;
|
||||
@@ -94,12 +107,87 @@ static void Elite_led_color(uint16_t color){
|
||||
}
|
||||
}
|
||||
|
||||
static void Elite_chan_led_color(uint16_t color, uint8_t chan) {
|
||||
switch (color) {
|
||||
case COLOR_RED: {
|
||||
update_LED_status(chan, DARKLED, 0xFF, 0x00, 0x00);
|
||||
break;
|
||||
}
|
||||
case COLOR_ORANGE: {
|
||||
update_LED_status(chan, DARKLED, 0xFF, 0x58, 0x09);
|
||||
break;
|
||||
}
|
||||
case COLOR_YELLOW: {
|
||||
update_LED_status(chan, DARKLED, 0xFF, 0x80, 0x00);
|
||||
break;
|
||||
}
|
||||
case COLOR_GREEN: {
|
||||
update_LED_status(chan, DARKLED, 0x00, 0xFA, 0x00);
|
||||
break;
|
||||
}
|
||||
case COLOR_YELLOWGREEN: {
|
||||
update_LED_status(chan, DARKLED, 0x64, 0xA6, 0x00);
|
||||
break;
|
||||
}
|
||||
case COLOR_BLUE: {
|
||||
update_LED_status(chan, DARKLED, 0x00, 0x00, 0xAA);
|
||||
break;
|
||||
}
|
||||
case COLOR_CYAN: {
|
||||
update_LED_status(chan, DARKLED, 0x00, 0x40, 0x40);
|
||||
break;
|
||||
}
|
||||
case COLOR_MAGENTA: {
|
||||
update_LED_status(chan, DARKLED, 0xFF, 0x00, 0x80);
|
||||
break;
|
||||
}
|
||||
case COLOR_PURPLE: {
|
||||
update_LED_status(chan, DARKLED, 0xFF, 0x00, 0xFF);
|
||||
break;
|
||||
}
|
||||
case COLOR_WHITE: {
|
||||
update_LED_status(chan, DARKLED, 0xCA, 0xFF, 0xFF);
|
||||
break;
|
||||
}
|
||||
case COLOR_BLACK: {
|
||||
update_LED_status(chan, 0x00, 0x00, 0x00, 0x00);
|
||||
break;
|
||||
}
|
||||
//dark LED
|
||||
case COLOR_YELLOW_DARK: {
|
||||
update_LED_status(chan, DARKLED, 0xFF, 0x80, 0x00);
|
||||
break;
|
||||
}
|
||||
case COLOR_GREEN_DARK: {
|
||||
update_LED_status(chan, DARKLED, 0x00, 0x33, 0x00);
|
||||
break;
|
||||
}
|
||||
case COLOR_BLUE_DARK: {
|
||||
update_LED_status(chan, DARKLED, 0x00, 0x00, 0x33);
|
||||
break;
|
||||
}
|
||||
case COLOR_CYAN_DARK: {
|
||||
update_LED_status(chan, DARKLED, 0x00, 0x10, 0x10);
|
||||
break;
|
||||
}
|
||||
case COLOR_PURPLE_DARK: {
|
||||
update_LED_status(chan, DARKLED, 0x55, 0x00, 0x55);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
// refresh_LED();
|
||||
}
|
||||
}
|
||||
|
||||
static void ModeLED(uint16_t modeStatus) {
|
||||
btWaitLedFlag = 0;
|
||||
noEventLedFlag = 0;
|
||||
preWorkLedFlag = 0;
|
||||
workingLedFlag = 0;
|
||||
postWorkLedFlag = 0;
|
||||
TRIG01workFlag = 0;
|
||||
|
||||
switch (modeStatus) {
|
||||
case BT_WAIT: {
|
||||
@@ -127,6 +215,12 @@ static void ModeLED(uint16_t modeStatus) {
|
||||
Elite_led_color(COLOR_BLUE);
|
||||
break;
|
||||
}
|
||||
case TRIG01_WORK: {
|
||||
TRIG01workFlag = 1;
|
||||
WorkModeLED();
|
||||
refresh_LED();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
LEDPowerON();
|
||||
break;
|
||||
@@ -134,8 +228,7 @@ static void ModeLED(uint16_t modeStatus) {
|
||||
}
|
||||
}
|
||||
|
||||
static void checkFlafLED()
|
||||
{
|
||||
static void checkFlafLED() {
|
||||
if(btWaitLedFlag == 1){
|
||||
ModeLED(BT_WAIT);
|
||||
}
|
||||
@@ -151,38 +244,184 @@ static void checkFlafLED()
|
||||
else if(postWorkLedFlag == 1){
|
||||
ModeLED(POST_WORK);
|
||||
}
|
||||
}
|
||||
|
||||
static void WorkModeLED()
|
||||
{
|
||||
switch (instru.eliteFxn) {
|
||||
case CURVE_EIS:
|
||||
case CURVE_EIS_CV:
|
||||
WORKLED();
|
||||
break;
|
||||
|
||||
case CURVE_CALI_ADC:
|
||||
if (instru.AdcChannel == IIN_ADC) {
|
||||
Elite_led_color(COLOR_RED);
|
||||
} else if (instru.AdcChannel == VIN_ADC) {
|
||||
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;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
else if(TRIG01workFlag == 1){
|
||||
ModeLED(TRIG01_WORK);
|
||||
}
|
||||
}
|
||||
|
||||
static void WorkModeLED() {
|
||||
switch (INSTRUCTION.eliteFxn) {
|
||||
case IV_CURVE:
|
||||
case CV_CURVE:
|
||||
case DIFFERENTIAL_PULSE_VOLTAMMETRY:
|
||||
case SQUARE_WAVE_VOLTAMMETRY:
|
||||
case VOLT_OUTPUT:
|
||||
case ZT_CURVE:
|
||||
case VT_CURVE:
|
||||
case IT_CURVE:
|
||||
case ADC_TEST:{
|
||||
SET_LED_CHAN(TRC.chan_en, WORKING);
|
||||
break;
|
||||
}
|
||||
case CYCLIC_VOLTAMMETRY:
|
||||
case LINEAR_SWEEP_VOLTAMMETRY:
|
||||
case CONSTANT_VSCAN:{
|
||||
WORKLED();
|
||||
break;
|
||||
}
|
||||
case PULSE_MODE:{
|
||||
// Elite_led_color(COLOR_YELLOW);
|
||||
WORKLED();
|
||||
break;
|
||||
}
|
||||
case CONSTANT_CURRENT:{
|
||||
WORKLED();
|
||||
break;
|
||||
}
|
||||
case CALI_ADC_MODE:{
|
||||
if(INSTRUCTION.AdcChannel == IIN_ADC){
|
||||
Elite_led_color(COLOR_RED);
|
||||
}else if(INSTRUCTION.AdcChannel == VIN_ADC){
|
||||
Elite_led_color(COLOR_ORANGE);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
// case VIS_RST: {
|
||||
// LEDPowerON();
|
||||
// break;
|
||||
// }
|
||||
default: {
|
||||
WORKLED();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void LED_channel_write(uint8_t chan, uint8_t bright, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
update_LED_status(chan, bright, red, green, blue);
|
||||
refresh_LED();
|
||||
}
|
||||
|
||||
static void update_LED_status (uint8_t chan, uint8_t bright, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
switch(chan) {
|
||||
case LED_PR0: {
|
||||
LED.LED_buf[2] = 0xE000 | ((uint16_t)bright << 8) | blue;
|
||||
LED.LED_buf[3] = ((uint16_t)green << 8) | red;
|
||||
break;
|
||||
}
|
||||
case LED_D0: {
|
||||
LED.LED_buf[4] = 0xE000 | ((uint16_t)bright << 8) | blue;
|
||||
LED.LED_buf[5] = ((uint16_t)green << 8) | red;
|
||||
break;
|
||||
}
|
||||
case LED_A0: {
|
||||
LED.LED_buf[6] = 0xE000 | ((uint16_t)bright << 8) | blue;
|
||||
LED.LED_buf[7] = ((uint16_t)green << 8) | red;
|
||||
break;
|
||||
}
|
||||
case LED_A2: {
|
||||
LED.LED_buf[8] = 0xE000 | ((uint16_t)bright << 8) | blue;
|
||||
LED.LED_buf[9] = ((uint16_t)green << 8) | red;
|
||||
break;
|
||||
}
|
||||
case LED_A3: {
|
||||
LED.LED_buf[10] = 0xE000 | ((uint16_t)bright << 8) | blue;
|
||||
LED.LED_buf[11] = ((uint16_t)green << 8) | red;
|
||||
break;
|
||||
}
|
||||
case LED_A1: {
|
||||
LED.LED_buf[12] = 0xE000 | ((uint16_t)bright << 8) | blue;
|
||||
LED.LED_buf[13] = ((uint16_t)green << 8) | red;
|
||||
break;
|
||||
}
|
||||
case LED_D1: {
|
||||
LED.LED_buf[14] = 0xE000 | ((uint16_t)bright << 8) | blue;
|
||||
LED.LED_buf[15] = ((uint16_t)green << 8) | red;
|
||||
break;
|
||||
}
|
||||
case LED_PR1: {
|
||||
LED.LED_buf[16] = 0xE000 | ((uint16_t)bright << 8) | blue;
|
||||
LED.LED_buf[17] = ((uint16_t)green << 8) | red;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
static void refresh_LED() {
|
||||
spi_LEDtxbuf[0] = 0x0000;
|
||||
spi_LEDtxbuf[1] = 0x0000;
|
||||
|
||||
for (int i = 2; i < SPI_LED_SIZE - 2; i += 2) {
|
||||
spi_LEDtxbuf[i] = LED.LED_buf[i];
|
||||
spi_LEDtxbuf[i+1] = LED.LED_buf[i+1];
|
||||
}
|
||||
|
||||
spi_LEDtxbuf[SPI_LED_SIZE - 2] = 0xffff;
|
||||
spi_LEDtxbuf[SPI_LED_SIZE - 1] = 0xffff;
|
||||
|
||||
LED_SPI(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf);
|
||||
}
|
||||
static void TRIG_LED_Init() {
|
||||
spi_LEDtxbuf[0] = 0x0000;
|
||||
spi_LEDtxbuf[1] = 0x0000;
|
||||
|
||||
for (int i = 2; i < SPI_LED_SIZE - 2; i += 2) {
|
||||
spi_LEDtxbuf[i] = 0xE000;
|
||||
spi_LEDtxbuf[i+1] = 0x0000;
|
||||
}
|
||||
|
||||
spi_LEDtxbuf[SPI_LED_SIZE - 2] = 0xffff;
|
||||
spi_LEDtxbuf[SPI_LED_SIZE - 1] = 0xffff;
|
||||
|
||||
LED_SPI(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf);
|
||||
}
|
||||
|
||||
static void SET_LED_CHAN(bool *chan_en, uint16_t modeStatus){
|
||||
uint8_t ledcolor = 0;
|
||||
switch(modeStatus) {
|
||||
case NO_EVENT:{
|
||||
ledcolor = COLOR_GREEN;
|
||||
break;
|
||||
}
|
||||
case WORKING:{
|
||||
ledcolor = COLOR_CYAN;
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
ledcolor = COLOR_GREEN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t trig_chan = 0;
|
||||
for (int i=0; i<TRIG_CHAN_COUNT-2; i++) {
|
||||
trig_chan = (uint8_t) (i);
|
||||
if(TRC.chan_en[i]) {
|
||||
Elite_chan_led_color(ledcolor, trig_chan);
|
||||
} else {
|
||||
Elite_chan_led_color(COLOR_BLACK, trig_chan);
|
||||
}
|
||||
}
|
||||
if(!TRC.chan_en[8]) {
|
||||
Elite_chan_led_color(COLOR_PURPLE_DARK, LED_D0);
|
||||
} else if(TRC.chan_en[1]) {
|
||||
Elite_chan_led_color(ledcolor, LED_D0);
|
||||
} else {
|
||||
Elite_chan_led_color(COLOR_BLACK, LED_D0); // determine DOUT on or off
|
||||
}
|
||||
if(!TRC.chan_en[9]) {
|
||||
Elite_chan_led_color(COLOR_PURPLE_DARK, LED_D1);
|
||||
} else if(TRC.chan_en[6]) {
|
||||
Elite_chan_led_color(ledcolor, LED_D1);
|
||||
} else {
|
||||
Elite_chan_led_color(COLOR_BLACK, LED_D1);
|
||||
}
|
||||
refresh_LED();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
|
||||
#ifndef ELITE_LED_INIT
|
||||
#define ELITE_LED_INIT
|
||||
|
||||
static void InitLED() {
|
||||
for (int i = 2; i < SPI_LED_SIZE - 2; i += 2) {
|
||||
LED.LED_buf[i] = 0xE000;
|
||||
LED.LED_buf[i+1] = 0x0000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
#ifndef ELITELSV
|
||||
#define ELITELSV
|
||||
|
||||
#define Vset INSTRUCTION.Vset
|
||||
|
||||
static uint16_t LSVCurve(LSVMode *LSV){
|
||||
static uint16_t DACOutCode;
|
||||
static int32_t Vin;
|
||||
static int32_t Vout;
|
||||
static int32_t DeltaVout;
|
||||
|
||||
Vin = LSV->_measureVin * 200;//[5nV]
|
||||
if(DACReset){
|
||||
Vout = Vset + Vin;
|
||||
DACReset = false;
|
||||
}else{
|
||||
DeltaVout = Vset - (Vout - Vin);
|
||||
Vout = Vout + DeltaVout;
|
||||
}
|
||||
|
||||
INSTRUCTION.VoltConstant = Vout / 40000 + 25000;//5nV=>usercode
|
||||
DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant);
|
||||
|
||||
int32_t RealV2;
|
||||
RealV2 = (int32_t)((Vout - Vin) / 200);//[1uV]
|
||||
InputNotify(NOTIFY_VOLT, RealV2);
|
||||
|
||||
int32_t RealV;
|
||||
RealV = (int32_t)(Vout / 200);//[1uV]
|
||||
InputNotify(NOTIFY_IMPEDANCE, RealV);
|
||||
|
||||
DAC_outputV(DACOutCode);
|
||||
//
|
||||
return DACOutCode;
|
||||
}
|
||||
|
||||
static void LSV_Vscan(LSVMode *LSV){
|
||||
|
||||
NotifyCycleNumber = (INSTRUCTION.cycleNumber - LSV->_cycleNumber + 1);
|
||||
|
||||
if(vscanReset){
|
||||
if(INSTRUCTION.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(INSTRUCTION.step <= 10){
|
||||
LSV->_Vstep = INSTRUCTION.step * INSTRUCTION.VsetRate / 5;
|
||||
}else{
|
||||
LSV->_Vstep = INSTRUCTION.step / 5 * INSTRUCTION.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){
|
||||
ModeLED(POST_WORK);
|
||||
// PeriodicEvent = false;
|
||||
Vset = LSV->_Vmin;
|
||||
InitEliteFlag();
|
||||
INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
INSTRUCTION.charge = 0x01;
|
||||
INSTRUCTION.constantCurrent = 0x00;
|
||||
INSTRUCTION.Vmax = 0xC350;
|
||||
INSTRUCTION.Vmin = 0x0000;
|
||||
INSTRUCTION.notifyRate = 500;
|
||||
INSTRUCTION.VoViSwitch = 0x02;//read Vscan = Vout - Vin
|
||||
}else if (Vset <= LSV->_Vmin){
|
||||
ModeLED(POST_WORK);
|
||||
// PeriodicEvent = false;
|
||||
Vset = LSV->_Vmax;
|
||||
InitEliteFlag();
|
||||
INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
INSTRUCTION.charge = 0x01;
|
||||
INSTRUCTION.constantCurrent = 0x00;
|
||||
INSTRUCTION.Vmax = 0xC350;
|
||||
INSTRUCTION.Vmin = 0x0000;
|
||||
INSTRUCTION.notifyRate = 500;
|
||||
INSTRUCTION.VoViSwitch = 0x02;//read Vscan = Vout - Vin
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+6
-10
@@ -29,7 +29,6 @@ static uint8_t NotifyVolt[4] = {0};
|
||||
static uint8_t NotifyImpedance[4] = {0};
|
||||
static uint8_t NotifyVoltBat[4] = {0};
|
||||
static uint16_t NotifyCycleNumber = 0;
|
||||
static uint8_t finishMode = 0;
|
||||
|
||||
// ****************** New Notify Format ******************************** //
|
||||
/*
|
||||
@@ -90,12 +89,12 @@ static uint8_t finishMode = 0;
|
||||
static void SendNotify() {
|
||||
initDATBuf();
|
||||
|
||||
not_buf[0] = instru.chip_id;
|
||||
not_buf[0] = INSTRUCTION.chip_id;
|
||||
|
||||
for (int i = 0; i < 4; 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
|
||||
not_buf[i + 1] = NotifyCurrent[i];
|
||||
not_buf[i + 5] = NotifyVolt[i];
|
||||
not_buf[i + 9] = NotifyImpedance[i];
|
||||
}
|
||||
|
||||
// 1 Timestamp = 32 usec; 31 Timestamp ~= 1 msec
|
||||
@@ -109,9 +108,7 @@ static void SendNotify() {
|
||||
not_buf[17] = (NotifyCycleNumber >> 8) & 0xff;
|
||||
not_buf[18] = NotifyCycleNumber & 0xff;
|
||||
|
||||
not_buf[19] = (finishMode << 7) & 0x80 | instru.ADCGainLv & 0x0F;
|
||||
|
||||
for (int i = 20; i < BLE_DAT_BUFF_SIZE; i++){
|
||||
for (int i = 19; i < BLE_DAT_BUFF_SIZE; i++){
|
||||
not_buf[i] = 0;
|
||||
}
|
||||
|
||||
@@ -139,7 +136,6 @@ static void initCISBuf(){
|
||||
static void initRawDataBuf(){
|
||||
not_time_stamp = 0;
|
||||
NotifyCycleNumber = 0;
|
||||
finishMode = 0;
|
||||
|
||||
for (int i = 0; i < 4; i++){
|
||||
NotifyCurrent[i] = 0;
|
||||
@@ -152,7 +148,7 @@ static void FlushNotify(){
|
||||
initRawDataBuf();
|
||||
initDATBuf();
|
||||
|
||||
not_buf[0] = instru.chip_id;
|
||||
not_buf[0] = INSTRUCTION.chip_id;
|
||||
|
||||
SimpleProfile_SetParameter(BLE_DAT_BUFF_CHAR, BLE_DAT_BUFF_SIZE, not_buf);
|
||||
}
|
||||
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
#ifndef ELITEPULSE
|
||||
#define ELITEPULSE
|
||||
|
||||
#define Vset INSTRUCTION.Vset
|
||||
|
||||
static void PULSE_Vscan(PULSEMode *PULSE)
|
||||
{
|
||||
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 = INSTRUCTION.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;
|
||||
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
|
||||
+29
-33
@@ -3,26 +3,27 @@
|
||||
#define ELITERESET
|
||||
|
||||
static void reset() {
|
||||
mode_init = true;
|
||||
megaStiEnable = false;
|
||||
PeriodicEvent = false; // is there an PeriodicEvent?
|
||||
Free_Work_Mode = true; // Free(WorkModeData)
|
||||
InitPeriodicEvent = true; // need to create a WorkModeData?
|
||||
|
||||
megaStiEnable = false;
|
||||
ModeLED(NO_EVENT);
|
||||
InitEliteFlag();
|
||||
InitFlag();
|
||||
InitCT();
|
||||
InitGPT();
|
||||
|
||||
InitLED();
|
||||
InitTrigChan();
|
||||
|
||||
VinADCGainControl(VIN_GAIN_AUTO);
|
||||
IinADCGainControl(I_GAIN_AUTO);
|
||||
disable_trig_output();
|
||||
|
||||
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
|
||||
VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
|
||||
|
||||
initINSBuf();
|
||||
initDATBuf();
|
||||
|
||||
AD5940_HWReset();
|
||||
AD5940_init();
|
||||
// AD5940_sftreset();
|
||||
|
||||
// PIN_setOutputValue(pin_handle, HIGH_Z_MODE, 0); // HIGH Z MODE // 1: close; 0: open;
|
||||
|
||||
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;
|
||||
@@ -39,28 +40,25 @@ static void reset() {
|
||||
spi_ADC_rxbuf[i] = 0;
|
||||
}
|
||||
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1); // AD_CS HIGH
|
||||
ModeLED(NO_EVENT);
|
||||
CPUdelay(1600);
|
||||
}
|
||||
|
||||
static void Eliteinterrupt() {
|
||||
mode_init = true;
|
||||
megaStiEnable = false;
|
||||
PeriodicEvent = false; // is there an PeriodicEvent?
|
||||
Free_Work_Mode = true; // Free(WorkModeData)
|
||||
InitPeriodicEvent = true; // need to create a WorkModeData?
|
||||
|
||||
megaStiEnable = false;
|
||||
ModeLED(NO_EVENT);
|
||||
InitFlag();
|
||||
InitEliteFlag();
|
||||
InitCT();
|
||||
InitGPT();
|
||||
|
||||
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 0 => open high_z mode
|
||||
|
||||
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
|
||||
VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
|
||||
|
||||
initINSBuf();
|
||||
initDATBuf();
|
||||
AD5940_HWReset();
|
||||
AD5940_init();
|
||||
|
||||
// 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;
|
||||
@@ -77,8 +75,6 @@ static void Eliteinterrupt() {
|
||||
spi_ADC_rxbuf[i] = 0;
|
||||
}
|
||||
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1); // AD_CS HIGH
|
||||
ModeLED(NO_EVENT);
|
||||
CPUdelay(8000);
|
||||
}
|
||||
#endif
|
||||
|
||||
+78
-176
@@ -15,9 +15,10 @@
|
||||
#include "Elite_PIN.h"
|
||||
|
||||
/* application use SPI parameters and buffers */
|
||||
#define SPI_LED_SIZE 28
|
||||
#define SPI_DAC_SIZE 6
|
||||
#define SPI_ADC_SIZE 4
|
||||
#define SPI_LED_SIZE LED_BUFF_SIZE
|
||||
#define SPI_DAC_SIZE 3
|
||||
#define SPI_ADC_SIZE 4
|
||||
#define SPI_GPIO_BUFF_SIZE 10
|
||||
|
||||
static uint16_t spi_LEDtxbuf[SPI_LED_SIZE] = {0};
|
||||
static uint16_t spi_LEDrxbuf[SPI_LED_SIZE] = {0};
|
||||
@@ -27,8 +28,9 @@ 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;
|
||||
|
||||
static uint16_t spi_GPIO_txbuf = 0;
|
||||
static uint16_t SPI_GPIO[SPI_GPIO_BUFF_SIZE] = {0};
|
||||
|
||||
/* system use SPI parameters */
|
||||
static SPI_Handle spiHandle0 = NULL; // SPI0 = LED
|
||||
@@ -44,7 +46,7 @@ static void ELITE15_SPI_CLOSE();
|
||||
static void Elite_SPI_init(){
|
||||
SPI_init();
|
||||
SPI_Params_init(&spiParams0);
|
||||
spiParams0.bitRate = 2000; // 2k
|
||||
spiParams0.bitRate = 2000; // 12k
|
||||
spiParams0.mode = SPI_MASTER;
|
||||
spiParams0.dataSize = 16;
|
||||
spiParams0.frameFormat = SPI_POL0_PHA1;
|
||||
@@ -54,8 +56,7 @@ static void Elite_SPI_init(){
|
||||
spiParams1.bitRate = 1000000; // 1M
|
||||
spiParams1.mode = SPI_MASTER;
|
||||
spiParams1.dataSize = 8;
|
||||
spiParams1.frameFormat = SPI_POL0_PHA0;
|
||||
|
||||
spiParams1.frameFormat = SPI_POL0_PHA1;
|
||||
spiHandle1 = SPI_open(Board_SPI1, &spiParams1); // ADC DAC SPI
|
||||
}
|
||||
|
||||
@@ -68,7 +69,9 @@ 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) {
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 0); // CS_ADC
|
||||
// PIN15_setOutputValue(ADC_CS, 0); // ADC_CS LOW
|
||||
latch_setOutputValue(LOAD0, 1);
|
||||
// PIN_setOutputValue(pin_handle, D6, 0); // ADC_CS LOW
|
||||
|
||||
ADC_DAC_transaction.count = length;
|
||||
ADC_DAC_transaction.txBuf = spi_txbuf;
|
||||
@@ -76,33 +79,38 @@ 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, AD_CS, 1); // CS_ADC
|
||||
// PIN_setOutputValue(pin_handle, D6, 1); // ADC_CS HOGH
|
||||
// update_latch_status (ADC_CS, 1);
|
||||
// PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
|
||||
}
|
||||
|
||||
static void DAC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
ADC_DAC_transaction.count = length;
|
||||
ADC_DAC_transaction.txBuf = spi_txbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
// 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 HOGH
|
||||
// update_latch_status (DAC_CS, 1);
|
||||
// PIN15_setOutputValue(DAC_CS, 1); // DAC_CS HIGH
|
||||
}
|
||||
|
||||
static void ELITE15_SPI_HOLD() {
|
||||
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);
|
||||
|
||||
// PIN_setOutputValue(pin_handle, LOADA, 0); // Turn on LATCH0
|
||||
// PIN_setOutputValue(pin_handle, LOADB, 0);
|
||||
PIN_setPortOutputValue(pin_handle, 0); // stay at LOAD0
|
||||
}
|
||||
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, LOADB, 1); // Turn off all LATCH
|
||||
// PIN_setOutputValue(pin_handle, LOADA, 1);
|
||||
PIN_setPortOutputValue(pin_handle, 0); // stay at LOAD0
|
||||
|
||||
SPI_close(spiHandle0);
|
||||
SPI_close(spiHandle1);
|
||||
@@ -110,163 +118,57 @@ 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
|
||||
latch_setOutputValue(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, AD_CS, 1); // CS_ADC
|
||||
// PIN_setOutputValue(pin_handle, D6, 1); // ADC_CS HIGH
|
||||
// update_latch_status (ADC_CS, 1);
|
||||
// PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
|
||||
}
|
||||
|
||||
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;
|
||||
static void GPIO_SPI_transfer(uint32_t *GPIO_CLK_CH, uint16_t spi_GPIO_txbuf) {
|
||||
|
||||
SPI_transfer(spiHandle0, &LED_transaction);
|
||||
for (int i=0; i<SPI_GPIO_BUFF_SIZE; i++) {
|
||||
SPI_GPIO[i] = 0;
|
||||
}
|
||||
|
||||
SPI_GPIO[0] = (spi_GPIO_txbuf & 0b0000000000000001); // MOSI
|
||||
SPI_GPIO[1] = (spi_GPIO_txbuf & 0b0000000000000010);
|
||||
SPI_GPIO[2] = (spi_GPIO_txbuf & 0b0000000000000100);
|
||||
SPI_GPIO[3] = (spi_GPIO_txbuf & 0b0000000000001000);
|
||||
SPI_GPIO[4] = (spi_GPIO_txbuf & 0b0000000000010000);
|
||||
SPI_GPIO[5] = (spi_GPIO_txbuf & 0b0000000000100000);
|
||||
SPI_GPIO[6] = (spi_GPIO_txbuf & 0b0000000001000000);
|
||||
SPI_GPIO[7] = (spi_GPIO_txbuf & 0b0000000010000000);
|
||||
SPI_GPIO[8] = (spi_GPIO_txbuf & 0b0000000100000000);
|
||||
SPI_GPIO[9] = (spi_GPIO_txbuf & 0b0000001000000000);
|
||||
|
||||
ELITE15_SPI_CLOSE();
|
||||
PIN_setPortOutputValue(pin_handle, 0); // Turn on LATCH0
|
||||
add_elite_pin();
|
||||
|
||||
for (int i=9; i>=0; i--) {
|
||||
PIN_setOutputValue(pin_handle, GPIO_CLK_CH[1], 0); // generate clk signal
|
||||
PIN_setOutputValue(pin_handle, D3, SPI_GPIO[i]); // data transfer at rising edge, MOSI = D3
|
||||
PIN_setOutputValue(pin_handle, GPIO_CLK_CH[1], 1); // generate clk signal
|
||||
}
|
||||
|
||||
PIN_setOutputValue(pin_handle, GPIO_CLK_CH[1], 0);
|
||||
update_latch_status (GPIO_CLK_CH[0], GPIO_CLK_CH[1], 0);
|
||||
|
||||
PIN_setOutputValue(pin_handle, D3, 0);
|
||||
update_latch_status (ADC_SPI_MOSI, 0);
|
||||
|
||||
// PIN_setPortOutputValue(pin_handle, 0); // set all LATCH0 pin to LOW
|
||||
remove_elite_pin();
|
||||
ELITE15_SPI_HOLD();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#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
|
||||
|
||||
+548
-545
File diff suppressed because it is too large
Load Diff
+21
@@ -0,0 +1,21 @@
|
||||
|
||||
#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 ZT_Vscan(RTMode *RT){
|
||||
if(vscanReset){
|
||||
Vset = ((int32_t)(INSTRUCTION.VoltConstant) - 25000) * 4 * 10000; //[5nV]
|
||||
OneWayVoltScan();
|
||||
}
|
||||
|
||||
if(!vscanReset){
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+57
-97
@@ -6,65 +6,6 @@
|
||||
#include <Board.h>
|
||||
#include <ti/drivers/PIN.h>
|
||||
|
||||
//#define ELITE_PIN_1_5
|
||||
//#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
|
||||
@@ -85,37 +26,35 @@ static void remove_elite_pin() {
|
||||
#define D6 IOID_9
|
||||
#define D7 IOID_10
|
||||
|
||||
#define LOAD0 IOID_13
|
||||
#define LOAD1 IOID_12
|
||||
#define LOAD2 IOID_11
|
||||
#define LOADB IOID_12
|
||||
#define LOADA IOID_11
|
||||
|
||||
#define ADC_CS LOAD0, D6
|
||||
#define DAC_CS LOAD0, D7
|
||||
#define ADC_DAC_SPI_MOSI LOAD0, D3
|
||||
#define ADC_DAC_SPI_CLK LOAD0, D2
|
||||
#define TW_SCKI_2 LOAD0, D6
|
||||
#define TW_SCKI_3 LOAD0, D7
|
||||
#define ADC_SPI_MOSI LOAD0, D3
|
||||
#define ADC_SPI_CLK LOAD0, D2
|
||||
#define LED_MOSI LOAD0, D1
|
||||
#define LED_CLK LOAD0, D0
|
||||
#define MEM_CS LOAD0, D5
|
||||
#define TW_SCKI_0 LOAD0, D4
|
||||
#define TW_SCKI_1 LOAD0, D5
|
||||
|
||||
#ifdef ELITE_PIN_1_5
|
||||
#define MEM_HOLD LOAD0, D4
|
||||
#define HIGH_Z_MODE LOAD2, D5
|
||||
#endif
|
||||
#ifdef ELITE_PIN_1_5_RE
|
||||
#define MEM_HOLD LOAD1, D0
|
||||
#define HIGH_Z_MODE LOAD0, D4
|
||||
#endif
|
||||
#define BAT_CHAR LOAD1, D0
|
||||
#define BAT_OK LOAD1, D1
|
||||
#define PULLUP_3V_0 LOAD1, D2
|
||||
#define PULLUP_3V_1 LOAD1, D3
|
||||
#define shutdown_6994 LOAD1, D4
|
||||
#define OUT_5V_EN_0 LOAD1, D5
|
||||
#define enable_5v LOAD1, D6
|
||||
#define OUT_5V_EN_1 LOAD1, D7
|
||||
|
||||
#define Turnon_I_MID LOAD2, D0
|
||||
#define Turnon_I_SMALL LOAD2, D4
|
||||
#define Turnon_I_LARGE LOAD2, D1
|
||||
#define Turnon_V_SMALL LOAD2, D2
|
||||
#define Turnon_V_MID LOAD2, D3
|
||||
#define Turon_VOUT_SMALL LOAD2, D7
|
||||
#define shutdown_6994 LOAD2, D6
|
||||
|
||||
//#define Turnon10K Turnon_I_MID
|
||||
//#define Turnon200R Turnon_I_LARGE
|
||||
#define DO_MOS_0 LOAD2, D0
|
||||
#define DO_MOS_1 LOAD2, D1
|
||||
#define AO_MOS_0 LOAD2, D2
|
||||
#define AO_MOS_1 LOAD2, D3
|
||||
#define AO_MOS_2 LOAD2, D4
|
||||
#define AO_MOS_3 LOAD2, D5
|
||||
#define DO_PR_0 LOAD2, D6
|
||||
#define DO_PR_1 LOAD2, D7
|
||||
|
||||
/* I2C */
|
||||
#ifdef ELITE_VERSION_1_4
|
||||
@@ -124,8 +63,13 @@ static void remove_elite_pin() {
|
||||
#endif
|
||||
|
||||
#define switch_on IOID_14
|
||||
#define enable_10v LOAD1, D5
|
||||
#define enable_5v LOAD1, D6
|
||||
#define FLT IOID_13
|
||||
#define TRIG_0 IOID_0
|
||||
#define TRIG_1 IOID_2
|
||||
|
||||
#define LOAD0 0x00000000
|
||||
#define LOAD1 0x00000001
|
||||
#define LOAD2 0x00000002
|
||||
|
||||
PIN_Handle pin_handle;
|
||||
static PIN_State ZM_rst;
|
||||
@@ -135,16 +79,19 @@ const PIN_Config BLE_IO[] = {
|
||||
// D1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
// D2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
// D3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
D4 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
D5 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
D6 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
D7 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
// D4 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
// D5 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
// D6 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
// D7 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
|
||||
LOAD0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
LOAD1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
LOAD2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
LOADA | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
LOADB | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
|
||||
switch_on | PIN_INPUT_EN | PIN_PULLDOWN, // to sense switch
|
||||
switch_on | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLDOWN, // to sense switch
|
||||
|
||||
TRIG_0 | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLDOWN,
|
||||
TRIG_1 | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLDOWN,
|
||||
FLT | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLDOWN,
|
||||
|
||||
PIN_TERMINATE
|
||||
};
|
||||
@@ -159,17 +106,30 @@ static void add_elite_pin() {
|
||||
D2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
PIN_add(pin_handle,
|
||||
D3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
|
||||
PIN_add(pin_handle,
|
||||
D4 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
PIN_add(pin_handle,
|
||||
D5 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
PIN_add(pin_handle,
|
||||
D6 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
PIN_add(pin_handle,
|
||||
D7 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
// if(elite15_status != PIN_SUCCESS) {
|
||||
// LED_color(DARKLED, 0x0F, 0x0F, 0x0F);
|
||||
// }
|
||||
}
|
||||
|
||||
static void trig_callback(PIN_Handle handle, PIN_Id pinId);
|
||||
|
||||
static void remove_elite_pin() {
|
||||
PIN_close(pin_handle);
|
||||
pin_handle = PIN_open(&ZM_rst, BLE_IO);
|
||||
|
||||
PIN_registerIntCb(pin_handle, trig_callback);
|
||||
PIN_setInterrupt(pin_handle, TRIG_0 | PIN_IRQ_NEGEDGE);
|
||||
PIN_setInterrupt(pin_handle, TRIG_1 | PIN_IRQ_NEGEDGE);
|
||||
PIN_setInterrupt(pin_handle, FLT | PIN_IRQ_NEGEDGE);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @def BOOSTXL_CC2650MA_SPIName
|
||||
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
#ifndef ELITETRIG
|
||||
#define ELITETRIG
|
||||
|
||||
static bool trig0_event_wait = false;
|
||||
static bool trig1_event_wait = false;
|
||||
static void set_output_enable(bool *out_chan);
|
||||
|
||||
|
||||
static void InitTrigChan () {
|
||||
for(int i=0; i<TRIG_CHAN_COUNT; i++) {
|
||||
TRC.chan_en[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void trig_en_check( ) {
|
||||
if (INSTRUCTION.trig0_en) {
|
||||
trig0_event_wait = true;
|
||||
INSTRUCTION.trig0_en = 0;
|
||||
} else if (INSTRUCTION.trig1_en) {
|
||||
trig1_event_wait = true;
|
||||
INSTRUCTION.trig1_en = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void FLT_sense( ) {
|
||||
bool FLT_value = true;
|
||||
FLT_value = PIN_getInputValue(FLT);
|
||||
|
||||
if(!FLT_value) { // if FLT = LOW, disable all output
|
||||
// PIN15_setOutputValue(OUT_5V_EN_0, 1);
|
||||
// PIN15_setOutputValue(OUT_5V_EN_1, 1);
|
||||
// set_output_enable(allDisable);
|
||||
} else {
|
||||
PIN15_setOutputValue_refresh();
|
||||
}
|
||||
}
|
||||
|
||||
static void trig_sense( ) {
|
||||
if (Trig_receive) {
|
||||
Trig_receive = false;
|
||||
|
||||
if (trig0_event) {
|
||||
trig0_event = false;
|
||||
trig0_event_wait = true;
|
||||
} else if (trig1_event) {
|
||||
trig1_event = false;
|
||||
trig1_event_wait = true;
|
||||
} else if (FLT_event) {
|
||||
FLT_event = false;
|
||||
FLT_sense();
|
||||
}
|
||||
}
|
||||
|
||||
if (trig0_event_wait && trig1_event_wait) { // both channel are triggered
|
||||
trig0_event_wait = false;
|
||||
trig1_event_wait = false;
|
||||
if(TRIG_TrigEnable && INSTRUCTION.eliteFxn == PULSE_MODE) {
|
||||
trig_PeriodicEvent = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void trig_callback(PIN_Handle handle, PIN_Id pinId) {
|
||||
if(TRIG_TrigEnable && INSTRUCTION.eliteFxn == PULSE_MODE) {
|
||||
// trig_PeriodicEvent = true;
|
||||
Trig_receive = true;
|
||||
}
|
||||
// PIN15_setOutputValue(MEGA_G_LED, 1);
|
||||
// PIN15_setOutputValue(MEGA_G_LED, 1);
|
||||
switch (pinId) {
|
||||
case TRIG_0: {
|
||||
trig0_event = true;
|
||||
break;
|
||||
}
|
||||
case TRIG_1: {
|
||||
trig1_event = true;
|
||||
break;
|
||||
}
|
||||
case FLT:{
|
||||
FLT_event = true;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void set_output_enable(bool *out_chan) {
|
||||
update_latch_status(DO_PR_0 , out_chan[0]);
|
||||
update_latch_status(DO_MOS_0 , out_chan[1]);
|
||||
update_latch_status(AO_MOS_0 , out_chan[2]);
|
||||
update_latch_status(AO_MOS_2 , out_chan[3]);
|
||||
update_latch_status(AO_MOS_3 , out_chan[4]);
|
||||
update_latch_status(AO_MOS_1 , out_chan[5]);
|
||||
update_latch_status(DO_MOS_1 , out_chan[6]);
|
||||
update_latch_status(DO_PR_1 , out_chan[7]);
|
||||
update_latch_status(OUT_5V_EN_0, out_chan[8]);
|
||||
update_latch_status(OUT_5V_EN_1, out_chan[9]);
|
||||
|
||||
PIN15_setOutputValue_refresh();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+23
-13
@@ -42,18 +42,22 @@ static void headstage_battery_volt(){
|
||||
|
||||
static void EliteADCBattery(){
|
||||
static uint8_t ADCSwitch = 0;
|
||||
if(ADCSwitch == 0){ /**read V**/
|
||||
ReadADCBat(spi_ADC_rxbuf);
|
||||
ADCSwitch++;
|
||||
}
|
||||
else if(ADCSwitch == 1){ /**read V**/
|
||||
ReadADCBat(spi_ADC_rxbuf);
|
||||
ADCSwitch++;
|
||||
}
|
||||
else if(ADCSwitch == 2){ /**read V(buffer)**/
|
||||
headstage_battery_volt();
|
||||
batteryCheck_flag = false;
|
||||
if(INSTRUCTION.eliteFxn == ADC_TEST){
|
||||
ADCSwitch = 0;
|
||||
}else{
|
||||
if(ADCSwitch == 0){ /**read V**/
|
||||
ReadADCBat(spi_ADC_rxbuf);
|
||||
ADCSwitch++;
|
||||
}
|
||||
else if(ADCSwitch == 1){ /**read V**/
|
||||
ReadADCBat(spi_ADC_rxbuf);
|
||||
ADCSwitch++;
|
||||
}
|
||||
else if(ADCSwitch == 2){ /**read V(buffer)**/
|
||||
headstage_battery_volt();
|
||||
batteryCheck_flag = false;
|
||||
ADCSwitch = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,8 +84,14 @@ static void measureBat(){
|
||||
|
||||
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);
|
||||
if( bat < 768 && bat > 20){ // 768 = 3V
|
||||
PIN15_setOutputValue(enable_5v, 0);
|
||||
} else if (bat < 1070){ // 1075 = 4.2V
|
||||
PIN15_setOutputValue(BAT_CHAR, 1);
|
||||
PIN15_setOutputValue(BAT_OK, 0);
|
||||
} else if (bat >= 1075){
|
||||
PIN15_setOutputValue(BAT_CHAR, 0);
|
||||
PIN15_setOutputValue(BAT_OK, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+38
-41
@@ -12,45 +12,41 @@
|
||||
#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
|
||||
#define VIS_TRIG_EN 0x41
|
||||
|
||||
// RIS (real instruction)
|
||||
enum all_mode_e {
|
||||
|
||||
CURVE_EIS = 0xD1, //Should Change to 0xD1
|
||||
CURVE_EIS_CV = 0xD2,
|
||||
|
||||
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,
|
||||
};
|
||||
#define IV_CURVE 0x10
|
||||
#define CV_CURVE 0x20
|
||||
#define VOLT_OUTPUT 0x30
|
||||
#define ZT_CURVE 0x40
|
||||
#define VT_CURVE 0x50
|
||||
#define IT_CURVE 0x60
|
||||
#define SET_SAMPLE_RATE 0x70
|
||||
#define SET_ADC_DAC_GAIN 0x80
|
||||
#define SET_EN_CHAN 0x81
|
||||
#define DIFFERENTIAL_PULSE_VOLTAMMETRY 0xA0
|
||||
#define SQUARE_WAVE_VOLTAMMETRY 0xB0
|
||||
#define CYCLIC_VOLTAMMETRY 0xC0
|
||||
#define CONSTANT_CURRENT 0xD0
|
||||
#define CYCLE_CONSTANT_CURRENT 0xF0
|
||||
#define HIGH_CYCLE_CYCLIC_VOLTAMMETRY 0x01
|
||||
#define LINEAR_SWEEP_VOLTAMMETRY 0x02
|
||||
#define CONSTANT_VSCAN 0x03
|
||||
#define ADC_TEST 0x91
|
||||
#define CALI_DAC_MODE 0x93
|
||||
#define CALI_ADC_MODE 0x92
|
||||
#define PULSE_MODE 0x94
|
||||
|
||||
// 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)
|
||||
@@ -59,6 +55,7 @@ enum all_mode_e {
|
||||
#define VDIRECTION(v1,v2) ((v1 > v2) ? 0 : 1)
|
||||
#define AFTER_READ_I 0
|
||||
#define AFTER_READ_V 1
|
||||
#define ReadADCVolt(x) ((x==0)? ReadADCVout(spi_ADC_rxbuf) : ReadADCVin(spi_ADC_rxbuf))
|
||||
#define PARA_1 0x01
|
||||
#define PARA_2 0x02
|
||||
#define PARA_3 0x03
|
||||
@@ -100,23 +97,23 @@ enum all_mode_e {
|
||||
#define KEYLED() Elite_led_color(COLOR_YELLOW)
|
||||
#define BT_WAIT_LED() Elite_led_color(COLOR_YELLOWGREEN)
|
||||
|
||||
/* TRIG01 define */
|
||||
#define PR_0 0x00
|
||||
#define MOS_D0 0x01
|
||||
#define MOS_A0 0x02
|
||||
#define MOS_A2 0x03
|
||||
#define MOS_A3 0x04
|
||||
#define MOS_A1 0x05
|
||||
#define MOS_D1 0x06
|
||||
#define PR_1 0x07
|
||||
#define TRIG_CHAN_COUNT 10 // channel count of TRIG01
|
||||
|
||||
#define BT_WAIT 0x01
|
||||
#define NO_EVENT 0x02
|
||||
#define PRE_WORK 0x03
|
||||
#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 TRIG01_WORK 0x06
|
||||
|
||||
#define VALUE_ZERO_TO_ONE(_v) (_v == 0) ? 1 : _v
|
||||
#endif
|
||||
|
||||
+705
-543
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -3,10 +3,10 @@
|
||||
#define VERSION_DATE
|
||||
|
||||
#define VERSION_DATE_YEAR 21
|
||||
#define VERSION_DATE_MONTH 8
|
||||
#define VERSION_DATE_DAY 30
|
||||
#define VERSION_DATE_HOUR 15
|
||||
#define VERSION_DATE_MINUTE 47
|
||||
#define VERSION_DATE_MONTH 1
|
||||
#define VERSION_DATE_DAY 5
|
||||
#define VERSION_DATE_HOUR 11
|
||||
#define VERSION_DATE_MINUTE 8
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
|
||||
-197
@@ -1,197 +0,0 @@
|
||||
#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
@@ -1,448 +0,0 @@
|
||||
#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
|
||||
+681
-529
File diff suppressed because it is too large
Load Diff
+16
-16
@@ -129,16 +129,16 @@ static void update_ins_sti_channel(uint8_t *buf, uint8 sti_chp, uint8 sti_chn) {
|
||||
|
||||
static void update_ins_buffer() {
|
||||
uint8 header = 0b10100000;
|
||||
uint8 amp_gain = (instru.amp_gain & 0b11) << 3;
|
||||
uint8 amp_lbf = instru.amp_low_band_freq & 0b111;
|
||||
uint8 amp_gain = (INSTRUCTION.amp_gain & 0b11) << 3;
|
||||
uint8 amp_lbf = INSTRUCTION.amp_low_band_freq & 0b111;
|
||||
uint8 channel = 0; // should be call update_ins_channel to modify this value
|
||||
uint8 chopper = (instru.chopper) ? 0b00001000 : 0;
|
||||
uint8 fast_settle = (instru.fast_settle) ? 0b00000100 : 0;
|
||||
uint8 sti_enable = (instru.work_mode != STI_MODE_DISABLE) ? 0b00000010 : 0;
|
||||
uint8 sti_volt_l = (instru.sti_volt & 0b11111) >> 4;
|
||||
uint8 sti_volt_h = (instru.sti_volt & 0b01111) << 4;
|
||||
uint8 sti_chp = instru.sti_channel_pmos & 0b1111;
|
||||
uint8 sti_chn = (instru.sti_channel_nmos & 0b1111) << 4;
|
||||
uint8 chopper = (INSTRUCTION.chopper) ? 0b00001000 : 0;
|
||||
uint8 fast_settle = (INSTRUCTION.fast_settle) ? 0b00000100 : 0;
|
||||
uint8 sti_enable = (INSTRUCTION.work_mode != STI_MODE_DISABLE) ? 0b00000010 : 0;
|
||||
uint8 sti_volt_l = (INSTRUCTION.sti_volt & 0b11111) >> 4;
|
||||
uint8 sti_volt_h = (INSTRUCTION.sti_volt & 0b01111) << 4;
|
||||
uint8 sti_chp = INSTRUCTION.sti_channel_pmos & 0b1111;
|
||||
uint8 sti_chn = (INSTRUCTION.sti_channel_nmos & 0b1111) << 4;
|
||||
uint8 clk_signal = 0; // should be call update_ins_clock to modify this value
|
||||
|
||||
spi_txbuf[0] = header | amp_gain | amp_lbf;
|
||||
@@ -193,7 +193,7 @@ static bool update_ins_rec_buffer() {
|
||||
* @param: buf: pointer of the SPI buffer.
|
||||
*/
|
||||
static void update_ins_sti_buffer() {
|
||||
switch (instru.work_mode) {
|
||||
switch (INSTRUCTION.work_mode) {
|
||||
case STI_MODE_POS:
|
||||
case STI_MODE_NEG:
|
||||
// copy [4:7]
|
||||
@@ -215,7 +215,7 @@ static void update_ins_sti_buffer() {
|
||||
update_ins_sti_enable(spi_txbuf, TRUE);
|
||||
// ins buf [4:7]
|
||||
update_ins_sti_enable(spi_txbuf + 4, TRUE);
|
||||
update_ins_sti_channel(spi_txbuf + 4, 0xF, instru.sti_channel_pmos);
|
||||
update_ins_sti_channel(spi_txbuf + 4, 0xF, INSTRUCTION.sti_channel_pmos);
|
||||
// ins buf [8:B]
|
||||
update_ins_sti_enable(spi_txbuf + 8, FALSE);
|
||||
break;
|
||||
@@ -238,13 +238,13 @@ static void update_ins_sti_buffer() {
|
||||
spi_txbuf[15] = spi_txbuf[3];
|
||||
// change content
|
||||
update_ins_sti_enable(spi_txbuf + 0, TRUE);
|
||||
update_ins_sti_channel(spi_txbuf + 0, instru.sti_channel_pmos, instru.sti_channel_nmos);
|
||||
update_ins_sti_channel(spi_txbuf + 0, INSTRUCTION.sti_channel_pmos, INSTRUCTION.sti_channel_nmos);
|
||||
// ins buf [4:7]
|
||||
update_ins_sti_enable(spi_txbuf + 4, TRUE);
|
||||
update_ins_sti_channel(spi_txbuf + 4, instru.sti_channel_nmos, instru.sti_channel_pmos);
|
||||
update_ins_sti_channel(spi_txbuf + 4, INSTRUCTION.sti_channel_nmos, INSTRUCTION.sti_channel_pmos);
|
||||
// ins buf [8:B]
|
||||
update_ins_sti_enable(spi_txbuf + 8, TRUE);
|
||||
update_ins_sti_channel(spi_txbuf + 8, 0xF, instru.sti_channel_nmos);
|
||||
update_ins_sti_channel(spi_txbuf + 8, 0xF, INSTRUCTION.sti_channel_nmos);
|
||||
// ins buf [C:F]
|
||||
update_ins_sti_enable(spi_txbuf + 12, FALSE);
|
||||
break;
|
||||
@@ -281,12 +281,12 @@ static void headstage_tni_update_instruction_callback(uint8_t ins_type, uint8_t
|
||||
}
|
||||
|
||||
static uint8_t *spi_transact_rec_instruction() {
|
||||
if (IS_REC_MODE(instru.work_mode)) {
|
||||
if (IS_REC_MODE(INSTRUCTION.work_mode)) {
|
||||
PIN_setOutputValue(pin_handle, IOID_13, 1); // DBS_P2S turn on
|
||||
headstage_spi_transaction(SPI_BUFFER_SIZE, spi_txbuf, spi_rxbuf);
|
||||
PIN_setOutputValue(pin_handle, IOID_13, 0); // DBS_P2S turn off
|
||||
|
||||
} else if (IS_ARM_MODE(instru.work_mode) && !adc_clock_signal) {
|
||||
} else if (IS_ARM_MODE(INSTRUCTION.work_mode) && !adc_clock_signal) {
|
||||
create_ramp(spi_rxbuf);
|
||||
}
|
||||
|
||||
|
||||
+357
-237
@@ -22,7 +22,7 @@
|
||||
#include "EliteWorkData.h"
|
||||
#include <driverlib/aon_batmon.h>
|
||||
|
||||
static void SimpleBLEPeripheral_performPeriodicTask(void);
|
||||
static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData);
|
||||
|
||||
static void SimpleBLEPeripheral_clockHandler(UArg arg) {
|
||||
// Store the event.
|
||||
@@ -46,31 +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
|
||||
/*
|
||||
InitLED();
|
||||
InitTrigChan();
|
||||
Init_Elite15_PIN();
|
||||
ELITE15_SPI_HOLD();
|
||||
|
||||
|
||||
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;
|
||||
*/
|
||||
PIN15_setOutputValue(shutdown_6994, 1); // OFF = 1 => turn off 6994
|
||||
// PIN15_setOutputValue(OUT_5V_EN_0, 1); // disable 5V output // 1 => output disable
|
||||
// PIN15_setOutputValue(OUT_5V_EN_1, 1);
|
||||
// PIN15_setOutputValue(DO_MOS_0, 0); // all Dout off
|
||||
// PIN15_setOutputValue(DO_MOS_1, 0);
|
||||
// AoutChannelSelect(0xFF, 0); // all Aout off
|
||||
disable_trig_output(); // all output disable
|
||||
|
||||
InitEliteInstruction();
|
||||
|
||||
// init DAC, set output ~= 0 V
|
||||
// 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 */
|
||||
// VinADCGainControl(VIN_GAIN_AUTO);
|
||||
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
elite_gptimer_open();
|
||||
elite_gptimer_start();
|
||||
|
||||
TW1508reset();
|
||||
// TRIG_LED_Init();
|
||||
// PIN_registerIntCb(pin_handle, switch_on_callback);
|
||||
// PIN_setInterrupt(pin_handle, switch_on | PIN_IRQ_POSEDGE);
|
||||
}
|
||||
@@ -80,7 +76,7 @@ static void ZM_update_instruction_callback(uint8_t ins_type, uint8_t chip_ID, ui
|
||||
|
||||
static void DACCode2Real2Notify(uint16_t DACcode) {
|
||||
int32_t RealV;
|
||||
RealV = DAC_to_realV(instru.VoutGainLevel, DACcode);
|
||||
RealV = DAC_to_realV(INSTRUCTION.VoutGainLevel, DACcode);
|
||||
|
||||
NotifyVolt[0] = (uint8_t)((RealV & 0xFF000000) >> 24);
|
||||
NotifyVolt[1] = (uint8_t)((RealV & 0x00FF0000) >> 16);
|
||||
@@ -88,15 +84,24 @@ static void DACCode2Real2Notify(uint16_t DACcode) {
|
||||
NotifyVolt[3] = (uint8_t)(RealV & 0x000000FF);
|
||||
}
|
||||
|
||||
#define IsPeriodicMode() ( \
|
||||
(instru.eliteFxn == CURVE_EIS) || \
|
||||
(instru.eliteFxn == CURVE_EIS_CV) || \
|
||||
(instru.eliteFxn == CURVE_CALI_ADC) \
|
||||
#define IsPeriodicMode() ( \
|
||||
(INSTRUCTION.eliteFxn == IV_CURVE) || \
|
||||
(INSTRUCTION.eliteFxn == CV_CURVE) || \
|
||||
(INSTRUCTION.eliteFxn == IT_CURVE) || \
|
||||
(INSTRUCTION.eliteFxn == VT_CURVE) || \
|
||||
(INSTRUCTION.eliteFxn == ZT_CURVE) || \
|
||||
(INSTRUCTION.eliteFxn == CONSTANT_CURRENT) || \
|
||||
(INSTRUCTION.eliteFxn == CYCLIC_VOLTAMMETRY) || \
|
||||
(INSTRUCTION.eliteFxn == LINEAR_SWEEP_VOLTAMMETRY) || \
|
||||
(INSTRUCTION.eliteFxn == CONSTANT_VSCAN) || \
|
||||
(INSTRUCTION.eliteFxn == CALI_ADC_MODE) \
|
||||
)
|
||||
|
||||
#define Ve1MatchVe2Mode() ( \
|
||||
(instru.eliteFxn == CURVE_EIS) || \
|
||||
(instru.eliteFxn == CURVE_EIS_CV) \
|
||||
#define Ve1MatchVe2Mode() ( \
|
||||
(INSTRUCTION.eliteFxn == IV_CURVE) || \
|
||||
(INSTRUCTION.eliteFxn == CV_CURVE) || \
|
||||
(INSTRUCTION.eliteFxn == CYCLIC_VOLTAMMETRY) || \
|
||||
(INSTRUCTION.eliteFxn == LINEAR_SWEEP_VOLTAMMETRY) \
|
||||
)
|
||||
|
||||
/*********************************************************************
|
||||
@@ -108,242 +113,335 @@ static void DACCode2Real2Notify(uint16_t DACcode) {
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
static void SimpleBLEPeripheral_performPeriodicTask(void) {
|
||||
if (IsPeriodicMode()) {
|
||||
if(instru.eliteFxn == CURVE_EIS){
|
||||
static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
|
||||
if ( IsPeriodicMode() ){
|
||||
/** 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;
|
||||
GPT.DeltaGptimerCounter = GPT.GptimerCounter - GPT.GptimerCounter0;
|
||||
GPT.GptimerCounter0 = GPT.GptimerCounter;
|
||||
|
||||
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;
|
||||
|
||||
if (instru.f1 == instru.f2) {
|
||||
DAC_outputF(instru.f1);
|
||||
if(EliteWorkReset){
|
||||
InitEliteGPtimer();
|
||||
EliteWorkReset = false;
|
||||
batteryADC_flag = false;
|
||||
record_flag = true;
|
||||
firstTimeReset = true;
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
if( Ve1MatchVe2Mode() ){
|
||||
if (INSTRUCTION.Ve1 == INSTRUCTION.Ve2) {
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.Ve1));
|
||||
PeriodicEvent = false;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
|
||||
SetEISHIGHZ(1);
|
||||
}
|
||||
}
|
||||
|
||||
//vscan counter //fset counter
|
||||
if (fset_flag) {
|
||||
vscan_ctrl(); //set
|
||||
fset_flag = false;
|
||||
fout_flag = true;
|
||||
|
||||
GPT.LeadTimeCounter = GPT.LeadTimeCounter + GPT.DeltaGptimerCounter;
|
||||
if(leadTimeReset && GPT.LeadTimeCounter <= 2000){
|
||||
vscanReset = true;
|
||||
}else{
|
||||
if(notifyFirst_flag){
|
||||
GPT.NotifyCounter = INSTRUCTION.notifyRate - 20;
|
||||
notifyFirst_flag = false;
|
||||
}
|
||||
vscanReset = false;
|
||||
leadTimeReset = 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;
|
||||
}
|
||||
//vscan counter
|
||||
GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.VscanRateCounter >= INSTRUCTION.VsetRate){
|
||||
if(GPT.VscanRateCounter >= INSTRUCTION.VsetRate * 2){
|
||||
GPT.GptimerMultiple = GPT.VscanRateCounter / INSTRUCTION.VsetRate;
|
||||
}else{
|
||||
GPT.GptimerMultiple = 1;
|
||||
}
|
||||
GPT.VscanRateCounter -= INSTRUCTION.VsetRate * GPT.GptimerMultiple; //To get right time
|
||||
vscan_flag = true;
|
||||
if(vscan_flag){
|
||||
EliteVscanControl(WorkModeData);
|
||||
vscan_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
|
||||
//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 >= INSTRUCTION.sampleRate){
|
||||
GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
|
||||
ADC_flag = true;
|
||||
if(ADC_flag){
|
||||
EliteADCControl(WorkModeData);
|
||||
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 >= INSTRUCTION.notifyRate){
|
||||
GPT.NotifyCounter -= INSTRUCTION.notifyRate; //To get right time
|
||||
notify_flag = true;
|
||||
if(vscanReset){
|
||||
notify_flag = false;
|
||||
}
|
||||
if(notify_flag){
|
||||
SendNotify(); //send
|
||||
SendNotify();
|
||||
notify_flag = false;
|
||||
fset_flag = true;
|
||||
time0 = (Timestamp_get32()) / 31;
|
||||
time1 = 0;
|
||||
delta_time = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// EliteDone();
|
||||
}
|
||||
else if (INSTRUCTION.eliteFxn == PULSE_MODE){
|
||||
/** 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;
|
||||
|
||||
if(EliteWorkReset){
|
||||
InitEliteGPtimer();
|
||||
EliteWorkReset = false;
|
||||
batteryADC_flag = false;
|
||||
record_flag = true;
|
||||
firstTimeReset = true;
|
||||
//pulsemode variable
|
||||
stiFirstTime = true;
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
if (Ve1MatchVe2Mode()) {
|
||||
if (INSTRUCTION.Ve1 == INSTRUCTION.Ve2) {
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.Ve1));
|
||||
PeriodicEvent = false;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
} else if (INSTRUCTION.eliteFxn == PULSE_MODE) {
|
||||
if(!megaStiEnable){
|
||||
PeriodicEvent = false;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GPT.LeadTimeCounter = GPT.LeadTimeCounter + GPT.DeltaGptimerCounter;
|
||||
if(leadTimeReset && GPT.LeadTimeCounter <= 2000){
|
||||
vscanReset = true;
|
||||
}else{
|
||||
if(notifyFirst_flag){
|
||||
GPT.NotifyCounter = INSTRUCTION.notifyRate - 20;
|
||||
notifyFirst_flag = false;
|
||||
}
|
||||
vscanReset = false;
|
||||
leadTimeReset = false;
|
||||
}
|
||||
|
||||
//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(INSTRUCTION.VoutGainLevel, 25000));
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
|
||||
//vscanReset = false;
|
||||
}else{
|
||||
if (megaStiEnable) {
|
||||
PULSE_Vscan(WorkModeData->PULSE);
|
||||
}
|
||||
}
|
||||
|
||||
// if(GPT.VscanRateCounter >= INSTRUCTION.VsetRate){
|
||||
// if(GPT.VscanRateCounter >= INSTRUCTION.VsetRate * 2){
|
||||
// GPT.GptimerMultiple = GPT.VscanRateCounter / INSTRUCTION.VsetRate;
|
||||
// }else{
|
||||
// GPT.GptimerMultiple = 1;
|
||||
// }
|
||||
// GPT.VscanRateCounter -= INSTRUCTION.VsetRate * GPT.GptimerMultiple; //To get right time
|
||||
// vscan_flag = true;
|
||||
// if(vscan_flag){
|
||||
// EliteVscanControl(WorkModeData);
|
||||
// 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 >= INSTRUCTION.sampleRate){
|
||||
GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
|
||||
ADC_flag = true;
|
||||
if(ADC_flag){
|
||||
EliteADCControl(WorkModeData);
|
||||
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 >= INSTRUCTION.notifyRate){
|
||||
GPT.NotifyCounter -= INSTRUCTION.notifyRate; //To get right time
|
||||
notify_flag = true;
|
||||
if(vscanReset){
|
||||
notify_flag = false;
|
||||
}
|
||||
if(notify_flag){
|
||||
SendNotify();
|
||||
notify_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
// EliteDone();
|
||||
}
|
||||
else if(INSTRUCTION.eliteFxn == VOLT_OUTPUT){
|
||||
VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
WorkModeData->VO->_Vset = INSTRUCTION.VoltConstant;
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, WorkModeData->VO->_Vset)); //UserCode -> DAC code -> DAC out
|
||||
FreeWorkMode(WorkModeData);
|
||||
PeriodicEvent = false;
|
||||
}
|
||||
else if(INSTRUCTION.eliteFxn == CALI_DAC_MODE){
|
||||
DAC_outputV(INSTRUCTION.VoltConstant); //UserCode -> DAC code -> DAC out
|
||||
FreeWorkMode(WorkModeData);
|
||||
PeriodicEvent = false;
|
||||
}
|
||||
else{
|
||||
// InitFlag();
|
||||
}
|
||||
}
|
||||
|
||||
static void EliteADCControl(WorkMode *WorkModeData) {
|
||||
switch (INSTRUCTION.eliteFxn) {
|
||||
case IV_CURVE:{
|
||||
CC_Plot(WorkModeData);
|
||||
break;
|
||||
}
|
||||
case CV_CURVE:{
|
||||
CC_Plot(WorkModeData);
|
||||
break;
|
||||
}
|
||||
case IT_CURVE:{
|
||||
IT_Plot(WorkModeData);
|
||||
break;
|
||||
}
|
||||
case VT_CURVE:{
|
||||
VT_Plot(WorkModeData);
|
||||
break;
|
||||
}
|
||||
case ZT_CURVE:{
|
||||
CC_Plot(WorkModeData);
|
||||
break;
|
||||
}
|
||||
case CONSTANT_CURRENT:{
|
||||
CC_Plot(WorkModeData);
|
||||
break;
|
||||
}
|
||||
case CYCLIC_VOLTAMMETRY:{
|
||||
CC_Plot(WorkModeData);
|
||||
break;
|
||||
}
|
||||
case LINEAR_SWEEP_VOLTAMMETRY:{
|
||||
CC_Plot(WorkModeData);
|
||||
break;
|
||||
}
|
||||
case CONSTANT_VSCAN:{
|
||||
CC_Plot(WorkModeData);
|
||||
break;
|
||||
}
|
||||
case CALI_ADC_MODE:{
|
||||
if(INSTRUCTION.AdcChannel == IIN_ADC){
|
||||
cali_IT_plot(WorkModeData);
|
||||
}else if(INSTRUCTION.AdcChannel == VIN_ADC){
|
||||
cali_VT_plot(WorkModeData);
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
static bool first_highz_flag = false;
|
||||
|
||||
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;
|
||||
|
||||
/*
|
||||
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));
|
||||
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()
|
||||
|
||||
break;
|
||||
}
|
||||
case PULSE_MODE:{
|
||||
CC_Plot(WorkModeData);
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void EliteADCControl(void) //CURVE_IV => CC_Plot() | CURVE_CV => Iin_Vin_Vout_Plot
|
||||
{
|
||||
void *wm = wm_get();
|
||||
|
||||
switch (instru.eliteFxn) {
|
||||
case CURVE_EIS:
|
||||
EIS_Plot();
|
||||
break;
|
||||
|
||||
case CURVE_EIS_CV:
|
||||
CV_Plot();
|
||||
break;
|
||||
|
||||
case CURVE_CALI_ADC:
|
||||
if (instru.AdcChannel == IIN_ADC) {
|
||||
cali_IT_plot();
|
||||
} else if (instru.AdcChannel == VIN_ADC) {
|
||||
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;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void mode_done(void) //finishMode = 1, SendNotify(), Eliteinterrupt()
|
||||
{
|
||||
if (instru.eliteFxn == CURVE_EIS_CV) {
|
||||
static void EliteDone() {
|
||||
if ((INSTRUCTION.eliteFxn == IV_CURVE) || (INSTRUCTION.eliteFxn == CV_CURVE) || (INSTRUCTION.eliteFxn == CYCLIC_VOLTAMMETRY)) {
|
||||
if (!PeriodicEvent) {
|
||||
finishMode = 1;
|
||||
SendNotify();
|
||||
Eliteinterrupt();
|
||||
}
|
||||
} else if (instru.eliteFxn == CURVE_EIS){
|
||||
if (!PeriodicEvent) {
|
||||
Eliteinterrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void vscan_ctrl(void)
|
||||
{
|
||||
switch (instru.eliteFxn) {
|
||||
case CURVE_EIS:
|
||||
eis_fscan();
|
||||
static void EliteVscanControl(WorkMode *WorkModeData) {
|
||||
switch (INSTRUCTION.eliteFxn) {
|
||||
case IV_CURVE:{
|
||||
IV_Vscan(WorkModeData->IV);
|
||||
break;
|
||||
|
||||
case CURVE_EIS_CV:
|
||||
cv_vscan();
|
||||
}
|
||||
case CV_CURVE:{
|
||||
CV_Vscan(WorkModeData->CV);
|
||||
break;
|
||||
|
||||
}
|
||||
case ZT_CURVE:{
|
||||
ZT_Vscan(WorkModeData->RT);
|
||||
break;
|
||||
}
|
||||
case CYCLIC_VOLTAMMETRY:{
|
||||
CV3_Vscan(WorkModeData->CV3);
|
||||
break;
|
||||
}
|
||||
case CONSTANT_CURRENT:{
|
||||
CC_Vscan(WorkModeData->CC);
|
||||
break;
|
||||
}
|
||||
case LINEAR_SWEEP_VOLTAMMETRY:{
|
||||
LSV_Vscan(WorkModeData->LSV);
|
||||
break;
|
||||
}
|
||||
case CONSTANT_VSCAN:{
|
||||
CVSCAN_Vscan(WorkModeData->CVSCAN);
|
||||
break;
|
||||
}
|
||||
case PULSE_MODE:{
|
||||
// PULSE_Vscan(WorkModeData->PULSE);
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
break;
|
||||
}
|
||||
@@ -378,16 +476,38 @@ static void step2VsetRate(uint32_t step){
|
||||
0.01mv, index = 4, n = 10000 */
|
||||
|
||||
if(step >= 10000){
|
||||
instru.VsetRateIndex = 0;
|
||||
INSTRUCTION.VsetRateIndex = 0;
|
||||
}else if (step >= 1000){
|
||||
instru.VsetRateIndex = 1;
|
||||
INSTRUCTION.VsetRateIndex = 1;
|
||||
}else if (step >= 100){
|
||||
instru.VsetRateIndex = 2;
|
||||
INSTRUCTION.VsetRateIndex = 2;
|
||||
}else if (step >= 10){
|
||||
instru.VsetRateIndex = 3;
|
||||
INSTRUCTION.VsetRateIndex = 3;
|
||||
}else if (step >= 1){
|
||||
instru.VsetRateIndex = 4;
|
||||
INSTRUCTION.VsetRateIndex = 4;
|
||||
}
|
||||
}
|
||||
|
||||
static void InitFlag(){
|
||||
PeriodicEvent = false; // is there an PeriodicEvent?
|
||||
Free_Work_Mode = true; // Free(WorkModeData)
|
||||
}
|
||||
|
||||
static void InitEliteGPtimer() {
|
||||
GPT.SampleRateCounter = INSTRUCTION.sampleRate - 10;
|
||||
GPT.VscanRateCounter = INSTRUCTION.VsetRate - 1;
|
||||
notifyFirst_flag = true;
|
||||
}
|
||||
|
||||
static void InitEliteFlag() {
|
||||
InitPeriodicEvent = true; // need to create a WorkModeData?
|
||||
DACReset = true;
|
||||
vscanReset = true;
|
||||
EliteWorkReset = true;
|
||||
leadTimeReset = true;
|
||||
I_GAIN_100R_counter = 0;
|
||||
I_GAIN_3K_counter = 0;
|
||||
I_GAIN_100K_counter = 0;
|
||||
I_GAIN_3M_counter = 0;
|
||||
}
|
||||
#endif /* IMPEDANCE_METER_H_ */
|
||||
|
||||
+30
-16
@@ -543,22 +543,30 @@ static void SimpleBLEPeripheral_init(void) {
|
||||
// static void detectKey_clockHandler(UArg arg);
|
||||
|
||||
static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
|
||||
uint8_t key= 0;
|
||||
bool EliteOn = 0;
|
||||
uint16_t counter6994 = 0;
|
||||
batteryADC_flag = false;
|
||||
|
||||
// Initialize application
|
||||
SimpleBLEPeripheral_init();
|
||||
ZM_init();
|
||||
WorkMode *WorkModeData = CreateWorkMode();
|
||||
|
||||
// init DAC, set output ~= 0 V
|
||||
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
|
||||
VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
|
||||
|
||||
uint8_t key = 0;
|
||||
uint16_t counter6994 = 0;
|
||||
bool EliteOn = 0;
|
||||
|
||||
elite_gptimer_start();
|
||||
|
||||
// Application main loops
|
||||
GPT.GptimerCounter0 = GPT.GptimerCounter;
|
||||
|
||||
//headstage_battery_volt();
|
||||
batteryADC_flag = false;
|
||||
headstage_battery_volt();
|
||||
headstage_init_device_info();
|
||||
|
||||
for (;;) { //keeps going until Periodic Event != True
|
||||
for (;;) {
|
||||
// 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
|
||||
@@ -605,7 +613,6 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(events & SBP_PERIODIC_EVT){
|
||||
events &= ~SBP_PERIODIC_EVT;
|
||||
if (!PeriodicEvent) { // if there is no periodic event
|
||||
@@ -614,34 +621,41 @@ 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) {
|
||||
//PIN_setOutputValue(pin_handle, shutdown_6994, 0); // OFF = 1 => turn off 6994
|
||||
PIN15_setOutputValue(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();
|
||||
FreeWorkMode(WorkModeData);
|
||||
InitEliteInstruction();
|
||||
Free_Work_Mode = false;
|
||||
}
|
||||
} else {
|
||||
EliteOn = TurnOnElite(key);
|
||||
// AD5940_init();
|
||||
}
|
||||
|
||||
trig_sense();
|
||||
|
||||
if (trig_PeriodicEvent) {
|
||||
trig_PeriodicEvent = false;
|
||||
PeriodicEvent = true;
|
||||
}
|
||||
|
||||
}
|
||||
else { // if there is periodic event
|
||||
if(InitPeriodicEvent){
|
||||
wm_init();
|
||||
InitWorkMode(WorkModeData);
|
||||
InitPeriodicEvent = false;
|
||||
}
|
||||
|
||||
// Perform periodic application task
|
||||
SimpleBLEPeripheral_performPeriodicTask();
|
||||
SimpleBLEPeripheral_performPeriodicTask(WorkModeData);
|
||||
key = PIN_getInputValue(switch_on);
|
||||
EliteKeyPress(key); // onPress=> key = 0; 1.lighten LED 2.long press shut down 2650
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user