elite cali script

This commit is contained in:
weiting2
2020-03-13 17:49:46 +08:00
parent bbc6c231a2
commit de45c74a85
2 changed files with 94 additions and 4 deletions
@@ -4,12 +4,12 @@
#define VERSION_DATE_YEAR 20
#define VERSION_DATE_MONTH 3
#define VERSION_DATE_DAY 11
#define VERSION_DATE_HOUR 11
#define VERSION_DATE_MINUTE 15
#define VERSION_DATE_DAY 13
#define VERSION_DATE_HOUR 17
#define VERSION_DATE_MINUTE 49
// this is NOT the version hash !!
// it's the last version hash
#define VERSION_HASH 4c4ea1e54d1235c236ef0fc28c0138e3f309043e
#define VERSION_HASH bbc6c231a263d20f751cd2807f863e4e7783c8ef
#define VERSION_GIT_BRANCH Elite_OBJ_Version
#endif
+90
View File
@@ -0,0 +1,90 @@
#!/bin/bash
#input="./Elite_test.txt"
input="./$1.txt"
output="./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDeviceCorrection.h"
#variable
declare -i current_line=1436
declare -i col_index=0
declare -i row_index=0
#declare -i coeff=1
#declare -i offset=0
declare -i current_gain=0
#declare -i vin_gain=0
#declare -i vout_gain=0
MAC="MAC"
#constant
declare -i ADC_CURRENT_GAIN_NUMBER=3
declare -i ADC_VOLTAGE_GAIN_NUMBER=1
declare -i DAC_GAIN_NUMBER=1
while read -r line; do
for word in $line; do
# get device MAC
if [ $row_index -eq 0 ] && [ $col_index -eq 1 ];then
MAC=$word
sed -i "${current_line} i \\\n#ifdef BOARD_${MAC}{" "$output"
sed -i 's/:/_/g' "$output"
current_line=$current_line+2
fi
#get ADC current cali data
declare -i Iin_range=3+$ADC_CURRENT_GAIN_NUMBER
if [ $row_index -gt 1 ] && [ $row_index -lt $Iin_range ];then
if [ $col_index -eq 1 ];then
sed -i "${current_line} i \\\t.ADC_current[${current_gain}].coeff = ($word)," "$output"
current_line=$current_line+1
elif [ $col_index -eq 2 ];then
sed -i "${current_line} i \\\t.ADC_current[${current_gain}].offset = ($word)," "$output"
current_line=$current_line+1
if [ $current_gain -lt 2 ];then
current_gain=$current_gain+1
else
current_gain=0
fi
fi
#get DAC Vout cali data
declare -i Vout_range=3+$ADC_CURRENT_GAIN_NUMBER+$DAC_GAIN_NUMBER
elif [ $row_index -gt 1 ] && [ $row_index -lt $Vout_range ];then
if [ $col_index -eq 1 ];then
sed -i "${current_line} i \\\t.Usercode2DAC.coeff = ($word)," "$output"
current_line=$current_line+1
elif [ $col_index -eq 2 ];then
sed -i "${current_line} i \\\t.Usercode2DAC.offset = ($word)," "$output"
current_line=$current_line+1
fi
#get ADC Vin cali data
declare -i Vin_range=3+$ADC_CURRENT_GAIN_NUMBER+$DAC_GAIN_NUMBER+$ADC_VOLTAGE_GAIN_NUMBER
elif [ $row_index -gt 1 ] && [ $row_index -lt $Vin_range ];then
if [ $col_index -eq 1 ];then
sed -i "${current_line} i \\\t.ADC_volt.coeff = ($word)," "$output"
current_line=$current_line+1
elif [ $col_index -eq 2 ];then
sed -i "${current_line} i \\\t.ADC_volt.offset = ($word)," "$output"
current_line=$current_line+1
fi
fi
#update index
if [ $col_index -lt 2 ];then
col_index=$col_index+1
else
col_index=0
row_index=$row_index+1
fi
done
done < $input
sed -i "${current_line} i };" "$output"
current_line=$current_line+1
sed -i "${current_line} i #endif" "$output"