📄 os_cnf.h
字号:
/*********************************************************/
/* SCHWED-OS operating system */
/* */
/* (C) by J鰎g Schwedes 2009, All rights reserved */
/*********************************************************/
#ifndef OS_CNF_H
#define OS_CNF_H
#include <io.h>
/*
ReadMeReadMe+++ !!! Important Notes !!! +++ReadMeReadMe
Nomenclature for this OS description:
TASK: A task is here a "void function(void)" which MUST return to the OS.
So this OS is more a function scheduler.
example: void function(void) { do something; return;}
This is also true for the preemptive static or dynamic tasks.
STATIC TASK: All tasks which are defined at compile time.
(Their adresses are fixed linked in ROM tables)
CYCLE TASK: This is a function which is scheduled all 5 or 10ms.
DYNAMIC TASK: Where the static and cyclic tasks are all configured at compile
time with their adresses linked to ROM tables,
the dynamic tasks are activated at runtime by calling by reference.
example: void function(void) { do something; return;}
OS_ActDynPreempTask(function);
HIGH PRIO PREEMPTIVE TASK: These tasks are started within 1ms and interrupt all
cyclic tasks.
OTHER NOTES: Please, every application interrupt service routine has to start
with OS_BeginInt()
and end with OS_EndInt(). This ensures correct interrupt nested counter
handling if configured.
*/
/* *************************************************************************************
* OS feature configuration *
* description *
***************************************************************************************
OS_USE_5MS_TASKS:
for 5ms Cycle Task list (ROM jump table) support
OS_USE_5MS_TASKS:
for 10ms Cycle Task list (ROM jump table) support
OS_USE_IDLE_TASK:
Hook Task executed while OS is idle. Only
small code < 150us recommended
OS_USE_IDLE_TASK_FORCE_TO_REALTIME:
each Idle Task Hook time will be measured.
If idle time < remaining free time of OS,
one more call to Idle Task will be done.
OS_USE_HIGH_PRIO_PREEMPTIVE_TASKS:
A High Prio Task can be executed by call of OS_ActPreempTask(u8 task_nr),
where task_nr is the position of the Task in the task list (0..7 ROM table).
Those Tasks will be executed within 1ms and interrupt all other (Cyclic) Tasks.
After execution the Task is terminated and must be activated again.
But a High Prio task can activate itself or other High Prio Tasks.
OS_USE_HIGH_PRIO_DYNAMIC_PREEMPTIVE_TASK:
A High Prio dynamic Task can be executed by
call of OS_ActDynPreempTask(function_name), where function_name
is the name of the void function to be executed. Those Tasks will be executed
within 1ms and interrupt all other (Cyclic) Tasks. After execution,
the Task is terminated and must be activated again. But a High Prio task can
activate itself or other High Prio Tasks. A number of OS_DYN_TASK_BUF_SIZE
must be reserved (RAM buffer). If more then one task should be executed within 1ms,
OS_DYN_TASK_BUF_SIZE must be greater then one.
NOTEs for Preemptive: If preemptive tasks are enabled the PreemtiveHandler will
always enable interrupts. Handler and timebase-int share one interrupt.
If the handler is called, this enables interrupts and ensure that timebase
interrupt is not blocked if preemptive tasks are longer then 1ms.
If one ore more preemptive tasks are pending and they are in sum
longer then 1ms, the timebaseinterrupt doesn't start the handler again as
long they are finihed.
OS_USE_INTERRUPT_NESTED_CTR:
Please enable this feature at all !!
This ensures correct enabling of interrupts e.g in case of nested atomic sequences.
Only use of OS services OS_SuspendInt and OS_ResumeInt is allowed !!
Also each interrupt must begin with OS_BeginInt and has to end with OS_EndInt
service !!
OS_USE_CPU_LOAD_MES:
Enables CPU-Load measurement.
Label os_cpu_load/os_cpu_load_max = 0...10000 dec | 0...100%
if os_cpu_load is greater then 100% (10000dec), the realtime is not given anymore.
Note: below 100% os_cpu_load the Idle task can violate realtime depending of its
runtime !!!!!!
OS_USE_ERROR_TASK:
This enable Error handling if e.g realtime is highly violated or interrupt nested
counter is not plausible.
An action can be done in OS_ErrorTask, e.g reset of the system.
****************** current configuration ***********************************************/
// #define OS_USE_5MS_TASKS
// #define OS_USE_10MS_TASKS
#define OS_USE_IDLE_TASK
// #define OS_USE_IDLE_TASK_FORCE_TO_REALTIME
// #define OS_USE_HIGH_PRIO_PREEMPTIVE_TASKS
#define OS_USE_HIGH_PRIO_DYNAMIC_PREEMPTIVE_TASK
#define OS_USE_INTERRUPT_NESTED_CTR
// #define OS_USE_CPU_LOAD_MES
// #define OS_USE_ERROR_TASK
#ifdef OS_USE_HIGH_PRIO_DYNAMIC_PREEMPTIVE_TASK
#define OS_DYN_TASK_BUF_SIZE 0x01
/* buffer size for dynamic tasks.
OS_DYN_TASK_BUF_SIZE number of tasks
can be executed within 1ms */
#endif
/* ************************************************************************************/
/* OS system configuration */
#if defined(__ATtiny25__) || defined(__ATtiny45__) || defined(__ATtiny85__)
#define OS_F_CPU 4000000
#else
#define OS_F_CPU 8000000
#endif
// #define OS_F_TIMER 1000000 /* reserved but currently not used */
/**************************************************************************************/
/* interfaces to uC functions
and compiler intrinsics: Here IAR compiler */
#define OS_EnaInt() __enable_interrupt() /* enables global interrupt flag */
#define OS_DisInt() __disable_interrupt() /* disables global interrupt flag */
#define OS_SaveInt() __save_interrupt() /* reserved but currently not used */
#define OS_RestInt(state) __restore_interrupt(state) /* reserved but currently not used */
#define OS_SystemReset() __watchdog_reset() /* software reset possibility */
#define __OS_ROM __flash
/* constants and tables are placed and accessed in flash memory.
Important,
because otherwise they are placed as a work copy in valuably RAM.
Used by all OS jump tables e.g for cyclic and static tasks configuration.
This maybe is a feature only for IAR compiler */
#define __OS_NO_INIT __no_init
/* RAM area which has no init. Used by reset save
OS labels like OS_error/OS_error_cpl.
This maybe a feature only for IAR compiler */
#define __OS_INLINE inline
/* IAR compiler supports inline functions (C99 standard)
This can be used by OS static functions like OS_InitTask and will
reduce code and stack overhead. */
#define OS_JUMP_TO_OS_StartSchwedOS() __indirect_jump_to((u32)&OS_StartSchwedOS)
/* a JUMP to OS_StartSchwedOS is preferred,
because a CALL will push return adress
on RSTACK, but function never returns.
This is preferred if compiler does not
know that OS_StartSchwedOS() will not
return. Another possibilitiy is to define
__OS_NO_RETURN, see BELOW */
#define __OS_NO_RETURN __noreturn
/* informs the compiler (maybe only a feature of IAR) that the
function will not return. This is a directive used
at definition of OS_StartSchwedOS */
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -