📄 rtos.h
字号:
#ifndef RTOS_H_INCLUDED
#define RTOS_H_INCLUDED
/*
************************************************************************
* *
* RTOS.H : include file for RTOS *
* *
* to be included in every C-module accessing RTOS-routines *
* *
* Part of embOS real-time operating system *
* *
* (c) Copyright SEGGER Microcontrollersysteme GmbH www.segger.com *
* *
* *
************************************************************************
*** Chip specifics ARM7TDMI / ARM9TDMI with ARM ADS 1.2 compiler ***
*/
#include <string.h> /* req. for memset.h */
#ifdef __TARGET_ARCH_4T
#define OS_CPU "ARM4T/RVDK"
#else
#define OS_CPU "ARM-core-5/RVDK"
#endif
#ifndef __thumb
__inline void __enable_irq(void) {
int tmp;
__asm {
MRS tmp,CPSR
BIC tmp,tmp,#0x80
MSR CPSR_c,tmp
}
}
__inline void __disable_irq(void) {
int tmp;
__asm {
MRS tmp,CPSR
ORR tmp,tmp,#0x80
MSR CPSR_c,tmp
}
}
#endif
#define OS_DI() __disable_irq();
#define OS_EI() __enable_irq();
#define OS_GetTime() (OS_Time)
#define OS_SP_ADJUST (0)
/* Int stack is automatically used by ARM */
#define OS_EnterIntStack()
#define OS_LeaveIntStack()
/* Enable nesting only, if OS_DICn==0 */
#define OS_EnterNestableInterrupt() { \
OS_MARK_IN_ISR(); \
OS_RegionCnt++; \
if (OS_DICnt==0) OS_EI(); \
}
#define OS_I32 int
#define OS_SIZEOF_INT 4
#define OS_BIG_ENDIAN 0
/* Option to supply more info to viewer */
#define OS_SUPPORT_SYSSTACK_INFO (1)
#define OS_SUPPORT_INTSTACK_INFO (1)
/* Define whether OS_Alloc is supported */
#define OS_SUPPORT_OS_ALLOC (1)
/* Option to get Stack pointer information */
#define OS_INIT_STACK_INFO() OS_GetStackInfo();
#ifdef __cplusplus
extern "C" {
#endif
typedef void OS_ISR_HANDLER(void);
void OS_irq_handler (void);
void OS_IRQ_SERVICE (void); /* embOS int handler in RTOSVect.s */
void IRQ_Handler (void);
OS_ISR_HANDLER* OS_ARM_InstallISRHandler (int ISRIndex, OS_ISR_HANDLER* pFunc);
void OS_ARM_EnableISR (int ISRIndex);
void OS_ARM_DisableISR (int ISRIndex);
int OS_ARM_ISRSetPrio (int ISRIndex, int Prio);
void OS_GetStackInfo (void);
void OS_InitPLL (void);
#ifdef __thumb
void __enable_irq(void);
void __disable_irq(void);
#endif
#ifdef __cplusplus
}
#endif
/*
**************************************
* *
* Check configuration *
* *
**************************************
This is required in order to automatically create the correct identifiers
in order to be able to autoamitcally remap the identifiers.
*/
#ifdef __thumb
#define OS_CPUMODE_PREFIX "T"
#else
#define OS_CPUMODE_PREFIX "A"
#endif
#ifdef __TARGET_ARCH_4T
#define OS_CPU_PREFIX "4"
#else
#define OS_CPU_PREFIX "5"
#endif
#ifdef __BIG_ENDIAN
#define OS_ENDIAN_PREFIX "B"
#else
#define OS_ENDIAN_PREFIX "L"
#endif
#define OS_MODEL OS_CPUMODE_PREFIX OS_CPU_PREFIX OS_ENDIAN_PREFIX
/*************** End of OSChip.h ***********************/
/********************************************************************
*
* Generic portion of embOS starts here
*
*********************************************************************
This file (original name OS_RAW.h) is part of RTOS.h, the include
file for embOS.
*/
#define __EMBOS__ 1 /* Enable application to find out */
#define EMBOS 1 /* that embOS is compiled and linked */
#define OS_VERSION_GENERIC (32600) /* Generic version 3.26 */
#ifndef OS_PORT_REVISION
#define OS_PORT_REVISION 0
#endif
#define OS_VERSION OS_VERSION_GENERIC + (OS_PORT_REVISION * 25)
/*********************************************************************
*
* Defines for library types
*
**********************************************************************
*/
/* If library type is not selected yet (on project level,
for example), then select DP by default
*/
#if (!defined(OS_LIBMODE_R) && !defined(OS_LIBMODE_RP) && \
!defined(OS_LIBMODE_S) && !defined(OS_LIBMODE_SP) && \
!defined(OS_LIBMODE_D) && !defined(OS_LIBMODE_DP) && \
!defined(OS_LIBMODE_ST) && !defined(OS_LIBMODE_DT) && \
!defined(OS_LIBMODE_T))
#define OS_LIBMODE_DP
#endif
#if defined(OS_LIBMODE_R)
#define OS_CHECKSTACK 0
#define OS_SUPPORT_DIAG 0
#define OS_DEBUG 0
#define OS_PROFILE 0
#define OS_SUPPORT_TICKSTEP 0
#define OS_TRACE 0
#define OS_CreateTask OS_CreateTask_R
#define OS_LIBMODE "R"
#elif defined(OS_LIBMODE_RP) /* Not normally generated */
#define OS_CHECKSTACK 0
#define OS_SUPPORT_DIAG 0
#define OS_DEBUG 0
#define OS_PROFILE 1
#define OS_SUPPORT_TICKSTEP 1
#define OS_TRACE 0
#define OS_CreateTask OS_CreateTask_RP
#define OS_LIBMODE "RP"
#elif defined(OS_LIBMODE_S)
#define OS_CHECKSTACK 1
#define OS_SUPPORT_DIAG 1
#define OS_DEBUG 0
#define OS_PROFILE 0
#define OS_SUPPORT_TICKSTEP 0
#define OS_TRACE 0
#define OS_CreateTask OS_CreateTask_S
#define OS_LIBMODE "S"
#elif defined(OS_LIBMODE_SP)
#define OS_CHECKSTACK 1
#define OS_SUPPORT_DIAG 1
#define OS_DEBUG 0
#define OS_PROFILE 1
#define OS_SUPPORT_TICKSTEP 1
#define OS_TRACE 0
#define OS_CreateTask OS_CreateTask_SP
#define OS_LIBMODE "SP"
#elif defined(OS_LIBMODE_D)
#define OS_CHECKSTACK 1
#define OS_SUPPORT_DIAG 1
#define OS_DEBUG 1
#define OS_PROFILE 0
#define OS_SUPPORT_TICKSTEP 1
#define OS_TRACE 0
#define OS_CreateTask OS_CreateTask_D
#define OS_LIBMODE "D"
#elif defined(OS_LIBMODE_DP)
#define OS_CHECKSTACK 1
#define OS_SUPPORT_DIAG 1
#define OS_PROFILE 1
#define OS_DEBUG 1
#define OS_SUPPORT_TICKSTEP 1
#define OS_TRACE 0
#define OS_CreateTask OS_CreateTask_DP
#define OS_LIBMODE "DP"
#elif defined(OS_LIBMODE_ST)
#define OS_CHECKSTACK 1
#define OS_SUPPORT_DIAG 1
#define OS_DEBUG 0
#define OS_PROFILE 1
#define OS_SUPPORT_TICKSTEP 1
#define OS_TRACE 1
#define OS_CreateTask OS_CreateTask_ST
#define OS_LIBMODE "ST"
#elif defined(OS_LIBMODE_DT)
#define OS_CHECKSTACK 1
#define OS_SUPPORT_DIAG 1
#define OS_DEBUG 1
#define OS_PROFILE 1
#define OS_SUPPORT_TICKSTEP 1
#define OS_TRACE 1
#define OS_CreateTask OS_CreateTask_DT
#define OS_LIBMODE "DT"
#elif defined(OS_LIBMODE_T)
#error This libmode has been renamed. T -> DT
#else
#error Please define library type used !
#endif
/*********************************************************************
*
* embOS compile time switches
*
**********************************************************************
These compile time switches can be modified when recompiling
the library. Usually, the values are in OSCHIP.H, which is then
merged with OS_RAW.H to form RTOS.H.
If the values are not defined in OSCHIP.H, the default values
below are used.
*/
/* Make it possible to place const data in RAM via
define and therefore via command line. This is required
for some smaller CPUs in small memory models
It is defined to be "const" by default, but can be defined to nothing
by simply adding a -DOS_CONST_DATA on the commandline
*/
#ifndef OS_CONST_DATA
#define OS_CONST_DATA const /* Default */
#else
#undef OS_CONST_DATA
#define OS_CONST_DATA /* define blank */
#endif
#ifndef OS_STACK_ADR
#define OS_STACK_ADR OS_U32
#endif
#ifndef OS_MODEL
#define OS_MODEL ""
#endif
#ifndef OS_MEMSET
#define OS_MEMSET(a,v,s) memset(a,v,s)
#endif
#ifndef OS_MEMCPY
#define OS_MEMCPY(dest,src,cnt) memcpy(dest,src,cnt)
#endif
#ifndef OS_STRLEN
#define OS_STRLEN(s) strlen(s)
#endif
#ifndef OS_DUMMY_STATEMENT
#define OS_DUMMY_STATEMENT()
#endif
#ifndef OS_USEPARA
#define OS_USEPARA(para) para=para
#endif
#ifndef OS_SUPPORT_TICKSTEP
#define OS_SUPPORT_TICKSTEP 0
#endif
#ifndef OS_SUPPORT_TIMEOUT
#define OS_SUPPORT_TIMEOUT 1
#endif
#ifndef OS_SUPPORT_CLEANUP_ON_TERMINATE /* Allows terminating a task which occupies resources */
#define OS_SUPPORT_CLEANUP_ON_TERMINATE 1
#endif
#ifndef OS_TRACKNAME
#define OS_TRACKNAME (1)
#endif
#ifndef OS_TRACE
#define OS_TRACE (0)
#endif
#ifndef OS_RR_SUPPORTED
#define OS_RR_SUPPORTED (1)
#endif
#ifndef __OS_STACK_AT_BOTTOM__
#define __OS_STACK_AT_BOTTOM__ (0)
#endif
/* Settings for NON-ANSI compiler syntax
The default behaviour complies with IAR.
*/
#ifndef OS_COMPILER_LOCATION_LEFT
#define OS_COMPILER_LOCATION_LEFT 1 /* (req. for IAR) */
#endif
#ifndef OS_COMPILER_STORAGE_MODIFIER_LEFT
#define OS_COMPILER_STORAGE_MODIFIER_LEFT 1 /* default for all except KEIL */
#endif
#define OS_LINK_RESOURCE_SEMAS (OS_SUPPORT_DIAG || OS_SUPPORT_CLEANUP_ON_TERMINATE)
#define OS_SUPPORT_DIAG_START_DELAY 0
/*********************************************************************
*
* Check Compile time switches
*
**********************************************************************
*/
#ifndef OS_SIZEOF_INT
#error "Please define OS_SIZEOF_INT (OSChip.h)"
#endif
#ifndef OS_BIG_ENDIAN
#error "Please define OS_BIG_ENDIAN (OSChip.h)"
#endif
/*********************************************************************
*
* Basic type defines
*
**********************************************************************
*/
#ifndef OS_I8
#define OS_I8 signed char
#endif
#ifndef OS_U8
#define OS_U8 unsigned char
#endif
#ifndef OS_I16
#define OS_I16 signed short
#endif
#ifndef OS_U16
#define OS_U16 unsigned short
#endif
#ifndef OS_I32
#define OS_I32 long
#endif
#ifndef OS_U32
#define OS_U32 unsigned OS_I32
#endif
/* Defines a true integer. This type is guaranteed
a) to have at least 8 bits,
b) to compile and execute best on the target CPU
It will normally be the same as an int, but on most
8-bit CPUs it will be replaced by a character because
the CPU can deal with 8 bits more efficient than with
16 bit integers.
Use with care !
*/
#ifndef OS_INT
#define OS_INT int
#endif
#ifndef OS_UINT
#define OS_UINT unsigned OS_INT
#endif
/*********************************************************************
*
* Error codes
*
**********************************************************************
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -