📄 salvo.h
字号:
#else
typedef OStypeInt8u OStypeSRGIE;
#endif
#if OSTIMER_PRESCALAR > 65535
typedef OStypeInt32u OStypePS;
#elif OSTIMER_PRESCALAR > 255
typedef OStypeInt16u OStypePS;
#elif OSTIMER_PRESCALAR > 0
typedef OStypeInt8u OStypePS;
#else
typedef OStypeInt8u OStypePS;
#endif
/************************************************************
**** ****
** **
Additional function attributes as necessary.
** **
**** ****
************************************************************/
#include <salvomcg.h>
/************************************************************
**** ****
** **
Port-specific typedefs.
These mainly have to do with differences among 8-bit
compilers w/regard to bitfields and pointer types.
** **
**** ****
************************************************************/
#if OSUSE_CHAR_SIZED_BITFIELDS
typedef OStypeInt8u OStypeBitField; /* depends on whether */
#else /* compiler follows */
typedef OStypeInt16u OStypeBitField; /* ANSI strictly. Also */
/* related to some tar- */
/* gets' OSDispatch(). */
#endif
typedef struct { /* status consists of: */
OStypeBitField prio:4; /* 4 bits of priority */
OStypeBitField state:3; /* 3 bits of state */
OStypeBitField yielded:1; /* 1 yielded bit */
#if ( (OSCTXSW_METHOD == OSVIA_OSDISPATCH) \
|| (OSCTXSW_METHOD == OSVIA_OSDISPATCH_WLABEL) )
OStypeBitField frameSize:8; /* 8 bits of stack frame*/
/* size (only some */
/* distributions) */
#endif
} OStypeStatus;
typedef OStypeBitField OStypeStatusValue; /* this is used where */
/* a compiler can't */
/* properly handle bit- */
/* field operations. */
/* Highly non-portable, */
/* be careful! */
typedef OStypeInt8u OStypeLostTick; /* no point in tracking */
/* more than 8 bits of */
/* lost ticks */
typedef OSMESSAGE_TYPE OStypeMsg; /* usually void */
typedef void (OSTASK_POINTER_TYPE * OStypeTFP) (void);
/************************************************************
**** ****
** **
Port-specific context switcher support.
If the context-switcher used is OSCtxSw(), then there's no
need for labels.
If it's done in-line, then labels are required so that the
compiler can reference the "resume at" address.
** **
**** ****
************************************************************/
#if (OSCTXSW_METHOD == OSVIA_OSCTXSW)
#define _OSLabel(a)
void OSCtxSw( void );
#define OS_Yield(label) OSCtxSw()
#elif (OSCTXSW_METHOD == OSVIA_OSDISPATCH)
#define _OSLabel(a)
void OSDispatch( void );
void OSCtxSw( void );
#define OS_Yield(label) OSCtxSw()
#elif ( (OSCTXSW_METHOD == OSRTNADDR_IS_PARAM) \
|| (OSCTXSW_METHOD == OSRTNADDR_IS_VAR) )
#if !defined(_OSLabel)
#define _OSLabel(a) void a (void);
#endif
#elif (OSCTXSW_METHOD == OSVIA_OSDISPATCH_WLABEL)
void OSDispatch( void );
void OSCtxSw( OStypeTFP tFP );
#if !defined(_OSLabel)
#define _OSLabel(a) void a (void);
#endif
#else
#error salvo.h: OSCTXSW_METHOD not defined.
#endif
/************************************************************
**** ****
** **
Bank specifiers and memory type for some compilers. Used for
objects and pointers to objects.
If OSLOC_ALL is undefined(i.e. user hasn't defined it in
salvocfg.h), it defaults to OSLOC_DEFAULT, defined in
portXyz.h. Else it's set by user in salvocfg.h.
Every undefined OSLOC_XYZ is set to OSLOC_ALL.
This allows the user to specify OSLOC_ALL and then explicitly
set individual ones independently.
MPLAB-C18 doesn't support OSLOC_XYZ because of the need for
explicit sections declared via #pragma udata access SecName.
** **
**** ****
************************************************************/
#if OSCOMPILER == OSMPLAB_C18
#if OSMPLAB_C18_LOC_ALL_NEAR
#undef OSLOC_ALL
#define OSLOC_ALL near
#else
#undef OSLOC_ALL
#define OSLOC_ALL
#endif /* #if OSMPLAB_C18_LOC_ALL_NEAR */
#undef OSLOC_COUNT
#define OSLOC_COUNT OSLOC_ALL
#undef OSLOC_CTCB
#define OSLOC_CTCB OSLOC_ALL
#undef OSLOC_DEPTH
#define OSLOC_DEPTH OSLOC_ALL
#undef OSLOC_ECB
#define OSLOC_ECB OSLOC_ALL
#undef OSLOC_EFCB
#define OSLOC_EFCB OSLOC_ALL
#undef OSLOC_ERR
#define OSLOC_ERR OSLOC_ALL
#undef OSLOC_LOGMSG
#define OSLOC_LOGMSG OSLOC_ALL
#undef OSLOC_LOST_TICK
#define OSLOC_LOST_TICK OSLOC_ALL
#undef OSLOC_MQCB
#define OSLOC_MQCB OSLOC_ALL
#undef OSLOC_MSGQ
#define OSLOC_MSGQ OSLOC_ALL
#undef OSLOC_PS
#define OSLOC_PS OSLOC_ALL
#undef OSLOC_SIGQ
#define OSLOC_SIGQ OSLOC_ALL
#undef OSLOC_TCB
#define OSLOC_TCB OSLOC_ALL
#undef OSLOC_TICK
#define OSLOC_TICK OSLOC_ALL
#endif /* #if OSCOMPILER ... */
#if !defined(OSLOC_ALL)
#define OSLOC_ALL OSLOC_DEFAULT
#endif
#if !defined(OSLOC_COUNT)
#define OSLOC_COUNT OSLOC_ALL
#endif
#if !defined(OSLOC_CTCB)
#define OSLOC_CTCB OSLOC_ALL
#endif
#if !defined(OSLOC_DEPTH)
#define OSLOC_DEPTH OSLOC_ALL
#endif
#if !defined(OSLOC_ECB)
#define OSLOC_ECB OSLOC_ALL
#endif
#if !defined(OSLOC_EFCB)
#define OSLOC_EFCB OSLOC_ALL
#endif
#if !defined(OSLOC_ERR)
#define OSLOC_ERR OSLOC_ALL
#endif
#if !defined(OSLOC_LOGMSG)
#define OSLOC_LOGMSG OSLOC_ALL
#endif
#if !defined(OSLOC_LOST_TICK)
#define OSLOC_LOST_TICK OSLOC_ALL
#endif
#if !defined(OSLOC_MQCB)
#define OSLOC_MQCB OSLOC_ALL
#endif
#if !defined(OSLOC_MSGQ)
#define OSLOC_MSGQ OSLOC_ALL
#endif
#if !defined(OSLOC_PS)
#define OSLOC_PS OSLOC_ALL
#endif
#if !defined(OSLOC_SIGQ)
#define OSLOC_SIGQ OSLOC_ALL
#endif
#if !defined(OSLOC_TCB)
#define OSLOC_TCB OSLOC_ALL
#endif
#if !defined(OSLOC_TICK)
#define OSLOC_TICK OSLOC_ALL
#endif
/************************************************************
**** ****
** **
Unqualified and qualified typedefs.
So far all the supported compilers follow ANSI by accepting
memory type qualifiers after the reserved types and before
the pointer *.
** **
**** ****
************************************************************/
#define OStypeCharEcbP unsigned char OSLOC_ECB *
#define OStypeCharTcbP unsigned char OSLOC_TCB *
#define OStypeEcbP OStypeEcb OSLOC_ECB *
#define OStypeEfcbP OStypeEfcb OSLOC_EFCB *
#define OStypeMqcbP OStypeMqcb OSLOC_MQCB *
#define OStypeMsgP OStypeMsg *
#define OStypeMsgPP OStypeMsg * *
#define OStypeMsgQPP OStypeMsg * OSLOC_MSGQ *
#define OStypePrioAP OStypePrioA OSLOC_ECB *
#define OStypeTcbP OStypeTcb OSLOC_TCB *
#define OStypeTcbPP OStypeTcb OSLOC_TCB * OSLOC_ECB *
#define OSgltypeCount OStypeCount OSLOC_COUNT
#define OSgltypeDepth OStypeDepth OSLOC_DEPTH
#define OSgltypeEcb OStypeEcb OSLOC_ECB
#define OSgltypeEfcb OStypeEfcb OSLOC_EFCB
#define OSgltypeErr OStypeErr OSLOC_ERR
#define OSgltypeLostTick OStypeLostTick OSLOC_LOST_TICK
#define OSgltypeLogMsg char OSLOC_LOGMSG
#define OSgltypeMqcb OStypeMqcb OSLOC_MQCB
#define OSgltypePrioA OStypePrioA OSLOC_ECB
#define OSgltypePS OStypePS OSLOC_PS
#define OSgltypeTcb OStypeTcb OSLOC_TCB
#define OSgltypeTick OStypeTick OSLOC_TICK
#define OSgltypeCTcbP OStypeTcbP OSLOC_CTCB
#define OSgltypeEcbP OStypeEcbP OSLOC_ECB
#define OSgltypeMsgQP OStypeMsgP OSLOC_MSGQ
#define OSgltypeSigQP OStypeTcbP OSLOC_SIGQ
#define OSgltypeTcbP OStypeTcbP OSLOC_ECB
#define OSgltypeFrameP OStypeFrameP
#define OSgltypeSRGIE OStypeSRGIE
/************************************************************
**** ****
** **
OSEnter|LeaveCritical():
OSBegin|EndCriticalSection():
Macros for entering and exiting critical regions of code.
OSBegin|EndCriticalSection() are essentially placeholders
for OSEnter|LeaveCritical(), and are sometimes redefined
in the various modules to support special interrupt-related
issues.
Compilers that support the monitor keyword use the
OSMONITOR_KEYWORD_PRE symbol as an extended keyword on each
function that needs interrupts disabled, and therefore do
not need OSBegin|EndCriticalSection() macros inside the
function.
OSSuspend|ResumeCriticalSection() are special interrupt-
disabling and enabling macros, respectively, to be used
inside large functions where interrupts should not be
disabled for the duration. When OSMONITOR_KEYWORD_PRE is
defined, they are defined, but OSBegin|EndCriticalSection()
are not.
** **
**** ****
************************************************************/
#if !defined(OSEnterCritical)
#define OSEnterCritical() do { OSDi(); \
OSDiHook(); \
} while(0)
#endif
#if !defined(OSLeaveCritical)
#define OSLeaveCritical() do { OSEiHook(); \
OSEi(); \
} while (0)
#endif
#define OSSuspendCriticalSection() OSLeaveCritical()
#define OSResumeCriticalSection() OSEnterCritical()
#if OSMONITOR_KEYWORD_EXISTS
#define OSBeginCriticalSection()
#define OSEndCriticalSection()
#else
#define OSBeginCriticalSection() OSEnterCritical()
#define OSEndCriticalSection() OSLeaveCritical()
#endif
/************************************************************
**** ****
** **
Task Priorities:
16 separate task priorities are supported, from 0 =
highest priority to 15 = lowest. If the idle task is
enabled, we exclude its priority (lowest, 15) from
the range of available priorities.
By default, idle task has a tID of 1. However, since v2.2.0
and earlier had the OSIDLE_TASK_NUM default to OSTASKS, the
user can override this setting if necessary.
** **
**** ****
************************************************************/
#if !OSDISABLE_TASK_PRIORITIES
#if defined(OSONLY_PRIO)
#undef OSONLY_PRIO
#endif
#define OSHIGHEST_PRIO 0
#define OSLOWEST_PRIO 15
#else
#define OSONLY_PRIO 0
#define OSHIGHEST_PRIO 0
#define OSLOWEST_PRIO 0
#endif
#define OSCT_ONE_SHOT 0
#define OSCT_CONTINUOUS 1
/************************************************************
**** ****
** **
Task State Definitions:
OSTCB_DESTROYED uninitialized / dead. Uninitialized
only valid if compiler initializes all
global vars to 0.
OSTCB_TASK_STOPPED task is stopped.
OSTCB_TASK_DELAYED task is delayed.
OSTCB_TASK_WAITING task is waiting for event.
OSTCB_TASK_WAITING_TO task is waiting for an event, with a timeout if
in an event queue. Waited for an event
and timed out if in eligible queue.
OSTCB_TASK_ELIGIBLE task is enqueued in the eligibel queue or
running, normal.
OSTCB_T
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -