diff options
Diffstat (limited to 'src/pio_test')
l--------- | src/pio_test/FreeRTOS | 1 | ||||
l--------- | src/pio_test/FreeRTOSConfig.h | 1 | ||||
-rw-r--r-- | src/pio_test/Makefile | 124 | ||||
-rw-r--r-- | src/pio_test/README | 1 | ||||
-rw-r--r-- | src/pio_test/bin/.git_keep | 0 | ||||
l--------- | src/pio_test/bsp | 1 | ||||
l--------- | src/pio_test/common.h | 1 | ||||
l--------- | src/pio_test/delay.c | 1 | ||||
l--------- | src/pio_test/delay.h | 1 | ||||
l--------- | src/pio_test/fsm.h | 1 | ||||
-rw-r--r-- | src/pio_test/main.c | 166 | ||||
l--------- | src/pio_test/pio.c | 1 | ||||
l--------- | src/pio_test/pio.h | 1 | ||||
-rw-r--r-- | src/pio_test/uart_things.h | 91 |
14 files changed, 0 insertions, 391 deletions
diff --git a/src/pio_test/FreeRTOS b/src/pio_test/FreeRTOS deleted file mode 120000 index 51f4e96..0000000 --- a/src/pio_test/FreeRTOS +++ /dev/null @@ -1 +0,0 @@ -../FreeRTOS
\ No newline at end of file diff --git a/src/pio_test/FreeRTOSConfig.h b/src/pio_test/FreeRTOSConfig.h deleted file mode 120000 index 62956a2..0000000 --- a/src/pio_test/FreeRTOSConfig.h +++ /dev/null @@ -1 +0,0 @@ -../fsm/FreeRTOSConfig.h
\ No newline at end of file diff --git a/src/pio_test/Makefile b/src/pio_test/Makefile deleted file mode 100644 index e7c6fb5..0000000 --- a/src/pio_test/Makefile +++ /dev/null @@ -1,124 +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 - $(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 - -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/pio_test/README b/src/pio_test/README deleted file mode 100644 index fe9c265..0000000 --- a/src/pio_test/README +++ /dev/null @@ -1 +0,0 @@ -This test project prints PIO input on the debug USART diff --git a/src/pio_test/bin/.git_keep b/src/pio_test/bin/.git_keep deleted file mode 100644 index e69de29..0000000 --- a/src/pio_test/bin/.git_keep +++ /dev/null diff --git a/src/pio_test/bsp b/src/pio_test/bsp deleted file mode 120000 index 5d9120a..0000000 --- a/src/pio_test/bsp +++ /dev/null @@ -1 +0,0 @@ -../bsp
\ No newline at end of file diff --git a/src/pio_test/common.h b/src/pio_test/common.h deleted file mode 120000 index ddb348b..0000000 --- a/src/pio_test/common.h +++ /dev/null @@ -1 +0,0 @@ -../fsm/common.h
\ No newline at end of file diff --git a/src/pio_test/delay.c b/src/pio_test/delay.c deleted file mode 120000 index 9fc92c2..0000000 --- a/src/pio_test/delay.c +++ /dev/null @@ -1 +0,0 @@ -../fsm/delay.c
\ No newline at end of file diff --git a/src/pio_test/delay.h b/src/pio_test/delay.h deleted file mode 120000 index 313cbbf..0000000 --- a/src/pio_test/delay.h +++ /dev/null @@ -1 +0,0 @@ -../fsm/delay.h
\ No newline at end of file diff --git a/src/pio_test/fsm.h b/src/pio_test/fsm.h deleted file mode 120000 index 3b64b34..0000000 --- a/src/pio_test/fsm.h +++ /dev/null @@ -1 +0,0 @@ -../fsm/fsm.h
\ No newline at end of file diff --git a/src/pio_test/main.c b/src/pio_test/main.c deleted file mode 100644 index 6a81f86..0000000 --- a/src/pio_test/main.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016 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 "stm32f4xx.h" -#include <stdio.h> -#include <stdarg.h> -#include <string.h> -#include <stm32f4xx.h> -#include <stm32f4xx_usart.h> -#include <stm32f4xx_conf.h> -#include "delay.h" - -/* Kernel includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "timers.h" -#include "semphr.h" -#include "pio.h" - - -#include "uart_things.h" - -void vApplicationStackOverflowHook( TaskHandle_t xTask, - signed char *pcTaskName ) -{ - usart_debug("TASK OVERFLOW %s\r\n", pcTaskName); - while (1) {}; -} - -void launcher_task(void *args); - -int main(void) -{ - // ============== PC DEBUG USART =========== - RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); - RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); - - GPIO_InitTypeDef GPIO_InitStruct; - GPIO_InitStruct.GPIO_Pin = GPIOA_PIN_USART2_RX | GPIOA_PIN_USART2_TX; - GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; - GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP; - GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_USART2); - GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_USART2); - - // Setup USART2 for 9600,8,N,1 - USART_InitTypeDef USART_InitStruct; - USART_InitStruct.USART_BaudRate = 9600; - USART_InitStruct.USART_WordLength = USART_WordLength_8b; - USART_InitStruct.USART_StopBits = USART_StopBits_1; - USART_InitStruct.USART_Parity = USART_Parity_No; - USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None; - USART_InitStruct.USART_Mode = USART_Mode_Tx | USART_Mode_Rx; - USART_Init(USART2, &USART_InitStruct); - -#if 0 - // enable the USART2 receive interrupt - USART_ITConfig(USART2, USART_IT_RXNE, ENABLE); - - NVIC_InitTypeDef NVIC_InitStructure; - NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 6; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; - NVIC_Init(&NVIC_InitStructure); - - NVIC_SetPriority(USART2_IRQn, 6); -#endif - - // finally this enables the complete USART2 peripheral - USART_Cmd(USART2, ENABLE); - - TaskHandle_t task_handle; - xTaskCreate( - launcher_task, - "TaskLauncher", - configMINIMAL_STACK_SIZE, - (void*) NULL, - tskIDLE_PRIORITY + 2UL, - &task_handle); - - /* Start the RTOS Scheduler */ - vTaskStartScheduler(); - - /* HALT */ - while(1); -} - -void launcher_task(void *args) { - - usart_debug_puts("pio init\r\n"); - - pio_init(); - - struct fsm_input_signals_t signals; - struct fsm_input_signals_t previous_signals; - - pio_set_fsm_signals(&previous_signals); - - usart_debug(" qrp = %d ", previous_signals.qrp); - usart_debug(" tone_1750 = %d ", previous_signals.tone_1750); - usart_debug(" sq = %d ", previous_signals.sq); - usart_debug(" discrim_u = %d ", previous_signals.discrim_u); - usart_debug(" discrim_d = %d ", previous_signals.discrim_d); - usart_debug(" wind_generator_ok = %d ", previous_signals.wind_generator_ok); - usart_debug(" sstv_mode = %d\r\n", previous_signals.sstv_mode); - - while(1) { - delay_ms(5 * 1000ul); - - pio_set_fsm_signals(&signals); - - if (previous_signals.qrp != signals.qrp) { - usart_debug("pio qrp = %d\r\n", signals.qrp); - } - if (previous_signals.tone_1750 != signals.tone_1750) { - usart_debug("pio tone_1750 = %d\r\n", signals.tone_1750); - } - if (previous_signals.sq != signals.sq) { - usart_debug("pio sq = %d\r\n", signals.sq); - } - if (previous_signals.discrim_u != signals.discrim_u) { - usart_debug("pio discrim_u = %d\r\n", signals.discrim_u); - } - if (previous_signals.discrim_d != signals.discrim_d) { - usart_debug("pio discrim_d = %d\r\n", signals.discrim_d); - } - if (previous_signals.wind_generator_ok != signals.wind_generator_ok) { - usart_debug("pio wind_generator_ok = %d\r\n", signals.wind_generator_ok); - } - if (previous_signals.sstv_mode != signals.sstv_mode) { - usart_debug("pio sstv_mode = %d\r\n", signals.sstv_mode); - } - - previous_signals = signals; - - pio_set_tx(signals.discrim_u); - pio_set_qrp(signals.discrim_d); - pio_set_mod_off(signals.tone_1750); - } -} - diff --git a/src/pio_test/pio.c b/src/pio_test/pio.c deleted file mode 120000 index 00c4edc..0000000 --- a/src/pio_test/pio.c +++ /dev/null @@ -1 +0,0 @@ -../fsm/pio.c
\ No newline at end of file diff --git a/src/pio_test/pio.h b/src/pio_test/pio.h deleted file mode 120000 index 6e326f5..0000000 --- a/src/pio_test/pio.h +++ /dev/null @@ -1 +0,0 @@ -../fsm/pio.h
\ No newline at end of file diff --git a/src/pio_test/uart_things.h b/src/pio_test/uart_things.h deleted file mode 100644 index 9055b37..0000000 --- a/src/pio_test/uart_things.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016 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. -*/ - -#pragma once - -const uint16_t GPIOA_PIN_USART2_RX = GPIO_Pin_3; -const uint16_t GPIOA_PIN_USART2_TX = GPIO_Pin_2; - - -char msg[32]; -static int cnt = 0; -void printcnt(void) -{ - snprintf(msg, 31, "%d ", cnt++); - - char* c = msg; - while (*c) { - USART_SendData(USART2, *c); - while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET) ; - c++; - } -} - -static void usart_puts(USART_TypeDef* USART, const char* str) -{ - while(*str) { - // wait until data register is empty - USART_SendData(USART, *str); - while(USART_GetFlagStatus(USART, USART_FLAG_TXE) == RESET) ; - str++; - } -} -#define MAX_MSG_LEN 80 -static char usart_debug_message[MAX_MSG_LEN]; - -void usart_debug(const char *format, ...) -{ - va_list list; - va_start(list, format); - vsnprintf(usart_debug_message, MAX_MSG_LEN-1, format, list); - usart_puts(USART2, usart_debug_message); - va_end(list); -} - -void usart_debug_puts(const char* str) -{ - usart_puts(USART2, str); -} - -void USART2_IRQHandler(void) -{ - /* RXNE handler */ - if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) - { - /* If received 't', toggle LED and transmit 'T' */ - if((char)USART_ReceiveData(USART2) == 't') - { - USART_SendData(USART2, 'T'); - - //while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET) ; - } - else { - USART_SendData(USART2, 'N'); - USART_SendData(USART2, 'o'); - USART_SendData(USART2, '!'); - USART_SendData(USART2, '\n'); - } - } -} - |