📄 os_cpu.h
字号:
/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
*
* (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
* All Rights Reserved
*
* V850 Specific code
* NORMAL MEMORY MODEL (Code <2MB)
*
* File : OS_CPU.H
* By : Jean J. Labrosse
*********************************************************************************************************
*/
#ifdef OS_CPU_GLOBALS
#define OS_CPU_EXT
#else
#define OS_CPU_EXT extern
#endif
/*
*********************************************************************************************************
* DATA TYPES
* (Compiler Specific)
*********************************************************************************************************
*/
typedef unsigned char BOOLEAN;
typedef unsigned char INT8U; /* Unsigned 8 bit quantity */
typedef signed char INT8S; /* Signed 8 bit quantity */
typedef unsigned short INT16U; /* Unsigned 16 bit quantity */
typedef signed short INT16S; /* Signed 16 bit quantity */
typedef unsigned long INT32U; /* Unsigned 32 bit quantity */
typedef signed long INT32S; /* Signed 32 bit quantity */
typedef float FP32; /* Single precision floating point */
typedef double FP64; /* Double precision floating point */
typedef unsigned int OS_STK; /* Each stack entry is 32-bit wide */
typedef volatile unsigned long OS_CPU_SR;
#define BYTE INT8S /* Define data types for backward compatibility ... */
#define UBYTE INT8U /* ... to uC/OS V1.xx. Not actually needed for ... */
#define WORD INT16S /* ... uC/OS-II. */
#define UWORD INT16U
#define LONG INT32S
#define ULONG INT32U
/*
*********************************************************************************************************
* NEC V850 port
*
* Method #1: Disable/Enable interrupts using simple instructions. After critical section, interrupts
* will be enabled even if they were disabled before entering the critical section. You MUST
* change the constant in OS_CPU_A.ASM, function OSIntCtxSw() from 10 to 8.
*
* Method #2: Disable/Enable interrupts by preserving the state of interrupts. In other words, if
* interrupts were disabled before entering the critical section, they will be disabled when
* leaving the critical section. You MUST change the constant in OS_CPU_A.ASM, function
* OSIntCtxSw() from 8 to 10.
*
* Method #3: Save SR in local function register. Only this method works reliably for now.
*********************************************************************************************************
*/
#define OS_CRITICAL_METHOD 3 /* The other two methods appear to have trouble! */
#if OS_CRITICAL_METHOD == 1
#define OS_ENTER_CRITICAL() asm("DI") /* Disable interrupts */
#define OS_EXIT_CRITICAL() asm("EI") /* Enable interrupts */
#endif
/* The following code saves the interrupt status before return. */
/* I should find a more efficient way to store the previous bit flag either on the stack or in register */
/* R17 is never used by the IAR compiler (Six registers locked), but check if we use correct compiler */
#ifndef __ICCV850__
#error You are not using IAR compiler! Register R22 is used by rtos and IAR (Six registers locked) does not touch it!!
#endif
#if OS_CRITICAL_METHOD == 2 /* Minimum pointer movement is 2 bytes */
#define OS_ENTER_CRITICAL() asm("prepare {r22}, 0"); asm("stsr psw, r22"); asm("di"); /* Disable interrupts */
#define OS_EXIT_CRITICAL() asm("ldsr r22, psw"); asm("dispose 0, {r22}"); /* Enable interrupts */
#endif
#if OS_CRITICAL_METHOD == 3
#include "intrv850.h"
#define OS_ENTER_CRITICAL() cpu_sr=__get_processor_register(Reg_PSW);__DI(); /* Disable interrupts */
#define OS_EXIT_CRITICAL() __set_processor_register(Reg_PSW,cpu_sr) /* Enable interrupts */
#endif
/*
*********************************************************************************************************
* Miscellaneous
*********************************************************************************************************
*/
#define OS_STK_GROWTH 1 /* Stack grows from HIGH to LOW memory */
#define OS_TASK_SW() asm("TRAP 0x10") /* Interrupt vector # used for context switch */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -