Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
maciekr1234 committed Dec 10, 2020
1 parent cfd522c commit 74c8961
Show file tree
Hide file tree
Showing 35 changed files with 270 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Desktop.ini
Thumbs.db
ehthumbs.db
.pio/*

.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/bookmarks.json

.bin/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "freertos"]
path = freertos
url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git
1 change: 1 addition & 0 deletions freertos
Submodule freertos added at 473383
2 changes: 2 additions & 0 deletions include/freertos/FreeRTOS.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/FreeRTOS.h"
2 changes: 2 additions & 0 deletions include/freertos/StackMacros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/StackMacros.h"
2 changes: 2 additions & 0 deletions include/freertos/atomic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/atomic.h"
2 changes: 2 additions & 0 deletions include/freertos/croutine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/croutine.h"
2 changes: 2 additions & 0 deletions include/freertos/deprecated_definitions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/deprecated_definitions.h"
2 changes: 2 additions & 0 deletions include/freertos/event_groups.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/event_groups.h"
2 changes: 2 additions & 0 deletions include/freertos/list.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/list.h"
2 changes: 2 additions & 0 deletions include/freertos/message_buffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/message_buffer.h"
2 changes: 2 additions & 0 deletions include/freertos/mpu_prototypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/mpu_prototypes.h"
2 changes: 2 additions & 0 deletions include/freertos/mpu_wrappers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/mpu_wrappers.h"
2 changes: 2 additions & 0 deletions include/freertos/portable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/portable.h"
47 changes: 47 additions & 0 deletions include/freertos/portmacro.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once

#include "stm32_def.h"

#ifdef __cplusplus
extern "C" {
#endif


#ifndef __CORTEX_M
#pragma GCC error "no \"__CORTEX_M\" definition"
#endif

#if (__CORTEX_M == 0x00U)
#include "../freertos/portable/GCC/ARM_CM0/portmacro.h"
#endif

#if (__CORTEX_M == 0x03U)
/* MPU not supported */
#if 0 /*(__MPU_PRESENT == 1)*/
#include "../freertos/portable/GCC/ARM_CM3_MPU/portmacro.h"
#else
#include "../freertos/portable/GCC/ARM_CM3/portmacro.h"
#endif
#endif

#if (__CORTEX_M == 0x04U)
/* MPU not supported */
#if 0 /*(__MPU_PRESENT == 1)*/
#include "../freertos/portable/GCC/ARM_CM4_MPU/portmacro.h"
#else
#include "../freertos/portable/GCC/ARM_CM4F/portmacro.h"
#endif
#endif

#if (__CORTEX_M == 0x07U)
/* MPU not supported */
#if 0 /*(__MPU_PRESENT == 1)*/
#include "../freertos/portable/GCC/ARM_CM7_MPU/r0p1/portmacro.h"
#else
#include "../freertos/portable/GCC/ARM_CM7/r0p1/portmacro.h"
#endif
#endif

#ifdef __cplusplus
} // extern "C"
#endif
2 changes: 2 additions & 0 deletions include/freertos/projdefs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/projdefs.h"
2 changes: 2 additions & 0 deletions include/freertos/queue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/queue.h"
2 changes: 2 additions & 0 deletions include/freertos/semphr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/semphr.h"
2 changes: 2 additions & 0 deletions include/freertos/stack_macros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/stack_macros.h"
2 changes: 2 additions & 0 deletions include/freertos/stream_buffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/stream_buffer.h"
2 changes: 2 additions & 0 deletions include/freertos/task.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/task.h"
2 changes: 2 additions & 0 deletions include/freertos/timers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "../freertos/include/timers.h"
11 changes: 9 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
{
"name": "freertos_kernel",
"version": "10.2.1",
"version": "10.4.2",
"keywords": "rtos, timing, thread, task, mutex, semaphore",
"description": "FreeRTOS kernel as pio library.",
"repository": {
"type": "git",
"url": "https://github.com/maciekr1234/freertos_kernel_lib.git"
},
"frameworks": "arduino",
"frameworks": "*",
"platforms": "ststm32",
"build": {
"extraScript": "pio_build.py",
"libArchive": false
},
"export": {
"exclude": [
".bin",
"tools"
]
}
}
8 changes: 8 additions & 0 deletions pio_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os
from os.path import sep, join, realpath, isdir, isfile

Import("env")

env.Append(CPPPATH=[
realpath(join("include", "freertos"))
])
1 change: 1 addition & 0 deletions src/croutine.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../freertos/croutine.c"
1 change: 1 addition & 0 deletions src/event_groups.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../freertos/event_groups.c"
23 changes: 23 additions & 0 deletions src/heap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

