📄 port.h
字号:
extern uint8_t isrStackMem_g[];
/**
* This function is implement in arch_c.c
*/
void interruptReturn(void) __attribute__ ((naked));
/**
* Macro for saving the context during an interrupt service.
*/
#define SAVE_CONTEXT(void) \
__asm__ __volatile__ ( \
"push r0" "\n\t" \
"in r0, __SREG__" "\n\t" \
"cli" "\n\t" \
"push r0" "\n\t" \
"push r1" "\n\t" \
"clr __zero_reg__" "\n\t" \
"push r2" "\n\t" \
"push r3" "\n\t" \
"push r4" "\n\t" \
"push r5" "\n\t" \
"push r6" "\n\t" \
"push r7" "\n\t" \
"push r8" "\n\t" \
"push r9" "\n\t" \
"push r10" "\n\t" \
"push r11" "\n\t" \
"push r12" "\n\t" \
"push r13" "\n\t" \
"push r14" "\n\t" \
"push r15" "\n\t" \
"push r16" "\n\t" \
"push r17" "\n\t" \
"push r18" "\n\t" \
"push r19" "\n\t" \
"push r20" "\n\t" \
"push r21" "\n\t" \
"push r22" "\n\t" \
"push r23" "\n\t" \
"push r24" "\n\t" \
"push r25" "\n\t" \
"push r26" "\n\t" \
"push r27" "\n\t" \
"push r28" "\n\t" \
"push r29" "\n\t" \
"push r30" "\n\t" \
"push r31" "\n\t" \
:: \
)
/**
* Macro for restoring the context during an interrupt service.
*/
#define RESTORE_CONTEXT(void) \
__asm__ __volatile__ ( \
"pop r31" "\n\t" \
"pop r30" "\n\t" \
"pop r29" "\n\t" \
"pop r28" "\n\t" \
"pop r27" "\n\t" \
"pop r26" "\n\t" \
"pop r25" "\n\t" \
"pop r24" "\n\t" \
"pop r23" "\n\t" \
"pop r22" "\n\t" \
"pop r21" "\n\t" \
"pop r20" "\n\t" \
"pop r19" "\n\t" \
"pop r18" "\n\t" \
"pop r17" "\n\t" \
"pop r16" "\n\t" \
"pop r15" "\n\t" \
"pop r14" "\n\t" \
"pop r13" "\n\t" \
"pop r12" "\n\t" \
"pop r11" "\n\t" \
"pop r10" "\n\t" \
"pop r9" "\n\t" \
"pop r8" "\n\t" \
"pop r7" "\n\t" \
"pop r6" "\n\t" \
"pop r5" "\n\t" \
"pop r4" "\n\t" \
"pop r3" "\n\t" \
"pop r2" "\n\t" \
"pop r1" "\n\t" \
"pop r0" "\n\t" \
"out __SREG__, r0" "\n\t" \
"pop r0" "\n\t" \
:: \
)
/**
* This macro is used to define an interrupt service routine for using
* API functions from picoos.
* The macro generate the apropriated frame for that and delegates
* to an handler.
* See an example for handle a interrupt from the UART:
*
* @code
* static void handleUartRecive( void );
* static void handleUartRecive( void ) {
* posSemaSignal(semaReceive);
* }
*
* PICOOS_SIGNAL( SIG_UART_RECV, handleUartRecive )
*
* @endcode
*
* @param signalname The name of the signal for generate this frame.
*
* @param handler The function to handle the interrupt.
*
*/
#define PICOOS_SIGNAL(signame, handler) \
void signame (void) __attribute__ ((signal, naked)); \
void signame (void) { \
SAVE_CONTEXT(); \
if (posInInterrupt_g == 0) { \
posCurrentTask_g->stackptr = (void*)SP; \
SP = (uint16_t)(isrStackMem_g + ISR_STACK_SIZE -1); \
} \
c_pos_intEnter(); \
handler(); \
c_pos_intExit(); \
SP = (uint16_t)posCurrentTask_g->stackptr; \
__asm__ __volatile__("jmp interruptReturn"); \
} \
/*---------------------------------------------------------------------------
* FINDBIT - DEFINITIONS FOR GENERIC FILE fbit_gen.c
*-------------------------------------------------------------------------*/
/** @defgroup findbit Configuration: Generic Findbit
* @ingroup configp
* The pico]OS is shipped with a generic file that implements variouse
* methods for finding the first and least significant bit set.
* This section contains switches for configuring the file fbit_gen.c.
* Please see the section <b>pico]OS Porting Information</b> for details
* about findbit.
* @{
*/
/** Generic finbit configuration, look-up table support.
* The findbit mechanism can be implemented as look-up table.<br>
*
* POSCFG_FBIT_USE_LUTABLE = 0:<br>
* Do not use look up tables. "findbit" is implemented as a function.
* (This does not increase code size through tables. Also
* some CPUs may execute program code faster from their caches
* than fetching data from big lookup tables.)
* Note: This is the only possible setting for
* systems with ::MVAR_BITS != 8 <br>
*
* POSCFG_FBIT_USE_LUTABLE = 1:<br>
* - When round robin scheduling is disabled, findbit is done
* by use of a 256 byte sized lookup table.
* - When round robin scheduling is enabled, findbit is implemented
* as a function and uses a 256 byte sized lookup table.<br>
*
* POSCFG_FBIT_USE_LUTABLE = 2:<br>
* This is only applicable for round robin scheduling.
* "findbit" is implemented as a two dimensional lookup table.
* This blows code size very much.
*/
#define POSCFG_FBIT_USE_LUTABLE 0
/** Generic finbit configuration, machine bit-shift ability.
* Some machines are very slow in doing bit-shifts. If your
* target is such a machine, you can define this parameter to
* zero to prevent findbit of doing excessive bitshifts.
*/
#define POSCFG_FBIT_BITSHIFT 1
/** @} */
/*---------------------------------------------------------------------------
* PORT DEPENDENT NANO LAYER CONFIGURATION
*-------------------------------------------------------------------------*/
/** @defgroup portnlcfg Configuration: Nano Layer Port
* @ingroup configp
* This section is used to configure port dependent
* settings for the nano layer. (file port.h)
* @{
*/
/** Set the direction the stack grows.
* When the processor stack grows from bottom to top, this define
* must be set to 1. On platforms where the stack grows from
* top to bottom, this define must be set to 0.
*/
#define NOSCFG_STACK_GROWS_UP 0
/** Set the default stack size.
* If the functions ::nosTaskCreate or ::nosInit are called with
* a stack size of zero, this value is taken as the default stack size.
*/
#define NOSCFG_DEFAULT_STACKSIZE 64
// 128
/** Enable generic console output handshake.
* Please see description of function ::c_nos_putcharReady for details.
*/
#define NOSCFG_CONOUT_HANDSHAKE 0
/** Set the size of the console output FIFO.
* If ::NOSCFG_CONOUT_HANDSHAKE is enabled, a FIFO buffer can be used
* to speed up console output and to reduce CPU usage. This option is
* useful when console output is done through a serial line that does
* not have a hardware FIFO. To enable the FIFO, set this define to
* the FIFO size in bytes. A zero will disable the FIFO buffer.
*/
#define NOSCFG_CONOUT_FIFOSIZE 20
/** @} */
/*---------------------------------------------------------------------------
* USER DEFINED CONTENT OF TASK ENVIRONMENT
*-------------------------------------------------------------------------*/
#if (DOX!=0)
/** @def POS_USERTASKDATA
* Add user defined data elements to the global task structure.
* Please see detailed description of ::POSTASK_t.
* @sa POSTASK_t
*/
#define POS_USERTASKDATA void *stackptr;
#else
/* Here is an example for different memory handling types:
*/
#if (POSCFG_TASKSTACKTYPE == 0)
#define POS_USERTASKDATA \
void *stackptr;
#elif (POSCFG_TASKSTACKTYPE == 1)
#define POS_USERTASKDATA \
void *stackptr; \
void *stackroot;
#elif (POSCFG_TASKSTACKTYPE == 2)
/* context switch (stack frame): 35 bytes
* os (call depth) 4*2 : 8 bytes
* runtime lib + application : 20 + 20 = 40 bytes
* sum = 128
*/
#define FIXED_STACK_SIZE 0x80
#define POS_USERTASKDATA \
void *stackptr; \
unsigned char stack[FIXED_STACK_SIZE];
#endif
#endif /* DOX */
#endif /* _PORT_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -