aboutsummaryrefslogtreecommitdiff
path: root/stm32f091
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-09-26 16:36:55 +0200
committerlonkaars <loek@pipeframe.xyz>2022-09-26 16:36:55 +0200
commit07e2eef57eeff5a2d21945b9ad6ca1dbd714b924 (patch)
tree63531bad637e201e17d1f58d0dfa42adc316ec2f /stm32f091
parentc82637ccbd2a99466dacd830147ef3df92f86753 (diff)
freertos compiles without errors
Diffstat (limited to 'stm32f091')
-rw-r--r--stm32f091/FreeRTOSConfig.h122
-rw-r--r--stm32f091/idle_task_static_memory.c18
-rw-r--r--stm32f091/idle_task_static_memory.h8
m---------stm32f091/lib/FreeRTOS-Kernel0
-rw-r--r--stm32f091/main.c (renamed from stm32f091/main.cpp)25
-rw-r--r--stm32f091/makefile30
6 files changed, 188 insertions, 15 deletions
diff --git a/stm32f091/FreeRTOSConfig.h b/stm32f091/FreeRTOSConfig.h
new file mode 100644
index 0000000..17c0ce7
--- /dev/null
+++ b/stm32f091/FreeRTOSConfig.h
@@ -0,0 +1,122 @@
+/* USER CODE BEGIN Header */
+/*
+ * FreeRTOS Kernel V10.0.1
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * 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.
+ *
+ * http://www.FreeRTOS.org
+ * http://aws.amazon.com/freertos
+ *
+ * 1 tab == 4 spaces!
+ */
+/* USER CODE END Header */
+
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+/*-----------------------------------------------------------
+ * Application specific definitions.
+ *
+ * These definitions should be adjusted for your particular hardware and
+ * application requirements.
+ *
+ * These parameters and more are described within the 'configuration' section of the
+ * FreeRTOS API documentation available on the FreeRTOS.org web site.
+ *
+ * See http://www.freertos.org/a00110.html
+ *----------------------------------------------------------*/
+
+/* USER CODE BEGIN Includes */
+/* Section where include file can be added */
+/* USER CODE END Includes */
+
+/* Ensure definitions are only used by the compiler, and not by the assembler. */
+#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
+ #include <stdint.h>
+ extern uint32_t SystemCoreClock;
+ void xPortSysTickHandler(void);
+#endif
+#define configUSE_PREEMPTION 1
+#define configSUPPORT_STATIC_ALLOCATION 1
+#define configSUPPORT_DYNAMIC_ALLOCATION 1
+#define configUSE_IDLE_HOOK 0
+#define configUSE_TICK_HOOK 0
+#define configCPU_CLOCK_HZ ( SystemCoreClock )
+#define configTICK_RATE_HZ ((TickType_t)1000)
+#define configMAX_PRIORITIES ( 56 )
+#define configMINIMAL_STACK_SIZE ((uint16_t)128)
+#define configTOTAL_HEAP_SIZE ((size_t)3072)
+#define configMAX_TASK_NAME_LEN ( 16 )
+#define configUSE_16_BIT_TICKS 0
+#define configUSE_MUTEXES 1
+#define configUSE_TRACE_FACILITY 1
+#define configQUEUE_REGISTRY_SIZE 8
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
+
+/* Co-routine definitions. */
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
+
+/* Software timer definitions. */
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY ( 2 )
+#define configTIMER_QUEUE_LENGTH 10
+#define configTIMER_TASK_STACK_DEPTH 256
+
+/* The following flag must be enabled only when using newlib */
+#define configUSE_NEWLIB_REENTRANT 1
+
+/* Set the following definitions to 1 to include the API function, or zero
+to exclude the API function. */
+#define INCLUDE_vTaskPrioritySet 1
+#define INCLUDE_uxTaskPriorityGet 1
+#define INCLUDE_vTaskDelete 1
+#define INCLUDE_vTaskCleanUpResources 0
+#define INCLUDE_vTaskSuspend 1
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_xTaskGetSchedulerState 1
+#define INCLUDE_xTimerPendFunctionCall 1
+#define INCLUDE_xQueueGetMutexHolder 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 1
+#define INCLUDE_eTaskGetState 1
+
+/* Normal assert() semantics without relying on the provision of an assert.h
+header file. */
+/* USER CODE BEGIN 1 */
+#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );}
+/* USER CODE END 1 */
+
+/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
+standard names. */
+#define vPortSVCHandler SVC_Handler
+#define xPortPendSVHandler PendSV_Handler
+
+/* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick,
+ to prevent overwriting SysTick_Handler defined within STM32Cube HAL */
+
+/* #define xPortSysTickHandler SysTick_Handler */
+
+/* USER CODE BEGIN Defines */
+/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */
+/* USER CODE END Defines */
+
+#endif /* FREERTOS_CONFIG_H */
diff --git a/stm32f091/idle_task_static_memory.c b/stm32f091/idle_task_static_memory.c
new file mode 100644
index 0000000..0774224
--- /dev/null
+++ b/stm32f091/idle_task_static_memory.c
@@ -0,0 +1,18 @@
+#include "idle_task_static_memory.h"
+
+void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) {
+ static StaticTask_t xIdleTaskTCB;
+ static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
+ *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
+ *ppxIdleTaskStackBuffer = uxIdleTaskStack;
+ *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
+}
+
+void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ) {
+ static StaticTask_t xTimerTaskTCB;
+ static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
+ *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
+ *ppxTimerTaskStackBuffer = uxTimerTaskStack;
+ *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
+}
+
diff --git a/stm32f091/idle_task_static_memory.h b/stm32f091/idle_task_static_memory.h
new file mode 100644
index 0000000..24712fa
--- /dev/null
+++ b/stm32f091/idle_task_static_memory.h
@@ -0,0 +1,8 @@
+#pragma once
+
+#include <FreeRTOS.h>
+#include <FreeRTOSConfig.h>
+#include <task.h>
+
+void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize);
+void vApplicationGetTimerTaskMemory(StaticTask_t ** ppxTimerTaskTCBBuffer, StackType_t ** ppxTimerTaskStackBuffer, uint32_t * pulTimerTaskStackSize);
diff --git a/stm32f091/lib/FreeRTOS-Kernel b/stm32f091/lib/FreeRTOS-Kernel
new file mode 160000
+Subproject c09187e73b4d1258f11900a7da163fa3c33b5a3
diff --git a/stm32f091/main.cpp b/stm32f091/main.c
index 180240e..cc815c9 100644
--- a/stm32f091/main.cpp
+++ b/stm32f091/main.c
@@ -1,21 +1,32 @@
+#include <FreeRTOS.h>
+#include <task.h>
#include <stm32f0xx.h>
#include <stdint.h>
#define PORT GPIOA
#define PIN 5
-int main() {
- RCC->AHBENR |= RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN;
-
- PORT->MODER &= ~(0b11 << (PIN * 2));
- PORT->MODER |= (0b01 << (PIN * 2));
-
+void task_1(void *pv_parameters) {
uint8_t led = 1;
while (1) {
PORT->ODR &= ~(1 << PIN);
PORT->ODR |= (led << PIN);
led ^= 1;
- for (unsigned long i = 0; i < 50000; i++) asm("nop");
+
+ vTaskDelay(200 / portTICK_RATE_MS);
+ // for (unsigned int gert = 0; gert < 100000; gert++)
+ // asm("nop");
}
}
+
+int main() {
+ RCC->AHBENR |= RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN;
+
+ PORT->MODER &= ~(0b11 << (PIN * 2));
+ PORT->MODER |= (0b01 << (PIN * 2));
+
+ // task_1(0);
+ xTaskCreate(task_1, "task1", 128, NULL, 1, NULL);
+ vTaskStartScheduler();
+}
diff --git a/stm32f091/makefile b/stm32f091/makefile
index c187df7..a359853 100644
--- a/stm32f091/makefile
+++ b/stm32f091/makefile
@@ -1,5 +1,5 @@
-CC = arm-none-eabi-g++
-LD = arm-none-eabi-g++
+CC = arm-none-eabi-gcc
+LD = arm-none-eabi-gcc
OC = arm-none-eabi-objcopy
RM = rm -f
@@ -9,19 +9,23 @@ SHARED_FLAGS += -g
SHARED_FLAGS += -D STM32F091xC
SHARED_FLAGS += -Wall
SHARED_FLAGS += -Wextra
-SHARED_FLAGS += -Wno-register
+# SHARED_FLAGS += -Wno-register
SHARED_FLAGS += -Wa,--defsym,CALL_ARM_SYSTEM_INIT=1
+# SHARED_FLAGS += -I/usr/arm-none-eabi/include/
SHARED_FLAGS += -I./lib/STM32-base-STM32Cube/CMSIS/ARM/inc
SHARED_FLAGS += -I./lib/STM32-base-STM32Cube/CMSIS/STM32F0xx/inc
SHARED_FLAGS += -I./lib/STM32-base/startup
+SHARED_FLAGS += -I./lib/FreeRTOS-Kernel/include
+SHARED_FLAGS += -I./lib/FreeRTOS-Kernel/portable/GCC/ARM_CM0/
+SHARED_FLAGS += -I.
SHARED_FLAGS += -ffunction-sections
SHARED_FLAGS += -fdata-sections
SHARED_FLAGS += -mlittle-endian
SHARED_FLAGS += -mthumb
-SHARED_FLAGS += -masm-syntax-unified
+# SHARED_FLAGS += -masm-syntax-unified
SHARED_FLAGS += -specs=nosys.specs
-SHARED_FLAGS += -fno-threadsafe-statics
-SHARED_FLAGS += -fno-rtti
+# SHARED_FLAGS += -fno-threadsafe-statics
+# SHARED_FLAGS += -fno-rtti
SHARED_FLAGS += -fno-exceptions
SHARED_FLAGS += -fno-unwind-tables
SHARED_FLAGS += -Wl,-L./lib/STM32-base/linker,-T./lib/STM32-base/linker/STM32F0xx/STM32F091xC.ld
@@ -32,7 +36,17 @@ CFLAGS += $(SHARED_FLAGS)
LFLAGS += $(SHARED_FLAGS)
AFLAGS += $(SHARED_FLAGS)
-OBJS += $(patsubst %.cpp,%.o, $(wildcard *.cpp))
+OBJS += $(patsubst %.c,%.o, $(wildcard *.c))
+OBJS += lib/FreeRTOS-Kernel/croutine.o \
+ lib/FreeRTOS-Kernel/event_groups.o \
+ lib/FreeRTOS-Kernel/list.o \
+ lib/FreeRTOS-Kernel/queue.o \
+ lib/FreeRTOS-Kernel/stream_buffer.o \
+ lib/FreeRTOS-Kernel/tasks.o \
+ lib/FreeRTOS-Kernel/timers.o \
+ lib/FreeRTOS-Kernel/portable/GCC/ARM_CM0/port.o \
+ lib/FreeRTOS-Kernel/portable/MemMang/heap_4.o
+
OBJS += ./lib/STM32-base/startup/STM32F0xx/STM32F091xC.o
OBJS += ./lib/STM32-base-STM32Cube/CMSIS/STM32F0xx/src/system_stm32f0xx.o
@@ -47,7 +61,7 @@ $(TARGET).bin: $(TARGET).elf
%.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
-%.o: %.cpp
+%.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
$(TARGET).elf: $(OBJS)