From b5ce18e826d536f00d95359e02f1f0ac1db24ded Mon Sep 17 00:00:00 2001 From: FReenen Date: Sat, 15 Jun 2024 23:22:31 +0200 Subject: [PATCH] from old backup --- compile.sh | 70 +++++++++++++++++++++++++++++++++++ decoders/README.md | 7 ++++ decoders/tmc429/__init__.py | 9 +++++ decoders/tmc429/pd.py | 73 +++++++++++++++++++++++++++++++++++++ 4 files changed, 159 insertions(+) create mode 100644 compile.sh create mode 100644 decoders/README.md create mode 100644 decoders/tmc429/__init__.py create mode 100644 decoders/tmc429/pd.py diff --git a/compile.sh b/compile.sh new file mode 100644 index 0000000..6c72e6e --- /dev/null +++ b/compile.sh @@ -0,0 +1,70 @@ +#/bin/sh + +CUR_DIR=$(pwd) + +# config +DEVICE=MSP430G2553 +OUT_DIR=$CUR_DIR/out +MAIN_FILE=$CUR_DIR/main.c + +# GCC directorys +GCC_DIR=$HOME/ti/gcc +GCC_BIN_DIR=$GCC_DIR/bin +GCC_ELF_INC=$GCC_DIR/msp430-elf/include +GCC_MSP_INC=$GCC_DIR/include +GCC_LD=$GCC_MSP_INC/$(echo $DEVICE | tr A-Z a-z).ld + +# comands +CC=$GCC_BIN_DIR/msp430-elf-gcc + +# optionsh + +# -O optimizer; -O0: no optimization, -O1: level 1, -O2: level 2, -O3: level 3, -Os: size, -Ofast: speed, -OG: debug experiance +# -D [=] define; : the name of the defination, : the value for de definition defaults to 1 +# -mmcu= muc name +# -g add debug information for GDB +# -ffunction-sections a specific optimisation thing +# -fdata-sections a specific optimisation thing +# -T add linker script (dl file) +# -L add source directory for libraries(-l serches for a librarie) +# -Wl,--gc-sections enable that specific optimisation thing mansiont by -ffunction-sections and -fdata-sections +# -I adds directory to the search list for header files + +# original cmd +# -Os -mmcu=${DEVICE} -g -ffunction-sections -fdata-sections -D __${DEVICE}__ -D DEPRECATED +# my version +# -Og -mmcu=${DEVICE} -g -D __${DEVICE}__ + +# original cmd +# -T ${GCC_LD} -L ${GCC_MSP_INC} -mmcu=${DEVICE} -g -Wl,--gc-sections +# my version +# -T ${GCC_LD} -L ${GCC_MSP_INC} -mmcu=${DEVICE} -g + +# my complete version +# -Og -mmcu=${DEVICE} -g -D__${DEVICE}__ -T ${GCC_LD} -L ${GCC_MSP_INC} -I ${GCC_MSP_INC} -I ${GCC_ELF_INC} + +MYFLAGS="-Og -mmcu=${DEVICE} -g -D__${DEVICE}__ -T ${GCC_LD} -L ${GCC_MSP_INC} -I ${GCC_MSP_INC} -I ${GCC_ELF_INC}" + +CFLAGS="-Os -D__${DEVICE}__ -mmcu=${DEVICE} -g -ffunction-sections -fdata-sections -DDEPRECATED" +LDFLAGS="-T ${GCC_LD} -L ${GCC_MSP_INC} -mmcu=${DEVICE} -g -Wl,--gc-sections" +INCLUDES="-I ${GCC_MSP_INC} -I ${GCC_ELF_INC}" + +# files +EXOBJECT=$OUT_DIR/$DEVICE.elf.o +EXOUTPUT=$OUT_DIR/$DEVICE.elf.out + + +function execute(){ + echo + echo ========================== + echo execute\> $* + $* +} + +execute mkdir -p $OUT_DIR +execute $CC $MYFLAGS $MAIN_FILE -o $EXOUTPUT +# execute $CC $INCLUDES $CFLAGS -c $MAIN_FILE -o $EXOBJECT +# execute $CC $LDFLAGS $EXOBJECT -o $EXOUTPUT + +# execute mspdebug rf2500 "prog ${EXOUTPUT}" +# execute mspdebug rf2500 "run" diff --git a/decoders/README.md b/decoders/README.md new file mode 100644 index 0000000..8ea2ea1 --- /dev/null +++ b/decoders/README.md @@ -0,0 +1,7 @@ +# decoders + +This folder containts the decoders for Sigrok Pulseview to decode the data send and received by the muc + +## what to find hire + +- TMC429 decoder \ No newline at end of file diff --git a/decoders/tmc429/__init__.py b/decoders/tmc429/__init__.py new file mode 100644 index 0000000..2916163 --- /dev/null +++ b/decoders/tmc429/__init__.py @@ -0,0 +1,9 @@ +''' +This decoder stacks on top of the 'spi' PD and decodes the protocol spoken +by the Trinamic TMC429 motion controller chip. + +Details: +https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC429_datasheet.pdf +''' + +from .pd import Decoder \ No newline at end of file diff --git a/decoders/tmc429/pd.py b/decoders/tmc429/pd.py new file mode 100644 index 0000000..d811f5b --- /dev/null +++ b/decoders/tmc429/pd.py @@ -0,0 +1,73 @@ +import sigrokdecode as srd +from .lists import * + +( + ANN_RS1, ANN_RS2, ANN_RS3, ANN_xEQ1, ANN_xEQ2, ANN_xEQ3, + ANN_WARN + ) = range(7) + +class Decoder(srd.Decoder): + api_version = 3 + id = 'tmc429' + name = 'TMC429' + longname = 'Trinamic TMC429' + desc = 'Trinamic TMC429 3-axis motion controller.' + license = 'gplv3+' + inputs = ['spi'] + outputs = [] + tags = ['IC'] + annotations = ( + ('RS1', 'Left rerence switch 1'), + ('RS2', 'Left rerence switch 2'), + ('RS3', 'Left rerence switch 3'), + ('xEQ1', 'Motro 1 reached target posistion'), + ('xEQ2', 'Motro 2 reached target posistion'), + ('xEQ3', 'Motro 3 reached target posistion'), + ('warning', 'Warnings') + ) + annotation_rows = ( + ('recieve', 'Recieve', (ANN_RS1, ANN_RS2, ANN_RS3, ANN_xEQ1, ANN_xEQ2, ANN_xEQ3)), + ('warning', 'Warnings', (ANN_WARN)) + ) + + def __init__(self): + self.reset() + + def reset(self): + #self.ss_cmd, self.es_cmd = 0, 0 + self.mosi_bytes = [] + + def start(self): + self.out_ann = self.register(srd.OUTPUT_ANN) + + # def putx(self, data): + # self.put(self.ss_cmd, self.es_cmd, self.out_ann, data) + + def put_warn(self, pos, msg): + self.put(pos[0], pos[1], self.out_ann, [2, [msg]]) + + def decode(self, ss, es, data): + if(data[0] == 'BITS'): + # check length of datapacket + if(len(data[1]) < 16): + # datapacket to short + #TODO: add error + return + + # trim to the last 16 bits + #TODO: add warning it packet is to long + while(len(data[1]) == 16): + data[1].pop(0) + data[2].pop(0) + + self.decodeRecieve(data[2]) + + def decodeRecieve(self, data): + # read left rerence switches + if(data[2][0]): + self.put(data[2][1], data[2][2], self.out_ann, [ANN_RS3, ['RS3']]) + if(data[4][0]): + self.put(data[4][1], data[4][2], self.out_ann, [ANN_RS2, ['RS2']]) + if(data[6][0]): + self.put(data[6][1], data[6][2], self.out_ann, [ANN_RS1, ['RS1']]) +