Compare commits

..

38 Commits

Author SHA1 Message Date
Benny Liu 63310bdd03 cali_count_max = 5000 for smallest Vin and Iin gain 2020-12-17 12:38:38 +08:00
Benny Liu 1954ff8d9e Add calibration count from 1000 to 5000. 2020-12-03 14:36:31 +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
26 changed files with 1827 additions and 845 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 @@ 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.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/
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.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
@@ -106,7 +106,7 @@ extern const PIN_Config BoardGpioInitTable[];
#define Board_BP_Pin_J2_15 DIO8 /* MOSI */
#define Board_BP_Pin_J2_14 DIO7 /* MISO */
#define Board_BP_Pin_J2_13 DIO9 /* DAC_CS */
#define Board_BP_Pin_J2_12 DIO12 /* AD_CS */
#define Board_BP_Pin_J2_12 DIO12 /* ADC_CS */
#define Board_BP_Pin_J2_11 IOID_UNUSED /* NC */
/* Mapping of BoosterPack Connector Pins to BoosterPack Standard Functions (reflecting the BoosterPack Standard)
@@ -0,0 +1,246 @@
#ifndef Elite15_PIN
#define Elite_15PIN
#include "Elite_PIN.h"
static void update_latch_status (uint32_t latch_num, uint32_t elite_pin, bool highlow) {
switch (latch_num) {
case LOAD0: {
switch (elite_pin) {
case D0: {
LH.LATCH0[0] = highlow;
break;
}
case D1: {
LH.LATCH0[1] = highlow;
break;
}
case D2: {
LH.LATCH0[2] = highlow;
break;
}
case D3: {
LH.LATCH0[3] = highlow;
break;
}
case D4: {
LH.LATCH0[4] = highlow;
break;
}
case D5: {
LH.LATCH0[5] = highlow;
break;
}
case D6: {
LH.LATCH0[6] = highlow;
break;
}
case D7: {
LH.LATCH0[7] = highlow;
break;
}
default: {
break;
}
}
break;
}
case LOAD1: {
switch (elite_pin) {
case D0: {
LH.LATCH1[0] = highlow;
break;
}
case D1: {
LH.LATCH1[1] = highlow;
break;
}
case D2: {
LH.LATCH1[2] = highlow;
break;
}
case D3: {
LH.LATCH1[3] = highlow;
break;
}
case D4: {
LH.LATCH1[4] = highlow;
break;
}
case D5: {
LH.LATCH1[5] = highlow;
break;
}
case D6: {
LH.LATCH1[6] = highlow;
break;
}
case D7: {
LH.LATCH1[7] = highlow;
break;
}
default: {
break;
}
}
break;
}
case LOAD2: {
switch (elite_pin) {
case D0: {
LH.LATCH2[0] = highlow;
break;
}
case D1: {
LH.LATCH2[1] = highlow;
break;
}
case D2: {
LH.LATCH2[2] = highlow;
break;
}
case D3: {
LH.LATCH2[3] = highlow;
break;
}
case D4: {
LH.LATCH2[4] = highlow;
break;
}
case D5: {
LH.LATCH2[5] = highlow;
break;
}
case D6: {
LH.LATCH2[6] = highlow;
break;
}
case D7: {
LH.LATCH2[7] = highlow;
break;
}
default: {
break;
}
}
break;
}
default: {
break;
}
}
}
static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool highlow) {
ELITE15_SPI_CLOSE();
add_elite_pin();
update_latch_status (latch_num, pin_num, highlow);
// PIN_setOutputValue(&ZM_rst, latch_num, 1); // Turn on latch
switch (latch_num) {
case LOAD0: {
// PIN_setOutputValue(&ZM_rst, D0, LH.LATCH0[0]);
// PIN_setOutputValue(&ZM_rst, D1, LH.LATCH0[1]);
// PIN_setOutputValue(&ZM_rst, D2, LH.LATCH0[2]);
// PIN_setOutputValue(&ZM_rst, D3, LH.LATCH0[3]);
PIN_setOutputValue(pin_handle, D4, LH.LATCH0[4]);
PIN_setOutputValue(pin_handle, D5, LH.LATCH0[5]);
PIN_setOutputValue(pin_handle, D6, LH.LATCH0[6]);
PIN_setOutputValue(pin_handle, D7, LH.LATCH0[7]);
break;
}
case LOAD1: {
PIN_setOutputValue(pin_handle, D0, LH.LATCH1[0]);
PIN_setOutputValue(pin_handle, D1, LH.LATCH1[1]);
PIN_setOutputValue(pin_handle, D2, LH.LATCH1[2]);
PIN_setOutputValue(pin_handle, D3, LH.LATCH1[3]);
PIN_setOutputValue(pin_handle, D4, LH.LATCH1[4]);
PIN_setOutputValue(pin_handle, D5, LH.LATCH1[5]);
PIN_setOutputValue(pin_handle, D6, LH.LATCH1[6]);
PIN_setOutputValue(pin_handle, D7, LH.LATCH1[7]);
break;
}
case LOAD2: {
PIN_setOutputValue(pin_handle, D0, LH.LATCH2[0]);
PIN_setOutputValue(pin_handle, D1, LH.LATCH2[1]);
PIN_setOutputValue(pin_handle, D2, LH.LATCH2[2]);
PIN_setOutputValue(pin_handle, D3, LH.LATCH2[3]);
PIN_setOutputValue(pin_handle, D4, LH.LATCH2[4]);
PIN_setOutputValue(pin_handle, D5, LH.LATCH2[5]);
PIN_setOutputValue(pin_handle, D6, LH.LATCH2[6]);
PIN_setOutputValue(pin_handle, D7, LH.LATCH2[7]);
break;
}
default: {
break;
}
}
PIN_setOutputValue(&ZM_rst, latch_num, 1); // Turn on latch
CPUdelay(10);
PIN_setOutputValue(&ZM_rst, latch_num, 0); // Turn off latch
remove_elite_pin();
ELITE15_SPI_HOLD();
}
static void Init_Elite15_PIN () {
InitLH();
add_elite_pin();
PIN_setOutputValue(pin_handle, D0, 0);
PIN_setOutputValue(pin_handle, D1, 0);
PIN_setOutputValue(pin_handle, D2, 0);
PIN_setOutputValue(pin_handle, D3, 0);
PIN_setOutputValue(pin_handle, D4, 0);
PIN_setOutputValue(pin_handle, D5, 0);
PIN_setOutputValue(pin_handle, D6, 0);
PIN_setOutputValue(pin_handle, D7, 0);
PIN_setOutputValue(pin_handle, LOAD0, 0);
PIN_setOutputValue(pin_handle, LOAD1, 1);
PIN_setOutputValue(pin_handle, LOAD2, 1);
CPUdelay(10);
PIN_setOutputValue(pin_handle, LOAD1, 0);
PIN_setOutputValue(pin_handle, LOAD2, 0);
PIN_setOutputValue(pin_handle, D0, 0);
PIN_setOutputValue(pin_handle, D1, 0);
PIN_setOutputValue(pin_handle, D2, 0);
PIN_setOutputValue(pin_handle, D3, 0);
PIN_setOutputValue(pin_handle, D4, 1);
PIN_setOutputValue(pin_handle, D5, 1);
PIN_setOutputValue(pin_handle, D6, 1);
PIN_setOutputValue(pin_handle, D7, 1);
CPUdelay(10);
PIN_setOutputValue(pin_handle, LOAD0, 1);
PIN_setOutputValue(pin_handle, LOAD0, 0);
remove_elite_pin();
// InitLH();
// add_elite_pin();
//
// PIN_setOutputValue(pin_handle, LOAD0, 1);
// PIN_setOutputValue(pin_handle, LOAD1, 1);
// PIN_setOutputValue(pin_handle, LOAD2, 1);
// CPUdelay(10);
// PIN_setOutputValue(pin_handle, D0, 0);
// PIN_setOutputValue(pin_handle, D1, 0);
// PIN_setOutputValue(pin_handle, D2, 0);
// PIN_setOutputValue(pin_handle, D3, 0);
// PIN_setOutputValue(pin_handle, D4, 0);
// PIN_setOutputValue(pin_handle, D5, 0);
// PIN_setOutputValue(pin_handle, D6, 0);
// PIN_setOutputValue(pin_handle, D7, 0);
// CPUdelay(10);
// PIN_setOutputValue(pin_handle, LOAD0, 0);
// PIN_setOutputValue(pin_handle, LOAD1, 0);
// PIN_setOutputValue(pin_handle, LOAD2, 0);
//
// remove_elite_pin();
}
#endif
@@ -80,6 +80,86 @@ static void CAL_ADC_write(uint8_t ADCin) {
CAL_ADC_SPI(2, spi_ADC_txbuf, spi_ADC_rxbuf);
}
/* 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;
}
}
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;
}
}
static void ADCChannelSelect(uint8_t ADCChannel){
// set ADC parameter
// 0xC1~F1 = reading AIN0~AIN3. Using FSR+-6V, resolution = 187.5uV
@@ -158,12 +238,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
@@ -189,286 +277,286 @@ static int32_t AutoGainReadVin(uint8_t *buf){
return RealVolt;
}
//static void AutoGainChangeIin(int32_t RealCurrent){
// // switch to 1 level current(small) 3M
// // switch to 2 level current 100K
// // switch to 3 level current 3K
// // switch to 4 level current(large) 100R
// if(INSTRUCTION.ADCGainLevel == I_GAIN_100R){
// if(RealCurrent < I_GAIN_LARGE_BOUNDARY && RealCurrent > -1*I_GAIN_LARGE_BOUNDARY){
// // switch to 1 level current(small)
// if (RealCurrent < I_GAIN_MID1_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID1_BOUNDARY1){
// I_GAIN_3M_counter++;
// if(I_GAIN_3M_counter > 2){
// INSTRUCTION.ADCGainLevel = I_GAIN_3M;
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
// I_GAIN_3M_counter = 0;
// record_flag = false;
// }
// }
// // switch to 2 level current
// else if (RealCurrent < I_GAIN_MID2_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID2_BOUNDARY1){
// I_GAIN_100K_counter++;
// if(I_GAIN_100K_counter > 2){
// INSTRUCTION.ADCGainLevel = I_GAIN_100K;
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
// I_GAIN_100K_counter = 0;
// record_flag = false;
// }
// }
// // switch to 3 level current
// else{
// I_GAIN_3K_counter++;
// if(I_GAIN_3K_counter > 2){
// INSTRUCTION.ADCGainLevel = I_GAIN_3K;
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
// I_GAIN_3K_counter = 0;
// record_flag = false;
// }
// }
// }else{
// if(I_GAIN_3K_counter > 0){
// I_GAIN_3K_counter--;
// }
// if(I_GAIN_100K_counter > 0){
// I_GAIN_100K_counter--;
// }
// if(I_GAIN_3M_counter > 0){
// I_GAIN_3M_counter--;
// }
// }
// }
// else if(INSTRUCTION.ADCGainLevel == I_GAIN_3K){
// // switch to 4 level current(large)
// if(RealCurrent > I_GAIN_MID2_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID2_BOUNDARY2){
// I_GAIN_100R_counter++;
// if(I_GAIN_100R_counter > 2){
// INSTRUCTION.ADCGainLevel = I_GAIN_100R;
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
// I_GAIN_100R_counter = 0;
// record_flag = false;
// }
// }
// else if (RealCurrent < I_GAIN_MID2_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID2_BOUNDARY1){
// // switch to 1 level current(small)
// if(RealCurrent < I_GAIN_MID1_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID1_BOUNDARY1){
// I_GAIN_3M_counter++;
// if(I_GAIN_3M_counter > 2){
// INSTRUCTION.ADCGainLevel = I_GAIN_3M;
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
// I_GAIN_3M_counter = 0;
// record_flag = false;
// }
// }
// // switch to 2 level current
// else{
// I_GAIN_100K_counter++;
// if(I_GAIN_100K_counter > 2){
// INSTRUCTION.ADCGainLevel = I_GAIN_100K;
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
// I_GAIN_100K_counter = 0;
// record_flag = false;
// }
// }
// }else{
// if(I_GAIN_100R_counter > 0){
// I_GAIN_100R_counter--;
// }
// if(I_GAIN_100K_counter > 0){
// I_GAIN_100K_counter--;
// }
// if(I_GAIN_3M_counter > 0){
// I_GAIN_3M_counter--;
// }
// }
// }
// else if(INSTRUCTION.ADCGainLevel == I_GAIN_100K){
// // switch to 1 level current(small)
// if(RealCurrent < I_GAIN_MID1_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID1_BOUNDARY1){
// I_GAIN_3M_counter++;
// if(I_GAIN_3M_counter > 2){
// INSTRUCTION.ADCGainLevel = I_GAIN_3M;
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
// I_GAIN_3M_counter = 0;
// record_flag = false;
// }
// }
// else if (RealCurrent > I_GAIN_MID1_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID1_BOUNDARY2){
// // switch to 4 level current(large)
// if(RealCurrent > I_GAIN_MID2_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID2_BOUNDARY2){
// I_GAIN_100R_counter++;
// if(I_GAIN_100R_counter > 2){
// INSTRUCTION.ADCGainLevel = I_GAIN_100R;
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
// I_GAIN_100R_counter = 0;
// record_flag = false;
// }
// }
// // switch to 3 level current
// else{
// I_GAIN_3K_counter++;
// if(I_GAIN_3K_counter > 2){
// INSTRUCTION.ADCGainLevel = I_GAIN_3K;
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
// I_GAIN_3K_counter = 0;
// record_flag = false;
// }
// }
// }else{
// if(I_GAIN_100R_counter > 0){
// I_GAIN_100R_counter--;
// }
// if(I_GAIN_3K_counter > 0){
// I_GAIN_3K_counter--;
// }
// if(I_GAIN_3M_counter > 0){
// I_GAIN_3M_counter--;
// }
// }
// }
// else if(INSTRUCTION.ADCGainLevel == I_GAIN_3M){
// if(RealCurrent > I_GAIN_SMALL_BOUNDARY || RealCurrent < -1*I_GAIN_SMALL_BOUNDARY){
// // switch to 4 level current(large)
// if(RealCurrent > I_GAIN_MID2_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID2_BOUNDARY2){
// I_GAIN_100R_counter++;
// if(I_GAIN_100R_counter > 2){
// INSTRUCTION.ADCGainLevel = I_GAIN_100R;
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
// I_GAIN_100R_counter = 0;
// record_flag = false;
// }
// }
// // switch to 3 level current
// else if(RealCurrent > I_GAIN_MID1_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID1_BOUNDARY2){
// I_GAIN_3K_counter++;
// if(I_GAIN_3K_counter > 2){
// INSTRUCTION.ADCGainLevel = I_GAIN_3K;
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
// I_GAIN_3K_counter = 0;
// record_flag = false;
// }
// }
// // switch to 2 level current
// else{
// I_GAIN_100K_counter++;
// if(I_GAIN_100K_counter > 2){
// INSTRUCTION.ADCGainLevel = I_GAIN_100K;
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
// I_GAIN_100K_counter = 0;
// record_flag = false;
// }
//
// }
// }else{
// if(I_GAIN_100R_counter > 0){
// I_GAIN_100R_counter--;
// }
// if(I_GAIN_3K_counter > 0){
// I_GAIN_3K_counter--;
// }
// if(I_GAIN_100K_counter > 0){
// I_GAIN_100K_counter--;
// }
// }
// }
//}
static void AutoGainChangeIin(int32_t RealCurrent){
// switch to 1 level current(small) 3M
// switch to 2 level current 100K
// switch to 3 level current 3K
// switch to 4 level current(large) 100R
if(INSTRUCTION.ADCGainLevel == I_GAIN_100R){
if(RealCurrent < I_GAIN_LARGE_BOUNDARY && RealCurrent > -1*I_GAIN_LARGE_BOUNDARY){
// switch to 1 level current(small)
if (RealCurrent < I_GAIN_MID1_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID1_BOUNDARY1){
I_GAIN_3M_counter++;
if(I_GAIN_3M_counter > 2){
INSTRUCTION.ADCGainLevel = I_GAIN_3M;
IinADCGainControl(INSTRUCTION.ADCGainLevel);
I_GAIN_3M_counter = 0;
record_flag = false;
}
}
// switch to 2 level current
else if (RealCurrent < I_GAIN_MID2_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID2_BOUNDARY1){
I_GAIN_100K_counter++;
if(I_GAIN_100K_counter > 2){
INSTRUCTION.ADCGainLevel = I_GAIN_100K;
IinADCGainControl(INSTRUCTION.ADCGainLevel);
I_GAIN_100K_counter = 0;
record_flag = false;
}
}
// switch to 3 level current
else{
I_GAIN_3K_counter++;
if(I_GAIN_3K_counter > 2){
INSTRUCTION.ADCGainLevel = I_GAIN_3K;
IinADCGainControl(INSTRUCTION.ADCGainLevel);
I_GAIN_3K_counter = 0;
record_flag = false;
}
}
}else{
if(I_GAIN_3K_counter > 0){
I_GAIN_3K_counter--;
}
if(I_GAIN_100K_counter > 0){
I_GAIN_100K_counter--;
}
if(I_GAIN_3M_counter > 0){
I_GAIN_3M_counter--;
}
}
}
else if(INSTRUCTION.ADCGainLevel == I_GAIN_3K){
// switch to 4 level current(large)
if(RealCurrent > I_GAIN_MID2_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID2_BOUNDARY2){
I_GAIN_100R_counter++;
if(I_GAIN_100R_counter > 2){
INSTRUCTION.ADCGainLevel = I_GAIN_100R;
IinADCGainControl(INSTRUCTION.ADCGainLevel);
I_GAIN_100R_counter = 0;
record_flag = false;
}
}
else if (RealCurrent < I_GAIN_MID2_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID2_BOUNDARY1){
// switch to 1 level current(small)
if(RealCurrent < I_GAIN_MID1_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID1_BOUNDARY1){
I_GAIN_3M_counter++;
if(I_GAIN_3M_counter > 2){
INSTRUCTION.ADCGainLevel = I_GAIN_3M;
IinADCGainControl(INSTRUCTION.ADCGainLevel);
I_GAIN_3M_counter = 0;
record_flag = false;
}
}
// switch to 2 level current
else{
I_GAIN_100K_counter++;
if(I_GAIN_100K_counter > 2){
INSTRUCTION.ADCGainLevel = I_GAIN_100K;
IinADCGainControl(INSTRUCTION.ADCGainLevel);
I_GAIN_100K_counter = 0;
record_flag = false;
}
}
}else{
if(I_GAIN_100R_counter > 0){
I_GAIN_100R_counter--;
}
if(I_GAIN_100K_counter > 0){
I_GAIN_100K_counter--;
}
if(I_GAIN_3M_counter > 0){
I_GAIN_3M_counter--;
}
}
}
else if(INSTRUCTION.ADCGainLevel == I_GAIN_100K){
// switch to 1 level current(small)
if(RealCurrent < I_GAIN_MID1_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID1_BOUNDARY1){
I_GAIN_3M_counter++;
if(I_GAIN_3M_counter > 2){
INSTRUCTION.ADCGainLevel = I_GAIN_3M;
IinADCGainControl(INSTRUCTION.ADCGainLevel);
I_GAIN_3M_counter = 0;
record_flag = false;
}
}
else if (RealCurrent > I_GAIN_MID1_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID1_BOUNDARY2){
// switch to 4 level current(large)
if(RealCurrent > I_GAIN_MID2_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID2_BOUNDARY2){
I_GAIN_100R_counter++;
if(I_GAIN_100R_counter > 2){
INSTRUCTION.ADCGainLevel = I_GAIN_100R;
IinADCGainControl(INSTRUCTION.ADCGainLevel);
I_GAIN_100R_counter = 0;
record_flag = false;
}
}
// switch to 3 level current
else{
I_GAIN_3K_counter++;
if(I_GAIN_3K_counter > 2){
INSTRUCTION.ADCGainLevel = I_GAIN_3K;
IinADCGainControl(INSTRUCTION.ADCGainLevel);
I_GAIN_3K_counter = 0;
record_flag = false;
}
}
}else{
if(I_GAIN_100R_counter > 0){
I_GAIN_100R_counter--;
}
if(I_GAIN_3K_counter > 0){
I_GAIN_3K_counter--;
}
if(I_GAIN_3M_counter > 0){
I_GAIN_3M_counter--;
}
}
}
else if(INSTRUCTION.ADCGainLevel == I_GAIN_3M){
if(RealCurrent > I_GAIN_SMALL_BOUNDARY || RealCurrent < -1*I_GAIN_SMALL_BOUNDARY){
// switch to 4 level current(large)
if(RealCurrent > I_GAIN_MID2_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID2_BOUNDARY2){
I_GAIN_100R_counter++;
if(I_GAIN_100R_counter > 2){
INSTRUCTION.ADCGainLevel = I_GAIN_100R;
IinADCGainControl(INSTRUCTION.ADCGainLevel);
I_GAIN_100R_counter = 0;
record_flag = false;
}
}
// switch to 3 level current
else if(RealCurrent > I_GAIN_MID1_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID1_BOUNDARY2){
I_GAIN_3K_counter++;
if(I_GAIN_3K_counter > 2){
INSTRUCTION.ADCGainLevel = I_GAIN_3K;
IinADCGainControl(INSTRUCTION.ADCGainLevel);
I_GAIN_3K_counter = 0;
record_flag = false;
}
}
// switch to 2 level current
else{
I_GAIN_100K_counter++;
if(I_GAIN_100K_counter > 2){
INSTRUCTION.ADCGainLevel = I_GAIN_100K;
IinADCGainControl(INSTRUCTION.ADCGainLevel);
I_GAIN_100K_counter = 0;
record_flag = false;
}
//static void AutoGainChangeVin(int32_t RealVin){
// // switch to 1 level volt(small) 1M
// // switch to 2 level volt 30K
// // switch to 3 level volt(large) 1K
// if(INSTRUCTION.VinADCGainLevel == VIN_GAIN_1M){
// if(RealVin > VIN_GAIN_SMALL_BOUNDARY || RealVin < -1*VIN_GAIN_SMALL_BOUNDARY){
// // switch to 3 level volt(large)
// if (RealVin > VIN_GAIN_MID1_BOUNDARY2 || RealVin < -1*VIN_GAIN_MID1_BOUNDARY2){
// VIN_GAIN_1K_counter++;
// if(VIN_GAIN_1K_counter > 2){
// INSTRUCTION.VinADCGainLevel = VIN_GAIN_1K;
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
// VIN_GAIN_1K_counter = 0;
// record_flag = false;
// }
// }
// // switch to 2 level volt
// else{
// VIN_GAIN_30K_counter++;
// if(VIN_GAIN_30K_counter > 2){
// INSTRUCTION.VinADCGainLevel = VIN_GAIN_30K;
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
// VIN_GAIN_30K_counter = 0;
// record_flag = false;
// }
// }
// }else{
// if(VIN_GAIN_1K_counter > 0){
// VIN_GAIN_1K_counter--;
// }
// if(VIN_GAIN_30K_counter > 0){
// VIN_GAIN_30K_counter--;
// }
// }
// }
// else if(INSTRUCTION.VinADCGainLevel == VIN_GAIN_30K){
// // switch to 1 level volt(small)
// if(RealVin < VIN_GAIN_MID1_BOUNDARY1 && RealVin > -1*VIN_GAIN_MID1_BOUNDARY1){
// VIN_GAIN_1M_counter++;
// if(VIN_GAIN_1M_counter > 2){
// INSTRUCTION.VinADCGainLevel = VIN_GAIN_1M;
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
// VIN_GAIN_1M_counter = 0;
// record_flag = false;
// }
// }
// else if (RealVin > VIN_GAIN_MID1_BOUNDARY2 || RealVin < -1*VIN_GAIN_MID1_BOUNDARY2){
// // switch to 3 level volt
// VIN_GAIN_1K_counter++;
// if(VIN_GAIN_1K_counter > 2){
// INSTRUCTION.VinADCGainLevel = VIN_GAIN_1K;
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
// VIN_GAIN_1K_counter = 0;
// record_flag = false;
// }
// }else{
// if(VIN_GAIN_1K_counter > 0){
// VIN_GAIN_1K_counter--;
// }
// if(VIN_GAIN_1M_counter > 0){
// VIN_GAIN_1M_counter--;
// }
// }
// }
// else if(INSTRUCTION.VinADCGainLevel == VIN_GAIN_1K){
// if(RealVin < VIN_GAIN_LARGE_BOUNDARY && RealVin > -1*VIN_GAIN_LARGE_BOUNDARY){
// // switch to 1 level volt(small)
// if (RealVin < VIN_GAIN_MID1_BOUNDARY1 && RealVin > -1*VIN_GAIN_MID1_BOUNDARY1){
// VIN_GAIN_1M_counter++;
// if(VIN_GAIN_1M_counter > 2){
// INSTRUCTION.VinADCGainLevel = VIN_GAIN_1M;
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
// VIN_GAIN_1M_counter = 0;
// record_flag = false;
// }
// }
// // switch to 2 level volt
// else{
// VIN_GAIN_30K_counter++;
// if(VIN_GAIN_30K_counter > 2){
// INSTRUCTION.VinADCGainLevel = VIN_GAIN_30K;
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
// VIN_GAIN_30K_counter = 0;
// record_flag = false;
// }
// }
// }else{
// if(VIN_GAIN_1M_counter > 0){
// VIN_GAIN_1M_counter--;
// }
// if(VIN_GAIN_30K_counter > 0){
// VIN_GAIN_30K_counter--;
// }
// }
// }
//}
}
}else{
if(I_GAIN_100R_counter > 0){
I_GAIN_100R_counter--;
}
if(I_GAIN_3K_counter > 0){
I_GAIN_3K_counter--;
}
if(I_GAIN_100K_counter > 0){
I_GAIN_100K_counter--;
}
}
}
}
static void AutoGainChangeVin(int32_t RealVin){
// switch to 1 level volt(small) 1M
// switch to 2 level volt 30K
// switch to 3 level volt(large) 1K
if(INSTRUCTION.VinADCGainLevel == VIN_GAIN_1M){
if(RealVin > VIN_GAIN_SMALL_BOUNDARY || RealVin < -1*VIN_GAIN_SMALL_BOUNDARY){
// switch to 3 level volt(large)
if (RealVin > VIN_GAIN_MID1_BOUNDARY2 || RealVin < -1*VIN_GAIN_MID1_BOUNDARY2){
VIN_GAIN_1K_counter++;
if(VIN_GAIN_1K_counter > 2){
INSTRUCTION.VinADCGainLevel = VIN_GAIN_1K;
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
VIN_GAIN_1K_counter = 0;
record_flag = false;
}
}
// switch to 2 level volt
else{
VIN_GAIN_30K_counter++;
if(VIN_GAIN_30K_counter > 2){
INSTRUCTION.VinADCGainLevel = VIN_GAIN_30K;
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
VIN_GAIN_30K_counter = 0;
record_flag = false;
}
}
}else{
if(VIN_GAIN_1K_counter > 0){
VIN_GAIN_1K_counter--;
}
if(VIN_GAIN_30K_counter > 0){
VIN_GAIN_30K_counter--;
}
}
}
else if(INSTRUCTION.VinADCGainLevel == VIN_GAIN_30K){
// switch to 1 level volt(small)
if(RealVin < VIN_GAIN_MID1_BOUNDARY1 && RealVin > -1*VIN_GAIN_MID1_BOUNDARY1){
VIN_GAIN_1M_counter++;
if(VIN_GAIN_1M_counter > 2){
INSTRUCTION.VinADCGainLevel = VIN_GAIN_1M;
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
VIN_GAIN_1M_counter = 0;
record_flag = false;
}
}
else if (RealVin > VIN_GAIN_MID1_BOUNDARY2 || RealVin < -1*VIN_GAIN_MID1_BOUNDARY2){
// switch to 3 level volt
VIN_GAIN_1K_counter++;
if(VIN_GAIN_1K_counter > 2){
INSTRUCTION.VinADCGainLevel = VIN_GAIN_1K;
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
VIN_GAIN_1K_counter = 0;
record_flag = false;
}
}else{
if(VIN_GAIN_1K_counter > 0){
VIN_GAIN_1K_counter--;
}
if(VIN_GAIN_1M_counter > 0){
VIN_GAIN_1M_counter--;
}
}
}
else if(INSTRUCTION.VinADCGainLevel == VIN_GAIN_1K){
if(RealVin < VIN_GAIN_LARGE_BOUNDARY && RealVin > -1*VIN_GAIN_LARGE_BOUNDARY){
// switch to 1 level volt(small)
if (RealVin < VIN_GAIN_MID1_BOUNDARY1 && RealVin > -1*VIN_GAIN_MID1_BOUNDARY1){
VIN_GAIN_1M_counter++;
if(VIN_GAIN_1M_counter > 2){
INSTRUCTION.VinADCGainLevel = VIN_GAIN_1M;
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
VIN_GAIN_1M_counter = 0;
record_flag = false;
}
}
// switch to 2 level volt
else{
VIN_GAIN_30K_counter++;
if(VIN_GAIN_30K_counter > 2){
INSTRUCTION.VinADCGainLevel = VIN_GAIN_30K;
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
VIN_GAIN_30K_counter = 0;
record_flag = false;
}
}
}else{
if(VIN_GAIN_1M_counter > 0){
VIN_GAIN_1M_counter--;
}
if(VIN_GAIN_30K_counter > 0){
VIN_GAIN_30K_counter--;
}
}
}
}
static uint16_t ADC_CURRENT_AVG_calibration (uint8_t ADC_channel) {
uint32_t ADCValueTemp = 0;
@@ -5,31 +5,34 @@
static bool DACReset;
#ifdef ELITE_VERSION_1_3
#define DACOUT 0x30
static void DAC_outputV(uint16_t voltLV) {
// C = command, X = don't care, D = data
// CCCC XXXX = command
// DDDD DDDD = v1
// DDDD XXXX = v2
uint8_t v1, v2 = 0;
v1 = (uint8_t) (voltLV >> 4) & 0xFF;
v2 = (uint8_t) ((voltLV & 0x000F) << 4) & 0xF0;
spi_DACtxbuf[0] = command;
spi_DACtxbuf[1] = v1;
spi_DACtxbuf[2] = v2;
for (int i = 3; i < SPI_DAC_SIZE; i++) {
spi_DACtxbuf[i] = 0;
}
DAC_SPI(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
}
#endif
//#ifdef ELITE_VERSION_1_3
//#define DACOUT 0x30
//
//static void DAC_outputV(uint16_t voltLV) {
// // C = command, X = don't care, D = data
// // CCCC XXXX = command
// // DDDD DDDD = v1
// // DDDD XXXX = v2
//
// uint8_t v1, v2 = 0;
// v1 = (uint8_t) (voltLV >> 4) & 0xFF;
// v2 = (uint8_t) ((voltLV & 0x000F) << 4) & 0xF0;
//
// spi_DACtxbuf[0] = command;
// spi_DACtxbuf[1] = v1;
// spi_DACtxbuf[2] = v2;
// for (int i = 3; i < SPI_DAC_SIZE; i++) {
// spi_DACtxbuf[i] = 0;
// }
//
// DAC_SPI(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
//}
//#endif
#ifdef ELITE_VERSION_1_4
#define DACCLS 0x02
#define DACOUT 0x31
static uint16_t DAC_outputV(uint16_t voltLV) {
// C = command, X = don't care, D = data
// CCCC CCCC = command
@@ -52,19 +55,26 @@ static uint16_t DAC_outputV(uint16_t voltLV) {
return voltLV;
}
#endif
#ifdef ELITE_VERSION_EIS
static uint32_t DAC_outputV(uint32_t voltLV) {
// uint8_t v1, v2 = 0;
// v1 = (uint8_t) ((voltLV & 0xFF00) >> 8);
// v2 = (uint8_t) (voltLV & 0x00FF);
EIS_LPDAC_SPI(voltLV);
return voltLV;
static void VoutGainControl(uint8_t VOUTLevel){
if(VOUTLevel == 0){
// VOUT gain level = 0, using 240K resister
PIN15_setOutputValue(Turon_VOUT_SMALL, 0);
}
else if(VOUTLevel == 1){
// VOUT gain level = 1, using 15K resister
PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
}
else if(VOUTLevel == 2){
// VOUT gain level = 2, using 15K resister
PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
}
else{
// default using 15K resister
PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
}
}
#endif
static int32_t User2Real(uint16_t UserCode){
@@ -74,22 +84,27 @@ 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){
if(RealVolt > DAC_VOUT_GAIN_LARGE_BOUNDARY || RealVolt < -1 * DAC_VOUT_GAIN_LARGE_BOUNDARY){
// switch to 2 level volt(large)
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
record_flag = false;
}
}
@@ -97,6 +112,7 @@ static void AutoGainChangeVout(int32_t RealVolt){
if(RealVolt < DAC_VOUT_GAIN_SMALL_BOUNDARY && RealVolt > -1 * DAC_VOUT_GAIN_SMALL_BOUNDARY ){
// switch to 1 level volt(small)
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
record_flag = false;
}
}
@@ -29,7 +29,7 @@
*/
#define BOARD_C6D4
#define BOARD_C771
typedef struct _formula{
@@ -49,7 +49,7 @@ struct _correction{
} Correction =
#ifdef BOARD_C6E1
#ifdef BOARD_C6E1 // not well
{
.ADC_volt[0].coeff = (-6251051),
.ADC_volt[0].offset = 102081366120,
@@ -82,36 +82,36 @@ struct _correction{
#ifdef BOARD_C7A1
{
.ADC_volt[0].coeff = (6204),
.ADC_volt[0].offset = -100237253,
.ADC_volt[0].coeff = (6256),
.ADC_volt[0].offset = -101532028,
.ADC_volt[1].coeff = (214511),
.ADC_volt[1].offset = -3485722036,
.ADC_volt[1].coeff = (215138),
.ADC_volt[1].offset = -3501890770,
.ADC_volt[2].coeff = (6213224),
.ADC_volt[2].offset = -101104189300,
.ADC_volt[2].coeff = (6245014),
.ADC_volt[2].offset = -101751226981,
.ADC_current[0].coeff = 2078892,
.ADC_current[0].offset = (-33685110900),
.ADC_current[0].coeff = 3125920,
.ADC_current[0].offset = (-50880328288),
.ADC_current[1].coeff = 64769469,
.ADC_current[1].offset = (-1048938859469),
.ADC_current[1].coeff = 71636129,
.ADC_current[1].offset = (-1166093783868),
.ADC_current[2].coeff = 2090182091,
.ADC_current[2].offset = (-33847893234994),
.ADC_current[2].coeff = 1459555637,
.ADC_current[2].offset = (-23757721396024),
.ADC_current[3].coeff = 60030468992,
.ADC_current[3].offset = (-972275155887907),
.ADC_current[3].coeff = 30723232882,
.ADC_current[3].offset = (-500144809348170),
.Usercode2DAC[0].coeff = (-10512772),
.Usercode2DAC[0].offset = 581302323013,
.Usercode2DAC[0].coeff = (-10543817),
.Usercode2DAC[0].offset = 583163641972,
.Usercode2DAC[1].coeff = (-178991273),
.Usercode2DAC[1].offset = 4794464882260,
.Usercode2DAC[1].coeff = (-178077711),
.Usercode2DAC[1].offset = 4777894559527,
};
#endif
#ifdef BOARD_C6D4
#ifdef BOARD_C6D4 // not well
{
.ADC_volt[0].coeff = (6226),
.ADC_volt[0].offset = -100075170,
@@ -142,6 +142,68 @@ struct _correction{
};
#endif
#ifdef BOARD_C771
{
.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_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
// 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){
@@ -224,43 +286,41 @@ static int32_t DecodeADCValue(uint8_t ADCGain, uint8_t ADCChannel, uint8_t *ADC_
// #0 board, (0x5f75 <= rawdata) && (rawdata <= 0x5fb2)
// ((0x5f97 < rawdata) && (rawdata < 0x6589)) || ((0x5999 < rawdata) && (rawdata < 0x5f93))
//static void ADC_overflow(uint8_t gain, uint8_t *rawdata){
//
// // Gain boundary defines different ADC gain level working area
// // Gain0Boundary = {lowerbound, upperbound}, is the lower and upper bound of gain level 0 working area.
//
// uint16_t U16Rawdata = 0;
// U16Rawdata = (((uint16_t) (rawdata[0]))<<8) | ((uint16_t) (rawdata[1]));
//
// if(gain == I_GAIN_3M){
// if( U16Rawdata <= Correction.Gain0Boundary[0]){
// rawdata[0] = Correction.Gain0Boundary[0] >> 4;
// rawdata[1] = (uint8_t) (Correction.Gain0Boundary[0] & 0x00FF);
// }
// else if(U16Rawdata >= Correction.Gain0Boundary[1]){
// rawdata[0] = (uint8_t) (Correction.Gain0Boundary[1] >> 4);
// rawdata[1] = (uint8_t) (Correction.Gain0Boundary[1] & 0x00FF);
// }
// }
// else if(gain == I_GAIN_100K){
// if( U16Rawdata <= Correction.Gain1Boundary[0]){
// rawdata[0] = Correction.Gain1Boundary[0] >> 4;
// rawdata[1] = (uint8_t) (Correction.Gain1Boundary[0] & 0x00FF);
// }
// else if(U16Rawdata >= Correction.Gain1Boundary[1]){
// rawdata[0] = (uint8_t) (Correction.Gain1Boundary[1] >> 4);
// rawdata[1] = (uint8_t) (Correction.Gain1Boundary[1] & 0x00FF);
// }
// }
//}
static void ADC_overflow(uint8_t gain, uint8_t *rawdata){
// Gain boundary defines different ADC gain level working area
// Gain0Boundary = {lowerbound, upperbound}, is the lower and upper bound of gain level 0 working area.
uint16_t U16Rawdata = 0;
U16Rawdata = (((uint16_t) (rawdata[0]))<<8) | ((uint16_t) (rawdata[1]));
if(gain == I_GAIN_3M){
if( U16Rawdata <= Correction.Gain0Boundary[0]){
rawdata[0] = Correction.Gain0Boundary[0] >> 4;
rawdata[1] = (uint8_t) (Correction.Gain0Boundary[0] & 0x00FF);
}
else if(U16Rawdata >= Correction.Gain0Boundary[1]){
rawdata[0] = (uint8_t) (Correction.Gain0Boundary[1] >> 4);
rawdata[1] = (uint8_t) (Correction.Gain0Boundary[1] & 0x00FF);
}
}
else if(gain == I_GAIN_100K){
if( U16Rawdata <= Correction.Gain1Boundary[0]){
rawdata[0] = Correction.Gain1Boundary[0] >> 4;
rawdata[1] = (uint8_t) (Correction.Gain1Boundary[0] & 0x00FF);
}
else if(U16Rawdata >= Correction.Gain1Boundary[1]){
rawdata[0] = (uint8_t) (Correction.Gain1Boundary[1] >> 4);
rawdata[1] = (uint8_t) (Correction.Gain1Boundary[1] & 0x00FF);
}
}
}
// User will enter -5V~+5V in UI.
// websever and controler use 0~50000 represent -5~+5V
// this function should turn 0~50000 into DACcode which output the exactly voltage user want
static uint16_t Usercode_Correction_to_DAC(uint8_t DACGain, uint16_t usercode)
{
AutoGainChangeVout(usercode);
long long usercode_32;
uint16_t DACcode = 0;
@@ -22,7 +22,6 @@ struct _GPT{
uint32_t BatteryADCCounter;
uint32_t BatteryCheckCounter;
uint32_t GptimerMultiple;
uint32_t TestCounter;
}GPT = {0};
static void InitCT(){
@@ -75,6 +75,22 @@ struct HEADSTAGE_INSTRUCTION {
uint8_t charge;
int32_t constantCurrent;
int32_t Currentmax;
int32_t t1;
int32_t t2;
int32_t t3;
int32_t t4;
int32_t t5;
int32_t v1;
int32_t v2;
int32_t v3;
int32_t v4;
int32_t v5;
int32_t t1Time;
int32_t t2Time;
int32_t t3Time;
int32_t t4Time;
int32_t t5Time;
uint16_t loop;
uint16_t StepTime;
@@ -121,5 +137,21 @@ static void InitEliteInstruction(){
INSTRUCTION.Currentmax = 0;
INSTRUCTION.StepTime = STEPTIME_ONE_SEC;
INSTRUCTION.AdcChannel = 0;
INSTRUCTION.t1 = 0;
INSTRUCTION.t2 = 0;
INSTRUCTION.t3 = 0;
INSTRUCTION.t4 = 0;
INSTRUCTION.t5 = 0;
INSTRUCTION.t1Time = 0;
INSTRUCTION.t2Time = 0;
INSTRUCTION.t3Time = 0;
INSTRUCTION.t4Time = 0;
INSTRUCTION.t5Time = 0;
INSTRUCTION.v1 = DAC_ZERO;
INSTRUCTION.v2 = DAC_ZERO;
INSTRUCTION.v3 = DAC_ZERO;
INSTRUCTION.v4 = DAC_ZERO;
INSTRUCTION.v5 = DAC_ZERO;
INSTRUCTION.loop = 1;
}
#endif
@@ -8,19 +8,25 @@ static bool TurnOnElite(uint8_t key) {
if (key == 0) {
// press 1 sec, power on LED, read bat power
if (TurnOnCounter >= CLOCK_ONE_SECOND) {
PIN_setOutputValue(pin_handle, enable_5v, 1);// enable 5V
Elite_SPI_init();
ModeLED(BT_WAIT);
AD5940_init();
// DAC_outputV(0x3FFFF);
return true;
headstage_battery_volt();
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) |
((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
if( bat < 768 && bat > 20){
PIN15_setOutputValue(enable_5v, 0);
return false;
}else{
PIN15_setOutputValue(enable_5v, 1); // enable 5V
TurnOn10V();
ModeLED(BT_WAIT);
return true;
}
} else {
TurnOnCounter++;
return false;
}
} else {
TurnOnCounter = 0;
PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V
PIN15_setOutputValue(enable_5v, 0); // disable 5V
return false;
}
}
@@ -40,7 +46,7 @@ static void EliteKeyPress(uint8_t key) {
// press 3~4 sec, shutdown 2650
else if (ShutDownCounter > (CLOCK_ONE_SECOND*3) ) {
LED_color(DARKLED, 0xFF, 0xFF, 0x00);
PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V
PIN15_setOutputValue(enable_5v, 0); // disable 5V
}
ShutDownCounter ++;
} else {
@@ -60,4 +66,10 @@ static void EliteKeyPress(uint8_t key) {
}
}
static void TurnOn10V() {
If10Von = true;
PIN15_setOutputValue(enable_10v, 1);
CPUdelay(8000);
}
#endif
@@ -149,6 +149,11 @@ static void WorkModeLED() {
WORKLED();
break;
}
case PULSE_MODE:{
// Elite_led_color(COLOR_YELLOW);
WORKLED();
break;
}
case CONSTANT_CURRENT:{
WORKLED();
break;
@@ -0,0 +1,345 @@
#ifndef ELITEPULSE
#define ELITEPULSE
#define Vset INSTRUCTION.Vset
//static uint16_t CV3Curve(CV3Mode *CV3){
// static uint16_t DACOutCode;
// static int32_t Vin;
// static int32_t Vout;
// static int32_t DeltaVout;
//
// Vin = CV3->_measureVin * 200;//[5nV]
// if(DACReset){
// Vout = Vset + Vin;
// DACReset = false;
// }else{
// DeltaVout = Vset - (Vout - Vin);
// Vout = Vout + DeltaVout;
// }
//
// INSTRUCTION.VoltConstant = Vout / 40000 + 25000;//5nV=>usercode
// DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.DacVoutAgcLevel, INSTRUCTION.VoltConstant);
//
// int32_t RealV2;
// RealV2 = (int32_t)((Vout - Vin) / 200);//[1uV]
// InputNotify(NOTIFY_VOLT, RealV2);
//
// int32_t RealV;
// RealV = (int32_t)(Vout / 200);//[1uV]
// InputNotify(NOTIFY_IMPEDANCE, RealV);
//
// DAC_outputV(DACOutCode);
//
// return DACOutCode;
//}
//static void PULSE_Vscan(PULSEMode *PULSE){
// static uint16_t lastVolt;
// if (vscanReset) {
// lastVolt = INSTRUCTION.VoltConstant;
// if (PULSE->_tflag == 0) {
// PULSE->_tflag = PULSE->_t2;
// PULSE->_vflag = PULSE->_v2;
// }
// else {
// PULSE->_tflag = PULSE->_t1;
// PULSE->_vflag = PULSE->_v1;
// }
// INSTRUCTION.VoltConstant = PULSE->_vflag;
// if(lastVolt != INSTRUCTION.VoltConstant){
// lastVolt = INSTRUCTION.VoltConstant;
// DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
// }
// vscanReset = false;
// }
//
// if (!vscanReset) {
// //vscan counter
// if (GPT.VscanRateCounter >= PULSE->_tflag) {
// GPT.VscanRateCounter -= PULSE->_tflag; //To get right time
// }
//
// if (PULSE->_loop > 0 && PULSE->_cycleNumber > 0) {
// if (PULSE->_tflag == PULSE->_t1) {
// PULSE->_tflag = PULSE->_t2;
// PULSE->_vflag = PULSE->_v2;
// }
// else if (PULSE->_tflag == PULSE->_t2) {
// PULSE->_tflag = PULSE->_t3;
// PULSE->_vflag = PULSE->_v3;
// }
// else if (PULSE->_tflag == PULSE->_t3) {
// PULSE->_cycleNumber -- ;
// if (PULSE->_cycleNumber == 0) {
// PULSE->_tflag = PULSE->_t4;
// PULSE->_vflag = PULSE->_v4;
// }
// else {
// PULSE->_tflag = PULSE->_t2;
// PULSE->_vflag = PULSE->_v2;
// }
// }
// INSTRUCTION.VoltConstant = PULSE->_vflag;
// if(lastVolt != INSTRUCTION.VoltConstant){
// lastVolt = INSTRUCTION.VoltConstant;
// DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
// }
// }
// else if (PULSE->_loop > 0 && PULSE->_cycleNumber <= 0) {
// if (PULSE->_tflag == PULSE->_t1) {
// PULSE->_tflag = PULSE->_t4;
// PULSE->_vflag = PULSE->_v4;
// }
// else if (PULSE->_tflag == PULSE->_t4) {
// PULSE->_loop -- ;
// if (PULSE->_loop > 0) {
// PULSE->_cycleNumber = INSTRUCTION.cycleNumber;
// PULSE->_tflag = PULSE->_t2;
// PULSE->_vflag = PULSE->_v2;
// }
// else {
// PULSE->_tflag = PULSE->_t5;
// PULSE->_vflag = PULSE->_v5;
// }
// }
// INSTRUCTION.VoltConstant = PULSE->_vflag;
// if(lastVolt != INSTRUCTION.VoltConstant){
// lastVolt = INSTRUCTION.VoltConstant;
// DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
// }
// }
// else if (PULSE->_loop <= 0) {
// if (PULSE->_tflag == PULSE->_t5) {
// PeriodicEvent = false;
// ELITE15_SPI_CLOSE();
// ModeLED(NO_EVENT);
// }
// }
// InputNotify(NOTIFY_IMPEDANCE, PULSE->_vflag);
// }
//// int32_t RealV;
//// RealV = (int32_t)(Vset / 500);//[1uV]
//// InputNotify(NOTIFY_VOLT, RealV);
//}
static void PULSE_Vscan(PULSEMode *PULSE)
{
static uint16_t lastVolt;
if (vscanReset) {
if (PULSE->_tflag == 0) {
PULSE->_tflag = PULSE->_t2;
PULSE->_vflag = PULSE->_v2;
}
else {
PULSE->_tflag = PULSE->_t1;
PULSE->_vflag = PULSE->_v1;
}
lastVolt = INSTRUCTION.VoltConstant;
INSTRUCTION.VoltConstant = PULSE->_vflag;
if (lastVolt != INSTRUCTION.VoltConstant) {
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
}
vscanReset = false;
}
if (!vscanReset) {
if (GPT.VscanRateCounter >= PULSE->_tflag) {
GPT.VscanRateCounter -= PULSE->_tflag; //To get right time
}
if (PULSE->_loop > 0 && PULSE->_cycleNumber > 0) {
if (PULSE->_tflag == PULSE->_t1) {
PULSE->_tflag = PULSE->_t2;
PULSE->_vflag = PULSE->_v2;
}
else if (PULSE->_tflag == PULSE->_t2) {
PULSE->_tflag = PULSE->_t3;
PULSE->_vflag = PULSE->_v3;
}
else if (PULSE->_tflag == PULSE->_t3) {
PULSE->_cycleNumber -- ;
if (PULSE->_cycleNumber == 0) {
PULSE->_tflag = PULSE->_t4;
PULSE->_vflag = PULSE->_v4;
}
else {
PULSE->_tflag = PULSE->_t2;
PULSE->_vflag = PULSE->_v2;
}
}
INSTRUCTION.VoltConstant = PULSE->_vflag;
if (lastVolt != INSTRUCTION.VoltConstant) {
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
}
}
else if (PULSE->_loop > 0 && PULSE->_cycleNumber <= 0) {
if (PULSE->_tflag == PULSE->_t1) {
PULSE->_tflag = PULSE->_t4;
PULSE->_vflag = PULSE->_v4;
}
else if (PULSE->_tflag == PULSE->_t4) {
PULSE->_loop -- ;
if (PULSE->_loop > 0) {
PULSE->_cycleNumber = INSTRUCTION.cycleNumber;
PULSE->_tflag = PULSE->_t2;
PULSE->_vflag = PULSE->_v2;
}
else {
PULSE->_tflag = PULSE->_t5;
PULSE->_vflag = PULSE->_v5;
}
}
INSTRUCTION.VoltConstant = PULSE->_vflag;
if (lastVolt != INSTRUCTION.VoltConstant) {
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
}
}
else if (PULSE->_loop <= 0) {
if (PULSE->_tflag == PULSE->_t5) {
PeriodicEvent = false;
ModeLED(NO_EVENT);
}
}
InputNotify(NOTIFY_IMPEDANCE, PULSE->_vflag);
}
}
static void test_Vscan(PULSEMode *PULSE){
static uint16_t lastVolt;
static uint8_t testV;
if(firstTimeReset){
firstTimeReset = false;
lastVolt = INSTRUCTION.VoltConstant;
if (PULSE->_tTime == 0) {
PULSE->_tflag = PULSE->_t2;
PULSE->_vflag = PULSE->_v2;
PULSE->_tTime = PULSE->_t2Time;
testV = 1;
}
else {
PULSE->_tflag = PULSE->_t1;
PULSE->_vflag = PULSE->_v1;
PULSE->_tTime = PULSE->_t1Time;
testV = 2;
}
INSTRUCTION.VoltConstant = PULSE->_vflag;
if(lastVolt != INSTRUCTION.VoltConstant){
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
}
//InputNotify(NOTIFY_IMPEDANCE, testV);
}
else if(!firstTimeReset){
if(GPT.VscanRateCounter >= PULSE->_tTime){
GPT.VscanRateCounter -= PULSE->_tTime; //To get right time
vscan_flag = true;
if(vscan_flag){
if (PULSE->_loop > 0 && PULSE->_cycleNumber > 0) {
if (PULSE->_tflag == PULSE->_t1) {
PULSE->_tflag = PULSE->_t2;
PULSE->_vflag = PULSE->_v2;
PULSE->_tTime = PULSE->_t2Time;
testV = 3;
}
else if (PULSE->_tflag == PULSE->_t2) {
PULSE->_tflag = PULSE->_t3;
PULSE->_vflag = PULSE->_v3;
PULSE->_tTime = PULSE->_t3Time;
testV = 4;
}
else if (PULSE->_tflag == PULSE->_t3) {
PULSE->_cycleNumber -- ;
if (PULSE->_cycleNumber == 0) {
PULSE->_tflag = PULSE->_t4;
PULSE->_vflag = PULSE->_v4;
PULSE->_tTime = PULSE->_t4Time;
if (PULSE->_t4Time == 0) {
PULSE->_tflag = PULSE->_t2;
PULSE->_vflag = PULSE->_v2;
PULSE->_tTime = PULSE->_t2Time;
PULSE->_loop--;
PULSE->_cycleNumber = INSTRUCTION.cycleNumber;
if (PULSE->_loop == 0) {
PULSE->_tflag = PULSE->_t5;
PULSE->_vflag = PULSE->_v5;
PULSE->_tTime = PULSE->_t5Time;
if (PULSE->_t5Time == 0) {
PeriodicEvent = false;
ModeLED(NO_EVENT);
}
}
}
testV = 5;
}
else {
PULSE->_tflag = PULSE->_t2;
PULSE->_vflag = PULSE->_v2;
PULSE->_tTime = PULSE->_t2Time;
testV = 6;
}
}
INSTRUCTION.VoltConstant = PULSE->_vflag;
if(lastVolt != INSTRUCTION.VoltConstant){
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
}
}
else if (PULSE->_loop > 0 && PULSE->_cycleNumber <= 0) {
if (PULSE->_tflag == PULSE->_t4) {
PULSE->_loop -- ;
if (PULSE->_loop > 0) {
PULSE->_cycleNumber = INSTRUCTION.cycleNumber;
PULSE->_tflag = PULSE->_t2;
PULSE->_vflag = PULSE->_v2;
PULSE->_tTime = PULSE->_t2Time;
testV = 8;
}
else {
PULSE->_tflag = PULSE->_t5;
PULSE->_vflag = PULSE->_v5;
PULSE->_tTime = PULSE->_t5Time;
testV = 9;
}
}
INSTRUCTION.VoltConstant = PULSE->_vflag;
if(lastVolt != INSTRUCTION.VoltConstant){
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
}
}
else if (PULSE->_loop <= 0) {
if (PULSE->_tflag == PULSE->_t5) {
testV = 10;
PeriodicEvent = false;
ModeLED(NO_EVENT);
}
}
//InputNotify(NOTIFY_IMPEDANCE, testV);
vscan_flag = false;
}
}
}
}
#endif
@@ -8,11 +8,16 @@ static void reset() {
InitFlag();
InitCT();
InitGPT();
InitLH();
// VinADCGainControl(VIN_GAIN_AUTO);
// IinADCGainControl(I_GAIN_AUTO);
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 0 => open high_z mode
VinADCGainControl(VIN_GAIN_AUTO);
IinADCGainControl(I_GAIN_AUTO);
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
initINSBuf();
initDATBuf();
@@ -31,23 +36,22 @@ static void reset() {
spi_ADC_rxbuf[i] = 0;
}
PIN_setOutputValue(pin_handle, AD_CS, 1); // AD_CS HIGH
// PIN15_setOutputValue(DAC_CS, 1); // DAC_CS HIGH
CPUdelay(1600);
}
static void Eliteinterrupt() {
InitFlag();
ModeLED(NO_EVENT);
InitFlag();
InitEliteFlag();
InitCT();
InitGPT();
InitLH();
// VinADCGainControl(VIN_GAIN_AUTO);
// IinADCGainControl(I_GAIN_AUTO);
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
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();
@@ -66,7 +70,6 @@ static void Eliteinterrupt() {
spi_ADC_rxbuf[i] = 0;
}
PIN_setOutputValue(pin_handle, AD_CS, 1); // AD_CS HIGH
CPUdelay(8000);
}
#endif
@@ -16,7 +16,7 @@
/* application use SPI parameters and buffers */
#define SPI_LED_SIZE 28
#define SPI_DAC_SIZE 5
#define SPI_DAC_SIZE 3
#define SPI_ADC_SIZE 4
static uint16_t spi_LEDtxbuf[SPI_LED_SIZE] = {0};
@@ -36,10 +36,13 @@ static SPI_Params spiParams1;
static SPI_Transaction LED_transaction;
static SPI_Transaction ADC_DAC_transaction;
static void ELITE15_SPI_HOLD();
static void ELITE15_SPI_CLOSE();
static void Elite_SPI_init(){
SPI_init();
SPI_Params_init(&spiParams0);
spiParams0.bitRate = 2000; // 2k
spiParams0.bitRate = 2000; // 12k
spiParams0.mode = SPI_MASTER;
spiParams0.dataSize = 16;
spiParams0.frameFormat = SPI_POL0_PHA1;
@@ -49,8 +52,7 @@ static void Elite_SPI_init(){
spiParams1.bitRate = 1000000; // 1M
spiParams1.mode = SPI_MASTER;
spiParams1.dataSize = 8;
spiParams1.frameFormat = SPI_POL0_PHA0;
spiParams1.frameFormat = SPI_POL0_PHA1;
spiHandle1 = SPI_open(Board_SPI1, &spiParams1); // ADC DAC SPI
}
@@ -63,7 +65,9 @@ static void LED_SPI(uint8_t length, uint16_t *spi_txbuf, uint16_t *spi_rxbuf) {
}
static void ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
PIN_setOutputValue(pin_handle, AD_CS, 0); // CS_ADC
// PIN15_setOutputValue(ADC_CS, 0); // ADC_CS LOW
PIN_setOutputValue(pin_handle, LOAD0, 1);
PIN_setOutputValue(pin_handle, D6, 0); // ADC_CS LOW
ADC_DAC_transaction.count = length;
ADC_DAC_transaction.txBuf = spi_txbuf;
@@ -71,231 +75,58 @@ static void ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
PIN_setOutputValue(pin_handle, AD_CS, 1); // CS_ADC
PIN_setOutputValue(pin_handle, D6, 1); // ADC_CS HOGH
update_latch_status (ADC_CS, 1);
// PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
}
static void DAC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
// PIN15_setOutputValue(DAC_CS, 0); // DAC_CS LOW
PIN_setOutputValue(pin_handle, LOAD0, 1);
PIN_setOutputValue(pin_handle, D7, 0); // DAC_CS LOW
ADC_DAC_transaction.count = length;
ADC_DAC_transaction.txBuf = spi_txbuf;
ADC_DAC_transaction.rxBuf = spi_rxbuf;
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
PIN_setOutputValue(pin_handle, D7, 1); // DAC_CS HOGH
update_latch_status (DAC_CS, 1);
// PIN15_setOutputValue(DAC_CS, 1); // DAC_CS HIGH
}
static void ELITE15_SPI_HOLD() {
Elite_SPI_init();
PIN_setOutputValue(pin_handle, LOAD0, 1);
PIN_setOutputValue(pin_handle, LOAD1, 0);
PIN_setOutputValue(pin_handle, LOAD2, 0);
}
static void ELITE15_SPI_CLOSE() {
PIN_setOutputValue(pin_handle, LOAD0, 0);
PIN_setOutputValue(pin_handle, LOAD1, 0);
PIN_setOutputValue(pin_handle, LOAD2, 0);
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) {
// PIN15_setOutputValue(ADC_CS, 0); // ADC_CS LOW
PIN_setOutputValue(pin_handle, LOAD0, 1);
PIN_setOutputValue(pin_handle, D6, 0); // ADC_CS LOW
ADC_DAC_transaction.count = length;
ADC_DAC_transaction.txBuf = spi_txbuf;
ADC_DAC_transaction.rxBuf = spi_rxbuf;
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
PIN_setOutputValue(pin_handle, AD_CS, 1); // CS_ADC
PIN_setOutputValue(pin_handle, D6, 1); // ADC_CS HOGH
update_latch_status (ADC_CS, 1);
// PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
}
static void CAL_LED_SPI(uint8_t length, uint16_t *spi_txbuf, uint16_t *spi_rxbuf) {
LED_transaction.count = length;
LED_transaction.txBuf = spi_txbuf;
LED_transaction.rxBuf = spi_rxbuf;
SPI_transfer(spiHandle0, &LED_transaction);
}
#ifdef ELITE_VERSION_EIS
//define SPI command
#define SPICMD_SETADDR 0x20
#define SPICMD_WRITEREG 0x2D
#define SPICMD_READREG 0x6D
//define REG
#define LPDACCON0 0x2128
#define LPDACSW0 0x2124
#define LPDACDAT0 0x2120
#define LPREFBUFCON 0x2050
#define SWMUX 0x235C
#define LPTIASW0 0x20E4
#define SWCON 0x200C
#define HSDACCON 0x2010
#define HSDACDAT 0x2048
#define LPTIACON0 0x20EC
#define HSTIACON 0x20FC
#define AFECON 0x2000
#define DSWFULLCON 0x2150
#define NSWFULLCON 0x2154
#define PSWFULLCON 0x2158
#define TSWFULLCON 0x215C
#define WGFCW 0x2030
#define WGPHASE 0x2034
#define WGOFFSET 0x2038
#define WGAMPLITUDE 0x203C
#define WGCON 0x2014
#define DE0RESCON 0x20F8
#define ADCCON 0x21A8
#define DFTCON 0x20D0
#define ADCFILTERCON 0x2044
static void select_REG(uint16_t addr){
PIN_setOutputValue(pin_handle, AD_CS, 0);
// CPUdelay(16000);
spi_DACtxbuf[0] = SPICMD_SETADDR;
spi_DACtxbuf[1] = (uint8_t)((addr & 0xFF00) >> 8);
spi_DACtxbuf[2] = (uint8_t)(addr & 0x00FF);
ADC_DAC_transaction.count = 3;
ADC_DAC_transaction.txBuf = spi_DACtxbuf;
ADC_DAC_transaction.rxBuf = spi_rxbuf;
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
// CPUdelay(16000);
PIN_setOutputValue(pin_handle, AD_CS, 1);
}
static void w16_REG(uint16_t data){
PIN_setOutputValue(pin_handle, AD_CS, 0);
spi_DACtxbuf[0] = SPICMD_WRITEREG;
spi_DACtxbuf[1] = (uint8_t)((data & 0xFF00) >> 8);
spi_DACtxbuf[2] = (uint8_t)(data & 0x00FF);
ADC_DAC_transaction.count = 3;
ADC_DAC_transaction.txBuf = spi_DACtxbuf;
ADC_DAC_transaction.rxBuf = spi_rxbuf;
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
PIN_setOutputValue(pin_handle, AD_CS, 1);
}
static void r16_REG(){
PIN_setOutputValue(pin_handle, AD_CS, 0);
spi_DACtxbuf[0] = SPICMD_READREG;
spi_DACtxbuf[1] = 0x00;
spi_DACtxbuf[2] = 0x00;
spi_DACtxbuf[3] = 0x00;
ADC_DAC_transaction.count = 4;
ADC_DAC_transaction.txBuf = spi_DACtxbuf;
ADC_DAC_transaction.rxBuf = spi_rxbuf;
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
PIN_setOutputValue(pin_handle, AD_CS, 1);
}
static void w32_REG(uint32_t data){
PIN_setOutputValue(pin_handle, AD_CS, 0);
spi_DACtxbuf[0] = SPICMD_WRITEREG;
spi_DACtxbuf[1] = (uint8_t)((data & 0xFF000000) >> 24);
spi_DACtxbuf[2] = (uint8_t)((data & 0x00FF0000) >> 16);
spi_DACtxbuf[3] = (uint8_t)((data & 0x0000FF00) >> 8);
spi_DACtxbuf[4] = (uint8_t)(data & 0x000000FF);
ADC_DAC_transaction.count = 5;
ADC_DAC_transaction.txBuf = spi_DACtxbuf;
ADC_DAC_transaction.rxBuf = spi_rxbuf;
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
PIN_setOutputValue(pin_handle, AD_CS, 1);
}
static void r32_REG(){
PIN_setOutputValue(pin_handle, AD_CS, 0);
spi_DACtxbuf[0] = SPICMD_READREG;
spi_DACtxbuf[1] = 0x00;
spi_DACtxbuf[2] = 0x00;
spi_DACtxbuf[3] = 0x00;
spi_DACtxbuf[4] = 0x00;
spi_DACtxbuf[5] = 0x00;
ADC_DAC_transaction.count = 6;
ADC_DAC_transaction.txBuf = spi_DACtxbuf;
ADC_DAC_transaction.rxBuf = spi_rxbuf;
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
PIN_setOutputValue(pin_handle, AD_CS, 1);
}
static void AD5940_init(){
PIN_setOutputValue(pin_handle, AD_reset, 0);
PIN_setOutputValue(pin_handle, AD_reset, 1);
select_REG(0x0908);//initiation
w16_REG(0x02C9);
select_REG(0x0C08);
w16_REG(0x206C);
select_REG(0x21F0);
w16_REG(0x0010);
select_REG(0x0410);
w16_REG(0x02C9);
select_REG(0x0A28);
w16_REG(0x0009);
select_REG(0x238C);
w16_REG(0x0104);
select_REG(0x0A04);
w16_REG(0x4859);
select_REG(0x0A04);
w16_REG(0xF27B);
select_REG(0x0A00);
w16_REG(0x8009);
select_REG(0x0A04);
w16_REG(0x4859);
select_REG(0x22F0);
w16_REG(0x0000);
select_REG(SWCON); //200C
w32_REG(0x000402B5); //0b1000000001010110101
select_REG(HSDACCON); //2010 //ac gain
w32_REG(0x0000001E);
select_REG(WGFCW); //2030
w32_REG(0x00340000); //SINEFCW/2^30 * 32 MHz
select_REG(WGCON); //2014
w32_REG(0x00000004); //AC on/off; 0x0:DC 0x4:AC 0x5:trapezoid
//0x0: 00000 DC
//0x4: 00100 Sinusoid
//0x6: 00110 Trapezoid ---Taylor
select_REG(LPDACCON0); //2128 //DC on
w32_REG(0b00000001);
select_REG(LPDACSW0); //2124 //operation
w32_REG(0b00101011);
select_REG(LPDACDAT0); //2120 //output Vout
w32_REG(0x00000000);
// select_REG(HSTIACON); //20FC //SE0's gain
// w32_REG(0x0);
select_REG(DE0RESCON); //20F8 //DE0's gain
w32_REG(0x00000068);
select_REG(ADCCON); //21A8
w32_REG(0x00000101);
select_REG(DFTCON); //20D0
w32_REG(0x000000C1);
select_REG(ADCFILTERCON); //2044
w32_REG(0x000000D0);
select_REG(AFECON); //2000
w32_REG(0x0030CFC0);
// w32_REG(0b1100011100111111000000);
}
static void EIS_LPDAC_SPI(){
// uint32_t con = 0b00001;//12 bit DAC
// uint32_t sw = 0b01010;//test mode
// uint32_t volt = 0;//2.4v
// uint32_t buf = 0;//LP reference
// uint32_t cm = 0;//common mode disabled
// select_REG(LPDACCON0);
// w32_REG(con);
// select_REG(LPDACSW0);
// w32_REG(sw);
// select_REG(LPDACDAT0);
// w32_REG(volt);
// select_REG(LPREFBUFCON);
// w32_REG(buf);
// select_REG(SWMUX);
// w32_REG(cm);
}
#endif
#endif // ELITE_SPI
@@ -1,7 +1,7 @@
#ifndef ELITE_WORK_DATA
#define ELITE_WORK_DATA
#define CLOCK_ONE_SECOND 00001
#define CLOCK_ONE_SECOND 10000
#include "EliteInstruction.h"
@@ -327,6 +327,66 @@ CVSCANMode * InitCVSCANMode(){
}
/*End of CONSTANT_VSCAN Mode*/
/* PULSE_MODE Mode(PULSE_MODE)*/
typedef struct _PULSEMode{
MEASURE;
// int32_t _Vinit;
int32_t _Vset;
int32_t _t1;
int32_t _t2;
int32_t _t3;
int32_t _t4;
int32_t _t5;
int32_t _v1;
int32_t _v2;
int32_t _v3;
int32_t _v4;
int32_t _v5;
int32_t _tflag;
int32_t _vflag;
uint16_t _cycleNumber;
uint16_t _loop;
int32_t _t1Time;
int32_t _t2Time;
int32_t _t3Time;
int32_t _t4Time;
int32_t _t5Time;
int32_t _tTime;
}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->_Vinit = (INSTRUCTION.Vinit - 25000) * 4 * 10000; //[5nV]
ret->_Vset = 0;
ret->_t1 = INSTRUCTION.t1;
ret->_t2 = INSTRUCTION.t2;
ret->_t3 = INSTRUCTION.t3;
ret->_t4 = INSTRUCTION.t4;
ret->_t5 = INSTRUCTION.t5;
ret->_v1 = INSTRUCTION.v1;
ret->_v2 = INSTRUCTION.v2;
ret->_v3 = INSTRUCTION.v3;
ret->_v4 = INSTRUCTION.v4;
ret->_v5 = INSTRUCTION.v5;
ret->_t1Time = INSTRUCTION.t1Time;
ret->_t2Time = INSTRUCTION.t2Time;
ret->_t3Time = INSTRUCTION.t3Time;
ret->_t4Time = INSTRUCTION.t4Time;
ret->_t5Time = INSTRUCTION.t5Time;
ret->_tTime = INSTRUCTION.t1Time;
ret->_tflag = 1;
ret->_vflag = INSTRUCTION.v1;
ret->_cycleNumber = INSTRUCTION.cycleNumber;
ret->_loop = INSTRUCTION.loop;
return ret;
}
/*End of PULSE_MODE Mode*/
/* Cycle CC Mode */
typedef struct _CCCMode{
int32_t _measureCurrent;
@@ -423,6 +483,7 @@ typedef union _WorkMode{
LSVMode *LSV;
CVSCANMode *CVSCAN;
PSMode *PS;
PULSEMode *PULSE;
// CCCMode *CCC;
}WorkMode;
@@ -464,6 +525,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 +600,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);
@@ -8,37 +8,97 @@
/* SPI Board */
#define Board_SPI0_MISO PIN_UNASSIGNED
#define Board_SPI0_MOSI IOID_4
#define Board_SPI0_CLK IOID_3
#define Board_SPI0_MOSI D1
#define Board_SPI0_CLK D0
#define Board_SPI0_CS PIN_UNASSIGNED
#define Board_SPI1_MISO IOID_1
#define Board_SPI1_MOSI IOID_6
#define Board_SPI1_CLK IOID_5
#define Board_SPI1_MOSI D3
#define Board_SPI1_CLK D2
#define Board_SPI1_CS PIN_UNASSIGNED
#define AD_CS IOID_10
#define D0 IOID_3
#define D1 IOID_4
#define D2 IOID_5
#define D3 IOID_6
#define D4 IOID_7
#define D5 IOID_8
#define D6 IOID_9
#define D7 IOID_10
//#define SD_MISO IOID_11
//#define SD_CS IOID_8
//#define SD_CLK IOID_7
//#define SD_MOSI IOID_13
#define LOAD0 IOID_13
#define LOAD1 IOID_12
#define LOAD2 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 LED_MOSI LOAD0, D1
#define LED_CLK LOAD0, D0
#define MEM_HOLD LOAD0, D4
#define MEM_CS 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 Turnon10K Turnon_I_MID
//#define Turnon200R Turnon_I_LARGE
/* I2C */
#ifdef ELITE_VERSION_1_4
#define Board_I2C0_SCL0 PIN_UNASSIGNED
#define Board_I2C0_SDA0 PIN_UNASSIGNED
#endif
#define shutdown_6994 LOAD2, D6
#define switch_on IOID_14
#define enable_5v IOID_9
#define AD_reset IOID_13
#define HIGH_Z_MODE LOAD2, D5
#define enable_10v LOAD1, D5
#define enable_5v LOAD1, D6
PIN_Handle pin_handle;
static PIN_State ZM_rst;
const PIN_Config BLE_IO[] = {
enable_5v | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,// 5V_enable
AD_reset | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
switch_on | PIN_INPUT_EN | PIN_PULLDOWN,
AD_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
// D0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// 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,
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,
switch_on | PIN_INPUT_EN | PIN_PULLDOWN, // to sense switch
PIN_TERMINATE
};
static void add_elite_pin() {
// PIN_Status elite15_status;
PIN_add(pin_handle,
D0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
PIN_add(pin_handle,
D1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
PIN_add(pin_handle,
D2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
PIN_add(pin_handle,
D3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
// if(elite15_status != PIN_SUCCESS) {
// LED_color(DARKLED, 0x0F, 0x0F, 0x0F);
// }
}
static void remove_elite_pin() {
PIN_close(pin_handle);
pin_handle = PIN_open(&ZM_rst, BLE_IO);
@@ -159,6 +219,8 @@ const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[CC2650_MA_I2CCOUNT] = {
.intNum = INT_I2C_IRQ,
.intPriority = ~0,
.swiPriority = 0,
.sdaPin = Board_I2C0_SDA0,
.sclPin = Board_I2C0_SCL0,
}
};
@@ -85,7 +85,7 @@ static void measureBat(){
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) |
((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
if( bat < 768 && bat > 20){
PIN_setOutputValue(pin_handle, enable_5v, 0);
PIN15_setOutputValue(enable_5v, 0);
}
}
@@ -39,17 +39,13 @@
#define ADC_TEST 0x91
#define CALI_DAC_MODE 0x93
#define CALI_ADC_MODE 0x92
#define DEV_MODE 0xFF
#define PULSE_MODE 0x94
// CIS (control instruction)
#define CIS_VERSION 0x40
#define CIS_VOLT 0x10
#define CIS_LED_TEST 0x70
#define CTL_WRT 0x20
#define CTL_RD 0x21
#define CTL_RD_DFTR 0x78
#define CTL_RD_DFTI 0x7C
#define CTL_WRT_WGAMPL 0x3C
// mode parameter
#define STEP_TO_VSETRATE(step) step2VsetRate(step)
#define VMAX(v1,v2) ((v1 >= v2) ? v1 : v2)
@@ -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;
}
@@ -447,12 +465,12 @@ static void readIin(WorkMode *WorkModeData){
if(INSTRUCTION.AutoGainEnable){
TEMP_MODE->_measureCurrent = AutoGainReadIin(spi_ADC_rxbuf);
// AutoGainChangeIin(TEMP_MODE->_measureCurrent);
AutoGainChangeIin(TEMP_MODE->_measureCurrent);
}else{
ReadADCIin(spi_ADC_rxbuf);
TEMP_MODE->_measureCurrent = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
if(lastIinADCGainLevel != INSTRUCTION.ADCGainLevel){
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
IinADCGainControl(INSTRUCTION.ADCGainLevel);
record_flag = false;
}
}
@@ -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;
}
@@ -507,12 +529,12 @@ static int32_t readVinVout(WorkMode *WorkModeData){
if(TEMP_MODE->_VoViSwitch == 0x01 || TEMP_MODE->_VoViSwitch == 0x02){
if(INSTRUCTION.VinAutoGainEnable){
TEMP_MODE->_measureVin = AutoGainReadVin(spi_ADC_rxbuf);
// AutoGainChangeVin(TEMP_MODE->_measureVin);
AutoGainChangeVin(TEMP_MODE->_measureVin);
}else{
ReadADCVolt(TEMP_MODE->_VoViSwitch);
TEMP_MODE->_measureVin = DecodeADCValue(INSTRUCTION.VinADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
if(lastVinADCGainLevel != INSTRUCTION.VinADCGainLevel){
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
record_flag = false;
}
@@ -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;
@@ -572,8 +598,10 @@ static void cali_IT_plot(WorkMode *WorkModeData) {
}
static uint8_t ADCSwitch = 0;
int32_t ADCValueTemp = 0;
static int32_t ADCValueSUM = 0;
int32_t ADCValueAVG = 0;
int16_t ADCValueAVG_RAW = 0;
if(ADCSwitch == 0){ /**read Iin(buffer)**/
if(INSTRUCTION.AutoGainEnable){
@@ -582,7 +610,7 @@ static void cali_IT_plot(WorkMode *WorkModeData) {
ReadADCIin(spi_ADC_rxbuf);
CURRENT_MODE->_measureCurrent = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
if(lastIinADCGainLevel != INSTRUCTION.ADCGainLevel){
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
IinADCGainControl(INSTRUCTION.ADCGainLevel);
record_flag = false;
}
}
@@ -596,7 +624,7 @@ static void cali_IT_plot(WorkMode *WorkModeData) {
}
}else{
static uint16_t cali_count = 0;
if(cali_count >= 1000){
if(cali_count >= 5000){
ADCValueAVG = ADCValueSUM / cali_count;
InputNotify(NOTIFY_CURRENT, ADCValueAVG);
@@ -614,12 +642,13 @@ static void cali_IT_plot(WorkMode *WorkModeData) {
PeriodicEvent = false;
ModeLED(NO_EVENT);
}else{
cali_count++;
ADCValueSUM = ADCValueSUM + CURRENT_MODE->_measureCurrent;
InputNotify(NOTIFY_CURRENT, CURRENT_MODE->_measureCurrent);
InputNotify(NOTIFY_VOLT, ADCValueSUM);
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
// InputNotify(NOTIFY_CURRENT, CURRENT_MODE->_measureCurrent);
// InputNotify(NOTIFY_VOLT, ADCValueSUM);
// InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
}
}
@@ -675,6 +704,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;
@@ -683,8 +716,10 @@ static void cali_VT_plot(WorkMode *WorkModeData) {
static uint8_t ADCSwitch = 0;
static int32_t VoltData;
int32_t ADCValueTemp = 0;
static int32_t ADCValueSUM = 0;
int32_t ADCValueAVG = 0;
int16_t ADCValueAVG_RAW = 0;
if(ADCSwitch == 0){ /**read Iin(buffer)**/
if(CURRENT_MODE->_VoViSwitch == 0x01 || CURRENT_MODE->_VoViSwitch == 0x02){
@@ -694,7 +729,7 @@ static void cali_VT_plot(WorkMode *WorkModeData) {
ReadADCVolt(CURRENT_MODE->_VoViSwitch);
CURRENT_MODE->_measureVin = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
if(lastVinADCGainLevel != INSTRUCTION.VinADCGainLevel){
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
record_flag = false;
}
@@ -3,10 +3,10 @@
#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_MONTH 11
#define VERSION_DATE_DAY 26
#define VERSION_DATE_HOUR 22
#define VERSION_DATE_MINUTE 48
// this is NOT the version hash !!
// it's the last version hash
@@ -430,14 +430,19 @@ 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
#define MINOR_PRODUCT_NUMBER 2 //1:Elite_legacy(Ori_Neulive) 2:Elite_zm 3:Elite_bat
#define MAJOR_VERSION_NUMBER 1
#define MINOR_VERSION_NUMBER 6
#define ELITE_VERSION_EIS
//#define ELITE_VERSION_1_4
#define MINOR_VERSION_NUMBER 7
#define ELITE_VERSION_1_4
//#define ELITE_VERSION_1_3
// buffer size
@@ -482,6 +487,7 @@ struct _LH{
uint8_t LoadState;
} LH= {0};
static void InitLH();
static void Init_Elite15_PIN();
static Clock_Struct periodicClock;
@@ -550,6 +556,7 @@ static bool record_flag;
static bool vscanReset;
static bool EliteWorkReset;
static bool leadTimeReset;
static bool firstTimeReset;
static int16_t I_GAIN_100R_counter;
static int16_t I_GAIN_3K_counter;
static int16_t I_GAIN_100K_counter;
@@ -567,17 +574,22 @@ static bool preWorkLedFlag = 0;
static bool workingLedFlag = 0;
static bool postWorkLedFlag = 0;
static void update_latch_status (uint32_t latch_num, uint32_t elite_pin, bool highlow);
// ADC function
static int32_t DecodeADCValue(uint8_t ADCGain, uint8_t ADCChannel, uint8_t *ADC_raw);
static void headstage_battery_volt();
static void EliteADCBattery();
//static void VinADCGainControl(uint8_t VinADCLevel);
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);
// Elite key detection & turn on/ shutdown function (peripheral hardware control)
static void Elite_led_color(uint16_t color);
static void ModeLED(uint16_t modeStatus);
//static void LED_color(uint8_t bright, uint8_t red, uint8_t green, uint8_t blue);
static bool If10Von = false;
static void TurnOn10V();
// periodic event control
static void EliteADCControl();
@@ -597,6 +609,8 @@ 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);
static void test_Vscan(PULSEMode *PULSE);
//mode (notify)
static void initDATBuf();
@@ -611,6 +625,7 @@ static void InitEliteFlag();
#include "EliteDAC.h"
#include "EliteSPI.h"
#include "Elite_PIN.h"
#include "Elite15_PIN.h"
#ifdef ELITE_VERSION_1_4
#include "EliteI2C.h"
@@ -634,6 +649,7 @@ static void InitEliteFlag();
#include "EliteCV3Mode.h"
#include "EliteLSVMode.h"
#include "EliteCVSCANMode.h"
#include "ElitePulseMode.h"
#include "Elite_batt.h"
#include "Elite_power.h"
@@ -641,7 +657,7 @@ static void InitEliteFlag();
static void update_ZM_instruction(uint8 *ins) {
uint8_t ins_type = ins[0] & 0b11110000;
uint8_t chip_ID = ins[0] & 0b00001111;
uint8_t oper = ins[1] & 0xFF; // this is don't care in RIS
uint8_t oper = ins[1] & 0xF0; // this is don't care in RIS
INSTRUCTION.chip_id = chip_ID;
switch (ins_type) {
@@ -650,6 +666,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
INSTRUCTION.eliteFxn = IV_CURVE;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.Ve1 = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
@@ -666,11 +683,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
INSTRUCTION.eliteFxn = CV_CURVE;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.Ve1 = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
@@ -687,25 +712,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
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
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;
}
@@ -729,6 +776,7 @@ static void update_ZM_instruction(uint8 *ins) {
case CONSTANT_CURRENT:{
ModeLED(WORKING);
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
@@ -737,6 +785,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
@@ -746,6 +796,7 @@ 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){
INSTRUCTION.sampleRate = 15;
INSTRUCTION.Vinit = ((int32_t)(ins[4]) << 8) | (int32_t)(ins[5]);
@@ -770,12 +821,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
INSTRUCTION.eliteFxn = CYCLIC_VOLTAMMETRY;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.Vinit = ((int32_t)(ins[3]) << 8) | (int32_t)(ins[4]);
@@ -797,11 +851,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:{
ModeLED(WORKING);
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]);
@@ -819,11 +876,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:{
ModeLED(WORKING);
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]);
@@ -831,6 +891,8 @@ 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;
}
@@ -945,10 +1007,19 @@ static void update_ZM_instruction(uint8 *ins) {
// INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
// }
INSTRUCTION.VoutGainLevel = ins[4];
VoutGainControl(INSTRUCTION.VoutGainLevel);
break;
}
case HIGH_Z :{
switch(ins[4]) {
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
break;
}
default :{
break;
}
@@ -972,23 +1043,32 @@ static void update_ZM_instruction(uint8 *ins) {
switch(ins[3]) {
case IIN_ADC :{ // 0x00
// IinADCGainControl(ins[4]);
IinADCGainControl(ins[4]);
AVG_done = 1;
ADC_input = CMD_CURRENT_MEASURE;
break;
}
case VIN_ADC :{ // 0x01
// VinADCGainControl(ins[4]);
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 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
break;
}
default :{
break;
}
@@ -1049,6 +1129,7 @@ static void update_ZM_instruction(uint8 *ins) {
case CALI_DAC_MODE: {
ModeLED(WORKING);
INSTRUCTION.eliteFxn = CALI_DAC_MODE;
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
INSTRUCTION.VoltConstant = ( ((uint16_t)(ins[3])) << 8) | (uint16_t)(ins[4]);
break;
}
@@ -1080,124 +1161,94 @@ static void update_ZM_instruction(uint8 *ins) {
break;
}
case DEV_MODE: { // INS_TYPE_RIS:0x30, DEV_MODE:0xFFF
switch (ins[3]) {
case CTL_WRT: { // ble write: 0x3000FF 20FFFFFFFFFFFF
uint32_t address = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
uint32_t data = ((uint16_t)(ins[6]) << 24) | (uint16_t)(ins[7]) << 16 |
(uint16_t)(ins[8]) << 8 | (uint16_t)(ins[9]);
case PULSE_MODE:{
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
if(ins[3] == PARA_1){
INSTRUCTION.sampleRate = 15;
INSTRUCTION.notifyRate = 100;
INSTRUCTION.VoViSwitch = 0x01;
INSTRUCTION.t1 = 1;
INSTRUCTION.t2 = 2;
INSTRUCTION.t3 = 3;
INSTRUCTION.t4 = 4;
INSTRUCTION.t5 = 5;
INSTRUCTION.t1Time = (int32_t)(ins[4]) << 24 | (int32_t)(ins[5]) << 16 | (int32_t)(ins[6]) << 8 | (int32_t)(ins[7]);
INSTRUCTION.t2Time = (int32_t)(ins[8]) << 24 | (int32_t)(ins[9]) << 16 | (int32_t)(ins[10]) << 8 | (int32_t)(ins[11]);
INSTRUCTION.t3Time = (int32_t)(ins[12]) << 24 | (int32_t)(ins[13]) << 16 | (int32_t)(ins[14]) << 8 | (int32_t)(ins[15]);
INSTRUCTION.t4Time = (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.eliteFxn = PULSE_MODE;
ModeLED(WORKING);
INSTRUCTION.v1 = 25000;
INSTRUCTION.v2 = 50000;
INSTRUCTION.v3 = 25000;
INSTRUCTION.v4 = 25000;
INSTRUCTION.v5 = 25000;
INSTRUCTION.t5Time = (int32_t)(ins[4]) << 24 | (int32_t)(ins[5]) << 16 | (int32_t)(ins[6]) << 8 | (int32_t)(ins[7]);
INSTRUCTION.cycleNumber = (uint16_t)(ins[8]);
INSTRUCTION.loop = (uint16_t)(ins[9]);
INSTRUCTION.VsetRate = 2;
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
select_REG(address);
w32_REG(data);
initCISBuf();
cis_buf[0] = (uint8_t)((address & 0x0000FF00) >> 8);
cis_buf[1] = (uint8_t)(address & 0x000000FF);
cis_buf[2] = (uint8_t)((data & 0xFF000000) >> 24);
cis_buf[3] = (uint8_t)((data & 0x00FF0000) >> 16);
cis_buf[4] = (uint8_t)((data & 0x0000FF00) >> 8);
cis_buf[5] = (uint8_t)(data & 0x000000FF);
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
break;
}
case CTL_RD: { // ble write: 0x3000FF 21FFFF
uint32_t address = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
select_REG(address);
r32_REG();
initCISBuf();
cis_buf[0] = (uint8_t)((address & 0x0000FF00) >> 8);
cis_buf[1] = (uint8_t)(address & 0x000000FF);
cis_buf[2] = spi_rxbuf[2];
cis_buf[3] = spi_rxbuf[3];
cis_buf[4] = spi_rxbuf[4];
cis_buf[5] = spi_rxbuf[5];
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
break;
}
case CTL_RD_DFTR: { // ble write: 0x3000FF 78FFFFFFFF
select_REG(0x2078);
r32_REG();
initCISBuf();
cis_buf[0] = (uint8_t)(0x20);
cis_buf[1] = (uint8_t)(0x78);
cis_buf[2] = spi_rxbuf[2];
cis_buf[3] = spi_rxbuf[3];
cis_buf[4] = spi_rxbuf[4];
cis_buf[5] = spi_rxbuf[5];
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
break;
}
case CTL_RD_DFTI: { // ble write: 0x3000FF 7CFFFFFFFF
select_REG(0x207C);
r32_REG();
initCISBuf();
cis_buf[0] = (uint8_t)(0x20);
cis_buf[1] = (uint8_t)(0x7C);
cis_buf[2] = spi_rxbuf[2];
cis_buf[3] = spi_rxbuf[3];
cis_buf[4] = spi_rxbuf[4];
cis_buf[5] = spi_rxbuf[5];
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
break;
}
case CTL_WRT_WGAMPL: { // ble write: 0x3000FF 3CFFFFFFFF | write waveform generator amplitude
uint32_t data = ((uint16_t)(ins[4]) << 24) | (uint16_t)(ins[5]) << 16 | (uint16_t)(ins[6]) << 8 | (uint16_t)(ins[7]);
select_REG(0x2014);
w32_REG(0x0); // 0x0: DC disable ac first
select_REG(0x203C);
w32_REG(data);
initCISBuf();
cis_buf[0] = (uint8_t)(0x20);
cis_buf[1] = (uint8_t)(0x3C);
cis_buf[2] = (uint8_t)((data & 0xFF000000) >> 24);
cis_buf[3] = (uint8_t)((data & 0x00FF0000) >> 16);
cis_buf[4] = (uint8_t)((data & 0x0000FF00) >> 8);
cis_buf[5] = (uint8_t)(data & 0x000000FF);
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
select_REG(0x2014);
w32_REG(0x4); //0x4: Sinusoid
break;
}
case 0x01: { // ble write: 0x3000FF 01
if (ins[4] == 1) {
Elite_led_color(COLOR_RED); //0101
} else if (ins[4] == 2){
Elite_led_color(COLOR_ORANGE); //0102
} else if (ins[4] == 3){
Elite_led_color(COLOR_YELLOW);
} else if (ins[4] == 4){
Elite_led_color(COLOR_GREEN);
} else if (ins[4] == 5){
Elite_led_color(COLOR_BLUE);
} else if (ins[4] == 6){
Elite_led_color(COLOR_MAGENTA);
} else if (ins[4] == 7){
Elite_led_color(COLOR_PURPLE);
}
initCISBuf();
cis_buf[0] = (uint8_t)(0x11);
cis_buf[1] = (uint8_t)(0xFF);
cis_buf[2] = ins[4];
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
break;
}
}
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
// INSTRUCTION.eliteFxn = PULSE_MODE;
// ModeLED(WORKING);
//
// INSTRUCTION.sampleRate = 15;
// INSTRUCTION.notifyRate = 1000;
// INSTRUCTION.VoViSwitch = 0x01;
// INSTRUCTION.t1 = 1;
// INSTRUCTION.t2 = 2;
// INSTRUCTION.t3 = 3;
// INSTRUCTION.t4 = 4;
// INSTRUCTION.t5 = 5;
// INSTRUCTION.t1Time = ((int32_t)(ins[3]) << 8) | (int32_t)(ins[4]);
// INSTRUCTION.t2Time = ((int32_t)(ins[5]) << 8) | (int32_t)(ins[6]);
// INSTRUCTION.t3Time = ((int32_t)(ins[7]) << 8) | (int32_t)(ins[8]);
// INSTRUCTION.t4Time = ((int32_t)(ins[9]) << 8) | (int32_t)(ins[10]);
// INSTRUCTION.t5Time = ((int32_t)(ins[11]) << 8) | (int32_t)(ins[12]);
// INSTRUCTION.v1 = 25000;
// INSTRUCTION.v2 = 50000;
// INSTRUCTION.v3 = 25000;
// INSTRUCTION.v4 = 25000;
// INSTRUCTION.v5 = 25000;
// INSTRUCTION.cycleNumber = (uint16_t)(ins[13]);
// INSTRUCTION.loop = (uint16_t)(ins[14]);
// INSTRUCTION.VsetRate = 2;
//
// INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
//------------------------------------------------------------------------------------------
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
// INSTRUCTION.eliteFxn = PULSE_MODE;
// ModeLED(WORKING);
//
// INSTRUCTION.sampleRate = 15;
// INSTRUCTION.notifyRate = 1000;
// INSTRUCTION.VoViSwitch = 0x01;
// INSTRUCTION.t1 = 1;
// INSTRUCTION.t1Time = 20000;
// INSTRUCTION.t2 = 2;
// INSTRUCTION.t2Time = 20000;
// INSTRUCTION.t3 = 3;
// INSTRUCTION.t3Time = 20000;
// INSTRUCTION.t4 = 4;
// INSTRUCTION.t4Time = 20000;
// INSTRUCTION.t5 = 5;
// INSTRUCTION.t5Time = 20000;
// INSTRUCTION.v1 = 25000; //1V
// INSTRUCTION.v2 = 50000; //2V
// INSTRUCTION.v3 = 25000; //3V
// INSTRUCTION.v4 = 25000;
// INSTRUCTION.v5 = 25000;
// INSTRUCTION.cycleNumber = 5;
// INSTRUCTION.loop = 2;
// INSTRUCTION.VsetRate = 2;
//
// INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
break;
}
@@ -1274,6 +1325,7 @@ static void update_ZM_instruction(uint8 *ins) {
case VIS_CC_ZERO:{
ModeLED(PRE_WORK);
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.charge = 0x01;
@@ -1282,6 +1334,7 @@ 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;
}
@@ -1295,7 +1348,7 @@ static void update_ZM_instruction(uint8 *ins) {
case INS_TYPE_CIS: {
switch (oper) {
case 0x00: {
// I2CWrite(0x01, 0xAB);
I2CWrite(0x01, 0xAB);
break;
}
@@ -46,12 +46,21 @@ static void ZM_init() {
// initialize
pin_handle = PIN_open(&ZM_rst, BLE_IO);
Init_Elite15_PIN();
ELITE15_SPI_HOLD();
PIN_setOutputValue(pin_handle, AD_CS, 1); // AD_CS HIGH
PIN15_setOutputValue(shutdown_6994, 1); // OFF = 1 => turn off 6994
PIN15_setOutputValue(enable_10v, 0); // enable 10V
PIN15_setOutputValue(HIGH_Z_MODE, 1); // HIGH Z MODE // 1 => close high_z mode
InitEliteInstruction();
IinADCGainControl(INSTRUCTION.ADCGainLevel);
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
VoutGainControl(INSTRUCTION.VoutGainLevel);
elite_gptimer_open();
// PIN_registerIntCb(pin_handle, switch_on_callback);
// PIN_setInterrupt(pin_handle, switch_on | PIN_IRQ_POSEDGE);
}
static void ZM_update_instruction_callback(uint8_t ins_type, uint8_t chip_ID, uint8_t *ins) {}
@@ -110,8 +119,10 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
EliteWorkReset = false;
batteryADC_flag = false;
record_flag = true;
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
firstTimeReset = true;
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
IinADCGainControl(INSTRUCTION.ADCGainLevel);
VoutGainControl(INSTRUCTION.VoutGainLevel);
if( Ve1MatchVe2Mode() ){
if (INSTRUCTION.Ve1 == INSTRUCTION.Ve2) {
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.Ve1));
@@ -160,7 +171,7 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) | ((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
if( bat < 768 && bat > 20){
PIN_setOutputValue(pin_handle, enable_5v, 0);
PIN15_setOutputValue(enable_5v, 0);
}
//ADC counter
@@ -190,18 +201,126 @@ 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;
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);
}
}
}
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;
if (vscanReset) {
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
//vscanReset = false;
}else{
test_Vscan(WorkModeData->PULSE);
}
// if(GPT.VscanRateCounter >= INSTRUCTION.VsetRate){
// if(GPT.VscanRateCounter >= INSTRUCTION.VsetRate * 2){
// GPT.GptimerMultiple = GPT.VscanRateCounter / INSTRUCTION.VsetRate;
// }else{
// GPT.GptimerMultiple = 1;
// }
// GPT.VscanRateCounter -= INSTRUCTION.VsetRate * GPT.GptimerMultiple; //To get right time
// vscan_flag = true;
// if(vscan_flag){
// EliteVscanControl(WorkModeData);
// vscan_flag = false;
// }
// }
//battery counter
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
if(GPT.BatteryCheckCounter >= 50000){
GPT.BatteryCheckCounter -= 50000; //To get right time
batteryCheck_flag = true;
}
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) | ((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
if( bat < 768 && bat > 20){
PIN15_setOutputValue(enable_5v, 0);
}
//ADC counter
GPT.SampleRateCounter = GPT.SampleRateCounter + GPT.DeltaGptimerCounter;
if(GPT.SampleRateCounter >= INSTRUCTION.sampleRate){
GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
ADC_flag = true;
if(ADC_flag){
EliteADCControl(WorkModeData);
ADC_flag = false;
}
}
//Notify counter(Notify control, check if we need to send notify)
//please don't put Notify counter before ADC counter, maybe get wrong data
GPT.NotifyCounter = GPT.NotifyCounter + GPT.DeltaGptimerCounter;
if(GPT.NotifyCounter >= INSTRUCTION.notifyRate){
GPT.NotifyCounter -= INSTRUCTION.notifyRate; //To get right time
notify_flag = true;
if(vscanReset){
notify_flag = false;
}
if(notify_flag){
SendNotify();
notify_flag = false;
}
}
// EliteDone();
}
else if(INSTRUCTION.eliteFxn == VOLT_OUTPUT){
VoutGainControl(INSTRUCTION.VoutGainLevel);
WorkModeData->VO->_Vset = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, WorkModeData->VO->_Vset)); //UserCode -> DAC code -> DAC out
FreeWorkMode(WorkModeData);
PeriodicEvent = false;
}else if(INSTRUCTION.eliteFxn == CALI_DAC_MODE){
}
else if(INSTRUCTION.eliteFxn == CALI_DAC_MODE){
DAC_outputV(INSTRUCTION.VoltConstant); //UserCode -> DAC code -> DAC out
FreeWorkMode(WorkModeData);
PeriodicEvent = false;
}
else{
InitFlag();
// InitFlag();
}
}
@@ -252,6 +371,10 @@ static void EliteADCControl(WorkMode *WorkModeData) {
break;
}
case PULSE_MODE:{
CC_Plot(WorkModeData);
break;
}
default:{
break;
}
@@ -297,6 +420,10 @@ static void EliteVscanControl(WorkMode *WorkModeData) {
CVSCAN_Vscan(WorkModeData->CVSCAN);
break;
}
case PULSE_MODE:{
PULSE_Vscan(WorkModeData->PULSE);
break;
}
default:{
break;
}
@@ -546,22 +546,24 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
// Initialize application
SimpleBLEPeripheral_init();
ZM_init();
WorkMode *WorkModeData = CreateWorkMode();
// init DAC, set output ~= 0 V
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
uint8_t key = 0;
uint16_t counter6994 = 0;
bool EliteOn = 0;
// init DAC, set output ~= 0 V
// DAC_outputV(25000);
elite_gptimer_start();
// Application main loops
GPT.GptimerCounter0 = GPT.GptimerCounter;
batteryADC_flag = false;
// headstage_battery_volt();
headstage_battery_volt();
headstage_init_device_info();
for (;;) {
@@ -616,39 +618,39 @@ 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) {
} 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;
// }
if(key != 0){ //detect Elite battery power when no periodic event
measureBat();
}
if(Free_Work_Mode){
FreeWorkMode(WorkModeData);
InitEliteInstruction();
Free_Work_Mode = false;
}
} else {
EliteOn = TurnOnElite(key);
}
}
// else { // if there is periodic event
// if(InitPeriodicEvent){
// InitWorkMode(WorkModeData);
// InitPeriodicEvent = false;
// }
//
// // Perform periodic application task
// SimpleBLEPeripheral_performPeriodicTask(WorkModeData);
// key = PIN_getInputValue(switch_on);
// EliteKeyPress(key); // onPress=> key = 0; 1.lighten LED 2.long press shut down 2650
// }
else { // if there is periodic event
if(InitPeriodicEvent){
InitWorkMode(WorkModeData);
InitPeriodicEvent = false;
}
// Perform periodic application task
SimpleBLEPeripheral_performPeriodicTask(WorkModeData);
key = PIN_getInputValue(switch_on);
EliteKeyPress(key); // onPress=> key = 0; 1.lighten LED 2.long press shut down 2650
}
}
#ifdef FEATURE_OAD