69 lines
2.0 KiB
Bash
Executable File
69 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
folder=$(basename "$(pwd)")
|
|
|
|
if [ "$folder" == "bioprocc2650" ]; then
|
|
|
|
input="./Neulive_sti_cali.txt"
|
|
output="./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_cali_sti.h"
|
|
|
|
#variable
|
|
declare -i current_line=96
|
|
declare -i col_index=0
|
|
declare -i row_index=0
|
|
|
|
#constant
|
|
declare -i COL_MAX=8
|
|
declare -i START_ROW=23
|
|
declare -i UN_USED_ROW=$START_ROW-1
|
|
|
|
MAC="MAC"
|
|
|
|
while read -r line; do
|
|
for word in $line; do
|
|
# get device MAC
|
|
if [ $row_index -gt $UN_USED_ROW ] && [ $col_index -eq 3 ];then
|
|
MAC=$word
|
|
sed -i "${current_line} i \\\n#elif defined(BOARD_${MAC})\\n{" "$output"
|
|
sed -i 's/:/_/g' "$output"
|
|
current_line=$current_line+3
|
|
fi
|
|
|
|
# get device positive channel coeff and offset
|
|
if [ $row_index -gt $UN_USED_ROW ] && [ $col_index -eq 4 ];then
|
|
sed -i "${current_line} i \ .p_ch.coefficient = $word," "$output"
|
|
current_line=$current_line+1
|
|
fi
|
|
|
|
if [ $row_index -gt $UN_USED_ROW ] && [ $col_index -eq 5 ];then
|
|
sed -i "${current_line} i \ .p_ch.offset = $word," "$output"
|
|
current_line=$current_line+1
|
|
fi
|
|
|
|
# get device negative channel coeff and offset
|
|
if [ $row_index -gt $UN_USED_ROW ] && [ $col_index -eq 6 ];then
|
|
sed -i "${current_line} i \ .n_ch.coefficient = $word," "$output"
|
|
current_line=$current_line+1
|
|
fi
|
|
|
|
if [ $row_index -gt $UN_USED_ROW ] && [ $col_index -eq 7 ];then
|
|
sed -i "${current_line} i \ .n_ch.offset = $word" "$output"
|
|
current_line=$current_line+1
|
|
sed -i "${current_line} i };" "$output"
|
|
current_line=$current_line+1
|
|
fi
|
|
|
|
#update index
|
|
if [ $col_index -lt $COL_MAX ];then
|
|
col_index=$col_index+1
|
|
else
|
|
col_index=0
|
|
row_index=$row_index+1
|
|
fi
|
|
done
|
|
done < $input
|
|
|
|
else
|
|
echo "This script should be executed on CC2650 periperal only"
|
|
fi
|