#include "FreeRTOS.h"


#ifndef configMEMMANG_HEAP_NB
#define configMEMMANG_HEAP_NB 5
#endif

#if (configMEMMANG_HEAP_NB == -1)
// #include "../freertos/portable/MemMang/heap_useNewlib.c"
#elif (configMEMMANG_HEAP_NB == 1)
#include "../freertos/portable/MemMang/heap_1.c"
#elif (configMEMMANG_HEAP_NB == 2)
#include "../freertos/portable/MemMang/heap_2.c"
#elif (configMEMMANG_HEAP_NB == 3)
#include "../freertos/portable/MemMang/heap_3.c"
#elif (configMEMMANG_HEAP_NB == 4)
#include "../freertos/portable/MemMang/heap_4.c"
#elif (configMEMMANG_HEAP_NB == 5)
#include "../freertos/portable/MemMang/heap_5.c"
#else
#error "Wrong Memory allocation implementations defined"
#endif
1 change: 1 addition & 0 deletions src/list.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../freertos/list.c"
46 changes: 46 additions & 0 deletions src/port.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

#include "stm32_def.h"

#ifdef __cplusplus
extern "C" {
#endif


#ifndef __CORTEX_M
#pragma GCC error "no \"__CORTEX_M\" definition"
#endif

#if (__CORTEX_M == 0x00U)
#include "../freertos/portable/GCC/ARM_CM0/port.c"
#endif

#if (__CORTEX_M == 0x03U)
/* MPU not supported */
#if 0 /*(__MPU_PRESENT == 1)*/
#include "../freertos/portable/GCC/ARM_CM3_MPU/port.c"
#else
#include "../freertos/portable/GCC/ARM_CM3/port.c"
#endif
#endif

#if (__CORTEX_M == 0x04U)
/* MPU not supported */
#if 0 /*(__MPU_PRESENT == 1)*/
#include "../freertos/portable/GCC/ARM_CM4_MPU/port.c"
#else
#include "../freertos/portable/GCC/ARM_CM4F/port.c"
#endif
#endif

#if (__CORTEX_M == 0x07U)
/* MPU not supported */
#if 0 /*(__MPU_PRESENT == 1)*/
#include "../freertos/portable/GCC/ARM_CM7_MPU/r0p1/port.c"
#else
#include "../freertos/portable/GCC/ARM_CM7/r0p1/port.c"
#endif
#endif

#ifdef __cplusplus
} // extern "C"
#endif
1 change: 1 addition & 0 deletions src/queue.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../freertos/queue.c"
1 change: 1 addition & 0 deletions src/stream_buffer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../freertos/stream_buffer.c"
1 change: 1 addition & 0 deletions src/tasks.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../freertos/tasks.c"
1 change: 1 addition & 0 deletions src/timers.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../freertos/timers.c"
75 changes: 75 additions & 0 deletions tools/prepare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

import os,sys

from os.path import sep, join, realpath, isdir, isfile, dirname
from string import Template


root_dir = realpath(join(dirname(realpath(__file__)), ".."))
include_dir = join(root_dir, "include")

freertos_root_dir = join(root_dir, "freertos")
freertos_portable_dir = join(freertos_root_dir, "portable")


freertos_header_tpl = Template('#pragma once\n#include "../freertos/include/$name"\n')
freertos_src_tpl = Template('#include "../freertos/$name"\n')


freertos_include_names = [
"FreeRTOS.h",
"StackMacros.h",
"atomic.h",
"croutine.h",
"deprecated_definitions.h",
"event_groups.h",
"list.h",
"message_buffer.h",
"mpu_prototypes.h",
"mpu_wrappers.h",
"portable.h",
"projdefs.h",
"queue.h",
"semphr.h",
"stack_macros.h",
"stream_buffer.h",
"task.h",
"timers.h",
]

freertos_src_names = [
"croutine.c",
"event_groups.c",
"list.c",
"queue.c",
"stream_buffer.c",
"tasks.c",
"timers.c",
]

def generate_freertos_header(name):
file_path = join(include_dir, name)
if os.path.exists(file_path):
os.remove(file_path)

with open(file_path,"w") as header_file:
header_file.write(freertos_header_tpl.substitute(name=name))

def generate_freertos_src(name):
file_path = join(root_dir, "src", name)
if os.path.exists(file_path):
os.remove(file_path)

with open(file_path,"w") as f:
f.write(freertos_src_tpl.substitute(name=name))


def main():
for header in freertos_include_names:
generate_freertos_header(header)

for f in freertos_src_names:
generate_freertos_src(f)

if __name__ == "__main__":
sys.exit(main())

0 comments on commit 74c8961

Please sign in to comment.