Compare commits

...

78 Commits

Author SHA1 Message Date
Benny Liu 123e620f50 Modify trigger receive function.
Turn on PULSE_MODE.
Use "struct" to express channel.
2021-05-24 16:20:25 +08:00
Benny Liu b5a7720c24 Modify LED notification. 2021-05-21 15:26:15 +08:00
Benny Liu 152937ca32 Disable all output after reset() 2021-05-07 17:39:57 +08:00
Benny Liu 3c85fbef6f Work mode LED for TRIG01. 2021-05-07 16:28:49 +08:00
Benny Liu 4ff8f044c4 Check TW1508 function ok. 2021-05-03 18:01:13 +08:00
Benny Liu 22a2095cd7 Add update TRIG01 pin output value. 2021-05-03 14:57:29 +08:00
Benny Liu 9c10e4ba53 Add set channel select LED notification. 2021-04-26 17:24:44 +08:00
Benny Liu 0529f84511 Charging notification LED 2021-04-23 17:09:57 +08:00
Benny Liu da63ff03d3 Add refresh TRIG01 LED function. 2021-04-23 13:25:27 +08:00
Benny Liu 141dcb70a3 full scale range for TW1508: 0x0000 ~ 0x03FF 2021-03-22 16:24:34 +08:00
Benny Liu 8625222e36 Switch to LOAD0 before remove_elite_pin(). 2021-03-22 14:41:07 +08:00
Benny Liu 498652836c Switch to LOAD0 before remove_elite_pin(). No pin overwrite issue. 2021-03-19 17:56:47 +08:00
Benny Liu dbfd4364e3 Latch LOADA & LOADB no no. 2021-03-15 18:22:08 +08:00
Benny Liu bd049e4fec Use headstage.h ADC_TEST to test TRIG01, TW1508 control still not working.
TW1508reset() --> turnoff itself
2021-03-12 18:17:22 +08:00
Benny Liu f20b6634ae Merge remote-tracking branch 'origin/Elite_TRIG01_development' into Elite_TRIG01_development 2021-02-26 17:43:11 +08:00
Benny Liu b59472ad2d Add TRIG01 LED functions. 2021-02-26 17:29:59 +08:00
Benny Liu a75b3ba58f Add TRIG02 LED functions. 2021-02-26 17:19:20 +08:00
Benny Liu 8c3d8f46df Update TRIG01 ADC command 2021-02-22 15:29:52 +08:00
Benny Liu ca29a325f1 Use GPIO control TW1508, yes yes. 2021-02-20 18:50:00 +08:00
Benny Liu 61aee1a3e6 Use GPIO to control TW1508. 2021-02-18 14:33:25 +08:00
Benny Liu 162b528385 Add file TRIG.h 2021-02-17 14:40:17 +08:00
Benny Liu b6e30d25f5 Modify trigger callback function. 2021-02-17 12:08:30 +08:00
Benny Liu db8d7bf0af 5V output pin FLT callback function 2021-02-08 17:58:53 +08:00
Benny Liu 48d770b271 trigger callback 2021-02-08 17:49:47 +08:00
Benny Liu 88d1fc0a5e Add trigger sensing pin. 2021-02-08 17:03:11 +08:00
Benny Liu 9769d38897 Update Elite TRIG01 pin. Add trigger sensing pin. 2021-02-08 16:43:37 +08:00
Benny Liu 8be3c30b23 Update Elite TRIG01 pin 2021-02-08 14:17:22 +08:00
Roy 916a8f5dc7 [update] fix Cycle I-V cycle 2021-01-05 11:08:06 +08:00
Roy 25cc8b16fa [update] fix CV3 cycle 2021-01-05 10:31:08 +08:00
Roy 67bf8b67dd [cali] add BOARD_C797 & BOARD_C639 calibration data. 2020-12-31 09:40:38 +08:00
Roy 13dfdbd502 [update] fix problem for change level 2020-12-30 16:36:16 +08:00
Roy e0ae30d40d [update] add dark led fun() 2020-12-29 11:45:09 +08:00
Roy 2c3a0a7ee8 [cali] add BOARD_C615 & BOARD_C78B calibration data. 2020-12-29 10:43:51 +08:00
Benny Liu f1086df363 turn on 6994 shutdown 2020-12-17 12:40:07 +08:00
Roy 6345ee875a [cali] add BOARD_C60C calibration data. 2020-12-16 09:59:21 +08:00
Roy 69061f9afd [cali] add BOARD_C903 calibration data. 2020-12-15 10:00:58 +08:00
Roy 3aecb50b47 [cali] add BOARD_C69F calibration data. 2020-12-14 18:37:01 +08:00
Roy e030578fd8 [update] update headstage version on elite1.5 (0,2,1,6) 2020-12-10 17:16:37 +08:00
Roy c05fefe71c Merge branch 'Elite1.5_developement_testmode1210' into Elite1.5_developement 2020-12-10 17:04:31 +08:00
Roy 177b56e8f9 [update] update pulsemode on elite1.5 2020-12-10 17:03:08 +08:00
Benny Liu aeb7a8afaf cali_count_max = 5000 for smallest Vin and Iin gain 2020-12-10 15:53:35 +08:00
Roy 0edaa77857 [update] match 1.5 ui (cali code) 2020-12-04 11:28:33 +08:00
Roy c656eebcbc [update] align notify (match megafly ui) 2020-11-26 22:48:53 +08:00
Roy e17e78bc18 [update] add Vout boundary (usc) 2020-11-26 16:14:31 +08:00
Benny Liu c3235e985f Change 1.5 Iin measurement range. 2020-11-26 15:48:01 +08:00
Roy 656e0fb485 [cali] update BOARD_C7A1 calibration data. 2020-11-23 12:12:09 +08:00
Roy d3dd5270dd [update] tag controller version 2020-11-23 10:18:46 +08:00
Roy e588b30c8b [update] monitor bat 2020-11-20 14:45:21 +08:00
Roy d3f9aec31c add BOARD_C604 calibration data. 2020-11-20 11:50:17 +08:00
Roy ed617c88c9 [update] remove megafly pin 2020-11-20 11:14:01 +08:00
Roy 0b8f4c2414 Merge branch 'Elite1.5_developement_magafly_1119_1' into Elite1.5_developement 2020-11-20 11:08:51 +08:00
Roy b5449b7404 [update]update pulsefly INSTRUCTION.notifyRate 2020-11-20 11:06:12 +08:00
Roy a3c1241f38 Merge branch 'Elite1.5_calibration' into Elite1.5_developement 2020-11-20 11:01:45 +08:00
Roy bbf60ebfed test periodicEvent 2020-11-19 16:00:51 +08:00
Roy 0e9f40bdd5 Megafly trigger yes yes. 2020-11-19 15:47:07 +08:00
Roy e32897f6b5 [update] Megafly notify check. & Megafly trigger. 2020-11-19 15:40:12 +08:00
Roy 6ee4b47d90 [update]update pulsefly INSTRUCTION.notifyRate 2020-11-18 11:57:53 +08:00
YiChin dac19f62b2 test ok,but T2~T3=0 can't handle 2020-11-16 14:43:50 +08:00
YiChin 8e6d112729 test ok,but T2~T3=0 can't handle 2020-11-16 14:30:27 +08:00
YiChin 9e1dc1e3f4 test ok,but T1~T5=0 can't handle 2020-11-13 18:28:48 +08:00
YiChin 49fb3afc01 test ok,but T1~T5=0 can't handle 2020-11-13 13:30:47 +08:00
YiChin f3b402fce9 test ok 2020-11-12 18:01:32 +08:00
YiChin ef9a38d7fc test not ok(RT not ok) 2020-11-12 17:24:04 +08:00
YiChin 67275a7921 test not ok(RT not ok) 2020-11-12 16:17:15 +08:00
YiChin 0ddaa02414 test not ok 2020-11-12 15:39:44 +08:00
YiChin 96d5735164 test not ok 2020-11-12 14:55:28 +08:00
YiChin ac32fb9c73 test not ok 2020-11-12 12:23:14 +08:00
Benny Liu 9acc242ff6 Add Megafly pin. 2020-11-12 10:22:31 +08:00
YiChin d8a403c410 add BOARD_C771 calibration data. 2020-11-12 10:18:12 +08:00
YiChin f1d0acef23 update pulse mode 2020-11-12 10:16:40 +08:00
YiChin 9811572f47 add pulse mode 2020-11-11 16:44:49 +08:00
YiChin 8753e2ddc6 dont send battery information 2020-10-22 10:38:09 +08:00
YiChin f6167c25ca update SPI hold & take away AutoGainChangeVout() 2020-10-20 18:41:00 +08:00
YiChin cb3894712e take away AutoGainChangeVout() 2020-10-20 18:23:13 +08:00
YiChin 995a47e200 update SPI hold 2020-10-20 17:11:36 +08:00
YiChin cde9096018 update SPI hold 2020-10-20 12:18:29 +08:00
YiChin 6c1bd24b92 update SPI hold 2020-10-19 18:40:35 +08:00
YiChin 0c129bc99b take away bat() 2020-09-25 09:43:39 +08:00
34 changed files with 2142 additions and 555 deletions
@@ -34,17 +34,17 @@
<listOptionValue builtIn="false" value="LINK_ORDER=TOOLS/ccs_linker_defines.cmd;TOOLS/cc26xx_app.cmd;"/>
<listOptionValue builtIn="false" value="RTSC_MBS_VERSION=2.2.0"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.277675815" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="18.1.4.LTS" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.277675815" name="Compiler version" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="18.1.4.LTS" valueType="string"/>
<targetPlatform id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.targetPlatformDebug.1593934674" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.targetPlatformDebug"/>
<builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.builderDebug.632414212" name="GNU Make.FlashROM" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.builderDebug"/>
<builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.builderDebug.632414212" keepEnvironmentInBuildfile="false" name="GNU Make" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.builderDebug"/>
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.compilerDebug.154623462" name="ARM Compiler" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.compilerDebug">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.SILICON_VERSION.974280107" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.SILICON_VERSION" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.SILICON_VERSION.7M3" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CODE_STATE.1783826131" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CODE_STATE" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CODE_STATE.16" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.ABI.1536570599" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.ABI" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.ABI.eabi" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.LITTLE_ENDIAN.1895413316" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.LITTLE_ENDIAN" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_LEVEL.322983319" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_LEVEL" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_LEVEL.4" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_FOR_SPEED.1305400753" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_FOR_SPEED" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_FOR_SPEED.0" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.INCLUDE_PATH.1468985930" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.INCLUDE_PATH" valueType="includePath">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.SILICON_VERSION.974280107" name="Target processor version (--silicon_version, -mv)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.SILICON_VERSION" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.SILICON_VERSION.7M3" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CODE_STATE.1783826131" name="Designate code state, 16-bit (thumb) or 32-bit (--code_state)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CODE_STATE" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CODE_STATE.16" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.ABI.1536570599" name="Application binary interface. (--abi)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.ABI" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.ABI.eabi" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.LITTLE_ENDIAN.1895413316" name="Little endian code [See 'General' page to edit] (--little_endian, -me)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.LITTLE_ENDIAN" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_LEVEL.322983319" name="Optimization level (--opt_level, -O)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_LEVEL" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_LEVEL.4" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_FOR_SPEED.1305400753" name="Speed vs. size trade-offs (--opt_for_speed, -mf)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_FOR_SPEED" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_FOR_SPEED.0" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.INCLUDE_PATH.1468985930" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.INCLUDE_PATH" valueType="includePath">
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/include"/>
<listOptionValue builtIn="false" value="C:\ti\simplelink\ble_sdk_2_02_02_25\src\examples\simple_peripheral\cc26xx\app\headstage"/>
<listOptionValue builtIn="false" value="${SRC_EX}/examples/simple_peripheral/cc26xx/app"/>
@@ -70,7 +70,7 @@
<listOptionValue builtIn="false" value="${SRC_BLE_CORE}/rom"/>
<listOptionValue builtIn="false" value="${CC26XXWARE}"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEFINE.1897088" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEFINE" valueType="definedSymbols">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEFINE.1897088" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEFINE" valueType="definedSymbols">
<listOptionValue builtIn="false" value="BOARD_DISPLAY_EXCLUDE_UART"/>
<listOptionValue builtIn="false" value="POWER_SAVING"/>
<listOptionValue builtIn="false" value="BOOSTXL_CC2650MA"/>
@@ -86,19 +86,19 @@
<listOptionValue builtIn="false" value="xdc_runtime_Assert_DISABLE_ALL"/>
<listOptionValue builtIn="false" value="xdc_runtime_Log_DISABLE_ALL"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEBUGGING_MODEL.871011287" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEBUGGING_MODEL" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEBUGGING_MODEL.SYMDEBUG__DWARF" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.C_DIALECT.863089168" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.C_DIALECT" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.C_DIALECT.C99" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GCC.1454248503" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GCC" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_SUPPRESS.1965115059" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_SUPPRESS" valueType="stringList">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEBUGGING_MODEL.871011287" name="Debugging model" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEBUGGING_MODEL" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEBUGGING_MODEL.SYMDEBUG__DWARF" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.C_DIALECT.863089168" name="C Dialect" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.C_DIALECT" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.C_DIALECT.C99" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GCC.1454248503" name="Enable support for GCC extensions (DEPRECATED) (--gcc)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GCC" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_SUPPRESS.1965115059" name="Suppress diagnostic &lt;id&gt; (--diag_suppress, -pds)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_SUPPRESS" valueType="stringList">
<listOptionValue builtIn="false" value="48"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WARNING.1638011093" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WARNING" valueType="stringList">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WARNING.1638011093" name="Treat diagnostic &lt;id&gt; as warning (--diag_warning, -pdsw)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WARNING" valueType="stringList">
<listOptionValue builtIn="false" value="225"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WRAP.1920170652" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WRAP.off" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DISPLAY_ERROR_NUMBER.2038786257" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GEN_FUNC_SUBSECTIONS.811478344" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GEN_FUNC_SUBSECTIONS" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GEN_FUNC_SUBSECTIONS.on" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CMD_FILE.1229809338" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CMD_FILE" valueType="stringList">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WRAP.1920170652" name="Wrap diagnostic messages (--diag_wrap)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WRAP.off" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DISPLAY_ERROR_NUMBER.2038786257" name="Emit diagnostic identifier numbers (--display_error_number, -pden)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GEN_FUNC_SUBSECTIONS.811478344" name="Place each function in a separate subsection (--gen_func_subsections, -ms)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GEN_FUNC_SUBSECTIONS" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GEN_FUNC_SUBSECTIONS.on" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CMD_FILE.1229809338" name="Read options from specified file (--cmd_file, -@)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CMD_FILE" valueType="stringList">
<listOptionValue builtIn="false" value="${SRC_EX}/config/build_components.opt"/>
<listOptionValue builtIn="false" value="${ORG_PROJ_DIR}/build_config.opt"/>
<listOptionValue builtIn="false" value="${ORG_PROJ_DIR}/../../ccs/config/ccs_compiler_defines.bcfg"/>
@@ -109,48 +109,48 @@
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__ASM2_SRCS.463094612" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__ASM2_SRCS"/>
</tool>
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.linkerDebug.1351821865" name="ARM Linker" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.linkerDebug">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.STACK_SIZE.174129193" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.STACK_SIZE" value="256" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.HEAP_SIZE.567300083" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.HEAP_SIZE" value="0" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.MAP_FILE.1800982811" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.MAP_FILE" value="&quot;${ProjName}.map&quot;" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.OUTPUT_FILE.1091211742" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.OUTPUT_FILE" value="${ProjName}.out" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.LIBRARY.1479599481" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.LIBRARY" valueType="libs">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.STACK_SIZE.174129193" name="Set C system stack size (--stack_size, -stack)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.STACK_SIZE" value="256" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.HEAP_SIZE.567300083" name="Heap size for C/C++ dynamic memory allocation (--heap_size, -heap)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.HEAP_SIZE" value="0" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.MAP_FILE.1800982811" name="Link information (map) listed into &lt;file&gt; (--map_file, -m)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.MAP_FILE" value="&quot;${ProjName}.map&quot;" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.OUTPUT_FILE.1091211742" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.OUTPUT_FILE" value="${ProjName}.out" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.LIBRARY.1479599481" name="Include library file or command file as input (--library, -l)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.LIBRARY" valueType="libs">
<listOptionValue builtIn="false" value="libc.a"/>
<listOptionValue builtIn="false" value="${CC26XXWARE}/driverlib/bin/ccs/driverlib.lib"/>
<listOptionValue builtIn="false" value="${ROM}/common_rom_releases/03282014/common_rom.symbols"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.SEARCH_PATH.672837228" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.SEARCH_PATH" valueType="libPaths">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.SEARCH_PATH.672837228" name="Add &lt;dir&gt; to library search path (--search_path, -i)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.SEARCH_PATH" valueType="libPaths">
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/lib"/>
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/include"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_SUPPRESS.544523272" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_SUPPRESS" valueType="stringList">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_SUPPRESS.544523272" name="Suppress diagnostic &lt;id&gt; (--diag_suppress)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_SUPPRESS" valueType="stringList">
<listOptionValue builtIn="false" value="10247-D"/>
<listOptionValue builtIn="false" value="16002-D"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_WRAP.1281207998" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_WRAP.off" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DISPLAY_ERROR_NUMBER.468817864" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.XML_LINK_INFO.1679096029" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.XML_LINK_INFO" value="&quot;${ProjName}_linkInfo.xml&quot;" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.COMPRESS_DWARF.254835397" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.COMPRESS_DWARF" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.COMPRESS_DWARF.on" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.UNUSED_SECTION_ELIMINATION.1848192295" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.UNUSED_SECTION_ELIMINATION" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.UNUSED_SECTION_ELIMINATION.on" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_WRAP.1281207998" name="Wrap diagnostic messages (--diag_wrap)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_WRAP.off" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DISPLAY_ERROR_NUMBER.468817864" name="Emit diagnostic identifier numbers (--display_error_number)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.XML_LINK_INFO.1679096029" name="Detailed link information data-base into &lt;file&gt; (--xml_link_info, -xml_link_info)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.XML_LINK_INFO" value="&quot;${ProjName}_linkInfo.xml&quot;" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.COMPRESS_DWARF.254835397" name="Aggressively reduce size of the DWARF information (--compress_dwarf)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.COMPRESS_DWARF" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.COMPRESS_DWARF.on" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.UNUSED_SECTION_ELIMINATION.1848192295" name="Eliminate sections not needed in the executable (--unused_section_elimination)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.UNUSED_SECTION_ELIMINATION" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.UNUSED_SECTION_ELIMINATION.on" valueType="enumerated"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__CMD_SRCS.1999849945" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__CMD_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__CMD2_SRCS.25027104" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__CMD2_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__GEN_CMDS.888093741" name="Generated Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__GEN_CMDS"/>
</tool>
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.19288898" name="ARM Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.ROMWIDTH.11734737" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.ROMWIDTH" value="8" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.MEMWIDTH.466140455" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.MEMWIDTH" value="8" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.OUTPUT_FORMAT.824070691" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.OUTPUT_FORMAT" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.OUTPUT_FORMAT.INTEL" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.ROMWIDTH.11734737" name="Specify rom width (--romwidth, -romwidth=width)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.ROMWIDTH" value="8" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.MEMWIDTH.466140455" name="Specify memory width (--memwidth, -memwidth=width)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.MEMWIDTH" value="8" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.OUTPUT_FORMAT.824070691" name="Output format" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.OUTPUT_FORMAT" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.OUTPUT_FORMAT.INTEL" valueType="enumerated"/>
</tool>
<tool id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.1392704063" name="XDCtools" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool">
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.XDC_PATH.225737408" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.XDC_PATH" valueType="stringList">
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.XDC_PATH.225737408" name="Package repositories (--xdcpath)" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.XDC_PATH" valueType="stringList">
<listOptionValue builtIn="false" value="${COM_TI_RTSC_TIRTOSCC13XX_CC26XX_REPOS}"/>
<listOptionValue builtIn="false" value="${TARGET_CONTENT_BASE}"/>
</option>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.TARGET.571281110" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.TARGET" value="ti.targets.arm.elf.M3" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.PLATFORM.205178830" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.PLATFORM" value="ti.platforms.simplelink:CC2640F128" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.PLATFORM_RAW.1097777495" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.PLATFORM_RAW" value="ti.platforms.simplelink:CC2640F128" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.BUILD_PROFILE.744121344" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.BUILD_PROFILE" value="release" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.CODEGEN_TOOL_DIR.165807018" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.CODEGEN_TOOL_DIR" value="${CG_TOOL_ROOT}" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.COMPILE_OPTIONS.391961861" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.COMPILE_OPTIONS" value="&quot;${COMPILER_FLAGS}&quot;" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.TARGET.571281110" name="Target (-t)" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.TARGET" value="ti.targets.arm.elf.M3" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.PLATFORM.205178830" name="Platform (-p)" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.PLATFORM" value="ti.platforms.simplelink:CC2640F128" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.PLATFORM_RAW.1097777495" name="Platform (-p)" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.PLATFORM_RAW" value="ti.platforms.simplelink:CC2640F128" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.BUILD_PROFILE.744121344" name="Build-profile (-r)" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.BUILD_PROFILE" value="release" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.CODEGEN_TOOL_DIR.165807018" name="Compiler tools directory (-c)" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.CODEGEN_TOOL_DIR" value="${CG_TOOL_ROOT}" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.COMPILE_OPTIONS.391961861" name="Additional compiler options (--compileOptions)" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.COMPILE_OPTIONS" value="&quot;${COMPILER_FLAGS}&quot;" valueType="string"/>
</tool>
</toolChain>
</folderInfo>
@@ -16,7 +16,7 @@
# sources were generated) is:
# C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\config\src
#
GEN_SRC_DIR ?= ../../../../../ti/simplelink/ble_sdk_2_02_02_25/examples/cc2650em/simple_peripheral/ccs/config/src
GEN_SRC_DIR ?= ../../config/src
ifeq (,$(wildcard $(GEN_SRC_DIR)))
$(error "ERROR: GEN_SRC_DIR must be set to the directory containing the generated sources")
@@ -1,12 +1,12 @@
XOPTS = -I"C:/ti/xdctools_3_32_00_06_core/packages/" -Dxdc_target_types__=C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/targets/arm/elf/std.h -Dxdc_target_name__=M3
XOPTS = -I"C:/ti/xdctools_3_32_02_25_core/packages/" -Dxdc_target_types__=C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/targets/arm/elf/std.h -Dxdc_target_name__=M3
vpath % C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/sysbios/
vpath %.c C:/ti/xdctools_3_32_00_06_core/packages/
vpath %.c C:/ti/xdctools_3_32_02_25_core/packages/
CCOPTS = --endian=little -mv7M3 --abi=eabi -q -ms --opt_for_speed=0 --program_level_compile -o3 -g --optimize_with_debug -Dti_sysbios_knl_Task_minimizeLatency__D=FALSE -Dti_sysbios_family_arm_cc26xx_Boot_driverlibVersion=2 -Dti_sysbios_knl_Clock_stopCheckNext__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_enableException__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_disablePriority__D=32U -Dti_sysbios_family_arm_m3_Hwi_numSparseInterrupts__D=0U
XDC_ROOT = C:/ti/xdctools_3_32_00_06_core/packages/
XDC_ROOT = C:/ti/xdctools_3_32_02_25_core/packages/
BIOS_ROOT = C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/sysbios/
@@ -16,14 +16,14 @@ BIOS_INC = -I"C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/pa
TARGET_INC = -I"C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/"
INCS = $(BIOS_INC) $(TARGET_INC) --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/include" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/icall/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/dev_info" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/common/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/heapmgr" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/controller/cc26xx/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/target" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/osal/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/sdata" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/saddr" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/icall/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/rom" --include_path="C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/cc26xxware_2_24_03_17272" -IC:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/
INCS = $(BIOS_INC) $(TARGET_INC) --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/icall/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/dev_info" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/common/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/heapmgr" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/controller/cc26xx/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/target" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/osal/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/sdata" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/saddr" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/icall/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/rom" --include_path="C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/cc26xxware_2_24_03_17272" -IC:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/
CC = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/include
ASM = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/include
AR = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/bin/armar rq
CC = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include
ASM = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include
AR = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armar rq
DEL = C:/ti/xdctools_3_32_00_06_core/packages/../bin/rm -f
CP = C:/ti/xdctools_3_32_00_06_core/packages/../bin/cp -f
DEL = C:/ti/xdctools_3_32_02_25_core/packages/../bin/rm -f
CP = C:/ti/xdctools_3_32_02_25_core/packages/../bin/cp -f
define RM
$(if $(wildcard $1),$(DEL) $1,:)
@@ -133,23 +133,21 @@ static void update_latch_status (uint32_t latch_num, uint32_t elite_pin, bool hi
}
static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool highlow) {
if(PeriodicEvent){
ELITE15_SPI_CLOSE();
}
ELITE15_SPI_CLOSE();
add_elite_pin();
update_latch_status (latch_num, pin_num, highlow);
PIN_setOutputValue(&ZM_rst, latch_num, 1); // Turn on latch
CPUdelay(10);
// 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]);
// 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: {
@@ -178,23 +176,18 @@ static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool hig
break;
}
}
CPUdelay(10);
PIN_setOutputValue(&ZM_rst, latch_num, 0); // Turn off latch
latch_setOutputValue(latch_num, 1); // Turn on latch
// CPUdelay(10);
// latch_setOutputValue(latch_num, 0); // Turn off latch
latch_setOutputValue(LOAD0, 1); // set latch at LOAD0 for SPI transfer
remove_elite_pin();
if(PeriodicEvent){
ELITE15_SPI_HOLD();
}
ELITE15_SPI_HOLD();
}
static void Init_Elite15_PIN () {
InitLH();
add_elite_pin();
PIN_setOutputValue(pin_handle, LOAD0, 1);
PIN_setOutputValue(pin_handle, LOAD1, 1);
PIN_setOutputValue(pin_handle, LOAD2, 1);
CPUdelay(10);
PIN_setOutputValue(pin_handle, D0, 0);
PIN_setOutputValue(pin_handle, D1, 0);
PIN_setOutputValue(pin_handle, D2, 0);
@@ -203,15 +196,88 @@ static void Init_Elite15_PIN () {
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);
PIN_setOutputValue(pin_handle, LOAD0, 0);
PIN_setOutputValue(pin_handle, LOAD1, 0);
PIN_setOutputValue(pin_handle, LOAD2, 0);
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
@@ -13,12 +13,24 @@
#define CMD_DAC_MEASURE 0xE5
#define CMD_BATTERY_MEASURE 0xF1
// Elite TRIG01 ADC command
#define CMD_DOUT_5V_IMON_0 0xC5
#define CMD_DOUT_5V_IMON_1 0xD5
//#define CMD_DAC_MEASURE 0xE5 // ADC AIN2 left floating
#define CMD_BATTERY_MEASURE 0xF1
// controller command, these are command from control box
#define ADC_CH_CURRENT 0x00
#define ADC_CH_VOLT 0x01
#define ADC_CH_DAC 0x02
#define ADC_CH_BAT 0x03
#define Aout_CH_0 0x00
#define Aout_CH_1 0x01
#define Aout_CH_2 0x02
#define Aout_CH_3 0x03
static void ADC_write(uint8_t ADCin) {
/*
* This function can only define [15]~[8] through ADCin
@@ -46,11 +58,7 @@ static void ADC_write(uint8_t ADCin) {
spi_ADC_txbuf[0] = ADCin;
spi_ADC_txbuf[1] = 0b11101011;
if(PeriodicEvent){
ADC_SPI_TEST(2, spi_ADC_txbuf, spi_ADC_rxbuf);
}else{
ADC_SPI(2, spi_ADC_txbuf, spi_ADC_rxbuf);
}
ADC_SPI(2, spi_ADC_txbuf, spi_ADC_rxbuf);
}
static void ADC_read(uint8_t *ADCdata){
@@ -59,11 +67,7 @@ static void ADC_read(uint8_t *ADCdata){
spi_ADC_rxbuf[i] = 0;
}
if(PeriodicEvent){
ADC_SPI_TEST(2, spi_ADC_txbuf, spi_ADC_rxbuf);
}else{
ADC_SPI(2, spi_ADC_txbuf, spi_ADC_rxbuf);
}
ADC_SPI(2, spi_ADC_txbuf, spi_ADC_rxbuf);
}
/* Elite1.5 Calibration Usage */
@@ -90,82 +94,82 @@ static void CAL_ADC_write(uint8_t ADCin) {
/* Gain Control for Vin & Iin */
static void IinADCGainControl(uint8_t IinADCLevel){
if(IinADCLevel == 0){
// ADC gain level = 0, using 3M resister
PIN15_setOutputValue(Turnon_I_LARGE, 0);
PIN15_setOutputValue(Turnon_I_MID, 0);
PIN15_setOutputValue(Turnon_I_SMALL, 0);
}
else if(IinADCLevel == 1){
// ADC gain level = 1, using 100K resister
PIN15_setOutputValue(Turnon_I_LARGE, 0);
PIN15_setOutputValue(Turnon_I_MID, 0);
PIN15_setOutputValue(Turnon_I_SMALL, 1);
}
else if(IinADCLevel == 2){
// ADC gain level = 2, using 3K resister
PIN15_setOutputValue(Turnon_I_LARGE, 0);
PIN15_setOutputValue(Turnon_I_MID, 1);
PIN15_setOutputValue(Turnon_I_SMALL, 0);
}
else if(IinADCLevel == 3){
// ADC gain level = 3, using 100R resistor
PIN15_setOutputValue(Turnon_I_LARGE, 1);
PIN15_setOutputValue(Turnon_I_MID, 0);
PIN15_setOutputValue(Turnon_I_SMALL, 0);
}
else if(IinADCLevel == 4){
// ADC gain level = 3, auto gain (using 100R resister)
PIN15_setOutputValue(Turnon_I_LARGE, 1);
PIN15_setOutputValue(Turnon_I_MID, 0);
PIN15_setOutputValue(Turnon_I_SMALL, 0);
}
else{
// default using 100R resister
PIN15_setOutputValue(Turnon_I_LARGE, 1);
PIN15_setOutputValue(Turnon_I_MID, 0);
PIN15_setOutputValue(Turnon_I_SMALL, 0);
}
if(IinADCLevel == 0 || IinADCLevel == 1 || IinADCLevel == 2 || IinADCLevel == 3){
lastIinADCGainLevel = IinADCLevel;
}else{
lastIinADCGainLevel = 3;
}
// if(IinADCLevel == 0){
// // ADC gain level = 0, using 3M resister
// PIN15_setOutputValue(Turnon_I_LARGE, 0);
// PIN15_setOutputValue(Turnon_I_MID, 0);
// PIN15_setOutputValue(Turnon_I_SMALL, 0);
// }
// else if(IinADCLevel == 1){
// // ADC gain level = 1, using 100K resister
// PIN15_setOutputValue(Turnon_I_LARGE, 0);
// PIN15_setOutputValue(Turnon_I_MID, 0);
// PIN15_setOutputValue(Turnon_I_SMALL, 1);
// }
// else if(IinADCLevel == 2){
// // ADC gain level = 2, using 3K resister
// PIN15_setOutputValue(Turnon_I_LARGE, 0);
// PIN15_setOutputValue(Turnon_I_MID, 1);
// PIN15_setOutputValue(Turnon_I_SMALL, 0);
// }
// else if(IinADCLevel == 3){
// // ADC gain level = 3, using 100R resistor
// PIN15_setOutputValue(Turnon_I_LARGE, 1);
// PIN15_setOutputValue(Turnon_I_MID, 0);
// PIN15_setOutputValue(Turnon_I_SMALL, 0);
// }
// else if(IinADCLevel == 4){
// // ADC gain level = 3, auto gain (using 100R resister)
// PIN15_setOutputValue(Turnon_I_LARGE, 1);
// PIN15_setOutputValue(Turnon_I_MID, 0);
// PIN15_setOutputValue(Turnon_I_SMALL, 0);
// }
// else{
// // default using 100R resister
// PIN15_setOutputValue(Turnon_I_LARGE, 1);
// PIN15_setOutputValue(Turnon_I_MID, 0);
// PIN15_setOutputValue(Turnon_I_SMALL, 0);
// }
//
// if(IinADCLevel == 0 || IinADCLevel == 1 || IinADCLevel == 2 || IinADCLevel == 3){
// lastIinADCGainLevel = IinADCLevel;
// }else{
// lastIinADCGainLevel = 3;
// }
}
static void VinADCGainControl(uint8_t VinADCLevel){
if(VinADCLevel == 0){
// Vin ADC gain level = 0, using 1M resister
PIN15_setOutputValue(Turnon_V_SMALL, 0);
PIN15_setOutputValue(Turnon_V_MID, 0);
}
else if(VinADCLevel == 1){
// Vin ADC gain level = 1, using 30K resister
PIN15_setOutputValue(Turnon_V_SMALL, 0);
PIN15_setOutputValue(Turnon_V_MID, 1);
}
else if(VinADCLevel == 2){
// Vin ADC gain level = 2, using 1K resister
PIN15_setOutputValue(Turnon_V_SMALL, 1);
PIN15_setOutputValue(Turnon_V_MID, 0);
}
else if(VinADCLevel == 3){
// Vin ADC gain level = 3, auto gain (using 1K resister)
PIN15_setOutputValue(Turnon_V_SMALL, 1);
PIN15_setOutputValue(Turnon_V_MID, 0);
}
else{
// default using 1K resister
PIN15_setOutputValue(Turnon_V_SMALL, 1);
PIN15_setOutputValue(Turnon_V_MID, 0);
}
if(VinADCLevel == 0 || VinADCLevel == 1 || VinADCLevel == 2){
lastVinADCGainLevel = VinADCLevel;
}else{
lastVinADCGainLevel = 2;
}
// if(VinADCLevel == 0){
// // Vin ADC gain level = 0, using 1M resister
// PIN15_setOutputValue(Turnon_V_SMALL, 0);
// PIN15_setOutputValue(Turnon_V_MID, 0);
// }
// else if(VinADCLevel == 1){
// // Vin ADC gain level = 1, using 30K resister
// PIN15_setOutputValue(Turnon_V_SMALL, 0);
// PIN15_setOutputValue(Turnon_V_MID, 1);
// }
// else if(VinADCLevel == 2){
// // Vin ADC gain level = 2, using 1K resister
// PIN15_setOutputValue(Turnon_V_SMALL, 1);
// PIN15_setOutputValue(Turnon_V_MID, 0);
// }
// else if(VinADCLevel == 3){
// // Vin ADC gain level = 3, auto gain (using 1K resister)
// PIN15_setOutputValue(Turnon_V_SMALL, 1);
// PIN15_setOutputValue(Turnon_V_MID, 0);
// }
// else{
// // default using 1K resister
// PIN15_setOutputValue(Turnon_V_SMALL, 1);
// PIN15_setOutputValue(Turnon_V_MID, 0);
// }
//
// if(VinADCLevel == 0 || VinADCLevel == 1 || VinADCLevel == 2){
// lastVinADCGainLevel = VinADCLevel;
// }else{
// lastVinADCGainLevel = 2;
// }
}
static void ADCChannelSelect(uint8_t ADCChannel){
@@ -246,12 +250,20 @@ static void ReadADCBat(uint8_t *buf){
/* for Elite1.5-re */
// Iin theoretical boundary <2.67, 1.89~80, 63~2600, >1900 (uA)
/* Old boundary
#define I_GAIN_SMALL_BOUNDARY 4000 // 4 uA = 4,000,000 pA
#define I_GAIN_MID1_BOUNDARY1 2000 // 2 uA = 2,000,000 pA
#define I_GAIN_MID1_BOUNDARY2 90000 // 90 uA = 90,000,000 pA
#define I_GAIN_MID2_BOUNDARY1 70000 // 70 uA = 70,000,000 pA
#define I_GAIN_MID2_BOUNDARY2 1800000 // 1800 uA = 1,800,000 nA
#define I_GAIN_LARGE_BOUNDARY 950000 // 950 uA = 950,000 nA
*/
#define I_GAIN_SMALL_BOUNDARY 4000 // 4 uA = 4,000,000 pA
#define I_GAIN_MID1_BOUNDARY1 2500 // 2.5 uA = 2,500,000 pA
#define I_GAIN_MID1_BOUNDARY2 100000 // 100 uA = 100,000,000 pA
#define I_GAIN_MID2_BOUNDARY1 85000 // 85 uA = 85,000,000 pA
#define I_GAIN_MID2_BOUNDARY2 2050000 // 2050 uA = 2,050,000 nA
#define I_GAIN_LARGE_BOUNDARY 1800000 // 1800 uA = 1,800,000 nA
// Vin theoretical boundary <7, 5~200, >100 (mV)
#define VIN_GAIN_SMALL_BOUNDARY 7000 // 7 mV = 7,000,000 nV
@@ -603,4 +615,97 @@ static uint16_t ADC_CURRENT_AVG_calibration (uint8_t ADC_channel) {
return ADCValueAVG_RAW;
}
/* use GPIO to control TW1508 */
static void GPIO_SPI_write(uint8_t GPIO_channel, uint16_t GPIOin) {
/*
Iout = 1.25/680 * ([9:7] +1)/8 * [6:0]
*/
static uint32_t TW_CH_0 [2] = {TW_SCKI_0};
static uint32_t TW_CH_1 [2] = {TW_SCKI_1};
static uint32_t TW_CH_2 [2] = {TW_SCKI_2};
static uint32_t TW_CH_3 [2] = {TW_SCKI_3};
uint32_t CLK_CH[2] = {0};
spi_GPIO_txbuf = 0;
static bool trans_valid = false;
switch (GPIO_channel) {
case Aout_CH_0: {
CLK_CH[0] = TW_CH_0[0];
CLK_CH[1] = TW_CH_0[1];
trans_valid = true;
break;
}
case Aout_CH_1: {
CLK_CH[0] = TW_CH_1[0];
CLK_CH[1] = TW_CH_1[1];
trans_valid = true;
break;
}
case Aout_CH_2: {
CLK_CH[0] = TW_CH_2[0];
CLK_CH[1] = TW_CH_2[1];
trans_valid = true;
break;
}
case Aout_CH_3: {
CLK_CH[0] = TW_CH_3[0];
CLK_CH[1] = TW_CH_3[1];
trans_valid = true;
break;
}
default: {
trans_valid = false;
break;
}
}
/* GPIOin = 0x0000 ~ 0x03FF */
spi_GPIO_txbuf = GPIOin;
if (trans_valid) {
GPIO_SPI_transfer(CLK_CH, spi_GPIO_txbuf);
trans_valid = false;
}
}
static void AoutChannelSelect(uint8_t Aout_channel, bool on_off) {
switch (Aout_channel) {
case Aout_CH_0: {
PIN15_setOutputValue(AO_MOS_0, on_off);
break;
}
case Aout_CH_1: {
PIN15_setOutputValue(AO_MOS_1, on_off);
break;
}
case Aout_CH_2: {
PIN15_setOutputValue(AO_MOS_2, on_off);
break;
}
case Aout_CH_3: {
PIN15_setOutputValue(AO_MOS_3, on_off);
break;
}
case 0xFF :{ // output all off or on
PIN15_setOutputValue(AO_MOS_0, on_off);
PIN15_setOutputValue(AO_MOS_1, on_off);
PIN15_setOutputValue(AO_MOS_2, on_off);
PIN15_setOutputValue(AO_MOS_3, on_off);
}
default: {
break;
}
}
}
static void TW1508reset() {
GPIO_SPI_write(Aout_CH_0, 0x0000);
GPIO_SPI_write(Aout_CH_1, 0x0000);
GPIO_SPI_write(Aout_CH_2, 0x0000);
GPIO_SPI_write(Aout_CH_3, 0x0000);
}
#endif
@@ -34,106 +34,103 @@ static uint16_t CV3Curve(CV3Mode *CV3){
return DACOutCode;
}
static void CV3_Vscan(CV3Mode *CV3){
static int16_t VminCounter;
static int16_t VmaxCounter;
static uint16_t CycleCounter;
static void CV3_Vscan(CV3Mode *CV3) {
static bool VminCounter;
static bool VmaxCounter;
NotifyCycleNumber = (INSTRUCTION.cycleNumber - CV3->_cycleNumber + 1);
if(vscanReset){
VmaxCounter = 0;
VminCounter = 0;
CycleCounter = 0;
if (vscanReset) {
VmaxCounter = false;
VminCounter = false;
if(INSTRUCTION.directionInit == 1){
if (INSTRUCTION.directionInit == 1) {
CV3->_direction_up = true;
CV3->_current_direction_up = true;
}else{
} else {
CV3->_direction_up = false;
CV3->_current_direction_up = false;
}
//Vsetp = x * 20 * N, x=xmV ; N=VscanRate
if(INSTRUCTION.step <= 10){
if (INSTRUCTION.step <= 10) {
CV3->_Vstep = INSTRUCTION.step * INSTRUCTION.VsetRate / 5;
}else{
} else {
CV3->_Vstep = INSTRUCTION.step / 5 * INSTRUCTION.VsetRate;
}
if(CV3->_Vmin == CV3->_Vinit){
VminCounter = -1;
if (CV3->_Vmin == CV3->_Vinit) {
VminCounter = true;
}
if(CV3->_Vmax == CV3->_Vinit){
VmaxCounter = -1;
if (CV3->_Vmax == CV3->_Vinit) {
VmaxCounter = true;
}
Vset = CV3->_Vinit;
}
if(!vscanReset){
if((INSTRUCTION.Vinit < INSTRUCTION.Ve1 && INSTRUCTION.Vinit < INSTRUCTION.Ve2) ||
if (!vscanReset) {
if ((INSTRUCTION.Vinit < INSTRUCTION.Ve1 && INSTRUCTION.Vinit < INSTRUCTION.Ve2) ||
(INSTRUCTION.Vinit > INSTRUCTION.Ve1 && INSTRUCTION.Vinit > INSTRUCTION.Ve2)
){
if (CV3->_current_direction_up){
Vset = Vset + CV3->_Vstep;
}else{
Vset = Vset - CV3->_Vstep;
) {
if (CV3->_current_direction_up) {
Vset = Vset + CV3->_Vstep * GPT.GptimerMultiple;
} else {
Vset = Vset - CV3->_Vstep * GPT.GptimerMultiple;
}
if(INSTRUCTION.Vinit < INSTRUCTION.Ve1 && INSTRUCTION.Vinit < INSTRUCTION.Ve2){
if(Vset == CV3->_Vmin){
VminCounter = -1;
if (INSTRUCTION.Vinit < INSTRUCTION.Ve1 && INSTRUCTION.Vinit < INSTRUCTION.Ve2) {
if (Vset == CV3->_Vmin) {
VminCounter = true;
INSTRUCTION.Vinit = INSTRUCTION.Vmin;
CV3->_Vinit = CV3->_Vmin;
}
}else if(INSTRUCTION.Vinit > INSTRUCTION.Ve1 && INSTRUCTION.Vinit > INSTRUCTION.Ve2){
if(Vset == CV3->_Vmax){
VmaxCounter = -1;
} else if (INSTRUCTION.Vinit > INSTRUCTION.Ve1 && INSTRUCTION.Vinit > INSTRUCTION.Ve2) {
if (Vset == CV3->_Vmax) {
VmaxCounter = true;
INSTRUCTION.Vinit = INSTRUCTION.Vmax;
CV3->_Vinit = CV3->_Vmax;
}
}
}else{
if (Vset >= CV3->_Vmax){
VmaxCounter++;
}else if (Vset <= CV3->_Vmin){
VminCounter++;
} else {
if (Vset >= CV3->_Vmax) {
VmaxCounter = true;
} else if (Vset <= CV3->_Vmin) {
VminCounter = true;
}
if (CV3->_current_direction_up){
if (CV3->_current_direction_up) {
Vset = Vset + CV3->_Vstep * GPT.GptimerMultiple;
}else{
} else {
Vset = Vset - CV3->_Vstep * GPT.GptimerMultiple;
}
if(VmaxCounter != 0 && VminCounter != 0){
if(VmaxCounter == VminCounter && CV3->_direction_up && CV3->_current_direction_up){
if(CycleCounter != VmaxCounter){
if(Vset >= CV3->_Vinit){
CV3->_cycleNumber--;
CycleCounter = VmaxCounter; //VmaxCounter = VminCounter = CycleCounter
}
if (VmaxCounter && VminCounter) {
if (CV3->_direction_up && CV3->_current_direction_up) {
if (Vset >= CV3->_Vinit) {
CV3->_cycleNumber--;
VminCounter = false;
VmaxCounter = false;
}
}
if(VmaxCounter == VminCounter && !CV3->_direction_up && !CV3->_current_direction_up){
if(CycleCounter != VmaxCounter){
if(Vset <= CV3->_Vinit){
CV3->_cycleNumber--;
CycleCounter = VmaxCounter; //VmaxCounter = VminCounter = CycleCounter
}
if (!CV3->_direction_up && !CV3->_current_direction_up) {
if (Vset <= CV3->_Vinit) {
CV3->_cycleNumber--;
VminCounter = false;
VmaxCounter = false;
}
}
}
if (Vset >= CV3->_Vmax){
if (Vset >= CV3->_Vmax) {
CV3->_current_direction_up = false;
}else if (Vset <= CV3->_Vmin){
} else if (Vset <= CV3->_Vmin) {
CV3->_current_direction_up = true;
}
/*stop condition*/
if(CV3->_cycleNumber == 0){
if (CV3->_cycleNumber == 0) {
// PeriodicEvent = false;
ModeLED(POST_WORK);
InitEliteFlag();
@@ -147,7 +144,6 @@ static void CV3_Vscan(CV3Mode *CV3){
INSTRUCTION.VoViSwitch = 0x02;//read Vscan = Vout - Vin
}
}
}
// int32_t RealV;
// RealV = (int32_t)(Vset / 500);//[1uV]
@@ -133,16 +133,14 @@ static uint16_t DPVCurve(WorkMode *WorkModeData) {
}
static void CV_Vscan(CVMode *CV){
static int16_t VminCounter;
static int16_t VmaxCounter;
static uint16_t CycleCounter;
static bool VminCounter;
static bool VmaxCounter;
NotifyCycleNumber = (INSTRUCTION.cycleNumber - CV->_cycleNumber + 1);
if(vscanReset){
VmaxCounter = 0;
VminCounter = 0;
CycleCounter = 0;
VmaxCounter = false;
VminCounter = false;
if(INSTRUCTION.directionInit == 1){
CV->_direction_up = true;
@@ -160,10 +158,10 @@ static void CV_Vscan(CVMode *CV){
}
if(CV->_Vmin == CV->_Vinit){
VminCounter = -1;
VminCounter = true;
}
if(CV->_Vmax == CV->_Vinit){
VmaxCounter = -1;
VmaxCounter = true;
}
Vset = CV->_Vinit;
@@ -171,9 +169,9 @@ static void CV_Vscan(CVMode *CV){
if(!vscanReset){
if (Vset >= CV->_Vmax){
VmaxCounter++;
VmaxCounter = true;
}else if (Vset <= CV->_Vmin){
VminCounter++;
VminCounter = true;
}
if (CV->_current_direction_up){
@@ -182,21 +180,19 @@ static void CV_Vscan(CVMode *CV){
Vset = Vset - CV->_Vstep * GPT.GptimerMultiple;
}
if(VmaxCounter != 0 && VminCounter != 0){
if(VmaxCounter == VminCounter && CV->_direction_up && CV->_current_direction_up){
if(CycleCounter != VmaxCounter){
if(Vset >= CV->_Vinit){
CV->_cycleNumber--;
CycleCounter = VmaxCounter; //VmaxCounter = VminCounter = CycleCounter
}
if(VmaxCounter && VminCounter){
if(CV->_direction_up && CV->_current_direction_up){
if(Vset >= CV->_Vinit){
CV->_cycleNumber--;
VminCounter = false;
VmaxCounter = false;
}
}
if(VmaxCounter == VminCounter && !CV->_direction_up && !CV->_current_direction_up){
if(CycleCounter != VmaxCounter){
if(Vset <= CV->_Vinit){
CV->_cycleNumber--;
CycleCounter = VmaxCounter; //VmaxCounter = VminCounter = CycleCounter
}
if(!CV->_direction_up && !CV->_current_direction_up){
if(Vset <= CV->_Vinit){
CV->_cycleNumber--;
VminCounter = false;
VmaxCounter = false;
}
}
}
@@ -210,7 +206,6 @@ static void CV_Vscan(CVMode *CV){
/*stop condition*/
if(CV->_cycleNumber == 0){
PeriodicEvent = false;
ELITE15_SPI_CLOSE();
ModeLED(NO_EVENT);
}
}
@@ -51,11 +51,7 @@ static uint16_t DAC_outputV(uint16_t voltLV) {
spi_DACtxbuf[1] = v1;
spi_DACtxbuf[2] = v2;
if(PeriodicEvent){
DAC_SPI_TEST(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
}else{
DAC_SPI(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
}
// DAC_SPI(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
return voltLV;
}
@@ -63,19 +59,19 @@ static uint16_t DAC_outputV(uint16_t voltLV) {
static void VoutGainControl(uint8_t VOUTLevel){
if(VOUTLevel == 0){
// VOUT gain level = 0, using 240K resister
PIN15_setOutputValue(Turon_VOUT_SMALL, 0);
// PIN15_setOutputValue(Turon_VOUT_SMALL, 0);
}
else if(VOUTLevel == 1){
// VOUT gain level = 1, using 15K resister
PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
// PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
}
else if(VOUTLevel == 2){
// VOUT gain level = 2, using 15K resister
PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
// PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
}
else{
// default using 15K resister
PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
// PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
}
}
@@ -88,16 +84,20 @@ static int32_t User2Real(uint16_t UserCode){
// DAC Vout theoretical boundary <300, 100~ (mV)
#define DAC_VOUT_GAIN_SMALL_BOUNDARY 100000 // 100 mV = 25500(usercode)
#define DAC_VOUT_GAIN_LARGE_BOUNDARY 300000 // 300 mV = 26500(usercode)
#define DAC_VOUT_GAIN_SMALL_BOUNDARY 100000 // 25500(usercode) = 100 mV
#define DAC_VOUT_GAIN_LARGE_BOUNDARY 300000 // 26500(usercode) = 300 mV
#define DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE 26500 // 26500(usercode) = 300 mV
#define DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE 23500 // 23500(usercode) = -300 mV
static void AutoGainChangeVout(int32_t RealVolt){
RealVolt = (RealVolt - 25000) * 200; // (RealVolt - 25000) / 5 * 1000
static void AutoGainChangeVout(int32_t userCode){
int32_t RealVolt = (userCode - 25000) * 200; // (userCode - 25000) / 5 * 1000 [1uV]
// switch to 1 level volt(small) 15K
// switch to 2 level volt(large) 240K
if(INSTRUCTION.VoutGainLevel == VOUT_GAIN_AUTO){
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
record_flag = false;
}
if(INSTRUCTION.VoutGainLevel == VOUT_GAIN_15K){
@@ -29,7 +29,7 @@
*/
#define BOARD_C6D4
#define BOARD_C903
typedef struct _formula{
@@ -49,7 +49,385 @@ struct _correction{
} Correction =
#ifdef BOARD_C6E1
#ifdef BOARD_C7A1 //megafly
{
.ADC_volt[0].coeff = (6256),
.ADC_volt[0].offset = -101532028,
.ADC_volt[1].coeff = (215138),
.ADC_volt[1].offset = -3501890770,
.ADC_volt[2].coeff = (6245014),
.ADC_volt[2].offset = -101751226981,
.ADC_current[0].coeff = 3125920,
.ADC_current[0].offset = (-50880328288),
.ADC_current[1].coeff = 71636129,
.ADC_current[1].offset = (-1166093783868),
.ADC_current[2].coeff = 1459555637,
.ADC_current[2].offset = (-23757721396024),
.ADC_current[3].coeff = 30723232882,
.ADC_current[3].offset = (-500144809348170),
.Usercode2DAC[0].coeff = (-10543817),
.Usercode2DAC[0].offset = 583163641972,
.Usercode2DAC[1].coeff = (-178077711),
.Usercode2DAC[1].offset = 4777894559527,
//.Usercode2DAC15v = 41485,
};
#endif
#ifdef BOARD_C724 //megafly
{
.ADC_volt[0].coeff = (6251),
.ADC_volt[0].offset = -99750397,
.ADC_volt[1].coeff = (214419),
.ADC_volt[1].offset = -3491659841,
.ADC_volt[2].coeff = (6227737),
.ADC_volt[2].offset = -101557618268,
.ADC_current[0].coeff = 3138613,
.ADC_current[0].offset = (-51149570420),
.ADC_current[1].coeff = 71715555,
.ADC_current[1].offset = (-1168777305352),
.ADC_current[2].coeff = 1455501991,
.ADC_current[2].offset = (-23719715469357),
.ADC_current[3].coeff = 30688298312,
.ADC_current[3].offset = (-500150163983795),
.Usercode2DAC[0].coeff = (-10540182),
.Usercode2DAC[0].offset = 584459109821,
.Usercode2DAC[1].coeff = (-179175265),
.Usercode2DAC[1].offset = 4801179734836,
//.Usercode2DAC15v = MEGA_15V,
};
#endif
#ifdef BOARD_C874 //megafly
{
.ADC_volt[0].coeff = (6260),
.ADC_volt[0].offset = -99787811,
.ADC_volt[1].coeff = (214494),
.ADC_volt[1].offset = -3492178752,
.ADC_volt[2].coeff = (6231057),
.ADC_volt[2].offset = -101591914655,
.ADC_current[0].coeff = 3148251,
.ADC_current[0].offset = (-51277675282),
.ADC_current[1].coeff = 71859885,
.ADC_current[1].offset = (-1170556644217),
.ADC_current[2].coeff = 1462458824,
.ADC_current[2].offset = (-23822062635236),
.ADC_current[3].coeff = 30748473913,
.ADC_current[3].offset = (-500860829105930),
.Usercode2DAC[0].coeff = (-10570366),
.Usercode2DAC[0].offset = 585189864243,
.Usercode2DAC[1].coeff = (-178920333),
.Usercode2DAC[1].offset = 4794801719146,
//.Usercode2DAC15v = 41355,
};
#endif
#ifdef BOARD_C604
{
.ADC_volt[0].coeff = (6194),
.ADC_volt[0].offset = -100974071,
.ADC_volt[1].coeff = (215506),
.ADC_volt[1].offset = -3517864544,
.ADC_volt[2].coeff = (6243728),
.ADC_volt[2].offset = -102012564806,
.ADC_current[0].coeff = 3139436,
.ADC_current[0].offset = (-51217085818),
.ADC_current[1].coeff = 71622830,
.ADC_current[1].offset = (-1168462302473),
.ADC_current[2].coeff = 1462344785,
.ADC_current[2].offset = (-23855062972762),
.ADC_current[3].coeff = 30689232716,
.ADC_current[3].offset = (-500670762245868),
.Usercode2DAC[0].coeff = (-10507403),
.Usercode2DAC[0].offset = 582940058695,
.Usercode2DAC[1].coeff = (-178479878),
.Usercode2DAC[1].offset = 4782895510276,
};
#endif
#ifdef BOARD_C69F
{
.ADC_volt[0].coeff = (6118),
.ADC_volt[0].offset = -99518615,
.ADC_volt[1].coeff = (209748),
.ADC_volt[1].offset = -3417768725,
.ADC_volt[2].coeff = (6131501),
.ADC_volt[2].offset = -99999128933,
.ADC_current[0].coeff = 3148514,
.ADC_current[0].offset = (-50485662786),
.ADC_current[1].coeff = 71804564,
.ADC_current[1].offset = (-1151299062516),
.ADC_current[2].coeff = 1463584080,
.ADC_current[2].offset = (-23465643586165),
.ADC_current[3].coeff = 30747070723,
.ADC_current[3].offset = (-492979538892707),
.Usercode2DAC[0].coeff = (-10534427),
.Usercode2DAC[0].offset = 577647889649,
.Usercode2DAC[1].coeff = (-178317702),
.Usercode2DAC[1].offset = 4773350420707,
};
#endif
#ifdef BOARD_C903
{
.ADC_volt[0].coeff = (6268),
.ADC_volt[0].offset = -103687047,
.ADC_volt[1].coeff = (216289),
.ADC_volt[1].offset = -3581110600,
.ADC_volt[2].coeff = (6255165),
.ADC_volt[2].offset = -103653080405,
.ADC_current[0].coeff = 3136844,
.ADC_current[0].offset = (-51057548335),
.ADC_current[1].coeff = 71729828,
.ADC_current[1].offset = (-1167474302377),
.ADC_current[2].coeff = 1457587112,
.ADC_current[2].offset = (-23722230272507),
.ADC_current[3].coeff = 30688020320,
.ADC_current[3].offset = (-499567626613052),
.Usercode2DAC[0].coeff = (-10538549),
.Usercode2DAC[0].offset = 582561125327,
.Usercode2DAC[1].coeff = (-179443367),
.Usercode2DAC[1].offset = 4806000714268,
};
#endif
#ifdef BOARD_C60C
{
.ADC_volt[0].coeff = (6232),
.ADC_volt[0].offset = -100384012,
.ADC_volt[1].coeff = (216642),
.ADC_volt[1].offset = -3529452462,
.ADC_volt[2].coeff = (6233108),
.ADC_volt[2].offset = -100604531870,
.ADC_current[0].coeff = 3145651,
.ADC_current[0].offset = (-51102123184),
.ADC_current[1].coeff = 71727284,
.ADC_current[1].offset = (-1165169041311),
.ADC_current[2].coeff = 1463455403,
.ADC_current[2].offset = (-23772125686630),
.ADC_current[3].coeff = 30773610135,
.ADC_current[3].offset = (-499913505030514),
.Usercode2DAC[0].coeff = (-10570464),
.Usercode2DAC[0].offset = 583479916773,
.Usercode2DAC[1].coeff = (-178725281),
.Usercode2DAC[1].offset = 4787957689974,
};
#endif
#ifdef BOARD_C78B
{
.ADC_volt[0].coeff = (6242),
.ADC_volt[0].offset = -101356025,
.ADC_volt[1].coeff = (215624),
.ADC_volt[1].offset = -3503045312,
.ADC_volt[2].coeff = (6243816),
.ADC_volt[2].offset = -101524034738,
.ADC_current[0].coeff = 3131950,
.ADC_current[0].offset = (-50953509336),
.ADC_current[1].coeff = 71591803,
.ADC_current[1].offset = (-1164676104750),
.ADC_current[2].coeff = 1457994881,
.ADC_current[2].offset = (-23717445756897),
.ADC_current[3].coeff = 30731877501,
.ADC_current[3].offset = (-499947688305697),
.Usercode2DAC[0].coeff = (-10509141),
.Usercode2DAC[0].offset = 581313489845,
.Usercode2DAC[1].coeff = (-177847688),
.Usercode2DAC[1].offset = 4765751343445,
};
#endif
#ifdef BOARD_C615
{
.ADC_volt[0].coeff = (6213),
.ADC_volt[0].offset = -100904734,
.ADC_volt[1].coeff = (213486),
.ADC_volt[1].offset = -3475774161,
.ADC_volt[2].coeff = (6220838),
.ADC_volt[2].offset = -101367452805,
.ADC_current[0].coeff = 3133669,
.ADC_current[0].offset = (-50985338691),
.ADC_current[1].coeff = 71848701,
.ADC_current[1].offset = (-1168930549263),
.ADC_current[2].coeff = 1465220422,
.ADC_current[2].offset = (-23836711044239),
.ADC_current[3].coeff = 30753809644,
.ADC_current[3].offset = (-500364315274466),
.Usercode2DAC[0].coeff = (-10519306),
.Usercode2DAC[0].offset = 583547544303,
.Usercode2DAC[1].coeff = (-179481859),
.Usercode2DAC[1].offset = 4808633144378,
};
#endif
#ifdef BOARD_C797
{
.ADC_volt[0].coeff = (6285),
.ADC_volt[0].offset = -102399765,
.ADC_volt[1].coeff = (217179),
.ADC_volt[1].offset = -3541219740,
.ADC_volt[2].coeff = (6293290),
.ADC_volt[2].offset = -102701705789,
.ADC_current[0].coeff = 3124793,
.ADC_current[0].offset = (-50785593516),
.ADC_current[1].coeff = 71661923,
.ADC_current[1].offset = (-1164632411724),
.ADC_current[2].coeff = 1459117290,
.ADC_current[2].offset = (-23712400276764),
.ADC_current[3].coeff = 30624856407,
.ADC_current[3].offset = (-497729976849926),
.Usercode2DAC[0].coeff = (-10517402),
.Usercode2DAC[0].offset = 581255473226,
.Usercode2DAC[1].coeff = (-178353177),
.Usercode2DAC[1].offset = 4777407394955,
};
#endif
#ifdef BOARD_C639
{
.ADC_volt[0].coeff = (6208),
.ADC_volt[0].offset = -100729867,
.ADC_volt[1].coeff = (214500),
.ADC_volt[1].offset = -3488858165,
.ADC_volt[2].coeff = (6228268),
.ADC_volt[2].offset = -101395718164,
.ADC_current[0].coeff = 3139511,
.ADC_current[0].offset = (-51174954874),
.ADC_current[1].coeff = 71851912,
.ADC_current[1].offset = (-1171152880960),
.ADC_current[2].coeff = 1461965017,
.ADC_current[2].offset = (-23828340962540),
.ADC_current[3].coeff = 30773724865,
.ADC_current[3].offset = (-501611882239925),
.Usercode2DAC[0].coeff = (-10520659),
.Usercode2DAC[0].offset = 581192312483,
.Usercode2DAC[1].coeff = (-177973792),
.Usercode2DAC[1].offset = 4768259045109,
};
#endif
#ifdef BOARD_C771 //die
{
.ADC_volt[0].coeff = (6301),
.ADC_volt[0].offset = -102184705,
.ADC_volt[1].coeff = (216877),
.ADC_volt[1].offset = -3519583281,
.ADC_volt[2].coeff = (6298448),
.ADC_volt[2].offset = -102304286091,
.ADC_current[0].coeff = 3115431,
.ADC_current[0].offset = (-50586460394),
.ADC_current[1].coeff = 71203612,
.ADC_current[1].offset = (-1156022105141),
.ADC_current[2].coeff = 1451318434,
.ADC_current[2].offset = (-23560731221983),
.ADC_current[3].coeff = 30518004246,
.ADC_current[3].offset = (-495456618814855),
.Usercode2DAC[0].coeff = (-10568719),
.Usercode2DAC[0].offset = 585036272447,
.Usercode2DAC[1].coeff = (-179441058),
.Usercode2DAC[1].offset = 4807380622351,
};
#endif
#ifdef BOARD_C6E1 // not well
{
.ADC_volt[0].coeff = (-6251051),
.ADC_volt[0].offset = 102081366120,
@@ -80,38 +458,7 @@ struct _correction{
};
#endif
#ifdef BOARD_C7A1
{
.ADC_volt[0].coeff = (6204),
.ADC_volt[0].offset = -100237253,
.ADC_volt[1].coeff = (214511),
.ADC_volt[1].offset = -3485722036,
.ADC_volt[2].coeff = (6213224),
.ADC_volt[2].offset = -101104189300,
.ADC_current[0].coeff = 2078892,
.ADC_current[0].offset = (-33685110900),
.ADC_current[1].coeff = 64769469,
.ADC_current[1].offset = (-1048938859469),
.ADC_current[2].coeff = 2090182091,
.ADC_current[2].offset = (-33847893234994),
.ADC_current[3].coeff = 60030468992,
.ADC_current[3].offset = (-972275155887907),
.Usercode2DAC[0].coeff = (-10512772),
.Usercode2DAC[0].offset = 581302323013,
.Usercode2DAC[1].coeff = (-178991273),
.Usercode2DAC[1].offset = 4794464882260,
};
#endif
#ifdef BOARD_C6D4
#ifdef BOARD_C6D4 // not well
{
.ADC_volt[0].coeff = (6226),
.ADC_volt[0].offset = -100075170,
@@ -141,7 +488,6 @@ struct _correction{
.Usercode2DAC[1].offset = 4789272862069,
};
#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){
@@ -259,8 +605,6 @@ static void ADC_overflow(uint8_t gain, uint8_t *rawdata){
// this function should turn 0~50000 into DACcode which output the exactly voltage user want
static uint16_t Usercode_Correction_to_DAC(uint8_t DACGain, uint16_t usercode)
{
AutoGainChangeVout(usercode);
long long usercode_32;
uint16_t DACcode = 0;
@@ -22,6 +22,7 @@ struct _GPT{
uint32_t BatteryADCCounter;
uint32_t BatteryCheckCounter;
uint32_t GptimerMultiple;
uint32_t StiCounter;
}GPT = {0};
static void InitCT(){
@@ -41,5 +42,6 @@ static void InitGPT(){
GPT.LeadTimeCounter = 0;
GPT.BatteryADCCounter = 0;
GPT.BatteryCheckCounter = 0;
GPT.StiCounter = 0;
}
#endif
@@ -28,13 +28,11 @@ static void IV_Vscan(IVMode *IV){
if(IV->_current_direction_up){
if(Vset >= IV->_Vmax){
PeriodicEvent = false;
ELITE15_SPI_CLOSE();
ModeLED(NO_EVENT);
}
}else{
if(Vset <= IV->_Vmin){
PeriodicEvent = false;
ELITE15_SPI_CLOSE();
ModeLED(NO_EVENT);
}
}
@@ -8,6 +8,13 @@
#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
@@ -75,11 +82,43 @@ struct HEADSTAGE_INSTRUCTION {
uint8_t charge;
int32_t constantCurrent;
int32_t Currentmax;
int32_t sti_v1;
int32_t sti_v2;
int32_t sti_v3;
int32_t sti_v4;
int32_t sti_v5;
int32_t sti_v6;
int32_t sti_v7;
int32_t sti_t1;
int32_t sti_t2;
int32_t sti_t3;
int32_t sti_t4;
int32_t sti_t5;
int32_t sti_t6;
int32_t sti_t7;
uint16_t sti_cy;
uint16_t sti_loop;
uint16_t StepTime;
uint8_t AdcChannel;
/** 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;
/** trigger mode enable **/
bool trig0_en;
bool trig1_en;
} INSTRUCTION = {0};
/*********************************************************************
@@ -121,5 +160,34 @@ static void InitEliteInstruction(){
INSTRUCTION.Currentmax = 0;
INSTRUCTION.StepTime = STEPTIME_ONE_SEC;
INSTRUCTION.AdcChannel = 0;
//pulse mode
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;
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
@@ -68,7 +68,7 @@ static void EliteKeyPress(uint8_t key) {
static void TurnOn10V() {
If10Von = true;
PIN15_setOutputValue(enable_10v, 1);
// PIN15_setOutputValue(enable_10v, 1);
CPUdelay(8000);
}
@@ -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;
@@ -18,26 +31,21 @@ static void LED_color(uint8_t bright, uint8_t red, uint8_t green, uint8_t blue)
spi_LEDtxbuf[SPI_LED_SIZE - 2] = 0xffff;
spi_LEDtxbuf[SPI_LED_SIZE - 1] = 0xffff;
if(PeriodicEvent){
LED_SPI_TEST(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf);
}else{
LED_SPI(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf);
}
LED_SPI(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf);
}
static void Elite_led_color(uint16_t color){
switch (color) {
case COLOR_RED: {
LED_color(DARKLED, 0x50, 0x00, 0x00);
LED_color(DARKLED, 0xFF, 0x00, 0x00);
break;
}
case COLOR_ORANGE: {
LED_color(DARKLED, 0x50, 0x58, 0x09);
LED_color(DARKLED, 0xFF, 0x58, 0x09);
break;
}
case COLOR_YELLOW: {
LED_color(LIGHTLED, 0x50, 0x80, 0x00);
LED_color(LIGHTLED, 0xFF, 0x80, 0x00);
break;
}
case COLOR_GREEN: {
@@ -57,33 +65,129 @@ static void Elite_led_color(uint16_t color){
break;
}
case COLOR_MAGENTA: {
LED_color(DARKLED, 0x50, 0x00, 0x80);
LED_color(DARKLED, 0xFF, 0x00, 0x80);
break;
}
case COLOR_PURPLE: {
LED_color(DARKLED, 0x50, 0x00, 0xFF);
LED_color(DARKLED, 0xFF, 0x00, 0xFF);
break;
}
case COLOR_WHITE: {
LED_color(DARKLED, 0x50, 0xFF, 0xFF);
LED_color(DARKLED, 0xCA, 0xFF, 0xFF);
break;
}
case COLOR_BLACK: {
LED_color(0x00, 0x00, 0x00, 0x00);
break;
}
//dark LED
case COLOR_YELLOW_DARK: {
LED_color(DARKLED, 0xFF, 0x80, 0x00);
break;
}
case COLOR_GREEN_DARK: {
LED_color(DARKLED, 0x00, 0x33, 0x00);
break;
}
case COLOR_BLUE_DARK: {
LED_color(DARKLED, 0x00, 0x00, 0x33);
break;
}
case COLOR_CYAN_DARK: {
LED_color(DARKLED, 0x00, 0x10, 0x10);
break;
}
case COLOR_PURPLE_DARK: {
LED_color(DARKLED, 0x55, 0x00, 0x55);
break;
}
default: {
break;
}
}
}
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: {
@@ -111,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,6 +244,9 @@ static void checkFlafLED() {
else if(postWorkLedFlag == 1){
ModeLED(POST_WORK);
}
else if(TRIG01workFlag == 1){
ModeLED(TRIG01_WORK);
}
}
static void WorkModeLED() {
@@ -146,13 +259,21 @@ static void WorkModeLED() {
case ZT_CURVE:
case VT_CURVE:
case IT_CURVE:
case ADC_TEST:
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;
@@ -177,4 +298,130 @@ static void WorkModeLED() {
}
}
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
@@ -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
@@ -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
@@ -3,21 +3,28 @@
#define ELITERESET
static void reset() {
megaStiEnable = false;
ModeLED(NO_EVENT);
InitEliteFlag();
InitFlag();
InitCT();
InitGPT();
InitLH();
InitLED();
InitTrigChan();
VinADCGainControl(VIN_GAIN_AUTO);
IinADCGainControl(I_GAIN_AUTO);
VoutGainControl(VOUT_GAIN_AUTO);
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0 => open high_z mode
disable_trig_output();
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
initINSBuf();
initDATBuf();
for (int i = 0; i < SPI_LED_SIZE; i++) {
spi_LEDtxbuf[i] = 0;
spi_LEDrxbuf[i] = 0;
@@ -33,25 +40,23 @@ static void reset() {
spi_ADC_rxbuf[i] = 0;
}
PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
PIN15_setOutputValue(DAC_CS, 1); // DAC_CS HIGH
CPUdelay(1600);
}
static void Eliteinterrupt() {
InitFlag();
megaStiEnable = false;
ModeLED(NO_EVENT);
InitFlag();
InitEliteFlag();
InitCT();
InitGPT();
InitLH();
VinADCGainControl(VIN_GAIN_AUTO);
IinADCGainControl(I_GAIN_AUTO);
VoutGainControl(VOUT_GAIN_AUTO);
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0 => open high_z mode
// 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();
@@ -70,8 +75,6 @@ static void Eliteinterrupt() {
spi_ADC_rxbuf[i] = 0;
}
PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
PIN15_setOutputValue(DAC_CS, 1); // DAC_CS HIGH
CPUdelay(8000);
}
#endif
@@ -15,9 +15,10 @@
#include "Elite_PIN.h"
/* application use SPI parameters and buffers */
#define SPI_LED_SIZE 28
#define SPI_DAC_SIZE 3
#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};
@@ -28,6 +29,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 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
static SPI_Handle spiHandle1 = NULL; // SPI1 = ADC +DAC
@@ -57,20 +61,17 @@ static void Elite_SPI_init(){
}
static void LED_SPI(uint8_t length, uint16_t *spi_txbuf, uint16_t *spi_rxbuf) {
ELITE15_SPI_HOLD();
LED_transaction.count = length;
LED_transaction.txBuf = spi_txbuf;
LED_transaction.rxBuf = spi_rxbuf;
SPI_transfer(spiHandle0, &LED_transaction);
ELITE15_SPI_CLOSE();
}
static void ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
ELITE15_SPI_HOLD();
PIN_setOutputValue(pin_handle, D6, 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;
@@ -78,82 +79,48 @@ static void ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
PIN_setOutputValue(pin_handle, D6, 1); // CS_ADC
ELITE15_SPI_CLOSE();
// 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) {
ELITE15_SPI_HOLD();
PIN_setOutputValue(pin_handle, D7, 0); // CD_DAC
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); // CD_DAC
ELITE15_SPI_CLOSE();
// 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 LED_SPI_TEST(uint8_t length, uint16_t *spi_txbuf, uint16_t *spi_rxbuf) {
LED_transaction.count = length;
LED_transaction.txBuf = spi_txbuf;
LED_transaction.rxBuf = spi_rxbuf;
SPI_transfer(spiHandle0, &LED_transaction);
}
static void ADC_SPI_TEST(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
PIN_setOutputValue(pin_handle, D6, 0); // CS_ADC
ADC_DAC_transaction.count = length;
ADC_DAC_transaction.txBuf = spi_txbuf;
ADC_DAC_transaction.rxBuf = spi_rxbuf;
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
PIN_setOutputValue(pin_handle, D6, 1); // CS_ADC
}
static void DAC_SPI_TEST(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
PIN_setOutputValue(pin_handle, D7, 0); // CD_DAC
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); // CD_DAC
}
static void ELITE15_SPI_HOLD() {
PIN_setOutputValue(pin_handle, LOAD0, 1);
PIN_setOutputValue(pin_handle, LOAD1, 0);
PIN_setOutputValue(pin_handle, LOAD2, 0);
PIN_setOutputValue(pin_handle, D4, 1); // HOLD_MEM
PIN_setOutputValue(pin_handle, D5, 1); // CS_MEM
PIN_setOutputValue(pin_handle, D6, 1); // CS_ADC
PIN_setOutputValue(pin_handle, D7, 1); // CD_DAC
static void ELITE15_SPI_HOLD() {
Elite_SPI_init();
// 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, D4, 1); // HOLD_MEM
PIN_setOutputValue(pin_handle, D5, 1); // CS_MEM
PIN_setOutputValue(pin_handle, D6, 1); // CS_ADC
PIN_setOutputValue(pin_handle, D7, 1); // CD_DAC
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);
}
/* Elite1.5 Calibration SPI */
static void CAL_ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
// ELITE15_SPI_HOLD();
PIN_setOutputValue(pin_handle, D6, 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;
@@ -161,21 +128,47 @@ static void CAL_ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf)
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
PIN_setOutputValue(pin_handle, D6, 1); // CS_ADC
// ELITE15_SPI_CLOSE();
// 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) {
// ELITE15_SPI_HOLD();
static void GPIO_SPI_transfer(uint32_t *GPIO_CLK_CH, uint16_t spi_GPIO_txbuf) {
LED_transaction.count = length;
LED_transaction.txBuf = spi_txbuf;
LED_transaction.rxBuf = spi_rxbuf;
for (int i=0; i<SPI_GPIO_BUFF_SIZE; i++) {
SPI_GPIO[i] = 0;
}
SPI_transfer(spiHandle0, &LED_transaction);
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();
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();
}
#endif // ELITE_SPI
@@ -327,6 +327,62 @@ CVSCANMode * InitCVSCANMode(){
}
/*End of CONSTANT_VSCAN Mode*/
/* PULSE_MODE Mode(PULSE_MODE)*/
typedef struct _PULSEMode {
MEASURE;
int32_t _Vset;
int32_t _sti_v1;
int32_t _sti_v2;
int32_t _sti_v3;
int32_t _sti_v4;
int32_t _sti_v5;
int32_t _sti_v6;
int32_t _sti_v7;
int32_t _sti_t1;
int32_t _sti_t2;
int32_t _sti_t3;
int32_t _sti_t4;
int32_t _sti_t5;
int32_t _sti_t6;
int32_t _sti_t7;
int32_t _sti_t;
int32_t _sti_v; //output voltage now
int32_t _sti_t_flag; //Where's the time stage turn
uint16_t _sti_cy;
uint16_t _sti_lp;
} PULSEMode;
PULSEMode * InitPULSEMode() {
PULSEMode *ret = malloc(sizeof(PULSEMode));
ret->_measureCurrent = 0;
ret->_measureVin = 0;
ret->_measureVout = 0;
ret->_measureBat = 0;
ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
ret->_Vset = 0;
ret->_sti_v1 = INSTRUCTION.sti_v1;
ret->_sti_v2 = INSTRUCTION.sti_v2;
ret->_sti_v3 = INSTRUCTION.sti_v3;
ret->_sti_v4 = INSTRUCTION.sti_v4;
ret->_sti_v5 = INSTRUCTION.sti_v5;
ret->_sti_v6 = INSTRUCTION.sti_v6;
ret->_sti_v7 = INSTRUCTION.sti_v7;
ret->_sti_t1 = INSTRUCTION.sti_t1;
ret->_sti_t2 = INSTRUCTION.sti_t2;
ret->_sti_t3 = INSTRUCTION.sti_t3;
ret->_sti_t4 = INSTRUCTION.sti_t4;
ret->_sti_t5 = INSTRUCTION.sti_t5;
ret->_sti_t6 = INSTRUCTION.sti_t6;
ret->_sti_t7 = INSTRUCTION.sti_t7;
ret->_sti_t = INSTRUCTION.sti_t1;
ret->_sti_v = INSTRUCTION.sti_v1;
ret->_sti_t_flag = 1;
ret->_sti_cy = INSTRUCTION.sti_cy;
ret->_sti_lp = INSTRUCTION.sti_loop;
return ret;
}
/*End of PULSE_MODE Mode*/
/* Cycle CC Mode */
typedef struct _CCCMode{
int32_t _measureCurrent;
@@ -423,6 +479,7 @@ typedef union _WorkMode{
LSVMode *LSV;
CVSCANMode *CVSCAN;
PSMode *PS;
PULSEMode *PULSE;
// CCCMode *CCC;
}WorkMode;
@@ -464,6 +521,9 @@ void InitWorkMode(WorkMode *WM){
case CONSTANT_VSCAN:
WM->CVSCAN = InitCVSCANMode();
break;
case PULSE_MODE:
WM->PULSE = InitPULSEMode();
break;
// case CYCLE_CONSTANT_CURRENT:
// WM->CCC = InitCCCMode();
// break;
@@ -536,6 +596,12 @@ void FreeWorkMode(WorkMode *WM){
WM->CVSCAN = NULL;
}
break;
case PULSE_MODE:
if(WM->PULSE != NULL){
free(WM->PULSE);
WM->PULSE = NULL;
}
break;
// case CYCLE_CONSTANT_CURRENT:
// if(WM->CCC != NULL){
// free(WM->CCC);
@@ -26,28 +26,35 @@
#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_HOLD LOAD0, D4
#define MEM_CS LOAD0, D5
#define TW_SCKI_0 LOAD0, D4
#define TW_SCKI_1 LOAD0, D5
#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 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 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
@@ -55,11 +62,14 @@
#define Board_I2C0_SDA0 PIN_UNASSIGNED
#endif
#define shutdown_6994 LOAD2, D6
#define switch_on IOID_14
#define HIGH_Z_MODE LOAD2, D5
#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;
@@ -69,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
};
@@ -93,15 +106,29 @@ 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);
}
/*!
@@ -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
@@ -84,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){
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);
}
}
@@ -18,6 +18,7 @@
#define VIS_DEVICE_SHINY 0x10
#define VIS_SHINY_DIS 0x20
#define VIS_CC_ZERO 0x40
#define VIS_TRIG_EN 0x41
// RIS (real instruction)
#define IV_CURVE 0x10
@@ -27,7 +28,8 @@
#define VT_CURVE 0x50
#define IT_CURVE 0x60
#define SET_SAMPLE_RATE 0x70
#define SET_ADC_DAC_GAIN 0x80
#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
@@ -39,6 +41,7 @@
#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
@@ -55,6 +58,21 @@
#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
#define PARA_4 0x04
#define PARA_5 0x05
#define PARA_6 0x06
#define PARA_7 0x07
#define PARA_8 0x08
#define PARA_9 0x09
#define PARA_10 0x0A
#define PARA_11 0x0B
#define PARA_12 0x0C
#define PARA_13 0x0D
#define PARA_14 0x0E
#define PARA_15 0x0F
#define PARA_16 0x10
#define PARA_17 0x11
//Elite LED
#define COLOR_BLACK 0x00
@@ -68,17 +86,34 @@
#define COLOR_PURPLE 0x08
#define COLOR_WHITE 0x09
#define COLOR_YELLOWGREEN 0x0A
#define COLOR_YELLOW_DARK 0xF3
#define COLOR_GREEN_DARK 0xF4
#define COLOR_BLUE_DARK 0xF5
#define COLOR_CYAN_DARK 0xF6
#define COLOR_PURPLE_DARK 0xF8
#define LEDPowerON() Elite_led_color(COLOR_GREEN)
#define WORKLED() Elite_led_color(COLOR_CYAN)
#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
#define TRIG01_WORK 0x06
#define VALUE_ZERO_TO_ONE(_v) (_v == 0) ? 1 : _v
#endif
@@ -62,7 +62,8 @@ static void DACenable(WorkMode *WorkModeData, int32_t VoltData ,uint8_t afterRea
case VT_CURVE:
case CYCLIC_VOLTAMMETRY:
case LINEAR_SWEEP_VOLTAMMETRY:
case CONSTANT_VSCAN:{
case CONSTANT_VSCAN:
case PULSE_MODE:{
break;
}
default:{
@@ -82,7 +83,8 @@ static void DACenable(WorkMode *WorkModeData, int32_t VoltData ,uint8_t afterRea
}
case IT_CURVE:
case VT_CURVE:
case CONSTANT_CURRENT:{
case CONSTANT_CURRENT:
case PULSE_MODE:{
break;
}
case CYCLIC_VOLTAMMETRY:{
@@ -142,6 +144,10 @@ static void CC_Plot(WorkMode *WorkModeData){
#define CURRENT_MODE WorkModeData->CVSCAN
break;
}
case PULSE_MODE:{
#define CURRENT_MODE WorkModeData->PULSE
break;
}
default: {
break;
}
@@ -279,6 +285,10 @@ static void IT_Plot(WorkMode *WorkModeData) {
#define CURRENT_MODE WorkModeData->CVSCAN
break;
}
case PULSE_MODE:{
#define CURRENT_MODE WorkModeData->PULSE
break;
}
default: {
break;
}
@@ -357,6 +367,10 @@ static void VT_Plot(WorkMode *WorkModeData) {
#define CURRENT_MODE WorkModeData->CVSCAN
break;
}
case PULSE_MODE:{
#define CURRENT_MODE WorkModeData->PULSE
break;
}
default: {
break;
}
@@ -440,6 +454,10 @@ static void readIin(WorkMode *WorkModeData){
#define TEMP_MODE WorkModeData->CVSCAN
break;
}
case PULSE_MODE:{
#define TEMP_MODE WorkModeData->PULSE
break;
}
default: {
break;
}
@@ -497,6 +515,10 @@ static int32_t readVinVout(WorkMode *WorkModeData){
#define TEMP_MODE WorkModeData->CVSCAN
break;
}
case PULSE_MODE:{
#define TEMP_MODE WorkModeData->PULSE
break;
}
default: {
break;
}
@@ -565,6 +587,10 @@ static void cali_IT_plot(WorkMode *WorkModeData) {
#define CURRENT_MODE WorkModeData->CVSCAN
break;
}
case PULSE_MODE:{
#define CURRENT_MODE WorkModeData->PULSE
break;
}
default: {
#define CURRENT_MODE WorkModeData->VT
break;
@@ -576,6 +602,7 @@ static void cali_IT_plot(WorkMode *WorkModeData) {
static int32_t ADCValueSUM = 0;
int32_t ADCValueAVG = 0;
int16_t ADCValueAVG_RAW = 0;
static uint16_t cali_count_max = 1000;
if(ADCSwitch == 0){ /**read Iin(buffer)**/
if(INSTRUCTION.AutoGainEnable){
@@ -588,6 +615,11 @@ static void cali_IT_plot(WorkMode *WorkModeData) {
record_flag = false;
}
}
if(INSTRUCTION.ADCGainLevel == 0) {
cali_count_max = 5000;
} else {
cali_count_max = 1000;
}
if(record_flag == false){
static int recordCount = 0;
@@ -598,7 +630,7 @@ static void cali_IT_plot(WorkMode *WorkModeData) {
}
}else{
static uint16_t cali_count = 0;
if(cali_count >= 1000){
if(cali_count >= cali_count_max){
ADCValueAVG = ADCValueSUM / cali_count;
InputNotify(NOTIFY_CURRENT, ADCValueAVG);
@@ -615,7 +647,6 @@ static void cali_IT_plot(WorkMode *WorkModeData) {
cali_count = 0;
PeriodicEvent = false;
ELITE15_SPI_CLOSE();
ModeLED(NO_EVENT);
}else{
cali_count++;
@@ -678,6 +709,10 @@ static void cali_VT_plot(WorkMode *WorkModeData) {
#define CURRENT_MODE WorkModeData->CVSCAN
break;
}
case PULSE_MODE:{
#define CURRENT_MODE WorkModeData->PULSE
break;
}
default: {
#define CURRENT_MODE WorkModeData->VT
break;
@@ -690,6 +725,7 @@ static void cali_VT_plot(WorkMode *WorkModeData) {
static int32_t ADCValueSUM = 0;
int32_t ADCValueAVG = 0;
int16_t ADCValueAVG_RAW = 0;
static uint16_t cali_count_max = 1000;
if(ADCSwitch == 0){ /**read Iin(buffer)**/
if(CURRENT_MODE->_VoViSwitch == 0x01 || CURRENT_MODE->_VoViSwitch == 0x02){
@@ -706,6 +742,12 @@ static void cali_VT_plot(WorkMode *WorkModeData) {
}
VoltData = CURRENT_MODE->_measureVin;
}
if(INSTRUCTION.VinADCGainLevel == 0) {
cali_count_max = 5000;
} else {
cali_count_max = 1000;
}
// else if(CURRENT_MODE->_VoViSwitch == 0x00){
// ReadADCVolt(CURRENT_MODE->_VoViSwitch);
// CURRENT_MODE->_measureVout = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
@@ -721,7 +763,7 @@ static void cali_VT_plot(WorkMode *WorkModeData) {
}
}else{
static uint16_t cali_count = 0;
if(cali_count >= 1000){
if(cali_count >= cali_count_max){
ADCValueAVG = ADCValueSUM / cali_count;
InputNotify(NOTIFY_VOLT, ADCValueAVG);
@@ -738,7 +780,6 @@ static void cali_VT_plot(WorkMode *WorkModeData) {
cali_count = 0;
PeriodicEvent = false;
ELITE15_SPI_CLOSE();
ModeLED(NO_EVENT);
}else{
cali_count++;
@@ -2,11 +2,11 @@
#ifndef VERSION_DATE
#define VERSION_DATE
#define VERSION_DATE_YEAR 20
#define VERSION_DATE_MONTH 9
#define VERSION_DATE_DAY 7
#define VERSION_DATE_HOUR 17
#define VERSION_DATE_MINUTE 58
#define VERSION_DATE_YEAR 21
#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
@@ -430,6 +430,12 @@ characteristic change event
#define SBP_KEY_CHANGE_EVT 0x0010
#endif
/**************************
controller version
EliteZM02 0,2,1,5
EliteZM15 0,2,1,6
EliteZM_pulsefly 0,2,1,7
**************************/
// product information
#define DEVICE_NAME "Elite"
#define MAJOR_PRODUCT_NUMBER 0 //0:Elite ,1:Neulive
@@ -483,13 +489,39 @@ struct _LH{
static void InitLH();
static void Init_Elite15_PIN();
/**
* LED initialize for TRIG01
*/
#define LED_BUFF_SIZE 20 // Elite = 28; TRIG01 = 20
struct _LED{
uint16_t LED_buf[LED_BUFF_SIZE];
} LED= {0};
static void InitLED();
static Clock_Struct periodicClock;
static bool PeriodicEvent = false;
static bool InitPeriodicEvent = true;
static bool megaStiEnable = false;
static ICall_Semaphore semaphore;
static uint16_t events;
/**
* Trigger channel initialize
*/
struct _TRC{ // Trigger Channel
bool chan_en[TRIG_CHAN_COUNT];
} TRC= {0};
static void InitTrigChan();
/* Trigger Flag */
static bool trig_PeriodicEvent = false;
static bool TRIG_TrigEnable = false;
static bool Trig_receive = false;
static bool trig0_event = false;
static bool trig1_event = false;
static bool FLT_event = false;
/*=====================================
==== headstage function prototype ====
====================================*/
@@ -550,6 +582,9 @@ static bool record_flag;
static bool vscanReset;
static bool EliteWorkReset;
static bool leadTimeReset;
static bool firstTimeReset;
//pulse mode variable
static bool stiFirstTime;
static int16_t I_GAIN_100R_counter;
static int16_t I_GAIN_3K_counter;
static int16_t I_GAIN_100K_counter;
@@ -566,6 +601,9 @@ static bool noEventLedFlag = 0;
static bool preWorkLedFlag = 0;
static bool workingLedFlag = 0;
static bool postWorkLedFlag = 0;
static bool TRIG01workFlag = 0;
static void update_latch_status (uint32_t latch_num, uint32_t elite_pin, bool highlow);
// ADC function
static int32_t DecodeADCValue(uint8_t ADCGain, uint8_t ADCChannel, uint8_t *ADC_raw);
@@ -573,10 +611,13 @@ static void headstage_battery_volt();
static void EliteADCBattery();
static void VinADCGainControl(uint8_t VinADCLevel);
static void VoutGainControl(uint8_t VOUTLevel);
static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool highlow);
static void latch_setOutputValue (uint32_t latch_num, bool highlow);
static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool highlow);
// Elite key detection & turn on/ shutdown function (peripheral hardware control)
static void Elite_led_color(uint16_t color);
static void Elite_chan_led_color(uint16_t color, uint8_t chan);
static void ModeLED(uint16_t modeStatus);
//static void LED_color(uint8_t bright, uint8_t red, uint8_t green, uint8_t blue);
static bool If10Von = false;
@@ -600,6 +641,7 @@ static void CalcuResistance(RTMode *RT, int32_t VoltData);
static uint16_t CV3Curve(CV3Mode *CV3);
static uint16_t LSVCurve(LSVMode *LSV);
static uint16_t CVSCANCurve(CVSCANMode *CVSCAN);
static void PULSE_Vscan(PULSEMode *PULSE);
//mode (notify)
static void initDATBuf();
@@ -624,6 +666,7 @@ static void InitEliteFlag();
#include "EliteNotify.h"
#include "EliteFlagCTInit.h"
#include "EliteLatchInit.h"
#include "EliteLEDInit.h"
#include "EliteReset.h"
#include "EliteLED.h"
#include "EliteKeyDetect.h"
@@ -633,11 +676,13 @@ static void InitEliteFlag();
#include "EliteCVCurve.h"
#include "EliteZTCurve.h"
#include "EliteCCCMode.h"
#include "Elite_TRIG.h"
#include "impedance_meter.h"
#include "Elite_version.h"
#include "EliteCV3Mode.h"
#include "EliteLSVMode.h"
#include "EliteCVSCANMode.h"
#include "ElitePulseMode.h"
#include "Elite_batt.h"
#include "Elite_power.h"
@@ -654,7 +699,7 @@ static void update_ZM_instruction(uint8 *ins) {
switch (ins[2]) {
case IV_CURVE: {
ModeLED(WORKING);
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
INSTRUCTION.eliteFxn = IV_CURVE;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.Ve1 = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
@@ -671,12 +716,19 @@ static void update_ZM_instruction(uint8 *ins) {
INSTRUCTION.VsetRate = VsetRateTable[INSTRUCTION.VsetRateIndex];//N
INSTRUCTION.VoViSwitch = 0x01;
INSTRUCTION.cycleNumber = 1;
if((INSTRUCTION.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && INSTRUCTION.Ve1 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE)
&& (INSTRUCTION.Ve2 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && INSTRUCTION.Ve2 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE)){
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
} else {
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
}
break;
}
case CV_CURVE: {
ModeLED(WORKING);
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
INSTRUCTION.eliteFxn = CV_CURVE;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.Ve1 = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
@@ -693,27 +745,47 @@ static void update_ZM_instruction(uint8 *ins) {
INSTRUCTION.VsetRate = VsetRateTable[INSTRUCTION.VsetRateIndex];//N
INSTRUCTION.VoViSwitch = 0x01;
INSTRUCTION.cycleNumber = ins[10];
if((INSTRUCTION.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && INSTRUCTION.Ve1 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE)
&& (INSTRUCTION.Ve2 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && INSTRUCTION.Ve2 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE)){
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
}else{
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
}
break;
}
case VOLT_OUTPUT: {
ModeLED(WORKING);
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
INSTRUCTION.eliteFxn = VOLT_OUTPUT;
INSTRUCTION.VoltConstant = ( ((uint16_t)(ins[3])) << 8) | (uint16_t)(ins[4]);
AutoGainChangeVout((int32_t)INSTRUCTION.VoltConstant);
if(INSTRUCTION.VoltConstant < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && INSTRUCTION.VoltConstant > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE){
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
} else {
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
}
break;
}
case ZT_CURVE: {
ModeLED(WORKING);
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
INSTRUCTION.eliteFxn = ZT_CURVE;
INSTRUCTION.notifyRate = (uint32_t)INSTRUCTION.sampleRate;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.VsetRate = 100;
INSTRUCTION.VoltConstant = 25000 + 5000;
INSTRUCTION.VoViSwitch = 0x01;
INSTRUCTION.ADCGainLevel = I_GAIN_AUTO;
INSTRUCTION.VinADCGainLevel = VIN_GAIN_AUTO;
if(INSTRUCTION.VoltConstant < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && INSTRUCTION.VoltConstant > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE){
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
} else {
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
}
break;
}
@@ -735,9 +807,9 @@ static void update_ZM_instruction(uint8 *ins) {
break;
}
case CONSTANT_CURRENT:{
case CONSTANT_CURRENT: {
ModeLED(WORKING);
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.charge = ins[3]; //0:discharge 1:charge
@@ -746,6 +818,8 @@ static void update_ZM_instruction(uint8 *ins) {
INSTRUCTION.Vmin = (uint32_t)(ins[10]) << 8 | (uint32_t)(ins[11]);
INSTRUCTION.notifyRate = 500;
INSTRUCTION.VoViSwitch = 0x01;
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
/*******************************************************
controller instruction
ins[3] -> Charge, 0:discharge 1:charge
@@ -755,20 +829,20 @@ static void update_ZM_instruction(uint8 *ins) {
}
case CYCLIC_VOLTAMMETRY: {
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
if(ins[3] == PARA_1){
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
if (ins[3] == PARA_1) {
INSTRUCTION.sampleRate = 15;
INSTRUCTION.Vinit = ((int32_t)(ins[4]) << 8) | (int32_t)(ins[5]);
INSTRUCTION.Ve1 = ((uint16_t)(ins[6]) << 8) | (uint16_t)(ins[7]);
INSTRUCTION.Ve2 = ((uint16_t)(ins[8]) << 8) | (uint16_t)(ins[9]);
INSTRUCTION.Vmax = (int32_t)VMAX(INSTRUCTION.Ve1,INSTRUCTION.Ve2);
INSTRUCTION.Vmin = (int32_t)VMIN(INSTRUCTION.Ve1,INSTRUCTION.Ve2);
if(INSTRUCTION.Vinit > INSTRUCTION.Ve1 || INSTRUCTION.Vinit == INSTRUCTION.Vmax){
if (INSTRUCTION.Vinit > INSTRUCTION.Ve1 || INSTRUCTION.Vinit == INSTRUCTION.Vmax){
INSTRUCTION.directionInit = 0;//0:reverse 1:forward
}else if(INSTRUCTION.Vinit <= INSTRUCTION.Ve1 || INSTRUCTION.Vinit == INSTRUCTION.Vmin){
} else if (INSTRUCTION.Vinit <= INSTRUCTION.Ve1 || INSTRUCTION.Vinit == INSTRUCTION.Vmin){
INSTRUCTION.directionInit = 1;
}
}else if(ins[3] == PARA_2){
} else if (ins[3] == PARA_2) {
ModeLED(WORKING);
INSTRUCTION.eliteFxn = CYCLIC_VOLTAMMETRY;
INSTRUCTION.Currentmax = (int32_t)(ins[10]) << 24 | (int32_t)(ins[11]) << 16 | (int32_t)(ins[12]) << 8 | (int32_t)(ins[13]);
@@ -780,13 +854,15 @@ static void update_ZM_instruction(uint8 *ins) {
INSTRUCTION.VsetRate = VsetRateTable[INSTRUCTION.VsetRateIndex];//N
INSTRUCTION.VoViSwitch = 0x01;
INSTRUCTION.cycleNumber = ins[14];
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
}
break;
}
case HIGH_CYCLE_CYCLIC_VOLTAMMETRY: {
ModeLED(WORKING);
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
INSTRUCTION.eliteFxn = CYCLIC_VOLTAMMETRY;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.Vinit = ((int32_t)(ins[3]) << 8) | (int32_t)(ins[4]);
@@ -794,9 +870,9 @@ static void update_ZM_instruction(uint8 *ins) {
INSTRUCTION.Ve2 = ((uint16_t)(ins[7]) << 8) | (uint16_t)(ins[8]);
INSTRUCTION.Vmax = (int32_t)VMAX(INSTRUCTION.Ve1,INSTRUCTION.Ve2);
INSTRUCTION.Vmin = (int32_t)VMIN(INSTRUCTION.Ve1,INSTRUCTION.Ve2);
if(INSTRUCTION.Vinit > INSTRUCTION.Ve1 || INSTRUCTION.Vinit == INSTRUCTION.Vmax){
if (INSTRUCTION.Vinit > INSTRUCTION.Ve1 || INSTRUCTION.Vinit == INSTRUCTION.Vmax){
INSTRUCTION.directionInit = 0;//0:reverse 1:forward
}else if(INSTRUCTION.Vinit <= INSTRUCTION.Ve1 || INSTRUCTION.Vinit == INSTRUCTION.Vmin){
} else if (INSTRUCTION.Vinit <= INSTRUCTION.Ve1 || INSTRUCTION.Vinit == INSTRUCTION.Vmin){
INSTRUCTION.directionInit = 1;
}
INSTRUCTION.Currentmax = (int32_t)(ins[15]) << 24 | (int32_t)(ins[16]) << 16 | (int32_t)(ins[17]) << 8 | (int32_t)(ins[18]);
@@ -808,12 +884,14 @@ static void update_ZM_instruction(uint8 *ins) {
INSTRUCTION.VsetRate = VsetRateTable[INSTRUCTION.VsetRateIndex];//N
INSTRUCTION.VoViSwitch = 0x01;
INSTRUCTION.cycleNumber = ins[19] * 100;
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
break;
}
case LINEAR_SWEEP_VOLTAMMETRY:{
case LINEAR_SWEEP_VOLTAMMETRY: {
ModeLED(WORKING);
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
INSTRUCTION.eliteFxn = LINEAR_SWEEP_VOLTAMMETRY;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.Ve1 = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
@@ -831,12 +909,14 @@ static void update_ZM_instruction(uint8 *ins) {
INSTRUCTION.VsetRate = VsetRateTable[INSTRUCTION.VsetRateIndex];//N
INSTRUCTION.VoViSwitch = 0x01;
INSTRUCTION.cycleNumber = 1;//ins[17];
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
break;
}
case CONSTANT_VSCAN:{
case CONSTANT_VSCAN: {
ModeLED(WORKING);
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
INSTRUCTION.eliteFxn = CONSTANT_VSCAN;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.Vinit = ((int32_t)(ins[3]) << 8) | (int32_t)(ins[4]);
@@ -844,10 +924,12 @@ static void update_ZM_instruction(uint8 *ins) {
INSTRUCTION.notifyRate = 10000 / INSTRUCTION.notifyRate * 10;
INSTRUCTION.VsetRate = VsetRateTable[0];
INSTRUCTION.VoViSwitch = 0x01;
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
break;
}
case CYCLE_CONSTANT_CURRENT:{
case CYCLE_CONSTANT_CURRENT: {
break;
}
@@ -930,29 +1012,31 @@ static void update_ZM_instruction(uint8 *ins) {
case SET_ADC_DAC_GAIN: {
switch(ins[3]){
case IIN_ADC :{
case IIN_ADC : {
INSTRUCTION.ADCGainLevel = ins[4];
if(INSTRUCTION.ADCGainLevel != I_GAIN_AUTO){
if (INSTRUCTION.ADCGainLevel != I_GAIN_AUTO) {
INSTRUCTION.AutoGainEnable = 0;
}
else{
} else {
INSTRUCTION.AutoGainEnable = 1;
INSTRUCTION.ADCGainLevel = I_GAIN_100R;
IinADCGainControl(INSTRUCTION.ADCGainLevel);
record_flag = false;
}
break;
}
case VIN_ADC :{
case VIN_ADC : {
INSTRUCTION.VinADCGainLevel = ins[4];
if(INSTRUCTION.VinADCGainLevel != VIN_GAIN_AUTO){
if (INSTRUCTION.VinADCGainLevel != VIN_GAIN_AUTO) {
INSTRUCTION.VinAutoGainEnable = 0;
}
else{
} else {
INSTRUCTION.VinAutoGainEnable = 1;
INSTRUCTION.VinADCGainLevel = VIN_GAIN_1K;
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
record_flag = false;
}
break;
}
case VOUT_DAC :{
case VOUT_DAC : {
// INSTRUCTION.VoutGainLevel = ins[4];
// if(INSTRUCTION.VoutGainLevel == VOUT_GAIN_AUTO){
// INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
@@ -961,17 +1045,17 @@ static void update_ZM_instruction(uint8 *ins) {
VoutGainControl(INSTRUCTION.VoutGainLevel);
break;
}
case HIGH_Z :{
case HIGH_Z : {
switch(ins[4]) {
case 0x00 :{
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0 => open high_z mode
case 0x00 : {
// PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0 => open high_z mode
break;
}
case 0x01 :{
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
case 0x01 : {
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
break;
}
default :{
default : {
break;
}
}
@@ -984,67 +1068,160 @@ static void update_ZM_instruction(uint8 *ins) {
break;
}
case ADC_TEST: {
case SET_EN_CHAN: { // 0x81
InitTrigChan();
INSTRUCTION.tri_pr0 = (bool) ((ins[3] & 0xF0) >> 4);
INSTRUCTION.tri_d0 = (bool) (ins[3] & 0x0F);
INSTRUCTION.tri_a0 = (bool) ((ins[4] & 0xF0) >> 4);
INSTRUCTION.tri_a2 = (bool) (ins[4] & 0x0F);
INSTRUCTION.tri_a3 = (bool) ((ins[5] & 0xF0) >> 4);
INSTRUCTION.tri_a1 = (bool) (ins[5] & 0x0F);
INSTRUCTION.tri_d1 = (bool) ((ins[6] & 0xF0) >> 4);
INSTRUCTION.tri_pr1 = (bool) (ins[6] & 0x0F);
INSTRUCTION.output_5v_en0 = (bool) ((ins[7] & 0xF0) >> 4);
INSTRUCTION.output_5v_en1 = (bool) (ins[7] & 0x0F);;
if(!INSTRUCTION.output_5v_en0) { // if 5V enable, auto disable DOUT
INSTRUCTION.tri_d0 = 0;
}
if(!INSTRUCTION.output_5v_en1) {
INSTRUCTION.tri_d1 = 0;
}
TRC.chan_en[0] = INSTRUCTION.tri_pr0;
TRC.chan_en[1] = INSTRUCTION.tri_d0;
TRC.chan_en[2] = INSTRUCTION.tri_a0;
TRC.chan_en[3] = INSTRUCTION.tri_a2;
TRC.chan_en[4] = INSTRUCTION.tri_a3;
TRC.chan_en[5] = INSTRUCTION.tri_a1;
TRC.chan_en[6] = INSTRUCTION.tri_d1;
TRC.chan_en[7] = INSTRUCTION.tri_pr1;
TRC.chan_en[8] = INSTRUCTION.output_5v_en0;
TRC.chan_en[9] = INSTRUCTION.output_5v_en1;
SET_LED_CHAN(TRC.chan_en, NO_EVENT);
// set_output_enable(TRC.chan_en);
break;
}
case ADC_TEST: { // 0x91
INSTRUCTION.eliteFxn = ADC_TEST;
set_output_enable(TRC.chan_en);
// int32_t ADCRealValue = 0;
uint8_t CIS_buf[9] = {0};
uint16_t ADCValueAVG_RAW = 0;
uint8_t ADC_input = 0;
bool AVG_done = 0;
uint16_t TW1508in = 0;
TW1508in = (((uint16_t) (ins[5])) << 8 ) | ((uint16_t) (ins[6]));
// ModeLED(TRIG01_WORK);
switch(ins[3]) {
case IIN_ADC :{ // 0x00
IinADCGainControl(ins[4]);
AVG_done = 1;
ADC_input = CMD_CURRENT_MEASURE;
case AOUT_ADC :{ // 0x00
ModeLED(TRIG01_WORK);
if(ins[4] == 0xFF) {
TW1508reset();
}
else {
GPIO_SPI_write(ins[4], TW1508in); // GPIOin = 0x0000 ~ 0x03FF
}
break;
}
case VIN_ADC :{ // 0x01
VinADCGainControl(ins[4]);
AVG_done = 1;
ADC_input = CMD_VOLT_MEASURE;
break;
}
case VOUT_DAC :{ // 0x02
VoutGainControl(ins[4]);
AVG_done = 0;
break;
}
case HIGH_Z :{ // 0x03
switch(ins[4]) {
case DOUT_ADC :{ // 0x01
switch (ins[4]) {
case 0x00 :{
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0 => open high_z mode
PIN15_setOutputValue(DO_MOS_0, 0);
break;
}
case 0x01 :{
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
PIN15_setOutputValue(DO_MOS_0, 1);
break;
}
case 0x10 :{
PIN15_setOutputValue(DO_MOS_1, 0);
break;
}
case 0x11 :{
PIN15_setOutputValue(DO_MOS_1, 1);
break;
}
default :{
PIN15_setOutputValue(DO_MOS_0, 0);
PIN15_setOutputValue(DO_MOS_0, 0);
break;
}
}
break;
}
case PR_DAC :{ // 0x02
switch (ins[4]) {
case 0x00 :{
PIN15_setOutputValue(DO_PR_0, 0);
break;
}
case 0x01 :{
PIN15_setOutputValue(DO_PR_0, 1);
break;
}
case 0x10 :{
PIN15_setOutputValue(DO_PR_0, 0);
break;
}
case 0x11 :{
PIN15_setOutputValue(DO_PR_0, 1);
break;
}
default :{
PIN15_setOutputValue(DO_PR_0, 0);
PIN15_setOutputValue(DO_PR_0, 0);
break;
}
}
break;
}
case LEDtest :{ // 0x03
// update_LED_status(0x00,DARKLED, 0xA0, 0x00, 0x00);
// update_LED_status(0x01,DARKLED, 0x90, 0x50, 0x00);
// update_LED_status(0x02,DARKLED, 0x90, 0x90, 0x00);
// update_LED_status(0x03,DARKLED, 0x00, 0xf0, 0x00);
// update_LED_status(0x04,DARKLED, 0x00, 0x00, 0xff);
// update_LED_status(0x05,DARKLED, 0x20, 0x00, 0xf0);
// update_LED_status(0x06,DARKLED, 0x90, 0x00, 0xf0);
// update_LED_status(0x07,DARKLED, 0x20, 0x20, 0xa0);
// refresh_LED();
break;
}
case OUT_5V_EN :{ // 0x04
switch (ins[4]) {
case 0x00 :{
PIN15_setOutputValue(OUT_5V_EN_0, 0); // 0 => enable 5V output
break;
}
case 0x01 :{
PIN15_setOutputValue(OUT_5V_EN_0, 1); // 1 => disable 5V output
break;
}
case 0x10 :{
PIN15_setOutputValue(OUT_5V_EN_1, 0);
break;
}
case 0x11 :{
PIN15_setOutputValue(OUT_5V_EN_1, 1);
break;
}
default :{
PIN15_setOutputValue(OUT_5V_EN_0, 1);
PIN15_setOutputValue(OUT_5V_EN_1, 1);
break;
}
}
AVG_done = 0;
break;
}
default :{
AVG_done = 0;
break;
}
}
if (AVG_done) {
ELITE15_SPI_HOLD(); // Open SPI as early as possible
CPUdelay(100);
ADCValueAVG_RAW = ADC_CURRENT_AVG_calibration(ADC_input);
ELITE15_SPI_CLOSE(); // Close SPI
} else {
AVG_done = 0;
for (int i = 1; i < 9; i++) {
CIS_buf[i + 1] = 0x00;
}
}
CIS_buf[0] = chip_ID;
CIS_buf[1] = (uint8_t) ((ADCValueAVG_RAW & 0xFF00) >> 8);
CIS_buf[2] = (uint8_t) (ADCValueAVG_RAW & 0x00FF);
@@ -1078,7 +1255,7 @@ static void update_ZM_instruction(uint8 *ins) {
break;
}
/*
case CALI_DAC_MODE: {
ModeLED(WORKING);
INSTRUCTION.eliteFxn = CALI_DAC_MODE;
@@ -1089,7 +1266,7 @@ static void update_ZM_instruction(uint8 *ins) {
case CALI_ADC_MODE: {
switch(ins[3]) {
case IIN_ADC :{ // 0x00
case IIN_ADC : { // 0x00
INSTRUCTION.eliteFxn = CALI_ADC_MODE;
INSTRUCTION.AdcChannel = IIN_ADC;
INSTRUCTION.notifyRate = 1000;
@@ -1098,7 +1275,7 @@ static void update_ZM_instruction(uint8 *ins) {
ModeLED(WORKING);
break;
}
case VIN_ADC :{ // 0x01
case VIN_ADC : { // 0x01
INSTRUCTION.eliteFxn = CALI_ADC_MODE;
INSTRUCTION.AdcChannel = VIN_ADC;
INSTRUCTION.notifyRate = 1000;
@@ -1107,13 +1284,56 @@ static void update_ZM_instruction(uint8 *ins) {
ModeLED(WORKING);
break;
}
default :{
default : {
break;
}
}
break;
}
*/
case PULSE_MODE: {
// INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.notifyRate = 100;
INSTRUCTION.VoViSwitch = 0x01;
if (ins[3] == PARA_1) {
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode // no HIGH_Z for TRIG01
INSTRUCTION.sti_t1 = (int32_t)(ins[4]) << 24 | (int32_t)(ins[5]) << 16 | (int32_t)(ins[6]) << 8 | (int32_t)(ins[7]);
INSTRUCTION.sti_t2 = (int32_t)(ins[8]) << 24 | (int32_t)(ins[9]) << 16 | (int32_t)(ins[10]) << 8 | (int32_t)(ins[11]);
INSTRUCTION.sti_t3 = (int32_t)(ins[12]) << 24 | (int32_t)(ins[13]) << 16 | (int32_t)(ins[14]) << 8 | (int32_t)(ins[15]);
INSTRUCTION.sti_t4 = (int32_t)(ins[16]) << 24 | (int32_t)(ins[17]) << 16 | (int32_t)(ins[18]) << 8 | (int32_t)(ins[19]);
} else if (ins[3] == PARA_2) {
INSTRUCTION.sti_t5 = (int32_t)(ins[4]) << 24 | (int32_t)(ins[5]) << 16 | (int32_t)(ins[6]) << 8 | (int32_t)(ins[7]);
INSTRUCTION.sti_v1 = 25000; //8~11
INSTRUCTION.sti_v2 = 50000; //12~15 //41406.43161.
INSTRUCTION.sti_v3 = 25000; //16~19
} else if (ins[3] == PARA_3) {
INSTRUCTION.sti_v4 = 25000; //4~7
INSTRUCTION.sti_v5 = 25000; //8~11
INSTRUCTION.sti_cy = (uint16_t)(ins[12]); //12
INSTRUCTION.sti_loop = (uint16_t)(ins[13]); //13
} else if (ins[3] == PARA_4) {
INSTRUCTION.sti_t6 = (int32_t)(ins[4]) << 24 | (int32_t)(ins[5]) << 16 | (int32_t)(ins[6]) << 8 | (int32_t)(ins[7]); //4~7
INSTRUCTION.sti_t7 = (int32_t)(ins[8]) << 24 | (int32_t)(ins[9]) << 16 | (int32_t)(ins[10]) << 8 | (int32_t)(ins[11]); //8~11
INSTRUCTION.sti_v6 = 25000; //12~15
INSTRUCTION.sti_v7 = 25000;; //16~19
INSTRUCTION.sti_t1 = VALUE_ZERO_TO_ONE(INSTRUCTION.sti_t1);
INSTRUCTION.sti_t2 = VALUE_ZERO_TO_ONE(INSTRUCTION.sti_t2);
INSTRUCTION.sti_t3 = VALUE_ZERO_TO_ONE(INSTRUCTION.sti_t3);
INSTRUCTION.sti_t4 = VALUE_ZERO_TO_ONE(INSTRUCTION.sti_t4);
INSTRUCTION.sti_t5 = VALUE_ZERO_TO_ONE(INSTRUCTION.sti_t5);
INSTRUCTION.sti_t6 = VALUE_ZERO_TO_ONE(INSTRUCTION.sti_t6);
INSTRUCTION.sti_t7 = VALUE_ZERO_TO_ONE(INSTRUCTION.sti_t7);
megaStiEnable = true;
} else if (ins[3] == PARA_17) {
INSTRUCTION.eliteFxn = PULSE_MODE;
set_output_enable(TRC.chan_en);
// ModeLED(WORKING);
ModeLED(TRIG01_WORK);
}
break;
}
default: {
/** **/
break;
@@ -1140,12 +1360,11 @@ static void update_ZM_instruction(uint8 *ins) {
}
case VIS_STI: {
for(int i=0 ; i<12 ; i++){
for(int i = 0; i < 12; i++) {
FlushNotify();
}
PeriodicEvent = true;
InitEliteFlag();
ELITE15_SPI_HOLD();
break;
}
@@ -1155,18 +1374,14 @@ static void update_ZM_instruction(uint8 *ins) {
}
case VIS_INT: {
if(PeriodicEvent){
ELITE15_SPI_CLOSE();
}
Eliteinterrupt();
for(int i=0 ; i<12 ; i++){
for (int i = 0; i < 12; i++) {
FlushNotify();
}
break;
}
case VIS_DEVICE_SHINY:{
case VIS_DEVICE_SHINY: {
Elite_led_color(COLOR_PURPLE);
// uint8_t deviceShinySwitch = (ins[2] & 0b11110000) >> 4;//1:open 0:close
// if(deviceShinySwitch == 1){
@@ -1181,18 +1396,18 @@ static void update_ZM_instruction(uint8 *ins) {
break;
}
case VIS_SHINY_DIS:{
if(PeriodicEvent){
case VIS_SHINY_DIS: {
if (PeriodicEvent) {
WORKLED();
}else if(!PeriodicEvent){
} else if (!PeriodicEvent) {
LEDPowerON();
}
break;
}
case VIS_CC_ZERO:{
case VIS_CC_ZERO: {
ModeLED(PRE_WORK);
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.charge = 0x01;
@@ -1201,6 +1416,14 @@ static void update_ZM_instruction(uint8 *ins) {
INSTRUCTION.Vmin = 0x0000;
INSTRUCTION.notifyRate = 500;
INSTRUCTION.VoViSwitch = 0x02;//read Vscan = Vout - Vin
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
break;
}
case VIS_TRIG_EN: { // 0x41
INSTRUCTION.trig0_en = (bool) ((ins[2] & 0xF0) >> 4);
INSTRUCTION.trig1_en = (bool) (ins[2] & 0x0F);
trig_en_check();
break;
}
@@ -1218,7 +1441,7 @@ static void update_ZM_instruction(uint8 *ins) {
break;
}
case CIS_VERSION:{
case CIS_VERSION: {
initCISBuf();
cis_buf[0] = VERSION_DATE_YEAR;
cis_buf[1] = VERSION_DATE_MONTH;
@@ -1239,11 +1462,11 @@ static void update_ZM_instruction(uint8 *ins) {
}
case CIS_LED_TEST: { //0x7070
if( ins[2] == 0 ){
if (ins[2] == 0) {
Elite_led_color(ins[3]);
}else if( ins[2] == 1 ){
} else if (ins[2] == 1) {
LED_color(LIGHTLED, ins[3], ins[4], ins[5]);
}else if( ins[2] == 2 ){
} else if (ins[2] == 2) {
LED_color(DARKLED, ins[3], ins[4], ins[5]);
}
break;
@@ -46,15 +46,18 @@ static void ZM_init() {
// initialize
pin_handle = PIN_open(&ZM_rst, BLE_IO);
InitLED();
InitTrigChan();
Init_Elite15_PIN();
ELITE15_SPI_HOLD();
PIN15_setOutputValue(shutdown_6994, 1); // OFF = 1 => turn off 6994
PIN15_setOutputValue(enable_10v, 0); // enable 10V
PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
PIN15_setOutputValue(DAC_CS, 1); // DAC_CS HIGH
PIN15_setOutputValue(MEM_CS, 1); // MEM_CS HIGH
PIN15_setOutputValue(HIGH_Z_MODE, 0); // HIGH Z MODE
// 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();
IinADCGainControl(INSTRUCTION.ADCGainLevel);
@@ -62,6 +65,8 @@ static void ZM_init() {
VoutGainControl(INSTRUCTION.VoutGainLevel);
elite_gptimer_open();
TW1508reset();
// TRIG_LED_Init();
// PIN_registerIntCb(pin_handle, switch_on_callback);
// PIN_setInterrupt(pin_handle, switch_on | PIN_IRQ_POSEDGE);
}
@@ -122,6 +127,7 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
EliteWorkReset = false;
batteryADC_flag = false;
record_flag = true;
firstTimeReset = true;
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
IinADCGainControl(INSTRUCTION.ADCGainLevel);
VoutGainControl(INSTRUCTION.VoutGainLevel);
@@ -129,7 +135,6 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
if (INSTRUCTION.Ve1 == INSTRUCTION.Ve2) {
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.Ve1));
PeriodicEvent = false;
ELITE15_SPI_CLOSE();
ModeLED(NO_EVENT);
}
}
@@ -204,20 +209,136 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
}
// EliteDone();
}else if(INSTRUCTION.eliteFxn == VOLT_OUTPUT){
}
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;
ELITE15_SPI_CLOSE();
}else if(INSTRUCTION.eliteFxn == CALI_DAC_MODE){
}
else if(INSTRUCTION.eliteFxn == CALI_DAC_MODE){
DAC_outputV(INSTRUCTION.VoltConstant); //UserCode -> DAC code -> DAC out
FreeWorkMode(WorkModeData);
PeriodicEvent = false;
ELITE15_SPI_CLOSE();
}
else{
InitFlag();
// InitFlag();
}
}
@@ -268,6 +389,10 @@ static void EliteADCControl(WorkMode *WorkModeData) {
break;
}
case PULSE_MODE:{
CC_Plot(WorkModeData);
break;
}
default:{
break;
}
@@ -313,6 +438,10 @@ static void EliteVscanControl(WorkMode *WorkModeData) {
CVSCAN_Vscan(WorkModeData->CVSCAN);
break;
}
case PULSE_MODE:{
// PULSE_Vscan(WorkModeData->PULSE);
break;
}
default:{
break;
}
@@ -546,17 +546,18 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
// Initialize application
SimpleBLEPeripheral_init();
ZM_init();
// Elite_SPI_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;
// init DAC, set output ~= 0 V
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
elite_gptimer_start();
// Application main loops
@@ -617,27 +618,35 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
if (!PeriodicEvent) { // if there is no periodic event
key = PIN_getInputValue(switch_on);
if (EliteOn) {
if (counter6994 < CLOCK_ONE_SECOND/2) { // counter6994 enable a IC after 35 counts
if (counter6994 < CLOCK_ONE_SECOND*5) { // counter6994 enable a IC after 35 counts
counter6994++;
} else if (counter6994 == CLOCK_ONE_SECOND/2) {
PIN15_setOutputValue(shutdown_6994, 1); // OFF = 1 => turn off 6994
} else if (counter6994 == CLOCK_ONE_SECOND*5) {
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(Free_Work_Mode){
FreeWorkMode(WorkModeData);
InitEliteInstruction();
IinADCGainControl(INSTRUCTION.ADCGainLevel);
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
Free_Work_Mode = false;
}
} else {
EliteOn = TurnOnElite(key);
}
trig_sense();
if (trig_PeriodicEvent) {
trig_PeriodicEvent = false;
PeriodicEvent = true;
}
}
else { // if there is periodic event
if(InitPeriodicEvent){
@@ -975,6 +984,7 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
case GAPROLE_WAITING_AFTER_TIMEOUT:
SimpleBLEPeripheral_freeAttRsp(bleNotConnected);
ModeLED(BT_WAIT);
#ifdef PLUS_BROADCASTER
// Reset flag for next connection.