From 92a245bbfb841f024114d8a4e369fbd0b3c74306 Mon Sep 17 00:00:00 2001 From: Jake <jake.read@cba.mit.edu> Date: Sun, 10 Dec 2017 23:31:54 -0500 Subject: [PATCH] should be ready for experiments --- embedded/README.md | 15 +--- .../atsams70-tinyrouter/Debug/Makefile | 18 ++--- .../atsams70-tinyrouter.cproj | 2 +- .../atsams70-tinyrouter/src/main.c | 27 ++++++- .../atsams70-tinyrouter/src/node.h | 3 +- .../atsams70-tinyrouter/src/packet.c | 15 ++-- .../atsams70-tinyrouter/src/packet.h | 10 +-- .../atsams70-tinyrouter/src/packet_handling.c | 79 ++++++++++--------- .../atsams70-tinyrouter/src/packet_handling.h | 5 ++ .../atsams70-tinyrouter/src/ringbuffer.c | 36 ++++----- .../atsams70-tinyrouter/src/ringbuffer.h | 5 ++ .../atsams70-tinyrouter/src/tinyport.c | 29 +++---- .../atsams70-tinyrouter/src/tinyport.h | 5 +- 13 files changed, 131 insertions(+), 118 deletions(-) diff --git a/embedded/README.md b/embedded/README.md index 9f85828..a8f79c0 100644 --- a/embedded/README.md +++ b/embedded/README.md @@ -1,21 +1,12 @@ # 'API' -// test with 8 or so? -// test at higher bitrates? -// how to do big packet pushing? +// how to do big packet pushing? how to verify? +// start writing now // better app layer - and make sure to clear space? - - towards timing measurement - -// status updates & lambda function - -// testing ... - - p1 -> hi when rx buffer non-empty - - p2 -> hi when packet handler has packet - - p3 -> hi when tx buffer non-empty # Results -// do writeup +// writeup str8 to latex In this screenshot, a falling edge on Channel 4 indicates an end of the main while() loop - so intervals between are packet processing and decision making. diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/Debug/Makefile b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/Debug/Makefile index d8acbee..085d898 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/Debug/Makefile +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/Debug/Makefile @@ -226,63 +226,63 @@ LINKER_SCRIPT_DEP+= \ src/%.o: ../src/%.c @echo Building file: $< @echo Invoking: ARM/GNU C Compiler : 6.2.1 - $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O2 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" + $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O3 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" @echo Finished building: $< src/ASF/common/services/delay/sam/%.o: ../src/ASF/common/services/delay/sam/%.c @echo Building file: $< @echo Invoking: ARM/GNU C Compiler : 6.2.1 - $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O2 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" + $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O3 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" @echo Finished building: $< src/ASF/common/services/clock/sams70/%.o: ../src/ASF/common/services/clock/sams70/%.c @echo Building file: $< @echo Invoking: ARM/GNU C Compiler : 6.2.1 - $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O2 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" + $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O3 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" @echo Finished building: $< src/ASF/sam/drivers/pmc/%.o: ../src/ASF/sam/drivers/pmc/%.c @echo Building file: $< @echo Invoking: ARM/GNU C Compiler : 6.2.1 - $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O2 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" + $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O3 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" @echo Finished building: $< src/ASF/common/boards/user_board/%.o: ../src/ASF/common/boards/user_board/%.c @echo Building file: $< @echo Invoking: ARM/GNU C Compiler : 6.2.1 - $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O2 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" + $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O3 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" @echo Finished building: $< src/ASF/common/utils/interrupt/%.o: ../src/ASF/common/utils/interrupt/%.c @echo Building file: $< @echo Invoking: ARM/GNU C Compiler : 6.2.1 - $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O2 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" + $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O3 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" @echo Finished building: $< src/ASF/sam/utils/cmsis/sams70/source/templates/gcc/%.o: ../src/ASF/sam/utils/cmsis/sams70/source/templates/gcc/%.c @echo Building file: $< @echo Invoking: ARM/GNU C Compiler : 6.2.1 - $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O2 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" + $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O3 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" @echo Finished building: $< src/ASF/sam/utils/cmsis/sams70/source/templates/%.o: ../src/ASF/sam/utils/cmsis/sams70/source/templates/%.c @echo Building file: $< @echo Invoking: ARM/GNU C Compiler : 6.2.1 - $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O2 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" + $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O3 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" @echo Finished building: $< src/ASF/sam/utils/syscalls/gcc/%.o: ../src/ASF/sam/utils/syscalls/gcc/%.c @echo Building file: $< @echo Invoking: ARM/GNU C Compiler : 6.2.1 - $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O2 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" + $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAMS70N20__ -DDEBUG -Dscanf=iscanf -DBOARD=USER_BOARD -DARM_MATH_CM7=true -Dprintf=iprintf -I"../src/ASF/common/boards" -I"../src/ASF/sam/utils" -I"../src/ASF/sam/utils/header_files" -I"../src/ASF/sam/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/sam/utils/fpu" -I"../src/ASF/common/utils" -I"../src/ASF/sam/utils/cmsis/sams70/source/templates" -I"../src/ASF/sam/utils/cmsis/sams70/include" -I"../src/ASF/common/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam/drivers/pmc" -I"../src/ASF/common/services/clock" -I"../src/ASF/common/services/delay" -O3 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m7 -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" @echo Finished building: $< diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/atsams70-tinyrouter.cproj b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/atsams70-tinyrouter.cproj index d2e2e85..f61040a 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/atsams70-tinyrouter.cproj +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/atsams70-tinyrouter.cproj @@ -362,7 +362,7 @@ <Value>../src/ASF/common/services/delay</Value> </ListValues> </armgcc.compiler.directories.IncludePaths> - <armgcc.compiler.optimization.level>Optimize more (-O2)</armgcc.compiler.optimization.level> + <armgcc.compiler.optimization.level>Optimize most (-O3)</armgcc.compiler.optimization.level> <armgcc.compiler.optimization.OtherFlags>-fdata-sections</armgcc.compiler.optimization.OtherFlags> <armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection> <armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel> diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/main.c b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/main.c index 231e973..a85d612 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/main.c +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/main.c @@ -188,7 +188,9 @@ int main (void){ tp4 = tinyport_new(UART4, PIOD, PERIPHERAL_C, PIO_PER_P18, PIO_PER_P19, &p4rbrx, &p4rbtx, &p4lr, &p4lg, &p4lb); tp_init(&tp1); + #if IS_HOME_PORT UART2->UART_BRGR = 81; // manual set to FTDI speed + #endif tp_init(&tp2); tp_init(&tp3); tp_init(&tp4); @@ -231,7 +233,10 @@ int main (void){ } } - packet_t packetlooper; + packet_t packetlooper = packet_new(); + + uint32_t beatTicker = 0; + uint32_t packetTicker = 0; while(1){ pin_set(&tstclk); @@ -242,18 +247,32 @@ int main (void){ } for(int i = 0; i < 4; i++){ // loop over ports and check for packets, add packets to packet buffer if(ports[i]->haspacket){ - + packetTicker ++; // TODO: update heartbeat / buffer depth packetlooper = ports[i]->packet; packet_clean(&ports[i]->packet); // reset packet states ports[i]->haspacket = TP_NO_PACKET; - handle_packet(&packetlooper, i); - packet_clean(&packetlooper); } } + pin_clear(&tstclk); + /* + if(!(packetTicker % HEARTBEAT_PERPACKET_MODULO)){ + packetTicker ++; // unlock + send_heartbeats(); + beatTicker = 0; + } + + beatTicker ++; + if(!(beatTicker % HEARTBEAT_MODULO)){ + pin_set(&tstpckt); + send_heartbeats(); + } else { + pin_clear(&tstpckt); + } + */ delay_cycles(1); // one clock tick to relax interrupt scheduler } // end while } // end main diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/node.h b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/node.h index 71b0ecb..b4931a1 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/node.h +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/node.h @@ -2,7 +2,8 @@ #define NODE_H_ #define MAX_HOPCOUNT 6 -#define MYADDRESS 2 +#define MYADDRESS 9 +#define IS_HOME_PORT 0 uint8_t LUT[1024][4]; uint8_t myAddress; diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet.c b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet.c index 53b7c7f..564cb12 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet.c +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet.c @@ -10,24 +10,27 @@ packet_t packet_new(void){ packet_t packet; packet.counter = 0; - packet.size = 255; + packet.raw[4] = 255; // sets size big so no clipping during handling return packet; } void packet_buildraw(packet_t *packet){ + /* packet->raw[0] = packet->type; packet->raw[1] = packet->destination; packet->raw[2] = 0; // hop count packet->raw[3] = packet->source; packet->raw[4] = packet->size; + */ } void packet_clean(packet_t *packet){ packet->counter = 0; - packet->type = 0; - packet->destination = 0; - packet->source = 0; - packet->hopcount = 0; - packet->size = 255; + packet->raw[4] = 255; + //packet->type = 0; + //packet->destination = 0; + //packet->source = 0; + //packet->hopcount = 0; + //packet->size = 255; } \ No newline at end of file diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet.h b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet.h index c1a4fd6..2ec4bf1 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet.h +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet.h @@ -20,11 +20,11 @@ typedef struct{ uint8_t counter; uint8_t raw[255]; - uint8_t type; - uint8_t destination; - uint8_t source; - uint8_t hopcount; - uint8_t size; + //uint8_t type; + //uint8_t destination; + //uint8_t source; + //uint8_t hopcount; + //uint8_t size; }packet_t; packet_t packet_new(void); diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet_handling.c b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet_handling.c index 158ddf3..b294db7 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet_handling.c +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet_handling.c @@ -16,9 +16,7 @@ void update_LUT(uint16_t src, uint8_t hopCount, uint8_t port) { } void send_packet(packet_t* p, uint8_t port) { - tp_putdata(ports[port], p->raw, p->size); - //free((void*)p); // need rethink packet passing ? - // @Dougie: when I use free here I don't get the full packet return? + tp_putdata(ports[port], p->raw, p->raw[4]); } void broadcast_packet(packet_t* p, uint8_t exclude) { @@ -33,59 +31,68 @@ int in_table(uint8_t dest) { LUT[dest][2] == MAX_HOPCOUNT && LUT[dest][3] == MAX_HOPCOUNT); } -void acknowledge_packet(packet_t* p){ - packet_t ackpack = packet_new(); - - ackpack.type = P_ACK; - ackpack.destination = p->source; - ackpack.source = p->destination; - ackpack.hopcount = 0; - ackpack.size = 5; - - packet_buildraw(&ackpack); // from pointers -> raw bytes - - if (in_table(ackpack.destination)) { +packet_t ackpack; + +void acknowledge_packet(packet_t* p){ + ackpack.raw[0] = P_ACK; // is ack + ackpack.raw[1] = p->raw[3]; // destination = source + ackpack.raw[2] = 0; // hopcount = 0 + ackpack.raw[3] = p->raw[1]; // source = destination (should be us) + ackpack.raw[4] = 5; // all acks are 5 bytes + + if (in_table(ackpack.raw[1])) { send_on_bestport(&ackpack); } else { // altho, this should not happen - we have presumably just seen this come in. p->raw[0] = P_ACK_FLOOD; broadcast_packet(p, 4); } - - // add: - //free(&ackpack); } void send_on_bestport(packet_t* p){ + // empty buffer reads buffersize '1' + // from there, 8 bytes in buffer is + 1 (x >> 3) + // so divide by 1 is like ~ packet lambda (where packet is 3 byte payload) + // divide by 3 for one hopcount = three packets in buffer *shrugman* int bestPort = 0; - int bestHopCount = LUT[p->destination][0]; + int bestLambda = LUT[p->raw[1]][0] + ports[0]->buffersize / 3; for (int i = 0; i < 4; i++) { - if (LUT[p->destination][i] < bestHopCount) { + if (LUT[p->raw[1]][i] < bestLambda) { bestPort = i; - bestHopCount = LUT[p->destination][i]; + bestLambda = LUT[p->raw[1]][0] + ports[0]->buffersize / 3; } } send_packet(p, bestPort); } +void send_heartbeats(void){ + #if IS_HOME_PORT + for(int i = 1; i < 4; i ++){ + tp_putchar(ports[i], 257 - (rb_free_space(ports[i]->rbtx) >> 3)); + } + #else + for(int i = 0; i < 4; i ++){ + tp_putchar(ports[i], 257 - (rb_free_space(ports[i]->rbtx) >> 3)); + } + #endif +} + void handle_packet(packet_t* p, uint8_t port) { - if (p->hopcount > MAX_HOPCOUNT && p->destination != myAddress) { - free((void*)p); // kill it! + if (p->raw[2] > MAX_HOPCOUNT && p->raw[1] != myAddress) { return; // bail! } else { - update_LUT(p->source, p->hopcount, port); // always, and before the hopcount goes up! - p->hopcount ++; // sloppy double-set: we should be just using raw values everywhere? - p->raw[2] = p->hopcount; + update_LUT(p->raw[3], p->raw[2], port); // always, and before the hopcount goes up! + p->raw[2] ++; } switch (parse_type(p)) { case P_STANDARD: - if (p->destination == myAddress) { + if (p->raw[1] == myAddress) { app_onpacket(*p); acknowledge_packet(p); } else { - if (in_table(p->destination)) { + if (in_table(p->raw[1])) { send_on_bestport(p); } else { p->raw[0] = P_STANDARD_FLOOD; @@ -95,10 +102,10 @@ void handle_packet(packet_t* p, uint8_t port) { break; case P_ACK: - if (p->destination == myAddress) { + if (p->raw[1] == myAddress) { app_onack(*p); } else { - if (in_table(p->destination)) { + if (in_table(p->raw[1])) { send_on_bestport(p); } else { p->raw[0] = P_ACK_FLOOD; @@ -108,12 +115,12 @@ void handle_packet(packet_t* p, uint8_t port) { break; case P_STANDARD_FLOOD: - LUT[p->destination][port] = MAX_HOPCOUNT; // likely no good path exists on this port - if (p->destination == myAddress) { + //LUT[p->raw[1]][port] = MAX_HOPCOUNT; // likely no good path exists on this port + if (p->raw[1] == myAddress) { app_onpacket(*p); acknowledge_packet(p); } else { - if(in_table(p->destination)){ + if(in_table(p->raw[1])){ send_on_bestport(p); } else { broadcast_packet(p, port); @@ -122,11 +129,11 @@ void handle_packet(packet_t* p, uint8_t port) { break; case P_ACK_FLOOD: - LUT[p->destination][port] = MAX_HOPCOUNT; // lngpeotp - if (p->destination == myAddress) { + //LUT[p->raw[1]][port] = MAX_HOPCOUNT; // lngpeotp + if (p->raw[1] == myAddress) { app_onack(*p); } else { - if(in_table(p->destination)){ + if(in_table(p->raw[1])){ send_on_bestport(p); } else { broadcast_packet(p, port); diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet_handling.h b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet_handling.h index 8d4019c..d19fa65 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet_handling.h +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet_handling.h @@ -9,6 +9,9 @@ #ifndef PACKET_HANDLING_H_ #define PACKET_HANDLING_H_ +#define HEARTBEAT_MODULO 25000 // becomes, roughly, 200ms +#define HEARTBEAT_PERPACKET_MODULO 4 + #include "node.h" int parse_type(packet_t* p); @@ -23,6 +26,8 @@ void handle_packet(packet_t* p, uint8_t port); void send_on_bestport(packet_t* p); +void send_heartbeats(void); + void acknowledge_packet(packet_t* p); int in_table(uint8_t dest); diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/ringbuffer.c b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/ringbuffer.c index a9dc0ef..ba917da 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/ringbuffer.c +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/ringbuffer.c @@ -24,19 +24,6 @@ uint8_t rb_reset(ringbuffer_t *rb){ } } -uint8_t rb_putchar(ringbuffer_t *rb, uint8_t data){ - if(rb){ - rb->buffer[rb->head] = data; - rb->head = (rb->head + 1) % rb->size; // for wrap around - if(rb->head == rb->tail){ - rb->tail = (rb->tail + 1) % rb->size; - } - return 1; - } else { - return 0; - } -} - uint8_t rb_putdata(ringbuffer_t *rb, uint8_t *data, uint8_t size){ uint8_t i = 0; while(!rb_full(rb) && i < size){ @@ -45,14 +32,15 @@ uint8_t rb_putdata(ringbuffer_t *rb, uint8_t *data, uint8_t size){ } } +uint8_t rb_putchar(ringbuffer_t *rb, uint8_t data){ + rb->buffer[rb->head] = data; + rb->head = (rb->head + 1) % rb->size; // for wrap around +} + uint8_t rb_get(ringbuffer_t *rb){ - if(rb && !rb_empty(rb)){ - uint8_t data = rb->buffer[rb->tail]; - rb->tail = (rb->tail + 1) % rb->size; - return data; - } else { - return 0; - } + uint8_t data = rb->buffer[rb->tail]; + rb->tail = (rb->tail + 1) % rb->size; + return data; } uint8_t rb_empty(ringbuffer_t *rb){ @@ -61,4 +49,12 @@ uint8_t rb_empty(ringbuffer_t *rb){ uint8_t rb_full(ringbuffer_t *rb){ return ((rb->head + 1) % rb->size) == rb->tail; +} + +size_t rb_free_space(ringbuffer_t *rb){ + if(rb->head >= rb->tail){ + return rb->size - (rb->head - rb->tail); + } else { + return rb->tail - rb->head - 1; + } } \ No newline at end of file diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/ringbuffer.h b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/ringbuffer.h index 1c74e3e..e404536 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/ringbuffer.h +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/ringbuffer.h @@ -12,6 +12,7 @@ a ringbuffer, s/o https://github.com/dhess/c-ringbuf s/o https://embeddedartistry.com/blog/2017/4/6/circular-buffers-in-cc +s/o https://www.downtowndougbrown.com/2013/01/microcontrollers-interrupt-safe-ring-buffers/ */ #include <stdlib.h> @@ -19,6 +20,8 @@ s/o https://embeddedartistry.com/blog/2017/4/6/circular-buffers-in-cc #include <stddef.h> #include <stdbool.h> +#include <asf.h> + typedef struct { uint8_t * buffer; size_t head; @@ -43,4 +46,6 @@ uint8_t rb_empty(ringbuffer_t *rb); uint8_t rb_full(ringbuffer_t *rb); +size_t rb_free_space(ringbuffer_t *rb); + #endif \ No newline at end of file diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/tinyport.c b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/tinyport.c index 9292a57..fea0b12 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/tinyport.c +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/tinyport.c @@ -53,8 +53,8 @@ void tp_init(tinyport_t *tp){ } void tp_putchar(tinyport_t *tp, uint8_t data){ - while(!(tp->uart->UART_SR & UART_SR_TXRDY)); // but wait - tp->uart->UART_THR = data; + rb_putchar(tp->rbtx, data); + tp->uart->UART_IER |= UART_IER_TXRDY; } int tp_putdata(tinyport_t *tp, uint8_t *data, uint8_t size){ @@ -63,13 +63,6 @@ int tp_putdata(tinyport_t *tp, uint8_t *data, uint8_t size){ return 1; } -void tp_rxhandler(tinyport_t *tp){ - uint8_t data = tp->uart->UART_RHR; - rb_putchar(tp->rbrx, data); - //pin_clear(tp->stlb); - //pin_set(&tstrx); -} - void tp_packetparser(tinyport_t *tp){ while(!tp->haspacket && !rb_empty(tp->rbrx)){ // while the ringbuffer contains data and we don't have a packet yet @@ -85,7 +78,7 @@ void tp_packetparser(tinyport_t *tp){ tp->packetstate = TP_PACKETSTATE_INSIDE; tp->packet.raw[tp->packet.counter] = data; tp->packet.counter ++; - } else { + } else { tp->buffersize = data; } break; @@ -98,18 +91,9 @@ void tp_packetparser(tinyport_t *tp){ // when done, fill in fields for easy access in handling tp->packet.raw[tp->packet.counter] = data; tp->packet.counter ++; - if(tp->packet.counter == 5){ - tp->packet.size = data; // 5th byte in packet structure is size - } - if(tp->packet.counter >= tp->packet.size){ // check counter against packet size to see if @ end of packet - tp->packet.type = tp->packet.raw[0]; - tp->packet.destination = tp->packet.raw[1];//((uint16_t)tp->packet.raw[1] << 8) | tp->packet.raw[2]; - tp->packet.hopcount = tp->packet.raw[2]; - tp->packet.source = tp->packet.raw[3];//((uint16_t)tp->packet.raw[4] << 8) | tp->packet.raw[5]; + if(tp->packet.counter >= tp->packet.raw[4]){ // check counter against packet size to see if @ end of packet tp->haspacket = TP_HAS_PACKET; // this data is final byte, we have packet, this will be last tick in loop tp->packetstate = TP_PACKETSTATE_OUTSIDE; // and we're outside again - pin_set(tp->stlb); - pin_clear(&tstrx); } break; @@ -120,6 +104,11 @@ void tp_packetparser(tinyport_t *tp){ } // end while } // end packetparser +void tp_rxhandler(tinyport_t *tp){ + uint8_t data = tp->uart->UART_RHR; + rb_putchar(tp->rbrx, data); +} + void tp_txhandler(tinyport_t *tp){ if(!rb_empty(tp->rbtx)){ tp->uart->UART_THR = rb_get(tp->rbtx); diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/tinyport.h b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/tinyport.h index dad90d5..c8e576f 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/tinyport.h +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/tinyport.h @@ -45,11 +45,8 @@ #define TP_NO_PACKET 0 #define TP_HAS_PACKET 1 -// packet delimiters -#define TP_DELIMITER_START 255 - #define UART_BAUD_DIVIDER 3 // 977: 9600 baud, 81: 115200, 10: 921600, 3: 3.125 MB, 2: 4.687 MB, 1: 9.337 MB -#define RINGBUFFER_SIZE 1024 // in bytes, or 4 full length packets, have 384KBytes total in system +#define RINGBUFFER_SIZE 2048 // in bytes, or 4 full length packets, have 384KBytes total in system #include "asf.h" #include "pin.h" -- GitLab