Compare commits

..

1 Commits

Author SHA1 Message Date
yichin 646650ddee test data rate 2020-05-06 18:05:37 +08:00
48 changed files with 789 additions and 2619 deletions
+1 -7
View File
@@ -8,7 +8,7 @@ no device y=ax+b MAC a+ b+ a- b- avg
7 c652 c652 18:04:ED:37:C6:52 2024 -7687 2086 -11283 4.88850143182858
8 c5ed c5ed 18:04:ED:37:C5:ED 2231 -1711 2353 -70845 4.45265043545859
9 9bef 9bef 0081F9E49BEF 2383 -8585 2415 -20347 4.2758539244186
10 8b50 8b50 00:81:F9:E4:8B:50 2366 -5223 2402 -14971 4.35162291666667
10 8b50 8b50 00:81:F9:E4:8B:50 2369 -11005 2360 -11797 4.30475635707671
11 c641 c641 18:04:ED:37:C6:41 2090 4616 1997 -40665 5.07591391714942
12 E8E6 E8E6 A4:DA:32:D4:E8:E6 2306 -88454 2418 -15140 4.2686494968089
13 E73B E73B A4:DA:32:D4:E7:3B 2262 -564 2298 44746 4.35551198222141
@@ -21,9 +21,3 @@ no device y=ax+b MAC a+ b+ a- b- avg
20 EEDB EEDB A4:DA:32:D4:EE:DB 2214 -1170 2351 -24636 4.44485358085645
21 E73A E73A A4:DA:32:D4:E7:3A 2210 -4855 2339 -16434 4.47776494604746
22 E6CF E6CF A4:DA:32:D4:E6:CF 2135 -5206 2193 -30885 4.73462680884304
23 E76A E76A A4:DA:32:D4:E7:6A 2076 1154 2096 -1073 4.840805202
24 F0AC F0AC A4:DA:32:D4:F0:AC 2125 -6660 2170 -439 4.667508288
25 E87C E87C A4:DA:32:D4:E8:7C 2265 6685 2230 2124 4.529796387
26 EF39 EF39 A4:DA:32:D4:EF:39 1976 6641 2035 2834 5.071840495
27 E91D E91D A4:DA:32:D4:E9:1D 2075 6344 2002 -5562 5.036438558
28 E87A E87A A4:DA:32:D4:E8:7A 2180 6651 2254 136 4.60339152
+1 -1
View File
@@ -4,7 +4,7 @@
#folder=$($path | awk -F"/" '{$NF}')
folder=$(basename "$(pwd)")
if [ "$folder" == "ti" ] ; then
if [ "$folder" == "bioprocc2650" ]; then
year=$(date +%-y)
month=$(date +%-m)
day=$(date +%-d)
@@ -2,17 +2,17 @@
<launchConfiguration type="com.ti.ccstudio.debug.launchType.device.debugging">
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot; ?&gt;&#10;&lt;PropertyValues&gt;&#10;&#10; &lt;property id=&quot;ConnectOnStartup&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;EnableInstalledBreakpoint&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;IgnoreSoftLaunchFailures&quot;&gt;&#10; &lt;curValue&gt;0&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10;&lt;/PropertyValues&gt;&#10;"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot; ?&gt;&#10;&lt;PropertyValues&gt;&#10;&#10; &lt;property id=&quot;ConnectOnStartup&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;EnableInstalledBreakpoint&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;IgnoreSoftLaunchFailures&quot;&gt;&#10; &lt;curValue&gt;0&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10;&lt;/PropertyValues&gt;&#10;"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot; ?&gt;&#10;&lt;PropertyValues&gt;&#10;&#10; &lt;property id=&quot;ConnectOnStartup&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;EnableInstalledBreakpoint&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;IgnoreSoftLaunchFailures&quot;&gt;&#10; &lt;curValue&gt;0&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10;&lt;/PropertyValues&gt;&#10;"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot; ?&gt;&#10;&lt;PropertyValues&gt;&#10;&#10; &lt;property id=&quot;ConnectOnStartup&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;EnableInstalledBreakpoint&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;IgnoreSoftLaunchFailures&quot;&gt;&#10; &lt;curValue&gt;0&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10;&lt;/PropertyValues&gt;&#10;"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_app}"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_app}"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_app}"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_app}"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="simple_peripheral_cc2650em_app"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="simple_peripheral_cc2650em_app"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="simple_peripheral_cc2650em_app"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="simple_peripheral_cc2650em_app"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_TARGET_CONFIG" value="${target_config_active_default:simple_peripheral_cc2650em_app}"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/simple_peripheral_cc2650em_app"/>
</listAttribute>
@@ -19,7 +19,7 @@
</property>
<property Type="choicelist" Value="1" id="Debug Probe Selection">
<choice Name="Select by serial number" value="0">
<property Type="stringfield" Value="L1000628" id="-- Enter the serial number"/>
<property Type="stringfield" Value="L1000537" id="-- Enter the serial number"/>
</choice>
</property>
<platform XML_version="1.2" id="platform_0">
@@ -3,6 +3,6 @@
* step by the lib_search utility
*/
"/home/alan/ti/simplelink/ble_sdk_2_02_02_25/blelib/host/host_pxxx.a"
"/home/alan/ti/simplelink/ble_sdk_2_02_02_25/blelib/ctrl/cc2640/cc2640_ctrl_pxxx_ext.a"
"/home/alan/ti/simplelink/ble_sdk_2_02_02_25/blelib/hci_tl/cc26xx/cc26xx_hci_tl_none_v41_v42.a"
"C:\ti\simplelink\ble_sdk_2_02_02_25\blelib\host\host_pxxx.a"
"C:\ti\simplelink\ble_sdk_2_02_02_25\blelib\ctrl\cc2640\cc2640_ctrl_pxxx_ext.a"
"C:\ti\simplelink\ble_sdk_2_02_02_25\blelib\hci_tl\cc26xx\cc26xx_hci_tl_none_v41_v42.a"
@@ -1,6 +1,6 @@
#
# This file was generated based on the configuration script:
# /home/alan/ti/simplelink/ble_sdk_2_02_02_25/examples/cc2650em/simple_peripheral/ccs/config/app_ble.cfg
# C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\config\app_ble.cfg
#
# This makefile may be included in other makefiles that need to build
# the libraries containing the compiled source files generated as
@@ -14,9 +14,9 @@
#
# The absolute path to the generated source directory (at the time the
# sources were generated) is:
# /home/alan/ti/simplelink/ble_sdk_2_02_02_25/examples/cc2650em/simple_peripheral/ccs/config/src
# C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\config\src
#
GEN_SRC_DIR ?= ../../../ti/simplelink/ble_sdk_2_02_02_25/examples/cc2650em/simple_peripheral/ccs/config/src
GEN_SRC_DIR ?= ../../config/src
ifeq (,$(wildcard $(GEN_SRC_DIR)))
$(error "ERROR: GEN_SRC_DIR must be set to the directory containing the generated sources")
@@ -1,29 +1,29 @@
XOPTS = -I"/home/alan/ti/xdctools_3_32_01_22_core/packages/" -Dxdc_target_types__=/home/alan/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/targets/arm/elf/std.h -Dxdc_target_name__=M3
XOPTS = -I"C:/ti/xdctools_3_32_02_25_core/packages/" -Dxdc_target_types__=C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/targets/arm/elf/std.h -Dxdc_target_name__=M3
vpath % /home/alan/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/sysbios/
vpath %.c /home/alan/ti/xdctools_3_32_01_22_core/packages/
vpath % C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/sysbios/
vpath %.c C:/ti/xdctools_3_32_02_25_core/packages/
CCOPTS = --endian=little -mv7M3 --abi=eabi -q -ms --opt_for_speed=0 --program_level_compile -o3 -g --optimize_with_debug -Dti_sysbios_knl_Task_minimizeLatency__D=FALSE -Dti_sysbios_family_arm_cc26xx_Boot_driverlibVersion=2 -Dti_sysbios_knl_Clock_stopCheckNext__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_enableException__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_disablePriority__D=32U -Dti_sysbios_family_arm_m3_Hwi_numSparseInterrupts__D=0U
XDC_ROOT = /home/alan/ti/xdctools_3_32_01_22_core/packages/
XDC_ROOT = C:/ti/xdctools_3_32_02_25_core/packages/
BIOS_ROOT = /home/alan/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/sysbios/
BIOS_ROOT = C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/sysbios/
BIOS_DEFS = -Dti_sysbios_BIOS_swiEnabled__D=TRUE -Dti_sysbios_BIOS_taskEnabled__D=TRUE -Dti_sysbios_BIOS_clockEnabled__D=TRUE -Dti_sysbios_BIOS_runtimeCreatesEnabled__D=TRUE -Dti_sysbios_knl_Task_moduleStateCheckFlag__D=FALSE -Dti_sysbios_knl_Task_objectCheckFlag__D=FALSE -Dti_sysbios_hal_Hwi_DISABLE_ALL_HOOKS -Dti_sysbios_knl_Swi_DISABLE_ALL_HOOKS -Dti_sysbios_BIOS_smpEnabled__D=FALSE -Dti_sysbios_Build_useHwiMacros -Dti_sysbios_knl_Swi_numPriorities__D=6 -Dti_sysbios_knl_Task_deleteTerminatedTasks__D=FALSE -Dti_sysbios_knl_Task_numPriorities__D=6 -Dti_sysbios_knl_Task_checkStackFlag__D=FALSE -Dti_sysbios_knl_Task_initStackFlag__D=TRUE -Dti_sysbios_knl_Task_DISABLE_ALL_HOOKS -Dti_sysbios_knl_Clock_TICK_SOURCE=ti_sysbios_knl_Clock_TickSource_TIMER -Dti_sysbios_knl_Clock_TICK_MODE=ti_sysbios_knl_Clock_TickMode_DYNAMIC -Dti_sysbios_hal_Core_delegate_getId=ti_sysbios_hal_CoreNull_getId__E -Dti_sysbios_hal_Core_delegate_interruptCore=ti_sysbios_hal_CoreNull_interruptCore__E -Dti_sysbios_hal_Core_delegate_lock=ti_sysbios_hal_CoreNull_lock__E -Dti_sysbios_hal_Core_delegate_unlock=ti_sysbios_hal_CoreNull_unlock__E -Dti_sysbios_hal_Core_numCores__D=1 -Dti_sysbios_hal_CoreNull_numCores__D=1 -Dti_sysbios_utils_Load_taskEnabled__D=TRUE -Dti_sysbios_utils_Load_swiEnabled__D=FALSE -Dti_sysbios_utils_Load_hwiEnabled__D=FALSE -Dti_sysbios_family_arm_m3_Hwi_dispatcherSwiSupport__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_dispatcherTaskSupport__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_dispatcherAutoNestingSupport__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_dispatcherIrpTrackingSupport__D=TRUE -Dti_sysbios_knl_Semaphore_supportsEvents__D=FALSE -Dti_sysbios_knl_Semaphore_supportsPriority__D=FALSE -Dxdc_runtime_Assert_DISABLE_ALL -Dxdc_runtime_Log_DISABLE_ALL
BIOS_INC = -I"/home/alan/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/"
BIOS_INC = -I"C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/"
TARGET_INC = -I"/home/alan/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/"
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="/home/alan/ti/ccs900/ccs/tools/compiler/ti-cgt-arm_20.2.1.LTS/include" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/icall/inc" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles/cc26xx" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/dev_info" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/cc26xx" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/common/cc26xx" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/components/heapmgr" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/controller/cc26xx/inc" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/target" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common/cc26xx" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/inc" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/components/osal/src/inc" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/sdata" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/saddr" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/components/icall/src/inc" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="/home/alan/ti/simplelink/ble_sdk_2_02_02_25/src/rom" --include_path="/home/alan/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/cc26xxware_2_24_03_17272" -I/home/alan/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.5.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 = /home/alan/ti/ccs900/ccs/tools/compiler/ti-cgt-arm_20.2.1.LTS/bin/armcl -c $(CCOPTS) -I /home/alan/ti/ccs900/ccs/tools/compiler/ti-cgt-arm_20.2.1.LTS/include
ASM = /home/alan/ti/ccs900/ccs/tools/compiler/ti-cgt-arm_20.2.1.LTS/bin/armcl -c $(CCOPTS) -I /home/alan/ti/ccs900/ccs/tools/compiler/ti-cgt-arm_20.2.1.LTS/include
AR = /home/alan/ti/ccs900/ccs/tools/compiler/ti-cgt-arm_20.2.1.LTS/bin/armar rq
CC = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.5.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.5.LTS/include
ASM = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.5.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.5.LTS/include
AR = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.5.LTS/bin/armar rq
DEL = rm -f
CP = cp -f
DEL = C:/ti/xdctools_3_32_02_25_core/packages/../bin/rm -f
CP = C:/ti/xdctools_3_32_02_25_core/packages/../bin/cp -f
define RM
$(if $(wildcard $1),$(DEL) $1,:)
@@ -100,8 +100,8 @@ rom_sysbios.obj: BIOS.c knl/Clock.c knl/Idle.c knl/Intrinsics.c knl/Event.c knl/
rom_sysbios.aem3: rom_sysbios.obj m3_Hwi_asm.obj m3_Hwi_asm_switch.obj m3_IntrinsicsSupport_asm.obj m3_TaskSupport_asm.obj
@-$(call RM, $@)
@echo arem3 $^ ...
@$(AR) $@ $^ /home/alan/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/sysbios/rom/cortexm/cc26xx/golden/CC26xx/rom_sysbios_config.obj
@$(AR) $@ $^ C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/sysbios/rom/cortexm/cc26xx/golden/CC26xx/rom_sysbios_config.obj
clean:
@$(DEL) ../makefile.libs
@$(DEL) ..\makefile.libs
@-$(call RM, *)
@@ -146,7 +146,6 @@ extern const PIN_Config BoardGpioInitTable[];
#define Board_GLED PIN_UNASSIGNED /* Green LED */
#define Board_RLED PIN_UNASSIGNED /* Red LED */
/* UART Board */
#define Board_UART_TX Board_BP_UART_Rx /* RXD */
#define Board_UART_RX Board_BP_UART_Tx /* TXD */
@@ -106,7 +106,7 @@
*/
#ifdef USE_ICALL
#include <icall.h>
#include <ICall.h>
typedef ICall_CSState halIntState_t;
@@ -55,7 +55,7 @@
#include <inc/hw_aon_rtc.h>
#include <driverlib/aon_rtc.h>
#include <driverlib/aon_event.h>
#include "icall.h"
#include "ICall.h"
/*******************************************************************************
* MACROS
@@ -48,7 +48,7 @@
#include <stdint.h>
#include "icall.h"
#include "ICall.h"
#ifdef __cplusplus
extern "C" {
@@ -55,7 +55,7 @@ extern "C"
// includes
// ****************************************************************************
#include "hal_types.h"
#include "osal.h"
#include "OSAL.h"
// ****************************************************************************
// defines
@@ -75,7 +75,7 @@
#ifdef ICALL_JT
#include "icall_JT.h"
#else
#include <icall.h>
#include <ICall.h>
#endif /* ICALL_JT */
#endif /* USE_ICALL */
@@ -405,7 +405,7 @@ uint32 osal_build_uint32( uint8 *swapped, uint8 len )
unsigned char * _ltoa(unsigned long l, unsigned char *buf, unsigned char radix)
{
#if defined (__TI_COMPILER_VERSION) || defined (__TI_COMPILER_VERSION__)
return ( (unsigned char*)ltoa( l, (char *)buf, radix ) );
return ( (unsigned char*)ltoa( l, (char *)buf ) );
#elif defined( __GNUC__ )
return ( (char*)ltoa( l, buf, radix ) );
#else
@@ -47,8 +47,8 @@
Release Date: 2018-04-02 18:03:35
*****************************************************************************/
#include "osal.h"
#include "osal_tasks.h"
#include "OSAL.h"
#include "OSAL_Tasks.h"
#include "hal_mcu.h"
#include "osal_cbtimer.h"
@@ -51,13 +51,13 @@
*/
#include "comdef.h"
#include "osal.h"
#include "osal_memory.h"
#include "OSAL.h"
#include "OSAL_Memory.h"
#ifdef ICALL_JT
#include "icall_JT.h"
#else
#include <icall.h>
#include <ICall.h>
#endif /* ICALL_JT */
/**************************************************************************************************
@@ -59,7 +59,7 @@
#ifdef ICALL_JT
#include "icall_JT.h"
#else
#include <icall.h>
#include <ICall.h>
#endif /* ICALL_JT */
#endif /* USE_ICALL */
@@ -62,11 +62,11 @@ extern "C"
#include <limits.h>
#include "comdef.h"
#include "osal_memory.h"
#include "osal_timers.h"
#include "OSAL_Memory.h"
#include "OSAL_Timers.h"
#ifdef USE_ICALL
#include <icall.h>
#include <ICall.h>
#endif /* USE_ICALL */
/*********************************************************************
@@ -80,7 +80,7 @@ the last entry in the page (higher memory address).
#include "hal_flash.h"
#include "hal_types.h"
#include "pwrmon.h"
#include "osal.h"
#include "OSAL.h"
#include "osal_snv.h"
#include "hal_assert.h"
#include <driverlib/vims.h>
@@ -52,7 +52,7 @@
#include <inc/hw_fcfg1.h>
#include "board.h"
#include "Board.h"
// RF Driver
#include <ti/drivers/rf/RF.h>
@@ -23,7 +23,7 @@ Instruction Specification
file defined:
Bio_Pro_Sci / 嚙踝蕭赤 / Pi3/DataServer / CC2650 / CC2650嚙踐垓蕭嚙踝隤嚙
Bio_Pro_Sci /  / Pi3/DataServer / CC2650 / CC2650誘銵
```
struct instruction {
@@ -93,20 +93,6 @@ instruction operator
#include <ti/sysbios/knl/Semaphore.h>
#include "simple_gatt_profile.h"
/** State for SPI (SPI callback to do task) **/
typedef enum {
CLOSE_SPI, // close SPI after MISO transmit
CONTINUOUS_TRANS, // transmit DBS data
FLUSH_BUFFER, // clean SPI buffer, used after a "write" SPI instruction (MISO)
FLUSH_BUFFER2, // clean SPI buffer twice
READ_REG, // read DBS register value, used after a "read" SPI instruction (MISO)
READ_REG2, // read DBS register value, used after a "read" SPI instruction (MISO)
END_TRANSMIT, // read DBS register value, used after a "read" SPI instruction (MISO)
ONE_SHOT_SPI, // end spi instruction
READ_MOSI
} SPI_CB_MODE;
/*========================
==== Global Variable ====
=========================*/
@@ -114,41 +100,11 @@ typedef enum {
static bool STI = false;
static bool IsFirstData = true;
static uint8_t spi_state_counter = 0;
static uint8_t check_reg_counter = 0;
static bool ConnectState = false;
static bool ErrorRestart = false;
static SPI_CB_MODE SPICallBack;
static uint8 adc_spi_en_switch = 1;
/*
* Let C = command, S = status;
* StiCommand = 0b00CC_00SS
* The first C is record command, the second is sti
* The first S is record status, the second is sti
*
* rec_sti_command | meaning |
* 0x00 | command = interrupt; status = idle |
* 0x01 | command = interrupt; status = sti without rec |
* 0x02 | command = interrupt; status = rec without sti |
* 0x03 | command = interrupt; status = sti & rec |
* 0x10 | command = start rec; status = idle |
* 0x11 | command = start rec; status = sti without rec |
* 0x12 | command = start rec; status = rec without sti |
* 0x13 | command = start rec; status = sti & rec |
* 0x20 | command = start sti; status = idle |
* 0x21 | command = start sti; status = sti without rec |
* 0x22 | command = start sti; status = rec without sti |
* 0x23 | command = start sti; status = sti & rec |
* 0x30 | command = rec & sti; status = idle |
* 0x31 | command = rec & sti; status = sti without rec |
* 0x32 | command = rec & sti; status = rec without sti |
* 0x33 | command = rec & sti; status = sti & rec |
*/
#define ENABLE_REC 0x20
#define ENABLE_STI 0x10
#define STATUS_REC 0x02
#define STATUS_STI 0x01
static uint8_t rec_sti_command = 0x00; // 0=NOP; 0x01=stop; 2=start;
static bool turn_off_sti = false;
static uint8_t SPICallBack = 0;
static uint32_t data_counter = 0;
/*======================
==== event control ====
@@ -214,7 +170,6 @@ extern ICall_Semaphore semaphore;
// command return characteristic
#define BLE_CDR_BUFF_CHAR SIMPLEPROFILE_CHAR2
#define BLE_CDR_BUFF_SIZE SIMPLEPROFILE_CHAR2_LEN
#define BLE_CDR_SMALL_SIZE 10
// instruction input characteristic
#define BLE_INS_BUFF_CHAR SIMPLEPROFILE_CHAR3
@@ -240,17 +195,13 @@ extern ICall_Semaphore semaphore;
#define INS_TYPE_CIS 0x70
// VIS operator
#define VIS_REC 0x10
#define VIS_STI 0x20
#define VIS_STOP_REC 0x30
#define VIS_STOP_STI 0x40
#define VIS_ASK 0x50
#define VIS_ASK 0x30
#define VIS_INT 0x60
#define VIS_FAST_SET 0x70
#define VIS_EN_ADC_CLK 0x80
#define VIS_STI 0x90
#define VIS_CAL 0xA0
#define VIS_START 0xC0
#define VIS_RST 0xF0
#define VIS_STOP_STI 0x01
// CIS operator
@@ -356,7 +307,7 @@ static uint16_t CONNECT_HANDLE = 0;
/**
* command instruction buffer
*/
static uint8_t cdr_buf[BLE_CDR_SMALL_SIZE] = {0};
static uint8_t cdr_buf[BLE_CDR_BUFF_SIZE] = {0};
/*====================
==== event table ====
@@ -23,28 +23,25 @@ static void CaliTable2u8(uint8_t* cali){
* - .......
*/
static void SendCaliValue(uint8_t CaliNumber){
uint8_t ch, cali_buf[BLE_CDR_BUFF_SIZE];
uint8_t ch, cdr_buf[10];
// ch = 2 * (CaliNumber % 4);
// uint8_t gain_level = CaliNumber / 4; // 0:gain, 1:offset
uint8_t channel_number = 8, index = 2;
uint8_t gain_level = 0;
ch = 2 * (CaliNumber % 4);
uint8_t gain_level = CaliNumber / 4; // 0:gain, 1:offset
if(CaliNumber < 4){
gain_level = CaliNumber;
}
cdr_buf[0] = CHIP_ID;
cali_buf[1] = CHIP_ID;
for(int i=0 ; i<channel_number ; i++){
cali_buf[index++] = (uint8_t) (CaliTable.Ch[i].Gain[gain_level] >> 8) & 0xFF;
cali_buf[index++] = (uint8_t) CaliTable.Ch[i].Gain[gain_level] & 0x00FF;
cali_buf[index++] = (uint8_t) (CaliTable.Ch[i].Offset[gain_level] >> 8) & 0xFF;
cali_buf[index++] = (uint8_t) CaliTable.Ch[i].Offset[gain_level] & 0x00FF;
}
cdr_buf[1] = (uint8_t) (CaliTable.Ch[ch].Gain[gain_level] >> 8) & 0xFF;
cdr_buf[2] = (uint8_t) CaliTable.Ch[ch].Gain[gain_level] & 0x00FF;
cdr_buf[3] = (uint8_t) (CaliTable.Ch[ch].Offset[gain_level] >> 8) & 0xFF;
cdr_buf[4] = (uint8_t) CaliTable.Ch[ch].Offset[gain_level] & 0x00FF;
cdr_buf[5] = (uint8_t) (CaliTable.Ch[ch+1].Gain[gain_level] >> 8) & 0xFF;
cdr_buf[6] = (uint8_t) CaliTable.Ch[ch+1].Gain[gain_level] & 0x00FF;
cdr_buf[7] = (uint8_t) (CaliTable.Ch[ch+1].Offset[gain_level] >> 8) & 0xFF;
cdr_buf[8] = (uint8_t) CaliTable.Ch[ch+1].Offset[gain_level] & 0x00FF;
cali_buf[0] = index - 1;
cdr_buf[9] = 0; // don't care
SimpleProfile_SetParameter(BLE_CDR_BUFF_CHAR, index, cali_buf);
SimpleProfile_SetParameter(BLE_CDR_BUFF_CHAR, BLE_CDR_BUFF_SIZE, cdr_buf);
}
#endif
@@ -94,54 +94,6 @@ struct _StiCaliStiTable{
.n_ch.offset = -20346
};
#elif defined(BOARD_A4_DA_32_D4_E9_1D)
{
.p_ch.coefficient = 2075,
.p_ch.offset = 6344,
.n_ch.coefficient = 2002,
.n_ch.offset = -5562
};
#elif defined(BOARD_A4_DA_32_D4_E8_7A)
{
.p_ch.coefficient = 2180,
.p_ch.offset = 6651,
.n_ch.coefficient = 2254,
.n_ch.offset = 136
};
#elif defined(BOARD_A4_DA_32_D4_F0_AC)
{
.p_ch.coefficient = 2125,
.p_ch.offset = -6660,
.n_ch.coefficient = 2170,
.n_ch.offset = -439
};
#elif defined(BOARD_A4_DA_32_D4_E8_7C)
{
.p_ch.coefficient = 2265,
.p_ch.offset = 6685,
.n_ch.coefficient = 2230,
.n_ch.offset = 2124
};
#elif defined(BOARD_A4_DA_32_D4_EF_39)
{
.p_ch.coefficient = 1976,
.p_ch.offset = 6641,
.n_ch.coefficient = 2035,
.n_ch.offset = 2834
};
#elif defined(BOARD_A4_DA_32_D4_E7_6A)
{
.p_ch.coefficient = 2076,
.p_ch.offset = 1154,
.n_ch.coefficient = 2096,
.n_ch.offset = -1073
};
#elif defined(BOARD_A4_DA_32_D4_E8_E6)
{
.p_ch.coefficient = 2306,
@@ -2,9 +2,7 @@
#ifndef NEU_CALI_TABLE
#define NEU_CALI_TABLE
// define Device_Name if "BOARD_TEST" as default
// else find headstage ID
#define BOARD_18_04_ED_37_C6_52
#define BOARD_TEST
typedef struct _SingleChannelCali{
uint16_t Gain[4];
@@ -85,9 +83,9 @@ struct _CaliTable{
.Ch[7].Offset[3] = 0
};
#elif defined(BOARD_80_6F_B0_ED_7A_34)
#elif defined(BOARD_18_04_ED_37_C7_38)
{
.DeviceName = "BOARD_80_6F_B0_ED_7A_34",
.DeviceName = "BOARD_18_04_ED_37_C7_38",
.Ch[0].Gain[0] = 48,
.Ch[0].Offset[0] = 49,
.Ch[1].Gain[0] = 49,
@@ -1330,70 +1328,70 @@ struct _CaliTable{
#elif defined(BOARD_A4_DA_32_D4_E8_71)
{
.DeviceName = "BOARD_A4_DA_32_D4_E8_71",
.Ch[0].Gain[0] = 13,
.Ch[0].Offset[0] = -9,
.Ch[1].Gain[0] = 47,
.Ch[1].Offset[0] = -11,
.Ch[0].Gain[0] = 48,
.Ch[0].Offset[0] = -10,
.Ch[1].Gain[0] = 41,
.Ch[1].Offset[0] = -10,
.Ch[2].Gain[0] = 48,
.Ch[2].Offset[0] = -1,
.Ch[2].Offset[0] = -3,
.Ch[3].Gain[0] = 48,
.Ch[3].Offset[0] = -3,
.Ch[3].Offset[0] = -14,
.Ch[4].Gain[0] = 12,
.Ch[4].Offset[0] = 18,
.Ch[4].Offset[0] = 17,
.Ch[5].Gain[0] = 48,
.Ch[5].Offset[0] = -4,
.Ch[5].Offset[0] = -3,
.Ch[6].Gain[0] = 13,
.Ch[6].Offset[0] = -9,
.Ch[6].Offset[0] = -8,
.Ch[7].Gain[0] = 46,
.Ch[7].Offset[0] = -14,
.Ch[0].Gain[1] = 91,
.Ch[0].Offset[1] = -72,
.Ch[1].Gain[1] = 351,
.Ch[1].Offset[1] = -84,
.Ch[2].Gain[1] = 352,
.Ch[2].Offset[1] = -11,
.Ch[3].Gain[1] = 353,
.Ch[3].Offset[1] = -30,
.Ch[4].Gain[1] = 92,
.Ch[4].Offset[1] = 126,
.Ch[5].Gain[1] = 351,
.Ch[5].Offset[1] = -36,
.Ch[6].Gain[1] = 93,
.Ch[6].Offset[1] = -73,
.Ch[7].Gain[1] = 342,
.Ch[7].Offset[1] = -109,
.Ch[0].Gain[2] = 375,
.Ch[0].Offset[2] = -320,
.Ch[1].Gain[2] = 1499,
.Ch[1].Offset[2] = -371,
.Ch[2].Gain[2] = 1508,
.Ch[2].Offset[2] = -47,
.Ch[3].Gain[2] = 1504,
.Ch[3].Offset[2] = -114,
.Ch[4].Gain[2] = 383,
.Ch[4].Offset[2] = 538,
.Ch[5].Gain[2] = 1505,
.Ch[5].Offset[2] = -155,
.Ch[6].Gain[2] = 402,
.Ch[6].Offset[2] = -309,
.Ch[7].Gain[2] = 1456,
.Ch[7].Offset[2] = -470,
.Ch[0].Gain[3] = 753,
.Ch[0].Offset[3] = -682,
.Ch[1].Gain[3] = 2689,
.Ch[1].Offset[3] = -680,
.Ch[2].Gain[3] = 3107,
.Ch[2].Offset[3] = -91,
.Ch[3].Gain[3] = 3054,
.Ch[3].Offset[3] = -225,
.Ch[4].Gain[3] = 669,
.Ch[4].Offset[3] = 1101,
.Ch[5].Gain[3] = 3007,
.Ch[5].Offset[3] = -295,
.Ch[6].Gain[3] = 844,
.Ch[6].Offset[3] = -670,
.Ch[7].Gain[3] = 2390,
.Ch[7].Offset[3] = -834
.Ch[7].Offset[0] = -13,
.Ch[0].Gain[1] = 355,
.Ch[0].Offset[1] = -30,
.Ch[1].Gain[1] = 300,
.Ch[1].Offset[1] = -78,
.Ch[2].Gain[1] = 356,
.Ch[2].Offset[1] = -28,
.Ch[3].Gain[1] = 356,
.Ch[3].Offset[1] = -110,
.Ch[4].Gain[1] = 93,
.Ch[4].Offset[1] = 117,
.Ch[5].Gain[1] = 355,
.Ch[5].Offset[1] = -29,
.Ch[6].Gain[1] = 90,
.Ch[6].Offset[1] = -64,
.Ch[7].Gain[1] = 339,
.Ch[7].Offset[1] = -103,
.Ch[0].Gain[2] = 1529,
.Ch[0].Offset[2] = -143,
.Ch[1].Gain[2] = 1295,
.Ch[1].Offset[2] = -337,
.Ch[2].Gain[2] = 1520,
.Ch[2].Offset[2] = -129,
.Ch[3].Gain[2] = 1507,
.Ch[3].Offset[2] = -472,
.Ch[4].Gain[2] = 391,
.Ch[4].Offset[2] = 500,
.Ch[5].Gain[2] = 1519,
.Ch[5].Offset[2] = -127,
.Ch[6].Gain[2] = 404,
.Ch[6].Offset[2] = -284,
.Ch[7].Gain[2] = 1433,
.Ch[7].Offset[2] = -445,
.Ch[0].Gain[3] = 3254,
.Ch[0].Offset[3] = -305,
.Ch[1].Gain[3] = 2640,
.Ch[1].Offset[3] = -712,
.Ch[2].Gain[3] = 3195,
.Ch[2].Offset[3] = -275,
.Ch[3].Gain[3] = 2768,
.Ch[3].Offset[3] = -947,
.Ch[4].Gain[3] = 739,
.Ch[4].Offset[3] = 1030,
.Ch[5].Gain[3] = 3188,
.Ch[5].Offset[3] = -280,
.Ch[6].Gain[3] = 843,
.Ch[6].Offset[3] = -599,
.Ch[7].Gain[3] = 2680,
.Ch[7].Offset[3] = -906
};
#elif defined(BOARD_A4_DA_32_D4_E7_3B)
@@ -1948,489 +1946,6 @@ struct _CaliTable{
.Ch[7].Offset[3] = -1263
};
#elif defined(BOARD_A4_DA_32_D4_E7_6A)
{
.DeviceName = "BOARD_A4_DA_32_D4_E7_6A",
.Ch[0].Gain[0] = 47,
.Ch[0].Offset[0] = -14,
.Ch[1].Gain[0] = 47,
.Ch[1].Offset[0] = -26,
.Ch[2].Gain[0] = 47,
.Ch[2].Offset[0] = -16,
.Ch[3].Gain[0] = 47,
.Ch[3].Offset[0] = -39,
.Ch[4].Gain[0] = 47,
.Ch[4].Offset[0] = 7,
.Ch[5].Gain[0] = 47,
.Ch[5].Offset[0] = 8,
.Ch[6].Gain[0] = 44,
.Ch[6].Offset[0] = -33,
.Ch[7].Gain[0] = 44,
.Ch[7].Offset[0] = -35,
.Ch[0].Gain[1] = 343,
.Ch[0].Offset[1] = 2,
.Ch[1].Gain[1] = 343,
.Ch[1].Offset[1] = -90,
.Ch[2].Gain[1] = 344,
.Ch[2].Offset[1] = -25,
.Ch[3].Gain[1] = 344,
.Ch[3].Offset[1] = -184,
.Ch[4].Gain[1] = 344,
.Ch[4].Offset[1] = 163,
.Ch[5].Gain[1] = 342,
.Ch[5].Offset[1] = 161,
.Ch[6].Gain[1] = 324,
.Ch[6].Offset[1] = -133,
.Ch[7].Gain[1] = 322,
.Ch[7].Offset[1] = -149,
.Ch[0].Gain[2] = 1409,
.Ch[0].Offset[2] = 51,
.Ch[1].Gain[2] = 1405,
.Ch[1].Offset[2] = -325,
.Ch[2].Gain[2] = 1401,
.Ch[2].Offset[2] = -47,
.Ch[3].Gain[2] = 1370,
.Ch[3].Offset[2] = -691,
.Ch[4].Gain[2] = 1364,
.Ch[4].Offset[2] = 714,
.Ch[5].Gain[2] = 1359,
.Ch[5].Offset[2] = 695,
.Ch[6].Gain[2] = 1323,
.Ch[6].Offset[2] = -491,
.Ch[7].Gain[2] = 1314,
.Ch[7].Offset[2] = -559,
.Ch[0].Gain[3] = 2771,
.Ch[0].Offset[3] = 117,
.Ch[1].Gain[3] = 2625,
.Ch[1].Offset[3] = -594,
.Ch[2].Gain[3] = 2738,
.Ch[2].Offset[3] = -72,
.Ch[3].Gain[3] = 1933,
.Ch[3].Offset[3] = -1147,
.Ch[4].Gain[3] = 1731,
.Ch[4].Offset[3] = 1168,
.Ch[5].Gain[3] = 1833,
.Ch[5].Offset[3] = 1171,
.Ch[6].Gain[3] = 2215,
.Ch[6].Offset[3] = -859,
.Ch[7].Gain[3] = 2086,
.Ch[7].Offset[3] = -964
};
#elif defined(BOARD_A4_DA_32_D4_E8_7A)
{
.DeviceName = "BOARD_A4_DA_32_D4_E8_7A",
.Ch[0].Gain[0] = 50,
.Ch[0].Offset[0] = 17,
.Ch[1].Gain[0] = 13,
.Ch[1].Offset[0] = 20,
.Ch[2].Gain[0] = 50,
.Ch[2].Offset[0] = 34,
.Ch[3].Gain[0] = 12,
.Ch[3].Offset[0] = 28,
.Ch[4].Gain[0] = 50,
.Ch[4].Offset[0] = 9,
.Ch[5].Gain[0] = 50,
.Ch[5].Offset[0] = 30,
.Ch[6].Gain[0] = 48,
.Ch[6].Offset[0] = 22,
.Ch[7].Gain[0] = 47,
.Ch[7].Offset[0] = 12,
.Ch[0].Gain[1] = 368,
.Ch[0].Offset[1] = 21,
.Ch[1].Gain[1] = 94,
.Ch[1].Offset[1] = 37,
.Ch[2].Gain[1] = 368,
.Ch[2].Offset[1] = 144,
.Ch[3].Gain[1] = 91,
.Ch[3].Offset[1] = 99,
.Ch[4].Gain[1] = 368,
.Ch[4].Offset[1] = -39,
.Ch[5].Gain[1] = 367,
.Ch[5].Offset[1] = 115,
.Ch[6].Gain[1] = 354,
.Ch[6].Offset[1] = 53,
.Ch[7].Gain[1] = 351,
.Ch[7].Offset[1] = -16,
.Ch[0].Gain[2] = 1545,
.Ch[0].Offset[2] = 34,
.Ch[1].Gain[2] = 397,
.Ch[1].Offset[2] = 103,
.Ch[2].Gain[2] = 1536,
.Ch[2].Offset[2] = 551,
.Ch[3].Gain[2] = 379,
.Ch[3].Offset[2] = 340,
.Ch[4].Gain[2] = 1524,
.Ch[4].Offset[2] = -214,
.Ch[5].Gain[2] = 1527,
.Ch[5].Offset[2] = 428,
.Ch[6].Gain[2] = 1484,
.Ch[6].Offset[2] = 157,
.Ch[7].Gain[2] = 1477,
.Ch[7].Offset[2] = -134,
.Ch[0].Gain[3] = 3161,
.Ch[0].Offset[3] = 52,
.Ch[1].Gain[3] = 796,
.Ch[1].Offset[3] = 189,
.Ch[2].Gain[3] = 2475,
.Ch[2].Offset[3] = 960,
.Ch[3].Gain[3] = 747,
.Ch[3].Offset[3] = 685,
.Ch[4].Gain[3] = 2956,
.Ch[4].Offset[3] = -425,
.Ch[5].Gain[3] = 2709,
.Ch[5].Offset[3] = 776,
.Ch[6].Gain[3] = 2968,
.Ch[6].Offset[3] = 300,
.Ch[7].Gain[3] = 2970,
.Ch[7].Offset[3] = -278
};
#elif defined(BOARD_A4_DA_32_D4_F0_AC)
{
.DeviceName = "BOARD_A4_DA_32_D4_F0_AC",
.Ch[0].Gain[0] = 50,
.Ch[0].Offset[0] = -2,
.Ch[1].Gain[0] = 51,
.Ch[1].Offset[0] = 38,
.Ch[2].Gain[0] = 50,
.Ch[2].Offset[0] = 63,
.Ch[3].Gain[0] = 50,
.Ch[3].Offset[0] = 38,
.Ch[4].Gain[0] = 51,
.Ch[4].Offset[0] = 42,
.Ch[5].Gain[0] = 50,
.Ch[5].Offset[0] = 44,
.Ch[6].Gain[0] = 48,
.Ch[6].Offset[0] = 26,
.Ch[7].Gain[0] = 47,
.Ch[7].Offset[0] = 5,
.Ch[0].Gain[1] = 372,
.Ch[0].Offset[1] = -216,
.Ch[1].Gain[1] = 372,
.Ch[1].Offset[1] = 74,
.Ch[2].Gain[1] = 373,
.Ch[2].Offset[1] = 261,
.Ch[3].Gain[1] = 374,
.Ch[3].Offset[1] = 66,
.Ch[4].Gain[1] = 373,
.Ch[4].Offset[1] = 100,
.Ch[5].Gain[1] = 372,
.Ch[5].Offset[1] = 126,
.Ch[6].Gain[1] = 359,
.Ch[6].Offset[1] = -5,
.Ch[7].Gain[1] = 358,
.Ch[7].Offset[1] = -159,
.Ch[0].Gain[2] = 1433,
.Ch[0].Offset[2] = -986,
.Ch[1].Gain[2] = 1547,
.Ch[1].Offset[2] = 208,
.Ch[2].Gain[2] = 1468,
.Ch[2].Offset[2] = 965,
.Ch[3].Gain[2] = 1543,
.Ch[3].Offset[2] = 172,
.Ch[4].Gain[2] = 1540,
.Ch[4].Offset[2] = 312,
.Ch[5].Gain[2] = 1533,
.Ch[5].Offset[2] = 419,
.Ch[6].Gain[2] = 1492,
.Ch[6].Offset[2] = -117,
.Ch[7].Gain[2] = 1446,
.Ch[7].Offset[2] = -753,
.Ch[0].Gain[3] = 1192,
.Ch[0].Offset[3] = -1501,
.Ch[1].Gain[3] = 3031,
.Ch[1].Offset[3] = 364,
.Ch[2].Gain[3] = 1467,
.Ch[2].Offset[3] = 1467,
.Ch[3].Gain[3] = 3036,
.Ch[3].Offset[3] = 302,
.Ch[4].Gain[3] = 2897,
.Ch[4].Offset[3] = 552,
.Ch[5].Gain[3] = 2699,
.Ch[5].Offset[3] = 731,
.Ch[6].Gain[3] = 2897,
.Ch[6].Offset[3] = -241,
.Ch[7].Gain[3] = 1747,
.Ch[7].Offset[3] = -1243
};
#elif defined(BOARD_A4_DA_32_D4_E8_7C)
{
.DeviceName = "BOARD_A4_DA_32_D4_E8_7C",
.Ch[0].Gain[0] = 49,
.Ch[0].Offset[0] = 75,
.Ch[1].Gain[0] = 49,
.Ch[1].Offset[0] = 32,
.Ch[2].Gain[0] = 49,
.Ch[2].Offset[0] = 46,
.Ch[3].Gain[0] = 49,
.Ch[3].Offset[0] = 50,
.Ch[4].Gain[0] = 13,
.Ch[4].Offset[0] = 46,
.Ch[5].Gain[0] = 49,
.Ch[5].Offset[0] = 45,
.Ch[6].Gain[0] = 47,
.Ch[6].Offset[0] = 36,
.Ch[7].Gain[0] = 46,
.Ch[7].Offset[0] = 52,
.Ch[0].Gain[1] = 364,
.Ch[0].Offset[1] = 229,
.Ch[1].Gain[1] = 362,
.Ch[1].Offset[1] = -101,
.Ch[2].Gain[1] = 365,
.Ch[2].Offset[1] = 6,
.Ch[3].Gain[1] = 365,
.Ch[3].Offset[1] = 47,
.Ch[4].Gain[1] = 96,
.Ch[4].Offset[1] = 0,
.Ch[5].Gain[1] = 363,
.Ch[5].Offset[1] = 9,
.Ch[6].Gain[1] = 354,
.Ch[6].Offset[1] = -51,
.Ch[7].Gain[1] = 353,
.Ch[7].Offset[1] = 54,
.Ch[0].Gain[2] = 1490,
.Ch[0].Offset[2] = 786,
.Ch[1].Gain[2] = 1472,
.Ch[1].Offset[2] = -584,
.Ch[2].Gain[2] = 1502,
.Ch[2].Offset[2] = -140,
.Ch[3].Gain[2] = 1485,
.Ch[3].Offset[2] = 47,
.Ch[4].Gain[2] = 382,
.Ch[4].Offset[2] = -171,
.Ch[5].Gain[2] = 1483,
.Ch[5].Offset[2] = -122,
.Ch[6].Gain[2] = 1417,
.Ch[6].Offset[2] = -367,
.Ch[7].Gain[2] = 1437,
.Ch[7].Offset[2] = 57,
.Ch[0].Gain[3] = 1963,
.Ch[0].Offset[3] = 1285,
.Ch[1].Gain[3] = 2229,
.Ch[1].Offset[3] = -1011,
.Ch[2].Gain[3] = 2925,
.Ch[2].Offset[3] = -289,
.Ch[3].Gain[3] = 2903,
.Ch[3].Offset[3] = 12,
.Ch[4].Gain[3] = 747,
.Ch[4].Offset[3] = -351,
.Ch[5].Gain[3] = 2881,
.Ch[5].Offset[3] = -284,
.Ch[6].Gain[3] = 2588,
.Ch[6].Offset[3] = -718,
.Ch[7].Gain[3] = 2953,
.Ch[7].Offset[3] = 71
};
#elif defined(BOARD_18_04_ED_37_C6_41)
{
.DeviceName = "BOARD_18_04_ED_37_C6_41",
.Ch[0].Gain[0] = 47,
.Ch[0].Offset[0] = 3,
.Ch[1].Gain[0] = 47,
.Ch[1].Offset[0] = 7,
.Ch[2].Gain[0] = 47,
.Ch[2].Offset[0] = 19,
.Ch[3].Gain[0] = 47,
.Ch[3].Offset[0] = 16,
.Ch[4].Gain[0] = 48,
.Ch[4].Offset[0] = 34,
.Ch[5].Gain[0] = 12,
.Ch[5].Offset[0] = 19,
.Ch[6].Gain[0] = 13,
.Ch[6].Offset[0] = -2,
.Ch[7].Gain[0] = 46,
.Ch[7].Offset[0] = -18,
.Ch[0].Gain[1] = 351,
.Ch[0].Offset[1] = -109,
.Ch[1].Gain[1] = 351,
.Ch[1].Offset[1] = -78,
.Ch[2].Gain[1] = 353,
.Ch[2].Offset[1] = 13,
.Ch[3].Gain[1] = 353,
.Ch[3].Offset[1] = -16,
.Ch[4].Gain[1] = 355,
.Ch[4].Offset[1] = 128,
.Ch[5].Gain[1] = 88,
.Ch[5].Offset[1] = 18,
.Ch[6].Gain[1] = 95,
.Ch[6].Offset[1] = -141,
.Ch[7].Gain[1] = 343,
.Ch[7].Offset[1] = -246,
.Ch[0].Gain[2] = 1498,
.Ch[0].Offset[2] = -540,
.Ch[1].Gain[2] = 1510,
.Ch[1].Offset[2] = -405,
.Ch[2].Gain[2] = 1512,
.Ch[2].Offset[2] = -10,
.Ch[3].Gain[2] = 1515,
.Ch[3].Offset[2] = -146,
.Ch[4].Gain[2] = 1521,
.Ch[4].Offset[2] = 481,
.Ch[5].Gain[2] = 373,
.Ch[5].Offset[2] = 16,
.Ch[6].Gain[2] = 409,
.Ch[6].Offset[2] = -672,
.Ch[7].Gain[2] = 1239,
.Ch[7].Offset[2] = -1062,
.Ch[0].Gain[3] = 1499,
.Ch[0].Offset[3] = -539,
.Ch[1].Gain[3] = 1508,
.Ch[1].Offset[3] = -405,
.Ch[2].Gain[3] = 1514,
.Ch[2].Offset[3] = -11,
.Ch[3].Gain[3] = 1515,
.Ch[3].Offset[3] = -150,
.Ch[4].Gain[3] = 1519,
.Ch[4].Offset[3] = 483,
.Ch[5].Gain[3] = 377,
.Ch[5].Offset[3] = 17,
.Ch[6].Gain[3] = 410,
.Ch[6].Offset[3] = -671,
.Ch[7].Gain[3] = 1242,
.Ch[7].Offset[3] = -1059
};
#elif defined(BOARD_A4_DA_32_D4_E9_1D)
{
.DeviceName = "BOARD_A4_DA_32_D4_E9_1D",
.Ch[0].Gain[0] = 48,
.Ch[0].Offset[0] = 13,
.Ch[1].Gain[0] = 48,
.Ch[1].Offset[0] = 23,
.Ch[2].Gain[0] = 48,
.Ch[2].Offset[0] = 37,
.Ch[3].Gain[0] = 48,
.Ch[3].Offset[0] = 24,
.Ch[4].Gain[0] = 48,
.Ch[4].Offset[0] = 8,
.Ch[5].Gain[0] = 48,
.Ch[5].Offset[0] = 39,
.Ch[6].Gain[0] = 47,
.Ch[6].Offset[0] = -6,
.Ch[7].Gain[0] = 47,
.Ch[7].Offset[0] = 13,
.Ch[0].Gain[1] = 352,
.Ch[0].Offset[1] = -33,
.Ch[1].Gain[1] = 352,
.Ch[1].Offset[1] = 12,
.Ch[2].Gain[1] = 352,
.Ch[2].Offset[1] = 104,
.Ch[3].Gain[1] = 353,
.Ch[3].Offset[1] = 39,
.Ch[4].Gain[1] = 353,
.Ch[4].Offset[1] = -59,
.Ch[5].Gain[1] = 350,
.Ch[5].Offset[1] = 87,
.Ch[6].Gain[1] = 345,
.Ch[6].Offset[1] = -191,
.Ch[7].Gain[1] = 342,
.Ch[7].Offset[1] = -58,
.Ch[0].Gain[2] = 1447,
.Ch[0].Offset[2] = -208,
.Ch[1].Gain[2] = 1447,
.Ch[1].Offset[2] = -19,
.Ch[2].Gain[2] = 1426,
.Ch[2].Offset[2] = 359,
.Ch[3].Gain[2] = 1438,
.Ch[3].Offset[2] = 90,
.Ch[4].Gain[2] = 1434,
.Ch[4].Offset[2] = -310,
.Ch[5].Gain[2] = 1417,
.Ch[5].Offset[2] = 292,
.Ch[6].Gain[2] = 1367,
.Ch[6].Offset[2] = -845,
.Ch[7].Gain[2] = 1406,
.Ch[7].Offset[2] = -319,
.Ch[0].Gain[3] = 2781,
.Ch[0].Offset[3] = -406,
.Ch[1].Gain[3] = 2860,
.Ch[1].Offset[3] = -54,
.Ch[2].Gain[3] = 2609,
.Ch[2].Offset[3] = 644,
.Ch[3].Gain[3] = 2806,
.Ch[3].Offset[3] = 150,
.Ch[4].Gain[3] = 2630,
.Ch[4].Offset[3] = -593,
.Ch[5].Gain[3] = 2644,
.Ch[5].Offset[3] = 527,
.Ch[6].Gain[3] = 1499,
.Ch[6].Offset[3] = -1347,
.Ch[7].Gain[3] = 2537,
.Ch[7].Offset[3] = -607
};
#elif defined(BOARD_A4_DA_32_D4_EF_39)
{
.DeviceName = "BOARD_A4_DA_32_D4_EF_39",
.Ch[0].Gain[0] = 48,
.Ch[0].Offset[0] = 37,
.Ch[1].Gain[0] = 48,
.Ch[1].Offset[0] = 44,
.Ch[2].Gain[0] = 48,
.Ch[2].Offset[0] = 30,
.Ch[3].Gain[0] = 49,
.Ch[3].Offset[0] = 18,
.Ch[4].Gain[0] = 36,
.Ch[4].Offset[0] = 20,
.Ch[5].Gain[0] = 48,
.Ch[5].Offset[0] = 32,
.Ch[6].Gain[0] = 47,
.Ch[6].Offset[0] = 35,
.Ch[7].Gain[0] = 47,
.Ch[7].Offset[0] = 30,
.Ch[0].Gain[1] = 359,
.Ch[0].Offset[1] = 72,
.Ch[1].Gain[1] = 360,
.Ch[1].Offset[1] = 120,
.Ch[2].Gain[1] = 360,
.Ch[2].Offset[1] = 19,
.Ch[3].Gain[1] = 362,
.Ch[3].Offset[1] = -70,
.Ch[4].Gain[1] = 285,
.Ch[4].Offset[1] = -49,
.Ch[5].Gain[1] = 359,
.Ch[5].Offset[1] = 32,
.Ch[6].Gain[1] = 351,
.Ch[6].Offset[1] = 53,
.Ch[7].Gain[1] = 349,
.Ch[7].Offset[1] = 12,
.Ch[0].Gain[2] = 1510,
.Ch[0].Offset[2] = 204,
.Ch[1].Gain[2] = 1508,
.Ch[1].Offset[2] = 409,
.Ch[2].Gain[2] = 1499,
.Ch[2].Offset[2] = -10,
.Ch[3].Gain[2] = 1504,
.Ch[3].Offset[2] = -404,
.Ch[4].Gain[2] = 1249,
.Ch[4].Offset[2] = -321,
.Ch[5].Gain[2] = 1502,
.Ch[5].Offset[2] = 36,
.Ch[6].Gain[2] = 1479,
.Ch[6].Offset[2] = 131,
.Ch[7].Gain[2] = 1475,
.Ch[7].Offset[2] = -53,
.Ch[0].Gain[3] = 2982,
.Ch[0].Offset[3] = 359,
.Ch[1].Gain[3] = 2702,
.Ch[1].Offset[3] = 721,
.Ch[2].Gain[3] = 3029,
.Ch[2].Offset[3] = -51,
.Ch[3].Gain[3] = 2620,
.Ch[3].Offset[3] = -749,
.Ch[4].Gain[3] = 2208,
.Ch[4].Offset[3] = -649,
.Ch[5].Gain[3] = 3041,
.Ch[5].Offset[3] = 34,
.Ch[6].Gain[3] = 3013,
.Ch[6].Offset[3] = 223,
.Ch[7].Gain[3] = 2974,
.Ch[7].Offset[3] = -136
};
// gain=1, offset = 0, if any channel has no calibration data
#else
{
@@ -1,7 +1,6 @@
#ifndef NEU_CHECK_INSTRUCTION
#define NEU_CHECK_INSTRUCTION
#include "headstage_instruction.h"
#include "neu/headstage_spi.h"
#include "neu/headstage_reset.h"
@@ -13,63 +12,34 @@ static uint8_t check_ins(uint16_t trans_ins){
return (trans_ins == recv_ins);
}
static void check_register(uint8_t register_to_check, uint16_t instruction_to_fit, NEU_WORK_STATE next_state){
if(check_reg_counter < 6){
static void check_register(uint8_t register_to_check, uint16_t instruction_to_fit, uint8_t next_state){
if(spi_state_counter < 6){
SPICallBack = CONTINUOUS_TRANS;
spi_txbuf[0] = register_to_check & 0x7F;
spi_txbuf[1] = rec_sti_command;
spi_txbuf[2] = check_reg_counter;
spi_txbuf[0] = register_to_check;
spi_txbuf[1] = register_to_check;
spi_txbuf[2] = register_to_check;
check_reg_counter ++;
spi_state_counter ++;
headstage_spi_transaction(3);
}
else{
check_reg_counter = 0;
spi_state_counter = 0;
if(check_ins(instruction_to_fit)){
NEULIVE_STATE.state = next_state;
SPICallBack = ONE_SHOT_SPI;
// update rec_sti_command
if(!(rec_sti_command & ENABLE_STI)){
// close STI success
rec_sti_command &= ~STATUS_STI;
}
// if(rec_sti_command & ENABLE_STI){
// rec_sti_command |= STATUS_STI;
// }
}
else{
// resend instruction
SPI_close(headstage_spi_handle);
// DBSReset();
// start recording failed
if( (rec_sti_command & ENABLE_REC) && !(rec_sti_command & STATUS_REC) ){
NEULIVE_STATE.state = NEU_WRITE_REC_INS;
NEULIVE_STATE.config_type = NEU_WARM_UP;
INSTRUCTION.ins_opcode = BIAS_ONE;
DBSReset();
NEULIVE_STATE.state = NEU_WRITE_INSTRUCTION;
NEULIVE_STATE.config_type = NEU_SET_STI_CUR;
if(STI){
INSTRUCTION.ins_opcode = T_ZE;
}
// start sti failed
else if( (rec_sti_command & ENABLE_STI) && !(rec_sti_command & STATUS_STI) ){
NEULIVE_STATE.state = NEU_WRITE_STI_INS;
NEULIVE_STATE.config_type = NEU_WARM_UP;
INSTRUCTION.ins_opcode = T_ZE;
// make sure rec can restart
not_buf_offset = NOT_BUF_OFFSET_INIT;
IsFirstData = true;
else{
INSTRUCTION.ins_opcode = BIAS_ONE;
}
// stop sti failed
else if( !(rec_sti_command & ENABLE_STI) && (rec_sti_command & STATUS_STI) ){
NEULIVE_STATE.state = NEU_STI_INT;
// make sure rec can restart
not_buf_offset = NOT_BUF_OFFSET_INIT;
IsFirstData = true;
}
SPICallBack = ONE_SHOT_SPI;
ReopenSPI();
}
@@ -77,115 +47,4 @@ static void check_register(uint8_t register_to_check, uint16_t instruction_to_fi
}
}
static uint8_t check_sti_register(uint8_t address, uint16_t instruction_to_fit);
static void check_sti_t1_t5(NEU_WORK_STATE next_state){
// get sti channel
uint8_t index, sti_channel[9];
for(index=0 ; index<9 ; index++){
sti_channel[index] = 0xFF;
}
// sti_channel will be [active_ch1, active_ch2, ..., 0xFF, 0xFF]
// where active_ch is the sti channel; 0xFF is used as an EOF
index = 0;
for(int i=0 ; i<8 ; i++){
if( (1 << i) & INSTRUCTION.sti_channel ){
sti_channel[index++] = i;
}
}
uint8_t register_address[5], register_index, success; // this is t1~t5 and sti_cycle number register address
uint16_t value_to_fit;
// check every active channel alternatively
for(index = 0 ; sti_channel[index]!=0xFF ; index++){
// check t1~t5 and sti-cycle register
for(register_index = 0 ; register_index < 5 ; register_index++){
// get register address
if(register_index < 4){
register_address[register_index] = sti_channel[index] * 4 + register_index + 1;
}
else{
register_address[register_index] = (sti_channel[index] / 2) + 42; // sti_cycle address
}
// get value to fit
if(register_index == 0){
uint16_t t1 = INSTRUCTION.sti_t1[sti_channel[index]];
uint16_t t21 = (INSTRUCTION.sti_t2[sti_channel[index]] & 0x003F) << 10;
value_to_fit = (t21) | (t1);
}
else if(register_index == 1){
uint16_t t22 = (INSTRUCTION.sti_t2[sti_channel[index]] >> 6) & 0x000F;
uint16_t t3 = INSTRUCTION.sti_t3[sti_channel[index]] << 4;
uint16_t t41 = (INSTRUCTION.sti_t4[sti_channel[index]] & 0x03) << 14;
value_to_fit = t41 | t3 | t22;
}
else if(register_index == 2){
uint16_t t42 = (INSTRUCTION.sti_t4[sti_channel[index]] >> 2) & 0xFFFF;
value_to_fit = t42;
}
else if(register_index == 3){
uint16_t t5 = (INSTRUCTION.sti_t5[sti_channel[index]]) & 0x03FF;
value_to_fit = t5;
}
else{
uint8_t odd_even = sti_channel[index] % 2;
if (!odd_even){
value_to_fit = (INSTRUCTION.current_sti_cycle[sti_channel[index] + 1] << 8) | (INSTRUCTION.current_sti_cycle[sti_channel[index]]);
}
else{
value_to_fit = (INSTRUCTION.current_sti_cycle[sti_channel[index]] << 8) | (INSTRUCTION.current_sti_cycle[sti_channel[index] - 1]);
}
}
success = check_sti_register(register_address[register_index], value_to_fit);
if(!success){
break;
}
}
if(!success){
break;
}
}
if(!success){
SPI_close(headstage_spi_handle);
NEULIVE_STATE.state = NEU_WRITE_STI_INS;
NEULIVE_STATE.config_type = NEU_WARM_UP;
INSTRUCTION.ins_opcode = T_ZE;
// make sure rec can restart
not_buf_offset = NOT_BUF_OFFSET_INIT;
IsFirstData = true;
ReopenSPI();
}
else{
NEULIVE_STATE.state = next_state;
}
SPICallBack = ONE_SHOT_SPI;
headstage_spi_transaction(3);
}
static uint8_t check_sti_register(uint8_t address, uint16_t instruction_to_fit){
check_reg_counter = 0;
while(check_reg_counter < 6){
SPICallBack = READ_REG;
spi_txbuf[0] = address & 0x7F;
spi_txbuf[1] = address;
spi_txbuf[2] = address;
headstage_spi_transaction(3); // check_reg_counter++ would be executed in SPI callback
}
check_reg_counter = 0;
// success = 1; failed = 0
return check_ins(instruction_to_fit);
}
#endif
@@ -1,164 +0,0 @@
#ifndef DBS_OBJECT_H
#define DBS_OBJECT_H
#include "neu/headstage_spi.h"
#define SYS_RESERVED_INDEX 0
#define SYS_GENERAL_ENABLE_INDEX 1
#define SYS_LNA_BIOS1_INDEX 2
#define SYS_LNA_BIOS2_INDEX 3
#define REC_CHANNEL_INDEX 0
#define REC_GAIN_INDEX 1
#define REC_ADC_CLOCK_INDEX 2
#define STI_ENABLE_INDEX 0
#define STI_AMP_POS_INDEX 1
#define STI_AMP_NEG_INDEX 2
#define STI_POLARITY_INDEX 3
#define STI_CYCLE_CH01_INDEX 4
#define STI_CYCLE_CH23_INDEX 5
#define STI_CYCLE_CH45_INDEX 6
#define STI_CYCLE_CH67_INDEX 7
#define STI_CLK_RATIO_INDEX 8
#define STI_ARBITRARY_EN_INDEX 9
#define STI_MODE_INDEX 10
#define STI_DURATION0_INDEX 11
#define STI_DURATION1_INDEX 12
#define STI_DURATION2_INDEX 13
#define STI_DURATION3_INDEX 14
//#define DBS_REGISTER \
// uint8_t address; \
// void (*write_reg) (DBSRegister *self, uint32_t reg_value); \
// uint32_t (*read_reg) (DBSRegister *self)
typedef struct _DBSRegister{
uint8_t address;
bool WriteRegister, CheckRegister;
void (*write_reg) (struct _DBSRegister *self, uint16_t reg_value);
void (*read_reg) (struct _DBSRegister *self);
}DBSRegister;
void write_reg(DBSRegister *self, uint16_t reg_value){
spi_txbuf[0] = 0x80 | self->address;
spi_txbuf[1] = (reg_value >> 8) & 0xFF ;
spi_txbuf[2] = reg_value & 0xFF;
SPICallBack = ONE_SHOT_SPI;
headstage_spi_transaction(SPI_BUFFER_SIZE);
}
void read_reg(DBSRegister *self){
spi_txbuf[0] = 0x7F & self->address;
spi_txbuf[1] = 0x7F & self->address; // it's don't care actually
spi_txbuf[2] = 0x7F & self->address; // it's don't care actually
SPICallBack = READ_REG;
headstage_spi_transaction(SPI_BUFFER_SIZE);
}
static uint16_t sys_register_default_value[4] = {
0x0000,
0x40F2,
0x0210,
0x4210
};
static uint16_t rec_register_value[3];
static uint16_t sti_register_value[43];
static DBSRegister sys_register[4];
static DBSRegister rec_register[3];
static DBSRegister sti_register[43];
static void InitSysRegister(){
sys_register[SYS_RESERVED_INDEX].address = 0x00;
sys_register[SYS_GENERAL_ENABLE_INDEX].address = 47; // general enable
sys_register[SYS_LNA_BIOS1_INDEX].address = 57;
sys_register[SYS_LNA_BIOS2_INDEX].address = 58;
for(int i=0 ; i<sizeof(sys_register)/sizeof(DBSRegister) ; i++){
sys_register[i].WriteRegister = false;
sys_register[i].CheckRegister = false;
sys_register[i].write_reg = &write_reg;
sys_register[i].read_reg = &read_reg;
}
}
static void InitRecRegister(){
rec_register[REC_CHANNEL_INDEX].address = 48;
rec_register[REC_GAIN_INDEX].address = 49;
rec_register[REC_ADC_CLOCK_INDEX].address = 51; // sampling rate
for(int i=0 ; i<sizeof(rec_register)/sizeof(DBSRegister) ; i++){
rec_register[i].WriteRegister = false;
rec_register[i].CheckRegister = false;
rec_register[i].write_reg = &write_reg;
rec_register[i].read_reg = &read_reg;
}
}
static void InitStiRegister(){
sti_register[STI_ENABLE_INDEX].address = 46;
sti_register[STI_AMP_POS_INDEX].address = 37;
sti_register[STI_AMP_NEG_INDEX].address = 38;
sti_register[STI_POLARITY_INDEX].address = 40;
sti_register[STI_CYCLE_CH01_INDEX].address = 42;
sti_register[STI_CYCLE_CH23_INDEX].address = 43;
sti_register[STI_CYCLE_CH45_INDEX].address = 44;
sti_register[STI_CYCLE_CH67_INDEX].address = 45;
sti_register[STI_CLK_RATIO_INDEX].address = 52;
sti_register[STI_ARBITRARY_EN_INDEX].address = 54;
sti_register[STI_MODE_INDEX].address = 56;
for(int ch=0 ; ch<8 ; ch++){
sti_register[ch*4 + STI_DURATION0_INDEX].address = ch*4 + 1;
sti_register[ch*4 + STI_DURATION1_INDEX].address = ch*4 + 2;
sti_register[ch*4 + STI_DURATION2_INDEX].address = ch*4 + 3;
sti_register[ch*4 + STI_DURATION3_INDEX].address = ch*4 + 4;
}
for(int i=0 ; i<sizeof(sti_register)/sizeof(DBSRegister) ; i++){
sti_register[i].WriteRegister = false;
sti_register[i].CheckRegister = false;
sti_register[i].write_reg = &write_reg;
sti_register[i].read_reg = &read_reg;
}
}
static void InitDBSRegister(){
InitSysRegister();
InitRecRegister();
InitStiRegister();
// for(int i=1 ; i<sizeof(sys_register)/sizeof(DBSRegister) ; i++){
for(int i=1 ; i<4 ; i++){
sys_register[i].WriteRegister = true;
}
flag_notify(EVT_NEU_SPI);
}
static void ResetDBSRegister(){
for(int i=0 ; i<sizeof(sys_register)/sizeof(DBSRegister) ; i++){
sys_register[i].WriteRegister = false;
sys_register[i].CheckRegister = false;
sys_register[i].write_reg = &write_reg;
sys_register[i].read_reg = &read_reg;
}
for(int i=0 ; i<sizeof(rec_register)/sizeof(DBSRegister) ; i++){
rec_register[i].WriteRegister = false;
rec_register[i].CheckRegister = false;
rec_register[i].write_reg = &write_reg;
rec_register[i].read_reg = &read_reg;
}
for(int i=0 ; i<sizeof(sti_register)/sizeof(DBSRegister) ; i++){
sti_register[i].WriteRegister = false;
sti_register[i].CheckRegister = false;
sti_register[i].write_reg = &write_reg;
sti_register[i].read_reg = &read_reg;
}
}
#endif
@@ -44,11 +44,11 @@ struct HEADSTAGE_PARAMETER_TABLE {
* -----------
*/
/**< these parameter define the bias voltage of amplifier. */
uint16_t vgrp;
uint16_t vgrn;
uint16_t vgr_int_old;
uint16_t vgr_intp;
uint16_t vgr_intn;
uint8_t vgrp;
uint8_t vgrn;
uint8_t vgr_int_old;
uint8_t vgr_intp;
uint8_t vgr_intn;
uint8_t ins_opcode; /**< check instruction opcode which is transmitted to DBS. */
@@ -62,9 +62,6 @@ struct HEADSTAGE_PARAMETER_TABLE {
uint16_t sti_amplitude_h; /**< positive side amplitude. */
uint16_t sti_amplitude_l; /**< negative side amplitude. */
uint16_t sti_amplitude_h_cali;
uint16_t sti_amplitude_l_cali;
uint16_t sys_clk_ratio; /**< frequency divider ratio for digital core clock. */
uint16_t adc_clock_ratio; /**< frequency divider ratio for adc clock. */
uint16_t sti_clock_ratio; /**< frequency divider ratio for stimulation clock. */
@@ -84,11 +81,11 @@ struct HEADSTAGE_PARAMETER_TABLE {
* manage which operation to be conducted
*/
struct HEADSTAGE_STATE {
NEU_WORK_STATE state;
uint16_t state;
NEU_CONFIG_TYPE config_type;
uint8_t config_type;
uint8_t index;
} NEULIVE_STATE={NEU_IDLE, NEU_WARM_UP, 0};
} NEULIVE_STATE = {0};
#endif
@@ -133,7 +133,7 @@ static uint8_t headstage_led_set_color(uint16_t *ins_buf, uint8_t repeat, uint8_
#ifdef HEADSTAGE_LED_USE_SPI
#include <board.h>
#include <Board.h>
#include <ti/drivers/SPI.h>
#include <ti/drivers/dma/UDMACC26XX.h>
#include <ti/drivers/spi/SPICC26XXDMA.h>
@@ -228,29 +228,4 @@ static void headstage_led_spi_color(uint8_t color) {
#endif // HEADSTAGE_LED_USE_GPIO
static void headstage_led_control(){
if( (rec_sti_command & STATUS_REC) && (rec_sti_command & STATUS_STI) ){
headstage_led_color(COLOR_MAGENTA);
}
else if((rec_sti_command & STATUS_REC)){
headstage_led_color(COLOR_BLUE);
}
else if((rec_sti_command & STATUS_STI)){
headstage_led_color(COLOR_ORANGE);
}
else{
if(ErrorRestart){
headstage_led_color(COLOR_RED);
}
else if(ConnectState){
headstage_led_color(COLOR_CYAN);
}
else{
headstage_led_color(COLOR_GREEN); // color green
}
}
}
#endif // HEADSTAGE_LED_H
@@ -3,7 +3,7 @@
#ifndef HEADSTAGE_PIN_H
#define HEADSTAGE_PIN_H
#include <board.h>
#include <Board.h>
#include <ti/drivers/PIN.h>
#if defined(HEADSTAGE_TNI_H)
@@ -1,103 +0,0 @@
#ifndef NEU_REC_INS_H
#define NEU_REC_INS_H
#include "headstage_instruction.h"
/**
* @fn build amplifier bias
*/
static bool build_amp_bias(uint32_t* value) {
uint8_t ins_opcode = INSTRUCTION.ins_opcode;
switch (ins_opcode) {
case BIAS_ONE: {
*value = (0x01 << 23) | (0x39 << 16) | NEU_LNA_BIAS_ONE;
INSTRUCTION.ins_opcode = BIAS_TWO;
return false;
}
case BIAS_TWO: {
*value = (0x01 << 23) | (0x3A << 16) | NEU_LNA_BIAS_TWO;
INSTRUCTION.ins_opcode = BIAS_TWO;
return true;
}
default: {
return false;
}
}
}
static NEU_CONFIG_TYPE build_rec_ins(NEU_CONFIG_TYPE config_type, uint32_t* value) {
bool done;
switch (config_type) {
/* These are recording parameter */
case NEU_WARM_UP:{
*value = (0x00 << 23) | (0x01 << 16) | 1;
return NEU_WARM_UP2;
}
case NEU_WARM_UP2:{
*value = (0x00 << 23) | (0x01 << 16) | 2;
return NEU_WARM_UP3;
}
case NEU_WARM_UP3:{
*value = (0x00 << 23) | (0x01 << 16) | 3;
return NEU_SET_GENERAL_EN;
}
case NEU_SET_GENERAL_EN: {
*value = (0x01 << 23) | (0x2F << 16) | NEU_GENERAL_EN;
return NEU_SET_REC_CHANNEL;
}
case NEU_SET_REC_CHANNEL: {
*value = (0x01 << 23) | (0x30 << 16) | INSTRUCTION.recording_channel;
return NEU_SET_AMP_GAIN;
}
case NEU_SET_AMP_GAIN: {
*value = (0x01 << 23) | (0x31 << 16) | INSTRUCTION.amplifier_gain;
return NEU_SET_VGRP;
}
case NEU_SET_VGRP:{
*value = (0x01 << 23) | (0x39 << 16) | (INSTRUCTION.vgrp << 5) | INSTRUCTION.vgrn;
return NEU_SET_VGRP_OLD;
}
case NEU_SET_VGRP_OLD:{
*value = (0x01 << 23) | (0x3A << 16) | (INSTRUCTION.vgr_int_old << 10) | (INSTRUCTION.vgr_intp << 5) | INSTRUCTION.vgr_intn;
return NEU_SETUP_DONE;
}
// case NEU_SET_SYS_CLK: {
// *value = (0x01 << 23) | (0x32 << 16) | INSTRUCTION.sys_clk_ratio;
// return NEU_SET_ADC_CLK;
// }
case NEU_SET_ADC_CLK: {
if(INSTRUCTION.adc_clock_ratio < 28){
INSTRUCTION.adc_clock_ratio = 28;
}
*value = (0x01 << 23) | (0x33 << 16) | INSTRUCTION.adc_clock_ratio;
// *value = (0x01 << 23) | (0x33 << 16) | 0x00C8;
return NEU_SET_AMP_BIAS;
}
case NEU_SET_AMP_BIAS: {
done = build_amp_bias(value);
if (done){
return NEU_SETUP_DONE;
}
else{
return NEU_SET_AMP_BIAS;
}
}
// case NEU_SET_CHOPPER: {
// *value = (0x01 << 23) | (0x3B << 16) | INSTRUCTION.chopper_ratio;
// return NEU_SETUP_DONE;
// }
default: {
return NEU_WARM_UP;
}
}
}
#endif
@@ -1,213 +0,0 @@
#ifndef NEU_STI_INS_H
#define NEU_STI_INS_H
#include "headstage_sti_cali.h"
#include "headstage_instruction.h"
/**
* @fn get_sti_channel
*/
#define ALL_STI_CH_CONFIG_DONE 0xFF
static uint8_t get_sti_channel(uint8_t sti_channel, uint8_t ch_number_config_done) {
uint8_t sti_ch;
uint8_t total_sti_ch_number = BitCount(sti_channel);
if(ch_number_config_done == total_sti_ch_number){ return ALL_STI_CH_CONFIG_DONE; }
for (uint8_t i = 0; i < NEU_STI_CHANNEL_COUNTS-1 ; i++) {
if ( (1 << i) & sti_channel) {
if(ch_number_config_done > 0){
ch_number_config_done --;
}
else{
sti_ch = i;
return sti_ch;
}
}
}
return 9;
}
/**
* @fn build sti instruction with channel information
*/
static bool build_sti_cur_instruction(uint8_t sti_channel, uint32_t* value) {
uint8_t ins_opcode = INSTRUCTION.ins_opcode;
uint8_t op_neu; /** this is the final opcode to write register table in DBS */
switch (ins_opcode) {
case T_ZE:{
// sending garbage SPI (want to warm up SPI)
op_neu = 1;
*value = (0x00 << 23) | (op_neu << 16) | 1;
INSTRUCTION.ins_opcode = T_ST;
return false;
}
case T_ST: {
op_neu = sti_channel * 4 + 1;
uint16_t t1 = INSTRUCTION.sti_t1[sti_channel];
uint16_t t21 = (INSTRUCTION.sti_t2[sti_channel] & 0x003F) << 10;
*value = (0x01 << 23) | (op_neu << 16) | (t21) | (t1);
INSTRUCTION.ins_opcode = T_ND;
return false;
}
case T_ND: {
op_neu = sti_channel * 4 + 2;
uint16_t t22 = (INSTRUCTION.sti_t2[sti_channel] >> 6) & 0x000F;
uint16_t t3 = INSTRUCTION.sti_t3[sti_channel] << 4;
uint16_t t41 = (INSTRUCTION.sti_t4[sti_channel] & 0x03) << 14;
*value = (0x01 << 23) | (op_neu << 16) | t41 | t3 | t22;
INSTRUCTION.ins_opcode = T_RD;
return false;
}
case T_RD: {
op_neu = sti_channel * 4 + 3;
uint16_t t42 = (INSTRUCTION.sti_t4[sti_channel] >> 2) & 0xFFFF;
*value = (0x01 << 23) | (op_neu << 16) | t42;
INSTRUCTION.ins_opcode = T_FT;
return false;
}
case T_FT: {
op_neu = sti_channel * 4 + 4;
uint16_t t5 = (INSTRUCTION.sti_t5[sti_channel]) & 0x03FF;
*value = (0x01 << 23) | (op_neu << 16) | t5;
INSTRUCTION.ins_opcode = STI_CYCLE;
return false;
}
case STI_CYCLE: {
op_neu = (sti_channel / 2) + 42;
uint8_t odd_even = sti_channel % 2;
INSTRUCTION.ins_opcode = T_ZE;
// if (NEULIVE_STATE.config_type == NEU_SET_STI_VOLT) INSTRUCTION.ins_opcode = HIGH_SIDE;
if(sti_channel == 8){
// voltage stimulate
op_neu = 41;
*value = (0x01 << 23) | (op_neu << 16) | (0x00 << 8) | (INSTRUCTION.current_sti_cycle[sti_channel]);
return true;
}
if (!odd_even){
*value = (0x01 << 23) | (op_neu << 16) | (INSTRUCTION.current_sti_cycle[sti_channel + 1] << 8) | (INSTRUCTION.current_sti_cycle[sti_channel]);
}
else{
*value = (0x01 << 23) | (op_neu << 16) | (INSTRUCTION.current_sti_cycle[sti_channel] << 8) | (INSTRUCTION.current_sti_cycle[sti_channel - 1]);
}
return true;
}
default: {
INSTRUCTION.ins_opcode = T_ZE;
return false;
}
}
}
/**
* @fn build stimulation voltage
*/
static bool build_sti_amplitude(uint32_t* value) {
uint8_t ins_opcode = INSTRUCTION.ins_opcode;
switch (ins_opcode) {
case HIGH_SIDE: {
*value = (0x01 << 23) | (0x25 << 16) | INSTRUCTION.sti_amplitude_h_cali;
INSTRUCTION.ins_opcode = LOW_SIDE;
return false;
}
case LOW_SIDE: {
*value = (0x01 << 23) | (0x26 << 16) | INSTRUCTION.sti_amplitude_l_cali;
// INSTRUCTION.ins_opcode = VOLT_MODE_AMP;
INSTRUCTION.ins_opcode = BIAS_ONE;
// return false;
return true;
}
case VOLT_MODE_AMP: {
*value = (0x01 << 23) | (0x27 << 16) | INSTRUCTION.voltage_sti_amplitude;
INSTRUCTION.ins_opcode = BIAS_ONE;
return true;
}
default: {
return false;
}
}
}
static NEU_CONFIG_TYPE build_sti_ins(NEU_CONFIG_TYPE config_type, uint32_t* value){
bool single_ch_config_done;
bool done;
switch (config_type) {
/* These are recording parameter */
case NEU_WARM_UP:{
*value = (0x00 << 23) | (0x01 << 16) | 1;
return NEU_WARM_UP2;
}
case NEU_WARM_UP2:{
*value = (0x00 << 23) | (0x01 << 16) | 2;
return NEU_WARM_UP3;
}
case NEU_WARM_UP3:{
*value = (0x00 << 23) | (0x01 << 16) | 3;
return NEU_SET_STI_CUR;
}
// set stimulate t1~t5
case NEU_SET_STI_CUR: {
uint8_t sti_channel = get_sti_channel(INSTRUCTION.sti_channel, INSTRUCTION.sti_ch_config_done);
// go to config sti amplitude
if (sti_channel == ALL_STI_CH_CONFIG_DONE) {
INSTRUCTION.sti_ch_config_done = 0;
INSTRUCTION.ins_opcode = HIGH_SIDE;
// get correct amplitude sti code
INSTRUCTION.sti_amplitude_h_cali = UserCode2StiCode(INSTRUCTION.sti_amplitude_h, POSITIVE_CHANNEL);
INSTRUCTION.sti_amplitude_l_cali = UserCode2StiCode(INSTRUCTION.sti_amplitude_l, NEGATIVE_CHANNEL);
return NEU_SET_STI_VOLT;
}
// config next sti channel
else {
single_ch_config_done = build_sti_cur_instruction(sti_channel, value);
if(single_ch_config_done){ INSTRUCTION.sti_ch_config_done++; }
return NEU_SET_STI_CUR;
}
}
// config sti amplitude
case NEU_SET_STI_VOLT: {
done = build_sti_amplitude(value);
if (done) {
return NEU_SET_POLARITY;
} else {
return NEU_SET_STI_VOLT;
}
}
case NEU_SET_POLARITY: {
*value = (0x01 << 23) | (0x28 << 16) | INSTRUCTION.current_sti_polarity;
return NEU_SET_STI_CLK;
}
case NEU_SET_STI_CLK: {
*value = (0x01 << 23) | (0x34 << 16) | INSTRUCTION.sti_clock_ratio;
*value = (0x01 << 23) | (0x34 << 16) | 2;
return NEU_SET_STI_MODE;
}
// case NEU_SET_ARBITRARY: {
// *value = (0x01 << 23) | (0x36 << 16) | INSTRUCTION.arbitrary_en;
// return NEU_SET_ARB_INDEX;
// }
// case NEU_SET_ARB_INDEX: {
// *value = (0x01 << 23) | (0x37 << 16) | INSTRUCTION.arbitrary_index;
// return NEU_SET_STI_MODE;
// }
case NEU_SET_STI_MODE: {
*value = (0x01 << 23) | (0x38 << 16) | (INSTRUCTION.sti_mode << 2) | (INSTRUCTION.sti_h_bridge << 1) | (INSTRUCTION.sti_ref);
return NEU_SETUP_DONE;
}
default: {
return NEU_WARM_UP;
}
}
}
#endif
@@ -3,15 +3,15 @@
#define VERSION_DATE
#define VERSION_DATE_YEAR 20
#define VERSION_DATE_MONTH 10
#define VERSION_DATE_DAY 26
#define VERSION_DATE_MONTH 5
#define VERSION_DATE_DAY 6
#define VERSION_DATE_HOUR 17
#define VERSION_DATE_MINUTE 3
#define VERSION_DATE_MINUTE 17
// this is NOT the version hash !!
// it's the last version hash
#define VERSION_HASH 764bd9364d7a99761ada31d35af557a39e1d65a4
#define VERSION_GIT_BRANCH neulive20_development_onchange_central
#define VERSION_HASH fcc89f3e1cbef6348808c6a076ee86909b02eeda
#define VERSION_GIT_BRANCH Neulive2.0_developement
static void get_board_name(char *board_name_ch, uint8 *board_name_int, uint8 name_size){
uint8 name_offset = 18;
@@ -3,7 +3,7 @@
#ifndef HEADSTAGE_WATCHDOG
#define HEADSTAGE_WATCHDOG
#include <board.h>
#include <Board.h>
#include <ti/drivers/Watchdog.h>
#include <ti/drivers/watchdog/WatchdogCC26XX.h>
@@ -8,93 +8,11 @@
#error "headstage/headstage_notify.h not included"
#endif
#include "headstage_dbs_object.h"
#define NOT_BUF_OFFSET_INIT 8
#include "headstage_cali_table.h"
static uint8_t numFFT = 16; // user define
static uint8_t step = 8; // which is numFFT/2
static uint8_t stageFFT = 4; // which is log2(numFFT)
static int twiddle_real[16] = {10000, 9238, 7071, 3826, 0, -3827, -7072, -9239, -10000, -9239, \
-7072, -3827, -1, 3826, 7071, 9238};
static int twiddle_imag[16] = { 0, -3827, -7072, -9239, -10000, -9239, -7072, -3827, -1, 3826, \
7071, 9238, 10000, 9238, 7071, 3826};
static void FFT(int* pred_LFP, int* imag_LFP, int numFFT);
static void BitReverse(int* BR_Array, int numFFT);
static void CLP(uint16_t raw_data);
static int ADC_U2S( uint16_t unsigned_buff);
static uint8_t not_buf_offset = NOT_BUF_OFFSET_INIT;
static uint32_t not_time_stamp = 0;
static void headstage_notify_set_timestamp();
static void headstage_notify_flip_buffer();
static uint8_t headstage_notify_append_data(uint8_t *data_value);
/**
* @fn headstage_neu_append_notify_data
*/
#define CHANNEL_VALID (INSTRUCTION.recording_channel & (0x0001 << channel))
static void headstage_neu_append_notify_data() {
uint8_t channel = spi_rxbuf[0];
// close-reopen SPI, if the first channel received is invalid
if(IsFirstData){
// start record
if((INSTRUCTION.recording_channel & (0x0001 << channel)) && (channel < 16)){
IsFirstData = false;
}
// restart SPI
else{
SPI_close(headstage_spi_handle);
ReopenSPI();
IsFirstData = true;
return;
}
}
// discard illegal channel
uint16_t valid_channel = INSTRUCTION.recording_channel & (0x0001 << channel);
if(!(INSTRUCTION.recording_channel & (0x0001 << channel)) || (channel > 15)){
// illegal channel
return;
}
uint8_t not_buf[2];
not_buf[0] = (channel & 0x0F) << 4 | (spi_rxbuf[1] & 0x0F);
not_buf[1] = spi_rxbuf[2];
// Borshin closed-loop start here <<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>----------------------
uint16_t borshin_raw;
uint8_t borshin_a;
uint8_t borshin_b;
uint8_t borshin_sample_rate;
uint16_t borshin_real;
borshin_raw = (spi_rxbuf[1]&0x0F)<<8 | spi_rxbuf[2];
borshin_a = CaliTable.Ch[channel].Gain[ rec_register_value[REC_CHANNEL_INDEX] ];
borshin_b = CaliTable.Ch[channel].Offset[ rec_register_value[REC_CHANNEL_INDEX] ];
borshin_real = borshin_raw * borshin_a + borshin_b; // range from [ FFF , 000 ]
borshin_sample_rate = 2000000/10/rec_register_value[REC_ADC_CLOCK_INDEX];
CLP( borshin_raw ); // This function input is 12-bit value
// the function will buffer 16-point then
// perform 16-point FFT.
// Afterwards, calculate sum of PSD then
// decided if HVS happened. (GPIO_4)
// Borshin closed-loop END here <<<<<<<<<<<<<<<<<<<<----------------------------->>>>>>>>>>>>>>>>>>>>
uint8_t data_size = headstage_notify_append_data(not_buf);
if (data_size >= BLE_NOT_BUFF_SIZE) {
headstage_notify_flip_buffer();
headstage_notify_send();
}
}
static void headstage_notify_set_timestamp() {
not_time_stamp = headstage_time_stamp_us();
@@ -105,9 +23,9 @@ static void headstage_notify_set_timestamp() {
}
static void headstage_notify_flip_buffer() {
uint8_t data_count = (not_buf_offset - NOT_BUF_OFFSET_INIT) / 2;
uint8_t data_count = (not_buf_offset - NOT_BUF_OFFSET_INIT) / 3;
headstage_notify_buffer[0] = CHIP_ID;
headstage_notify_buffer[0] = data_counter ++;
headstage_notify_buffer[1] = data_count;
not_buf_offset = NOT_BUF_OFFSET_INIT;
@@ -122,9 +40,11 @@ static uint8_t headstage_notify_append_data(uint8_t *data_value) {
if (data_value == NULL) {
headstage_notify_buffer[not_buf_offset++] = 0x00;
headstage_notify_buffer[not_buf_offset++] = 0x00;
headstage_notify_buffer[not_buf_offset++] = 0x00;
} else {
headstage_notify_buffer[not_buf_offset++] = data_value[0];
headstage_notify_buffer[not_buf_offset++] = data_value[1];
headstage_notify_buffer[not_buf_offset++] = data_value[2];
}
if (not_buf_offset >= BLE_NOT_BUFF_SIZE - 1) {
@@ -141,179 +61,3 @@ static uint8_t headstage_notify_append_data(uint8_t *data_value) {
}
#endif // HEADSTAGE_NOTIFY_TDC4VAF2_H
/*********************************************************************
* @fn FFT
*
* @brief TI Cortex M3 doesn't have floating-point ALU, we have to do
* fixed-point FFT. And in-place FFT because lack of RAM.
*
* @param None.
*
* @return None.
*/
static void FFT(int* pred_LFP, int* imag_LFP, int numFFT){
// testing_sig = !testing_sig;
// uint8_t stageFFT = 6; // static global log2(numFFT)
int l;
int product_real, product_imag;
int upfly_real, upfly_imag;
int downfly_real, downfly_imag;
for (int i=0; i<stageFFT; i++){
l = 1<<i;
for (int j=0; j<numFFT; j+=2*l){
for (int k=0; k<l; k++){
//printf("stage = %d , butterfly_top = %d , butterfly_down = %d , twiddle[%d] \n", i, j+k, j+k+l, NFFT*(k)/2/l);
product_real = pred_LFP[j+k+l] * twiddle_real[numFFT*(k)/2/l] \
- imag_LFP[j+k+l] * twiddle_imag[numFFT*(k)/2/l];
product_imag = pred_LFP[j+k+l] * twiddle_imag[numFFT*(k)/2/l] \
+ imag_LFP[j+k+l] * twiddle_real[numFFT*(k)/2/l];
product_real = product_real/10000; // left shift number =10 which is up to Int_twiddle-factor
product_imag = product_imag/10000;
upfly_real = pred_LFP[j+k] + product_real;
upfly_imag = imag_LFP[j+k] + product_imag;
downfly_real = pred_LFP[j+k] - product_real;
downfly_imag = imag_LFP[j+k] - product_imag;
pred_LFP[j+k] = upfly_real;
imag_LFP[j+k] = upfly_imag;
pred_LFP[j+k+l] = downfly_real;
imag_LFP[j+k+l] = downfly_imag;
}
}
}
return;
}
/*********************************************************************
* @fn ADC_U2S
*
* @brief ADC sample data in 12-bit which is FFF~000, but for FFT
* it needs to be pulled back to +7FF to -7FF. These is based
* on simulation result, which is like the function ADC_ISR()
* in Ramesh or Remy's code. [ ADC_unsigned_2_signed ]
*
* @param unsigned 16-bit input
*
* @return signed 16-bit output ----_0000_0000_0000 ~ ----_1000_0000_0000
*/
static int ADC_U2S( uint16_t unsigned_buff){
// 0x0FFF ~ 0x0000 (16-bit unsigned)
int output; // 0x07FF-0x0000 ~ 0x0FFF-0x0800
// int is 32-bit 0x0000_0000
if ( unsigned_buff >= 0x00000800)
output = unsigned_buff - 0x00000800;
else
output = unsigned_buff | 0xFFFFF800;
return output;
}
/*********************************************************************
* @fn BitReverse
*
* @brief Do array Bit-Reverse before perform FFT
*
* @param None.
*
* @return None.
*/
static void BitReverse(int* BR_Array, int numFFT){
// This BIR specify for 7-bit (0000_0000 ~ 0111_1111)
uint8_t n=0;
int tmp;
for (uint8_t i=0; i<numFFT; i++){
n = i; // printf ("%d %d\n",i,n);
n = (n&0x0f)<<4 | (n&0xf0)>>4; // 0123_4567 -> 4567_0123
n = (n&0x33)<<2 | (n&0xcc)>>2; // 4567_0123 -> 6745_2301
n = (n&0xaa)<<2 | (n&0x55)>>1; // 7856_3412 -> 7654_3210
n = n >> 1; // 7654_3210 -> 0765_4321
if (n>i){
tmp = BR_Array[n];
BR_Array[n] = BR_Array[i];
BR_Array[i] = tmp;
}
}
return;
} // END Bit Reverse Order Sort
/*********************************************************************
* @fn CLP ( Closed LooP )
*
* @brief
*
* @param None.
*
* @return None.
*/
static void CLP(uint16_t unsigned_real_data){
int signed_buff;
static int accumu_sum;
static int x_in[16];
static int real[16];
static int imag[16];
static int count_sample;
static int count_data;
int abs_tmp;
static int present, past1, past2, hvs;
// static int w[6] = {1597,-1909,1856,-1190,630,23};
static int w[6] = { 1, -2, 2, -1, 1, 0};
count_sample++; // count+1 every 1-ms
if (count_sample>=24){ // ensure sample LFP data every 24-ms(41.6667Hz)
signed_buff = ADC_U2S(unsigned_real_data); // FFF ~ 000 to +7FF ~ -7FF
x_in[count_data] = signed_buff;
real[count_data] = signed_buff;
imag[count_data] = 0;
count_sample = 0; // re-calculate count
count_data++;
if (count_data>=6){
accumu_sum = 0;
for (int i=6;i<numFFT;i++){
real[i] = ( w[0] * real[i-1] \
+ w[1] * real[i-2] \
+ w[2] * real[i-3] \
+ w[3] * real[i-4] \
+ w[4] * real[i-5] \
+ w[5] * real[i-6] );
imag[i] = 0;
}
BitReverse( real, numFFT);
FFT( real, imag, numFFT);
for (int i=1;i<6;i++){
if (i>=2&&i<=4){
accumu_sum += real[i]*real[i]+imag[i]*imag[i];
}
real[i-1] = x_in[i];
imag[i-1] = 0;
x_in[i-1] = x_in[i];
}
present = ( (accumu_sum) > 11500000 )?1:0;
if (present+past1+past2==3)
hvs = 1;
else
hvs = 0;
past2 = past1;
past1 = present;
if (hvs==1)
headstage_pin_output(PIN_CLP, 1);
else
headstage_pin_output(PIN_CLP, 0);
count_data--;
}
}
return;
}
@@ -29,8 +29,7 @@
#define PIN_LED_CLK IOID_1 // SPI1 clock
#define PIN_DC_DC IOID_2 // STI select need
#define PIN_EN_ADC_SPI_CLK IOID_3 //
//#define PIN_BATT_HALF IOID_4 //
#define PIN_CLP IOID_4 // cDBS detect HVS LED::also added in config table
#define PIN_BATT_HALF IOID_4 //
#define PIN_SPI_MISO IOID_7 //
#define PIN_SPI_MOSI IOID_8 //
#define PIN_SPI_CS IOID_9 //
@@ -78,10 +77,9 @@ static PIN_Config headstage_pin_configuration[] = { //
PIN_RESET | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
PIN_EN_ADC_SPI_CLK | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
PIN_DC_DC | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
PIN_CLP | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, // cDBS detect HVS LED::added in config table
// PIN_BATT_HALF | PIN_INPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
PIN_BATT_HALF | PIN_INPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
PIN_STI_CLK | PIN_INPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// TODO : add PIN_IRQ for STI clock to detect STI status (update LED & resend STI command if failed before)
//
PIN_TERMINATE};
#endif // HEADSTAGE_PIN_UNI_H
@@ -3,7 +3,7 @@
#ifndef HEADSTAGE_PWM_H
#define HEADSTAGE_PWM_H
#include <board.h>
#include <Board.h>
#include <ti/drivers/PWM.h>
static PWM_Handle headstage_system_pwm_handle = NULL;
@@ -13,14 +13,13 @@ static void MCUReset(){
// global variable reset
STI = false;
rec_sti_command = 0;
turn_off_sti = false;
IsFirstData = true;
data_counter = 0;
// SPI reset
SPI_close(headstage_spi_handle);
spi_state_counter = 0;
check_reg_counter = 0;
for(int i=0 ; i<SPI_BUFFER_SIZE ; i++ ){
spi_txbuf[i] = 0;
spi_rxbuf[i] = 0;
@@ -33,7 +32,7 @@ static void MCUReset(){
}
// CIS buffer reset
for(int i=0 ; i<BLE_CDR_SMALL_SIZE ; i++){
for(int i=0 ; i<BLE_CDR_BUFF_SIZE ; i++){
cdr_buf[i] = 0;
}
@@ -84,22 +83,20 @@ static void ResetINSTRUCTION(){
INSTRUCTION.sti_clock_ratio = 10;
INSTRUCTION.amplifier_gain = 0;
INSTRUCTION.chopper_ratio = 2;
INSTRUCTION.sti_t1[1] = 0;
INSTRUCTION.sti_t1[1] = 1;
INSTRUCTION.sti_t2[1] = 0;
INSTRUCTION.sti_t3[1] = 0;
INSTRUCTION.sti_t4[1] = 0;
INSTRUCTION.sti_t5[1] = 0;
INSTRUCTION.sti_channel = 0;
INSTRUCTION.sti_channel = 2;
INSTRUCTION.arbitrary_en = 0;
INSTRUCTION.arbitrary_index = 0;
INSTRUCTION.sti_h_bridge = 0;
INSTRUCTION.sti_mode = 0;
INSTRUCTION.sti_ref = 0;
INSTRUCTION.current_sti_polarity = 0;
INSTRUCTION.current_sti_polarity = 2;
INSTRUCTION.sti_amplitude_h = 0;
INSTRUCTION.sti_amplitude_l = 0;
INSTRUCTION.sti_amplitude_h_cali = 0;
INSTRUCTION.sti_amplitude_l_cali = 0;
INSTRUCTION.ins_opcode = BIAS_ONE;
INSTRUCTION.sti_ch_config_done = 0;
@@ -111,7 +108,7 @@ static void ResetINSTRUCTION(){
}
NEULIVE_STATE.state = NEU_IDLE;
NEULIVE_STATE.config_type = NEU_WARM_UP;
NEULIVE_STATE.config_type = 0;
NEULIVE_STATE.index = 0;
}
@@ -7,7 +7,7 @@
#error "put HEADSTAGE_MA_USE_SPI2 in predefined"
#endif
#include <board.h>
#include <Board.h>
#include <ti/drivers/SPI.h>
#include <ti/drivers/dma/UDMACC26XX.h>
#include <ti/drivers/spi/SPICC26XXDMA.h>
@@ -120,72 +120,4 @@ static void AppendSPITX(uint8_t index, uint32_t value){
}
}
/**
* @fn headstage_spi_callback
*
* description: callback function to deal with data transmission between DBS and CC2650
*/
static void headstage_spi_callback(SPI_Handle handle, SPI_Transaction* transaction) {
switch(SPICallBack){
case CONTINUOUS_TRANS:{
for(int i=0 ; i<SPI_BUFFER_SIZE ; i++){
spi_txbuf[i] = 0x00;
}
flag_notify(EVT_NEU_SPI);
break;
}
case FLUSH_BUFFER:{
SPICallBack = FLUSH_BUFFER2;
for(int i=0 ; i<SPI_BUFFER_SIZE ; i++){
spi_txbuf[i] = 0x00;
}
headstage_spi_transaction(SPI_BUFFER_SIZE);
break;
}
case FLUSH_BUFFER2:{
SPICallBack = ONE_SHOT_SPI;
for(int i=0 ; i<SPI_BUFFER_SIZE ; i++){
spi_txbuf[i] = 0x00;
}
flag_notify(EVT_NEU_SPI);
// headstage_spi_transaction(SPI_BUFFER_SIZE);
break;
}
case ONE_SHOT_SPI:{
SPICallBack = FLUSH_BUFFER;
for(int i=0 ; i<SPI_BUFFER_SIZE ; i++){
spi_txbuf[i] = 0x00;
}
headstage_spi_transaction(SPI_BUFFER_SIZE);
break;
}
case READ_MOSI:{
flag_notify(EVT_NEU_SPI);
break;
}
case READ_REG:{
check_reg_counter ++;
flag_notify(EVT_NEU_SPI);
break;
}
case CLOSE_SPI:{
SPICallBack = ONE_SHOT_SPI;
SPI_close(headstage_spi_handle);
break;
}
case END_TRANSMIT:{
tx_put_u24(0, 0);
SPICallBack = CONTINUOUS_TRANS;
break;
}
default:{
break;
}
}
}
#endif
@@ -114,13 +114,13 @@
#ifndef FEATURE_OAD
// Minimum connection interval (units of 1.25ms, 80=100ms) if automatic
// parameter update request is enabled
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL 8
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL 6
//#define DEFAULT_DESIRED_MIN_CONN_INTERVAL 14
// Maximum connection interval (units of 1.25ms, 800=1000ms) if automatic
// parameter update request is enabled
//#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 6
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 30
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 6
#else //! FEATURE_OAD
// Minimum connection interval (units of 1.25ms, 8=10ms) if automatic
@@ -561,7 +561,6 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
headstage_init_device_info();
headstage_init();
InitDBSRegister();
for (;;) {
// Waits for a signal to the semaphore associated with the calling thread.
@@ -51,7 +51,7 @@
#include "hal_types.h"
#include "ble_user_config.h"
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/rf/rf.h>
#if defined(BLE_V42_FEATURES) && (BLE_V42_FEATURES & SECURE_CONNS_CFG)
#include "ecc/ECCROMCC26XX.h"
@@ -82,8 +82,7 @@ extern "C" {
// Length of Characteristic 5 in bytes
#define SIMPLEPROFILE_CHAR1_LEN 2
//#define SIMPLEPROFILE_CHAR2_LEN 50
#define SIMPLEPROFILE_CHAR2_LEN 34
#define SIMPLEPROFILE_CHAR2_LEN 10
#define SIMPLEPROFILE_CHAR3_LEN 20
#define SIMPLEPROFILE_CHAR4_LEN 200
//#define SIMPLEPROFILE_CHAR4_LEN 20
+1 -1
View File
@@ -14,7 +14,7 @@ declare -i row_index=0
#constant
declare -i COL_MAX=8
declare -i START_ROW=27
declare -i START_ROW=23
declare -i UN_USED_ROW=$START_ROW-1
MAC="MAC"