-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathmiros.h
71 lines (60 loc) · 2.34 KB
/
miros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/****************************************************************************
* MInimal Real-time Operating System (MiROS)
* version 1.26 (matching lesson 26, see https://youtu.be/kLxxXNCrY60)
*
* This software is a teaching aid to illustrate the concepts underlying
* a Real-Time Operating System (RTOS). The main goal of the software is
* simplicity and clear presentation of the concepts, but without dealing
* with various corner cases, portability, or error handling. For these
* reasons, the software is generally NOT intended or recommended for use
* in commercial applications.
*
* Copyright (C) 2018 Miro Samek. All Rights Reserved.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Git repo:
* https://github.com/QuantumLeaps/MiROS
****************************************************************************/
#ifndef MIROS_H
#define MIROS_H
/* Thread Control Block (TCB) */
typedef struct {
void *sp; /* stack pointer */
uint32_t timeout; /* timeout delay down-counter */
uint8_t prio; /* thread priority */
/* ... other attributes associated with a thread */
} OSThread;
typedef void (*OSThreadHandler)();
void OS_init(void *stkSto, uint32_t stkSize);
/* callback to handle the idle condition */
void OS_onIdle(void);
/* this function must be called with interrupts DISABLED */
void OS_sched(void);
/* transfer control to the RTOS to run the threads */
void OS_run(void);
/* blocking delay */
void OS_delay(uint32_t ticks);
/* process all timeouts */
void OS_tick(void);
/* callback to configure and start interrupts */
void OS_onStartup(void);
void OSThread_start(
OSThread *me,
uint8_t prio, /* thread priority */
OSThreadHandler threadHandler,
void *stkSto, uint32_t stkSize);
#endif /* MIROS_H */