diff options
Diffstat (limited to 'src/fsm')
-rw-r--r-- | src/fsm/.gitignore | 1 | ||||
-rw-r--r-- | src/fsm/Makefile | 126 | ||||
-rw-r--r-- | src/fsm/README.md | 15 | ||||
-rw-r--r-- | src/fsm/bin/.git_keep | 0 | ||||
-rw-r--r-- | src/fsm/debug.c | 77 | ||||
-rw-r--r-- | src/fsm/debug.h | 47 | ||||
-rw-r--r-- | src/fsm/hardfault.s | 13 |
7 files changed, 0 insertions, 279 deletions
diff --git a/src/fsm/.gitignore b/src/fsm/.gitignore deleted file mode 100644 index 6533942..0000000 --- a/src/fsm/.gitignore +++ /dev/null @@ -1 +0,0 @@ -vc.h diff --git a/src/fsm/Makefile b/src/fsm/Makefile deleted file mode 100644 index b939934..0000000 --- a/src/fsm/Makefile +++ /dev/null @@ -1,126 +0,0 @@ -### -# GNU ARM Embedded Toolchain -CC=arm-none-eabi-gcc -LD=arm-none-eabi-ld -AR=arm-none-eabi-ar -AS=arm-none-eabi-as -CP=arm-none-eabi-objcopy -OD=arm-none-eabi-objdump -SIZE=arm-none-eabi-size - -### -# Directory Structure -BINDIR=bin -SRCDIR=. - -### -# Find source files -ASOURCES=$(shell find -L $(SRCDIR) -name '*.s') -CSOURCES+=$(shell find -L $(SRCDIR) -name '*.c') -# Find header directories -INC=$(shell find -L . -name '*.h' -exec dirname {} \; | uniq) -INCLUDES=$(INC:%=-I%) -# Create object list -OBJECTS=$(ASOURCES:%.s=%.o) -OBJECTS+=$(CSOURCES:%.c=%.o) -# Define output files ELF & IHEX -BINELF=outp.elf -BINHEX=outp.hex - -### -# MCU FLAGS -MCFLAGS=-mcpu=cortex-m4 -mthumb -mlittle-endian \ --mfpu=fpv4-sp-d16 -mfloat-abi=softfp -mthumb-interwork -# COMPILE FLAGS -DEFS=-DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DARM_MATH_CM4 -D__FPU_PRESENT=1 -CFLAGS =-Wall -ggdb -std=c99 -c $(MCFLAGS) $(DEFS) $(INCLUDES) -# LINKER FLAGS -LDSCRIPT= bsp/stm32_flash.ld -LDFLAGS =-T $(LDSCRIPT) --specs=nosys.specs $(MCFLAGS) -Wl,-Map=$(BINDIR)/outp.map - -### -# Optimizations -OPT?='O2 O3 O6' -# O1 and O4 are irrelevant -# O5 breaks FreeRTOS somehow -# I'm not trusting O7 - -ifneq ($(filter O1,$(OPT)),) -CXXFLAGS+=-fno-exceptions # Uncomment to disable exception handling -DEFS+=-DNO_EXCEPTIONS # The source code has to comply with this rule -endif - -ifneq ($(filter O2,$(OPT)),) -CFLAGS+=-Os # Optimize for size https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html -CXXFLAGS+=-Os -LDFLAGS+=-Os # Optimize for size https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html -endif - -ifneq ($(filter O3,$(OPT)),) -CFLAGS+=-ffunction-sections -fdata-sections # Place each function or data item into its own section in the output file -CXXFLAGS+=-ffunction-sections -fdata-sections # -||- -LDFLAGS+=-Wl,-gc-sections # Remove isolated unused sections -endif - -ifneq ($(filter O4,$(OPT)),) -CFLAGS+=-fno-builtin # Disable C++ exception handling -CXXFLAGS+=-fno-builtin # Disable C++ exception handling -endif - -ifneq ($(filter O5,$(OPT)),) -CFLAGS+=-flto # Enable link time optimization -CXXFLAGS+=-flto # Enable link time optimization -LDFLAGS+=-flto # Enable link time optimization -endif - -ifneq ($(filter O6,$(OPT)),) -CXXFLAGS+=-fno-rtti # Disable type introspection -endif - -ifneq ($(findstring O7,$(OPT)),) -LDFLAGS+=--specs=nano.specs # Use size optimized newlib -endif - -### -# Build Rules -.PHONY: all release debug clean - -all: release - -release: $(BINDIR)/$(BINHEX) - -debug: CFLAGS+=-g -debug: LDFLAGS+=-g -debug: release - -$(BINDIR)/$(BINHEX): $(BINDIR)/$(BINELF) - $(CP) -O ihex $< $@ - -$(BINDIR)/$(BINELF): $(OBJECTS) vc.h - $(CC) $(LDFLAGS) $(OBJECTS) -o $@ - $(SIZE) $(BINDIR)/$(BINELF) - -%.o: %.c $(INC) - $(CC) $(CFLAGS) $< -o $@ - -%.o: %.s - $(CC) $(CFLAGS) $< -o $@ - -vc.h: ../../.git/logs/HEAD - echo "// This file is generated by Makefile." > vc.h - echo "// Do not edit this file!" >> vc.h - git log -1 --format="format:#define GIT_VERSION \"%h\"" >> vc.h - echo >> vc.h - echo >> vc.h - -clean: - rm -f $(OBJECTS) $(BINDIR)/$(BINELF) $(BINDIR)/$(BINHEX) - -# Connect to openocd's gdb server on port 3333 -deploy: $(BINDIR)/$(BINELF) -ifeq ($(wildcard /opt/openocd/bin/openocd),) - /usr/bin/openocd -f /usr/share/openocd/scripts/board/stm32f4discovery.cfg -c "program bin/"$(BINELF)" verify reset" -c "init" -c "reset" -c "exit" -else - /opt/openocd/bin/openocd -f /opt/openocd/share/openocd/scripts/board/stm32f4discovery.cfg -c "program bin/"$(BINELF)" verify reset" -c "init" -c "reset" -c "exit" -endif - diff --git a/src/fsm/README.md b/src/fsm/README.md deleted file mode 100644 index 69f1f22..0000000 --- a/src/fsm/README.md +++ /dev/null @@ -1,15 +0,0 @@ -An example program that tries to output CW using -the audio codec on the STM32F4DISCOVERY, using the FSM -and switches. - -Connections as follows: - -Blue in QRP_n PC1 -Violet out LED red PC2 -Grey in 1750 PC4 -White out LED yel PC5 -Black - GND GND -Brown in RX_n PC6 -Red in U_n PC8 -Orange out LED grn PC9 -Green in D_n PC11 diff --git a/src/fsm/bin/.git_keep b/src/fsm/bin/.git_keep deleted file mode 100644 index e69de29..0000000 --- a/src/fsm/bin/.git_keep +++ /dev/null diff --git a/src/fsm/debug.c b/src/fsm/debug.c deleted file mode 100644 index 2e33a32..0000000 --- a/src/fsm/debug.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Matthias P. Braendli - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. -*/ - -#include <stddef.h> -#include <stdint.h> - -#include "debug.h" - -#if _DEBUG - -void debug_send_command(int command, void *message) -{ - __asm__ volatile ( - "mov r0, %[cmd];" - "mov r1, %[msg];" - "bkpt #0xAB" - : - : [cmd] "r" (command), [msg] "r" (message) - : "r0", "r1", "memory"); -} - -void put_char(char c) -{ - __asm__ volatile ( - "mov r0, #0x03\n" /* SYS_WRITEC */ - "mov r1, %[msg]\n" - "bkpt #0xAB\n" - : - : [msg] "r" (&c) - : "r0", "r1" - ); -} - -void debug_print(const char* str) -{ - const int std_err = 2; - - int strlen = 0; - const char* s; - s = str; - while (*s) { - strlen++; - s++; - } - - uint32_t m[] = { std_err, (uint32_t)str, strlen }; - debug_send_command(0x05, m); -} - -#else -void debug_send_command(int command, void *message) { } -void put_char(char c) { } -void debug_print(const char* str) { } - -#endif - diff --git a/src/fsm/debug.h b/src/fsm/debug.h deleted file mode 100644 index 6215e5f..0000000 --- a/src/fsm/debug.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Matthias P. Braendli - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. -*/ - -/* Debugging utilities using the ARM semihosting facilities. Warning, it's quite - * slow. - * - * when used with OpenOCD's gdb server, requires the gdb command - * - * monitor arm semihosting enable - */ -#ifndef __DEBUG_H_ -#define __DEBUG_H_ - -/* Example usage for the send_command function -const char *s = "Hello world\n"; -uint32_t m[] = { 2, (uint32_t)s, sizeof(s)/sizeof(char) }; -send_command(0x05, m); -// some interrupt ID - -*/ - -/* Print a string to the OpenOCD console */ -void debug_print(const char* str); - -#endif // __DEBUG_H_ - diff --git a/src/fsm/hardfault.s b/src/fsm/hardfault.s deleted file mode 100644 index 8570dcc..0000000 --- a/src/fsm/hardfault.s +++ /dev/null @@ -1,13 +0,0 @@ -.syntax unified -.cpu cortex-m3 -.thumb - -.global HardFault_Handler -.extern hard_fault_handler_c - -HardFault_Handler: - tst lr, #4 - ite eq - mrseq r0, msp - mrsne r0, psp - b hard_fault_handler_c |