avr_chen 发表于 2009-9-26 20:55:24

ucosii高手请进,紧急求助

!E C:/icc/include/os_cpu.h(27): redeclaration of `BOOLEAN'
!E C:/icc/include/os_cpu.h(28): redeclaration of `INT8U'
!E C:/icc/include/os_cpu.h(28): redeclaration of `INT8U'
!E C:/icc/include/os_cpu.h(30): redeclaration of `INT16U'
!E C:/icc/include/os_cpu.h(31): redeclaration of `INT16S'
!E C:/icc/include/os_cpu.h(32): redeclaration of `INT32U'
!E C:/icc/include/os_cpu.h(33): redeclaration of `INT32S'
!E C:/icc/include/os_cpu.h(34): redeclaration of `FP32'
!E C:/icc/include/os_cpu.h(36): redeclaration of `OS_STK'
!E C:/icc/include/os_cpu.h(37): redeclaration of `OS_CPU_SR'
C:\icc\bin\imakew.exe: Error code 1
Done: there are error(s). Exit code: 1


我编译的时候编译器报这样的错误,我不知道怎么回事。哪位能不能指点一下啊 。觉得很奇怪。谢谢,使用的是ICCAVR的编译器,用的是从本网站上下载的实例代码ucosii_m128_iccavr。谢谢。

Zwill 发表于 2009-9-26 21:00:07

OS_CPU.h你的数据类型重定义了

avr_chen 发表于 2009-9-26 21:04:26

谢谢楼上的Zwill 的回复
您说的重定义是什么意思啊
整个源文件是这样的OS_CPU.H   您能不能帮我看看啊谢谢
/*
*********************************************************************************************************
*                                             uC/OS-II
*                                       The Real-Time Kernel
*
*                                       ATmega128 Specific code
*
* File   : OS_CPU.H
* By       : Ole Saether
*            Jean J. Labrosse
*********************************************************************************************************
*/

#ifdefOS_CPU_GLOBALS
#define OS_CPU_EXT
#else
#define OS_CPU_EXTextern
#endif

/*
**********************************************************************************************************
*                                              DATA TYPES
*                                       (Compiler Specific)
**********************************************************************************************************
*/

typedef unsigned charBOOLEAN;
typedef unsigned charINT8U;                  /* Unsigned8 bit quantity                            */
typedef signed   charINT8S;                  /* Signed    8 bit quantity                            */
typedef unsigned int   INT16U;                   /* Unsigned 16 bit quantity                            */
typedef signed   int   INT16S;                   /* Signed   16 bit quantity                            */
typedef unsigned longINT32U;                   /* Unsigned 32 bit quantity                            */
typedef signed   longINT32S;                   /* Signed   32 bit quantity                            */
typedef float          FP32;                     /* Single precision floating point                     */

typedef unsigned charOS_STK;                   /* Each stack entry is 8-bit wide                      */
typedef unsigned charOS_CPU_SR;                /* Define size of CPU status register (PSW = 8 bits)   */

/*
*********************************************************************************************************
*                                             Atmel AVR
*
* 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.
*
* 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. The IAR compiler does not support inline assembly so I'm
*             using the _OPC() intrinsic function. Here are the instructions:
*
*             OS_ENTER_CRITICAL:
*               ST      -Y,R16
*               IN      R16,SREG
*               CLI
*               PUSH    R16
*               LD      R16,Y+
*
*             OS_EXIT_CRITICAL:
*               ST      -Y,R16
*               POP   R16
*               OUT   SREG,R16
*               LD      R16,Y+
*
* Method #3:Disable/Enable interrupts by preserving the state of interrupts.Generally speaking you
*             would store the state of the interrupt disable flag in the local variable 'cpu_sr' and then
*             disable interrupts.'cpu_sr' is allocated in all of uC/OS-II's functions that need to
*             disable interrupts.You would restore the interrupt disable state by copying back 'cpu_sr'
*             into the CPU's status register.
*********************************************************************************************************
*/

#defineOS_CRITICAL_METHOD    3


#if      OS_CRITICAL_METHOD == 3
#defineOS_ENTER_CRITICAL()(cpu_sr = OS_CPU_SR_Save()) /* Disable interrupts                        */
#defineOS_EXIT_CRITICAL()   (OS_CPU_SR_Restore(cpu_sr)) /* Enableinterrupts                        */
#endif

/*
**********************************************************************************************************
*                                          AVR Miscellaneous
**********************************************************************************************************
*/

#defineOS_STK_GROWTH      1                     /* Stack grows from HIGH to LOW memory on AVR       */

#defineOS_TASK_SW()       OSCtxSw()

/*
**********************************************************************************************************
*                                          GLOBAL VARIABLES
**********************************************************************************************************
*/

OS_CPU_EXTINT16UOSTaskStkSize;                  /* Used to set the total stack size of a task       */
OS_CPU_EXTINT16UOSTaskHardStkSize;            /* Used to set the hardware stack size of a task    */

/*
**********************************************************************************************************
*                                       Function Prototypes
**********************************************************************************************************
*/

#if OS_CRITICAL_METHOD == 3
OS_CPU_SROS_CPU_SR_Save(void);
void       OS_CPU_SR_Restore(OS_CPU_SR cpu_sr);
#endif

void       OSTickISR_Init(void);
void       OSTickISR_Handler(void);

Zwill 发表于 2009-9-27 00:11:34

你看看有没有其他地方定义过那几个数据类型,估计是某个头文件定义过数据类型了,AVR的没做过,我的是ARM7的板

yangsen 发表于 2009-9-27 08:32:40

估计头文件重复包含造成的。LZ可能把所有的.C文件加到工程里了,我记得好像只要加一个ucos.C就行了,这个文件把所有的.C文件都包含进去了。

avr_chen 发表于 2009-9-27 19:45:01

谢谢两位的回复
我自己检查了一下,重复定义应该是没有,应该是头文件重复包含了
可ucos-ii这么多头文件,要怎么来组织呢,我是新手,以前做的项目都没几个文件,现在用rtos,文件这么多,我有点头晕。呵呵。
ucos-ii整个文件是什么样的结构,包括.C和.H,能不能讲解一下。谢谢。

ralfak 发表于 2009-10-13 00:40:20

ucos-ii很多代码
但头文件只有一个就是ucos_ii.h
每个内核源文件都有include ucos_ii.h
既有变量定义又有变量声明
其中的奥妙就在下面的这段条件编译
#ifdefOS_CPU_GLOBALS
#define OS_CPU_EXT
#else
#define OS_CPU_EXTextern
#endif

sugarxyc 发表于 2009-11-14 08:16:29

帅哥,你说得太好了
页: [1]
查看完整版本: ucosii高手请进,紧急求助