Skip to content

Commit b957731

Browse files
committed
Added the start documentation (for me haha) and updated the .gitignore
1 parent 6acf3a2 commit b957731

16 files changed

Lines changed: 151 additions & 124 deletions

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
*.hex
22
*.bin
3-
*.elf
3+
*.elf
4+
examples/stm32f4x/compile_commands.json
5+
.cache
6+
compile_commands.json

.vscode/c_cpp_properties.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

doc/glossary.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

doc/sch.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Structure of source files
2+
3+
`inc/sch.h` - main the list of contents (system's headers)
4+
`inc/sch_common.h` - a header what inites the keywords within the system. Some technical things
5+
`inc/sch_config.h` - the config what'll configure the system. Defines the quantity of tasks and the mode of arbitration
6+
`inc/sch_context_change.h` - the header what creates the header of functions what will be implemented by the Assenbly or C code within the `port/`-files. These functions intended to switch the context
7+
`inc/sch_event_management.h` - the basic functional for event-driven interaction - the ability to transmit the data between the tasks
8+
`inc/sch_task_management.h` - the header what creates the header of functions what will be implemented by the Assenbly or C code within the `port/`-files. These functions intended to help to do the task management
9+
10+
`port/{platform}/sch_assertion.c` - implements the functions from the `sch_common.h`-file
11+
`port/{platform}/sch_context_change.c` - implements the functions from the `sch_context_change.h`-file
12+
`port/{platform}/sch_context_change.s` - implements the functions from the `sch_context_change.h`-file in Assembly
13+
`port/{platform}/sch_event_management.c` - implements the functions from the `sch_event_management.h`-file in Assembly
14+
`port/{platform}/sch_find_most_significant_task.s` - inplements the function of finding the most significant task by Assembly
15+
16+
# Simple example of creating the task:
17+
```
18+
19+
void sch_task_dispatch(sch_task_t* task);
20+
void sch_task_init(sch_task_t* task);
21+
22+
void main() {
23+
sch_task_t first_task;
24+
sch_task_create(&first_task, -3, 0, sch_task_dispatch, sch_task_init);
25+
sch_task_activate(&first_task);
26+
27+
}
28+
29+
void sch_task_dispatch(sch_task_t* task) {
30+
//something to do
31+
}
32+
33+
void sch_task_init(sch_task_t* task) {
34+
//something to do
35+
}
36+
37+
```
38+
39+
The `sch_task_create` attaches the task's parts to the main object to make it easy to call. For example, the typical dispatch function: `sch_task_dispatch` as the main task's function - that func describes what task will actually do. You can see the arguments of the function in the `sch/src/sch.c` file.
40+
Also the `sch_task_init` function will use by the user as the start of the task. But keep in mind that the init function will call at the moment of creating the task itself.

doc/sch_review.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

examples/stm32f4x/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ CFLAGS += -Iplatform/cmsis/CMSIS/Include
2121
CFLAGS += -Iplatform/cmsis/CMSIS/Device/ST/STM32F4xx/Include
2222
CFLAGS += -I../../sch/inc
2323
CFLAGS += -I../../sch/src
24+
CFLAGS += -I../../sch/port/stm32f4xx
2425
CFLAGS += $(DEFS)
2526

2627
ASFLAGS = $(MCU) $(OPT)
@@ -50,6 +51,7 @@ app/src/sysmem.c \
5051
../../sch/src/sch.c \
5152
../../sch/port/stm32f4xx/sch_find_most_significant_task.s \
5253
../../sch/port/stm32f4xx/sch_context_change.s \
54+
../../sch/port/stm32f4xx/sch_event_management.c \
5355

5456
all: $(TARGET).elf
5557

sch/inc/sch.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ extern "C" {
1818
#include <stdint.h>
1919

2020
#include "sch_config.h"
21-
#include "sch_assertion.h"
2221
#include "sch_context_change.h"
2322
#include "sch_common.h"
2423
#include "sch_task_management.h"

sch/inc/sch_assertion.h

Lines changed: 0 additions & 75 deletions
This file was deleted.

sch/inc/sch_common.h

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
#ifndef SCH_COMMON_H
1010
#define SCH_COMMON_H
1111

12+
#include <cstdint>
1213
#ifdef __cplusplus
1314
extern "C" {
1415
#endif
1516

1617
/*--Weak macro definition----------------------------------------------------*/
1718

1819
/**
19-
* @brief
20+
* @brief The definition of portable
21+
* common __WEAK construction
2022
*
2123
*/
2224
#if defined(__GNUC__)
@@ -29,8 +31,60 @@ extern "C" {
2931
#define __WEAK
3032
#endif
3133

34+
/*--Checking compilation conditions------------------------------------------*/
35+
36+
/**
37+
* @brief Check macro definitions
38+
*
39+
* @details Checking the definition of a macro,
40+
* with the value of which the functions of the
41+
* "function module" sch_assertion will later
42+
* be called
43+
*
44+
*/
45+
#ifdef SCH_ASSERTION_NORETURN
46+
#define SCH_NORETURN_FUNC_ATTRIBUTE __attribute__((noreturn))
47+
#else
48+
#define SCH_NORETURN_FUNC_ATTRIBUTE
49+
#endif
50+
51+
/**
52+
* @brief Check macro definitions
53+
*
54+
* @details Checking the definition of the macro
55+
* responsible for calling the sch_fault_handler
56+
* error handler
57+
*
58+
* @note The configuration of the sch_fault_handler
59+
* function is determined, among other things, by
60+
* the SCH_ASSERTION_NORETURN macro
61+
*
62+
*/
63+
#ifdef SCH_ASSERTION
64+
#define SCH_ASSERT(expr) ((expr) ? ((void)0) : sch_fault_handler())
65+
#else
66+
#define SCH_ASSERT(expr) ((expr) ? ((void)0) : sch_fault_handler())
67+
#endif
68+
69+
/*--Definition of functions--------------------------------------------------*/
70+
71+
/**
72+
* @brief Error handling function
73+
*
74+
* @note The function has an additional attribute
75+
* for returning to the context from which the
76+
* function was called. The value of this attribute
77+
* depends on the definition (or non-definition) of
78+
* the SCH_ASSERTION_NORETURN macro
79+
*
80+
* @return void
81+
*/
82+
__WEAK SCH_NORETURN_FUNC_ATTRIBUTE void sch_fault_handler(void);
83+
84+
/*---------------------------------------------------------------------------*/
85+
3286
#ifdef __cplusplus
3387
}
3488
#endif
3589

36-
#endif
90+
#endif

0 commit comments

Comments
 (0)